@lifi/widget 3.25.0-beta.5 → 3.26.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/CHANGELOG.md +43 -0
- package/dist/esm/components/AmountInput/AmountInput.js +75 -17
- package/dist/esm/components/AmountInput/AmountInput.js.map +1 -1
- package/dist/esm/components/AmountInput/AmountInput.style.d.ts +4 -0
- package/dist/esm/components/AmountInput/AmountInput.style.js +11 -0
- package/dist/esm/components/AmountInput/AmountInput.style.js.map +1 -1
- package/dist/esm/components/AmountInput/AmountInputAdornment.style.d.ts +1 -0
- package/dist/esm/components/AmountInput/AmountInputAdornment.style.js +64 -5
- package/dist/esm/components/AmountInput/AmountInputAdornment.style.js.map +1 -1
- package/dist/esm/components/AmountInput/AmountInputEndAdornment.js +20 -7
- package/dist/esm/components/AmountInput/AmountInputEndAdornment.js.map +1 -1
- package/dist/esm/components/AmountInput/PriceFormHelperText.js +41 -15
- package/dist/esm/components/AmountInput/PriceFormHelperText.js.map +1 -1
- package/dist/esm/components/AmountInput/PriceFormHelperText.style.d.ts +1 -0
- package/dist/esm/components/AmountInput/PriceFormHelperText.style.js +29 -0
- package/dist/esm/components/AmountInput/PriceFormHelperText.style.js.map +1 -0
- package/dist/esm/components/AppContainer.js +1 -0
- package/dist/esm/components/AppContainer.js.map +1 -1
- package/dist/esm/components/ChainSelect/useChainSelect.js +2 -4
- package/dist/esm/components/ChainSelect/useChainSelect.js.map +1 -1
- package/dist/esm/components/Chains/ChainList.d.ts +2 -3
- package/dist/esm/components/Chains/ChainList.js +4 -3
- package/dist/esm/components/Chains/ChainList.js.map +1 -1
- package/dist/esm/components/Chains/ChainList.style.js +10 -3
- package/dist/esm/components/Chains/ChainList.style.js.map +1 -1
- package/dist/esm/components/Chains/ChainListItem.d.ts +4 -1
- package/dist/esm/components/Chains/ChainListItem.js +14 -2
- package/dist/esm/components/Chains/ChainListItem.js.map +1 -1
- package/dist/esm/components/Chains/PinChainButton.d.ts +7 -0
- package/dist/esm/components/Chains/PinChainButton.js +34 -0
- package/dist/esm/components/Chains/PinChainButton.js.map +1 -0
- package/dist/esm/components/Chains/SelectChainContent.js +15 -16
- package/dist/esm/components/Chains/SelectChainContent.js.map +1 -1
- package/dist/esm/components/Chains/VirtualizedChainList.d.ts +2 -1
- package/dist/esm/components/Chains/VirtualizedChainList.js +45 -9
- package/dist/esm/components/Chains/VirtualizedChainList.js.map +1 -1
- package/dist/esm/components/Header/NavigationHeader.js +5 -1
- package/dist/esm/components/Header/NavigationHeader.js.map +1 -1
- package/dist/esm/components/Messages/MinFromAmountUSDMessage.d.ts +6 -0
- package/dist/esm/components/Messages/MinFromAmountUSDMessage.js +15 -0
- package/dist/esm/components/Messages/MinFromAmountUSDMessage.js.map +1 -0
- package/dist/esm/components/Messages/WarningMessages.js +3 -0
- package/dist/esm/components/Messages/WarningMessages.js.map +1 -1
- package/dist/esm/components/Messages/useMessageQueue.js +15 -4
- package/dist/esm/components/Messages/useMessageQueue.js.map +1 -1
- package/dist/esm/components/Routes/RoutesContent.js +3 -2
- package/dist/esm/components/Routes/RoutesContent.js.map +1 -1
- package/dist/esm/components/Routes/RoutesExpanded.style.js +3 -2
- package/dist/esm/components/Routes/RoutesExpanded.style.js.map +1 -1
- package/dist/esm/components/SendToWallet/SendToWalletButton.js +1 -1
- package/dist/esm/components/SendToWallet/SendToWalletButton.js.map +1 -1
- package/dist/esm/components/SendToWallet/SendToWalletExpandButton.js +3 -3
- package/dist/esm/components/SendToWallet/SendToWalletExpandButton.js.map +1 -1
- package/dist/esm/components/Step/StepProcess.js +3 -8
- package/dist/esm/components/Step/StepProcess.js.map +1 -1
- package/dist/esm/components/TokenList/TokenDetailsSheet.js +0 -2
- package/dist/esm/components/TokenList/TokenDetailsSheet.js.map +1 -1
- package/dist/esm/components/TokenList/TokenDetailsSheetContent.js +27 -4
- package/dist/esm/components/TokenList/TokenDetailsSheetContent.js.map +1 -1
- package/dist/esm/components/TokenList/TokenList.js +10 -1
- package/dist/esm/components/TokenList/TokenList.js.map +1 -1
- package/dist/esm/components/TokenList/TokenListItem.js +3 -1
- package/dist/esm/components/TokenList/TokenListItem.js.map +1 -1
- package/dist/esm/components/TokenList/useTokenSelect.js +2 -4
- package/dist/esm/components/TokenList/useTokenSelect.js.map +1 -1
- 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/useFromAmountThreshold.d.ts +4 -0
- package/dist/esm/hooks/useFromAmountThreshold.js +23 -0
- package/dist/esm/hooks/useFromAmountThreshold.js.map +1 -0
- package/dist/esm/hooks/useGasSufficiency.js +3 -3
- package/dist/esm/hooks/useGasSufficiency.js.map +1 -1
- package/dist/esm/hooks/useLongPress.d.ts +7 -0
- package/dist/esm/hooks/useLongPress.js +41 -0
- package/dist/esm/hooks/useLongPress.js.map +1 -0
- package/dist/esm/hooks/useNavigateBack.d.ts +1 -1
- package/dist/esm/hooks/useNavigateBack.js +8 -2
- package/dist/esm/hooks/useNavigateBack.js.map +1 -1
- package/dist/esm/hooks/useRouteExecution.js +1 -2
- package/dist/esm/hooks/useRouteExecution.js.map +1 -1
- package/dist/esm/hooks/useRoutes.js +19 -4
- package/dist/esm/hooks/useRoutes.js.map +1 -1
- package/dist/esm/hooks/useSettingMonitor.js +1 -2
- package/dist/esm/hooks/useSettingMonitor.js.map +1 -1
- package/dist/esm/hooks/useTokenAddressBalance.js +4 -1
- package/dist/esm/hooks/useTokenAddressBalance.js.map +1 -1
- package/dist/esm/hooks/useTokenBalances.d.ts +1 -2
- package/dist/esm/hooks/useTokenBalances.js +2 -3
- package/dist/esm/hooks/useTokenBalances.js.map +1 -1
- package/dist/esm/hooks/useTokenSearch.d.ts +2 -2
- package/dist/esm/hooks/useTokenSearch.js +5 -2
- package/dist/esm/hooks/useTokenSearch.js.map +1 -1
- package/dist/esm/hooks/useTokens.d.ts +1 -2
- package/dist/esm/hooks/useTokens.js +3 -12
- package/dist/esm/hooks/useTokens.js.map +1 -1
- package/dist/esm/hooks/useTools.js +2 -2
- package/dist/esm/hooks/useTools.js.map +1 -1
- package/dist/esm/i18n/bn.json +5 -2
- package/dist/esm/i18n/de.json +5 -2
- package/dist/esm/i18n/en.json +5 -2
- package/dist/esm/i18n/es.json +5 -2
- package/dist/esm/i18n/fr.json +5 -2
- package/dist/esm/i18n/hi.json +5 -2
- package/dist/esm/i18n/id.json +5 -2
- package/dist/esm/i18n/it.json +5 -2
- package/dist/esm/i18n/ja.json +5 -2
- package/dist/esm/i18n/ko.json +5 -2
- package/dist/esm/i18n/pl.json +4 -1
- package/dist/esm/i18n/pt.json +5 -2
- package/dist/esm/i18n/th.json +5 -2
- package/dist/esm/i18n/tr.json +5 -2
- package/dist/esm/i18n/uk.json +5 -2
- package/dist/esm/i18n/vi.json +5 -2
- package/dist/esm/i18n/zh.json +5 -2
- package/dist/esm/pages/SelectEnabledToolsPage.js +4 -2
- package/dist/esm/pages/SelectEnabledToolsPage.js.map +1 -1
- package/dist/esm/pages/SelectTokenPage/SearchTokenInput.js +14 -7
- package/dist/esm/pages/SelectTokenPage/SearchTokenInput.js.map +1 -1
- package/dist/esm/pages/SettingsPage/BridgeAndExchangeSettings.js +1 -2
- package/dist/esm/pages/SettingsPage/BridgeAndExchangeSettings.js.map +1 -1
- package/dist/esm/pages/TransactionPage/TransactionPage.js +5 -3
- package/dist/esm/pages/TransactionPage/TransactionPage.js.map +1 -1
- package/dist/esm/stores/bookmarks/BookmarkStore.d.ts +1 -2
- package/dist/esm/stores/bookmarks/BookmarkStore.js +3 -3
- package/dist/esm/stores/bookmarks/BookmarkStore.js.map +1 -1
- package/dist/esm/stores/bookmarks/useBookmarkActions.js +1 -2
- package/dist/esm/stores/bookmarks/useBookmarkActions.js.map +1 -1
- package/dist/esm/stores/bookmarks/useBookmarks.js +1 -2
- package/dist/esm/stores/bookmarks/useBookmarks.js.map +1 -1
- package/dist/esm/stores/chains/ChainOrderStore.d.ts +1 -1
- package/dist/esm/stores/chains/ChainOrderStore.js +20 -7
- package/dist/esm/stores/chains/ChainOrderStore.js.map +1 -1
- package/dist/esm/stores/chains/createChainOrderStore.js +19 -1
- package/dist/esm/stores/chains/createChainOrderStore.js.map +1 -1
- package/dist/esm/stores/chains/types.d.ts +2 -0
- package/dist/esm/stores/chains/useChainOrder.js +1 -2
- package/dist/esm/stores/chains/useChainOrder.js.map +1 -1
- package/dist/esm/stores/form/useFieldActions.js +1 -2
- package/dist/esm/stores/form/useFieldActions.js.map +1 -1
- package/dist/esm/stores/form/useFieldValues.js +1 -2
- package/dist/esm/stores/form/useFieldValues.js.map +1 -1
- package/dist/esm/stores/form/useFormStore.d.ts +1 -2
- package/dist/esm/stores/form/useFormStore.js +3 -3
- package/dist/esm/stores/form/useFormStore.js.map +1 -1
- package/dist/esm/stores/form/useTouchedFields.js +1 -2
- package/dist/esm/stores/form/useTouchedFields.js.map +1 -1
- package/dist/esm/stores/form/useValidation.js +5 -2
- package/dist/esm/stores/form/useValidation.js.map +1 -1
- package/dist/esm/stores/form/useValidationActions.js +1 -2
- package/dist/esm/stores/form/useValidationActions.js.map +1 -1
- package/dist/esm/stores/header/useHeaderStore.d.ts +1 -1
- package/dist/esm/stores/header/useHeaderStore.js +5 -5
- package/dist/esm/stores/header/useHeaderStore.js.map +1 -1
- package/dist/esm/stores/inputMode/useInputModeStore.d.ts +9 -0
- package/dist/esm/stores/inputMode/useInputModeStore.js +19 -0
- package/dist/esm/stores/inputMode/useInputModeStore.js.map +1 -0
- package/dist/esm/stores/routes/RouteExecutionStore.d.ts +1 -1
- package/dist/esm/stores/routes/RouteExecutionStore.js +3 -2
- package/dist/esm/stores/routes/RouteExecutionStore.js.map +1 -1
- package/dist/esm/stores/routes/useExecutingRoutesIds.js +1 -2
- package/dist/esm/stores/routes/useExecutingRoutesIds.js.map +1 -1
- package/dist/esm/stores/settings/useSendToWalletStore.d.ts +2 -1
- package/dist/esm/stores/settings/useSendToWalletStore.js +6 -3
- package/dist/esm/stores/settings/useSendToWalletStore.js.map +1 -1
- package/dist/esm/stores/settings/useSettings.js +1 -2
- package/dist/esm/stores/settings/useSettings.js.map +1 -1
- package/dist/esm/stores/settings/useSettingsActions.js +1 -2
- package/dist/esm/stores/settings/useSettingsActions.js.map +1 -1
- package/dist/esm/stores/settings/useSettingsStore.d.ts +2 -1
- package/dist/esm/stores/settings/useSettingsStore.js +5 -1
- package/dist/esm/stores/settings/useSettingsStore.js.map +1 -1
- package/dist/esm/stores/settings/useSplitSubvariantStore.js +2 -1
- package/dist/esm/stores/settings/useSplitSubvariantStore.js.map +1 -1
- package/dist/esm/themes/createTheme.js +5 -1
- package/dist/esm/themes/createTheme.js.map +1 -1
- package/dist/esm/types/widget.d.ts +3 -1
- package/dist/esm/types/widget.js +1 -0
- package/dist/esm/types/widget.js.map +1 -1
- package/dist/esm/utils/format.d.ts +4 -0
- package/dist/esm/utils/format.js +26 -0
- package/dist/esm/utils/format.js.map +1 -1
- package/dist/esm/utils/getPriceImpact.d.ts +2 -2
- package/dist/esm/utils/getPriceImpact.js.map +1 -1
- package/package.json +12 -12
- package/package.json.tmp +14 -14
- package/src/components/AmountInput/AmountInput.style.tsx +13 -0
- package/src/components/AmountInput/AmountInput.tsx +91 -18
- package/src/components/AmountInput/AmountInputAdornment.style.tsx +66 -5
- package/src/components/AmountInput/AmountInputEndAdornment.tsx +40 -10
- package/src/components/AmountInput/PriceFormHelperText.style.tsx +29 -0
- package/src/components/AmountInput/PriceFormHelperText.tsx +63 -19
- package/src/components/AppContainer.tsx +1 -0
- package/src/components/ChainSelect/useChainSelect.ts +2 -4
- package/src/components/Chains/ChainList.style.tsx +10 -2
- package/src/components/Chains/ChainList.tsx +6 -5
- package/src/components/Chains/ChainListItem.tsx +29 -0
- package/src/components/Chains/PinChainButton.tsx +51 -0
- package/src/components/Chains/SelectChainContent.tsx +18 -21
- package/src/components/Chains/VirtualizedChainList.tsx +67 -20
- package/src/components/Header/NavigationHeader.tsx +10 -1
- package/src/components/Messages/MinFromAmountUSDMessage.tsx +35 -0
- package/src/components/Messages/WarningMessages.tsx +8 -0
- package/src/components/Messages/useMessageQueue.ts +16 -4
- package/src/components/Routes/RoutesContent.tsx +6 -2
- package/src/components/Routes/RoutesExpanded.style.ts +3 -2
- package/src/components/SendToWallet/SendToWalletButton.tsx +1 -1
- package/src/components/SendToWallet/SendToWalletExpandButton.tsx +8 -3
- package/src/components/Step/StepProcess.tsx +3 -8
- package/src/components/TokenList/TokenDetailsSheet.tsx +0 -2
- package/src/components/TokenList/TokenDetailsSheetContent.tsx +50 -3
- package/src/components/TokenList/TokenList.tsx +24 -1
- package/src/components/TokenList/TokenListItem.tsx +6 -0
- package/src/components/TokenList/useTokenSelect.ts +2 -4
- package/src/config/version.ts +1 -1
- package/src/hooks/useFromAmountThreshold.ts +35 -0
- package/src/hooks/useGasSufficiency.ts +4 -4
- package/src/hooks/useLongPress.ts +51 -0
- package/src/hooks/useNavigateBack.ts +26 -17
- package/src/hooks/useRouteExecution.ts +1 -3
- package/src/hooks/useRoutes.ts +24 -4
- package/src/hooks/useSettingMonitor.ts +7 -11
- package/src/hooks/useTokenAddressBalance.ts +6 -1
- package/src/hooks/useTokenBalances.ts +3 -10
- package/src/hooks/useTokenSearch.ts +7 -4
- package/src/hooks/useTokens.ts +4 -31
- package/src/hooks/useTools.ts +2 -2
- package/src/i18n/bn.json +5 -2
- package/src/i18n/de.json +5 -2
- package/src/i18n/en.json +5 -2
- package/src/i18n/es.json +5 -2
- package/src/i18n/fr.json +5 -2
- package/src/i18n/hi.json +5 -2
- package/src/i18n/id.json +5 -2
- package/src/i18n/it.json +5 -2
- package/src/i18n/ja.json +5 -2
- package/src/i18n/ko.json +5 -2
- package/src/i18n/pl.json +4 -1
- package/src/i18n/pt.json +5 -2
- package/src/i18n/th.json +5 -2
- package/src/i18n/tr.json +5 -2
- package/src/i18n/uk.json +5 -2
- package/src/i18n/vi.json +5 -2
- package/src/i18n/zh.json +5 -2
- package/src/pages/SelectEnabledToolsPage.tsx +4 -5
- package/src/pages/SelectTokenPage/SearchTokenInput.tsx +19 -7
- package/src/pages/SettingsPage/BridgeAndExchangeSettings.tsx +1 -2
- package/src/pages/TransactionPage/TransactionPage.tsx +17 -9
- package/src/stores/bookmarks/BookmarkStore.tsx +3 -6
- package/src/stores/bookmarks/useBookmarkActions.ts +9 -13
- package/src/stores/bookmarks/useBookmarks.ts +1 -3
- package/src/stores/chains/ChainOrderStore.tsx +26 -8
- package/src/stores/chains/createChainOrderStore.ts +19 -1
- package/src/stores/chains/types.ts +2 -0
- package/src/stores/chains/useChainOrder.ts +1 -5
- package/src/stores/form/useFieldActions.ts +10 -14
- package/src/stores/form/useFieldValues.ts +1 -3
- package/src/stores/form/useFormStore.ts +3 -6
- package/src/stores/form/useTouchedFields.ts +1 -2
- package/src/stores/form/useValidation.ts +5 -5
- package/src/stores/form/useValidationActions.ts +5 -9
- package/src/stores/header/useHeaderStore.tsx +5 -14
- package/src/stores/inputMode/useInputModeStore.ts +29 -0
- package/src/stores/routes/RouteExecutionStore.tsx +3 -3
- package/src/stores/routes/useExecutingRoutesIds.ts +14 -17
- package/src/stores/settings/useSendToWalletStore.ts +11 -8
- package/src/stores/settings/useSettings.ts +8 -11
- package/src/stores/settings/useSettingsActions.ts +8 -12
- package/src/stores/settings/useSettingsStore.ts +8 -1
- package/src/stores/settings/useSplitSubvariantStore.tsx +2 -1
- package/src/themes/createTheme.ts +5 -1
- package/src/types/widget.ts +2 -0
- package/src/utils/format.ts +33 -0
- package/src/utils/getPriceImpact.ts +2 -2
package/src/i18n/vi.json
CHANGED
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"getGas": "Thiết lập gas",
|
|
37
37
|
"learnMore": "Xem thêm",
|
|
38
38
|
"light": "Sáng",
|
|
39
|
-
"max": "
|
|
39
|
+
"max": "",
|
|
40
40
|
"ok": "Ok",
|
|
41
41
|
"options": "Tùy chỉnh",
|
|
42
42
|
"removeTransaction": "Xoá giao dịch",
|
|
@@ -129,6 +129,7 @@
|
|
|
129
129
|
"highValueLoss": "Giá trị của token nhận được đang thấp hơn rất nhiều so với token được swap và chi phí giao dịch.",
|
|
130
130
|
"insufficientFunds": "Bạn không có đủ tiền để thực hiện tác vụ này.",
|
|
131
131
|
"insufficientGas": "Bạn không đủ gas để thực hiện swap. Bạn cần thêm ít nhất:",
|
|
132
|
+
"minFromAmountUSD": "",
|
|
132
133
|
"rateChanged": "Tỉ lệ hoán đổi đã thay đổi. Để tiếp tục Swap, bạn sẽ chấp nhận tỉ lệ mới.",
|
|
133
134
|
"resetSettings": "Thao tác này sẽ đặt lại mức độ ưu tiên của tuyến đường, độ trượt giá, giá gas, bridge và sàn giao dịch.",
|
|
134
135
|
"slippageOutsideRecommendedLimits": "Khả năng trượt giá cao có thể dẫn đến giao dịch không thành công do front-running.",
|
|
@@ -345,6 +346,8 @@
|
|
|
345
346
|
},
|
|
346
347
|
"tokenMetric": {
|
|
347
348
|
"currentPrice": "",
|
|
348
|
-
"contractAddress": ""
|
|
349
|
+
"contractAddress": "",
|
|
350
|
+
"marketCap": "",
|
|
351
|
+
"volume24h": ""
|
|
349
352
|
}
|
|
350
353
|
}
|
package/src/i18n/zh.json
CHANGED
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"getGas": "开始兑换燃气费",
|
|
37
37
|
"learnMore": "了解更多",
|
|
38
38
|
"light": "浅色主题",
|
|
39
|
-
"max": "
|
|
39
|
+
"max": "",
|
|
40
40
|
"ok": "确认",
|
|
41
41
|
"options": "选项",
|
|
42
42
|
"removeTransaction": "删除交易",
|
|
@@ -129,6 +129,7 @@
|
|
|
129
129
|
"highValueLoss": "收到的代币的价值明显低于要被兑换的代币和交易成本。",
|
|
130
130
|
"insufficientFunds": "你没有足够的资金来完成这笔交易。",
|
|
131
131
|
"insufficientGas": "您没有足够的燃气费来完成此次交易。您至少需要添加:",
|
|
132
|
+
"minFromAmountUSD": "",
|
|
132
133
|
"rateChanged": "兑换比例已经改变,如果继续兑换,您将接受新的兑换比例。",
|
|
133
134
|
"resetSettings": "这将重置您的路由优先级,滑点,燃气费,选中的跨链桥和链上交易所。",
|
|
134
135
|
"slippageOutsideRecommendedLimits": "过高的滑点可能会导致交易被抢跑,造成财产损失",
|
|
@@ -345,6 +346,8 @@
|
|
|
345
346
|
},
|
|
346
347
|
"tokenMetric": {
|
|
347
348
|
"currentPrice": "",
|
|
348
|
-
"contractAddress": ""
|
|
349
|
+
"contractAddress": "",
|
|
350
|
+
"marketCap": "",
|
|
351
|
+
"volume24h": ""
|
|
349
352
|
}
|
|
350
353
|
}
|
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
import type { MouseEventHandler } from 'react'
|
|
15
15
|
import { type FormEventHandler, useMemo, useState } from 'react'
|
|
16
16
|
import { useTranslation } from 'react-i18next'
|
|
17
|
-
import { shallow } from 'zustand/shallow'
|
|
18
17
|
import { FullPageContainer } from '../components/FullPageContainer.js'
|
|
19
18
|
import { ListItemText } from '../components/ListItemText.js'
|
|
20
19
|
import { StickySearchInput } from '../components/Search/SearchInput.js'
|
|
@@ -76,10 +75,10 @@ export const SelectEnabledToolsPage: React.FC<{
|
|
|
76
75
|
const typeKey = type.toLowerCase() as 'bridges' | 'exchanges'
|
|
77
76
|
const { tools } = useTools()
|
|
78
77
|
const { setToolValue, toggleToolKeys } = useSettingsActions()
|
|
79
|
-
const [enabledTools, disabledTools] = useSettingsStore(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
)
|
|
78
|
+
const [enabledTools, disabledTools] = useSettingsStore((state) => [
|
|
79
|
+
state[`_enabled${type}`],
|
|
80
|
+
state[`disabled${type}`],
|
|
81
|
+
])
|
|
83
82
|
|
|
84
83
|
const { t } = useTranslation()
|
|
85
84
|
const elementId = useDefaultElementId()
|
|
@@ -1,15 +1,27 @@
|
|
|
1
|
-
import { useEffect } from 'react'
|
|
1
|
+
import { useCallback, useEffect } from 'react'
|
|
2
2
|
import { useTranslation } from 'react-i18next'
|
|
3
3
|
import { SearchInput } from '../../components/Search/SearchInput.js'
|
|
4
4
|
import { useFieldActions } from '../../stores/form/useFieldActions.js'
|
|
5
|
-
import {
|
|
5
|
+
import { useFieldValues } from '../../stores/form/useFieldValues.js'
|
|
6
6
|
|
|
7
7
|
export const SearchTokenInput = () => {
|
|
8
8
|
const { t } = useTranslation()
|
|
9
|
-
const
|
|
10
|
-
const {
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const [value] = useFieldValues('tokenSearchFilter')
|
|
10
|
+
const { setFieldValue, setAsTouched } = useFieldActions()
|
|
11
|
+
|
|
12
|
+
const onChange = useCallback(
|
|
13
|
+
(newValue: string | number | undefined) => {
|
|
14
|
+
setFieldValue('tokenSearchFilter', newValue, {
|
|
15
|
+
isDirty: true,
|
|
16
|
+
isTouched: true,
|
|
17
|
+
})
|
|
18
|
+
},
|
|
19
|
+
[setFieldValue]
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
const onBlur = useCallback(() => {
|
|
23
|
+
setAsTouched('tokenSearchFilter')
|
|
24
|
+
}, [setAsTouched])
|
|
13
25
|
|
|
14
26
|
useEffect(
|
|
15
27
|
() => () => {
|
|
@@ -20,7 +32,7 @@ export const SearchTokenInput = () => {
|
|
|
20
32
|
|
|
21
33
|
return (
|
|
22
34
|
<SearchInput
|
|
23
|
-
name=
|
|
35
|
+
name="tokenSearchFilter"
|
|
24
36
|
placeholder={t('main.tokenSearch')}
|
|
25
37
|
onChange={(e) => onChange((e.target as HTMLInputElement).value)}
|
|
26
38
|
onBlur={onBlur}
|
|
@@ -2,7 +2,6 @@ import AirlineStops from '@mui/icons-material/AirlineStops'
|
|
|
2
2
|
import SwapHoriz from '@mui/icons-material/SwapHoriz'
|
|
3
3
|
import { useTranslation } from 'react-i18next'
|
|
4
4
|
import { useNavigate } from 'react-router-dom'
|
|
5
|
-
import { shallow } from 'zustand/shallow'
|
|
6
5
|
import { CardButton } from '../../components/Card/CardButton.js'
|
|
7
6
|
import { useSettingMonitor } from '../../hooks/useSettingMonitor.js'
|
|
8
7
|
import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js'
|
|
@@ -25,7 +24,7 @@ export const BridgeAndExchangeSettings: React.FC<{
|
|
|
25
24
|
const [enabledTools, tools] = useSettingsStore((state) => {
|
|
26
25
|
const enabledTools = Object.values(state[`_enabled${type}`])
|
|
27
26
|
return [enabledTools.filter(Boolean).length, enabledTools.length]
|
|
28
|
-
}
|
|
27
|
+
})
|
|
29
28
|
|
|
30
29
|
const { hiddenUI } = useWidgetConfig()
|
|
31
30
|
|
|
@@ -19,6 +19,7 @@ import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.j
|
|
|
19
19
|
import { useFieldActions } from '../../stores/form/useFieldActions.js'
|
|
20
20
|
import { RouteExecutionStatus } from '../../stores/routes/types.js'
|
|
21
21
|
import { WidgetEvent } from '../../types/events.js'
|
|
22
|
+
import { HiddenUI } from '../../types/widget.js'
|
|
22
23
|
import { getAccumulatedFeeCostsBreakdown } from '../../utils/fees.js'
|
|
23
24
|
import { ConfirmToAddressSheet } from './ConfirmToAddressSheet.js'
|
|
24
25
|
import type { ExchangeRateBottomSheetBase } from './ExchangeRateBottomSheet.js'
|
|
@@ -37,8 +38,12 @@ export const TransactionPage: React.FC = () => {
|
|
|
37
38
|
const { setFieldValue } = useFieldActions()
|
|
38
39
|
const emitter = useWidgetEvents()
|
|
39
40
|
const { navigateBack } = useNavigateBack()
|
|
40
|
-
const {
|
|
41
|
-
|
|
41
|
+
const {
|
|
42
|
+
subvariant,
|
|
43
|
+
subvariantOptions,
|
|
44
|
+
contractSecondaryComponent,
|
|
45
|
+
hiddenUI,
|
|
46
|
+
} = useWidgetConfig()
|
|
42
47
|
const { state }: any = useLocation()
|
|
43
48
|
const stateRouteId = state?.routeId
|
|
44
49
|
const [routeId, setRouteId] = useState<string>(stateRouteId)
|
|
@@ -141,7 +146,8 @@ export const TransactionPage: React.FC = () => {
|
|
|
141
146
|
toAddress &&
|
|
142
147
|
!hasActivity &&
|
|
143
148
|
!isLoadingAddressActivity &&
|
|
144
|
-
isActivityAddressFetched
|
|
149
|
+
isActivityAddressFetched &&
|
|
150
|
+
!hiddenUI?.includes(HiddenUI.LowAddressActivityConfirmation)
|
|
145
151
|
) {
|
|
146
152
|
confirmToAddressSheetRef.current?.open()
|
|
147
153
|
return
|
|
@@ -248,12 +254,14 @@ export const TransactionPage: React.FC = () => {
|
|
|
248
254
|
/>
|
|
249
255
|
) : null}
|
|
250
256
|
<ExchangeRateBottomSheet ref={exchangeRateBottomSheetRef} />
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
+
{!hiddenUI?.includes(HiddenUI.LowAddressActivityConfirmation) ? (
|
|
258
|
+
<ConfirmToAddressSheet
|
|
259
|
+
ref={confirmToAddressSheetRef}
|
|
260
|
+
onContinue={handleExecuteRoute}
|
|
261
|
+
toAddress={toAddress!}
|
|
262
|
+
toChainId={route.toChainId!}
|
|
263
|
+
/>
|
|
264
|
+
) : null}
|
|
257
265
|
</PageContainer>
|
|
258
266
|
)
|
|
259
267
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createContext, useContext, useRef } from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { useShallow } from 'zustand/shallow'
|
|
3
3
|
import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js'
|
|
4
4
|
import type { PersistStoreProviderProps } from '../types.js'
|
|
5
5
|
import { createBookmarksStore } from './createBookmarkStore.js'
|
|
@@ -25,10 +25,7 @@ export const BookmarkStoreProvider: React.FC<PersistStoreProviderProps> = ({
|
|
|
25
25
|
)
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export function useBookmarkStore<T>(
|
|
29
|
-
selector: (store: BookmarkState) => T,
|
|
30
|
-
equalityFunction = shallow
|
|
31
|
-
) {
|
|
28
|
+
export function useBookmarkStore<T>(selector: (store: BookmarkState) => T) {
|
|
32
29
|
const useStore = useContext(BookmarkStoreContext)
|
|
33
30
|
|
|
34
31
|
if (!useStore) {
|
|
@@ -37,5 +34,5 @@ export function useBookmarkStore<T>(
|
|
|
37
34
|
)
|
|
38
35
|
}
|
|
39
36
|
|
|
40
|
-
return useStore(selector
|
|
37
|
+
return useStore(useShallow(selector))
|
|
41
38
|
}
|
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
import { shallow } from 'zustand/shallow'
|
|
2
1
|
import { useBookmarkStore } from './BookmarkStore.js'
|
|
3
2
|
import type { BookmarkActions } from './types.js'
|
|
4
3
|
|
|
5
4
|
export const useBookmarkActions = () => {
|
|
6
|
-
const actions = useBookmarkStore<BookmarkActions>(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}),
|
|
16
|
-
shallow
|
|
17
|
-
)
|
|
5
|
+
const actions = useBookmarkStore<BookmarkActions>((store) => ({
|
|
6
|
+
getBookmark: store.getBookmark,
|
|
7
|
+
addBookmark: store.addBookmark,
|
|
8
|
+
removeBookmark: store.removeBookmark,
|
|
9
|
+
setSelectedBookmark: store.setSelectedBookmark,
|
|
10
|
+
getSelectedBookmark: store.getSelectedBookmark,
|
|
11
|
+
addRecentWallet: store.addRecentWallet,
|
|
12
|
+
removeRecentWallet: store.removeRecentWallet,
|
|
13
|
+
}))
|
|
18
14
|
|
|
19
15
|
return actions
|
|
20
16
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { shallow } from 'zustand/shallow'
|
|
2
1
|
import { useBookmarkStore } from './BookmarkStore.js'
|
|
3
2
|
import type { BookmarkProps } from './types.js'
|
|
4
3
|
|
|
5
4
|
export const useBookmarks = (): BookmarkProps => {
|
|
6
5
|
const [bookmarks, selectedBookmark, recentWallets] = useBookmarkStore(
|
|
7
|
-
(store) => [store.bookmarks, store.selectedBookmark, store.recentWallets]
|
|
8
|
-
shallow
|
|
6
|
+
(store) => [store.bookmarks, store.selectedBookmark, store.recentWallets]
|
|
9
7
|
)
|
|
10
8
|
|
|
11
9
|
return {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createContext, useContext, useEffect, useRef } from 'react'
|
|
2
2
|
import type { StoreApi } from 'zustand'
|
|
3
|
+
import { useShallow } from 'zustand/shallow'
|
|
3
4
|
import type { UseBoundStoreWithEqualityFn } from 'zustand/traditional'
|
|
4
5
|
import { useChains } from '../../hooks/useChains.js'
|
|
5
6
|
import { useExternalWalletProvider } from '../../providers/WalletProvider/useExternalWalletProvider.js'
|
|
@@ -27,6 +28,7 @@ export function ChainOrderStoreProvider({
|
|
|
27
28
|
const storeRef = useRef<ChainOrderStore>(null)
|
|
28
29
|
const { chains } = useChains()
|
|
29
30
|
const { setFieldValue, getFieldValues } = useFieldActions()
|
|
31
|
+
const { variant, subvariantOptions } = useWidgetConfig()
|
|
30
32
|
const { externalChainTypes, useExternalWalletProvidersOnly } =
|
|
31
33
|
useExternalWalletProvider()
|
|
32
34
|
|
|
@@ -58,15 +60,30 @@ export function ChainOrderStoreProvider({
|
|
|
58
60
|
: true
|
|
59
61
|
return passesChainsConfigFilter && passesWalletConfigFilter
|
|
60
62
|
})
|
|
63
|
+
|
|
61
64
|
const chainOrder = storeRef.current?.getState().initializeChains(
|
|
62
65
|
filteredChains.map((chain) => chain.id),
|
|
63
66
|
key
|
|
64
67
|
)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
|
|
69
|
+
const [chainValue] = getFieldValues(`${key}Chain`)
|
|
70
|
+
if (chainValue) {
|
|
71
|
+
return
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const firstAllowedPinnedChain = storeRef.current
|
|
75
|
+
?.getState()
|
|
76
|
+
.pinnedChains?.find((chainId) =>
|
|
77
|
+
filteredChains.some((chain) => chain.id === chainId)
|
|
78
|
+
)
|
|
79
|
+
if (
|
|
80
|
+
variant === 'wide' &&
|
|
81
|
+
subvariantOptions?.wide?.enableChainSidebar &&
|
|
82
|
+
firstAllowedPinnedChain
|
|
83
|
+
) {
|
|
84
|
+
setFieldValue(`${key}Chain`, firstAllowedPinnedChain)
|
|
85
|
+
} else if (chainOrder?.length) {
|
|
86
|
+
setFieldValue(`${key}Chain`, chainOrder[0])
|
|
70
87
|
}
|
|
71
88
|
})
|
|
72
89
|
}
|
|
@@ -77,6 +94,8 @@ export function ChainOrderStoreProvider({
|
|
|
77
94
|
getFieldValues,
|
|
78
95
|
setFieldValue,
|
|
79
96
|
useExternalWalletProvidersOnly,
|
|
97
|
+
variant,
|
|
98
|
+
subvariantOptions?.wide?.enableChainSidebar,
|
|
80
99
|
])
|
|
81
100
|
|
|
82
101
|
return (
|
|
@@ -97,9 +116,8 @@ export function useChainOrderStoreContext() {
|
|
|
97
116
|
}
|
|
98
117
|
|
|
99
118
|
export function useChainOrderStore<T>(
|
|
100
|
-
selector: (state: ChainOrderState) => T
|
|
101
|
-
equalityFn?: (left: T, right: T) => boolean
|
|
119
|
+
selector: (state: ChainOrderState) => T
|
|
102
120
|
): T {
|
|
103
121
|
const useStore = useChainOrderStoreContext()
|
|
104
|
-
return useStore(selector
|
|
122
|
+
return useStore(useShallow(selector))
|
|
105
123
|
}
|
|
@@ -17,6 +17,7 @@ export const createChainOrderStore = ({ namePrefix }: PersistStoreProps) =>
|
|
|
17
17
|
(set, get) => ({
|
|
18
18
|
chainOrder: defaultChainState,
|
|
19
19
|
availableChains: defaultChainState,
|
|
20
|
+
pinnedChains: [],
|
|
20
21
|
initializeChains: (chainIds, type) => {
|
|
21
22
|
set((state: ChainOrderState) => {
|
|
22
23
|
const chainOrder = state.chainOrder[type].filter((chainId) =>
|
|
@@ -76,11 +77,28 @@ export const createChainOrderStore = ({ namePrefix }: PersistStoreProps) =>
|
|
|
76
77
|
}
|
|
77
78
|
})
|
|
78
79
|
},
|
|
80
|
+
setPinnedChain: (chainId) => {
|
|
81
|
+
set((state: ChainOrderState) => {
|
|
82
|
+
const pinnedChains = [...state.pinnedChains]
|
|
83
|
+
if (pinnedChains.includes(chainId)) {
|
|
84
|
+
return {
|
|
85
|
+
pinnedChains: pinnedChains.filter((id) => id !== chainId),
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
pinnedChains.push(chainId)
|
|
89
|
+
return {
|
|
90
|
+
pinnedChains,
|
|
91
|
+
}
|
|
92
|
+
})
|
|
93
|
+
},
|
|
79
94
|
}),
|
|
80
95
|
{
|
|
81
96
|
name: `${namePrefix || 'li.fi'}-widget-chains-order`,
|
|
82
97
|
version: 2,
|
|
83
|
-
partialize: (state) => ({
|
|
98
|
+
partialize: (state) => ({
|
|
99
|
+
chainOrder: state.chainOrder,
|
|
100
|
+
pinnedChains: state.pinnedChains,
|
|
101
|
+
}),
|
|
84
102
|
}
|
|
85
103
|
) as StateCreator<ChainOrderState, [], [], ChainOrderState>,
|
|
86
104
|
Object.is
|
|
@@ -9,9 +9,11 @@ export interface ChainOrderProps {
|
|
|
9
9
|
from: number[]
|
|
10
10
|
to: number[]
|
|
11
11
|
}
|
|
12
|
+
pinnedChains: number[]
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
export interface ChainOrderState extends ChainOrderProps {
|
|
15
16
|
initializeChains(chainIds: number[], type: FormType): number[]
|
|
16
17
|
setChain(chainId: number, type: FormType): void
|
|
18
|
+
setPinnedChain(chainId: number): void
|
|
17
19
|
}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import { shallow } from 'zustand/shallow'
|
|
2
1
|
import type { FormType } from '../form/types.js'
|
|
3
2
|
import { useChainOrderStore } from './ChainOrderStore.js'
|
|
4
3
|
|
|
5
4
|
export const useChainOrder = (
|
|
6
5
|
type: FormType
|
|
7
6
|
): [number[], (chainId: number, type: FormType) => void] => {
|
|
8
|
-
return useChainOrderStore(
|
|
9
|
-
(state) => [state.chainOrder[type], state.setChain],
|
|
10
|
-
shallow
|
|
11
|
-
)
|
|
7
|
+
return useChainOrderStore((state) => [state.chainOrder[type], state.setChain])
|
|
12
8
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { useCallback } from 'react'
|
|
2
|
-
import { shallow } from 'zustand/shallow'
|
|
3
2
|
import { useWidgetEvents } from '../../hooks/useWidgetEvents.js'
|
|
4
3
|
import type { FormFieldChanged } from '../../types/events.js'
|
|
5
4
|
import { WidgetEvent } from '../../types/events.js'
|
|
@@ -14,19 +13,16 @@ import { useFormStore } from './useFormStore.js'
|
|
|
14
13
|
|
|
15
14
|
export const useFieldActions = () => {
|
|
16
15
|
const emitter = useWidgetEvents()
|
|
17
|
-
const actions = useFormStore<FormActions>(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}),
|
|
28
|
-
shallow
|
|
29
|
-
)
|
|
16
|
+
const actions = useFormStore<FormActions>((store) => ({
|
|
17
|
+
getFieldValues: store.getFieldValues,
|
|
18
|
+
isTouched: store.isTouched,
|
|
19
|
+
isDirty: store.isDirty,
|
|
20
|
+
resetField: store.resetField,
|
|
21
|
+
setAsTouched: store.setAsTouched,
|
|
22
|
+
setDefaultValues: store.setDefaultValues,
|
|
23
|
+
setFieldValue: store.setFieldValue,
|
|
24
|
+
setUserAndDefaultValues: store.setUserAndDefaultValues,
|
|
25
|
+
}))
|
|
30
26
|
|
|
31
27
|
const setFieldValueWithEmittedEvents = useCallback(
|
|
32
28
|
(
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { shallow } from 'zustand/shallow'
|
|
2
1
|
import type { FormFieldArray, FormFieldNames } from './types.js'
|
|
3
2
|
import { useFormStore } from './useFormStore.js'
|
|
4
3
|
|
|
@@ -6,8 +5,7 @@ import { useFormStore } from './useFormStore.js'
|
|
|
6
5
|
export const useFieldValues = <T extends FormFieldNames[]>(...names: T) => {
|
|
7
6
|
const values = useFormStore(
|
|
8
7
|
(store) =>
|
|
9
|
-
names.map((name) => store.userValues[name]?.value) as FormFieldArray<T
|
|
10
|
-
shallow
|
|
8
|
+
names.map((name) => store.userValues[name]?.value) as FormFieldArray<T>
|
|
11
9
|
)
|
|
12
10
|
|
|
13
11
|
return values
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { useContext } from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { useShallow } from 'zustand/shallow'
|
|
3
3
|
import { FormStoreContext } from './FormStoreContext.js'
|
|
4
4
|
import type { FormValuesState } from './types.js'
|
|
5
5
|
|
|
6
|
-
export function useFormStore<T>(
|
|
7
|
-
selector: (state: FormValuesState) => T,
|
|
8
|
-
equalityFn = shallow
|
|
9
|
-
): T {
|
|
6
|
+
export function useFormStore<T>(selector: (state: FormValuesState) => T): T {
|
|
10
7
|
const useStore = useContext(FormStoreContext)
|
|
11
8
|
|
|
12
9
|
if (!useStore) {
|
|
13
10
|
throw new Error('You forgot to wrap your component in <FormStoreProvider>.')
|
|
14
11
|
}
|
|
15
12
|
|
|
16
|
-
return useStore(selector
|
|
13
|
+
return useStore(useShallow(selector))
|
|
17
14
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { shallow } from 'zustand/shallow'
|
|
2
1
|
import { useFormStore } from './useFormStore.js'
|
|
3
2
|
|
|
4
3
|
export const useTouchedFields = () => {
|
|
5
|
-
const touchedFields = useFormStore((store) => store.touchedFields
|
|
4
|
+
const touchedFields = useFormStore((store) => store.touchedFields)
|
|
6
5
|
|
|
7
6
|
return touchedFields
|
|
8
7
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { shallow } from 'zustand/shallow'
|
|
2
1
|
import type { ValidationProps } from './types.js'
|
|
3
2
|
import { useFormStore } from './useFormStore.js'
|
|
4
3
|
export const useValidation = (): Omit<ValidationProps, 'validation'> => {
|
|
5
|
-
const [isValid, isValidating, errors] = useFormStore(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const [isValid, isValidating, errors] = useFormStore((store) => [
|
|
5
|
+
store.isValid,
|
|
6
|
+
store.isValidating,
|
|
7
|
+
store.errors,
|
|
8
|
+
])
|
|
9
9
|
|
|
10
10
|
return {
|
|
11
11
|
isValid,
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import { shallow } from 'zustand/shallow'
|
|
2
1
|
import type { ValidationActions } from './types.js'
|
|
3
2
|
import { useFormStore } from './useFormStore.js'
|
|
4
3
|
|
|
5
4
|
export const useValidationActions = () => {
|
|
6
|
-
const actions = useFormStore<ValidationActions>(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}),
|
|
12
|
-
shallow
|
|
13
|
-
)
|
|
5
|
+
const actions = useFormStore<ValidationActions>((store) => ({
|
|
6
|
+
addFieldValidation: store.addFieldValidation,
|
|
7
|
+
triggerFieldValidation: store.triggerFieldValidation,
|
|
8
|
+
clearErrors: store.clearErrors,
|
|
9
|
+
}))
|
|
14
10
|
|
|
15
11
|
return actions
|
|
16
12
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createContext, useContext, useRef } from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { useShallow } from 'zustand/shallow'
|
|
3
3
|
import { createWithEqualityFn } from 'zustand/traditional'
|
|
4
4
|
import type { PersistStoreProviderProps } from '../types.js'
|
|
5
5
|
import type { HeaderState, HeaderStore } from './types.js'
|
|
@@ -28,12 +28,9 @@ export function useHeaderStoreContext() {
|
|
|
28
28
|
return useStore
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
export function useHeaderStore<T>(
|
|
32
|
-
selector: (state: HeaderState) => T,
|
|
33
|
-
equalityCheck?: (objA: T, objB: T) => boolean
|
|
34
|
-
): T {
|
|
31
|
+
export function useHeaderStore<T>(selector: (state: HeaderState) => T): T {
|
|
35
32
|
const useStore = useHeaderStoreContext()
|
|
36
|
-
return useStore(selector
|
|
33
|
+
return useStore(useShallow(selector))
|
|
37
34
|
}
|
|
38
35
|
|
|
39
36
|
// We use fixed position on the header when Widget is in Full Height layout.
|
|
@@ -42,10 +39,7 @@ export function useHeaderStore<T>(
|
|
|
42
39
|
// To prevent the remaining page content from appearing behind the header we need to
|
|
43
40
|
// pass the headers height so that the position of the page content can be adjusted
|
|
44
41
|
export function useHeaderHeight() {
|
|
45
|
-
const
|
|
46
|
-
(state) => [state.headerHeight],
|
|
47
|
-
shallow
|
|
48
|
-
)
|
|
42
|
+
const headerHeight = useHeaderStore((state) => state.headerHeight)
|
|
49
43
|
|
|
50
44
|
return {
|
|
51
45
|
headerHeight,
|
|
@@ -53,10 +47,7 @@ export function useHeaderHeight() {
|
|
|
53
47
|
}
|
|
54
48
|
|
|
55
49
|
export function useSetHeaderHeight() {
|
|
56
|
-
const
|
|
57
|
-
(state) => [state.setHeaderHeight],
|
|
58
|
-
shallow
|
|
59
|
-
)
|
|
50
|
+
const setHeaderHeight = useHeaderStore((state) => state.setHeaderHeight)
|
|
60
51
|
|
|
61
52
|
return {
|
|
62
53
|
setHeaderHeight,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { create } from 'zustand'
|
|
2
|
+
import type { FormTypeProps } from '../form/types.js'
|
|
3
|
+
|
|
4
|
+
export type InputMode = 'amount' | 'price'
|
|
5
|
+
|
|
6
|
+
interface InputModeState {
|
|
7
|
+
inputMode: Record<'from' | 'to', InputMode>
|
|
8
|
+
setInputMode: (formType: FormTypeProps['formType'], mode: InputMode) => void
|
|
9
|
+
toggleInputMode: (formType: FormTypeProps['formType']) => void
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const useInputModeStore = create<InputModeState>((set, get) => ({
|
|
13
|
+
inputMode: {
|
|
14
|
+
from: 'amount',
|
|
15
|
+
to: 'amount',
|
|
16
|
+
},
|
|
17
|
+
setInputMode: (formType, mode) =>
|
|
18
|
+
set((state) => ({
|
|
19
|
+
inputMode: {
|
|
20
|
+
...state.inputMode,
|
|
21
|
+
[formType]: mode,
|
|
22
|
+
},
|
|
23
|
+
})),
|
|
24
|
+
toggleInputMode: (formType) => {
|
|
25
|
+
const currentMode = get().inputMode[formType]
|
|
26
|
+
const newMode = currentMode === 'amount' ? 'price' : 'amount'
|
|
27
|
+
get().setInputMode(formType, newMode)
|
|
28
|
+
},
|
|
29
|
+
}))
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createContext, useContext, useRef } from 'react'
|
|
2
2
|
import type { StoreApi } from 'zustand'
|
|
3
|
+
import { useShallow } from 'zustand/shallow'
|
|
3
4
|
import type { UseBoundStoreWithEqualityFn } from 'zustand/traditional'
|
|
4
5
|
import type { PersistStoreProviderProps } from '../types.js'
|
|
5
6
|
import { createRouteExecutionStore } from './createRouteExecutionStore.js'
|
|
@@ -38,9 +39,8 @@ export function useRouteExecutionStoreContext() {
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
export function useRouteExecutionStore<T>(
|
|
41
|
-
selector: (state: RouteExecutionState) => T
|
|
42
|
-
equalityFn?: (left: T, right: T) => boolean
|
|
42
|
+
selector: (state: RouteExecutionState) => T
|
|
43
43
|
): T {
|
|
44
44
|
const useStore = useRouteExecutionStoreContext()
|
|
45
|
-
return useStore(selector
|
|
45
|
+
return useStore(useShallow(selector))
|
|
46
46
|
}
|