@lifi/widget 4.1.0 → 4.3.0
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/dist/esm/AppDefault.js +14 -0
- package/dist/esm/AppDefault.js.map +1 -1
- package/dist/esm/components/AmountInput/AmountInput.js +2 -1
- package/dist/esm/components/AmountInput/AmountInput.js.map +1 -1
- package/dist/esm/components/AmountInput/AmountInputEndAdornment.js +4 -2
- package/dist/esm/components/AmountInput/AmountInputEndAdornment.js.map +1 -1
- package/dist/esm/components/AmountInput/AmountInputEndAdornment.style.js +1 -1
- package/dist/esm/components/AmountInput/AmountInputEndAdornment.style.js.map +1 -1
- package/dist/esm/components/AmountInput/PriceFormHelperText.js +4 -2
- package/dist/esm/components/AmountInput/PriceFormHelperText.js.map +1 -1
- package/dist/esm/components/AmountInputCard/AmountInputCard.style.js +98 -0
- package/dist/esm/components/AmountInputCard/AmountInputCard.style.js.map +1 -0
- package/dist/esm/components/AmountInputCard/AmountInputCardPair.js +25 -0
- package/dist/esm/components/AmountInputCard/AmountInputCardPair.js.map +1 -0
- package/dist/esm/components/AmountInputCard/BalanceDisplay.js +35 -0
- package/dist/esm/components/AmountInputCard/BalanceDisplay.js.map +1 -0
- package/dist/esm/components/AmountInputCard/BalanceDisplay.style.js +11 -0
- package/dist/esm/components/AmountInputCard/BalanceDisplay.style.js.map +1 -0
- package/dist/esm/components/AmountInputCard/FiatValueToggle.js +41 -0
- package/dist/esm/components/AmountInputCard/FiatValueToggle.js.map +1 -0
- package/dist/esm/components/AmountInputCard/PercentageChips.js +80 -0
- package/dist/esm/components/AmountInputCard/PercentageChips.js.map +1 -0
- package/dist/esm/components/AmountInputCard/PercentageChips.style.js +43 -0
- package/dist/esm/components/AmountInputCard/PercentageChips.style.js.map +1 -0
- package/dist/esm/components/AmountInputCard/ReceiveAmountCard.js +137 -0
- package/dist/esm/components/AmountInputCard/ReceiveAmountCard.js.map +1 -0
- package/dist/esm/components/AmountInputCard/SendAmountCard.js +102 -0
- package/dist/esm/components/AmountInputCard/SendAmountCard.js.map +1 -0
- package/dist/esm/components/Avatar/Avatar.js +12 -3
- package/dist/esm/components/Avatar/Avatar.js.map +1 -1
- package/dist/esm/components/Chains/VirtualizedChainList.js +2 -1
- package/dist/esm/components/Chains/VirtualizedChainList.js.map +1 -1
- package/dist/esm/components/Header/HeaderNavigationTabs.js +14 -1
- package/dist/esm/components/Header/HeaderNavigationTabs.js.map +1 -1
- package/dist/esm/components/IconCircle/IconCircle.style.js +1 -1
- package/dist/esm/components/LimitOrderSettings/LimitOrderSettings.js +99 -0
- package/dist/esm/components/LimitOrderSettings/LimitOrderSettings.js.map +1 -0
- package/dist/esm/components/LimitOrderSettings/LimitOrderSettings.style.js +52 -0
- package/dist/esm/components/LimitOrderSettings/LimitOrderSettings.style.js.map +1 -0
- package/dist/esm/components/LimitPriceCard/LimitPriceCard.js +115 -0
- package/dist/esm/components/LimitPriceCard/LimitPriceCard.js.map +1 -0
- package/dist/esm/components/LimitPriceCard/LimitPriceCard.style.js +89 -0
- package/dist/esm/components/LimitPriceCard/LimitPriceCard.style.js.map +1 -0
- package/dist/esm/components/LimitPriceCard/LimitPricePresets.js +91 -0
- package/dist/esm/components/LimitPriceCard/LimitPricePresets.js.map +1 -0
- package/dist/esm/components/RouteCard/RouteProviderCard.js +118 -0
- package/dist/esm/components/RouteCard/RouteProviderCard.js.map +1 -0
- package/dist/esm/components/Routes/LimitOrderRoutes.js +34 -0
- package/dist/esm/components/Routes/LimitOrderRoutes.js.map +1 -0
- package/dist/esm/components/Routes/Routes.js +2 -2
- package/dist/esm/components/Routes/Routes.js.map +1 -1
- package/dist/esm/components/SettingsPanel/SettingsPanel.js +51 -0
- package/dist/esm/components/SettingsPanel/SettingsPanel.js.map +1 -0
- package/dist/esm/components/SettingsPanel/SettingsPanel.style.js +33 -0
- package/dist/esm/components/SettingsPanel/SettingsPanel.style.js.map +1 -0
- package/dist/esm/components/SettingsPanel/utils.js +14 -0
- package/dist/esm/components/SettingsPanel/utils.js.map +1 -0
- package/dist/esm/components/SwapButton/SwapButton.js +50 -0
- package/dist/esm/components/SwapButton/SwapButton.js.map +1 -0
- package/dist/esm/components/SwapButton/SwapButton.style.js +24 -0
- package/dist/esm/components/SwapButton/SwapButton.style.js.map +1 -0
- package/dist/esm/components/TokenPillButton/TokenPillButton.js +52 -0
- package/dist/esm/components/TokenPillButton/TokenPillButton.js.map +1 -0
- package/dist/esm/components/TokenPillButton/TokenPillButton.style.js +39 -0
- package/dist/esm/components/TokenPillButton/TokenPillButton.style.js.map +1 -0
- package/dist/esm/config/version.d.ts +1 -1
- package/dist/esm/config/version.js +1 -1
- package/dist/esm/config/version.js.map +1 -1
- package/dist/esm/hooks/useChainSearch.js +2 -1
- package/dist/esm/hooks/useChainSearch.js.map +1 -1
- package/dist/esm/hooks/useFilteredByTokenBalances.js +4 -1
- package/dist/esm/hooks/useFilteredByTokenBalances.js.map +1 -1
- package/dist/esm/hooks/useLimitMarketRate.js +24 -0
- package/dist/esm/hooks/useLimitMarketRate.js.map +1 -0
- package/dist/esm/hooks/useLinkedLimitFields.js +49 -0
- package/dist/esm/hooks/useLinkedLimitFields.js.map +1 -0
- package/dist/esm/hooks/useRoutes.js +23 -6
- package/dist/esm/hooks/useRoutes.js.map +1 -1
- package/dist/esm/hooks/useTokens.js +16 -14
- package/dist/esm/hooks/useTokens.js.map +1 -1
- package/dist/esm/hooks/useWideVariant.js +5 -2
- package/dist/esm/hooks/useWideVariant.js.map +1 -1
- package/dist/esm/i18n/en.json +22 -0
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/pages/MainPage/LimitPageContent.js +23 -0
- package/dist/esm/pages/MainPage/LimitPageContent.js.map +1 -0
- package/dist/esm/pages/MainPage/MainPage.js +19 -22
- package/dist/esm/pages/MainPage/MainPage.js.map +1 -1
- package/dist/esm/pages/MainPage/MainPageActions.js +28 -0
- package/dist/esm/pages/MainPage/MainPageActions.js.map +1 -0
- package/dist/esm/pages/MainPage/ReviewButton.js +9 -2
- package/dist/esm/pages/MainPage/ReviewButton.js.map +1 -1
- package/dist/esm/pages/RoutePriorityPage.js +48 -0
- package/dist/esm/pages/RoutePriorityPage.js.map +1 -0
- package/dist/esm/pages/SettingsPage/BridgeAndExchangeSettings.js +2 -2
- package/dist/esm/pages/SettingsPage/BridgeAndExchangeSettings.js.map +1 -1
- package/dist/esm/pages/SettingsPage/RoutePrioritySettings.js +12 -27
- package/dist/esm/pages/SettingsPage/RoutePrioritySettings.js.map +1 -1
- package/dist/esm/pages/SettingsPage/SlippageSettings/SlippagePage.js +133 -0
- package/dist/esm/pages/SettingsPage/SlippageSettings/SlippagePage.js.map +1 -0
- package/dist/esm/pages/SettingsPage/SlippageSettings/SlippageSettings.js +14 -72
- package/dist/esm/pages/SettingsPage/SlippageSettings/SlippageSettings.js.map +1 -1
- package/dist/esm/pages/SettingsPage/SlippageSettings/SlippageSettings.style.js +26 -14
- package/dist/esm/pages/SettingsPage/SlippageSettings/SlippageSettings.style.js.map +1 -1
- package/dist/esm/pages/SettingsPage/ThemeSettings.js +4 -0
- package/dist/esm/pages/SettingsPage/ThemeSettings.js.map +1 -1
- package/dist/esm/pages/TransactionPage/TransactionReview.js +4 -1
- package/dist/esm/pages/TransactionPage/TransactionReview.js.map +1 -1
- package/dist/esm/providers/I18nProvider/I18nProvider.js +1 -1
- package/dist/esm/providers/I18nProvider/enResource.d.ts +1 -1
- package/dist/esm/providers/I18nProvider/enResource.js +1 -1
- package/dist/esm/providers/I18nProvider/types.d.ts +2 -2
- package/dist/esm/providers/SDKClientProvider.js +25 -24
- package/dist/esm/providers/SDKClientProvider.js.map +1 -1
- package/dist/esm/providers/WidgetProvider/WidgetProvider.js +22 -21
- package/dist/esm/providers/WidgetProvider/WidgetProvider.js.map +1 -1
- package/dist/esm/stores/form/URLSearchParamsBuilder.js +14 -3
- package/dist/esm/stores/form/URLSearchParamsBuilder.js.map +1 -1
- package/dist/esm/stores/form/createFormStore.js +6 -2
- package/dist/esm/stores/form/createFormStore.js.map +1 -1
- package/dist/esm/stores/form/getDefaultValuesFromQueryString.js +3 -0
- package/dist/esm/stores/form/getDefaultValuesFromQueryString.js.map +1 -1
- package/dist/esm/stores/form/types.d.ts +9 -1
- package/dist/esm/stores/form/types.d.ts.map +1 -1
- package/dist/esm/stores/form/types.js.map +1 -1
- package/dist/esm/stores/form/useClearAmountFields.js +1 -0
- package/dist/esm/stores/form/useClearAmountFields.js.map +1 -1
- package/dist/esm/stores/navigationTabs/useNavigationTabsStore.js +4 -2
- package/dist/esm/stores/navigationTabs/useNavigationTabsStore.js.map +1 -1
- package/dist/esm/stores/navigationTabs/utils.js +38 -8
- package/dist/esm/stores/navigationTabs/utils.js.map +1 -1
- package/dist/esm/types/events.d.ts +10 -1
- package/dist/esm/types/events.d.ts.map +1 -1
- package/dist/esm/types/events.js +2 -0
- package/dist/esm/types/events.js.map +1 -1
- package/dist/esm/types/widget.d.ts +10 -0
- package/dist/esm/types/widget.d.ts.map +1 -1
- package/dist/esm/types/widget.js.map +1 -1
- package/dist/esm/utils/format.d.ts +1 -1
- package/dist/esm/utils/format.d.ts.map +1 -1
- package/dist/esm/utils/format.js +2 -2
- package/dist/esm/utils/format.js.map +1 -1
- package/dist/esm/utils/limitOrder.js +61 -0
- package/dist/esm/utils/limitOrder.js.map +1 -0
- package/dist/esm/utils/navigationRoutes.d.ts +2 -0
- package/dist/esm/utils/navigationRoutes.d.ts.map +1 -1
- package/dist/esm/utils/navigationRoutes.js +6 -0
- package/dist/esm/utils/navigationRoutes.js.map +1 -1
- package/dist/esm/utils/token.js +38 -3
- package/dist/esm/utils/token.js.map +1 -1
- package/package.json +11 -11
- package/src/AppDefault.tsx +16 -0
- package/src/components/AmountInput/AmountInputEndAdornment.style.ts +1 -1
- package/src/components/AmountInput/AmountInputEndAdornment.tsx +5 -2
- package/src/components/AmountInputCard/AmountInputCard.style.tsx +157 -0
- package/src/components/AmountInputCard/AmountInputCardPair.tsx +25 -0
- package/src/components/AmountInputCard/BalanceDisplay.style.tsx +9 -0
- package/src/components/AmountInputCard/BalanceDisplay.tsx +46 -0
- package/src/components/AmountInputCard/FiatValueToggle.tsx +55 -0
- package/src/components/AmountInputCard/PercentageChips.style.tsx +60 -0
- package/src/components/AmountInputCard/PercentageChips.tsx +100 -0
- package/src/components/AmountInputCard/ReceiveAmountCard.tsx +219 -0
- package/src/components/AmountInputCard/SendAmountCard.tsx +179 -0
- package/src/components/Avatar/Avatar.tsx +8 -3
- package/src/components/Header/HeaderNavigationTabs.tsx +19 -2
- package/src/components/LimitOrderSettings/LimitOrderSettings.style.tsx +69 -0
- package/src/components/LimitOrderSettings/LimitOrderSettings.tsx +124 -0
- package/src/components/LimitPriceCard/LimitPriceCard.style.tsx +103 -0
- package/src/components/LimitPriceCard/LimitPriceCard.tsx +153 -0
- package/src/components/LimitPriceCard/LimitPricePresets.tsx +139 -0
- package/src/components/RouteCard/RouteProviderCard.tsx +113 -0
- package/src/components/Routes/LimitOrderRoutes.tsx +64 -0
- package/src/components/Routes/Routes.tsx +3 -2
- package/src/components/SettingsPanel/SettingsPanel.style.tsx +41 -0
- package/src/components/SettingsPanel/SettingsPanel.tsx +73 -0
- package/src/components/SettingsPanel/utils.ts +27 -0
- package/src/components/SwapButton/SwapButton.style.tsx +28 -0
- package/src/components/SwapButton/SwapButton.tsx +71 -0
- package/src/components/TokenPillButton/TokenPillButton.style.tsx +50 -0
- package/src/components/TokenPillButton/TokenPillButton.tsx +81 -0
- package/src/config/version.ts +1 -1
- package/src/hooks/useFilteredByTokenBalances.ts +7 -2
- package/src/hooks/useLimitMarketRate.ts +39 -0
- package/src/hooks/useLinkedLimitFields.ts +74 -0
- package/src/hooks/useRoutes.ts +45 -4
- package/src/hooks/useWideVariant.ts +8 -2
- package/src/pages/MainPage/LimitPageContent.tsx +18 -0
- package/src/pages/MainPage/MainPage.tsx +43 -30
- package/src/pages/MainPage/MainPageActions.tsx +35 -0
- package/src/pages/MainPage/ReviewButton.tsx +13 -1
- package/src/pages/RoutePriorityPage.tsx +55 -0
- package/src/pages/SettingsPage/RoutePrioritySettings.tsx +14 -38
- package/src/pages/SettingsPage/SlippageSettings/SlippagePage.tsx +176 -0
- package/src/pages/SettingsPage/SlippageSettings/SlippageSettings.style.tsx +32 -25
- package/src/pages/SettingsPage/SlippageSettings/SlippageSettings.tsx +14 -128
- package/src/pages/SettingsPage/ThemeSettings.tsx +4 -0
- package/src/stores/form/URLSearchParamsBuilder.tsx +25 -3
- package/src/stores/form/createFormStore.ts +7 -3
- package/src/stores/form/getDefaultValuesFromQueryString.ts +11 -0
- package/src/stores/form/types.ts +14 -1
- package/src/stores/form/useClearAmountFields.ts +1 -0
- package/src/stores/navigationTabs/types.ts +6 -0
- package/src/stores/navigationTabs/useNavigationTabsStore.tsx +8 -3
- package/src/stores/navigationTabs/utils.ts +67 -5
- package/src/types/events.ts +12 -0
- package/src/types/widget.ts +10 -0
- package/src/utils/format.ts +6 -2
- package/src/utils/limitOrder.ts +88 -0
- package/src/utils/navigationRoutes.ts +6 -0
- package/src/utils/token.ts +71 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MainPage.js","names":[],"sources":["../../../../src/pages/MainPage/MainPage.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"MainPage.js","names":[],"sources":["../../../../src/pages/MainPage/MainPage.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { AmountInput } from '../../components/AmountInput/AmountInput.js'\nimport { AmountInputCardPair } from '../../components/AmountInputCard/AmountInputCardPair.js'\nimport { ContractComponent } from '../../components/ContractComponent/ContractComponent.js'\nimport { GasRefuelMessage } from '../../components/Messages/GasRefuelMessage.js'\nimport { PageContainer } from '../../components/PageContainer.js'\nimport { Routes } from '../../components/Routes/Routes.js'\nimport { SelectChainAndToken } from '../../components/SelectChainAndToken.js'\nimport { SendToWalletButton } from '../../components/SendToWallet/SendToWalletButton.js'\nimport { SettingsPanel } from '../../components/SettingsPanel/SettingsPanel.js'\nimport { advancedNavigationTabKeys } from '../../components/SettingsPanel/utils.js'\nimport { useHeader } from '../../hooks/useHeader.js'\nimport { useWideVariant } from '../../hooks/useWideVariant.js'\nimport { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js'\nimport { useNavigationTabsStore } from '../../stores/navigationTabs/useNavigationTabsStore.js'\nimport { LimitPageContent } from './LimitPageContent.js'\nimport { MainPageActions } from './MainPageActions.js'\n\nconst marginSx = { marginBottom: 2 }\n\nexport const MainPage: React.FC = () => {\n const { t } = useTranslation()\n const wideVariant = useWideVariant()\n const { mode, modeOptions, contractComponent, hiddenUI, defaultUI } =\n useWidgetConfig()\n const activeTab = useNavigationTabsStore((state) => state.activeTab)\n\n const custom = mode === 'custom'\n // Surface the settings panel on the main page for advanced navigation tabs.\n const advancedMode =\n !!activeTab && advancedNavigationTabKeys.includes(activeTab)\n const showSendReceiveCards = defaultUI?.layout === 'cards'\n // Custom non-deposit contract flows have no amount entry — they keep the\n // chain/token selectors only, in both layouts.\n const showAmountEntry = !custom || modeOptions?.custom?.type === 'deposit'\n const showGasRefuelMessage = !hiddenUI?.gasRefuelMessage\n\n const splitTitle =\n modeOptions?.split === 'bridge'\n ? t('header.bridge')\n : modeOptions?.split === 'swap'\n ? t('header.swap')\n : undefined\n const title =\n mode === 'limit'\n ? t('header.limit')\n : mode === 'custom'\n ? t(`header.${modeOptions?.custom?.type ?? 'checkout'}`)\n : mode === 'refuel'\n ? t('header.gas')\n : mode === 'split' && splitTitle\n ? splitTitle\n : t('header.exchange')\n\n useHeader(title)\n\n if (mode === 'limit') {\n return <LimitPageContent />\n }\n\n return (\n <PageContainer topGutters>\n {custom ? (\n <ContractComponent sx={marginSx}>{contractComponent}</ContractComponent>\n ) : null}\n {showSendReceiveCards && showAmountEntry ? (\n <AmountInputCardPair sx={marginSx} />\n ) : (\n <>\n <SelectChainAndToken sx={marginSx} />\n {!showSendReceiveCards && showAmountEntry ? (\n <AmountInput formType=\"from\" sx={marginSx} />\n ) : null}\n </>\n )}\n {advancedMode ? <SettingsPanel sx={marginSx} /> : null}\n {!wideVariant ? <Routes sx={marginSx} /> : null}\n <SendToWalletButton sx={marginSx} />\n {showGasRefuelMessage ? <GasRefuelMessage sx={marginSx} /> : null}\n <MainPageActions showSendToWalletExpand />\n </PageContainer>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBA,MAAM,WAAW,EAAE,cAAc,EAAE;AAEnC,MAAa,iBAA2B;CACtC,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,cAAc,eAAe;CACnC,MAAM,EAAE,MAAM,aAAa,mBAAmB,UAAU,cACtD,gBAAgB;CAClB,MAAM,YAAY,wBAAwB,UAAU,MAAM,SAAS;CAEnE,MAAM,SAAS,SAAS;CAExB,MAAM,eACJ,CAAC,CAAC,aAAa,0BAA0B,SAAS,SAAS;CAC7D,MAAM,uBAAuB,WAAW,WAAW;CAGnD,MAAM,kBAAkB,CAAC,UAAU,aAAa,QAAQ,SAAS;CACjE,MAAM,uBAAuB,CAAC,UAAU;CAExC,MAAM,aACJ,aAAa,UAAU,WACnB,EAAE,eAAe,IACjB,aAAa,UAAU,SACrB,EAAE,aAAa,IACf,KAAA;CAYR,UAVE,SAAS,UACL,EAAE,cAAc,IAChB,SAAS,WACP,EAAE,UAAU,aAAa,QAAQ,QAAQ,YAAY,IACrD,SAAS,WACP,EAAE,YAAY,IACd,SAAS,WAAW,aAClB,aACA,EAAE,iBAAiB,CAEhB;CAEf,IAAI,SAAS,SACX,OAAO,oBAAC,kBAAD,CAAmB,CAAA;CAG5B,OACE,qBAAC,eAAD;EAAe,YAAA;YAAf;GACG,SACC,oBAAC,mBAAD;IAAmB,IAAI;cAAW;GAAqC,CAAA,IACrE;GACH,wBAAwB,kBACvB,oBAAC,qBAAD,EAAqB,IAAI,SAAW,CAAA,IAEpC,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,qBAAD,EAAqB,IAAI,SAAW,CAAA,GACnC,CAAC,wBAAwB,kBACxB,oBAAC,aAAD;IAAa,UAAS;IAAO,IAAI;GAAW,CAAA,IAC1C,IACJ,EAAA,CAAA;GAEH,eAAe,oBAAC,eAAD,EAAe,IAAI,SAAW,CAAA,IAAI;GACjD,CAAC,cAAc,oBAAC,QAAD,EAAQ,IAAI,SAAW,CAAA,IAAI;GAC3C,oBAAC,oBAAD,EAAoB,IAAI,SAAW,CAAA;GAClC,uBAAuB,oBAAC,kBAAD,EAAkB,IAAI,SAAW,CAAA,IAAI;GAC7D,oBAAC,iBAAD,EAAiB,wBAAA,KAAwB,CAAA;EAC5B;;AAEnB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useWidgetConfig } from "../../providers/WidgetProvider/WidgetProvider.js";
|
|
2
|
+
import { PoweredBy } from "../../components/PoweredBy/PoweredBy.js";
|
|
3
|
+
import { SendToWalletExpandButton } from "../../components/SendToWallet/SendToWalletExpandButton.js";
|
|
4
|
+
import { MainWarningMessages } from "./MainWarningMessages.js";
|
|
5
|
+
import { ReviewButton } from "./ReviewButton.js";
|
|
6
|
+
import { Box } from "@mui/material";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
//#region src/pages/MainPage/MainPageActions.tsx
|
|
9
|
+
const marginSx = { marginBottom: 2 };
|
|
10
|
+
const MainPageActions = ({ showSendToWalletExpand }) => {
|
|
11
|
+
const { hiddenUI } = useWidgetConfig();
|
|
12
|
+
const showPoweredBy = !hiddenUI?.poweredBy;
|
|
13
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
14
|
+
/* @__PURE__ */ jsx(MainWarningMessages, { sx: marginSx }),
|
|
15
|
+
/* @__PURE__ */ jsxs(Box, {
|
|
16
|
+
sx: {
|
|
17
|
+
display: "flex",
|
|
18
|
+
mb: showPoweredBy ? 1 : 3
|
|
19
|
+
},
|
|
20
|
+
children: [/* @__PURE__ */ jsx(ReviewButton, {}), showSendToWalletExpand ? /* @__PURE__ */ jsx(SendToWalletExpandButton, {}) : null]
|
|
21
|
+
}),
|
|
22
|
+
showPoweredBy ? /* @__PURE__ */ jsx(PoweredBy, {}) : null
|
|
23
|
+
] });
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { MainPageActions };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=MainPageActions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MainPageActions.js","names":[],"sources":["../../../../src/pages/MainPage/MainPageActions.tsx"],"sourcesContent":["import { Box } from '@mui/material'\nimport { PoweredBy } from '../../components/PoweredBy/PoweredBy.js'\nimport { SendToWalletExpandButton } from '../../components/SendToWallet/SendToWalletExpandButton.js'\nimport { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js'\nimport { MainWarningMessages } from './MainWarningMessages.js'\nimport { ReviewButton } from './ReviewButton.js'\n\ninterface MainPageActionsProps {\n showSendToWalletExpand?: boolean\n}\n\nconst marginSx = { marginBottom: 2 }\n\nexport const MainPageActions: React.FC<MainPageActionsProps> = ({\n showSendToWalletExpand,\n}) => {\n const { hiddenUI } = useWidgetConfig()\n const showPoweredBy = !hiddenUI?.poweredBy\n\n return (\n <>\n <MainWarningMessages sx={marginSx} />\n <Box\n sx={{\n display: 'flex',\n mb: showPoweredBy ? 1 : 3,\n }}\n >\n <ReviewButton />\n {showSendToWalletExpand ? <SendToWalletExpandButton /> : null}\n </Box>\n {showPoweredBy ? <PoweredBy /> : null}\n </>\n )\n}\n"],"mappings":";;;;;;;;AAWA,MAAM,WAAW,EAAE,cAAc,EAAE;AAEnC,MAAa,mBAAmD,EAC9D,6BACI;CACJ,MAAM,EAAE,aAAa,gBAAgB;CACrC,MAAM,gBAAgB,CAAC,UAAU;CAEjC,OACE,qBAAA,UAAA,EAAA,UAAA;EACE,oBAAC,qBAAD,EAAqB,IAAI,SAAW,CAAA;EACpC,qBAAC,KAAD;GACE,IAAI;IACF,SAAS;IACT,IAAI,gBAAgB,IAAI;GAC1B;aAJF,CAME,oBAAC,cAAD,CAAe,CAAA,GACd,yBAAyB,oBAAC,0BAAD,CAA2B,CAAA,IAAI,IACtD;;EACJ,gBAAgB,oBAAC,WAAD,CAAY,CAAA,IAAI;CACjC,EAAA,CAAA;AAEN"}
|
|
@@ -3,6 +3,7 @@ import "../../types/events.js";
|
|
|
3
3
|
import { useWidgetConfig } from "../../providers/WidgetProvider/WidgetProvider.js";
|
|
4
4
|
import { navigationRoutes } from "../../utils/navigationRoutes.js";
|
|
5
5
|
import { useSplitMode } from "../../stores/navigationTabs/useNavigationTabsStore.js";
|
|
6
|
+
import { useFieldValues } from "../../stores/form/useFieldValues.js";
|
|
6
7
|
import { useRoutes } from "../../hooks/useRoutes.js";
|
|
7
8
|
import { useToAddressRequirements } from "../../hooks/useToAddressRequirements.js";
|
|
8
9
|
import { BaseTransactionButton } from "../../components/BaseTransactionButton/BaseTransactionButton.js";
|
|
@@ -18,7 +19,8 @@ const ReviewButton = () => {
|
|
|
18
19
|
const splitState = useSplitMode();
|
|
19
20
|
const { toAddress, requiredToAddress } = useToAddressRequirements();
|
|
20
21
|
const { routes, setReviewableRoute } = useRoutes();
|
|
21
|
-
const
|
|
22
|
+
const [selectedRouteId] = useFieldValues("selectedRouteId");
|
|
23
|
+
const currentRoute = (mode === "limit" ? routes?.find((route) => route.id === selectedRouteId) : void 0) ?? routes?.[0];
|
|
22
24
|
const handleClick = async () => {
|
|
23
25
|
if (!currentRoute) return;
|
|
24
26
|
setReviewableRoute(currentRoute);
|
|
@@ -35,11 +37,16 @@ const ReviewButton = () => {
|
|
|
35
37
|
if (currentRoute) switch (mode) {
|
|
36
38
|
case "custom": return t(`button.${modeOptions?.custom?.type ?? "checkout"}Review`);
|
|
37
39
|
case "refuel": return t("button.getGas");
|
|
38
|
-
|
|
40
|
+
case "limit": return t("button.review");
|
|
41
|
+
default: {
|
|
42
|
+
const transactionType = currentRoute.fromChainId === currentRoute.toChainId ? "swap" : "bridge";
|
|
43
|
+
return t(`button.${transactionType}Review`);
|
|
44
|
+
}
|
|
39
45
|
}
|
|
40
46
|
switch (mode) {
|
|
41
47
|
case "custom": return modeOptions?.custom?.type === "deposit" ? t("button.deposit") : t("button.buy");
|
|
42
48
|
case "refuel": return t("button.getGas");
|
|
49
|
+
case "limit": return t("button.review");
|
|
43
50
|
case "split":
|
|
44
51
|
if (splitState) return t(`button.${splitState}`);
|
|
45
52
|
return t("button.exchange");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReviewButton.js","names":[],"sources":["../../../../src/pages/MainPage/ReviewButton.tsx"],"sourcesContent":["import { useNavigate } from '@tanstack/react-router'\nimport { useTranslation } from 'react-i18next'\nimport { BaseTransactionButton } from '../../components/BaseTransactionButton/BaseTransactionButton.js'\nimport { useRoutes } from '../../hooks/useRoutes.js'\nimport { useToAddressRequirements } from '../../hooks/useToAddressRequirements.js'\nimport { useWidgetEvents } from '../../hooks/useWidgetEvents.js'\nimport { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js'\nimport { useSplitMode } from '../../stores/navigationTabs/useNavigationTabsStore.js'\nimport { WidgetEvent } from '../../types/events.js'\nimport { navigationRoutes } from '../../utils/navigationRoutes.js'\n\nexport const ReviewButton: React.FC = () => {\n const { t } = useTranslation()\n const navigate = useNavigate()\n const emitter = useWidgetEvents()\n const { mode, modeOptions } = useWidgetConfig()\n const splitState = useSplitMode()\n const { toAddress, requiredToAddress } = useToAddressRequirements()\n const { routes, setReviewableRoute } = useRoutes()\n\n const currentRoute
|
|
1
|
+
{"version":3,"file":"ReviewButton.js","names":[],"sources":["../../../../src/pages/MainPage/ReviewButton.tsx"],"sourcesContent":["import { useNavigate } from '@tanstack/react-router'\nimport { useTranslation } from 'react-i18next'\nimport { BaseTransactionButton } from '../../components/BaseTransactionButton/BaseTransactionButton.js'\nimport { useRoutes } from '../../hooks/useRoutes.js'\nimport { useToAddressRequirements } from '../../hooks/useToAddressRequirements.js'\nimport { useWidgetEvents } from '../../hooks/useWidgetEvents.js'\nimport { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js'\nimport { useFieldValues } from '../../stores/form/useFieldValues.js'\nimport { useSplitMode } from '../../stores/navigationTabs/useNavigationTabsStore.js'\nimport { WidgetEvent } from '../../types/events.js'\nimport { navigationRoutes } from '../../utils/navigationRoutes.js'\n\nexport const ReviewButton: React.FC = () => {\n const { t } = useTranslation()\n const navigate = useNavigate()\n const emitter = useWidgetEvents()\n const { mode, modeOptions } = useWidgetConfig()\n const splitState = useSplitMode()\n const { toAddress, requiredToAddress } = useToAddressRequirements()\n const { routes, setReviewableRoute } = useRoutes()\n const [selectedRouteId] = useFieldValues('selectedRouteId')\n\n // The provider pick only applies in limit mode (it's the only flow that sets\n // it). Honoring it in other modes would be wrong, since provider/tool keys\n // can collide across modes. Everywhere else, fall back to the best route.\n const currentRoute =\n (mode === 'limit'\n ? routes?.find((route) => route.id === selectedRouteId)\n : undefined) ?? routes?.[0]\n\n const handleClick = async () => {\n if (!currentRoute) {\n return\n }\n\n setReviewableRoute(currentRoute)\n navigate({\n to: navigationRoutes.transactionExecution,\n search: { routeId: currentRoute.id },\n })\n emitter.emit(WidgetEvent.RouteSelected, {\n route: currentRoute,\n routes: routes!,\n })\n }\n\n const getButtonText = (): string => {\n if (currentRoute) {\n switch (mode) {\n case 'custom':\n return t(`button.${modeOptions?.custom?.type ?? 'checkout'}Review`)\n case 'refuel':\n return t('button.getGas')\n case 'limit':\n return t('button.review')\n default: {\n const transactionType =\n currentRoute.fromChainId === currentRoute.toChainId\n ? 'swap'\n : 'bridge'\n return t(`button.${transactionType}Review`)\n }\n }\n }\n switch (mode) {\n case 'custom':\n return modeOptions?.custom?.type === 'deposit'\n ? t('button.deposit')\n : t('button.buy')\n case 'refuel':\n return t('button.getGas')\n case 'limit':\n return t('button.review')\n case 'split':\n if (splitState) {\n return t(`button.${splitState}`)\n }\n return t('button.exchange')\n default:\n return t('button.exchange')\n }\n }\n\n return (\n <BaseTransactionButton\n text={getButtonText()}\n onClick={handleClick}\n disabled={currentRoute && requiredToAddress && !toAddress}\n route={currentRoute}\n sx={{ flex: 1 }}\n />\n )\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,MAAa,qBAA+B;CAC1C,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,WAAW,YAAY;CAC7B,MAAM,UAAU,gBAAgB;CAChC,MAAM,EAAE,MAAM,gBAAgB,gBAAgB;CAC9C,MAAM,aAAa,aAAa;CAChC,MAAM,EAAE,WAAW,sBAAsB,yBAAyB;CAClE,MAAM,EAAE,QAAQ,uBAAuB,UAAU;CACjD,MAAM,CAAC,mBAAmB,eAAe,iBAAiB;CAK1D,MAAM,gBACH,SAAS,UACN,QAAQ,MAAM,UAAU,MAAM,OAAO,eAAe,IACpD,KAAA,MAAc,SAAS;CAE7B,MAAM,cAAc,YAAY;EAC9B,IAAI,CAAC,cACH;EAGF,mBAAmB,YAAY;EAC/B,SAAS;GACP,IAAI,iBAAiB;GACrB,QAAQ,EAAE,SAAS,aAAa,GAAG;EACrC,CAAC;EACD,QAAQ,KAAA,iBAAgC;GACtC,OAAO;GACC;EACV,CAAC;CACH;CAEA,MAAM,sBAA8B;EAClC,IAAI,cACF,QAAQ,MAAR;GACE,KAAK,UACH,OAAO,EAAE,UAAU,aAAa,QAAQ,QAAQ,WAAW,OAAO;GACpE,KAAK,UACH,OAAO,EAAE,eAAe;GAC1B,KAAK,SACH,OAAO,EAAE,eAAe;GAC1B,SAAS;IACP,MAAM,kBACJ,aAAa,gBAAgB,aAAa,YACtC,SACA;IACN,OAAO,EAAE,UAAU,gBAAgB,OAAO;GAC5C;EACF;EAEF,QAAQ,MAAR;GACE,KAAK,UACH,OAAO,aAAa,QAAQ,SAAS,YACjC,EAAE,gBAAgB,IAClB,EAAE,YAAY;GACpB,KAAK,UACH,OAAO,EAAE,eAAe;GAC1B,KAAK,SACH,OAAO,EAAE,eAAe;GAC1B,KAAK;IACH,IAAI,YACF,OAAO,EAAE,UAAU,YAAY;IAEjC,OAAO,EAAE,iBAAiB;GAC5B,SACE,OAAO,EAAE,iBAAiB;EAC9B;CACF;CAEA,OACE,oBAAC,uBAAD;EACE,MAAM,cAAc;EACpB,SAAS;EACT,UAAU,gBAAgB,qBAAqB,CAAC;EAChD,OAAO;EACP,IAAI,EAAE,MAAM,EAAE;CACf,CAAA;AAEL"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useSettingsActions } from "../stores/settings/useSettingsActions.js";
|
|
2
|
+
import { PageContainer } from "../components/PageContainer.js";
|
|
3
|
+
import { useSettings } from "../stores/settings/useSettings.js";
|
|
4
|
+
import { useHeader } from "../hooks/useHeader.js";
|
|
5
|
+
import { useListHeight } from "../hooks/useListHeight.js";
|
|
6
|
+
import { ListItemText as ListItemText$1 } from "../components/ListItemText.js";
|
|
7
|
+
import { SettingsListItemButton } from "../components/SettingsListItemButton.js";
|
|
8
|
+
import { useRef } from "react";
|
|
9
|
+
import { List } from "@mui/material";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { useTranslation } from "react-i18next";
|
|
12
|
+
import Check from "@mui/icons-material/Check";
|
|
13
|
+
//#region src/pages/RoutePriorityPage.tsx
|
|
14
|
+
const routePriorities = ["CHEAPEST", "FASTEST"];
|
|
15
|
+
const RoutePriorityPage = () => {
|
|
16
|
+
const { t } = useTranslation();
|
|
17
|
+
const { setValue } = useSettingsActions();
|
|
18
|
+
const { routePriority } = useSettings(["routePriority"]);
|
|
19
|
+
const listParentRef = useRef(null);
|
|
20
|
+
const { listHeight } = useListHeight({ listParentRef });
|
|
21
|
+
useHeader(t("settings.routePriority"));
|
|
22
|
+
return /* @__PURE__ */ jsx(PageContainer, {
|
|
23
|
+
disableGutters: true,
|
|
24
|
+
children: /* @__PURE__ */ jsx(List, {
|
|
25
|
+
className: "long-list",
|
|
26
|
+
ref: listParentRef,
|
|
27
|
+
style: {
|
|
28
|
+
height: listHeight,
|
|
29
|
+
overflow: "auto"
|
|
30
|
+
},
|
|
31
|
+
sx: { padding: 1.5 },
|
|
32
|
+
children: routePriorities.map((priority) => {
|
|
33
|
+
const key = priority.toLowerCase();
|
|
34
|
+
return /* @__PURE__ */ jsxs(SettingsListItemButton, {
|
|
35
|
+
onClick: () => setValue("routePriority", priority),
|
|
36
|
+
children: [/* @__PURE__ */ jsx(ListItemText$1, {
|
|
37
|
+
primary: t(`settings.routePriorityOptions.${key}.title`),
|
|
38
|
+
secondary: t(`settings.routePriorityOptions.${key}.description`)
|
|
39
|
+
}), routePriority === priority && /* @__PURE__ */ jsx(Check, { color: "primary" })]
|
|
40
|
+
}, priority);
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
//#endregion
|
|
46
|
+
export { RoutePriorityPage };
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=RoutePriorityPage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RoutePriorityPage.js","names":["ListItemText"],"sources":["../../../src/pages/RoutePriorityPage.tsx"],"sourcesContent":["import type { Order } from '@lifi/sdk'\nimport Check from '@mui/icons-material/Check'\nimport { List } from '@mui/material'\nimport { useRef } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { ListItemText } from '../components/ListItemText.js'\nimport { PageContainer } from '../components/PageContainer.js'\nimport { SettingsListItemButton } from '../components/SettingsListItemButton.js'\nimport { useHeader } from '../hooks/useHeader.js'\nimport { useListHeight } from '../hooks/useListHeight.js'\nimport { useSettings } from '../stores/settings/useSettings.js'\nimport { useSettingsActions } from '../stores/settings/useSettingsActions.js'\n\nconst routePriorities: Order[] = ['CHEAPEST', 'FASTEST']\n\nexport const RoutePriorityPage: React.FC = () => {\n const { t } = useTranslation()\n const { setValue } = useSettingsActions()\n const { routePriority } = useSettings(['routePriority'])\n const listParentRef = useRef<HTMLUListElement | null>(null)\n const { listHeight } = useListHeight({ listParentRef })\n\n useHeader(t('settings.routePriority'))\n\n return (\n <PageContainer disableGutters>\n <List\n className=\"long-list\"\n ref={listParentRef}\n style={{ height: listHeight, overflow: 'auto' }}\n sx={{\n padding: 1.5,\n }}\n >\n {routePriorities.map((priority) => {\n const key = priority.toLowerCase()\n return (\n <SettingsListItemButton\n key={priority}\n onClick={() => setValue('routePriority', priority)}\n >\n <ListItemText\n primary={t(`settings.routePriorityOptions.${key}.title` as any)}\n secondary={t(\n `settings.routePriorityOptions.${key}.description` as any\n )}\n />\n {routePriority === priority && <Check color=\"primary\" />}\n </SettingsListItemButton>\n )\n })}\n </List>\n </PageContainer>\n )\n}\n"],"mappings":";;;;;;;;;;;;;AAaA,MAAM,kBAA2B,CAAC,YAAY,SAAS;AAEvD,MAAa,0BAAoC;CAC/C,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,EAAE,aAAa,mBAAmB;CACxC,MAAM,EAAE,kBAAkB,YAAY,CAAC,eAAe,CAAC;CACvD,MAAM,gBAAgB,OAAgC,IAAI;CAC1D,MAAM,EAAE,eAAe,cAAc,EAAE,cAAc,CAAC;CAEtD,UAAU,EAAE,wBAAwB,CAAC;CAErC,OACE,oBAAC,eAAD;EAAe,gBAAA;YACb,oBAAC,MAAD;GACE,WAAU;GACV,KAAK;GACL,OAAO;IAAE,QAAQ;IAAY,UAAU;GAAO;GAC9C,IAAI,EACF,SAAS,IACX;aAEC,gBAAgB,KAAK,aAAa;IACjC,MAAM,MAAM,SAAS,YAAY;IACjC,OACE,qBAAC,wBAAD;KAEE,eAAe,SAAS,iBAAiB,QAAQ;eAFnD,CAIE,oBAACA,gBAAD;MACE,SAAS,EAAE,iCAAiC,IAAI,OAAc;MAC9D,WAAW,EACT,iCAAiC,IAAI,aACvC;KACD,CAAA,GACA,kBAAkB,YAAY,oBAAC,OAAD,EAAO,OAAM,UAAW,CAAA,CACjC;OAVjB,QAUiB;GAE5B,CAAC;EACG,CAAA;CACO,CAAA;AAEnB"}
|
|
@@ -7,12 +7,12 @@ import { BadgedValue } from "./SettingsCard/BadgedValue.js";
|
|
|
7
7
|
import { useNavigate } from "@tanstack/react-router";
|
|
8
8
|
import { jsx } from "react/jsx-runtime";
|
|
9
9
|
import { useTranslation } from "react-i18next";
|
|
10
|
+
import SwapHorizIcon from "@mui/icons-material/SwapHoriz";
|
|
10
11
|
import AirlineStops from "@mui/icons-material/AirlineStops";
|
|
11
|
-
import SwapHoriz from "@mui/icons-material/SwapHoriz";
|
|
12
12
|
//#region src/pages/SettingsPage/BridgeAndExchangeSettings.tsx
|
|
13
13
|
const supportedIcons = {
|
|
14
14
|
Bridges: AirlineStops,
|
|
15
|
-
Exchanges:
|
|
15
|
+
Exchanges: SwapHorizIcon
|
|
16
16
|
};
|
|
17
17
|
const BridgeAndExchangeSettings = ({ type }) => {
|
|
18
18
|
const { isBridgesChanged, isExchangesChanged } = useSettingMonitor();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BridgeAndExchangeSettings.js","names":[],"sources":["../../../../src/pages/SettingsPage/BridgeAndExchangeSettings.tsx"],"sourcesContent":["import AirlineStops from '@mui/icons-material/AirlineStops'\nimport SwapHoriz from '@mui/icons-material/SwapHoriz'\nimport { useNavigate } from '@tanstack/react-router'\nimport { useTranslation } from 'react-i18next'\nimport { CardButton } from '../../components/Card/CardButton.js'\nimport { useSettingMonitor } from '../../hooks/useSettingMonitor.js'\nimport { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js'\nimport { useSettingsStore } from '../../stores/settings/SettingsStore.js'\nimport { navigationRoutes } from '../../utils/navigationRoutes.js'\nimport { BadgedValue } from './SettingsCard/BadgedValue.js'\n\nconst supportedIcons = {\n Bridges: AirlineStops,\n Exchanges: SwapHoriz,\n}\n\nexport const BridgeAndExchangeSettings: React.FC<{\n type: 'Bridges' | 'Exchanges'\n}> = ({ type }) => {\n const { isBridgesChanged, isExchangesChanged } = useSettingMonitor()\n const { t } = useTranslation()\n const navigate = useNavigate()\n const [enabledTools, tools] = useSettingsStore((state) => {\n const enabledTools = Object.values(state[`_enabled${type}`])\n return [enabledTools.filter(Boolean).length, enabledTools.length]\n })\n\n const { hiddenUI } = useWidgetConfig()\n\n if (type === 'Bridges' && hiddenUI?.bridgesSettings) {\n return null\n }\n\n const customisationLookUp = {\n Bridges: isBridgesChanged,\n Exchanges: isExchangesChanged,\n }\n\n const handleClick = () => {\n navigate({\n to: navigationRoutes[type.toLowerCase() as 'bridges' | 'exchanges'],\n })\n }\n\n const Icon = supportedIcons[type]\n\n return (\n <CardButton\n onClick={handleClick}\n icon={<Icon />}\n title={t(`settings.enabled${type}`)}\n >\n <BadgedValue\n badgeColor=\"info\"\n showBadge={customisationLookUp[type]}\n >{`${enabledTools}/${tools}`}</BadgedValue>\n </CardButton>\n )\n}\n"],"mappings":";;;;;;;;;;;;AAWA,MAAM,iBAAiB;CACrB,SAAS;CACT,
|
|
1
|
+
{"version":3,"file":"BridgeAndExchangeSettings.js","names":["SwapHoriz"],"sources":["../../../../src/pages/SettingsPage/BridgeAndExchangeSettings.tsx"],"sourcesContent":["import AirlineStops from '@mui/icons-material/AirlineStops'\nimport SwapHoriz from '@mui/icons-material/SwapHoriz'\nimport { useNavigate } from '@tanstack/react-router'\nimport { useTranslation } from 'react-i18next'\nimport { CardButton } from '../../components/Card/CardButton.js'\nimport { useSettingMonitor } from '../../hooks/useSettingMonitor.js'\nimport { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js'\nimport { useSettingsStore } from '../../stores/settings/SettingsStore.js'\nimport { navigationRoutes } from '../../utils/navigationRoutes.js'\nimport { BadgedValue } from './SettingsCard/BadgedValue.js'\n\nconst supportedIcons = {\n Bridges: AirlineStops,\n Exchanges: SwapHoriz,\n}\n\nexport const BridgeAndExchangeSettings: React.FC<{\n type: 'Bridges' | 'Exchanges'\n}> = ({ type }) => {\n const { isBridgesChanged, isExchangesChanged } = useSettingMonitor()\n const { t } = useTranslation()\n const navigate = useNavigate()\n const [enabledTools, tools] = useSettingsStore((state) => {\n const enabledTools = Object.values(state[`_enabled${type}`])\n return [enabledTools.filter(Boolean).length, enabledTools.length]\n })\n\n const { hiddenUI } = useWidgetConfig()\n\n if (type === 'Bridges' && hiddenUI?.bridgesSettings) {\n return null\n }\n\n const customisationLookUp = {\n Bridges: isBridgesChanged,\n Exchanges: isExchangesChanged,\n }\n\n const handleClick = () => {\n navigate({\n to: navigationRoutes[type.toLowerCase() as 'bridges' | 'exchanges'],\n })\n }\n\n const Icon = supportedIcons[type]\n\n return (\n <CardButton\n onClick={handleClick}\n icon={<Icon />}\n title={t(`settings.enabled${type}`)}\n >\n <BadgedValue\n badgeColor=\"info\"\n showBadge={customisationLookUp[type]}\n >{`${enabledTools}/${tools}`}</BadgedValue>\n </CardButton>\n )\n}\n"],"mappings":";;;;;;;;;;;;AAWA,MAAM,iBAAiB;CACrB,SAAS;CACT,WAAWA;AACb;AAEA,MAAa,6BAEP,EAAE,WAAW;CACjB,MAAM,EAAE,kBAAkB,uBAAuB,kBAAkB;CACnE,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,WAAW,YAAY;CAC7B,MAAM,CAAC,cAAc,SAAS,kBAAkB,UAAU;EACxD,MAAM,eAAe,OAAO,OAAO,MAAM,WAAW,OAAO;EAC3D,OAAO,CAAC,aAAa,OAAO,OAAO,CAAC,CAAC,QAAQ,aAAa,MAAM;CAClE,CAAC;CAED,MAAM,EAAE,aAAa,gBAAgB;CAErC,IAAI,SAAS,aAAa,UAAU,iBAClC,OAAO;CAGT,MAAM,sBAAsB;EAC1B,SAAS;EACT,WAAW;CACb;CAEA,MAAM,oBAAoB;EACxB,SAAS,EACP,IAAI,iBAAiB,KAAK,YAAY,GACxC,CAAC;CACH;CAEA,MAAM,OAAO,eAAe;CAE5B,OACE,oBAAC,YAAD;EACE,SAAS;EACT,MAAM,oBAAC,MAAD,CAAO,CAAA;EACb,OAAO,EAAE,mBAAmB,MAAM;YAElC,oBAAC,aAAD;GACE,YAAW;GACX,WAAW,oBAAoB;aAC/B,GAAG,aAAa,GAAG;EAAqB,CAAA;CAChC,CAAA;AAEhB"}
|
|
@@ -1,44 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { navigationRoutes } from "../../utils/navigationRoutes.js";
|
|
2
2
|
import { useSettings } from "../../stores/settings/useSettings.js";
|
|
3
|
-
import { CardTabs, Tab } from "../../components/Tabs/Tabs.style.js";
|
|
4
3
|
import { useSettingMonitor } from "../../hooks/useSettingMonitor.js";
|
|
4
|
+
import { CardButton } from "../../components/Card/CardButton.js";
|
|
5
5
|
import { BadgedValue } from "./SettingsCard/BadgedValue.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useNavigate } from "@tanstack/react-router";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
8
|
import { useTranslation } from "react-i18next";
|
|
9
9
|
import Route from "@mui/icons-material/Route";
|
|
10
10
|
//#region src/pages/SettingsPage/RoutePrioritySettings.tsx
|
|
11
|
-
const Priorities = ["CHEAPEST", "FASTEST"];
|
|
12
11
|
const RoutePrioritySettings = () => {
|
|
13
12
|
const { t } = useTranslation();
|
|
14
|
-
const
|
|
13
|
+
const navigate = useNavigate();
|
|
15
14
|
const { isRoutePriorityChanged } = useSettingMonitor();
|
|
16
15
|
const { routePriority } = useSettings(["routePriority"]);
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
setValue("routePriority", routePriority);
|
|
16
|
+
const handleClick = () => {
|
|
17
|
+
navigate({ to: navigationRoutes.routePriority });
|
|
20
18
|
};
|
|
21
|
-
return /* @__PURE__ */ jsx(
|
|
22
|
-
|
|
23
|
-
badgeColor: "info",
|
|
24
|
-
showBadge: isRoutePriorityChanged,
|
|
25
|
-
children: t(`main.tags.${currentRoutePriority.toLowerCase()}`)
|
|
26
|
-
}),
|
|
19
|
+
return /* @__PURE__ */ jsx(CardButton, {
|
|
20
|
+
onClick: handleClick,
|
|
27
21
|
icon: /* @__PURE__ */ jsx(Route, {}),
|
|
28
22
|
title: t("settings.routePriority"),
|
|
29
|
-
children: /* @__PURE__ */ jsx(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
onChange: handleRoutePriorityChange,
|
|
34
|
-
sx: { mt: 1.5 },
|
|
35
|
-
children: Priorities.map((priority) => {
|
|
36
|
-
return /* @__PURE__ */ jsx(Tab, {
|
|
37
|
-
label: t(`main.tags.${priority.toLowerCase()}`),
|
|
38
|
-
value: priority,
|
|
39
|
-
disableRipple: true
|
|
40
|
-
}, priority);
|
|
41
|
-
})
|
|
23
|
+
children: /* @__PURE__ */ jsx(BadgedValue, {
|
|
24
|
+
badgeColor: "info",
|
|
25
|
+
showBadge: isRoutePriorityChanged,
|
|
26
|
+
children: routePriority === "FASTEST" ? t("settings.routePriorityOptions.fastest.title") : t("settings.routePriorityOptions.cheapest.title")
|
|
42
27
|
})
|
|
43
28
|
});
|
|
44
29
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RoutePrioritySettings.js","names":[],"sources":["../../../../src/pages/SettingsPage/RoutePrioritySettings.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"RoutePrioritySettings.js","names":[],"sources":["../../../../src/pages/SettingsPage/RoutePrioritySettings.tsx"],"sourcesContent":["import Route from '@mui/icons-material/Route'\nimport { useNavigate } from '@tanstack/react-router'\nimport { useTranslation } from 'react-i18next'\nimport { CardButton } from '../../components/Card/CardButton.js'\nimport { useSettingMonitor } from '../../hooks/useSettingMonitor.js'\nimport { useSettings } from '../../stores/settings/useSettings.js'\nimport { navigationRoutes } from '../../utils/navigationRoutes.js'\nimport { BadgedValue } from './SettingsCard/BadgedValue.js'\n\nexport const RoutePrioritySettings: React.FC = () => {\n const { t } = useTranslation()\n const navigate = useNavigate()\n const { isRoutePriorityChanged } = useSettingMonitor()\n const { routePriority } = useSettings(['routePriority'])\n\n const handleClick = () => {\n navigate({ to: navigationRoutes.routePriority })\n }\n\n return (\n <CardButton\n onClick={handleClick}\n icon={<Route />}\n title={t('settings.routePriority')}\n >\n <BadgedValue badgeColor=\"info\" showBadge={isRoutePriorityChanged}>\n {routePriority === 'FASTEST'\n ? t('settings.routePriorityOptions.fastest.title')\n : t('settings.routePriorityOptions.cheapest.title')}\n </BadgedValue>\n </CardButton>\n )\n}\n"],"mappings":";;;;;;;;;;AASA,MAAa,8BAAwC;CACnD,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,WAAW,YAAY;CAC7B,MAAM,EAAE,2BAA2B,kBAAkB;CACrD,MAAM,EAAE,kBAAkB,YAAY,CAAC,eAAe,CAAC;CAEvD,MAAM,oBAAoB;EACxB,SAAS,EAAE,IAAI,iBAAiB,cAAc,CAAC;CACjD;CAEA,OACE,oBAAC,YAAD;EACE,SAAS;EACT,MAAM,oBAAC,OAAD,CAAQ,CAAA;EACd,OAAO,EAAE,wBAAwB;YAEjC,oBAAC,aAAD;GAAa,YAAW;GAAO,WAAW;aACvC,kBAAkB,YACf,EAAE,6CAA6C,IAC/C,EAAE,8CAA8C;EACzC,CAAA;CACH,CAAA;AAEhB"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { useSettingsActions } from "../../../stores/settings/useSettingsActions.js";
|
|
2
|
+
import { formatInputAmount, formatSlippage } from "../../../utils/format.js";
|
|
3
|
+
import { PageContainer } from "../../../components/PageContainer.js";
|
|
4
|
+
import { useSettings } from "../../../stores/settings/useSettings.js";
|
|
5
|
+
import { useSettingMonitor } from "../../../hooks/useSettingMonitor.js";
|
|
6
|
+
import { useHeader } from "../../../hooks/useHeader.js";
|
|
7
|
+
import { useListHeight } from "../../../hooks/useListHeight.js";
|
|
8
|
+
import { ListItemText as ListItemText$1 } from "../../../components/ListItemText.js";
|
|
9
|
+
import { SettingsListItemButton } from "../../../components/SettingsListItemButton.js";
|
|
10
|
+
import { SlippageClearButton, SlippageInput, SlippageLimitsWarningContainer } from "./SlippageSettings.style.js";
|
|
11
|
+
import { useRef, useState } from "react";
|
|
12
|
+
import { Box, Collapse, List, Typography } from "@mui/material";
|
|
13
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { useTranslation } from "react-i18next";
|
|
15
|
+
import CloseRounded from "@mui/icons-material/CloseRounded";
|
|
16
|
+
import WarningRounded from "@mui/icons-material/WarningRounded";
|
|
17
|
+
import Check from "@mui/icons-material/Check";
|
|
18
|
+
//#region src/pages/SettingsPage/SlippageSettings/SlippagePage.tsx
|
|
19
|
+
const slippagePresets = ["0.5", "1"];
|
|
20
|
+
const maxFractionDigits = 5;
|
|
21
|
+
const SlippagePage = () => {
|
|
22
|
+
const { t } = useTranslation();
|
|
23
|
+
const { isSlippageNotRecommended, isSlippageUnderRecommendedLimits, isSlippageOutsideRecommendedLimits } = useSettingMonitor();
|
|
24
|
+
const { slippage } = useSettings(["slippage"]);
|
|
25
|
+
const { setValue } = useSettingsActions();
|
|
26
|
+
const defaultValue = useRef(slippage);
|
|
27
|
+
const listParentRef = useRef(null);
|
|
28
|
+
const { listHeight } = useListHeight({ listParentRef });
|
|
29
|
+
useHeader(t("settings.slippage"));
|
|
30
|
+
const isAuto = !slippage || slippage === void 0;
|
|
31
|
+
const isPreset = !!slippage && slippagePresets.includes(slippage);
|
|
32
|
+
const isCustom = !isAuto && !isPreset;
|
|
33
|
+
const [customMode, setCustomMode] = useState(isCustom);
|
|
34
|
+
const [inputValue, setInputValue] = useState(isCustom ? slippage ?? "" : "");
|
|
35
|
+
const handleAuto = () => {
|
|
36
|
+
setCustomMode(false);
|
|
37
|
+
setInputValue("");
|
|
38
|
+
setValue("slippage", void 0);
|
|
39
|
+
};
|
|
40
|
+
const handlePreset = (preset) => {
|
|
41
|
+
setCustomMode(false);
|
|
42
|
+
setValue("slippage", preset);
|
|
43
|
+
};
|
|
44
|
+
const handleCustom = () => {
|
|
45
|
+
setCustomMode(true);
|
|
46
|
+
const initialValue = slippage || "";
|
|
47
|
+
if (initialValue) {
|
|
48
|
+
setInputValue(initialValue);
|
|
49
|
+
setValue("slippage", initialValue);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const formatAndSetSlippage = (value, returnInitial = false) => {
|
|
53
|
+
const formattedSlippage = formatSlippage(value, defaultValue.current, returnInitial);
|
|
54
|
+
const formattedValue = Number(formattedSlippage) === 0 && !returnInitial ? "0" : formatInputAmount(formattedSlippage, maxFractionDigits, returnInitial);
|
|
55
|
+
const maxLength = Number(formattedValue) < 10 ? 7 : 8;
|
|
56
|
+
const slicedValue = formattedValue.slice(0, maxLength);
|
|
57
|
+
setInputValue(slicedValue);
|
|
58
|
+
setValue("slippage", slicedValue.length ? slicedValue : void 0);
|
|
59
|
+
};
|
|
60
|
+
const handleInputUpdate = (event) => {
|
|
61
|
+
formatAndSetSlippage(event.target.value, true);
|
|
62
|
+
};
|
|
63
|
+
const handleInputFocus = (event) => {
|
|
64
|
+
formatAndSetSlippage(event.target.value);
|
|
65
|
+
};
|
|
66
|
+
const handleInputBlur = (event) => {
|
|
67
|
+
formatAndSetSlippage(event.target.value);
|
|
68
|
+
};
|
|
69
|
+
const slippageWarningText = isSlippageOutsideRecommendedLimits ? t("warning.message.slippageOutsideRecommendedLimits") : isSlippageUnderRecommendedLimits ? t("warning.message.slippageUnderRecommendedLimits") : "";
|
|
70
|
+
return /* @__PURE__ */ jsx(PageContainer, {
|
|
71
|
+
disableGutters: true,
|
|
72
|
+
children: /* @__PURE__ */ jsxs(List, {
|
|
73
|
+
className: "long-list",
|
|
74
|
+
ref: listParentRef,
|
|
75
|
+
style: {
|
|
76
|
+
height: listHeight,
|
|
77
|
+
overflow: "auto"
|
|
78
|
+
},
|
|
79
|
+
sx: { padding: 1.5 },
|
|
80
|
+
children: [
|
|
81
|
+
/* @__PURE__ */ jsxs(SettingsListItemButton, {
|
|
82
|
+
onClick: handleAuto,
|
|
83
|
+
children: [/* @__PURE__ */ jsx(ListItemText$1, {
|
|
84
|
+
primary: t("button.auto"),
|
|
85
|
+
secondary: t("settings.slippageAutoDescription")
|
|
86
|
+
}), !customMode && isAuto && /* @__PURE__ */ jsx(Check, { color: "primary" })]
|
|
87
|
+
}),
|
|
88
|
+
slippagePresets.map((preset) => /* @__PURE__ */ jsxs(SettingsListItemButton, {
|
|
89
|
+
onClick: () => handlePreset(preset),
|
|
90
|
+
children: [/* @__PURE__ */ jsx(ListItemText$1, { primary: `${preset}%` }), !customMode && slippage === preset && /* @__PURE__ */ jsx(Check, { color: "primary" })]
|
|
91
|
+
}, preset)),
|
|
92
|
+
/* @__PURE__ */ jsxs(SettingsListItemButton, {
|
|
93
|
+
onClick: handleCustom,
|
|
94
|
+
children: [/* @__PURE__ */ jsx(ListItemText$1, { primary: t("settings.custom") }), customMode && /* @__PURE__ */ jsx(Check, { color: "primary" })]
|
|
95
|
+
}),
|
|
96
|
+
/* @__PURE__ */ jsx(Collapse, {
|
|
97
|
+
in: customMode,
|
|
98
|
+
children: /* @__PURE__ */ jsxs(Box, {
|
|
99
|
+
sx: {
|
|
100
|
+
px: 1.5,
|
|
101
|
+
pt: 1
|
|
102
|
+
},
|
|
103
|
+
children: [/* @__PURE__ */ jsx(SlippageInput, {
|
|
104
|
+
placeholder: "0.5",
|
|
105
|
+
inputProps: { inputMode: "decimal" },
|
|
106
|
+
value: inputValue,
|
|
107
|
+
onChange: handleInputUpdate,
|
|
108
|
+
onFocus: handleInputFocus,
|
|
109
|
+
onBlur: handleInputBlur,
|
|
110
|
+
autoComplete: "off",
|
|
111
|
+
endAdornment: !isAuto && /* @__PURE__ */ jsx(SlippageClearButton, {
|
|
112
|
+
size: "small",
|
|
113
|
+
onClick: handleAuto,
|
|
114
|
+
"aria-label": "Clear",
|
|
115
|
+
children: /* @__PURE__ */ jsx(CloseRounded, { fontSize: "small" })
|
|
116
|
+
})
|
|
117
|
+
}), isSlippageNotRecommended && /* @__PURE__ */ jsxs(SlippageLimitsWarningContainer, { children: [/* @__PURE__ */ jsx(WarningRounded, { color: "warning" }), /* @__PURE__ */ jsx(Typography, {
|
|
118
|
+
sx: {
|
|
119
|
+
fontSize: 13,
|
|
120
|
+
fontWeight: 400
|
|
121
|
+
},
|
|
122
|
+
children: slippageWarningText
|
|
123
|
+
})] })]
|
|
124
|
+
})
|
|
125
|
+
})
|
|
126
|
+
]
|
|
127
|
+
})
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
//#endregion
|
|
131
|
+
export { SlippagePage };
|
|
132
|
+
|
|
133
|
+
//# sourceMappingURL=SlippagePage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SlippagePage.js","names":["ListItemText"],"sources":["../../../../../src/pages/SettingsPage/SlippageSettings/SlippagePage.tsx"],"sourcesContent":["import Check from '@mui/icons-material/Check'\nimport CloseRounded from '@mui/icons-material/CloseRounded'\nimport WarningRounded from '@mui/icons-material/WarningRounded'\nimport { Box, Collapse, List, Typography } from '@mui/material'\nimport type { ChangeEventHandler, FocusEventHandler } from 'react'\nimport { useRef, useState } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { ListItemText } from '../../../components/ListItemText.js'\nimport { PageContainer } from '../../../components/PageContainer.js'\nimport { SettingsListItemButton } from '../../../components/SettingsListItemButton.js'\nimport { useHeader } from '../../../hooks/useHeader.js'\nimport { useListHeight } from '../../../hooks/useListHeight.js'\nimport { useSettingMonitor } from '../../../hooks/useSettingMonitor.js'\nimport { defaultSlippage } from '../../../stores/settings/createSettingsStore.js'\nimport { useSettings } from '../../../stores/settings/useSettings.js'\nimport { useSettingsActions } from '../../../stores/settings/useSettingsActions.js'\nimport { formatInputAmount, formatSlippage } from '../../../utils/format.js'\nimport {\n SlippageClearButton,\n SlippageInput,\n SlippageLimitsWarningContainer,\n} from './SlippageSettings.style.js'\n\nconst slippagePresets = ['0.5', '1']\nconst maxFractionDigits = 5\n\nexport const SlippagePage: React.FC = () => {\n const { t } = useTranslation()\n const {\n isSlippageNotRecommended,\n isSlippageUnderRecommendedLimits,\n isSlippageOutsideRecommendedLimits,\n } = useSettingMonitor()\n const { slippage } = useSettings(['slippage'])\n const { setValue } = useSettingsActions()\n const defaultValue = useRef(slippage)\n const listParentRef = useRef<HTMLUListElement | null>(null)\n const { listHeight } = useListHeight({ listParentRef })\n\n useHeader(t('settings.slippage'))\n\n const isAuto = !slippage || slippage === defaultSlippage\n const isPreset = !!slippage && slippagePresets.includes(slippage)\n const isCustom = !isAuto && !isPreset\n\n const [customMode, setCustomMode] = useState(isCustom)\n const [inputValue, setInputValue] = useState(isCustom ? (slippage ?? '') : '')\n\n const handleAuto = () => {\n setCustomMode(false)\n setInputValue('')\n setValue('slippage', defaultSlippage)\n }\n\n const handlePreset = (preset: string) => {\n setCustomMode(false)\n setValue('slippage', preset)\n }\n\n const handleCustom = () => {\n setCustomMode(true)\n const initialValue = slippage || ''\n if (initialValue) {\n setInputValue(initialValue)\n setValue('slippage', initialValue)\n }\n }\n\n const formatAndSetSlippage = (value: string, returnInitial = false) => {\n const formattedSlippage = formatSlippage(\n value,\n defaultValue.current,\n returnInitial\n )\n const formattedValue =\n Number(formattedSlippage) === 0 && !returnInitial\n ? '0'\n : formatInputAmount(formattedSlippage, maxFractionDigits, returnInitial)\n const maxLength =\n Number(formattedValue) < 10\n ? maxFractionDigits + 2\n : maxFractionDigits + 3\n const slicedValue = formattedValue.slice(0, maxLength)\n setInputValue(slicedValue)\n setValue('slippage', slicedValue.length ? slicedValue : defaultSlippage)\n }\n\n const handleInputUpdate: ChangeEventHandler<HTMLInputElement> = (event) => {\n formatAndSetSlippage(event.target.value, true)\n }\n\n const handleInputFocus: FocusEventHandler<HTMLInputElement> = (event) => {\n formatAndSetSlippage(event.target.value)\n }\n\n const handleInputBlur: FocusEventHandler<HTMLInputElement> = (event) => {\n formatAndSetSlippage(event.target.value)\n }\n\n const slippageWarningText = isSlippageOutsideRecommendedLimits\n ? t('warning.message.slippageOutsideRecommendedLimits')\n : isSlippageUnderRecommendedLimits\n ? t('warning.message.slippageUnderRecommendedLimits')\n : ''\n\n return (\n <PageContainer disableGutters>\n <List\n className=\"long-list\"\n ref={listParentRef}\n style={{ height: listHeight, overflow: 'auto' }}\n sx={{\n padding: 1.5,\n }}\n >\n <SettingsListItemButton onClick={handleAuto}>\n <ListItemText\n primary={t('button.auto')}\n secondary={t('settings.slippageAutoDescription')}\n />\n {!customMode && isAuto && <Check color=\"primary\" />}\n </SettingsListItemButton>\n {slippagePresets.map((preset) => (\n <SettingsListItemButton\n key={preset}\n onClick={() => handlePreset(preset)}\n >\n <ListItemText primary={`${preset}%`} />\n {!customMode && slippage === preset && <Check color=\"primary\" />}\n </SettingsListItemButton>\n ))}\n <SettingsListItemButton onClick={handleCustom}>\n <ListItemText primary={t('settings.custom')} />\n {customMode && <Check color=\"primary\" />}\n </SettingsListItemButton>\n <Collapse in={customMode}>\n <Box sx={{ px: 1.5, pt: 1 }}>\n <SlippageInput\n placeholder=\"0.5\"\n inputProps={{ inputMode: 'decimal' }}\n value={inputValue}\n onChange={handleInputUpdate}\n onFocus={handleInputFocus}\n onBlur={handleInputBlur}\n autoComplete=\"off\"\n endAdornment={\n !isAuto && (\n <SlippageClearButton\n size=\"small\"\n onClick={handleAuto}\n aria-label=\"Clear\"\n >\n <CloseRounded fontSize=\"small\" />\n </SlippageClearButton>\n )\n }\n />\n {isSlippageNotRecommended && (\n <SlippageLimitsWarningContainer>\n <WarningRounded color=\"warning\" />\n <Typography\n sx={{\n fontSize: 13,\n fontWeight: 400,\n }}\n >\n {slippageWarningText}\n </Typography>\n </SlippageLimitsWarningContainer>\n )}\n </Box>\n </Collapse>\n </List>\n </PageContainer>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAuBA,MAAM,kBAAkB,CAAC,OAAO,GAAG;AACnC,MAAM,oBAAoB;AAE1B,MAAa,qBAA+B;CAC1C,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,EACJ,0BACA,kCACA,uCACE,kBAAkB;CACtB,MAAM,EAAE,aAAa,YAAY,CAAC,UAAU,CAAC;CAC7C,MAAM,EAAE,aAAa,mBAAmB;CACxC,MAAM,eAAe,OAAO,QAAQ;CACpC,MAAM,gBAAgB,OAAgC,IAAI;CAC1D,MAAM,EAAE,eAAe,cAAc,EAAE,cAAc,CAAC;CAEtD,UAAU,EAAE,mBAAmB,CAAC;CAEhC,MAAM,SAAS,CAAC,YAAY,aAAA,KAAA;CAC5B,MAAM,WAAW,CAAC,CAAC,YAAY,gBAAgB,SAAS,QAAQ;CAChE,MAAM,WAAW,CAAC,UAAU,CAAC;CAE7B,MAAM,CAAC,YAAY,iBAAiB,SAAS,QAAQ;CACrD,MAAM,CAAC,YAAY,iBAAiB,SAAS,WAAY,YAAY,KAAM,EAAE;CAE7E,MAAM,mBAAmB;EACvB,cAAc,KAAK;EACnB,cAAc,EAAE;EAChB,SAAS,YAAA,KAAA,CAA2B;CACtC;CAEA,MAAM,gBAAgB,WAAmB;EACvC,cAAc,KAAK;EACnB,SAAS,YAAY,MAAM;CAC7B;CAEA,MAAM,qBAAqB;EACzB,cAAc,IAAI;EAClB,MAAM,eAAe,YAAY;EACjC,IAAI,cAAc;GAChB,cAAc,YAAY;GAC1B,SAAS,YAAY,YAAY;EACnC;CACF;CAEA,MAAM,wBAAwB,OAAe,gBAAgB,UAAU;EACrE,MAAM,oBAAoB,eACxB,OACA,aAAa,SACb,aACF;EACA,MAAM,iBACJ,OAAO,iBAAiB,MAAM,KAAK,CAAC,gBAChC,MACA,kBAAkB,mBAAmB,mBAAmB,aAAa;EAC3E,MAAM,YACJ,OAAO,cAAc,IAAI,KACrB,IACA;EACN,MAAM,cAAc,eAAe,MAAM,GAAG,SAAS;EACrD,cAAc,WAAW;EACzB,SAAS,YAAY,YAAY,SAAS,cAAA,KAAA,CAA6B;CACzE;CAEA,MAAM,qBAA2D,UAAU;EACzE,qBAAqB,MAAM,OAAO,OAAO,IAAI;CAC/C;CAEA,MAAM,oBAAyD,UAAU;EACvE,qBAAqB,MAAM,OAAO,KAAK;CACzC;CAEA,MAAM,mBAAwD,UAAU;EACtE,qBAAqB,MAAM,OAAO,KAAK;CACzC;CAEA,MAAM,sBAAsB,qCACxB,EAAE,kDAAkD,IACpD,mCACE,EAAE,gDAAgD,IAClD;CAEN,OACE,oBAAC,eAAD;EAAe,gBAAA;YACb,qBAAC,MAAD;GACE,WAAU;GACV,KAAK;GACL,OAAO;IAAE,QAAQ;IAAY,UAAU;GAAO;GAC9C,IAAI,EACF,SAAS,IACX;aANF;IAQE,qBAAC,wBAAD;KAAwB,SAAS;eAAjC,CACE,oBAACA,gBAAD;MACE,SAAS,EAAE,aAAa;MACxB,WAAW,EAAE,kCAAkC;KAChD,CAAA,GACA,CAAC,cAAc,UAAU,oBAAC,OAAD,EAAO,OAAM,UAAW,CAAA,CAC5B;;IACvB,gBAAgB,KAAK,WACpB,qBAAC,wBAAD;KAEE,eAAe,aAAa,MAAM;eAFpC,CAIE,oBAACA,gBAAD,EAAc,SAAS,GAAG,OAAO,GAAK,CAAA,GACrC,CAAC,cAAc,aAAa,UAAU,oBAAC,OAAD,EAAO,OAAM,UAAW,CAAA,CACzC;OALjB,MAKiB,CACzB;IACD,qBAAC,wBAAD;KAAwB,SAAS;eAAjC,CACE,oBAACA,gBAAD,EAAc,SAAS,EAAE,iBAAiB,EAAI,CAAA,GAC7C,cAAc,oBAAC,OAAD,EAAO,OAAM,UAAW,CAAA,CACjB;;IACxB,oBAAC,UAAD;KAAU,IAAI;eACZ,qBAAC,KAAD;MAAK,IAAI;OAAE,IAAI;OAAK,IAAI;MAAE;gBAA1B,CACE,oBAAC,eAAD;OACE,aAAY;OACZ,YAAY,EAAE,WAAW,UAAU;OACnC,OAAO;OACP,UAAU;OACV,SAAS;OACT,QAAQ;OACR,cAAa;OACb,cACE,CAAC,UACC,oBAAC,qBAAD;QACE,MAAK;QACL,SAAS;QACT,cAAW;kBAEX,oBAAC,cAAD,EAAc,UAAS,QAAS,CAAA;OACb,CAAA;MAG1B,CAAA,GACA,4BACC,qBAAC,gCAAD,EAAA,UAAA,CACE,oBAAC,gBAAD,EAAgB,OAAM,UAAW,CAAA,GACjC,oBAAC,YAAD;OACE,IAAI;QACF,UAAU;QACV,YAAY;OACd;iBAEC;MACS,CAAA,CACkB,EAAA,CAAA,CAE/B;;IACG,CAAA;GACN;;CACO,CAAA;AAEnB"}
|
|
@@ -1,88 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { formatInputAmount, formatSlippage } from "../../../utils/format.js";
|
|
1
|
+
import { navigationRoutes } from "../../../utils/navigationRoutes.js";
|
|
3
2
|
import { useSettings } from "../../../stores/settings/useSettings.js";
|
|
4
3
|
import { useSettingMonitor } from "../../../hooks/useSettingMonitor.js";
|
|
4
|
+
import { CardButton } from "../../../components/Card/CardButton.js";
|
|
5
5
|
import { BadgedValue } from "../SettingsCard/BadgedValue.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { useRef, useState } from "react";
|
|
9
|
-
import { Box, Typography } from "@mui/material";
|
|
10
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { useNavigate } from "@tanstack/react-router";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
11
8
|
import { useTranslation } from "react-i18next";
|
|
12
|
-
import WarningRounded from "@mui/icons-material/WarningRounded";
|
|
13
9
|
import Percent from "@mui/icons-material/Percent";
|
|
14
10
|
//#region src/pages/SettingsPage/SlippageSettings/SlippageSettings.tsx
|
|
15
|
-
const defaultSlippageInputValue = "0.5";
|
|
16
|
-
const maxFractionDigits = 5;
|
|
17
11
|
const SlippageSettings = () => {
|
|
18
12
|
const { t } = useTranslation();
|
|
19
|
-
const
|
|
13
|
+
const navigate = useNavigate();
|
|
14
|
+
const { isSlippageNotRecommended, isSlippageChanged } = useSettingMonitor();
|
|
20
15
|
const { slippage } = useSettings(["slippage"]);
|
|
21
|
-
const { setValue } = useSettingsActions();
|
|
22
|
-
const defaultValue = useRef(slippage);
|
|
23
|
-
const [focused, setFocused] = useState();
|
|
24
|
-
const [inputValue, setInputValue] = useState(!slippage || slippage === void 0 ? defaultSlippageInputValue : slippage);
|
|
25
|
-
const handleDefaultClick = () => {
|
|
26
|
-
setValue("slippage", void 0);
|
|
27
|
-
};
|
|
28
|
-
const formatAndSetSlippage = (value, returnInitial = false) => {
|
|
29
|
-
const formattedSlippage = formatSlippage(value, defaultValue.current, returnInitial);
|
|
30
|
-
const formattedValue = Number(formattedSlippage) === 0 && !returnInitial ? "0" : formatInputAmount(formattedSlippage, maxFractionDigits, returnInitial);
|
|
31
|
-
const maxLength = Number(formattedValue) < 10 ? 7 : 8;
|
|
32
|
-
const slicedValue = formattedValue.slice(0, maxLength);
|
|
33
|
-
setInputValue(slicedValue);
|
|
34
|
-
setValue("slippage", slicedValue.length ? slicedValue : void 0);
|
|
35
|
-
};
|
|
36
|
-
const handleInputUpdate = (event) => {
|
|
37
|
-
formatAndSetSlippage(event.target.value, true);
|
|
38
|
-
};
|
|
39
|
-
const handleInputFocus = (event) => {
|
|
40
|
-
setFocused("input");
|
|
41
|
-
formatAndSetSlippage(event.target.value);
|
|
42
|
-
};
|
|
43
|
-
const handleInputBlur = (event) => {
|
|
44
|
-
setFocused(void 0);
|
|
45
|
-
formatAndSetSlippage(event.target.value);
|
|
46
|
-
};
|
|
47
16
|
const badgeColor = isSlippageNotRecommended ? "warning" : isSlippageChanged ? "info" : void 0;
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
17
|
+
const handleClick = () => {
|
|
18
|
+
navigate({ to: navigationRoutes.slippage });
|
|
19
|
+
};
|
|
20
|
+
return /* @__PURE__ */ jsx(CardButton, {
|
|
21
|
+
onClick: handleClick,
|
|
22
|
+
icon: /* @__PURE__ */ jsx(Percent, {}),
|
|
23
|
+
title: t("settings.slippage"),
|
|
24
|
+
children: /* @__PURE__ */ jsx(BadgedValue, {
|
|
51
25
|
badgeColor,
|
|
52
26
|
showBadge: !!badgeColor,
|
|
53
27
|
children: slippage ? `${slippage}%` : t("button.auto")
|
|
54
|
-
}),
|
|
55
|
-
icon: /* @__PURE__ */ jsx(Percent, {}),
|
|
56
|
-
title: t("settings.slippage"),
|
|
57
|
-
children: /* @__PURE__ */ jsxs(Box, {
|
|
58
|
-
sx: { mt: 1.5 },
|
|
59
|
-
children: [/* @__PURE__ */ jsxs(SettingsFieldSet, { children: [/* @__PURE__ */ jsx(SettingsDefaultButton, {
|
|
60
|
-
selected: void 0 === slippage && focused !== "input",
|
|
61
|
-
onFocus: () => {
|
|
62
|
-
setFocused("button");
|
|
63
|
-
},
|
|
64
|
-
onBlur: () => {
|
|
65
|
-
setFocused(void 0);
|
|
66
|
-
},
|
|
67
|
-
onClick: handleDefaultClick,
|
|
68
|
-
disableRipple: true,
|
|
69
|
-
children: t("button.auto")
|
|
70
|
-
}), /* @__PURE__ */ jsx(SettingsCustomInput, {
|
|
71
|
-
selected: void 0 !== slippage && focused !== "button",
|
|
72
|
-
placeholder: focused === "input" ? "" : t("settings.custom"),
|
|
73
|
-
inputProps: { inputMode: "decimal" },
|
|
74
|
-
onChange: handleInputUpdate,
|
|
75
|
-
onFocus: handleInputFocus,
|
|
76
|
-
value: inputValue,
|
|
77
|
-
autoComplete: "off",
|
|
78
|
-
onBlur: handleInputBlur
|
|
79
|
-
})] }), isSlippageNotRecommended && /* @__PURE__ */ jsxs(SlippageLimitsWarningContainer, { children: [/* @__PURE__ */ jsx(WarningRounded, { color: "warning" }), /* @__PURE__ */ jsx(Typography, {
|
|
80
|
-
sx: {
|
|
81
|
-
fontSize: 13,
|
|
82
|
-
fontWeight: 400
|
|
83
|
-
},
|
|
84
|
-
children: slippageWarningText
|
|
85
|
-
})] })]
|
|
86
28
|
})
|
|
87
29
|
});
|
|
88
30
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SlippageSettings.js","names":[],"sources":["../../../../../src/pages/SettingsPage/SlippageSettings/SlippageSettings.tsx"],"sourcesContent":["import Percent from '@mui/icons-material/Percent'\nimport
|
|
1
|
+
{"version":3,"file":"SlippageSettings.js","names":[],"sources":["../../../../../src/pages/SettingsPage/SlippageSettings/SlippageSettings.tsx"],"sourcesContent":["import Percent from '@mui/icons-material/Percent'\nimport { useNavigate } from '@tanstack/react-router'\nimport { useTranslation } from 'react-i18next'\nimport { CardButton } from '../../../components/Card/CardButton.js'\nimport { useSettingMonitor } from '../../../hooks/useSettingMonitor.js'\nimport { useSettings } from '../../../stores/settings/useSettings.js'\nimport { navigationRoutes } from '../../../utils/navigationRoutes.js'\nimport { BadgedValue } from '../SettingsCard/BadgedValue.js'\n\nexport const SlippageSettings: React.FC = () => {\n const { t } = useTranslation()\n const navigate = useNavigate()\n const { isSlippageNotRecommended, isSlippageChanged } = useSettingMonitor()\n const { slippage } = useSettings(['slippage'])\n\n const badgeColor = isSlippageNotRecommended\n ? 'warning'\n : isSlippageChanged\n ? 'info'\n : undefined\n\n const handleClick = () => {\n navigate({ to: navigationRoutes.slippage })\n }\n\n return (\n <CardButton\n onClick={handleClick}\n icon={<Percent />}\n title={t('settings.slippage')}\n >\n <BadgedValue badgeColor={badgeColor} showBadge={!!badgeColor}>\n {slippage ? `${slippage}%` : t('button.auto')}\n </BadgedValue>\n </CardButton>\n )\n}\n"],"mappings":";;;;;;;;;;AASA,MAAa,yBAAmC;CAC9C,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,WAAW,YAAY;CAC7B,MAAM,EAAE,0BAA0B,sBAAsB,kBAAkB;CAC1E,MAAM,EAAE,aAAa,YAAY,CAAC,UAAU,CAAC;CAE7C,MAAM,aAAa,2BACf,YACA,oBACE,SACA,KAAA;CAEN,MAAM,oBAAoB;EACxB,SAAS,EAAE,IAAI,iBAAiB,SAAS,CAAC;CAC5C;CAEA,OACE,oBAAC,YAAD;EACE,SAAS;EACT,MAAM,oBAAC,SAAD,CAAU,CAAA;EAChB,OAAO,EAAE,mBAAmB;YAE5B,oBAAC,aAAD;GAAyB;GAAY,WAAW,CAAC,CAAC;aAC/C,WAAW,GAAG,SAAS,KAAK,EAAE,aAAa;EACjC,CAAA;CACH,CAAA;AAEhB"}
|