@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.
Files changed (274) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/dist/esm/components/AmountInput/AmountInput.js +75 -17
  3. package/dist/esm/components/AmountInput/AmountInput.js.map +1 -1
  4. package/dist/esm/components/AmountInput/AmountInput.style.d.ts +4 -0
  5. package/dist/esm/components/AmountInput/AmountInput.style.js +11 -0
  6. package/dist/esm/components/AmountInput/AmountInput.style.js.map +1 -1
  7. package/dist/esm/components/AmountInput/AmountInputAdornment.style.d.ts +1 -0
  8. package/dist/esm/components/AmountInput/AmountInputAdornment.style.js +64 -5
  9. package/dist/esm/components/AmountInput/AmountInputAdornment.style.js.map +1 -1
  10. package/dist/esm/components/AmountInput/AmountInputEndAdornment.js +20 -7
  11. package/dist/esm/components/AmountInput/AmountInputEndAdornment.js.map +1 -1
  12. package/dist/esm/components/AmountInput/PriceFormHelperText.js +41 -15
  13. package/dist/esm/components/AmountInput/PriceFormHelperText.js.map +1 -1
  14. package/dist/esm/components/AmountInput/PriceFormHelperText.style.d.ts +1 -0
  15. package/dist/esm/components/AmountInput/PriceFormHelperText.style.js +29 -0
  16. package/dist/esm/components/AmountInput/PriceFormHelperText.style.js.map +1 -0
  17. package/dist/esm/components/AppContainer.js +1 -0
  18. package/dist/esm/components/AppContainer.js.map +1 -1
  19. package/dist/esm/components/ChainSelect/useChainSelect.js +2 -4
  20. package/dist/esm/components/ChainSelect/useChainSelect.js.map +1 -1
  21. package/dist/esm/components/Chains/ChainList.d.ts +2 -3
  22. package/dist/esm/components/Chains/ChainList.js +4 -3
  23. package/dist/esm/components/Chains/ChainList.js.map +1 -1
  24. package/dist/esm/components/Chains/ChainList.style.js +10 -3
  25. package/dist/esm/components/Chains/ChainList.style.js.map +1 -1
  26. package/dist/esm/components/Chains/ChainListItem.d.ts +4 -1
  27. package/dist/esm/components/Chains/ChainListItem.js +14 -2
  28. package/dist/esm/components/Chains/ChainListItem.js.map +1 -1
  29. package/dist/esm/components/Chains/PinChainButton.d.ts +7 -0
  30. package/dist/esm/components/Chains/PinChainButton.js +34 -0
  31. package/dist/esm/components/Chains/PinChainButton.js.map +1 -0
  32. package/dist/esm/components/Chains/SelectChainContent.js +15 -16
  33. package/dist/esm/components/Chains/SelectChainContent.js.map +1 -1
  34. package/dist/esm/components/Chains/VirtualizedChainList.d.ts +2 -1
  35. package/dist/esm/components/Chains/VirtualizedChainList.js +45 -9
  36. package/dist/esm/components/Chains/VirtualizedChainList.js.map +1 -1
  37. package/dist/esm/components/Header/NavigationHeader.js +5 -1
  38. package/dist/esm/components/Header/NavigationHeader.js.map +1 -1
  39. package/dist/esm/components/Messages/MinFromAmountUSDMessage.d.ts +6 -0
  40. package/dist/esm/components/Messages/MinFromAmountUSDMessage.js +15 -0
  41. package/dist/esm/components/Messages/MinFromAmountUSDMessage.js.map +1 -0
  42. package/dist/esm/components/Messages/WarningMessages.js +3 -0
  43. package/dist/esm/components/Messages/WarningMessages.js.map +1 -1
  44. package/dist/esm/components/Messages/useMessageQueue.js +15 -4
  45. package/dist/esm/components/Messages/useMessageQueue.js.map +1 -1
  46. package/dist/esm/components/Routes/RoutesContent.js +3 -2
  47. package/dist/esm/components/Routes/RoutesContent.js.map +1 -1
  48. package/dist/esm/components/Routes/RoutesExpanded.style.js +3 -2
  49. package/dist/esm/components/Routes/RoutesExpanded.style.js.map +1 -1
  50. package/dist/esm/components/SendToWallet/SendToWalletButton.js +1 -1
  51. package/dist/esm/components/SendToWallet/SendToWalletButton.js.map +1 -1
  52. package/dist/esm/components/SendToWallet/SendToWalletExpandButton.js +3 -3
  53. package/dist/esm/components/SendToWallet/SendToWalletExpandButton.js.map +1 -1
  54. package/dist/esm/components/Step/StepProcess.js +3 -8
  55. package/dist/esm/components/Step/StepProcess.js.map +1 -1
  56. package/dist/esm/components/TokenList/TokenDetailsSheet.js +0 -2
  57. package/dist/esm/components/TokenList/TokenDetailsSheet.js.map +1 -1
  58. package/dist/esm/components/TokenList/TokenDetailsSheetContent.js +27 -4
  59. package/dist/esm/components/TokenList/TokenDetailsSheetContent.js.map +1 -1
  60. package/dist/esm/components/TokenList/TokenList.js +10 -1
  61. package/dist/esm/components/TokenList/TokenList.js.map +1 -1
  62. package/dist/esm/components/TokenList/TokenListItem.js +3 -1
  63. package/dist/esm/components/TokenList/TokenListItem.js.map +1 -1
  64. package/dist/esm/components/TokenList/useTokenSelect.js +2 -4
  65. package/dist/esm/components/TokenList/useTokenSelect.js.map +1 -1
  66. package/dist/esm/config/version.d.ts +1 -1
  67. package/dist/esm/config/version.js +1 -1
  68. package/dist/esm/config/version.js.map +1 -1
  69. package/dist/esm/hooks/useFromAmountThreshold.d.ts +4 -0
  70. package/dist/esm/hooks/useFromAmountThreshold.js +23 -0
  71. package/dist/esm/hooks/useFromAmountThreshold.js.map +1 -0
  72. package/dist/esm/hooks/useGasSufficiency.js +3 -3
  73. package/dist/esm/hooks/useGasSufficiency.js.map +1 -1
  74. package/dist/esm/hooks/useLongPress.d.ts +7 -0
  75. package/dist/esm/hooks/useLongPress.js +41 -0
  76. package/dist/esm/hooks/useLongPress.js.map +1 -0
  77. package/dist/esm/hooks/useNavigateBack.d.ts +1 -1
  78. package/dist/esm/hooks/useNavigateBack.js +8 -2
  79. package/dist/esm/hooks/useNavigateBack.js.map +1 -1
  80. package/dist/esm/hooks/useRouteExecution.js +1 -2
  81. package/dist/esm/hooks/useRouteExecution.js.map +1 -1
  82. package/dist/esm/hooks/useRoutes.js +19 -4
  83. package/dist/esm/hooks/useRoutes.js.map +1 -1
  84. package/dist/esm/hooks/useSettingMonitor.js +1 -2
  85. package/dist/esm/hooks/useSettingMonitor.js.map +1 -1
  86. package/dist/esm/hooks/useTokenAddressBalance.js +4 -1
  87. package/dist/esm/hooks/useTokenAddressBalance.js.map +1 -1
  88. package/dist/esm/hooks/useTokenBalances.d.ts +1 -2
  89. package/dist/esm/hooks/useTokenBalances.js +2 -3
  90. package/dist/esm/hooks/useTokenBalances.js.map +1 -1
  91. package/dist/esm/hooks/useTokenSearch.d.ts +2 -2
  92. package/dist/esm/hooks/useTokenSearch.js +5 -2
  93. package/dist/esm/hooks/useTokenSearch.js.map +1 -1
  94. package/dist/esm/hooks/useTokens.d.ts +1 -2
  95. package/dist/esm/hooks/useTokens.js +3 -12
  96. package/dist/esm/hooks/useTokens.js.map +1 -1
  97. package/dist/esm/hooks/useTools.js +2 -2
  98. package/dist/esm/hooks/useTools.js.map +1 -1
  99. package/dist/esm/i18n/bn.json +5 -2
  100. package/dist/esm/i18n/de.json +5 -2
  101. package/dist/esm/i18n/en.json +5 -2
  102. package/dist/esm/i18n/es.json +5 -2
  103. package/dist/esm/i18n/fr.json +5 -2
  104. package/dist/esm/i18n/hi.json +5 -2
  105. package/dist/esm/i18n/id.json +5 -2
  106. package/dist/esm/i18n/it.json +5 -2
  107. package/dist/esm/i18n/ja.json +5 -2
  108. package/dist/esm/i18n/ko.json +5 -2
  109. package/dist/esm/i18n/pl.json +4 -1
  110. package/dist/esm/i18n/pt.json +5 -2
  111. package/dist/esm/i18n/th.json +5 -2
  112. package/dist/esm/i18n/tr.json +5 -2
  113. package/dist/esm/i18n/uk.json +5 -2
  114. package/dist/esm/i18n/vi.json +5 -2
  115. package/dist/esm/i18n/zh.json +5 -2
  116. package/dist/esm/pages/SelectEnabledToolsPage.js +4 -2
  117. package/dist/esm/pages/SelectEnabledToolsPage.js.map +1 -1
  118. package/dist/esm/pages/SelectTokenPage/SearchTokenInput.js +14 -7
  119. package/dist/esm/pages/SelectTokenPage/SearchTokenInput.js.map +1 -1
  120. package/dist/esm/pages/SettingsPage/BridgeAndExchangeSettings.js +1 -2
  121. package/dist/esm/pages/SettingsPage/BridgeAndExchangeSettings.js.map +1 -1
  122. package/dist/esm/pages/TransactionPage/TransactionPage.js +5 -3
  123. package/dist/esm/pages/TransactionPage/TransactionPage.js.map +1 -1
  124. package/dist/esm/stores/bookmarks/BookmarkStore.d.ts +1 -2
  125. package/dist/esm/stores/bookmarks/BookmarkStore.js +3 -3
  126. package/dist/esm/stores/bookmarks/BookmarkStore.js.map +1 -1
  127. package/dist/esm/stores/bookmarks/useBookmarkActions.js +1 -2
  128. package/dist/esm/stores/bookmarks/useBookmarkActions.js.map +1 -1
  129. package/dist/esm/stores/bookmarks/useBookmarks.js +1 -2
  130. package/dist/esm/stores/bookmarks/useBookmarks.js.map +1 -1
  131. package/dist/esm/stores/chains/ChainOrderStore.d.ts +1 -1
  132. package/dist/esm/stores/chains/ChainOrderStore.js +20 -7
  133. package/dist/esm/stores/chains/ChainOrderStore.js.map +1 -1
  134. package/dist/esm/stores/chains/createChainOrderStore.js +19 -1
  135. package/dist/esm/stores/chains/createChainOrderStore.js.map +1 -1
  136. package/dist/esm/stores/chains/types.d.ts +2 -0
  137. package/dist/esm/stores/chains/useChainOrder.js +1 -2
  138. package/dist/esm/stores/chains/useChainOrder.js.map +1 -1
  139. package/dist/esm/stores/form/useFieldActions.js +1 -2
  140. package/dist/esm/stores/form/useFieldActions.js.map +1 -1
  141. package/dist/esm/stores/form/useFieldValues.js +1 -2
  142. package/dist/esm/stores/form/useFieldValues.js.map +1 -1
  143. package/dist/esm/stores/form/useFormStore.d.ts +1 -2
  144. package/dist/esm/stores/form/useFormStore.js +3 -3
  145. package/dist/esm/stores/form/useFormStore.js.map +1 -1
  146. package/dist/esm/stores/form/useTouchedFields.js +1 -2
  147. package/dist/esm/stores/form/useTouchedFields.js.map +1 -1
  148. package/dist/esm/stores/form/useValidation.js +5 -2
  149. package/dist/esm/stores/form/useValidation.js.map +1 -1
  150. package/dist/esm/stores/form/useValidationActions.js +1 -2
  151. package/dist/esm/stores/form/useValidationActions.js.map +1 -1
  152. package/dist/esm/stores/header/useHeaderStore.d.ts +1 -1
  153. package/dist/esm/stores/header/useHeaderStore.js +5 -5
  154. package/dist/esm/stores/header/useHeaderStore.js.map +1 -1
  155. package/dist/esm/stores/inputMode/useInputModeStore.d.ts +9 -0
  156. package/dist/esm/stores/inputMode/useInputModeStore.js +19 -0
  157. package/dist/esm/stores/inputMode/useInputModeStore.js.map +1 -0
  158. package/dist/esm/stores/routes/RouteExecutionStore.d.ts +1 -1
  159. package/dist/esm/stores/routes/RouteExecutionStore.js +3 -2
  160. package/dist/esm/stores/routes/RouteExecutionStore.js.map +1 -1
  161. package/dist/esm/stores/routes/useExecutingRoutesIds.js +1 -2
  162. package/dist/esm/stores/routes/useExecutingRoutesIds.js.map +1 -1
  163. package/dist/esm/stores/settings/useSendToWalletStore.d.ts +2 -1
  164. package/dist/esm/stores/settings/useSendToWalletStore.js +6 -3
  165. package/dist/esm/stores/settings/useSendToWalletStore.js.map +1 -1
  166. package/dist/esm/stores/settings/useSettings.js +1 -2
  167. package/dist/esm/stores/settings/useSettings.js.map +1 -1
  168. package/dist/esm/stores/settings/useSettingsActions.js +1 -2
  169. package/dist/esm/stores/settings/useSettingsActions.js.map +1 -1
  170. package/dist/esm/stores/settings/useSettingsStore.d.ts +2 -1
  171. package/dist/esm/stores/settings/useSettingsStore.js +5 -1
  172. package/dist/esm/stores/settings/useSettingsStore.js.map +1 -1
  173. package/dist/esm/stores/settings/useSplitSubvariantStore.js +2 -1
  174. package/dist/esm/stores/settings/useSplitSubvariantStore.js.map +1 -1
  175. package/dist/esm/themes/createTheme.js +5 -1
  176. package/dist/esm/themes/createTheme.js.map +1 -1
  177. package/dist/esm/types/widget.d.ts +3 -1
  178. package/dist/esm/types/widget.js +1 -0
  179. package/dist/esm/types/widget.js.map +1 -1
  180. package/dist/esm/utils/format.d.ts +4 -0
  181. package/dist/esm/utils/format.js +26 -0
  182. package/dist/esm/utils/format.js.map +1 -1
  183. package/dist/esm/utils/getPriceImpact.d.ts +2 -2
  184. package/dist/esm/utils/getPriceImpact.js.map +1 -1
  185. package/package.json +12 -12
  186. package/package.json.tmp +14 -14
  187. package/src/components/AmountInput/AmountInput.style.tsx +13 -0
  188. package/src/components/AmountInput/AmountInput.tsx +91 -18
  189. package/src/components/AmountInput/AmountInputAdornment.style.tsx +66 -5
  190. package/src/components/AmountInput/AmountInputEndAdornment.tsx +40 -10
  191. package/src/components/AmountInput/PriceFormHelperText.style.tsx +29 -0
  192. package/src/components/AmountInput/PriceFormHelperText.tsx +63 -19
  193. package/src/components/AppContainer.tsx +1 -0
  194. package/src/components/ChainSelect/useChainSelect.ts +2 -4
  195. package/src/components/Chains/ChainList.style.tsx +10 -2
  196. package/src/components/Chains/ChainList.tsx +6 -5
  197. package/src/components/Chains/ChainListItem.tsx +29 -0
  198. package/src/components/Chains/PinChainButton.tsx +51 -0
  199. package/src/components/Chains/SelectChainContent.tsx +18 -21
  200. package/src/components/Chains/VirtualizedChainList.tsx +67 -20
  201. package/src/components/Header/NavigationHeader.tsx +10 -1
  202. package/src/components/Messages/MinFromAmountUSDMessage.tsx +35 -0
  203. package/src/components/Messages/WarningMessages.tsx +8 -0
  204. package/src/components/Messages/useMessageQueue.ts +16 -4
  205. package/src/components/Routes/RoutesContent.tsx +6 -2
  206. package/src/components/Routes/RoutesExpanded.style.ts +3 -2
  207. package/src/components/SendToWallet/SendToWalletButton.tsx +1 -1
  208. package/src/components/SendToWallet/SendToWalletExpandButton.tsx +8 -3
  209. package/src/components/Step/StepProcess.tsx +3 -8
  210. package/src/components/TokenList/TokenDetailsSheet.tsx +0 -2
  211. package/src/components/TokenList/TokenDetailsSheetContent.tsx +50 -3
  212. package/src/components/TokenList/TokenList.tsx +24 -1
  213. package/src/components/TokenList/TokenListItem.tsx +6 -0
  214. package/src/components/TokenList/useTokenSelect.ts +2 -4
  215. package/src/config/version.ts +1 -1
  216. package/src/hooks/useFromAmountThreshold.ts +35 -0
  217. package/src/hooks/useGasSufficiency.ts +4 -4
  218. package/src/hooks/useLongPress.ts +51 -0
  219. package/src/hooks/useNavigateBack.ts +26 -17
  220. package/src/hooks/useRouteExecution.ts +1 -3
  221. package/src/hooks/useRoutes.ts +24 -4
  222. package/src/hooks/useSettingMonitor.ts +7 -11
  223. package/src/hooks/useTokenAddressBalance.ts +6 -1
  224. package/src/hooks/useTokenBalances.ts +3 -10
  225. package/src/hooks/useTokenSearch.ts +7 -4
  226. package/src/hooks/useTokens.ts +4 -31
  227. package/src/hooks/useTools.ts +2 -2
  228. package/src/i18n/bn.json +5 -2
  229. package/src/i18n/de.json +5 -2
  230. package/src/i18n/en.json +5 -2
  231. package/src/i18n/es.json +5 -2
  232. package/src/i18n/fr.json +5 -2
  233. package/src/i18n/hi.json +5 -2
  234. package/src/i18n/id.json +5 -2
  235. package/src/i18n/it.json +5 -2
  236. package/src/i18n/ja.json +5 -2
  237. package/src/i18n/ko.json +5 -2
  238. package/src/i18n/pl.json +4 -1
  239. package/src/i18n/pt.json +5 -2
  240. package/src/i18n/th.json +5 -2
  241. package/src/i18n/tr.json +5 -2
  242. package/src/i18n/uk.json +5 -2
  243. package/src/i18n/vi.json +5 -2
  244. package/src/i18n/zh.json +5 -2
  245. package/src/pages/SelectEnabledToolsPage.tsx +4 -5
  246. package/src/pages/SelectTokenPage/SearchTokenInput.tsx +19 -7
  247. package/src/pages/SettingsPage/BridgeAndExchangeSettings.tsx +1 -2
  248. package/src/pages/TransactionPage/TransactionPage.tsx +17 -9
  249. package/src/stores/bookmarks/BookmarkStore.tsx +3 -6
  250. package/src/stores/bookmarks/useBookmarkActions.ts +9 -13
  251. package/src/stores/bookmarks/useBookmarks.ts +1 -3
  252. package/src/stores/chains/ChainOrderStore.tsx +26 -8
  253. package/src/stores/chains/createChainOrderStore.ts +19 -1
  254. package/src/stores/chains/types.ts +2 -0
  255. package/src/stores/chains/useChainOrder.ts +1 -5
  256. package/src/stores/form/useFieldActions.ts +10 -14
  257. package/src/stores/form/useFieldValues.ts +1 -3
  258. package/src/stores/form/useFormStore.ts +3 -6
  259. package/src/stores/form/useTouchedFields.ts +1 -2
  260. package/src/stores/form/useValidation.ts +5 -5
  261. package/src/stores/form/useValidationActions.ts +5 -9
  262. package/src/stores/header/useHeaderStore.tsx +5 -14
  263. package/src/stores/inputMode/useInputModeStore.ts +29 -0
  264. package/src/stores/routes/RouteExecutionStore.tsx +3 -3
  265. package/src/stores/routes/useExecutingRoutesIds.ts +14 -17
  266. package/src/stores/settings/useSendToWalletStore.ts +11 -8
  267. package/src/stores/settings/useSettings.ts +8 -11
  268. package/src/stores/settings/useSettingsActions.ts +8 -12
  269. package/src/stores/settings/useSettingsStore.ts +8 -1
  270. package/src/stores/settings/useSplitSubvariantStore.tsx +2 -1
  271. package/src/themes/createTheme.ts +5 -1
  272. package/src/types/widget.ts +2 -0
  273. package/src/utils/format.ts +33 -0
  274. 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": "Tối đa",
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
- (state) => [state[`_enabled${type}`], state[`disabled${type}`]],
81
- shallow
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 { useFieldController } from '../../stores/form/useFieldController.js'
5
+ import { useFieldValues } from '../../stores/form/useFieldValues.js'
6
6
 
7
7
  export const SearchTokenInput = () => {
8
8
  const { t } = useTranslation()
9
- const { setFieldValue } = useFieldActions()
10
- const { onChange, onBlur, name, value } = useFieldController({
11
- name: 'tokenSearchFilter',
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={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
- }, shallow)
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 { subvariant, subvariantOptions, contractSecondaryComponent } =
41
- useWidgetConfig()
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
- <ConfirmToAddressSheet
252
- ref={confirmToAddressSheetRef}
253
- onContinue={handleExecuteRoute}
254
- toAddress={toAddress!}
255
- toChainId={route.toChainId!}
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 { shallow } from 'zustand/shallow'
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, equalityFunction)
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
- (store) => ({
8
- getBookmark: store.getBookmark,
9
- addBookmark: store.addBookmark,
10
- removeBookmark: store.removeBookmark,
11
- setSelectedBookmark: store.setSelectedBookmark,
12
- getSelectedBookmark: store.getSelectedBookmark,
13
- addRecentWallet: store.addRecentWallet,
14
- removeRecentWallet: store.removeRecentWallet,
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
- if (chainOrder) {
66
- const [chainValue] = getFieldValues(`${key}Chain`)
67
- if (!chainValue) {
68
- setFieldValue(`${key}Chain`, chainOrder[0])
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, equalityFn)
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) => ({ chainOrder: state.chainOrder }),
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
- (store) => ({
19
- getFieldValues: store.getFieldValues,
20
- isTouched: store.isTouched,
21
- isDirty: store.isDirty,
22
- resetField: store.resetField,
23
- setAsTouched: store.setAsTouched,
24
- setDefaultValues: store.setDefaultValues,
25
- setFieldValue: store.setFieldValue,
26
- setUserAndDefaultValues: store.setUserAndDefaultValues,
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 { shallow } from 'zustand/shallow'
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, equalityFn)
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, shallow)
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
- (store) => [store.isValid, store.isValidating, store.errors],
7
- shallow
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
- (store) => ({
8
- addFieldValidation: store.addFieldValidation,
9
- triggerFieldValidation: store.triggerFieldValidation,
10
- clearErrors: store.clearErrors,
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 { shallow } from 'zustand/shallow'
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, equalityCheck)
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 [headerHeight] = useHeaderStore(
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 [setHeaderHeight] = useHeaderStore(
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, equalityFn)
45
+ return useStore(useShallow(selector))
46
46
  }