@lifi/widget 3.25.0 → 3.26.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. package/CHANGELOG.md +27 -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/ChainsExpanded.d.ts +1 -1
  22. package/dist/esm/components/Chains/ChainsExpanded.js +3 -2
  23. package/dist/esm/components/Chains/ChainsExpanded.js.map +1 -1
  24. package/dist/esm/components/Chains/ChainsExpanded.style.js +1 -2
  25. package/dist/esm/components/Chains/ChainsExpanded.style.js.map +1 -1
  26. package/dist/esm/components/Chains/SelectChainContent.d.ts +1 -1
  27. package/dist/esm/components/Chains/SelectChainContent.js +3 -2
  28. package/dist/esm/components/Chains/SelectChainContent.js.map +1 -1
  29. package/dist/esm/components/Chains/VirtualizedChainList.js +5 -3
  30. package/dist/esm/components/Chains/VirtualizedChainList.js.map +1 -1
  31. package/dist/esm/components/Expansion/Expansion.js +5 -16
  32. package/dist/esm/components/Expansion/Expansion.js.map +1 -1
  33. package/dist/esm/components/Expansion/Expansion.style.d.ts +32 -0
  34. package/dist/esm/components/Expansion/Expansion.style.js +40 -0
  35. package/dist/esm/components/Expansion/Expansion.style.js.map +1 -0
  36. package/dist/esm/components/Expansion/ExpansionTransition.d.ts +0 -1
  37. package/dist/esm/components/Expansion/ExpansionTransition.js +1 -30
  38. package/dist/esm/components/Expansion/ExpansionTransition.js.map +1 -1
  39. package/dist/esm/components/Header/NavigationHeader.js +5 -1
  40. package/dist/esm/components/Header/NavigationHeader.js.map +1 -1
  41. package/dist/esm/components/Routes/RoutesContent.d.ts +2 -3
  42. package/dist/esm/components/Routes/RoutesContent.js +8 -23
  43. package/dist/esm/components/Routes/RoutesContent.js.map +1 -1
  44. package/dist/esm/components/Routes/RoutesExpanded.d.ts +2 -3
  45. package/dist/esm/components/Routes/RoutesExpanded.js +24 -8
  46. package/dist/esm/components/Routes/RoutesExpanded.js.map +1 -1
  47. package/dist/esm/components/Routes/RoutesExpanded.style.js +2 -2
  48. package/dist/esm/components/Routes/RoutesExpanded.style.js.map +1 -1
  49. package/dist/esm/components/SendToWallet/SendToWalletButton.js +1 -1
  50. package/dist/esm/components/SendToWallet/SendToWalletButton.js.map +1 -1
  51. package/dist/esm/components/SendToWallet/SendToWalletExpandButton.js +3 -3
  52. package/dist/esm/components/SendToWallet/SendToWalletExpandButton.js.map +1 -1
  53. package/dist/esm/components/Step/StepProcess.js +3 -8
  54. package/dist/esm/components/Step/StepProcess.js.map +1 -1
  55. package/dist/esm/components/TokenList/TokenDetailsSheetContent.js +1 -2
  56. package/dist/esm/components/TokenList/TokenDetailsSheetContent.js.map +1 -1
  57. package/dist/esm/components/TokenList/useTokenSelect.js +2 -4
  58. package/dist/esm/components/TokenList/useTokenSelect.js.map +1 -1
  59. package/dist/esm/config/version.d.ts +1 -1
  60. package/dist/esm/config/version.js +1 -1
  61. package/dist/esm/hooks/useFromAmountThreshold.js +2 -2
  62. package/dist/esm/hooks/useFromAmountThreshold.js.map +1 -1
  63. package/dist/esm/hooks/useGasSufficiency.js +3 -3
  64. package/dist/esm/hooks/useGasSufficiency.js.map +1 -1
  65. package/dist/esm/hooks/useNavigateBack.d.ts +1 -1
  66. package/dist/esm/hooks/useNavigateBack.js +8 -2
  67. package/dist/esm/hooks/useNavigateBack.js.map +1 -1
  68. package/dist/esm/hooks/useRouteExecution.js +1 -2
  69. package/dist/esm/hooks/useRouteExecution.js.map +1 -1
  70. package/dist/esm/hooks/useRoutes.js +51 -8
  71. package/dist/esm/hooks/useRoutes.js.map +1 -1
  72. package/dist/esm/hooks/useSettingMonitor.js +1 -2
  73. package/dist/esm/hooks/useSettingMonitor.js.map +1 -1
  74. package/dist/esm/hooks/useTokenAddressBalance.js +4 -1
  75. package/dist/esm/hooks/useTokenAddressBalance.js.map +1 -1
  76. package/dist/esm/hooks/useTokenSearch.js +5 -2
  77. package/dist/esm/hooks/useTokenSearch.js.map +1 -1
  78. package/dist/esm/hooks/useTokens.js +2 -2
  79. package/dist/esm/hooks/useTokens.js.map +1 -1
  80. package/dist/esm/hooks/useTools.js +2 -2
  81. package/dist/esm/hooks/useTools.js.map +1 -1
  82. package/dist/esm/i18n/bn.json +1 -1
  83. package/dist/esm/i18n/de.json +1 -1
  84. package/dist/esm/i18n/en.json +1 -1
  85. package/dist/esm/i18n/es.json +1 -1
  86. package/dist/esm/i18n/fr.json +1 -1
  87. package/dist/esm/i18n/hi.json +1 -1
  88. package/dist/esm/i18n/id.json +1 -1
  89. package/dist/esm/i18n/it.json +1 -1
  90. package/dist/esm/i18n/ja.json +1 -1
  91. package/dist/esm/i18n/ko.json +1 -1
  92. package/dist/esm/i18n/pt.json +1 -1
  93. package/dist/esm/i18n/th.json +1 -1
  94. package/dist/esm/i18n/tr.json +1 -1
  95. package/dist/esm/i18n/uk.json +1 -1
  96. package/dist/esm/i18n/vi.json +1 -1
  97. package/dist/esm/i18n/zh.json +1 -1
  98. package/dist/esm/pages/SelectEnabledToolsPage.js +4 -2
  99. package/dist/esm/pages/SelectEnabledToolsPage.js.map +1 -1
  100. package/dist/esm/pages/SelectTokenPage/SearchTokenInput.js +14 -7
  101. package/dist/esm/pages/SelectTokenPage/SearchTokenInput.js.map +1 -1
  102. package/dist/esm/pages/SettingsPage/BridgeAndExchangeSettings.js +1 -2
  103. package/dist/esm/pages/SettingsPage/BridgeAndExchangeSettings.js.map +1 -1
  104. package/dist/esm/pages/TransactionPage/TransactionPage.js +5 -3
  105. package/dist/esm/pages/TransactionPage/TransactionPage.js.map +1 -1
  106. package/dist/esm/stores/bookmarks/BookmarkStore.d.ts +1 -2
  107. package/dist/esm/stores/bookmarks/BookmarkStore.js +3 -3
  108. package/dist/esm/stores/bookmarks/BookmarkStore.js.map +1 -1
  109. package/dist/esm/stores/bookmarks/useBookmarkActions.js +1 -2
  110. package/dist/esm/stores/bookmarks/useBookmarkActions.js.map +1 -1
  111. package/dist/esm/stores/bookmarks/useBookmarks.js +1 -2
  112. package/dist/esm/stores/bookmarks/useBookmarks.js.map +1 -1
  113. package/dist/esm/stores/chains/ChainOrderStore.d.ts +1 -1
  114. package/dist/esm/stores/chains/ChainOrderStore.js +3 -2
  115. package/dist/esm/stores/chains/ChainOrderStore.js.map +1 -1
  116. package/dist/esm/stores/chains/useChainOrder.js +1 -2
  117. package/dist/esm/stores/chains/useChainOrder.js.map +1 -1
  118. package/dist/esm/stores/form/useFieldActions.js +1 -2
  119. package/dist/esm/stores/form/useFieldActions.js.map +1 -1
  120. package/dist/esm/stores/form/useFieldValues.js +1 -2
  121. package/dist/esm/stores/form/useFieldValues.js.map +1 -1
  122. package/dist/esm/stores/form/useFormStore.d.ts +1 -2
  123. package/dist/esm/stores/form/useFormStore.js +3 -3
  124. package/dist/esm/stores/form/useFormStore.js.map +1 -1
  125. package/dist/esm/stores/form/useTouchedFields.js +1 -2
  126. package/dist/esm/stores/form/useTouchedFields.js.map +1 -1
  127. package/dist/esm/stores/form/useValidation.js +5 -2
  128. package/dist/esm/stores/form/useValidation.js.map +1 -1
  129. package/dist/esm/stores/form/useValidationActions.js +1 -2
  130. package/dist/esm/stores/form/useValidationActions.js.map +1 -1
  131. package/dist/esm/stores/header/useHeaderStore.d.ts +1 -1
  132. package/dist/esm/stores/header/useHeaderStore.js +3 -2
  133. package/dist/esm/stores/header/useHeaderStore.js.map +1 -1
  134. package/dist/esm/stores/inputMode/useInputModeStore.d.ts +9 -0
  135. package/dist/esm/stores/inputMode/useInputModeStore.js +19 -0
  136. package/dist/esm/stores/inputMode/useInputModeStore.js.map +1 -0
  137. package/dist/esm/stores/routes/RouteExecutionStore.d.ts +1 -1
  138. package/dist/esm/stores/routes/RouteExecutionStore.js +3 -2
  139. package/dist/esm/stores/routes/RouteExecutionStore.js.map +1 -1
  140. package/dist/esm/stores/routes/useExecutingRoutesIds.js +1 -2
  141. package/dist/esm/stores/routes/useExecutingRoutesIds.js.map +1 -1
  142. package/dist/esm/stores/settings/useSendToWalletStore.d.ts +2 -1
  143. package/dist/esm/stores/settings/useSendToWalletStore.js +6 -3
  144. package/dist/esm/stores/settings/useSendToWalletStore.js.map +1 -1
  145. package/dist/esm/stores/settings/useSettings.js +1 -2
  146. package/dist/esm/stores/settings/useSettings.js.map +1 -1
  147. package/dist/esm/stores/settings/useSettingsActions.js +1 -2
  148. package/dist/esm/stores/settings/useSettingsActions.js.map +1 -1
  149. package/dist/esm/stores/settings/useSettingsStore.d.ts +2 -1
  150. package/dist/esm/stores/settings/useSettingsStore.js +5 -1
  151. package/dist/esm/stores/settings/useSettingsStore.js.map +1 -1
  152. package/dist/esm/stores/settings/useSplitSubvariantStore.js +2 -1
  153. package/dist/esm/stores/settings/useSplitSubvariantStore.js.map +1 -1
  154. package/dist/esm/themes/createTheme.js +5 -1
  155. package/dist/esm/themes/createTheme.js.map +1 -1
  156. package/dist/esm/types/widget.d.ts +2 -1
  157. package/dist/esm/types/widget.js +1 -0
  158. package/dist/esm/types/widget.js.map +1 -1
  159. package/dist/esm/utils/format.d.ts +4 -0
  160. package/dist/esm/utils/format.js +26 -0
  161. package/dist/esm/utils/format.js.map +1 -1
  162. package/dist/esm/utils/getPriceImpact.d.ts +2 -2
  163. package/dist/esm/utils/getPriceImpact.js.map +1 -1
  164. package/package.json +12 -12
  165. package/package.json.tmp +14 -14
  166. package/src/components/AmountInput/AmountInput.style.tsx +13 -0
  167. package/src/components/AmountInput/AmountInput.tsx +91 -18
  168. package/src/components/AmountInput/AmountInputAdornment.style.tsx +66 -5
  169. package/src/components/AmountInput/AmountInputEndAdornment.tsx +40 -10
  170. package/src/components/AmountInput/PriceFormHelperText.style.tsx +29 -0
  171. package/src/components/AmountInput/PriceFormHelperText.tsx +63 -19
  172. package/src/components/AppContainer.tsx +1 -0
  173. package/src/components/ChainSelect/useChainSelect.ts +2 -4
  174. package/src/components/Chains/ChainsExpanded.style.tsx +1 -2
  175. package/src/components/Chains/ChainsExpanded.tsx +6 -2
  176. package/src/components/Chains/SelectChainContent.tsx +81 -82
  177. package/src/components/Chains/VirtualizedChainList.tsx +5 -6
  178. package/src/components/Expansion/Expansion.style.tsx +43 -0
  179. package/src/components/Expansion/Expansion.tsx +8 -23
  180. package/src/components/Expansion/ExpansionTransition.tsx +5 -33
  181. package/src/components/Header/NavigationHeader.tsx +10 -1
  182. package/src/components/Routes/RoutesContent.tsx +14 -31
  183. package/src/components/Routes/RoutesExpanded.style.ts +2 -2
  184. package/src/components/Routes/RoutesExpanded.tsx +33 -13
  185. package/src/components/SendToWallet/SendToWalletButton.tsx +1 -1
  186. package/src/components/SendToWallet/SendToWalletExpandButton.tsx +8 -3
  187. package/src/components/Step/StepProcess.tsx +3 -8
  188. package/src/components/TokenList/TokenDetailsSheetContent.tsx +1 -2
  189. package/src/components/TokenList/useTokenSelect.ts +2 -4
  190. package/src/config/version.ts +1 -1
  191. package/src/hooks/useFromAmountThreshold.ts +6 -2
  192. package/src/hooks/useGasSufficiency.ts +4 -4
  193. package/src/hooks/useNavigateBack.ts +26 -17
  194. package/src/hooks/useRouteExecution.ts +1 -3
  195. package/src/hooks/useRoutes.ts +92 -37
  196. package/src/hooks/useSettingMonitor.ts +7 -11
  197. package/src/hooks/useTokenAddressBalance.ts +6 -1
  198. package/src/hooks/useTokenSearch.ts +5 -2
  199. package/src/hooks/useTokens.ts +2 -2
  200. package/src/hooks/useTools.ts +2 -2
  201. package/src/i18n/bn.json +1 -1
  202. package/src/i18n/de.json +1 -1
  203. package/src/i18n/en.json +1 -1
  204. package/src/i18n/es.json +1 -1
  205. package/src/i18n/fr.json +1 -1
  206. package/src/i18n/hi.json +1 -1
  207. package/src/i18n/id.json +1 -1
  208. package/src/i18n/it.json +1 -1
  209. package/src/i18n/ja.json +1 -1
  210. package/src/i18n/ko.json +1 -1
  211. package/src/i18n/pt.json +1 -1
  212. package/src/i18n/th.json +1 -1
  213. package/src/i18n/tr.json +1 -1
  214. package/src/i18n/uk.json +1 -1
  215. package/src/i18n/vi.json +1 -1
  216. package/src/i18n/zh.json +1 -1
  217. package/src/pages/SelectEnabledToolsPage.tsx +4 -5
  218. package/src/pages/SelectTokenPage/SearchTokenInput.tsx +19 -7
  219. package/src/pages/SettingsPage/BridgeAndExchangeSettings.tsx +1 -2
  220. package/src/pages/TransactionPage/TransactionPage.tsx +17 -9
  221. package/src/stores/bookmarks/BookmarkStore.tsx +3 -6
  222. package/src/stores/bookmarks/useBookmarkActions.ts +9 -13
  223. package/src/stores/bookmarks/useBookmarks.ts +1 -3
  224. package/src/stores/chains/ChainOrderStore.tsx +3 -3
  225. package/src/stores/chains/useChainOrder.ts +1 -5
  226. package/src/stores/form/useFieldActions.ts +10 -14
  227. package/src/stores/form/useFieldValues.ts +1 -3
  228. package/src/stores/form/useFormStore.ts +3 -6
  229. package/src/stores/form/useTouchedFields.ts +1 -2
  230. package/src/stores/form/useValidation.ts +5 -5
  231. package/src/stores/form/useValidationActions.ts +5 -9
  232. package/src/stores/header/useHeaderStore.tsx +3 -5
  233. package/src/stores/inputMode/useInputModeStore.ts +29 -0
  234. package/src/stores/routes/RouteExecutionStore.tsx +3 -3
  235. package/src/stores/routes/useExecutingRoutesIds.ts +14 -17
  236. package/src/stores/settings/useSendToWalletStore.ts +11 -8
  237. package/src/stores/settings/useSettings.ts +8 -11
  238. package/src/stores/settings/useSettingsActions.ts +8 -12
  239. package/src/stores/settings/useSettingsStore.ts +8 -1
  240. package/src/stores/settings/useSplitSubvariantStore.tsx +2 -1
  241. package/src/themes/createTheme.ts +5 -1
  242. package/src/types/widget.ts +1 -0
  243. package/src/utils/format.ts +33 -0
  244. package/src/utils/getPriceImpact.ts +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"format.js","sourceRoot":"","sources":["../../../src/utils/format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAA;AAElC;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAA0B,EAC1B,QAAgB;IAEhB,MAAM,eAAe,GAAG,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;IACpE,MAAM,YAAY,GAAG,MAAM,CAAC,UAAU,CAAC,eAAe,CAAC,CAAA;IACvD,IAAI,CAAC,YAAY,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC;QAC3D,OAAO,GAAG,CAAA;IACZ,CAAC;IAED,OAAO,eAAe,CAAA;AACxB,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,QAAQ,GAAG,EAAE,EACb,YAAY,GAAG,EAAE,EACjB,aAAa,GAAG,KAAK;IAErB,IAAI,CAAC,QAAQ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AAa,CAAC,IAAY;IACxC,OAAO,IAAI,CAAC,OAAO,CACjB,UAAU,EACV,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CACpD,CAAA;AACH,CAAC"}
@@ -1,9 +1,9 @@
1
1
  import type { Token } from '@lifi/sdk';
2
- interface GetPriceImpractProps {
2
+ interface GetPriceImpactProps {
3
3
  fromToken: Token;
4
4
  toToken: Token;
5
5
  fromAmount?: bigint;
6
6
  toAmount?: bigint;
7
7
  }
8
- export declare const getPriceImpact: ({ fromToken, toToken, fromAmount, toAmount, }: GetPriceImpractProps) => number;
8
+ export declare const getPriceImpact: ({ fromToken, toToken, fromAmount, toAmount, }: GetPriceImpactProps) => number;
9
9
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"getPriceImpact.js","sourceRoot":"","sources":["../../../src/utils/getPriceImpact.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAS9C,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAC7B,SAAS,EACT,OAAO,EACP,UAAU,EACV,QAAQ,GACa,EAAE,EAAE;IACzB,MAAM,cAAc,GAAG,gBAAgB,CACrC,UAAU,EACV,SAAS,CAAC,QAAQ,EAClB,SAAS,CAAC,QAAQ,CACnB,CAAA;IACD,MAAM,YAAY,GAAG,gBAAgB,CACnC,QAAQ,EACR,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,QAAQ,CACjB,CAAA;IAED,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,OAAO,CAAC,CAAA;IACV,CAAC;IAED,MAAM,WAAW,GAAG,YAAY,GAAG,cAAc,GAAG,CAAC,CAAA;IAErD,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA"}
1
+ {"version":3,"file":"getPriceImpact.js","sourceRoot":"","sources":["../../../src/utils/getPriceImpact.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAS9C,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAC7B,SAAS,EACT,OAAO,EACP,UAAU,EACV,QAAQ,GACY,EAAE,EAAE;IACxB,MAAM,cAAc,GAAG,gBAAgB,CACrC,UAAU,EACV,SAAS,CAAC,QAAQ,EAClB,SAAS,CAAC,QAAQ,CACnB,CAAA;IACD,MAAM,YAAY,GAAG,gBAAgB,CACnC,QAAQ,EACR,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,QAAQ,CACjB,CAAA;IAED,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,OAAO,CAAC,CAAA;IACV,CAAC;IAED,MAAM,WAAW,GAAG,YAAY,GAAG,cAAc,GAAG,CAAC,CAAA;IAErD,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/widget",
3
- "version": "3.25.0",
3
+ "version": "3.26.1",
4
4
  "description": "LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.",
5
5
  "type": "module",
6
6
  "main": "./dist/esm/index.js",
@@ -30,18 +30,18 @@
30
30
  "lifi"
31
31
  ],
32
32
  "dependencies": {
33
- "@bigmi/client": "^0.4.2",
34
- "@bigmi/core": "^0.4.2",
33
+ "@bigmi/client": "^0.4.3",
34
+ "@bigmi/core": "^0.4.3",
35
35
  "@emotion/react": "^11.14.0",
36
36
  "@emotion/styled": "^11.14.1",
37
- "@lifi/sdk": "^3.8.7",
38
- "@mui/icons-material": "^7.2.0",
39
- "@mui/material": "^7.2.0",
40
- "@mui/system": "^7.2.0",
41
- "@mysten/sui": "^1.36.2",
37
+ "@lifi/sdk": "^3.8.11",
38
+ "@mui/icons-material": "^7.3.1",
39
+ "@mui/material": "^7.3.1",
40
+ "@mui/system": "^7.3.1",
41
+ "@mysten/sui": "^1.37.1",
42
42
  "@solana/wallet-adapter-base": "^0.9.27",
43
43
  "@solana/wallet-adapter-coinbase": "^0.1.23",
44
- "@solana/web3.js": "^1.98.2",
44
+ "@solana/web3.js": "^1.98.4",
45
45
  "@tanstack/react-virtual": "^3.13.12",
46
46
  "i18next": "^25.3.0",
47
47
  "microdiff": "^1.5.0",
@@ -50,9 +50,9 @@
50
50
  "react-intersection-observer": "^9.16.0",
51
51
  "react-router-dom": "^6.30.0",
52
52
  "react-transition-group": "^4.4.5",
53
- "viem": "^2.33.0",
54
- "zustand": "^5.0.6",
55
- "@lifi/wallet-management": "^3.13.0"
53
+ "viem": "^2.33.2",
54
+ "zustand": "^5.0.7",
55
+ "@lifi/wallet-management": "^3.14.1"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "@bigmi/react": ">=0.4.0",
package/package.json.tmp CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/widget",
3
- "version": "3.25.0",
3
+ "version": "3.26.1",
4
4
  "description": "LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -49,19 +49,19 @@
49
49
  "lifi"
50
50
  ],
51
51
  "dependencies": {
52
- "@bigmi/client": "^0.4.2",
53
- "@bigmi/core": "^0.4.2",
52
+ "@bigmi/client": "^0.4.3",
53
+ "@bigmi/core": "^0.4.3",
54
54
  "@emotion/react": "^11.14.0",
55
55
  "@emotion/styled": "^11.14.1",
56
- "@lifi/sdk": "^3.8.7",
56
+ "@lifi/sdk": "^3.8.11",
57
57
  "@lifi/wallet-management": "workspace:^",
58
- "@mui/icons-material": "^7.2.0",
59
- "@mui/material": "^7.2.0",
60
- "@mui/system": "^7.2.0",
61
- "@mysten/sui": "^1.36.2",
58
+ "@mui/icons-material": "^7.3.1",
59
+ "@mui/material": "^7.3.1",
60
+ "@mui/system": "^7.3.1",
61
+ "@mysten/sui": "^1.37.1",
62
62
  "@solana/wallet-adapter-base": "^0.9.27",
63
63
  "@solana/wallet-adapter-coinbase": "^0.1.23",
64
- "@solana/web3.js": "^1.98.2",
64
+ "@solana/web3.js": "^1.98.4",
65
65
  "@tanstack/react-virtual": "^3.13.12",
66
66
  "i18next": "^25.3.0",
67
67
  "microdiff": "^1.5.0",
@@ -70,16 +70,16 @@
70
70
  "react-intersection-observer": "^9.16.0",
71
71
  "react-router-dom": "^6.30.0",
72
72
  "react-transition-group": "^4.4.5",
73
- "viem": "^2.33.0",
74
- "zustand": "^5.0.6"
73
+ "viem": "^2.33.2",
74
+ "zustand": "^5.0.7"
75
75
  },
76
76
  "devDependencies": {
77
77
  "@types/react-transition-group": "^4.4.12",
78
78
  "cpy-cli": "^5.0.0",
79
79
  "madge": "^8.0.0",
80
- "react": "^19.1.0",
81
- "react-dom": "^19.1.0",
82
- "typescript": "^5.8.3",
80
+ "react": "^19.1.1",
81
+ "react-dom": "^19.1.1",
82
+ "typescript": "^5.9.2",
83
83
  "vitest": "^3.2.4"
84
84
  },
85
85
  "peerDependencies": {
@@ -5,6 +5,7 @@ import {
5
5
  FormControl as MuiFormControl,
6
6
  styled,
7
7
  } from '@mui/material'
8
+ import { CardTitle } from '../Card/CardTitle.js'
8
9
 
9
10
  export const maxInputFontSize = 24
10
11
  export const minInputFontSize = 14
@@ -43,3 +44,15 @@ export const Input = styled(InputBase)(({ theme }) => ({
43
44
  WebkitTextFillColor: 'unset',
44
45
  },
45
46
  }))
47
+
48
+ export const AmountInputCardTitle = styled(CardTitle)(({ theme }) => ({
49
+ padding: theme.spacing(2, 0, 0, 0),
50
+ }))
51
+
52
+ export const AmountInputCardHeader = styled(Box)(({ theme }) => ({
53
+ padding: theme.spacing(0, 2, 0, 2),
54
+ display: 'flex',
55
+ justifyContent: 'space-between',
56
+ alignItems: 'start',
57
+ height: 30,
58
+ }))
@@ -1,19 +1,25 @@
1
1
  import type { Token } from '@lifi/sdk'
2
2
  import type { CardProps } from '@mui/material'
3
3
  import type { ChangeEvent, ReactNode } from 'react'
4
- import { useLayoutEffect, useRef } from 'react'
4
+ import { useLayoutEffect, useRef, useState } from 'react'
5
5
  import { useTranslation } from 'react-i18next'
6
6
  import { useToken } from '../../hooks/useToken.js'
7
7
  import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js'
8
8
  import { FormKeyHelper, type FormTypeProps } from '../../stores/form/types.js'
9
- import { useFieldController } from '../../stores/form/useFieldController.js'
9
+ import { useFieldActions } from '../../stores/form/useFieldActions.js'
10
10
  import { useFieldValues } from '../../stores/form/useFieldValues.js'
11
+ import { useInputModeStore } from '../../stores/inputMode/useInputModeStore.js'
11
12
  import { DisabledUI } from '../../types/widget.js'
12
- import { formatInputAmount } from '../../utils/format.js'
13
+ import {
14
+ formatInputAmount,
15
+ formatTokenPrice,
16
+ priceToTokenAmount,
17
+ } from '../../utils/format.js'
13
18
  import { fitInputText } from '../../utils/input.js'
14
- import { CardTitle } from '../Card/CardTitle.js'
15
19
  import { InputCard } from '../Card/InputCard.js'
16
20
  import {
21
+ AmountInputCardHeader,
22
+ AmountInputCardTitle,
17
23
  FormContainer,
18
24
  FormControl,
19
25
  Input,
@@ -24,6 +30,8 @@ import { AmountInputEndAdornment } from './AmountInputEndAdornment.js'
24
30
  import { AmountInputStartAdornment } from './AmountInputStartAdornment.js'
25
31
  import { PriceFormHelperText } from './PriceFormHelperText.js'
26
32
 
33
+ const USD_DECIMALS = 2
34
+
27
35
  export const AmountInput: React.FC<FormTypeProps & CardProps> = ({
28
36
  formType,
29
37
  ...props
@@ -36,6 +44,7 @@ export const AmountInput: React.FC<FormTypeProps & CardProps> = ({
36
44
  )
37
45
 
38
46
  const { token } = useToken(chainId, tokenAddress)
47
+
39
48
  const disabled = disabledUI?.includes(DisabledUI.FromAmount)
40
49
  return (
41
50
  <AmountInputBase
@@ -72,32 +81,88 @@ export const AmountInputBase: React.FC<
72
81
  const { t } = useTranslation()
73
82
  const { subvariant, subvariantOptions } = useWidgetConfig()
74
83
  const ref = useRef<HTMLInputElement>(null)
84
+
85
+ const isEditingRef = useRef(false)
86
+ const [formattedPriceInput, setFormattedPriceInput] = useState('')
87
+
75
88
  const amountKey = FormKeyHelper.getAmountKey(formType)
76
- const { onChange, onBlur, value } = useFieldController({ name: amountKey })
89
+ const [value] = useFieldValues(amountKey)
90
+ const { setFieldValue } = useFieldActions()
91
+ const { inputMode } = useInputModeStore()
92
+
93
+ const currentInputMode = inputMode[formType]
94
+ let displayValue: string
95
+ if (isEditingRef.current) {
96
+ if (currentInputMode === 'price') {
97
+ displayValue = formattedPriceInput
98
+ } else {
99
+ displayValue = value as string
100
+ }
101
+ } else {
102
+ if (currentInputMode === 'price') {
103
+ const priceValue = formatTokenPrice(value as string, token?.priceUSD)
104
+ displayValue = formatInputAmount(
105
+ priceValue.toFixed(USD_DECIMALS),
106
+ USD_DECIMALS
107
+ )
108
+ } else {
109
+ displayValue = value as string
110
+ }
111
+ }
77
112
 
78
113
  const handleChange = (
79
114
  event: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>
80
115
  ) => {
81
- const { value } = event.target
82
- const formattedAmount = formatInputAmount(value, token?.decimals, true)
83
- onChange(formattedAmount)
116
+ const { value: inputValue } = event.target
117
+ isEditingRef.current = true
118
+
119
+ let formattedValue: string
120
+ if (currentInputMode === 'price') {
121
+ const cleanInputValue = inputValue.replace('$', '')
122
+ formattedValue = formatInputAmount(cleanInputValue, USD_DECIMALS, true)
123
+ const tokenValue = priceToTokenAmount(formattedValue, token?.priceUSD)
124
+ setFormattedPriceInput(formattedValue)
125
+ setFieldValue(amountKey, tokenValue, { isDirty: true, isTouched: true })
126
+ } else {
127
+ formattedValue = formatInputAmount(inputValue, token?.decimals, true)
128
+ setFieldValue(amountKey, formattedValue, {
129
+ isDirty: true,
130
+ isTouched: true,
131
+ })
132
+ }
84
133
  }
85
134
 
86
135
  const handleBlur = (
87
136
  event: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>
88
137
  ) => {
89
- const { value } = event.target
90
- const formattedAmount = formatInputAmount(value, token?.decimals)
91
- onChange(formattedAmount)
92
- onBlur()
138
+ const { value: inputValue } = event.target
139
+ isEditingRef.current = false
140
+
141
+ let formattedValue: string
142
+ if (currentInputMode === 'price') {
143
+ const cleanInputValue = inputValue.replace('$', '')
144
+ formattedValue = formatInputAmount(cleanInputValue, USD_DECIMALS)
145
+ const tokenValue = priceToTokenAmount(formattedValue, token?.priceUSD)
146
+ const formattedAmount = formatInputAmount(tokenValue, token?.decimals)
147
+ setFieldValue(amountKey, formattedAmount, {
148
+ isDirty: true,
149
+ isTouched: true,
150
+ })
151
+ } else {
152
+ formattedValue = formatInputAmount(inputValue, token?.decimals)
153
+ setFieldValue(amountKey, formattedValue, {
154
+ isDirty: true,
155
+ isTouched: true,
156
+ })
157
+ }
93
158
  }
94
159
 
95
- // biome-ignore lint/correctness/useExhaustiveDependencies: we need to run effect on value change
160
+ // biome-ignore lint/correctness/useExhaustiveDependencies: we need run effect on value change
96
161
  useLayoutEffect(() => {
97
162
  if (ref.current) {
98
163
  fitInputText(maxInputFontSize, minInputFontSize, ref.current)
99
164
  }
100
- }, [value])
165
+ }, [displayValue])
101
166
 
102
167
  const title =
103
168
  subvariant === 'custom'
@@ -108,7 +173,10 @@ export const AmountInputBase: React.FC<
108
173
 
109
174
  return (
110
175
  <InputCard {...props}>
111
- <CardTitle>{title}</CardTitle>
176
+ <AmountInputCardHeader>
177
+ <AmountInputCardTitle>{title}</AmountInputCardTitle>
178
+ {endAdornment}
179
+ </AmountInputCardHeader>
112
180
  <FormContainer>
113
181
  <AmountInputStartAdornment formType={formType} />
114
182
  <FormControl fullWidth>
@@ -116,15 +184,20 @@ export const AmountInputBase: React.FC<
116
184
  inputRef={ref}
117
185
  size="small"
118
186
  autoComplete="off"
119
- placeholder="0"
187
+ placeholder={currentInputMode === 'price' ? '$0' : '0'}
120
188
  startAdornment={startAdornment}
121
- endAdornment={endAdornment}
122
189
  inputProps={{
123
190
  inputMode: 'decimal',
124
191
  }}
125
192
  onChange={handleChange}
126
193
  onBlur={handleBlur}
127
- value={value}
194
+ value={
195
+ currentInputMode === 'price'
196
+ ? displayValue
197
+ ? `$${displayValue}`
198
+ : ''
199
+ : displayValue
200
+ }
128
201
  name={amountKey}
129
202
  disabled={disabled}
130
203
  required
@@ -1,10 +1,71 @@
1
- import { Button as MuiButton, Skeleton, styled } from '@mui/material'
1
+ import { Box, Skeleton, styled } from '@mui/material'
2
+ import { cardClasses } from '@mui/material/Card'
3
+ import { ButtonTertiary } from '../ButtonTertiary.js'
2
4
 
3
- export const MaxButton = styled(MuiButton)(({ theme }) => ({
4
- padding: theme.spacing(0.5, 1, 0.625, 1),
5
- lineHeight: 1.0715,
6
- fontSize: '0.875rem',
5
+ export const ButtonContainer = styled(Box)(({ theme }) => ({
6
+ display: 'flex',
7
+ gap: theme.spacing(0.5),
8
+ }))
9
+
10
+ export const MaxButton = styled(ButtonTertiary)(({ theme }) => ({
11
+ padding: theme.spacing(0.5, 1, 0.5, 1),
12
+ margin: theme.spacing(0, 0, 0, 0.5),
13
+ lineHeight: 1,
14
+ fontSize: '0.75rem',
7
15
  minWidth: 'unset',
16
+ height: 24,
17
+ opacity: 0,
18
+ transform: 'scale(0.85) translateY(-10px)',
19
+ transition:
20
+ 'opacity 200ms cubic-bezier(0.4, 0, 0.2, 1), transform 200ms cubic-bezier(0.4, 0, 0.2, 1)',
21
+ '&[data-delay="0"]': {
22
+ [`.${cardClasses.root}:hover &`]: {
23
+ opacity: 1,
24
+ transform: 'scale(1) translateY(0)',
25
+ transitionDelay: '75ms',
26
+ },
27
+ [`.${cardClasses.root}:not(:hover) &`]: {
28
+ opacity: 0,
29
+ transform: 'scale(0.85) translateY(-10px)',
30
+ transitionDelay: '0ms',
31
+ },
32
+ },
33
+ '&[data-delay="1"]': {
34
+ [`.${cardClasses.root}:hover &`]: {
35
+ opacity: 1,
36
+ transform: 'scale(1) translateY(0)',
37
+ transitionDelay: '50ms',
38
+ },
39
+ [`.${cardClasses.root}:not(:hover) &`]: {
40
+ opacity: 0,
41
+ transform: 'scale(0.85) translateY(-10px)',
42
+ transitionDelay: '25ms',
43
+ },
44
+ },
45
+ '&[data-delay="2"]': {
46
+ [`.${cardClasses.root}:hover &`]: {
47
+ opacity: 1,
48
+ transform: 'scale(1) translateY(0)',
49
+ transitionDelay: '25ms',
50
+ },
51
+ [`.${cardClasses.root}:not(:hover) &`]: {
52
+ opacity: 0,
53
+ transform: 'scale(0.85) translateY(-10px)',
54
+ transitionDelay: '50ms',
55
+ },
56
+ },
57
+ '&[data-delay="3"]': {
58
+ [`.${cardClasses.root}:hover &`]: {
59
+ opacity: 1,
60
+ transform: 'scale(1) translateY(0)',
61
+ transitionDelay: '0ms',
62
+ },
63
+ [`.${cardClasses.root}:not(:hover) &`]: {
64
+ opacity: 0,
65
+ transform: 'scale(0.85) translateY(-10px)',
66
+ transitionDelay: '75ms',
67
+ },
68
+ },
8
69
  }))
9
70
 
10
71
  export const MaxButtonSkeleton = styled(Skeleton)(({ theme }) => ({
@@ -8,7 +8,7 @@ import type { FormTypeProps } from '../../stores/form/types.js'
8
8
  import { FormKeyHelper } from '../../stores/form/types.js'
9
9
  import { useFieldActions } from '../../stores/form/useFieldActions.js'
10
10
  import { useFieldValues } from '../../stores/form/useFieldValues.js'
11
- import { MaxButton, MaxButtonSkeleton } from './AmountInputAdornment.style.js'
11
+ import { ButtonContainer, MaxButton } from './AmountInputAdornment.style.js'
12
12
 
13
13
  export const AmountInputEndAdornment = ({ formType }: FormTypeProps) => {
14
14
  const { t } = useTranslation()
@@ -24,11 +24,11 @@ export const AmountInputEndAdornment = ({ formType }: FormTypeProps) => {
24
24
  // the user will have enough funds remaining to cover gas costs
25
25
  const { data } = useGasRecommendation(chainId)
26
26
 
27
- const { token, isLoading } = useTokenAddressBalance(chainId, tokenAddress)
27
+ const { token } = useTokenAddressBalance(chainId, tokenAddress)
28
28
 
29
- const handleMax = () => {
29
+ const getMaxAmount = () => {
30
30
  if (!token?.amount) {
31
- return
31
+ return 0n
32
32
  }
33
33
  const chain = getChainById(chainId)
34
34
  let maxAmount = token.amount
@@ -38,7 +38,26 @@ export const AmountInputEndAdornment = ({ formType }: FormTypeProps) => {
38
38
  maxAmount = token.amount - recommendedAmount
39
39
  }
40
40
  }
41
- if (maxAmount) {
41
+ return maxAmount
42
+ }
43
+
44
+ const handlePercentage = (percentage: number) => {
45
+ const maxAmount = getMaxAmount()
46
+ if (maxAmount && token?.decimals) {
47
+ const percentageAmount = (maxAmount * BigInt(percentage)) / 100n
48
+ setFieldValue(
49
+ FormKeyHelper.getAmountKey(formType),
50
+ formatUnits(percentageAmount, token.decimals),
51
+ {
52
+ isTouched: true,
53
+ }
54
+ )
55
+ }
56
+ }
57
+
58
+ const handleMax = () => {
59
+ const maxAmount = getMaxAmount()
60
+ if (maxAmount && token?.decimals) {
42
61
  setFieldValue(
43
62
  FormKeyHelper.getAmountKey(formType),
44
63
  formatUnits(maxAmount, token.decimals),
@@ -50,11 +69,22 @@ export const AmountInputEndAdornment = ({ formType }: FormTypeProps) => {
50
69
  }
51
70
 
52
71
  return (
53
- <InputAdornment position="end">
54
- {isLoading && tokenAddress ? (
55
- <MaxButtonSkeleton variant="rectangular" />
56
- ) : formType === 'from' && token?.amount ? (
57
- <MaxButton onClick={handleMax}>{t('button.max')}</MaxButton>
72
+ <InputAdornment position="end" sx={{ paddingTop: 2 }}>
73
+ {formType === 'from' && token?.amount ? (
74
+ <ButtonContainer>
75
+ <MaxButton onClick={() => handlePercentage(25)} data-delay="0">
76
+ 25%
77
+ </MaxButton>
78
+ <MaxButton onClick={() => handlePercentage(50)} data-delay="1">
79
+ 50%
80
+ </MaxButton>
81
+ <MaxButton onClick={() => handlePercentage(75)} data-delay="2">
82
+ 75%
83
+ </MaxButton>
84
+ <MaxButton onClick={handleMax} data-delay="3">
85
+ {t('button.max')}
86
+ </MaxButton>
87
+ </ButtonContainer>
58
88
  ) : null}
59
89
  </InputAdornment>
60
90
  )
@@ -0,0 +1,29 @@
1
+ import { Button, styled } from '@mui/material'
2
+
3
+ export const InputPriceButton = styled(Button)(({ theme, onClick }) => ({
4
+ color: theme.vars.palette.text.secondary,
5
+ padding: theme.spacing(0.25, 0.5, 0.25, 0.75),
6
+ maxHeight: 16,
7
+ fontSize: '0.75rem',
8
+ fontWeight: 500,
9
+ borderRadius: `calc(${theme.vars.shape.borderRadius} * 2)`,
10
+ backgroundColor: 'transparent',
11
+ minWidth: 32,
12
+ ...(onClick
13
+ ? {
14
+ '&:hover': {
15
+ backgroundColor: `rgba(${theme.vars.palette.common.onBackgroundChannel} / 0.04)`,
16
+ },
17
+ ...theme.applyStyles('dark', {
18
+ backgroundColor: 'transparent',
19
+ '&:hover': {
20
+ backgroundColor: `rgba(${theme.vars.palette.common.onBackgroundChannel} / 0.04)`,
21
+ },
22
+ }),
23
+ }
24
+ : {
25
+ cursor: 'text',
26
+ userSelect: 'text',
27
+ pointerEvents: 'none',
28
+ }),
29
+ }))
@@ -1,11 +1,14 @@
1
1
  import type { TokenAmount } from '@lifi/sdk'
2
+ import SwapVertIcon from '@mui/icons-material/SwapVert'
2
3
  import { FormHelperText, Skeleton, Typography } from '@mui/material'
3
4
  import { useTranslation } from 'react-i18next'
4
5
  import { useTokenAddressBalance } from '../../hooks/useTokenAddressBalance.js'
5
6
  import type { FormTypeProps } from '../../stores/form/types.js'
6
7
  import { FormKeyHelper } from '../../stores/form/types.js'
7
8
  import { useFieldValues } from '../../stores/form/useFieldValues.js'
9
+ import { useInputModeStore } from '../../stores/inputMode/useInputModeStore.js'
8
10
  import { formatTokenAmount, formatTokenPrice } from '../../utils/format.js'
11
+ import { InputPriceButton } from './PriceFormHelperText.style.js'
9
12
 
10
13
  export const PriceFormHelperText: React.FC<FormTypeProps> = ({ formType }) => {
11
14
  const [chainId, tokenAddress] = useFieldValues(
@@ -33,11 +36,31 @@ export const PriceFormHelperTextBase: React.FC<
33
36
  > = ({ formType, isLoading, tokenAddress, token }) => {
34
37
  const { t } = useTranslation()
35
38
  const [amount] = useFieldValues(FormKeyHelper.getAmountKey(formType))
39
+ const { inputMode, toggleInputMode } = useInputModeStore()
40
+
41
+ const currentInputMode = inputMode[formType]
36
42
 
37
43
  const tokenAmount = token
38
44
  ? formatTokenAmount(token.amount, token.decimals)
39
45
  : '0'
40
- const tokenPrice = formatTokenPrice(amount, token?.priceUSD)
46
+
47
+ const getPriceAmountDisplayValue = () => {
48
+ if (currentInputMode === 'amount') {
49
+ const tokenPrice = formatTokenPrice(
50
+ amount,
51
+ token?.priceUSD,
52
+ token?.decimals
53
+ )
54
+ return t('format.currency', { value: tokenPrice })
55
+ } else {
56
+ return t('format.tokenAmount', { value: amount || '0' })
57
+ }
58
+ }
59
+
60
+ const handleToggleMode = (e: React.MouseEvent) => {
61
+ e.stopPropagation()
62
+ toggleInputMode(formType)
63
+ }
41
64
 
42
65
  return (
43
66
  <FormHelperText
@@ -45,28 +68,49 @@ export const PriceFormHelperTextBase: React.FC<
45
68
  sx={{
46
69
  display: 'flex',
47
70
  justifyContent: 'space-between',
71
+ alignItems: 'center',
48
72
  margin: 0,
49
- marginLeft: 2,
50
- marginTop: 0.75,
73
+ marginLeft: 1.25,
74
+ marginTop: 0.5,
51
75
  }}
52
76
  >
53
- <Typography
54
- sx={{
55
- color: 'text.secondary',
56
- fontWeight: 500,
57
- fontSize: 12,
58
- lineHeight: 1,
59
- flex: 1,
60
- wordBreak: 'break-word',
61
- overflowWrap: 'break-word',
62
- }}
77
+ <InputPriceButton
78
+ onClick={token?.priceUSD ? handleToggleMode : undefined}
63
79
  >
64
- {t('format.currency', {
65
- value: tokenPrice,
66
- })}
67
- </Typography>
80
+ <Typography
81
+ sx={{
82
+ color: 'text.secondary',
83
+ fontWeight: 500,
84
+ fontSize: 12,
85
+ lineHeight: 1,
86
+ marginRight: 0.25,
87
+ maxWidth: 136,
88
+ overflow: 'hidden',
89
+ textOverflow: 'ellipsis',
90
+ whiteSpace: 'nowrap',
91
+ }}
92
+ >
93
+ {getPriceAmountDisplayValue()}
94
+ </Typography>
95
+ {currentInputMode === 'price' && token?.symbol ? (
96
+ <Typography
97
+ sx={{
98
+ color: 'text.secondary',
99
+ fontWeight: 500,
100
+ fontSize: 12,
101
+ lineHeight: 1,
102
+ wordBreak: 'break-word',
103
+ overflowWrap: 'break-word',
104
+ marginRight: 0.25,
105
+ }}
106
+ >
107
+ {token.symbol}
108
+ </Typography>
109
+ ) : null}
110
+ {token?.priceUSD && <SwapVertIcon sx={{ fontSize: 14 }} />}
111
+ </InputPriceButton>
68
112
  {isLoading && tokenAddress ? (
69
- <Skeleton variant="text" width={48} height={12} />
113
+ <Skeleton variant="text" width={56} height={16} />
70
114
  ) : token?.amount ? (
71
115
  <Typography
72
116
  sx={{
@@ -74,7 +118,7 @@ export const PriceFormHelperTextBase: React.FC<
74
118
  fontSize: 12,
75
119
  color: 'text.secondary',
76
120
  lineHeight: 1,
77
- pl: 0.25,
121
+ paddingLeft: 0.25,
78
122
  }}
79
123
  title={tokenAmount}
80
124
  >
@@ -71,6 +71,7 @@ export const RelativeContainer = styled(Box, {
71
71
  maxHeight: 'none',
72
72
  height: '100%',
73
73
  boxShadow: 'none',
74
+ borderRadius: 0,
74
75
  },
75
76
  },
76
77
  ],