@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
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import type { DefaultValues } from './types';
3
+ export declare const FormUpdater: React.FC<{
4
+ defaultValues: Partial<DefaultValues>;
5
+ }>;
@@ -0,0 +1,58 @@
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2
+ import { useEffect, useRef } from 'react';
3
+ import { useAccount } from '../../hooks';
4
+ import { useFieldActions } from './useFieldActions';
5
+ import { isItemAllowed, useWidgetConfig } from '../../providers';
6
+ import { FormKey } from './types';
7
+ export const FormUpdater = ({ defaultValues }) => {
8
+ const { fromChain, toChain, chains } = useWidgetConfig();
9
+ const { account } = useAccount();
10
+ const { isTouched, resetField, setFieldValue, getFieldValues } = useFieldActions();
11
+ const previousDefaultValues = useRef(defaultValues);
12
+ // Set wallet chain as default if no chains are provided by config and if they were not changed during widget usage
13
+ useEffect(() => {
14
+ const chainAllowed = account.chainId && isItemAllowed(account.chainId, chains);
15
+ if (!account.isConnected || !account.chainId || !chainAllowed) {
16
+ return;
17
+ }
18
+ if (!fromChain && !isTouched('fromChain') && !isTouched('fromToken')) {
19
+ resetField('fromChain', { defaultValue: account.chainId });
20
+ setFieldValue('fromToken', '');
21
+ if (isTouched('fromAmount')) {
22
+ setFieldValue('fromAmount', '');
23
+ }
24
+ }
25
+ if (!toChain && !isTouched('toChain') && !isTouched('toToken')) {
26
+ resetField('toChain', { defaultValue: account.chainId });
27
+ setFieldValue('toToken', '');
28
+ }
29
+ }, [
30
+ account.chainId,
31
+ account.isConnected,
32
+ chains,
33
+ fromChain,
34
+ toChain,
35
+ isTouched,
36
+ resetField,
37
+ setFieldValue,
38
+ ]);
39
+ // Makes widget config options reactive to changes
40
+ // should update userValues when defaultValues updates and includes additional logic for chains
41
+ useEffect(() => {
42
+ Object.keys(defaultValues).forEach((key) => {
43
+ if (previousDefaultValues.current[key] !== defaultValues[key]) {
44
+ const value = defaultValues[key] ||
45
+ // set the chain to the current user one if it is not present in the config
46
+ (key === FormKey.FromChain || key === FormKey.ToChain
47
+ ? account.chainId || ''
48
+ : '');
49
+ setFieldValue(key, value);
50
+ resetField(key, { defaultValue: value });
51
+ }
52
+ });
53
+ previousDefaultValues.current = defaultValues;
54
+ // eslint-disable-next-line react-hooks/exhaustive-deps
55
+ }, [defaultValues, getFieldValues, resetField, setFieldValue]);
56
+ return null;
57
+ };
58
+ //# sourceMappingURL=FormUpdater.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormUpdater.js","sourceRoot":"","sources":["../../../stores/form/FormUpdater.tsx"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEjE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,MAAM,CAAC,MAAM,WAAW,GAEnB,CAAC,EAAE,aAAa,EAAE,EAAE,EAAE;IACzB,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,eAAe,EAAE,CAAC;IACzD,MAAM,EAAE,OAAO,EAAE,GAAG,UAAU,EAAE,CAAC;IACjC,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,cAAc,EAAE,GAC5D,eAAe,EAAE,CAAC;IACpB,MAAM,qBAAqB,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;IAEpD,mHAAmH;IACnH,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,YAAY,GAChB,OAAO,CAAC,OAAO,IAAI,aAAa,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC5D,IAAI,CAAC,OAAO,CAAC,WAAW,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,CAAC,YAAY,EAAE,CAAC;YAC9D,OAAO;QACT,CAAC;QAED,IAAI,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Aa,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;gBAC1B,UAAU,CAAC,GAAG,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC,CAAC,CAAC;QACH,qBAAqB,CAAC,OAAO,GAAG,aAAa,CAAC;QAC9C,uDAAuD;IACzD,CAAC,EAAE,CAAC,aAAa,EAAE,cAAc,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC;IAE/D,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
@@ -1,21 +1,18 @@
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 { useFieldValues, useTouchedFields } from '../index';
5
4
  const formValueKeys = [
6
- FormKey.FromAmount,
7
- FormKey.FromChain,
8
- FormKey.FromToken,
9
- FormKey.ToAddress,
10
- FormKey.ToChain,
11
- FormKey.ToToken,
5
+ 'fromAmount',
6
+ 'fromChain',
7
+ 'fromToken',
8
+ 'toAddress',
9
+ 'toChain',
10
+ 'toToken',
12
11
  ];
13
12
  export const URLSearchParamsBuilder = () => {
14
13
  const { pathname } = useLocation();
15
- const {
16
- // Have to use touchedFields, because default values are not considered dirty
17
- touchedFields: { ...touchedFields }, } = useFormState();
18
- const values = useWatch({ name: formValueKeys });
14
+ const touchedFields = useTouchedFields();
15
+ const values = useFieldValues(...formValueKeys);
19
16
  useEffect(() => {
20
17
  const url = new URL(window.location);
21
18
  formValueKeys.forEach((key, index) => {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"URLSearchParamsBuilder.js","sourceRoot":"","sources":["../../../stores/form/URLSearchParamsBuilder.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,U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ultValues;
3
+ export declare const createFormStore: () => import("zustand/traditional").UseBoundStoreWithEqualityFn<import("zustand").StoreApi<FormValuesState>>;
@@ -0,0 +1,173 @@
1
+ import { createWithEqualityFn } from 'zustand/traditional';
2
+ export const formDefaultValues = {
3
+ fromAmount: '',
4
+ toAddress: '',
5
+ tokenSearchFilter: '',
6
+ contractOutputsToken: '',
7
+ toContractAddress: '',
8
+ toContractCallData: '',
9
+ toContractGasLimit: '',
10
+ toAmount: '',
11
+ };
12
+ const defaultValueToFormValue = (value) => ({
13
+ isTouched: false,
14
+ isDirty: false,
15
+ value,
16
+ });
17
+ const valuesToFormValues = (defaultValues) => {
18
+ return Object.keys(defaultValues).reduce((accum, key) => {
19
+ return { ...accum, [key]: defaultValueToFormValue(defaultValues[key]) };
20
+ }, {});
21
+ };
22
+ const isString = (str) => typeof str === 'string' || str instanceof String;
23
+ const getUpdatedTouchedFields = (userValues) => {
24
+ return Object.keys(userValues).reduce((accum, key) => userValues[key]?.isTouched
25
+ ? { ...accum, [key]: true }
26
+ : accum, {});
27
+ };
28
+ const mergeDefaultFormValues = (userValues, defaultValues) => Object.keys(defaultValues).reduce((accum, key) => {
29
+ const formValue = {
30
+ isTouched: !!(userValues[key]?.isTouched || defaultValues[key]?.isTouched),
31
+ isDirty: !!(userValues[key]?.isDirty || defaultValues[key]?.isTouched),
32
+ value: userValues[key]?.value || Number.isFinite(userValues[key]?.value)
33
+ ? userValues[key]?.value
34
+ : defaultValues[key]?.value,
35
+ };
36
+ return {
37
+ ...accum,
38
+ [key]: formValue,
39
+ };
40
+ }, { ...valuesToFormValues(formDefaultValues) });
41
+ export const createFormStore = () => createWithEqualityFn((set, get) => ({
42
+ defaultValues: valuesToFormValues(formDefaultValues),
43
+ userValues: valuesToFormValues(formDefaultValues),
44
+ touchedFields: {},
45
+ setDefaultValues: (defaultValue) => {
46
+ const defaultFormValues = valuesToFormValues(defaultValue);
47
+ set((state) => ({
48
+ defaultValues: defaultFormValues,
49
+ userValues: mergeDefaultFormValues(state.userValues, defaultFormValues),
50
+ }));
51
+ },
52
+ isTouched: (fieldName) => !!get().userValues[fieldName]?.isTouched,
53
+ setAsTouched: (fieldName) => {
54
+ const userValues = {
55
+ ...get().userValues,
56
+ [fieldName]: {
57
+ ...get().userValues[fieldName],
58
+ isTouched: true,
59
+ },
60
+ };
61
+ const touchedFields = getUpdatedTouchedFields(userValues);
62
+ set(() => ({
63
+ userValues,
64
+ touchedFields,
65
+ }));
66
+ },
67
+ resetField: (fieldName, { defaultValue } = {}) => {
68
+ if (defaultValue) {
69
+ const fieldValues = {
70
+ ...get().defaultValues[fieldName],
71
+ value: defaultValue,
72
+ };
73
+ const defaultValues = {
74
+ ...get().defaultValues,
75
+ [fieldName]: { ...fieldValues },
76
+ };
77
+ const userValues = {
78
+ ...get().userValues,
79
+ [fieldName]: { ...fieldValues },
80
+ };
81
+ const touchedFields = getUpdatedTouchedFields(userValues);
82
+ set(() => {
83
+ return {
84
+ defaultValues,
85
+ userValues,
86
+ touchedFields,
87
+ };
88
+ });
89
+ }
90
+ else {
91
+ const userValues = {
92
+ ...get().userValues,
93
+ [fieldName]: { ...get().defaultValues[fieldName] },
94
+ };
95
+ const touchedFields = getUpdatedTouchedFields(userValues);
96
+ set(() => ({
97
+ userValues,
98
+ touchedFields,
99
+ }));
100
+ }
101
+ },
102
+ setFieldValue: (fieldName, value, { isDirty, isTouched } = {}) => {
103
+ const userValues = {
104
+ ...get().userValues,
105
+ [fieldName]: {
106
+ value,
107
+ isDirty: isDirty === undefined
108
+ ? get().userValues[fieldName]?.isDirty
109
+ : isDirty,
110
+ isTouched: isTouched === undefined
111
+ ? get().userValues[fieldName]?.isTouched
112
+ : isTouched,
113
+ },
114
+ };
115
+ const touchedFields = getUpdatedTouchedFields(userValues);
116
+ set(() => ({
117
+ userValues,
118
+ touchedFields,
119
+ }));
120
+ },
121
+ getFieldValues: (...names) => names.map((name) => get().userValues[name]?.value),
122
+ isValid: true,
123
+ isValidating: false,
124
+ errors: {},
125
+ validation: {},
126
+ addFieldValidation: (name, validationFn) => {
127
+ set((state) => ({
128
+ validation: {
129
+ ...state.validation,
130
+ [name]: validationFn,
131
+ },
132
+ }));
133
+ },
134
+ triggerFieldValidation: async (name) => {
135
+ try {
136
+ let valid = true;
137
+ set(() => ({ isValid: false, isValidating: true }));
138
+ const validationFn = get().validation[name];
139
+ if (validationFn) {
140
+ const result = await validationFn(get().userValues?.[name]?.value);
141
+ if (isString(result)) {
142
+ valid = false;
143
+ set((state) => ({
144
+ errors: {
145
+ ...state.errors,
146
+ [name]: result,
147
+ },
148
+ }));
149
+ }
150
+ else {
151
+ valid = result;
152
+ if (valid) {
153
+ get().clearErrors(name);
154
+ }
155
+ }
156
+ }
157
+ set(() => ({ isValid: valid, isValidating: false }));
158
+ return valid;
159
+ }
160
+ catch (err) {
161
+ set(() => ({ isValidating: false }));
162
+ throw err;
163
+ }
164
+ },
165
+ clearErrors: (name) => {
166
+ const newErrors = { ...get().errors };
167
+ delete newErrors[name];
168
+ set(() => ({
169
+ errors: newErrors,
170
+ }));
171
+ },
172
+ }), Object.is);
173
+ //# sourceMappingURL=createFormStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createFormStore.js","sourceRoot":"","sources":["../../../stores/form/createFormStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAW3D,MAAM,CAAC,MAAM,iBAAiB,GAAkB;IAC9C,UAAU,EAAE,EAAE;IACd,SAAS,EAAE,EAAE;IACb,iBAAiB,EAAE,EAAE;IACrB,oBAAoB,EAAE,EAAE;IACxB,iBAAiB,EAAE,EAAE;IACrB,kBAAkB,EAAE,EAAE;IACtB,kBAAkB,EAAE,EAAE;IACtB,QAAQ,EAAE,EAAE;CACb,CAAC;AAEF,MAAM,uBAAuB,GAAG,CAC9B,KAAuB,EACa,EAAE,CAAC,CAAC;IACxC,SAAS,EAAE,KAAK;IAChB,OAAO,EAAE,KAAK;IACd,KAA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,CAAC,CAAC;YACT,MAAM,EAAE,SAAS;SAClB,CAAC,CAAC,CAAC;IACN,CAAC;CACF,CAAC,EACF,MAAM,CAAC,EAAE,CACV,CAAC"}
@@ -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,11 @@
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';
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../stores/form/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC"}
@@ -0,0 +1,108 @@
1
+ import type { UseBoundStoreWithEqualityFn } from 'zustand/traditional';
2
+ import type { StoreApi } from 'zustand';
3
+ export interface DefaultValues {
4
+ toAddress: string;
5
+ tokenSearchFilter: string;
6
+ contractOutputsToken: string;
7
+ toContractAddress: string;
8
+ toContractCallData: string;
9
+ toContractGasLimit: string;
10
+ toAmount: string;
11
+ fromAmount: string;
12
+ toChain?: number;
13
+ fromChain?: number;
14
+ fromToken?: string;
15
+ toToken?: string | undefined;
16
+ }
17
+ export type GenericFormValue = string | number | undefined;
18
+ export interface FormValueControl<T> {
19
+ isTouched: boolean;
20
+ isDirty: boolean;
21
+ value: T;
22
+ }
23
+ export interface FormValues {
24
+ toAddress: FormValueControl<string>;
25
+ tokenSearchFilter: FormValueControl<string>;
26
+ contractOutputsToken: FormValueControl<string>;
27
+ toContractAddress: FormValueControl<string>;
28
+ toContractCallData: FormValueControl<string>;
29
+ toContractGasLimit: FormValueControl<string>;
30
+ toAmount: FormValueControl<string>;
31
+ fromAmount: FormValueControl<string>;
32
+ fromToken?: FormValueControl<string | undefined>;
33
+ toToken?: FormValueControl<string | undefined>;
34
+ toChain?: FormValueControl<number | undefined>;
35
+ fromChain?: FormValueControl<number | undefined>;
36
+ }
37
+ export type FormFieldNames = keyof FormValues;
38
+ export type TouchedFields = {
39
+ [key in FormFieldNames]?: boolean;
40
+ };
41
+ type ValidationFn = (value: any) => Promise<boolean | string>;
42
+ export interface ValidationProps {
43
+ isValid: boolean;
44
+ isValidating: boolean;
45
+ errors: {
46
+ [key in FormFieldNames]?: string;
47
+ };
48
+ validation: {
49
+ [key in FormFieldNames]?: ValidationFn;
50
+ };
51
+ }
52
+ export interface ValidationActions {
53
+ addFieldValidation: (name: FormFieldNames, validationFn: ValidationFn) => void;
54
+ triggerFieldValidation: (name: FormFieldNames) => Promise<boolean>;
55
+ clearErrors: (name: FormFieldNames) => void;
56
+ }
57
+ export type ValidationActionNames = keyof ValidationActions;
58
+ export type ValidationActionFunctions = Array<ValidationActions[ValidationActionNames]>;
59
+ export interface FormProps {
60
+ defaultValues: FormValues;
61
+ userValues: FormValues;
62
+ touchedFields: {
63
+ [key in FormFieldNames]?: boolean;
64
+ };
65
+ }
66
+ interface ResetOptions {
67
+ defaultValue?: GenericFormValue;
68
+ }
69
+ export interface FormActions {
70
+ setDefaultValues: (formValues: DefaultValues) => void;
71
+ isTouched: (fieldName: FormFieldNames) => boolean;
72
+ setAsTouched: (fieldName: FormFieldNames) => void;
73
+ resetField: (fieldName: FormFieldNames, resetOptions?: ResetOptions) => void;
74
+ setFieldValue: (fieldName: FormFieldNames, value: GenericFormValue, options?: SetOptions) => void;
75
+ getFieldValues: (...names: FormFieldNames[]) => Array<any>;
76
+ }
77
+ export type FormActionNames = keyof FormActions;
78
+ export type FormActionFunctions = Array<FormActions[FormActionNames]>;
79
+ export type FormValuesState = FormProps & FormActions & ValidationProps & ValidationActions;
80
+ export type FormStoreStore = UseBoundStoreWithEqualityFn<StoreApi<FormValuesState>>;
81
+ interface SetOptions {
82
+ isDirty?: boolean;
83
+ isTouched?: boolean;
84
+ }
85
+ export declare enum FormKey {
86
+ ContractOutputsToken = "contractOutputsToken",
87
+ FromAmount = "fromAmount",
88
+ FromChain = "fromChain",
89
+ FromToken = "fromToken",
90
+ ToAddress = "toAddress",
91
+ ToAmount = "toAmount",
92
+ ToChain = "toChain",
93
+ ToContractAddress = "toContractAddress",
94
+ ToContractCallData = "toContractCallData",
95
+ ToContractGasLimit = "ToContractGasLimit",
96
+ ToToken = "toToken",
97
+ TokenSearchFilter = "tokenSearchFilter"
98
+ }
99
+ export type FormType = 'from' | 'to';
100
+ export interface FormTypeProps {
101
+ formType: FormType;
102
+ }
103
+ export declare const FormKeyHelper: {
104
+ getChainKey: (formType: FormType) => 'fromChain' | 'toChain';
105
+ getTokenKey: (formType: FormType) => 'fromToken' | 'toToken';
106
+ getAmountKey: (formType: FormType) => 'fromAmount' | 'toAmount';
107
+ };
108
+ export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../stores/form/types.ts"],"names":[],"mappings":"AA6GA,MAAM,CAAN,IAAY,OAaX;AAbD,WAAY,OAAO;IACjB,wDAA6C,CAAA;IAC7C,oCAAyB,CAAA;IACzB,kCAAuB,CAAA;IACvB,kCAAuB,CAAA;IACvB,kCAAuB,CAAA;IACvB,gCAAqB,CAAA;IACrB,8BAAmB,CAAA;IACnB,kDAAuC,CAAA;IACvC,oDAAyC,CAAA;IACzC,oDAAyC,CAAA;IACzC,8BAAmB,CAAA;IACnB,kDAAuC,CAAA;AACzC,CAAC,EAbW,OAAO,KAAP,OAAO,QAalB;AAQD,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,WAAW,EAAE,CAAC,QAAkB,EAA2B,EAAE,CAC3D,GAAG,QAAQ,OAAO;IACpB,WAAW,EAAE,CAAC,QAAkB,EAA2B,EAAE,CAC3D,GAAG,QAAQ,OAAO;IACpB,YAAY,EAAE,CAAC,QAAkB,EAA6B,EAAE,CAC9D,GAAG,QAAQ,QAAQ;CACtB,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { FormActions } from './types';
2
+ export declare const useFieldActions: () => FormActions;
@@ -0,0 +1,15 @@
1
+ import { shallow } from 'zustand/shallow';
2
+ import { useFormStore } from './FormStore';
3
+ const actionFunctions = [
4
+ 'setDefaultValues',
5
+ 'isTouched',
6
+ 'setAsTouched',
7
+ 'resetField',
8
+ 'setFieldValue',
9
+ 'getFieldValues',
10
+ ];
11
+ export const useFieldActions = () => {
12
+ const actions = useFormStore((store) => actionFunctions.map((actionName) => store[actionName]), shallow);
13
+ return actions.reduce((accum, actionName, i) => ({ ...accum, [actionFunctions[i]]: actionName }), {});
14
+ };
15
+ //# sourceMappingURL=useFieldActions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFieldActions.js","sourceRoot":"","sources":["../../../stores/form/useFieldActions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAM1C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,eAAe,GAAsB;IACzC,kBAAkB;IAClB,WAAW;IACX,cAAc;IACd,YAAY;IACZ,eAAe;IACf,gBAAgB;CACjB,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IAClC,MAAM,OAAO,GAAwB,YAAY,CAC/C,CAAC,KAAK,EAAE,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,EACjE,OAAO,CACR,CAAC;IAEF,OAAO,OAAO,CAAC,MAAM,CACnB,CAAC,KAAK,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAC1E,EAAE,CACY,CAAC;AACnB,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { FormFieldNames } from './types';
2
+ interface UseFieldControllerProps {
3
+ name: FormFieldNames;
4
+ }
5
+ export declare const useFieldController: ({ name }: UseFieldControllerProps) => {
6
+ onChange: (newValue: string | number | undefined) => void;
7
+ onBlur: () => void;
8
+ name: keyof import("./types").FormValues;
9
+ value: any;
10
+ };
11
+ export {};
@@ -0,0 +1,20 @@
1
+ import { useCallback } from 'react';
2
+ import { useFieldValues } from './useFieldValues';
3
+ import { useFieldActions } from './useFieldActions';
4
+ export const useFieldController = ({ name }) => {
5
+ const [fieldValue] = useFieldValues(name);
6
+ const { setFieldValue, setAsTouched } = useFieldActions();
7
+ const onChange = useCallback((newValue) => {
8
+ setFieldValue(name, newValue, { isDirty: true });
9
+ }, [name, setFieldValue]);
10
+ const onBlur = useCallback(() => {
11
+ setAsTouched(name);
12
+ }, [name, setAsTouched]);
13
+ return {
14
+ onChange,
15
+ onBlur,
16
+ name,
17
+ value: fieldValue,
18
+ };
19
+ };
20
+ //# sourceMappingURL=useFieldController.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFieldController.js","sourceRoot":"","sources":["../../../stores/form/useFieldController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAMpD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,EAAE,IAAI,EAA2B,EAAE,EAAE;IACtE,MAAM,CAAC,UAAU,CAAC,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,GAAG,eAAe,EAAE,CAAC;IAE1D,MAAM,QAAQ,GAAG,WAAW,CAC1B,CAAC,QAAqC,EAAE,EAAE;QACxC,aAAa,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACnD,CAAC,EACD,CAAC,IAAI,EAAE,aAAa,CAAC,CACtB,CAAC;IAEF,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE;QAC9B,YAAY,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC;IAEzB,OAAO;QACL,QAAQ;QACR,MAAM;QACN,IAAI;QACJ,KAAK,EAAE,UAAU;KAClB,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { FormFieldNames } from './types';
2
+ export declare const useFieldValues: (...names: FormFieldNames[]) => any;
@@ -0,0 +1,7 @@
1
+ import { useFormStore } from './FormStore';
2
+ import { shallow } from 'zustand/shallow';
3
+ export const useFieldValues = (...names) => {
4
+ const values = useFormStore((store) => names.map((name) => store.userValues[name]?.value), shallow);
5
+ return values;
6
+ };
7
+ //# sourceMappingURL=useFieldValues.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFieldValues.js","sourceRoot":"","sources":["../../../stores/form/useFieldValues.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAG,KAAuB,EAAE,EAAE;IAC3D,MAAM,MAAM,GAAG,YAAY,CACzB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,EAC7D,OAAO,CACR,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const useTouchedFields: () => any;
@@ -0,0 +1,7 @@
1
+ import { useFormStore } from './FormStore';
2
+ import { shallow } from 'zustand/shallow';
3
+ export const useTouchedFields = () => {
4
+ const touchedFields = useFormStore((store) => store.touchedFields, shallow);
5
+ return touchedFields;
6
+ };
7
+ //# sourceMappingURL=useTouchedFields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTouchedFields.js","sourceRoot":"","sources":["../../../stores/form/useTouchedFields.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,MAAM,aAAa,GAAG,YAAY,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAE5E,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { ValidationProps } from './types';
2
+ export declare const useValidation: () => Omit<ValidationProps, 'validation'>;
@@ -0,0 +1,11 @@
1
+ import { useFormStore } from './FormStore';
2
+ import { shallow } from 'zustand/shallow';
3
+ export const useValidation = () => {
4
+ const [isValid, isValidating, errors] = useFormStore((store) => [store.isValid, store.isValidating, store.errors], shallow);
5
+ return {
6
+ isValid,
7
+ isValidating,
8
+ errors,
9
+ };
10
+ };
11
+ //# sourceMappingURL=useValidation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useValidation.js","sourceRoot":"","sources":["../../../stores/form/useValidation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,MAAM,CAAC,MAAM,aAAa,GAAG,GAAwC,EAAE;IACrE,MAAM,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,CAAC,GAAG,YAAY,CAClD,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,EAC5D,OAAO,CACR,CAAC;IAEF,OAAO;QACL,OAAO;QACP,YAAY;QACZ,MAAM;KACP,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { ValidationActions } from './types';
2
+ export declare const useValidationActions: () => ValidationActions;
@@ -0,0 +1,15 @@
1
+ import { useFormStore } from './FormStore';
2
+ import { shallow } from 'zustand/shallow';
3
+ const validationFunctions = [
4
+ 'addFieldValidation',
5
+ 'triggerFieldValidation',
6
+ 'clearErrors',
7
+ ];
8
+ export const useValidationActions = () => {
9
+ const actions = useFormStore((store) => validationFunctions.map((actionName) => store[actionName]), shallow);
10
+ return actions.reduce((accum, actionName, i) => ({
11
+ ...accum,
12
+ [validationFunctions[i]]: actionName,
13
+ }), {});
14
+ };
15
+ //# sourceMappingURL=useValidationActions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useValidationActions.js","sourceRoot":"","sources":["../../../stores/form/useValidationActions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG1C,MAAM,mBAAmB,GAA4B;IACnD,oBAAoB;IACpB,wBAAwB;IACxB,aAAa;CACd,CAAC;AACF,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,EAAE;IACvC,MAAM,OAAO,GAA8B,YAAY,CACrD,CAAC,KAAK,EAAE,EAAE,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,EACrE,OAAO,CACR,CAAC;IAEF,OAAO,OAAO,CAAC,MAAM,CACnB,CAAC,KAAK,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QACzB,GAAG,KAAK;QACR,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU;KACrC,CAAC,EACF,EAAE,CACkB,CAAC;AACzB,CAAC,CAAC"}
@@ -3,3 +3,4 @@ export * from './chains';
3
3
  export * from './header';
4
4
  export * from './routes';
5
5
  export * from './settings';
6
+ export * from './form';
@@ -3,4 +3,5 @@ export * from './chains';
3
3
  export * from './header';
4
4
  export * from './routes';
5
5
  export * from './settings';
6
+ export * from './form';
6
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../stores/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../stores/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC"}