@lifi/widget 3.0.0-alpha.10 → 3.0.0-alpha.11

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 (328) hide show
  1. package/AppProvider.tsx +4 -8
  2. package/_cjs/AppProvider.js +2 -2
  3. package/_cjs/AppProvider.js.map +1 -1
  4. package/_cjs/components/AmountInput/AmountInput.d.ts +1 -1
  5. package/_cjs/components/AmountInput/AmountInput.js +5 -11
  6. package/_cjs/components/AmountInput/AmountInput.js.map +1 -1
  7. package/_cjs/components/AmountInput/AmountInputEndAdornment.d.ts +1 -1
  8. package/_cjs/components/AmountInput/AmountInputEndAdornment.js +5 -11
  9. package/_cjs/components/AmountInput/AmountInputEndAdornment.js.map +1 -1
  10. package/_cjs/components/AmountInput/AmountInputStartAdornment.d.ts +1 -1
  11. package/_cjs/components/AmountInput/AmountInputStartAdornment.js +2 -8
  12. package/_cjs/components/AmountInput/AmountInputStartAdornment.js.map +1 -1
  13. package/_cjs/components/AmountInput/FormPriceHelperText.d.ts +1 -1
  14. package/_cjs/components/AmountInput/FormPriceHelperText.js +3 -11
  15. package/_cjs/components/AmountInput/FormPriceHelperText.js.map +1 -1
  16. package/_cjs/components/ChainSelect/ChainSelect.d.ts +1 -1
  17. package/_cjs/components/ChainSelect/ChainSelect.js +1 -5
  18. package/_cjs/components/ChainSelect/ChainSelect.js.map +1 -1
  19. package/_cjs/components/ChainSelect/useChainSelect.d.ts +1 -1
  20. package/_cjs/components/ChainSelect/useChainSelect.js +10 -14
  21. package/_cjs/components/ChainSelect/useChainSelect.js.map +1 -1
  22. package/_cjs/components/Header/NavigationTabs.js +4 -6
  23. package/_cjs/components/Header/NavigationTabs.js.map +1 -1
  24. package/_cjs/components/ListItemText.d.ts +1 -1
  25. package/_cjs/components/NFT/NFT.js +13 -14
  26. package/_cjs/components/NFT/NFT.js.map +1 -1
  27. package/_cjs/components/ReverseTokensButton/ReverseTokensButton.js +7 -14
  28. package/_cjs/components/ReverseTokensButton/ReverseTokensButton.js.map +1 -1
  29. package/_cjs/components/Routes/Routes.js +2 -2
  30. package/_cjs/components/Routes/Routes.js.map +1 -1
  31. package/_cjs/components/Routes/RoutesExpanded.js +1 -2
  32. package/_cjs/components/Routes/RoutesExpanded.js.map +1 -1
  33. package/_cjs/components/SelectChainAndToken.js +6 -13
  34. package/_cjs/components/SelectChainAndToken.js.map +1 -1
  35. package/_cjs/components/SelectTokenButton/SelectTokenButton.d.ts +1 -1
  36. package/_cjs/components/SelectTokenButton/SelectTokenButton.js +3 -5
  37. package/_cjs/components/SelectTokenButton/SelectTokenButton.js.map +1 -1
  38. package/_cjs/components/SendToWallet/SendToWallet.js +43 -32
  39. package/_cjs/components/SendToWallet/SendToWallet.js.map +1 -1
  40. package/_cjs/components/SendToWallet/SendToWalletButton.js +2 -3
  41. package/_cjs/components/SendToWallet/SendToWalletButton.js.map +1 -1
  42. package/_cjs/components/Step/StepProcess.style.d.ts +2 -2
  43. package/_cjs/components/Tabs/Tabs.style.d.ts +1 -1
  44. package/_cjs/components/TokenList/TokenList.js +3 -6
  45. package/_cjs/components/TokenList/TokenList.js.map +1 -1
  46. package/_cjs/components/TokenList/TokenList.style.d.ts +2 -2
  47. package/_cjs/components/TokenList/TokenNotFound.d.ts +1 -1
  48. package/_cjs/components/TokenList/TokenNotFound.js +2 -5
  49. package/_cjs/components/TokenList/TokenNotFound.js.map +1 -1
  50. package/_cjs/components/TokenList/types.d.ts +1 -1
  51. package/_cjs/components/TokenList/useTokenSelect.d.ts +1 -1
  52. package/_cjs/components/TokenList/useTokenSelect.js +15 -18
  53. package/_cjs/components/TokenList/useTokenSelect.js.map +1 -1
  54. package/_cjs/config/version.d.ts +1 -1
  55. package/_cjs/config/version.js +1 -1
  56. package/_cjs/hooks/useDebouncedWatch.d.ts +2 -1
  57. package/_cjs/hooks/useDebouncedWatch.js +3 -7
  58. package/_cjs/hooks/useDebouncedWatch.js.map +1 -1
  59. package/_cjs/hooks/useFromTokenSufficiency.js +1 -5
  60. package/_cjs/hooks/useFromTokenSufficiency.js.map +1 -1
  61. package/_cjs/hooks/useGasRefuel.js +2 -10
  62. package/_cjs/hooks/useGasRefuel.js.map +1 -1
  63. package/_cjs/hooks/useRequiredToAddress.js +2 -4
  64. package/_cjs/hooks/useRequiredToAddress.js.map +1 -1
  65. package/_cjs/hooks/useRoutes.js +2 -15
  66. package/_cjs/hooks/useRoutes.js.map +1 -1
  67. package/_cjs/index.d.ts +2 -2
  68. package/_cjs/index.js +5 -5
  69. package/_cjs/index.js.map +1 -1
  70. package/_cjs/pages/MainPage/ReviewButton.js +1 -2
  71. package/_cjs/pages/MainPage/ReviewButton.js.map +1 -1
  72. package/_cjs/pages/SelectChainPage/types.d.ts +1 -1
  73. package/_cjs/pages/SelectNativeTokenPage/SelectNativeTokenPage.d.ts +1 -1
  74. package/_cjs/pages/SelectTokenPage/SearchTokenInput.js +11 -6
  75. package/_cjs/pages/SelectTokenPage/SearchTokenInput.js.map +1 -1
  76. package/_cjs/pages/SelectTokenPage/SelectTokenPage.d.ts +1 -1
  77. package/_cjs/pages/TransactionPage/StatusBottomSheet.js +10 -11
  78. package/_cjs/pages/TransactionPage/StatusBottomSheet.js.map +1 -1
  79. package/_cjs/pages/TransactionPage/TransactionPage.js +4 -5
  80. package/_cjs/pages/TransactionPage/TransactionPage.js.map +1 -1
  81. package/_cjs/providers/index.d.ts +0 -1
  82. package/_cjs/providers/index.js +0 -1
  83. package/_cjs/providers/index.js.map +1 -1
  84. package/_cjs/stores/StoreProvider.js +4 -3
  85. package/_cjs/stores/StoreProvider.js.map +1 -1
  86. package/_cjs/stores/chains/ChainOrderStore.js +6 -10
  87. package/_cjs/stores/chains/ChainOrderStore.js.map +1 -1
  88. package/_cjs/stores/form/FormStore.d.ts +6 -0
  89. package/_cjs/stores/form/FormStore.js +44 -0
  90. package/_cjs/stores/form/FormStore.js.map +1 -0
  91. package/_cjs/stores/form/FormUpdater.d.ts +5 -0
  92. package/_cjs/stores/form/FormUpdater.js +62 -0
  93. package/_cjs/stores/form/FormUpdater.js.map +1 -0
  94. package/_cjs/{providers/FormProvider → stores/form}/URLSearchParamsBuilder.js +9 -12
  95. package/_cjs/stores/form/URLSearchParamsBuilder.js.map +1 -0
  96. package/_cjs/stores/form/createFormStore.d.ts +3 -0
  97. package/_cjs/stores/form/createFormStore.js +177 -0
  98. package/_cjs/stores/form/createFormStore.js.map +1 -0
  99. package/_cjs/stores/form/index.d.ts +10 -0
  100. package/_cjs/{providers/FormProvider → stores/form}/index.js +9 -2
  101. package/_cjs/stores/form/index.js.map +1 -0
  102. package/_cjs/stores/form/types.d.ts +108 -0
  103. package/_cjs/stores/form/types.js.map +1 -0
  104. package/_cjs/stores/form/useFieldActions.d.ts +2 -0
  105. package/_cjs/stores/form/useFieldActions.js +19 -0
  106. package/_cjs/stores/form/useFieldActions.js.map +1 -0
  107. package/_cjs/stores/form/useFieldController.d.ts +11 -0
  108. package/_cjs/stores/form/useFieldController.js +24 -0
  109. package/_cjs/stores/form/useFieldController.js.map +1 -0
  110. package/_cjs/stores/form/useFieldValues.d.ts +2 -0
  111. package/_cjs/stores/form/useFieldValues.js +11 -0
  112. package/_cjs/stores/form/useFieldValues.js.map +1 -0
  113. package/_cjs/stores/form/useTouchedFields.d.ts +1 -0
  114. package/_cjs/stores/form/useTouchedFields.js +11 -0
  115. package/_cjs/stores/form/useTouchedFields.js.map +1 -0
  116. package/_cjs/stores/form/useValidation.d.ts +2 -0
  117. package/_cjs/stores/form/useValidation.js +15 -0
  118. package/_cjs/stores/form/useValidation.js.map +1 -0
  119. package/_cjs/stores/form/useValidationActions.d.ts +2 -0
  120. package/_cjs/stores/form/useValidationActions.js +19 -0
  121. package/_cjs/stores/form/useValidationActions.js.map +1 -0
  122. package/_cjs/stores/index.d.ts +1 -0
  123. package/_cjs/stores/index.js +1 -0
  124. package/_cjs/stores/index.js.map +1 -1
  125. package/_esm/AppProvider.js +3 -3
  126. package/_esm/AppProvider.js.map +1 -1
  127. package/_esm/components/AmountInput/AmountInput.d.ts +1 -1
  128. package/_esm/components/AmountInput/AmountInput.js +5 -11
  129. package/_esm/components/AmountInput/AmountInput.js.map +1 -1
  130. package/_esm/components/AmountInput/AmountInputEndAdornment.d.ts +1 -1
  131. package/_esm/components/AmountInput/AmountInputEndAdornment.js +5 -11
  132. package/_esm/components/AmountInput/AmountInputEndAdornment.js.map +1 -1
  133. package/_esm/components/AmountInput/AmountInputStartAdornment.d.ts +1 -1
  134. package/_esm/components/AmountInput/AmountInputStartAdornment.js +2 -8
  135. package/_esm/components/AmountInput/AmountInputStartAdornment.js.map +1 -1
  136. package/_esm/components/AmountInput/FormPriceHelperText.d.ts +1 -1
  137. package/_esm/components/AmountInput/FormPriceHelperText.js +3 -11
  138. package/_esm/components/AmountInput/FormPriceHelperText.js.map +1 -1
  139. package/_esm/components/ChainSelect/ChainSelect.d.ts +1 -1
  140. package/_esm/components/ChainSelect/ChainSelect.js +2 -6
  141. package/_esm/components/ChainSelect/ChainSelect.js.map +1 -1
  142. package/_esm/components/ChainSelect/useChainSelect.d.ts +1 -1
  143. package/_esm/components/ChainSelect/useChainSelect.js +11 -15
  144. package/_esm/components/ChainSelect/useChainSelect.js.map +1 -1
  145. package/_esm/components/Header/NavigationTabs.js +5 -7
  146. package/_esm/components/Header/NavigationTabs.js.map +1 -1
  147. package/_esm/components/ListItemText.d.ts +1 -1
  148. package/_esm/components/NFT/NFT.js +13 -14
  149. package/_esm/components/NFT/NFT.js.map +1 -1
  150. package/_esm/components/ReverseTokensButton/ReverseTokensButton.js +7 -14
  151. package/_esm/components/ReverseTokensButton/ReverseTokensButton.js.map +1 -1
  152. package/_esm/components/Routes/Routes.js +2 -2
  153. package/_esm/components/Routes/Routes.js.map +1 -1
  154. package/_esm/components/Routes/RoutesExpanded.js +2 -3
  155. package/_esm/components/Routes/RoutesExpanded.js.map +1 -1
  156. package/_esm/components/SelectChainAndToken.js +7 -14
  157. package/_esm/components/SelectChainAndToken.js.map +1 -1
  158. package/_esm/components/SelectTokenButton/SelectTokenButton.d.ts +1 -1
  159. package/_esm/components/SelectTokenButton/SelectTokenButton.js +3 -5
  160. package/_esm/components/SelectTokenButton/SelectTokenButton.js.map +1 -1
  161. package/_esm/components/SendToWallet/SendToWallet.js +45 -34
  162. package/_esm/components/SendToWallet/SendToWallet.js.map +1 -1
  163. package/_esm/components/SendToWallet/SendToWalletButton.js +4 -5
  164. package/_esm/components/SendToWallet/SendToWalletButton.js.map +1 -1
  165. package/_esm/components/Step/StepProcess.style.d.ts +2 -2
  166. package/_esm/components/Tabs/Tabs.style.d.ts +1 -1
  167. package/_esm/components/TokenList/TokenList.js +3 -6
  168. package/_esm/components/TokenList/TokenList.js.map +1 -1
  169. package/_esm/components/TokenList/TokenList.style.d.ts +2 -2
  170. package/_esm/components/TokenList/TokenNotFound.d.ts +1 -1
  171. package/_esm/components/TokenList/TokenNotFound.js +2 -5
  172. package/_esm/components/TokenList/TokenNotFound.js.map +1 -1
  173. package/_esm/components/TokenList/types.d.ts +1 -1
  174. package/_esm/components/TokenList/useTokenSelect.d.ts +1 -1
  175. package/_esm/components/TokenList/useTokenSelect.js +15 -18
  176. package/_esm/components/TokenList/useTokenSelect.js.map +1 -1
  177. package/_esm/config/version.d.ts +1 -1
  178. package/_esm/config/version.js +1 -1
  179. package/_esm/hooks/useDebouncedWatch.d.ts +2 -1
  180. package/_esm/hooks/useDebouncedWatch.js +3 -7
  181. package/_esm/hooks/useDebouncedWatch.js.map +1 -1
  182. package/_esm/hooks/useFromTokenSufficiency.js +2 -6
  183. package/_esm/hooks/useFromTokenSufficiency.js.map +1 -1
  184. package/_esm/hooks/useGasRefuel.js +2 -10
  185. package/_esm/hooks/useGasRefuel.js.map +1 -1
  186. package/_esm/hooks/useRequiredToAddress.js +3 -5
  187. package/_esm/hooks/useRequiredToAddress.js.map +1 -1
  188. package/_esm/hooks/useRoutes.js +4 -17
  189. package/_esm/hooks/useRoutes.js.map +1 -1
  190. package/_esm/index.d.ts +2 -2
  191. package/_esm/index.js +2 -2
  192. package/_esm/index.js.map +1 -1
  193. package/_esm/pages/MainPage/ReviewButton.js +2 -3
  194. package/_esm/pages/MainPage/ReviewButton.js.map +1 -1
  195. package/_esm/pages/SelectChainPage/types.d.ts +1 -1
  196. package/_esm/pages/SelectNativeTokenPage/SelectNativeTokenPage.d.ts +1 -1
  197. package/_esm/pages/SelectTokenPage/SearchTokenInput.js +11 -6
  198. package/_esm/pages/SelectTokenPage/SearchTokenInput.js.map +1 -1
  199. package/_esm/pages/SelectTokenPage/SelectTokenPage.d.ts +1 -1
  200. package/_esm/pages/TransactionPage/StatusBottomSheet.js +12 -13
  201. package/_esm/pages/TransactionPage/StatusBottomSheet.js.map +1 -1
  202. package/_esm/pages/TransactionPage/TransactionPage.js +6 -7
  203. package/_esm/pages/TransactionPage/TransactionPage.js.map +1 -1
  204. package/_esm/providers/index.d.ts +0 -1
  205. package/_esm/providers/index.js +0 -1
  206. package/_esm/providers/index.js.map +1 -1
  207. package/_esm/stores/StoreProvider.js +4 -3
  208. package/_esm/stores/StoreProvider.js.map +1 -1
  209. package/_esm/stores/chains/ChainOrderStore.js +6 -10
  210. package/_esm/stores/chains/ChainOrderStore.js.map +1 -1
  211. package/_esm/stores/form/FormStore.d.ts +6 -0
  212. package/_esm/stores/form/FormStore.js +39 -0
  213. package/_esm/stores/form/FormStore.js.map +1 -0
  214. package/_esm/stores/form/FormUpdater.d.ts +5 -0
  215. package/_esm/stores/form/FormUpdater.js +58 -0
  216. package/_esm/stores/form/FormUpdater.js.map +1 -0
  217. package/_esm/{providers/FormProvider → stores/form}/URLSearchParamsBuilder.js +9 -12
  218. package/_esm/stores/form/URLSearchParamsBuilder.js.map +1 -0
  219. package/_esm/stores/form/createFormStore.d.ts +3 -0
  220. package/_esm/stores/form/createFormStore.js +173 -0
  221. package/_esm/stores/form/createFormStore.js.map +1 -0
  222. package/_esm/stores/form/index.d.ts +10 -0
  223. package/_esm/stores/form/index.js +11 -0
  224. package/_esm/stores/form/index.js.map +1 -0
  225. package/_esm/stores/form/types.d.ts +108 -0
  226. package/_esm/stores/form/types.js.map +1 -0
  227. package/_esm/stores/form/useFieldActions.d.ts +2 -0
  228. package/_esm/stores/form/useFieldActions.js +15 -0
  229. package/_esm/stores/form/useFieldActions.js.map +1 -0
  230. package/_esm/stores/form/useFieldController.d.ts +11 -0
  231. package/_esm/stores/form/useFieldController.js +20 -0
  232. package/_esm/stores/form/useFieldController.js.map +1 -0
  233. package/_esm/stores/form/useFieldValues.d.ts +2 -0
  234. package/_esm/stores/form/useFieldValues.js +7 -0
  235. package/_esm/stores/form/useFieldValues.js.map +1 -0
  236. package/_esm/stores/form/useTouchedFields.d.ts +1 -0
  237. package/_esm/stores/form/useTouchedFields.js +7 -0
  238. package/_esm/stores/form/useTouchedFields.js.map +1 -0
  239. package/_esm/stores/form/useValidation.d.ts +2 -0
  240. package/_esm/stores/form/useValidation.js +11 -0
  241. package/_esm/stores/form/useValidation.js.map +1 -0
  242. package/_esm/stores/form/useValidationActions.d.ts +2 -0
  243. package/_esm/stores/form/useValidationActions.js +15 -0
  244. package/_esm/stores/form/useValidationActions.js.map +1 -0
  245. package/_esm/stores/index.d.ts +1 -0
  246. package/_esm/stores/index.js +1 -0
  247. package/_esm/stores/index.js.map +1 -1
  248. package/components/AmountInput/AmountInput.tsx +12 -14
  249. package/components/AmountInput/AmountInputEndAdornment.tsx +10 -12
  250. package/components/AmountInput/AmountInputStartAdornment.tsx +6 -9
  251. package/components/AmountInput/FormPriceHelperText.tsx +7 -13
  252. package/components/ChainSelect/ChainSelect.tsx +4 -7
  253. package/components/ChainSelect/useChainSelect.ts +18 -18
  254. package/components/Header/NavigationTabs.tsx +6 -7
  255. package/components/NFT/NFT.tsx +14 -14
  256. package/components/ReverseTokensButton/ReverseTokensButton.tsx +8 -14
  257. package/components/Routes/Routes.tsx +2 -2
  258. package/components/Routes/RoutesExpanded.tsx +2 -3
  259. package/components/SelectChainAndToken.tsx +13 -14
  260. package/components/SelectTokenButton/SelectTokenButton.tsx +7 -6
  261. package/components/SendToWallet/SendToWallet.tsx +58 -38
  262. package/components/SendToWallet/SendToWalletButton.tsx +8 -5
  263. package/components/TokenList/TokenList.tsx +3 -6
  264. package/components/TokenList/TokenNotFound.tsx +3 -6
  265. package/components/TokenList/types.ts +1 -1
  266. package/components/TokenList/useTokenSelect.ts +21 -19
  267. package/config/version.ts +1 -1
  268. package/hooks/useDebouncedWatch.ts +7 -8
  269. package/hooks/useFromTokenSufficiency.ts +6 -6
  270. package/hooks/useGasRefuel.ts +7 -10
  271. package/hooks/useRequiredToAddress.ts +3 -5
  272. package/hooks/useRoutes.ts +14 -17
  273. package/index.ts +2 -2
  274. package/package.json +10 -11
  275. package/pages/MainPage/ReviewButton.tsx +6 -3
  276. package/pages/SelectChainPage/types.ts +1 -1
  277. package/pages/SelectNativeTokenPage/SelectNativeTokenPage.tsx +1 -1
  278. package/pages/SelectTokenPage/SearchTokenInput.tsx +11 -6
  279. package/pages/SelectTokenPage/SelectTokenPage.tsx +1 -1
  280. package/pages/TransactionPage/StatusBottomSheet.tsx +18 -15
  281. package/pages/TransactionPage/TransactionPage.tsx +10 -7
  282. package/providers/index.ts +0 -1
  283. package/stores/StoreProvider.tsx +18 -15
  284. package/stores/chains/ChainOrderStore.tsx +9 -10
  285. package/stores/form/FormStore.tsx +66 -0
  286. package/stores/form/FormUpdater.tsx +69 -0
  287. package/{providers/FormProvider → stores/form}/URLSearchParamsBuilder.tsx +11 -15
  288. package/stores/form/createFormStore.ts +225 -0
  289. package/stores/form/index.ts +10 -0
  290. package/stores/form/types.ts +138 -0
  291. package/stores/form/useFieldActions.ts +28 -0
  292. package/stores/form/useFieldController.ts +31 -0
  293. package/stores/form/useFieldValues.ts +12 -0
  294. package/stores/form/useTouchedFields.ts +8 -0
  295. package/stores/form/useValidation.ts +15 -0
  296. package/stores/form/useValidationActions.ts +24 -0
  297. package/stores/index.ts +1 -0
  298. package/_cjs/providers/FormProvider/FormProvider.d.ts +0 -12
  299. package/_cjs/providers/FormProvider/FormProvider.js +0 -40
  300. package/_cjs/providers/FormProvider/FormProvider.js.map +0 -1
  301. package/_cjs/providers/FormProvider/FormUpdater.d.ts +0 -5
  302. package/_cjs/providers/FormProvider/FormUpdater.js +0 -72
  303. package/_cjs/providers/FormProvider/FormUpdater.js.map +0 -1
  304. package/_cjs/providers/FormProvider/URLSearchParamsBuilder.js.map +0 -1
  305. package/_cjs/providers/FormProvider/index.d.ts +0 -3
  306. package/_cjs/providers/FormProvider/index.js.map +0 -1
  307. package/_cjs/providers/FormProvider/types.d.ts +0 -37
  308. package/_cjs/providers/FormProvider/types.js.map +0 -1
  309. package/_esm/providers/FormProvider/FormProvider.d.ts +0 -12
  310. package/_esm/providers/FormProvider/FormProvider.js +0 -36
  311. package/_esm/providers/FormProvider/FormProvider.js.map +0 -1
  312. package/_esm/providers/FormProvider/FormUpdater.d.ts +0 -5
  313. package/_esm/providers/FormProvider/FormUpdater.js +0 -68
  314. package/_esm/providers/FormProvider/FormUpdater.js.map +0 -1
  315. package/_esm/providers/FormProvider/URLSearchParamsBuilder.js.map +0 -1
  316. package/_esm/providers/FormProvider/index.d.ts +0 -3
  317. package/_esm/providers/FormProvider/index.js +0 -4
  318. package/_esm/providers/FormProvider/index.js.map +0 -1
  319. package/_esm/providers/FormProvider/types.d.ts +0 -37
  320. package/_esm/providers/FormProvider/types.js.map +0 -1
  321. package/providers/FormProvider/FormProvider.tsx +0 -55
  322. package/providers/FormProvider/FormUpdater.tsx +0 -86
  323. package/providers/FormProvider/index.ts +0 -3
  324. package/providers/FormProvider/types.ts +0 -44
  325. /package/_cjs/{providers/FormProvider → stores/form}/URLSearchParamsBuilder.d.ts +0 -0
  326. /package/_cjs/{providers/FormProvider → stores/form}/types.js +0 -0
  327. /package/_esm/{providers/FormProvider → stores/form}/URLSearchParamsBuilder.d.ts +0 -0
  328. /package/_esm/{providers/FormProvider → stores/form}/types.js +0 -0
@@ -1,6 +1,7 @@
1
1
  import type { PropsWithChildren } from 'react';
2
2
  import type { WidgetConfigProps } from '../types';
3
3
  import { ChainOrderStoreProvider } from './chains';
4
+ import { FormStoreProvider } from './form';
4
5
  import { HeaderStoreProvider } from './header';
5
6
  import { RouteExecutionStoreProvider } from './routes';
6
7
  import { SplitSubvariantStoreProvider } from './settings';
@@ -10,20 +11,22 @@ export const StoreProvider: React.FC<PropsWithChildren<WidgetConfigProps>> = ({
10
11
  config,
11
12
  }) => {
12
13
  return (
13
- <SplitSubvariantStoreProvider
14
- state={
15
- config.subvariant === 'split'
16
- ? config.subvariantOptions || 'swap'
17
- : undefined
18
- }
19
- >
20
- <HeaderStoreProvider namePrefix={config?.keyPrefix}>
21
- <ChainOrderStoreProvider namePrefix={config?.keyPrefix}>
22
- <RouteExecutionStoreProvider namePrefix={config?.keyPrefix}>
23
- {children}
24
- </RouteExecutionStoreProvider>
25
- </ChainOrderStoreProvider>
26
- </HeaderStoreProvider>
27
- </SplitSubvariantStoreProvider>
14
+ <FormStoreProvider>
15
+ <SplitSubvariantStoreProvider
16
+ state={
17
+ config.subvariant === 'split'
18
+ ? config.subvariantOptions || 'swap'
19
+ : undefined
20
+ }
21
+ >
22
+ <HeaderStoreProvider namePrefix={config?.keyPrefix}>
23
+ <ChainOrderStoreProvider namePrefix={config?.keyPrefix}>
24
+ <RouteExecutionStoreProvider namePrefix={config?.keyPrefix}>
25
+ {children}
26
+ </RouteExecutionStoreProvider>
27
+ </ChainOrderStoreProvider>
28
+ </HeaderStoreProvider>
29
+ </SplitSubvariantStoreProvider>
30
+ </FormStoreProvider>
28
31
  );
29
32
  };
@@ -1,12 +1,11 @@
1
1
  import { createContext, useContext, useEffect, useRef } from 'react';
2
- import { useFormContext } from 'react-hook-form';
3
2
  import type { StoreApi } from 'zustand';
4
3
  import type { UseBoundStoreWithEqualityFn } from 'zustand/traditional';
5
4
  import { useChains } from '../../hooks';
6
- import { FormKey } from '../../providers';
7
5
  import type { PersistStoreProviderProps } from '../types';
8
6
  import { createChainOrderStore } from './createChainOrderStore';
9
7
  import type { ChainOrderState } from './types';
8
+ import { useFieldActions } from '../../stores';
10
9
 
11
10
  export type ChainOrderStore = UseBoundStoreWithEqualityFn<
12
11
  StoreApi<ChainOrderState>
@@ -22,7 +21,7 @@ export function ChainOrderStoreProvider({
22
21
  }: PersistStoreProviderProps) {
23
22
  const storeRef = useRef<ChainOrderStore>();
24
23
  const { chains: filteredChains } = useChains();
25
- const { setValue, getValues } = useFormContext();
24
+ const { setFieldValue, getFieldValues } = useFieldActions();
26
25
 
27
26
  if (!storeRef.current) {
28
27
  storeRef.current = createChainOrderStore(props);
@@ -34,19 +33,19 @@ export function ChainOrderStoreProvider({
34
33
  ?.getState()
35
34
  .initializeChains(filteredChains.map((chain) => chain.id));
36
35
  if (chainOrder) {
37
- const [fromChainValue, toChainValue] = getValues([
38
- FormKey.FromChain,
39
- FormKey.ToChain,
40
- ]);
36
+ const [fromChainValue, toChainValue] = getFieldValues(
37
+ 'fromChain',
38
+ 'toChain',
39
+ );
41
40
  if (!fromChainValue) {
42
- setValue(FormKey.FromChain, chainOrder[0]);
41
+ setFieldValue('fromChain', chainOrder[0]);
43
42
  }
44
43
  if (!toChainValue) {
45
- setValue(FormKey.ToChain, chainOrder[0]);
44
+ setFieldValue('toChain', chainOrder[0]);
46
45
  }
47
46
  }
48
47
  }
49
- }, [filteredChains, getValues, setValue]);
48
+ }, [filteredChains, getFieldValues, setFieldValue]);
50
49
 
51
50
  return (
52
51
  <ChainOrderStoreContext.Provider value={storeRef.current}>
@@ -0,0 +1,66 @@
1
+ import type { PropsWithChildren } from 'react';
2
+ import { createContext, useContext, useEffect, useMemo, useRef } from 'react';
3
+ import { shallow } from 'zustand/shallow';
4
+ import { useWidgetConfig } from '../../providers';
5
+ import type { FormStoreStore, FormValuesState } from './types';
6
+ import { createFormStore, formDefaultValues } from './createFormStore';
7
+ import { FormUpdater } from './FormUpdater';
8
+
9
+ export const FormStoreContext = createContext<FormStoreStore | null>(null);
10
+
11
+ export const FormStoreProvider: React.FC<PropsWithChildren> = ({
12
+ children,
13
+ }) => {
14
+ const storeRef = useRef<FormStoreStore>();
15
+
16
+ if (!storeRef.current) {
17
+ storeRef.current = createFormStore();
18
+ }
19
+
20
+ const { fromChain, fromToken, fromAmount, toChain, toToken, toAddress } =
21
+ useWidgetConfig();
22
+
23
+ const defaultValues = useMemo(
24
+ () => ({
25
+ ...formDefaultValues,
26
+ fromChain,
27
+ fromToken,
28
+ toChain,
29
+ toToken,
30
+ fromAmount:
31
+ (typeof fromAmount === 'number'
32
+ ? fromAmount?.toPrecision()
33
+ : fromAmount) || formDefaultValues.fromAmount,
34
+ toAddress: toAddress || formDefaultValues.toAddress,
35
+ }),
36
+ [fromAmount, fromChain, fromToken, toAddress, toChain, toToken],
37
+ );
38
+
39
+ useEffect(() => {
40
+ if (storeRef.current) {
41
+ storeRef.current.getState().setDefaultValues(defaultValues);
42
+ }
43
+ }, [defaultValues, storeRef]);
44
+
45
+ return (
46
+ <FormStoreContext.Provider value={storeRef.current}>
47
+ <FormUpdater defaultValues={defaultValues} />
48
+ {children}
49
+ </FormStoreContext.Provider>
50
+ );
51
+ };
52
+
53
+ export const useFormStore = (
54
+ selector: (store: FormValuesState) => any,
55
+ equalityFunction = shallow,
56
+ ) => {
57
+ const useStore = useContext(FormStoreContext);
58
+
59
+ if (!useStore) {
60
+ throw new Error(
61
+ 'You forgot to wrap your component in <FormStoreProvider>.',
62
+ );
63
+ }
64
+
65
+ return useStore(selector, equalityFunction);
66
+ };
@@ -0,0 +1,69 @@
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2
+ import { useEffect, useRef } from 'react';
3
+ import type { FormFieldNames } from './types';
4
+ import { useAccount } from '../../hooks';
5
+ import { useFieldActions } from './useFieldActions';
6
+ import { isItemAllowed, useWidgetConfig } from '../../providers';
7
+ import type { DefaultValues } from './types';
8
+ import { FormKey } from './types';
9
+
10
+ export const FormUpdater: React.FC<{
11
+ defaultValues: Partial<DefaultValues>;
12
+ }> = ({ defaultValues }) => {
13
+ const { fromChain, toChain, chains } = useWidgetConfig();
14
+ const { account } = useAccount();
15
+ const { isTouched, resetField, setFieldValue, getFieldValues } =
16
+ useFieldActions();
17
+ const previousDefaultValues = useRef(defaultValues);
18
+
19
+ // Set wallet chain as default if no chains are provided by config and if they were not changed during widget usage
20
+ useEffect(() => {
21
+ const chainAllowed =
22
+ account.chainId && isItemAllowed(account.chainId, chains);
23
+ if (!account.isConnected || !account.chainId || !chainAllowed) {
24
+ return;
25
+ }
26
+
27
+ if (!fromChain && !isTouched('fromChain') && !isTouched('fromToken')) {
28
+ resetField('fromChain', { defaultValue: account.chainId });
29
+ setFieldValue('fromToken', '');
30
+ if (isTouched('fromAmount')) {
31
+ setFieldValue('fromAmount', '');
32
+ }
33
+ }
34
+ if (!toChain && !isTouched('toChain') && !isTouched('toToken')) {
35
+ resetField('toChain', { defaultValue: account.chainId });
36
+ setFieldValue('toToken', '');
37
+ }
38
+ }, [
39
+ account.chainId,
40
+ account.isConnected,
41
+ chains,
42
+ fromChain,
43
+ toChain,
44
+ isTouched,
45
+ resetField,
46
+ setFieldValue,
47
+ ]);
48
+
49
+ // Makes widget config options reactive to changes
50
+ // should update userValues when defaultValues updates and includes additional logic for chains
51
+ useEffect(() => {
52
+ (Object.keys(defaultValues) as FormFieldNames[]).forEach((key) => {
53
+ if (previousDefaultValues.current[key] !== defaultValues[key]) {
54
+ const value =
55
+ defaultValues[key] ||
56
+ // set the chain to the current user one if it is not present in the config
57
+ (key === FormKey.FromChain || key === FormKey.ToChain
58
+ ? account.chainId || ''
59
+ : '');
60
+ setFieldValue(key, value);
61
+ resetField(key, { defaultValue: value });
62
+ }
63
+ });
64
+ previousDefaultValues.current = defaultValues;
65
+ // eslint-disable-next-line react-hooks/exhaustive-deps
66
+ }, [defaultValues, getFieldValues, resetField, setFieldValue]);
67
+
68
+ return null;
69
+ };
@@ -1,24 +1,20 @@
1
1
  import { useEffect } from 'react';
2
- import { useFormState, useWatch } from 'react-hook-form';
3
2
  import { useLocation } from 'react-router-dom';
4
- import { FormKey } from './types';
3
+ import type { FormFieldNames } from '../index';
4
+ import { useFieldValues, useTouchedFields } from '../index';
5
5
 
6
- const formValueKeys = [
7
- FormKey.FromAmount,
8
- FormKey.FromChain,
9
- FormKey.FromToken,
10
- FormKey.ToAddress,
11
- FormKey.ToChain,
12
- FormKey.ToToken,
6
+ const formValueKeys: FormFieldNames[] = [
7
+ 'fromAmount',
8
+ 'fromChain',
9
+ 'fromToken',
10
+ 'toAddress',
11
+ 'toChain',
12
+ 'toToken',
13
13
  ];
14
-
15
14
  export const URLSearchParamsBuilder = () => {
16
15
  const { pathname } = useLocation();
17
- const {
18
- // Have to use touchedFields, because default values are not considered dirty
19
- touchedFields: { ...touchedFields },
20
- } = useFormState();
21
- const values = useWatch({ name: formValueKeys });
16
+ const touchedFields = useTouchedFields();
17
+ const values = useFieldValues(...formValueKeys);
22
18
 
23
19
  useEffect(() => {
24
20
  const url = new URL(window.location as any);
@@ -0,0 +1,225 @@
1
+ import { createWithEqualityFn } from 'zustand/traditional';
2
+
3
+ import type {
4
+ DefaultValues,
5
+ FormFieldNames,
6
+ GenericFormValue,
7
+ FormValueControl,
8
+ FormValues,
9
+ FormValuesState,
10
+ } from './types';
11
+
12
+ export const formDefaultValues: DefaultValues = {
13
+ fromAmount: '',
14
+ toAddress: '',
15
+ tokenSearchFilter: '',
16
+ contractOutputsToken: '',
17
+ toContractAddress: '',
18
+ toContractCallData: '',
19
+ toContractGasLimit: '',
20
+ toAmount: '',
21
+ };
22
+
23
+ const defaultValueToFormValue = (
24
+ value: GenericFormValue,
25
+ ): FormValueControl<GenericFormValue> => ({
26
+ isTouched: false,
27
+ isDirty: false,
28
+ value,
29
+ });
30
+ const valuesToFormValues = (defaultValues: DefaultValues): FormValues => {
31
+ return (Object.keys(defaultValues) as FormFieldNames[]).reduce(
32
+ (accum, key) => {
33
+ return { ...accum, [key]: defaultValueToFormValue(defaultValues[key]) };
34
+ },
35
+ {},
36
+ ) as FormValues;
37
+ };
38
+
39
+ const isString = (str: any) => typeof str === 'string' || str instanceof String;
40
+
41
+ const getUpdatedTouchedFields = (userValues: FormValues) => {
42
+ return Object.keys(userValues).reduce(
43
+ (accum, key) =>
44
+ userValues[key as FormFieldNames]?.isTouched
45
+ ? { ...accum, [key]: true }
46
+ : accum,
47
+ {},
48
+ );
49
+ };
50
+ const mergeDefaultFormValues = (
51
+ userValues: FormValues,
52
+ defaultValues: FormValues,
53
+ ) =>
54
+ (Object.keys(defaultValues) as FormFieldNames[]).reduce<FormValues>(
55
+ (accum, key) => {
56
+ const formValue = {
57
+ isTouched: !!(
58
+ userValues[key]?.isTouched || defaultValues[key]?.isTouched
59
+ ),
60
+ isDirty: !!(userValues[key]?.isDirty || defaultValues[key]?.isTouched),
61
+ value:
62
+ userValues[key]?.value || Number.isFinite(userValues[key]?.value)
63
+ ? userValues[key]?.value
64
+ : defaultValues[key]?.value,
65
+ };
66
+
67
+ return {
68
+ ...accum,
69
+ [key]: formValue,
70
+ };
71
+ },
72
+ { ...valuesToFormValues(formDefaultValues) },
73
+ );
74
+
75
+ export const createFormStore = () =>
76
+ createWithEqualityFn<FormValuesState>(
77
+ (set, get) => ({
78
+ defaultValues: valuesToFormValues(formDefaultValues),
79
+ userValues: valuesToFormValues(formDefaultValues),
80
+ touchedFields: {},
81
+ setDefaultValues: (defaultValue) => {
82
+ const defaultFormValues = valuesToFormValues(defaultValue);
83
+ set((state) => ({
84
+ defaultValues: defaultFormValues,
85
+ userValues: mergeDefaultFormValues(
86
+ state.userValues,
87
+ defaultFormValues,
88
+ ),
89
+ }));
90
+ },
91
+ isTouched: (fieldName: FormFieldNames) =>
92
+ !!get().userValues[fieldName]?.isTouched,
93
+ setAsTouched: (fieldName: FormFieldNames) => {
94
+ const userValues = {
95
+ ...get().userValues,
96
+ [fieldName]: {
97
+ ...get().userValues[fieldName],
98
+ isTouched: true,
99
+ },
100
+ };
101
+
102
+ const touchedFields = getUpdatedTouchedFields(userValues);
103
+
104
+ set(() => ({
105
+ userValues,
106
+ touchedFields,
107
+ }));
108
+ },
109
+ resetField: (fieldName, { defaultValue } = {}) => {
110
+ if (defaultValue) {
111
+ const fieldValues = {
112
+ ...get().defaultValues[fieldName],
113
+ value: defaultValue,
114
+ };
115
+ const defaultValues = {
116
+ ...get().defaultValues,
117
+ [fieldName]: { ...fieldValues },
118
+ };
119
+ const userValues = {
120
+ ...get().userValues,
121
+ [fieldName]: { ...fieldValues },
122
+ };
123
+ const touchedFields = getUpdatedTouchedFields(userValues);
124
+
125
+ set(() => {
126
+ return {
127
+ defaultValues,
128
+ userValues,
129
+ touchedFields,
130
+ };
131
+ });
132
+ } else {
133
+ const userValues = {
134
+ ...get().userValues,
135
+ [fieldName]: { ...get().defaultValues[fieldName] },
136
+ };
137
+ const touchedFields = getUpdatedTouchedFields(userValues);
138
+
139
+ set(() => ({
140
+ userValues,
141
+ touchedFields,
142
+ }));
143
+ }
144
+ },
145
+ setFieldValue: (fieldName, value, { isDirty, isTouched } = {}) => {
146
+ const userValues = {
147
+ ...get().userValues,
148
+ [fieldName]: {
149
+ value,
150
+ isDirty:
151
+ isDirty === undefined
152
+ ? get().userValues[fieldName]?.isDirty
153
+ : isDirty,
154
+ isTouched:
155
+ isTouched === undefined
156
+ ? get().userValues[fieldName]?.isTouched
157
+ : isTouched,
158
+ },
159
+ };
160
+
161
+ const touchedFields = getUpdatedTouchedFields(userValues);
162
+
163
+ set(() => ({
164
+ userValues,
165
+ touchedFields,
166
+ }));
167
+ },
168
+ getFieldValues: (...names) =>
169
+ names.map((name) => get().userValues[name]?.value),
170
+ isValid: true,
171
+ isValidating: false,
172
+ errors: {},
173
+ validation: {},
174
+ addFieldValidation: (name, validationFn) => {
175
+ set((state) => ({
176
+ validation: {
177
+ ...state.validation,
178
+ [name]: validationFn,
179
+ },
180
+ }));
181
+ },
182
+ triggerFieldValidation: async (name) => {
183
+ try {
184
+ let valid = true;
185
+ set(() => ({ isValid: false, isValidating: true }));
186
+
187
+ const validationFn = get().validation[name];
188
+
189
+ if (validationFn) {
190
+ const result = await validationFn(get().userValues?.[name]?.value);
191
+ if (isString(result)) {
192
+ valid = false;
193
+ set((state) => ({
194
+ errors: {
195
+ ...state.errors,
196
+ [name]: result,
197
+ },
198
+ }));
199
+ } else {
200
+ valid = result as boolean;
201
+ if (valid) {
202
+ get().clearErrors(name);
203
+ }
204
+ }
205
+ }
206
+
207
+ set(() => ({ isValid: valid, isValidating: false }));
208
+ return valid;
209
+ } catch (err) {
210
+ set(() => ({ isValidating: false }));
211
+ throw err;
212
+ }
213
+ },
214
+ clearErrors: (name) => {
215
+ const newErrors = { ...get().errors };
216
+
217
+ delete newErrors[name];
218
+
219
+ set(() => ({
220
+ errors: newErrors,
221
+ }));
222
+ },
223
+ }),
224
+ Object.is,
225
+ );
@@ -0,0 +1,10 @@
1
+ export * from './createFormStore';
2
+ export * from './FormStore';
3
+ export * from './types';
4
+ export * from './useFieldActions';
5
+ export * from './useFieldController';
6
+ export * from './useFieldValues';
7
+ export * from './useTouchedFields';
8
+ export * from './useValidation';
9
+ export * from './useValidationActions';
10
+ export * from './URLSearchParamsBuilder';
@@ -0,0 +1,138 @@
1
+ import type { UseBoundStoreWithEqualityFn } from 'zustand/traditional';
2
+ import type { StoreApi } from 'zustand';
3
+
4
+ export interface DefaultValues {
5
+ toAddress: string;
6
+ tokenSearchFilter: string;
7
+ contractOutputsToken: string;
8
+ toContractAddress: string;
9
+ toContractCallData: string;
10
+ toContractGasLimit: string;
11
+ toAmount: string;
12
+ fromAmount: string;
13
+ toChain?: number;
14
+ fromChain?: number;
15
+ fromToken?: string;
16
+ toToken?: string | undefined;
17
+ }
18
+
19
+ export type GenericFormValue = string | number | undefined;
20
+ export interface FormValueControl<T> {
21
+ isTouched: boolean;
22
+ isDirty: boolean;
23
+ value: T;
24
+ }
25
+
26
+ export interface FormValues {
27
+ toAddress: FormValueControl<string>;
28
+ tokenSearchFilter: FormValueControl<string>;
29
+ contractOutputsToken: FormValueControl<string>;
30
+ toContractAddress: FormValueControl<string>;
31
+ toContractCallData: FormValueControl<string>;
32
+ toContractGasLimit: FormValueControl<string>;
33
+ toAmount: FormValueControl<string>;
34
+ fromAmount: FormValueControl<string>;
35
+ fromToken?: FormValueControl<string | undefined>;
36
+ toToken?: FormValueControl<string | undefined>;
37
+ toChain?: FormValueControl<number | undefined>;
38
+ fromChain?: FormValueControl<number | undefined>;
39
+ }
40
+
41
+ export type FormFieldNames = keyof FormValues;
42
+
43
+ export type TouchedFields = { [key in FormFieldNames]?: boolean };
44
+
45
+ type ValidationFn = (value: any) => Promise<boolean | string>;
46
+ export interface ValidationProps {
47
+ isValid: boolean;
48
+ isValidating: boolean;
49
+ errors: {
50
+ [key in FormFieldNames]?: string;
51
+ };
52
+ validation: {
53
+ [key in FormFieldNames]?: ValidationFn;
54
+ };
55
+ }
56
+
57
+ export interface ValidationActions {
58
+ addFieldValidation: (
59
+ name: FormFieldNames,
60
+ validationFn: ValidationFn,
61
+ ) => void;
62
+ triggerFieldValidation: (name: FormFieldNames) => Promise<boolean>;
63
+ clearErrors: (name: FormFieldNames) => void;
64
+ }
65
+ export type ValidationActionNames = keyof ValidationActions;
66
+ export type ValidationActionFunctions = Array<
67
+ ValidationActions[ValidationActionNames]
68
+ >;
69
+
70
+ export interface FormProps {
71
+ defaultValues: FormValues;
72
+ userValues: FormValues;
73
+ touchedFields: { [key in FormFieldNames]?: boolean };
74
+ }
75
+
76
+ interface ResetOptions {
77
+ defaultValue?: GenericFormValue;
78
+ }
79
+
80
+ export interface FormActions {
81
+ setDefaultValues: (formValues: DefaultValues) => void;
82
+ isTouched: (fieldName: FormFieldNames) => boolean;
83
+ setAsTouched: (fieldName: FormFieldNames) => void;
84
+ resetField: (fieldName: FormFieldNames, resetOptions?: ResetOptions) => void;
85
+ setFieldValue: (
86
+ fieldName: FormFieldNames,
87
+ value: GenericFormValue,
88
+ options?: SetOptions,
89
+ ) => void;
90
+ getFieldValues: (...names: FormFieldNames[]) => Array<any>;
91
+ }
92
+
93
+ export type FormActionNames = keyof FormActions;
94
+ export type FormActionFunctions = Array<FormActions[FormActionNames]>;
95
+
96
+ export type FormValuesState = FormProps &
97
+ FormActions &
98
+ ValidationProps &
99
+ ValidationActions;
100
+
101
+ export type FormStoreStore = UseBoundStoreWithEqualityFn<
102
+ StoreApi<FormValuesState>
103
+ >;
104
+
105
+ interface SetOptions {
106
+ isDirty?: boolean;
107
+ isTouched?: boolean;
108
+ }
109
+
110
+ export enum FormKey {
111
+ ContractOutputsToken = 'contractOutputsToken',
112
+ FromAmount = 'fromAmount',
113
+ FromChain = 'fromChain',
114
+ FromToken = 'fromToken',
115
+ ToAddress = 'toAddress',
116
+ ToAmount = 'toAmount',
117
+ ToChain = 'toChain',
118
+ ToContractAddress = 'toContractAddress',
119
+ ToContractCallData = 'toContractCallData',
120
+ ToContractGasLimit = 'ToContractGasLimit',
121
+ ToToken = 'toToken',
122
+ TokenSearchFilter = 'tokenSearchFilter',
123
+ }
124
+
125
+ export type FormType = 'from' | 'to';
126
+
127
+ export interface FormTypeProps {
128
+ formType: FormType;
129
+ }
130
+
131
+ export const FormKeyHelper = {
132
+ getChainKey: (formType: FormType): 'fromChain' | 'toChain' =>
133
+ `${formType}Chain`,
134
+ getTokenKey: (formType: FormType): 'fromToken' | 'toToken' =>
135
+ `${formType}Token`,
136
+ getAmountKey: (formType: FormType): 'fromAmount' | 'toAmount' =>
137
+ `${formType}Amount`,
138
+ };
@@ -0,0 +1,28 @@
1
+ import { shallow } from 'zustand/shallow';
2
+ import type {
3
+ FormActions,
4
+ FormActionNames,
5
+ FormActionFunctions,
6
+ } from './types';
7
+ import { useFormStore } from './FormStore';
8
+
9
+ const actionFunctions: FormActionNames[] = [
10
+ 'setDefaultValues',
11
+ 'isTouched',
12
+ 'setAsTouched',
13
+ 'resetField',
14
+ 'setFieldValue',
15
+ 'getFieldValues',
16
+ ];
17
+
18
+ export const useFieldActions = () => {
19
+ const actions: FormActionFunctions = useFormStore(
20
+ (store) => actionFunctions.map((actionName) => store[actionName]),
21
+ shallow,
22
+ );
23
+
24
+ return actions.reduce(
25
+ (accum, actionName, i) => ({ ...accum, [actionFunctions[i]]: actionName }),
26
+ {},
27
+ ) as FormActions;
28
+ };