@babylonlabs-io/core-ui 1.12.0 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (396) hide show
  1. package/dist/components/Accordion/Accordion.d.ts +2 -2
  2. package/dist/components/Accordion/Accordion.js +25 -0
  3. package/dist/components/Accordion/Accordion.stories.d.ts +6 -0
  4. package/dist/components/Accordion/Accordion.stories.js +16 -0
  5. package/dist/components/Accordion/components/AccordionDetails.d.ts +1 -1
  6. package/dist/components/Accordion/components/AccordionDetails.js +29 -0
  7. package/dist/components/Accordion/components/AccordionSummary.d.ts +1 -1
  8. package/dist/components/Accordion/components/AccordionSummary.js +10 -0
  9. package/dist/components/Accordion/hooks/useHeightObserver.d.ts +1 -1
  10. package/dist/components/Accordion/hooks/useHeightObserver.js +24 -0
  11. package/dist/components/Accordion/index.d.ts +4 -3
  12. package/dist/components/Accordion/index.js +4 -0
  13. package/dist/components/AmountItem/AmountItem.d.ts +1 -1
  14. package/dist/components/AmountItem/AmountItem.js +5 -0
  15. package/dist/components/AmountItem/AmountItem.stories.d.ts +6 -0
  16. package/dist/components/AmountItem/AmountItem.stories.js +29 -0
  17. package/dist/components/AmountItem/index.d.ts +1 -1
  18. package/dist/components/AmountItem/index.js +1 -0
  19. package/dist/components/Avatar/Avatar.d.ts +2 -1
  20. package/dist/components/Avatar/Avatar.js +6 -0
  21. package/dist/components/Avatar/Avatar.stories.d.ts +7 -0
  22. package/dist/components/Avatar/Avatar.stories.js +18 -0
  23. package/dist/components/Avatar/AvatarGroup.d.ts +3 -2
  24. package/dist/components/Avatar/AvatarGroup.js +15 -0
  25. package/dist/components/Avatar/AvatarGroup.stories.d.ts +6 -0
  26. package/dist/components/Avatar/AvatarGroup.stories.js +21 -0
  27. package/dist/components/Avatar/index.d.ts +2 -2
  28. package/dist/components/Avatar/index.js +2 -0
  29. package/dist/components/Badge/Badge.d.ts +2 -1
  30. package/dist/components/Badge/Badge.js +10 -0
  31. package/dist/components/Badge/Badge.stories.d.ts +6 -0
  32. package/dist/components/Badge/Badge.stories.js +14 -0
  33. package/dist/components/Badge/index.d.ts +1 -1
  34. package/dist/components/Badge/index.js +1 -0
  35. package/dist/components/Button/Button.d.ts +3 -2
  36. package/dist/components/Button/Button.js +8 -0
  37. package/dist/components/Button/Button.stories.d.ts +6 -0
  38. package/dist/components/Button/Button.stories.js +9 -0
  39. package/dist/components/Button/IconButton.d.ts +2 -1
  40. package/dist/components/Button/IconButton.js +6 -0
  41. package/dist/components/Button/IconButton.stories.d.ts +6 -0
  42. package/dist/components/Button/IconButton.stories.js +13 -0
  43. package/dist/components/Button/WalletDisconnectButton.d.ts +2 -2
  44. package/dist/components/Button/WalletDisconnectButton.js +8 -0
  45. package/dist/components/Button/index.d.ts +3 -3
  46. package/dist/components/Button/index.js +3 -0
  47. package/dist/components/Card/Card.d.ts +4 -3
  48. package/dist/components/Card/Card.js +6 -0
  49. package/dist/components/Card/Card.stories.d.ts +6 -0
  50. package/dist/components/Card/Card.stories.js +10 -0
  51. package/dist/components/Card/index.d.ts +1 -1
  52. package/dist/components/Card/index.js +1 -0
  53. package/dist/components/Chip/Chip.d.ts +2 -1
  54. package/dist/components/Chip/Chip.js +6 -0
  55. package/dist/components/Chip/Chip.stories.d.ts +6 -0
  56. package/dist/components/Chip/Chip.stories.js +9 -0
  57. package/dist/components/Chip/index.d.ts +1 -1
  58. package/dist/components/Chip/index.js +1 -0
  59. package/dist/components/Copy/Copy.d.ts +1 -1
  60. package/dist/components/Copy/Copy.js +29 -0
  61. package/dist/components/Copy/index.js +1 -0
  62. package/dist/components/CounterButton/CounterButton.js +8 -0
  63. package/dist/components/CounterButton/CounterButton.stories.d.ts +10 -0
  64. package/dist/components/CounterButton/CounterButton.stories.js +41 -0
  65. package/dist/components/CounterButton/index.d.ts +1 -1
  66. package/dist/components/CounterButton/index.js +1 -0
  67. package/dist/components/Dialog/Dialog.d.ts +1 -1
  68. package/dist/components/Dialog/Dialog.js +9 -0
  69. package/dist/components/Dialog/Dialog.stories.d.ts +7 -0
  70. package/dist/components/Dialog/Dialog.stories.js +41 -0
  71. package/dist/components/Dialog/MobileDialog.d.ts +1 -1
  72. package/dist/components/Dialog/MobileDialog.js +10 -0
  73. package/dist/components/Dialog/MobileDialog.stories.d.ts +6 -0
  74. package/dist/components/Dialog/MobileDialog.stories.js +27 -0
  75. package/dist/components/Dialog/components/Backdrop.d.ts +2 -1
  76. package/dist/components/Dialog/components/Backdrop.js +4 -0
  77. package/dist/components/Dialog/components/DialogBody.d.ts +1 -1
  78. package/dist/components/Dialog/components/DialogBody.js +3 -0
  79. package/dist/components/Dialog/components/DialogFooter.d.ts +1 -1
  80. package/dist/components/Dialog/components/DialogFooter.js +3 -0
  81. package/dist/components/Dialog/components/DialogHeader.d.ts +1 -1
  82. package/dist/components/Dialog/components/DialogHeader.js +5 -0
  83. package/dist/components/Dialog/index.d.ts +6 -5
  84. package/dist/components/Dialog/index.js +6 -0
  85. package/dist/components/DisplayHash/DisplayHash.d.ts +1 -1
  86. package/dist/components/DisplayHash/DisplayHash.js +10 -0
  87. package/dist/components/DisplayHash/index.js +1 -0
  88. package/dist/components/FeeItem/FeeItem.d.ts +1 -1
  89. package/dist/components/FeeItem/FeeItem.js +6 -0
  90. package/dist/components/FeeItem/FeeItem.stories.d.ts +7 -0
  91. package/dist/components/FeeItem/FeeItem.stories.js +19 -0
  92. package/dist/components/Form/Checkbox.d.ts +2 -2
  93. package/dist/components/Form/Checkbox.js +10 -0
  94. package/dist/components/Form/Checkbox.stories.d.ts +6 -0
  95. package/dist/components/Form/Checkbox.stories.js +13 -0
  96. package/dist/components/Form/FormControl.d.ts +2 -1
  97. package/dist/components/Form/FormControl.js +6 -0
  98. package/dist/components/Form/FormControl.stories.d.ts +8 -0
  99. package/dist/components/Form/FormControl.stories.js +30 -0
  100. package/dist/components/Form/Input.d.ts +3 -2
  101. package/dist/components/Form/Input.js +8 -0
  102. package/dist/components/Form/Input.stories.d.ts +10 -0
  103. package/dist/components/Form/Input.stories.js +43 -0
  104. package/dist/components/Form/Radio.d.ts +2 -2
  105. package/dist/components/Form/Radio.js +10 -0
  106. package/dist/components/Form/Radio.stories.d.ts +6 -0
  107. package/dist/components/Form/Radio.stories.js +13 -0
  108. package/dist/components/Form/Select.d.ts +3 -2
  109. package/dist/components/Form/Select.js +39 -0
  110. package/dist/components/Form/Select.stories.d.ts +9 -0
  111. package/dist/components/Form/Select.stories.js +47 -0
  112. package/dist/components/Form/components/Toggle.d.ts +3 -2
  113. package/dist/components/Form/components/Toggle.js +22 -0
  114. package/dist/components/Form/index.d.ts +5 -5
  115. package/dist/components/Form/index.js +5 -0
  116. package/dist/components/Heading/Heading.d.ts +3 -2
  117. package/dist/components/Heading/Heading.js +9 -0
  118. package/dist/components/Heading/Heading.stories.d.ts +6 -0
  119. package/dist/components/Heading/Heading.stories.js +10 -0
  120. package/dist/components/Heading/index.d.ts +1 -1
  121. package/dist/components/Heading/index.js +1 -0
  122. package/dist/components/Icons/ThemedIcon.js +25 -0
  123. package/dist/components/Icons/common/CloseIcon.d.ts +1 -1
  124. package/dist/components/Icons/common/CloseIcon.js +7 -0
  125. package/dist/components/Icons/common/CopyIcon.d.ts +1 -1
  126. package/dist/components/Icons/common/CopyIcon.js +7 -0
  127. package/dist/components/Icons/index.d.ts +6 -6
  128. package/dist/components/Icons/index.js +18 -0
  129. package/dist/components/Icons/wallet/BitcoinPublicKeyIcon.d.ts +1 -1
  130. package/dist/components/Icons/wallet/BitcoinPublicKeyIcon.js +5 -0
  131. package/dist/components/Icons/wallet/LinkWalletIcon.d.ts +1 -1
  132. package/dist/components/Icons/wallet/LinkWalletIcon.js +5 -0
  133. package/dist/components/Icons/wallet/UsingInscriptionIcon.d.ts +1 -1
  134. package/dist/components/Icons/wallet/UsingInscriptionIcon.js +5 -0
  135. package/dist/components/List/List.d.ts +3 -2
  136. package/dist/components/List/List.js +16 -0
  137. package/dist/components/List/List.stories.d.ts +11 -0
  138. package/dist/components/List/List.stories.js +69 -0
  139. package/dist/components/List/components/ListItem.js +6 -0
  140. package/dist/components/List/index.d.ts +2 -2
  141. package/dist/components/List/index.js +2 -0
  142. package/dist/components/ListLegacy/ListLegacy.d.ts +3 -2
  143. package/dist/components/ListLegacy/ListLegacy.js +16 -0
  144. package/dist/components/ListLegacy/ListLegacy.stories.d.ts +11 -0
  145. package/dist/components/ListLegacy/ListLegacy.stories.js +71 -0
  146. package/dist/components/ListLegacy/components/ListItemLegacy.js +6 -0
  147. package/dist/components/ListLegacy/index.d.ts +2 -2
  148. package/dist/components/ListLegacy/index.js +2 -0
  149. package/dist/components/Loader/Loader.d.ts +1 -0
  150. package/dist/components/Loader/Loader.js +6 -0
  151. package/dist/components/Loader/Loader.stories.d.ts +6 -0
  152. package/dist/components/Loader/Loader.stories.js +11 -0
  153. package/dist/components/Loader/index.d.ts +1 -1
  154. package/dist/components/Loader/index.js +1 -0
  155. package/dist/components/Menu/Menu.d.ts +2 -2
  156. package/dist/components/Menu/Menu.js +29 -0
  157. package/dist/components/Menu/Menu.stories.d.ts +6 -0
  158. package/dist/components/Menu/Menu.stories.js +38 -0
  159. package/dist/components/Menu/MenuContext.d.ts +1 -1
  160. package/dist/components/Menu/MenuContext.js +9 -0
  161. package/dist/components/Menu/MenuDrawer.d.ts +1 -1
  162. package/dist/components/Menu/MenuDrawer.js +22 -0
  163. package/dist/components/Menu/MenuItem.d.ts +1 -1
  164. package/dist/components/Menu/MenuItem.js +20 -0
  165. package/dist/components/Menu/SubMenu.d.ts +1 -1
  166. package/dist/components/Menu/SubMenu.js +12 -0
  167. package/dist/components/Menu/SubMenuItem.d.ts +1 -1
  168. package/dist/components/Menu/SubMenuItem.js +6 -0
  169. package/dist/components/Menu/index.d.ts +6 -6
  170. package/dist/components/Menu/index.js +6 -0
  171. package/dist/components/Popover/Popover.d.ts +3 -2
  172. package/dist/components/Popover/Popover.js +16 -0
  173. package/dist/components/Popover/Popover.stories.d.ts +6 -0
  174. package/dist/components/Popover/Popover.stories.js +25 -0
  175. package/dist/components/Popover/index.d.ts +1 -1
  176. package/dist/components/Popover/index.js +1 -0
  177. package/dist/components/Portal/Portal.d.ts +2 -2
  178. package/dist/components/Portal/Portal.js +45 -0
  179. package/dist/components/Portal/index.d.ts +1 -1
  180. package/dist/components/Portal/index.js +1 -0
  181. package/dist/components/Spacer/Spacer.d.ts +1 -1
  182. package/dist/components/Spacer/Spacer.js +9 -0
  183. package/dist/components/Spacer/index.js +1 -0
  184. package/dist/components/SubSection/SubSection.d.ts +1 -1
  185. package/dist/components/SubSection/SubSection.js +3 -0
  186. package/dist/components/SubSection/SubSection.stories.d.ts +6 -0
  187. package/dist/components/SubSection/SubSection.stories.js +13 -0
  188. package/dist/components/SubSection/index.d.ts +1 -1
  189. package/dist/components/SubSection/index.js +1 -0
  190. package/dist/components/Table/Table.d.ts +2 -1
  191. package/dist/components/Table/Table.js +37 -0
  192. package/dist/components/Table/Table.stories.d.ts +7 -0
  193. package/dist/components/Table/Table.stories.js +131 -0
  194. package/dist/components/Table/components/Cell.d.ts +1 -1
  195. package/dist/components/Table/components/Cell.js +6 -0
  196. package/dist/components/Table/components/Column.d.ts +1 -1
  197. package/dist/components/Table/components/Column.js +17 -0
  198. package/dist/components/Table/components/Row.d.ts +1 -1
  199. package/dist/components/Table/components/Row.js +6 -0
  200. package/dist/components/Table/index.d.ts +4 -4
  201. package/dist/components/Table/index.js +4 -0
  202. package/dist/components/Table/types/index.d.ts +1 -1
  203. package/dist/components/Table/types/index.js +1 -0
  204. package/dist/components/Text/Text.d.ts +3 -2
  205. package/dist/components/Text/Text.js +11 -0
  206. package/dist/components/Text/Text.stories.d.ts +6 -0
  207. package/dist/components/Text/Text.stories.js +10 -0
  208. package/dist/components/Text/index.d.ts +1 -1
  209. package/dist/components/Text/index.js +1 -0
  210. package/dist/components/Toggle/Toggle.d.ts +1 -0
  211. package/dist/components/Toggle/Toggle.js +12 -0
  212. package/dist/components/Toggle/Toggle.stories.d.ts +6 -0
  213. package/dist/components/Toggle/Toggle.stories.js +14 -0
  214. package/dist/components/Toggle/index.d.ts +1 -1
  215. package/dist/components/Toggle/index.js +1 -0
  216. package/dist/components/Warning/Warning.d.ts +2 -1
  217. package/dist/components/Warning/Warning.js +6 -0
  218. package/dist/components/Warning/Warning.stories.d.ts +9 -0
  219. package/dist/components/Warning/Warning.stories.js +26 -0
  220. package/dist/components/Warning/index.d.ts +1 -1
  221. package/dist/components/Warning/index.js +1 -0
  222. package/dist/components/index.js +3 -0
  223. package/dist/context/Dialog.context.d.ts +2 -2
  224. package/dist/context/Dialog.context.js +33 -0
  225. package/dist/context/Table.context.d.ts +2 -2
  226. package/dist/context/Table.context.js +8 -0
  227. package/dist/elements/FinalityProviderItem/FinalityProviderItem.js +30 -0
  228. package/dist/elements/FinalityProviderItem/FinalityProviderItem.stories.d.ts +12 -0
  229. package/dist/elements/FinalityProviderItem/FinalityProviderItem.stories.js +97 -0
  230. package/dist/elements/FinalityProviderItem/index.d.ts +1 -1
  231. package/dist/elements/FinalityProviderItem/index.js +1 -0
  232. package/dist/elements/FinalityProviderLogo/FinalityProviderLogo.js +24 -0
  233. package/dist/elements/FinalityProviderLogo/FinalityProviderLogo.stories.d.ts +13 -0
  234. package/dist/elements/FinalityProviderLogo/FinalityProviderLogo.stories.js +61 -0
  235. package/dist/elements/FinalityProviderLogo/index.d.ts +1 -1
  236. package/dist/elements/FinalityProviderLogo/index.js +1 -0
  237. package/dist/elements/Icons/ChevronRightIcon.d.ts +1 -1
  238. package/dist/elements/Icons/ChevronRightIcon.js +2 -0
  239. package/dist/elements/Icons/SettingsIcon.d.ts +1 -1
  240. package/dist/elements/Icons/SettingsIcon.js +2 -0
  241. package/dist/elements/Icons/index.js +2 -0
  242. package/dist/elements/ProvidersList/ProvidersList.js +9 -0
  243. package/dist/elements/ProvidersList/ProvidersList.stories.d.ts +10 -0
  244. package/dist/elements/ProvidersList/ProvidersList.stories.js +139 -0
  245. package/dist/elements/ProvidersList/index.d.ts +1 -1
  246. package/dist/elements/ProvidersList/index.js +1 -0
  247. package/dist/elements/Table/Table.d.ts +1 -1
  248. package/dist/elements/Table/Table.js +14 -0
  249. package/dist/elements/Table/Table.stories.d.ts +8 -0
  250. package/dist/elements/Table/Table.stories.js +50 -0
  251. package/dist/elements/Table/index.d.ts +1 -1
  252. package/dist/elements/Table/index.js +1 -0
  253. package/dist/hooks/index.js +9 -0
  254. package/dist/hooks/useClickOutside.js +17 -0
  255. package/dist/hooks/useControlledState.js +13 -0
  256. package/dist/hooks/useCopy.js +48 -0
  257. package/dist/hooks/useIsMobile.js +33 -0
  258. package/dist/hooks/useMemoizedArray.js +22 -0
  259. package/dist/hooks/useModalManager.js +28 -0
  260. package/dist/hooks/useResizeObserver.js +21 -0
  261. package/dist/hooks/useTableScroll.d.ts +1 -1
  262. package/dist/hooks/useTableScroll.js +22 -0
  263. package/dist/hooks/useTableSort.d.ts +1 -1
  264. package/dist/hooks/useTableSort.js +46 -0
  265. package/dist/index.cjs.js +1 -1
  266. package/dist/index.cjs.js.map +1 -1
  267. package/dist/index.d.ts +45 -44
  268. package/dist/index.es.js +900 -887
  269. package/dist/index.es.js.map +1 -1
  270. package/dist/index.js +45 -0
  271. package/dist/tsconfig.lib.tsbuildinfo +1 -0
  272. package/dist/utils/constants.js +3 -0
  273. package/dist/utils/css.js +6 -0
  274. package/dist/utils/helpers.js +71 -0
  275. package/dist/utils/trim.js +14 -0
  276. package/dist/widgets/form/CheckboxField/CheckboxField.d.ts +1 -1
  277. package/dist/widgets/form/CheckboxField/CheckboxField.js +7 -0
  278. package/dist/widgets/form/CheckboxField/CheckboxField.stories.d.ts +6 -0
  279. package/dist/widgets/form/CheckboxField/CheckboxField.stories.js +17 -0
  280. package/dist/widgets/form/CheckboxField/index.d.ts +1 -1
  281. package/dist/widgets/form/CheckboxField/index.js +1 -0
  282. package/dist/widgets/form/Form/Form.d.ts +3 -3
  283. package/dist/widgets/form/Form/Form.js +20 -0
  284. package/dist/widgets/form/Form/Form.stories.d.ts +6 -0
  285. package/dist/widgets/form/Form/Form.stories.js +27 -0
  286. package/dist/widgets/form/Form/index.d.ts +1 -1
  287. package/dist/widgets/form/Form/index.js +1 -0
  288. package/dist/widgets/form/HiddenField/HiddenField.d.ts +1 -1
  289. package/dist/widgets/form/HiddenField/HiddenField.js +13 -0
  290. package/dist/widgets/form/HiddenField/HiddenField.stories.d.ts +6 -0
  291. package/dist/widgets/form/HiddenField/HiddenField.stories.js +17 -0
  292. package/dist/widgets/form/HiddenField/index.d.ts +1 -1
  293. package/dist/widgets/form/HiddenField/index.js +1 -0
  294. package/dist/widgets/form/NumberField/NumberField.d.ts +2 -2
  295. package/dist/widgets/form/NumberField/NumberField.js +15 -0
  296. package/dist/widgets/form/NumberField/NumberField.stories.d.ts +6 -0
  297. package/dist/widgets/form/NumberField/NumberField.stories.js +31 -0
  298. package/dist/widgets/form/NumberField/index.d.ts +1 -1
  299. package/dist/widgets/form/NumberField/index.js +1 -0
  300. package/dist/widgets/form/RadioField/RadioField.d.ts +1 -1
  301. package/dist/widgets/form/RadioField/RadioField.js +7 -0
  302. package/dist/widgets/form/RadioField/RadioField.stories.d.ts +6 -0
  303. package/dist/widgets/form/RadioField/RadioField.stories.js +14 -0
  304. package/dist/widgets/form/RadioField/index.d.ts +1 -1
  305. package/dist/widgets/form/RadioField/index.js +1 -0
  306. package/dist/widgets/form/SelectField/SelectField.d.ts +3 -3
  307. package/dist/widgets/form/SelectField/SelectField.js +13 -0
  308. package/dist/widgets/form/SelectField/SelectField.stories.d.ts +6 -0
  309. package/dist/widgets/form/SelectField/SelectField.stories.js +33 -0
  310. package/dist/widgets/form/SelectField/index.d.ts +1 -1
  311. package/dist/widgets/form/SelectField/index.js +1 -0
  312. package/dist/widgets/form/TextField/TextField.d.ts +2 -2
  313. package/dist/widgets/form/TextField/TextField.js +9 -0
  314. package/dist/widgets/form/TextField/TextField.stories.d.ts +6 -0
  315. package/dist/widgets/form/TextField/TextField.stories.js +28 -0
  316. package/dist/widgets/form/TextField/index.d.ts +1 -1
  317. package/dist/widgets/form/TextField/index.js +1 -0
  318. package/dist/widgets/form/hooks.d.ts +3 -3
  319. package/dist/widgets/form/hooks.js +29 -0
  320. package/dist/widgets/form/types.js +1 -0
  321. package/dist/widgets/sections/AmountSubsection/AmountSubsection.js +29 -0
  322. package/dist/widgets/sections/AmountSubsection/AmountSubsection.stories.d.ts +6 -0
  323. package/dist/widgets/sections/AmountSubsection/AmountSubsection.stories.js +35 -0
  324. package/dist/widgets/sections/AmountSubsection/index.d.ts +1 -1
  325. package/dist/widgets/sections/AmountSubsection/index.js +1 -0
  326. package/dist/widgets/sections/FeesSection/BBNFeeAmount.js +7 -0
  327. package/dist/widgets/sections/FeesSection/BTCFeeAmount.js +19 -0
  328. package/dist/widgets/sections/FeesSection/BTCFeeRate.js +7 -0
  329. package/dist/widgets/sections/FeesSection/FeesSection.js +10 -0
  330. package/dist/widgets/sections/FeesSection/FeesSection.stories.d.ts +6 -0
  331. package/dist/widgets/sections/FeesSection/FeesSection.stories.js +14 -0
  332. package/dist/widgets/sections/FeesSection/Total.js +20 -0
  333. package/dist/widgets/sections/FeesSection/index.d.ts +6 -6
  334. package/dist/widgets/sections/FeesSection/index.js +6 -0
  335. package/dist/widgets/sections/FinalityProviderSubsection/FinalityProviderSubsection.d.ts +1 -1
  336. package/dist/widgets/sections/FinalityProviderSubsection/FinalityProviderSubsection.js +9 -0
  337. package/dist/widgets/sections/FinalityProviderSubsection/FinalityProviderSubsection.stories.d.ts +13 -0
  338. package/dist/widgets/sections/FinalityProviderSubsection/FinalityProviderSubsection.stories.js +191 -0
  339. package/dist/widgets/sections/FinalityProviderSubsection/index.d.ts +1 -1
  340. package/dist/widgets/sections/FinalityProviderSubsection/index.js +1 -0
  341. package/dist/widgets/sections/PreviewModal/PreviewModal.d.ts +1 -1
  342. package/dist/widgets/sections/PreviewModal/PreviewModal.js +37 -0
  343. package/dist/widgets/sections/PreviewModal/PreviewModal.stories.d.ts +6 -0
  344. package/dist/widgets/sections/PreviewModal/PreviewModal.stories.js +47 -0
  345. package/dist/widgets/sections/PreviewModal/index.d.ts +1 -1
  346. package/dist/widgets/sections/PreviewModal/index.js +1 -0
  347. package/dist/widgets/sections/RewardsPreviewModal/RewardsPreviewModal.d.ts +1 -1
  348. package/dist/widgets/sections/RewardsPreviewModal/RewardsPreviewModal.js +16 -0
  349. package/dist/widgets/sections/RewardsPreviewModal/RewardsPreviewModal.stories.d.ts +7 -0
  350. package/dist/widgets/sections/RewardsPreviewModal/RewardsPreviewModal.stories.js +60 -0
  351. package/dist/widgets/sections/RewardsSubsection/RewardsSubsection.js +13 -0
  352. package/dist/widgets/sections/RewardsSubsection/RewardsSubsection.stories.d.ts +7 -0
  353. package/dist/widgets/sections/RewardsSubsection/RewardsSubsection.stories.js +60 -0
  354. package/dist/widgets/sections/RewardsSubsection/index.d.ts +1 -1
  355. package/dist/widgets/sections/RewardsSubsection/index.js +1 -0
  356. package/dist/widgets/sections/SettingMenu/SettingMenu.d.ts +3 -3
  357. package/dist/widgets/sections/SettingMenu/SettingMenu.js +17 -0
  358. package/dist/widgets/sections/SettingMenu/SettingMenu.stories.d.ts +5 -0
  359. package/dist/widgets/sections/SettingMenu/SettingMenu.stories.js +35 -0
  360. package/dist/widgets/sections/SettingMenu/components/SettingMenuCustomContent.d.ts +1 -1
  361. package/dist/widgets/sections/SettingMenu/components/SettingMenuCustomContent.js +2 -0
  362. package/dist/widgets/sections/SettingMenu/components/SettingMenuDescription.d.ts +1 -1
  363. package/dist/widgets/sections/SettingMenu/components/SettingMenuDescription.js +4 -0
  364. package/dist/widgets/sections/SettingMenu/components/SettingMenuGroup.d.ts +1 -1
  365. package/dist/widgets/sections/SettingMenu/components/SettingMenuGroup.js +15 -0
  366. package/dist/widgets/sections/SettingMenu/components/SettingMenuItem.d.ts +1 -1
  367. package/dist/widgets/sections/SettingMenu/components/SettingMenuItem.js +13 -0
  368. package/dist/widgets/sections/SettingMenu/components/SettingMenuSubMenu.d.ts +1 -1
  369. package/dist/widgets/sections/SettingMenu/components/SettingMenuSubMenu.js +14 -0
  370. package/dist/widgets/sections/SettingMenu/components/SettingMenuTitle.d.ts +1 -1
  371. package/dist/widgets/sections/SettingMenu/components/SettingMenuTitle.js +4 -0
  372. package/dist/widgets/sections/SettingMenu/components/index.d.ts +12 -12
  373. package/dist/widgets/sections/SettingMenu/components/index.js +6 -0
  374. package/dist/widgets/sections/SettingMenu/index.d.ts +14 -14
  375. package/dist/widgets/sections/SettingMenu/index.js +7 -0
  376. package/dist/widgets/sections/TableElement/TableElement.d.ts +1 -1
  377. package/dist/widgets/sections/TableElement/TableElement.js +6 -0
  378. package/dist/widgets/sections/TableElement/TableElement.stories.d.ts +9 -0
  379. package/dist/widgets/sections/TableElement/TableElement.stories.js +54 -0
  380. package/dist/widgets/sections/TableElement/index.d.ts +1 -1
  381. package/dist/widgets/sections/TableElement/index.js +1 -0
  382. package/dist/widgets/sections/WalletMenu/WalletMenu.d.ts +1 -1
  383. package/dist/widgets/sections/WalletMenu/WalletMenu.js +22 -0
  384. package/dist/widgets/sections/WalletMenu/WalletMenu.stories.d.ts +6 -0
  385. package/dist/widgets/sections/WalletMenu/WalletMenu.stories.js +35 -0
  386. package/dist/widgets/sections/WalletMenu/components/WalletInfoCard.d.ts +1 -1
  387. package/dist/widgets/sections/WalletMenu/components/WalletInfoCard.js +9 -0
  388. package/dist/widgets/sections/WalletMenu/components/WalletInfoSection.d.ts +1 -1
  389. package/dist/widgets/sections/WalletMenu/components/WalletInfoSection.js +8 -0
  390. package/dist/widgets/sections/WalletMenu/components/WalletSettingItem.d.ts +1 -1
  391. package/dist/widgets/sections/WalletMenu/components/WalletSettingItem.js +7 -0
  392. package/dist/widgets/sections/WalletMenu/components/WalletToggle.d.ts +1 -1
  393. package/dist/widgets/sections/WalletMenu/components/WalletToggle.js +12 -0
  394. package/dist/widgets/sections/WalletMenu/components/index.js +4 -0
  395. package/dist/widgets/sections/WalletMenu/index.js +5 -0
  396. package/package.json +4 -10
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect } from "react";
3
+ import { FormProvider, useForm, } from "react-hook-form";
4
+ import { yupResolver } from "@hookform/resolvers/yup";
5
+ import { twJoin } from "tailwind-merge";
6
+ export function Form({ className, name, children, mode = "onBlur", reValidateMode = "onBlur", defaultValues, schema, formProps, onSubmit = () => null, onChange, }) {
7
+ const methods = useForm({
8
+ mode,
9
+ reValidateMode,
10
+ defaultValues,
11
+ resolver: schema ? yupResolver(schema) : undefined,
12
+ });
13
+ useEffect(() => {
14
+ if (!onChange)
15
+ return;
16
+ const { unsubscribe } = methods.watch(onChange);
17
+ return unsubscribe;
18
+ }, [onChange, methods.watch]);
19
+ return (_jsx(FormProvider, { ...methods, children: _jsx("form", { className: twJoin("bbn-form", className), name: name, onSubmit: methods.handleSubmit(onSubmit), ...formProps, children: children }) }));
20
+ }
@@ -0,0 +1,6 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { Form } from "./Form";
3
+ declare const meta: Meta<typeof Form>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof meta>;
6
+ export declare const Default: Story;
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as yup from "yup";
3
+ import { Form } from "./Form";
4
+ import { useField } from "@/widgets/form/hooks";
5
+ import { Input, FormControl } from "@/components/Form";
6
+ const meta = {
7
+ component: Form,
8
+ tags: ["autodocs"],
9
+ };
10
+ export default meta;
11
+ const Field = () => {
12
+ const { error, invalid, ...inputProps } = useField({ name: "test", autoFocus: true, defaultValue: "test" });
13
+ return (_jsx(FormControl, { label: "Text field", state: invalid ? "error" : "default", hint: error, children: _jsx(Input, { ...inputProps, state: invalid ? "error" : "default" }) }));
14
+ };
15
+ const schema = yup
16
+ .object()
17
+ .shape({
18
+ test: yup.string().required(),
19
+ })
20
+ .required();
21
+ export const Default = {
22
+ args: {
23
+ onChange: console.log,
24
+ schema,
25
+ },
26
+ render: (props) => (_jsx(Form, { ...props, children: _jsx(Field, {}) })),
27
+ };
@@ -1 +1 @@
1
- export * from './Form';
1
+ export * from "./Form";
@@ -0,0 +1 @@
1
+ export * from "./Form";
@@ -1,4 +1,4 @@
1
- import { FieldProps } from '../types';
1
+ import { FieldProps } from "@/widgets/form/types";
2
2
  export interface HiddenFieldProps extends FieldProps {
3
3
  displayError?: boolean;
4
4
  }
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { FormControl } from "@/components/Form";
3
+ import { useField } from "@/widgets/form/hooks";
4
+ export function HiddenField({ displayError = false, ...props }) {
5
+ const { error, value, onChange, onBlur, disabled, name, ref } = useField(props);
6
+ const input = (_jsx("input", { ref: ref, type: "hidden", name: name, disabled: disabled, value: value, onChange: onChange, onBlur: onBlur }));
7
+ if (displayError) {
8
+ const fieldState = displayError ? "error" : "default";
9
+ const fieldHint = displayError ? error : "";
10
+ return (_jsx(FormControl, { hint: fieldHint, state: fieldState, children: input }));
11
+ }
12
+ return input;
13
+ }
@@ -0,0 +1,6 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { HiddenField } from "./HiddenField";
3
+ declare const meta: Meta<typeof HiddenField>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof meta>;
6
+ export declare const Default: Story;
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Form } from "@/widgets/form/Form";
3
+ import { HiddenField } from "./HiddenField";
4
+ const meta = {
5
+ component: HiddenField,
6
+ tags: ["autodocs"],
7
+ };
8
+ export default meta;
9
+ export const Default = {
10
+ args: {
11
+ name: "hidden_field",
12
+ defaultValue: "test",
13
+ },
14
+ decorators: [
15
+ (Story) => (_jsx(Form, { onChange: console.log, children: _jsx(Story, {}) })),
16
+ ],
17
+ };
@@ -1 +1 @@
1
- export * from './HiddenField';
1
+ export * from "./HiddenField";
@@ -0,0 +1 @@
1
+ export * from "./HiddenField";
@@ -1,5 +1,5 @@
1
- import { ReactNode } from 'react';
2
- import { FieldProps } from '../types';
1
+ import { ReactNode } from "react";
2
+ import type { FieldProps } from "@/widgets/form/types";
3
3
  export interface NumberFieldProps extends FieldProps {
4
4
  type?: "text" | "hidden" | "number" | "password" | "tel" | "url" | "email";
5
5
  suffix?: ReactNode;
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { FormControl, Input } from "@/components/Form";
3
+ import { useField } from "@/widgets/form/hooks";
4
+ const NUMBER_REG_EXP = /^-?\d*\.?\d*$/;
5
+ export function NumberField({ name, id = name, label, hint, className, controlClassName, disabled, autoFocus, defaultValue, placeholder, type, suffix, prefix, shouldUnregister, state, validateOnMount, }) {
6
+ const { ref, value = "", error, invalid, onChange, onBlur, } = useField({ name, defaultValue, autoFocus, shouldUnregister, validateOnMount });
7
+ const fieldState = invalid ? "error" : state;
8
+ const fieldHint = invalid ? error : hint;
9
+ const handleChange = (e) => {
10
+ if (NUMBER_REG_EXP.test(e.target.value)) {
11
+ onChange(e.target.value);
12
+ }
13
+ };
14
+ return (_jsx(FormControl, { label: label, className: controlClassName, state: fieldState, hint: fieldHint, children: _jsx(Input, { inputMode: "decimal", pattern: "^-?\\d*\\.?\\d*$", ref: ref, value: value, id: id, name: name, type: type, className: className, disabled: disabled, autoFocus: autoFocus, placeholder: placeholder, suffix: suffix, prefix: prefix, state: fieldState, onChange: handleChange, onBlur: onBlur }) }));
15
+ }
@@ -0,0 +1,6 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { NumberField } from "./NumberField";
3
+ declare const meta: Meta<typeof NumberField>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof NumberField>;
6
+ export declare const Default: Story;
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as yup from "yup";
3
+ import { NumberField } from "./NumberField";
4
+ import { Form } from "@/widgets/form/Form";
5
+ const meta = {
6
+ component: NumberField,
7
+ tags: ["autodocs"],
8
+ };
9
+ export default meta;
10
+ const schema = yup
11
+ .object()
12
+ .shape({
13
+ number_field: yup
14
+ .number()
15
+ .transform((value) => (Number.isNaN(value) ? null : value))
16
+ .required(),
17
+ })
18
+ .required();
19
+ export const Default = {
20
+ args: {
21
+ label: "Number Field",
22
+ name: "number_field",
23
+ placeholder: "Default input",
24
+ hint: "Some random and useless hint",
25
+ defaultValue: "",
26
+ autoFocus: true,
27
+ },
28
+ decorators: [
29
+ (Story) => (_jsx(Form, { schema: schema, onChange: console.log, children: _jsx(Story, {}) })),
30
+ ],
31
+ };
@@ -1 +1 @@
1
- export * from './NumberField';
1
+ export * from "./NumberField";
@@ -0,0 +1 @@
1
+ export * from "./NumberField";
@@ -1,4 +1,4 @@
1
- import { RadioProps } from '../../../components/Form/Radio';
1
+ import { type RadioProps } from "@/components/Form/Radio";
2
2
  export interface RadioFieldProps extends RadioProps {
3
3
  name: string;
4
4
  value: string;
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Radio } from "@/components/Form/Radio";
3
+ import { useField } from "@/widgets/form/hooks";
4
+ export function RadioField({ name, id = name, label, className, disabled, value, defaultChecked, labelClassName, orientation, }) {
5
+ const { ref, value: selectedValue, onChange, onBlur, } = useField({ name, disabled, defaultValue: defaultChecked ? value : undefined });
6
+ return (_jsx(Radio, { ref: ref, name: name, id: id, label: label, className: className, disabled: disabled, checked: selectedValue === value, value: value, labelClassName: labelClassName, orientation: orientation, inputProps: { onChange, onBlur } }));
7
+ }
@@ -0,0 +1,6 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { RadioField } from "./RadioField";
3
+ declare const meta: Meta<typeof RadioField>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof meta>;
6
+ export declare const Default: Story;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Form } from "@/widgets/form/Form";
3
+ import { RadioField } from "./RadioField";
4
+ const meta = {
5
+ component: RadioField,
6
+ tags: ["autodocs"],
7
+ };
8
+ export default meta;
9
+ export const Default = {
10
+ decorators: [
11
+ (Story) => (_jsx(Form, { onChange: console.log, children: _jsx(Story, {}) })),
12
+ ],
13
+ render: () => (_jsxs("div", { className: "flex flex-col gap-4", children: [_jsx(RadioField, { name: "radio_filed", value: "test", label: "Test" }), _jsx(RadioField, { defaultChecked: true, name: "radio_filed", value: "test1", label: "Test 1" }), _jsx(RadioField, { name: "radio_filed", value: "test2", label: "Test 2" })] })),
14
+ };
@@ -1 +1 @@
1
- export * from './RadioField';
1
+ export * from "./RadioField";
@@ -0,0 +1 @@
1
+ export * from "./RadioField";
@@ -1,6 +1,6 @@
1
- import { ReactNode } from 'react';
2
- import { Option } from '../../../components/Form';
3
- import { FieldProps } from '../types';
1
+ import { ReactNode } from "react";
2
+ import { type Option } from "@/components/Form";
3
+ import type { FieldProps } from "@/widgets/form/types";
4
4
  export interface SelectFieldProps extends FieldProps {
5
5
  open?: boolean;
6
6
  defaultOpen?: boolean;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { FormControl, Select } from "@/components/Form";
3
+ import { useField } from "@/widgets/form/hooks";
4
+ export function SelectField({ open, defaultOpen, options, optionClassName, popoverClassName, name, id = name, label, hint, className, controlClassName, disabled, autoFocus, defaultValue, placeholder, shouldUnregister, state, validateOnMount, onOpen, onClose, renderSelectedOption, }) {
5
+ const { ref, value = "", error, invalid, onChange, onBlur, } = useField({ name, defaultValue, autoFocus, shouldUnregister, validateOnMount });
6
+ const fieldState = invalid ? "error" : state;
7
+ const fieldHint = invalid ? error : hint;
8
+ const handleClose = () => {
9
+ onBlur?.();
10
+ onClose?.();
11
+ };
12
+ return (_jsx(FormControl, { label: label, className: controlClassName, state: fieldState, hint: fieldHint, children: _jsx(Select, { open: open, defaultOpen: defaultOpen, options: options, ref: ref, value: value, id: id, name: name, className: className, disabled: disabled, placeholder: placeholder, state: fieldState, optionClassName: optionClassName, popoverClassName: popoverClassName, onSelect: onChange, onBlur: onBlur, onOpen: onOpen, onClose: handleClose, renderSelectedOption: renderSelectedOption }) }));
13
+ }
@@ -0,0 +1,6 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { SelectField } from "./SelectField";
3
+ declare const meta: Meta<typeof SelectField>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof SelectField>;
6
+ export declare const Default: Story;
@@ -0,0 +1,33 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as yup from "yup";
3
+ import { SelectField } from "./SelectField";
4
+ import { Form } from "../Form";
5
+ const meta = {
6
+ component: SelectField,
7
+ tags: ["autodocs"],
8
+ };
9
+ export default meta;
10
+ const schema = yup
11
+ .object()
12
+ .shape({
13
+ select_field: yup.string().required(),
14
+ })
15
+ .required();
16
+ export const Default = {
17
+ args: {
18
+ label: "Select Field",
19
+ name: "select_field",
20
+ placeholder: "Select value",
21
+ hint: "Some random and useless hint",
22
+ defaultValue: "pending",
23
+ options: [
24
+ { value: "", label: "None" },
25
+ { value: "active", label: "Active" },
26
+ { value: "inactive", label: "Inactive" },
27
+ { value: "pending", label: "Pending" },
28
+ ],
29
+ },
30
+ decorators: [
31
+ (Story) => (_jsx(Form, { schema: schema, onChange: console.log, children: _jsx(Story, {}) })),
32
+ ],
33
+ };
@@ -1 +1 @@
1
- export * from './SelectField';
1
+ export * from "./SelectField";
@@ -0,0 +1 @@
1
+ export * from "./SelectField";
@@ -1,5 +1,5 @@
1
- import { ReactNode } from 'react';
2
- import { FieldProps } from '../types';
1
+ import { ReactNode } from "react";
2
+ import type { FieldProps } from "@/widgets/form/types";
3
3
  export interface TextFieldProps extends FieldProps {
4
4
  type?: "text" | "hidden" | "number" | "password" | "tel" | "url" | "email";
5
5
  suffix?: ReactNode;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { FormControl, Input } from "@/components/Form";
3
+ import { useField } from "@/widgets/form/hooks";
4
+ export function TextField({ name, id = name, label, hint, className, controlClassName, disabled, autoFocus, defaultValue, placeholder, type, suffix, prefix, shouldUnregister, state, validateOnMount, }) {
5
+ const { ref, value = "", error, invalid, onChange, onBlur, } = useField({ name, defaultValue, autoFocus, shouldUnregister, validateOnMount });
6
+ const fieldState = invalid ? "error" : state;
7
+ const fieldHint = invalid ? error : hint;
8
+ return (_jsx(FormControl, { label: label, className: controlClassName, state: fieldState, hint: fieldHint, children: _jsx(Input, { ref: ref, value: value, id: id, name: name, type: type, className: className, disabled: disabled, autoFocus: autoFocus, placeholder: placeholder, suffix: suffix, prefix: prefix, state: fieldState, onChange: onChange, onBlur: onBlur }) }));
9
+ }
@@ -0,0 +1,6 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { TextField } from "./TextField";
3
+ declare const meta: Meta<typeof TextField>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof TextField>;
6
+ export declare const Default: Story;
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as yup from "yup";
3
+ import { TextField } from "./TextField";
4
+ import { Form } from "@/widgets/form/Form";
5
+ const meta = {
6
+ component: TextField,
7
+ tags: ["autodocs"],
8
+ };
9
+ export default meta;
10
+ const schema = yup
11
+ .object()
12
+ .shape({
13
+ text_field: yup.string().required(),
14
+ })
15
+ .required();
16
+ export const Default = {
17
+ args: {
18
+ label: "Text Field",
19
+ name: "text_field",
20
+ placeholder: "Default input",
21
+ hint: "Some random and useless hint",
22
+ defaultValue: "",
23
+ autoFocus: true,
24
+ },
25
+ decorators: [
26
+ (Story) => (_jsx(Form, { schema: schema, onChange: console.log, children: _jsx(Story, {}) })),
27
+ ],
28
+ };
@@ -1 +1 @@
1
- export * from './TextField';
1
+ export * from "./TextField";
@@ -0,0 +1 @@
1
+ export * from "./TextField";
@@ -1,4 +1,4 @@
1
- import { FieldError } from 'react-hook-form';
1
+ import { type FieldError } from "react-hook-form";
2
2
  interface FieldProps<V> {
3
3
  name: string;
4
4
  defaultValue?: V;
@@ -12,10 +12,10 @@ export declare function useField<V = string>({ name, defaultValue, disabled, aut
12
12
  invalid: boolean;
13
13
  error: string;
14
14
  onChange: (...event: any[]) => void;
15
- onBlur: import('react-hook-form').Noop;
15
+ onBlur: import("react-hook-form").Noop;
16
16
  disabled?: boolean;
17
17
  name: string;
18
- ref: import('react-hook-form').RefCallBack;
18
+ ref: import("react-hook-form").RefCallBack;
19
19
  };
20
20
  type FieldState = {
21
21
  invalid: boolean;
@@ -0,0 +1,29 @@
1
+ import { useEffect } from "react";
2
+ import { useController, useFormContext, useFormState } from "react-hook-form";
3
+ export function useField({ name, defaultValue, disabled = false, autoFocus = false, shouldUnregister = false, validateOnMount = true, }) {
4
+ const { setFocus, trigger } = useFormContext();
5
+ const { field, fieldState } = useController({ name, defaultValue, disabled, shouldUnregister });
6
+ const { invalid, isTouched, error } = fieldState;
7
+ useEffect(() => {
8
+ if (validateOnMount) {
9
+ trigger(name, { shouldFocus: autoFocus });
10
+ }
11
+ else if (autoFocus) {
12
+ setFocus(name);
13
+ }
14
+ }, [name, validateOnMount]);
15
+ return {
16
+ ...field,
17
+ value: field.value,
18
+ invalid: invalid && isTouched,
19
+ error: error?.message ?? "",
20
+ };
21
+ }
22
+ export function useFieldState(field) {
23
+ const { getFieldState } = useFormContext();
24
+ const formState = useFormState({ name: field });
25
+ const fieldState = Array.isArray(field)
26
+ ? field.map((fieldName) => getFieldState(fieldName, formState))
27
+ : getFieldState(field, formState);
28
+ return fieldState;
29
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,29 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { HiddenField } from "@/widgets/form/HiddenField";
3
+ import { SubSection } from "@/components/SubSection";
4
+ import { useFormContext, useWatch } from "react-hook-form";
5
+ import { AmountItem } from "../../../components/AmountItem/AmountItem";
6
+ import { calculateTokenValueInCurrency, maxDecimals } from "@/utils/helpers";
7
+ import { BTC_DECIMAL_PLACES } from "@/utils/constants";
8
+ export const AmountSubsection = ({ fieldName, currencyIcon, currencyName, displayBalance, placeholder = "Enter Amount", balanceDetails, min = "0", step = "any", autoFocus = true, }) => {
9
+ const amount = useWatch({ name: fieldName, defaultValue: "" });
10
+ const { setValue } = useFormContext();
11
+ const amountValue = parseFloat(amount || "0");
12
+ const amountUsd = calculateTokenValueInCurrency(amountValue, balanceDetails?.price ?? 0, {
13
+ zeroDisplay: "$0.00",
14
+ });
15
+ const handleInputChange = (e) => {
16
+ setValue(fieldName, e.target.value, {
17
+ shouldValidate: true,
18
+ shouldDirty: true,
19
+ shouldTouch: true,
20
+ });
21
+ };
22
+ const handleKeyDown = (e) => {
23
+ if (e.key === "ArrowUp" || e.key === "ArrowDown") {
24
+ e.preventDefault();
25
+ }
26
+ };
27
+ const subtitle = `Stakable: ${maxDecimals(Number(balanceDetails?.balance), balanceDetails?.decimals ?? BTC_DECIMAL_PLACES)} ${balanceDetails?.symbol}`;
28
+ return (_jsxs(_Fragment, { children: [_jsx(HiddenField, { name: fieldName, defaultValue: "" }), _jsx(SubSection, { className: "flex w-full flex-col content-center justify-between gap-4", children: _jsx(AmountItem, { amount: amount, currencyIcon: currencyIcon, currencyName: currencyName, placeholder: placeholder, displayBalance: displayBalance, balanceDetails: balanceDetails, min: min, step: step, autoFocus: autoFocus, onChange: handleInputChange, onKeyDown: handleKeyDown, amountUsd: amountUsd, subtitle: subtitle }) })] }));
29
+ };
@@ -0,0 +1,6 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { AmountSubsection } from "./AmountSubsection";
3
+ declare const meta: Meta<typeof AmountSubsection>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof meta>;
6
+ export declare const Default: Story;
@@ -0,0 +1,35 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as yup from "yup";
3
+ import { AmountSubsection } from "./AmountSubsection";
4
+ import { Form } from "@/widgets/form/Form";
5
+ const meta = {
6
+ component: AmountSubsection,
7
+ tags: ["autodocs"],
8
+ };
9
+ export default meta;
10
+ // Define a simple validation schema for the field used in this story
11
+ const schema = yup
12
+ .object()
13
+ .shape({
14
+ amount: yup.number().required().positive(),
15
+ })
16
+ .required();
17
+ export const Default = {
18
+ args: {
19
+ fieldName: "amount",
20
+ currencyIcon: "https://placehold.co/40x40",
21
+ currencyName: "BBN",
22
+ placeholder: "Enter Amount",
23
+ displayBalance: true,
24
+ balanceDetails: {
25
+ balance: 1234.56789,
26
+ symbol: "BBN",
27
+ price: 0.25,
28
+ displayUSD: true,
29
+ decimals: 8,
30
+ },
31
+ },
32
+ decorators: [
33
+ (Story) => (_jsx(Form, { onChange: console.log, schema: schema, children: _jsx(Story, {}) })),
34
+ ],
35
+ };
@@ -1 +1 @@
1
- export { AmountSubsection } from './AmountSubsection';
1
+ export { AmountSubsection } from "./AmountSubsection";
@@ -0,0 +1 @@
1
+ export { AmountSubsection } from "./AmountSubsection";
@@ -0,0 +1,7 @@
1
+ import { jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { FeeItem } from "../../../components/FeeItem/FeeItem";
3
+ import { BBN_DECIMAL_PLACES } from "../../../utils/constants";
4
+ export function BBNFeeAmount({ amount, coinSymbol, hint, title, className, decimals = BBN_DECIMAL_PLACES }) {
5
+ const formattedAmount = typeof amount === "number" ? amount.toFixed(decimals) : amount;
6
+ return (_jsxs(FeeItem, { title: title ?? `${coinSymbol} Network Fee`, hint: hint, className: className, children: [formattedAmount, " ", coinSymbol] }));
7
+ }
@@ -0,0 +1,19 @@
1
+ import { jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { FeeItem } from "../../../components/FeeItem/FeeItem";
3
+ import { BTC_DECIMAL_PLACES } from "../../../utils/constants";
4
+ export function BTCFeeAmount({ amount, coinSymbol, hint, title, className, decimals = BTC_DECIMAL_PLACES }) {
5
+ let formattedAmount;
6
+ if (typeof amount === "number") {
7
+ if (amount === 0) {
8
+ formattedAmount = "0";
9
+ }
10
+ else {
11
+ const str = amount.toFixed(decimals);
12
+ formattedAmount = str.replace(/0+$/, "").replace(/\.$/, "");
13
+ }
14
+ }
15
+ else {
16
+ formattedAmount = amount;
17
+ }
18
+ return (_jsxs(FeeItem, { title: title ?? `${coinSymbol} Network Fee`, hint: hint, className: className, children: [formattedAmount, " ", coinSymbol] }));
19
+ }
@@ -0,0 +1,7 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ import { FeeItem } from "../../../components/FeeItem/FeeItem";
3
+ import { Button } from "../../../components/Button";
4
+ import { FaPen } from "react-icons/fa6";
5
+ export function BTCFeeRate({ value, onEdit, title = "Network Fee Rate", className }) {
6
+ return (_jsxs(FeeItem, { title: title, className: className, children: [_jsxs("span", { children: [value, " sats/vB"] }), onEdit && (_jsx(Button, { size: "small", variant: "outlined", className: "h-6 w-6 pl-1 text-secondary-strokeDark", onClick: onEdit, children: _jsx(FaPen, { size: 16, className: "text-secondary-strokeDark" }) }))] }));
7
+ }
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { twMerge } from "tailwind-merge";
3
+ import { SubSection } from "../../../components/SubSection";
4
+ import { BTCFeeRate } from "./BTCFeeRate";
5
+ import { BTCFeeAmount } from "./BTCFeeAmount";
6
+ import { BBNFeeAmount } from "./BBNFeeAmount";
7
+ import { Total } from "./Total";
8
+ export function FeesSection({ className, feeRate, onFeeRateEdit, feeAmount, coinSymbol, feeAmountHint, total, totalHint, bbnFeeAmount, bbnCoinSymbol, bbnFeeAmountHint, bbnFeeDecimals, }) {
9
+ return (_jsx(SubSection, { className: twMerge("flex w-full flex-col content-center justify-between gap-4", className), children: _jsxs("div", { className: "flex flex-col gap-6 p-4", children: [_jsx(BTCFeeRate, { value: feeRate, onEdit: onFeeRateEdit }), _jsx(BTCFeeAmount, { amount: feeAmount, coinSymbol: coinSymbol, hint: feeAmountHint }), bbnFeeAmount !== undefined && bbnCoinSymbol ? (_jsx(BBNFeeAmount, { amount: bbnFeeAmount, coinSymbol: bbnCoinSymbol, hint: bbnFeeAmountHint, decimals: bbnFeeDecimals })) : null, _jsx("div", { className: "divider my-4" }), _jsx(Total, { total: total, coinSymbol: coinSymbol, hint: totalHint })] }) }));
10
+ }
@@ -0,0 +1,6 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { FeesSection } from "./FeesSection";
3
+ declare const meta: Meta<typeof FeesSection>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof meta>;
6
+ export declare const Default: Story;
@@ -0,0 +1,14 @@
1
+ import { FeesSection } from "./FeesSection";
2
+ const meta = {
3
+ component: FeesSection,
4
+ tags: ["autodocs"],
5
+ };
6
+ export default meta;
7
+ export const Default = {
8
+ args: {
9
+ feeRate: 5,
10
+ feeAmount: "0.0001",
11
+ coinSymbol: "BTC",
12
+ total: "0.0001",
13
+ },
14
+ };
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Text } from "../../../components/Text";
3
+ import { twMerge } from "tailwind-merge";
4
+ import { BTC_DECIMAL_PLACES } from "../../../utils/constants";
5
+ export function Total({ total, coinSymbol, hint, title = "Total", className, decimals = BTC_DECIMAL_PLACES }) {
6
+ let formattedTotal;
7
+ if (typeof total === "number") {
8
+ if (total === 0) {
9
+ formattedTotal = "0";
10
+ }
11
+ else {
12
+ const str = total.toFixed(decimals);
13
+ formattedTotal = str.replace(/0+$/, "").replace(/\.$/, "");
14
+ }
15
+ }
16
+ else {
17
+ formattedTotal = total;
18
+ }
19
+ return (_jsxs("div", { className: twMerge("flex flex-row items-start justify-between text-accent-primary", className), children: [_jsx(Text, { variant: "body1", className: "font-bold", children: title }), _jsxs("div", { className: "flex flex-col items-end justify-center", children: [_jsxs(Text, { variant: "body1", className: "font-bold", children: [formattedTotal, " ", coinSymbol] }), hint && (_jsx(Text, { variant: "body1", className: "text-sm text-accent-secondary", children: hint }))] })] }));
20
+ }