@metamask/design-system-react-native 0.23.0 → 0.25.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 (355) hide show
  1. package/CHANGELOG.md +35 -1
  2. package/dist/components/BannerBase/BannerBase.cjs +3 -12
  3. package/dist/components/BannerBase/BannerBase.cjs.map +1 -1
  4. package/dist/components/BannerBase/BannerBase.d.cts.map +1 -1
  5. package/dist/components/BannerBase/BannerBase.d.mts.map +1 -1
  6. package/dist/components/BannerBase/BannerBase.mjs +3 -12
  7. package/dist/components/BannerBase/BannerBase.mjs.map +1 -1
  8. package/dist/components/BannerBase/BannerBase.types.cjs.map +1 -1
  9. package/dist/components/BannerBase/BannerBase.types.d.cts +2 -7
  10. package/dist/components/BannerBase/BannerBase.types.d.cts.map +1 -1
  11. package/dist/components/BannerBase/BannerBase.types.d.mts +2 -7
  12. package/dist/components/BannerBase/BannerBase.types.d.mts.map +1 -1
  13. package/dist/components/BannerBase/BannerBase.types.mjs.map +1 -1
  14. package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.cjs +1 -17
  15. package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.cjs.map +1 -1
  16. package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.d.cts.map +1 -1
  17. package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.d.mts.map +1 -1
  18. package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.mjs +1 -17
  19. package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.mjs.map +1 -1
  20. package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.cjs +1 -17
  21. package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.cjs.map +1 -1
  22. package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.d.cts.map +1 -1
  23. package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.d.mts.map +1 -1
  24. package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.mjs +1 -17
  25. package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.mjs.map +1 -1
  26. package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.cjs +1 -17
  27. package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.cjs.map +1 -1
  28. package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.d.cts.map +1 -1
  29. package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.d.mts.map +1 -1
  30. package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.mjs +1 -17
  31. package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.mjs.map +1 -1
  32. package/dist/components/ButtonBase/ButtonBase.cjs +42 -28
  33. package/dist/components/ButtonBase/ButtonBase.cjs.map +1 -1
  34. package/dist/components/ButtonBase/ButtonBase.constants.cjs +31 -1
  35. package/dist/components/ButtonBase/ButtonBase.constants.cjs.map +1 -1
  36. package/dist/components/ButtonBase/ButtonBase.constants.d.cts +6 -1
  37. package/dist/components/ButtonBase/ButtonBase.constants.d.cts.map +1 -1
  38. package/dist/components/ButtonBase/ButtonBase.constants.d.mts +6 -1
  39. package/dist/components/ButtonBase/ButtonBase.constants.d.mts.map +1 -1
  40. package/dist/components/ButtonBase/ButtonBase.constants.mjs +29 -1
  41. package/dist/components/ButtonBase/ButtonBase.constants.mjs.map +1 -1
  42. package/dist/components/ButtonBase/ButtonBase.d.cts +1 -1
  43. package/dist/components/ButtonBase/ButtonBase.d.cts.map +1 -1
  44. package/dist/components/ButtonBase/ButtonBase.d.mts +1 -1
  45. package/dist/components/ButtonBase/ButtonBase.d.mts.map +1 -1
  46. package/dist/components/ButtonBase/ButtonBase.mjs +45 -31
  47. package/dist/components/ButtonBase/ButtonBase.mjs.map +1 -1
  48. package/dist/components/ButtonBase/ButtonBase.types.cjs.map +1 -1
  49. package/dist/components/ButtonBase/ButtonBase.types.d.cts +12 -0
  50. package/dist/components/ButtonBase/ButtonBase.types.d.cts.map +1 -1
  51. package/dist/components/ButtonBase/ButtonBase.types.d.mts +12 -0
  52. package/dist/components/ButtonBase/ButtonBase.types.d.mts.map +1 -1
  53. package/dist/components/ButtonBase/ButtonBase.types.mjs.map +1 -1
  54. package/dist/components/ButtonSemantic/ButtonSemantic.cjs +1 -17
  55. package/dist/components/ButtonSemantic/ButtonSemantic.cjs.map +1 -1
  56. package/dist/components/ButtonSemantic/ButtonSemantic.d.cts.map +1 -1
  57. package/dist/components/ButtonSemantic/ButtonSemantic.d.mts.map +1 -1
  58. package/dist/components/ButtonSemantic/ButtonSemantic.mjs +1 -17
  59. package/dist/components/ButtonSemantic/ButtonSemantic.mjs.map +1 -1
  60. package/dist/components/HeaderStandard/HeaderStandard.cjs +2 -26
  61. package/dist/components/HeaderStandard/HeaderStandard.cjs.map +1 -1
  62. package/dist/components/HeaderStandard/HeaderStandard.d.cts.map +1 -1
  63. package/dist/components/HeaderStandard/HeaderStandard.d.mts.map +1 -1
  64. package/dist/components/HeaderStandard/HeaderStandard.mjs +2 -26
  65. package/dist/components/HeaderStandard/HeaderStandard.mjs.map +1 -1
  66. package/dist/components/HeaderStandard/HeaderStandard.types.cjs +0 -5
  67. package/dist/components/HeaderStandard/HeaderStandard.types.cjs.map +1 -1
  68. package/dist/components/HeaderStandard/HeaderStandard.types.d.cts +2 -28
  69. package/dist/components/HeaderStandard/HeaderStandard.types.d.cts.map +1 -1
  70. package/dist/components/HeaderStandard/HeaderStandard.types.d.mts +2 -28
  71. package/dist/components/HeaderStandard/HeaderStandard.types.d.mts.map +1 -1
  72. package/dist/components/HeaderStandard/HeaderStandard.types.mjs +1 -9
  73. package/dist/components/HeaderStandard/HeaderStandard.types.mjs.map +1 -1
  74. package/dist/components/HeaderStandardAnimated/HeaderStandardAnimated.cjs +63 -0
  75. package/dist/components/HeaderStandardAnimated/HeaderStandardAnimated.cjs.map +1 -0
  76. package/dist/components/HeaderStandardAnimated/HeaderStandardAnimated.d.cts +4 -0
  77. package/dist/components/HeaderStandardAnimated/HeaderStandardAnimated.d.cts.map +1 -0
  78. package/dist/components/HeaderStandardAnimated/HeaderStandardAnimated.d.mts +4 -0
  79. package/dist/components/HeaderStandardAnimated/HeaderStandardAnimated.d.mts.map +1 -0
  80. package/dist/components/HeaderStandardAnimated/HeaderStandardAnimated.mjs +40 -0
  81. package/dist/components/HeaderStandardAnimated/HeaderStandardAnimated.mjs.map +1 -0
  82. package/dist/components/HeaderStandardAnimated/HeaderStandardAnimated.types.cjs +3 -0
  83. package/dist/components/HeaderStandardAnimated/HeaderStandardAnimated.types.cjs.map +1 -0
  84. package/dist/components/HeaderStandardAnimated/HeaderStandardAnimated.types.d.cts +31 -0
  85. package/dist/components/HeaderStandardAnimated/HeaderStandardAnimated.types.d.cts.map +1 -0
  86. package/dist/components/HeaderStandardAnimated/HeaderStandardAnimated.types.d.mts +31 -0
  87. package/dist/components/HeaderStandardAnimated/HeaderStandardAnimated.types.d.mts.map +1 -0
  88. package/dist/components/HeaderStandardAnimated/HeaderStandardAnimated.types.mjs +2 -0
  89. package/dist/components/HeaderStandardAnimated/HeaderStandardAnimated.types.mjs.map +1 -0
  90. package/dist/components/HeaderStandardAnimated/index.cjs +8 -0
  91. package/dist/components/HeaderStandardAnimated/index.cjs.map +1 -0
  92. package/dist/components/HeaderStandardAnimated/index.d.cts +4 -0
  93. package/dist/components/HeaderStandardAnimated/index.d.cts.map +1 -0
  94. package/dist/components/HeaderStandardAnimated/index.d.mts +4 -0
  95. package/dist/components/HeaderStandardAnimated/index.d.mts.map +1 -0
  96. package/dist/components/HeaderStandardAnimated/index.mjs +3 -0
  97. package/dist/components/HeaderStandardAnimated/index.mjs.map +1 -0
  98. package/dist/components/HeaderStandardAnimated/useHeaderStandardAnimated.cjs +62 -0
  99. package/dist/components/HeaderStandardAnimated/useHeaderStandardAnimated.cjs.map +1 -0
  100. package/dist/components/HeaderStandardAnimated/useHeaderStandardAnimated.d.cts +39 -0
  101. package/dist/components/HeaderStandardAnimated/useHeaderStandardAnimated.d.cts.map +1 -0
  102. package/dist/components/HeaderStandardAnimated/useHeaderStandardAnimated.d.mts +39 -0
  103. package/dist/components/HeaderStandardAnimated/useHeaderStandardAnimated.d.mts.map +1 -0
  104. package/dist/components/HeaderStandardAnimated/useHeaderStandardAnimated.mjs +57 -0
  105. package/dist/components/HeaderStandardAnimated/useHeaderStandardAnimated.mjs.map +1 -0
  106. package/dist/components/Icon/Icon.assets.cjs +12 -0
  107. package/dist/components/Icon/Icon.assets.cjs.map +1 -1
  108. package/dist/components/Icon/Icon.assets.d.cts.map +1 -1
  109. package/dist/components/Icon/Icon.assets.d.mts.map +1 -1
  110. package/dist/components/Icon/Icon.assets.mjs +12 -0
  111. package/dist/components/Icon/Icon.assets.mjs.map +1 -1
  112. package/dist/components/Icon/assets/candlestick.svg +1 -1
  113. package/dist/components/Icon/assets/group.svg +1 -0
  114. package/dist/components/Icon/assets/list-arrow.svg +1 -0
  115. package/dist/components/Icon/assets/musd-filled.svg +1 -0
  116. package/dist/components/Icon/assets/musd.svg +1 -0
  117. package/dist/components/Icon/assets/pie-chart.svg +1 -0
  118. package/dist/components/Icon/assets/predictions.svg +1 -0
  119. package/dist/components/Input/Input.cjs +25 -14
  120. package/dist/components/Input/Input.cjs.map +1 -1
  121. package/dist/components/Input/Input.d.cts.map +1 -1
  122. package/dist/components/Input/Input.d.mts.map +1 -1
  123. package/dist/components/Input/Input.mjs +25 -14
  124. package/dist/components/Input/Input.mjs.map +1 -1
  125. package/dist/components/SegmentButton/SegmentButton.cjs +86 -0
  126. package/dist/components/SegmentButton/SegmentButton.cjs.map +1 -0
  127. package/dist/components/SegmentButton/SegmentButton.d.cts +7 -0
  128. package/dist/components/SegmentButton/SegmentButton.d.cts.map +1 -0
  129. package/dist/components/SegmentButton/SegmentButton.d.mts +7 -0
  130. package/dist/components/SegmentButton/SegmentButton.d.mts.map +1 -0
  131. package/dist/components/SegmentButton/SegmentButton.mjs +66 -0
  132. package/dist/components/SegmentButton/SegmentButton.mjs.map +1 -0
  133. package/dist/components/SegmentButton/SegmentButton.types.cjs +3 -0
  134. package/dist/components/SegmentButton/SegmentButton.types.cjs.map +1 -0
  135. package/dist/components/SegmentButton/SegmentButton.types.d.cts +9 -0
  136. package/dist/components/SegmentButton/SegmentButton.types.d.cts.map +1 -0
  137. package/dist/components/SegmentButton/SegmentButton.types.d.mts +9 -0
  138. package/dist/components/SegmentButton/SegmentButton.types.d.mts.map +1 -0
  139. package/dist/components/SegmentButton/SegmentButton.types.mjs +2 -0
  140. package/dist/components/SegmentButton/SegmentButton.types.mjs.map +1 -0
  141. package/dist/components/SegmentButton/index.cjs +8 -0
  142. package/dist/components/SegmentButton/index.cjs.map +1 -0
  143. package/dist/components/SegmentButton/index.d.cts +4 -0
  144. package/dist/components/SegmentButton/index.d.cts.map +1 -0
  145. package/dist/components/SegmentButton/index.d.mts +4 -0
  146. package/dist/components/SegmentButton/index.d.mts.map +1 -0
  147. package/dist/components/SegmentButton/index.mjs +3 -0
  148. package/dist/components/SegmentButton/index.mjs.map +1 -0
  149. package/dist/components/SegmentGroup/SegmentGroup.cjs +47 -0
  150. package/dist/components/SegmentGroup/SegmentGroup.cjs.map +1 -0
  151. package/dist/components/SegmentGroup/SegmentGroup.d.cts +7 -0
  152. package/dist/components/SegmentGroup/SegmentGroup.d.cts.map +1 -0
  153. package/dist/components/SegmentGroup/SegmentGroup.d.mts +7 -0
  154. package/dist/components/SegmentGroup/SegmentGroup.d.mts.map +1 -0
  155. package/dist/components/SegmentGroup/SegmentGroup.mjs +27 -0
  156. package/dist/components/SegmentGroup/SegmentGroup.mjs.map +1 -0
  157. package/dist/components/SegmentGroup/SegmentGroup.types.cjs +3 -0
  158. package/dist/components/SegmentGroup/SegmentGroup.types.cjs.map +1 -0
  159. package/dist/components/SegmentGroup/SegmentGroup.types.d.cts +12 -0
  160. package/dist/components/SegmentGroup/SegmentGroup.types.d.cts.map +1 -0
  161. package/dist/components/SegmentGroup/SegmentGroup.types.d.mts +12 -0
  162. package/dist/components/SegmentGroup/SegmentGroup.types.d.mts.map +1 -0
  163. package/dist/components/SegmentGroup/SegmentGroup.types.mjs +2 -0
  164. package/dist/components/SegmentGroup/SegmentGroup.types.mjs.map +1 -0
  165. package/dist/components/SegmentGroup/index.cjs +6 -0
  166. package/dist/components/SegmentGroup/index.cjs.map +1 -0
  167. package/dist/components/SegmentGroup/index.d.cts +3 -0
  168. package/dist/components/SegmentGroup/index.d.cts.map +1 -0
  169. package/dist/components/SegmentGroup/index.d.mts +3 -0
  170. package/dist/components/SegmentGroup/index.d.mts.map +1 -0
  171. package/dist/components/SegmentGroup/index.mjs +2 -0
  172. package/dist/components/SegmentGroup/index.mjs.map +1 -0
  173. package/dist/components/SelectButton/SelectButton.cjs +53 -0
  174. package/dist/components/SelectButton/SelectButton.cjs.map +1 -0
  175. package/dist/components/SelectButton/SelectButton.constants.cjs +12 -0
  176. package/dist/components/SelectButton/SelectButton.constants.cjs.map +1 -0
  177. package/dist/components/SelectButton/SelectButton.constants.d.cts +4 -0
  178. package/dist/components/SelectButton/SelectButton.constants.d.cts.map +1 -0
  179. package/dist/components/SelectButton/SelectButton.constants.d.mts +4 -0
  180. package/dist/components/SelectButton/SelectButton.constants.d.mts.map +1 -0
  181. package/dist/components/SelectButton/SelectButton.constants.mjs +9 -0
  182. package/dist/components/SelectButton/SelectButton.constants.mjs.map +1 -0
  183. package/dist/components/SelectButton/SelectButton.d.cts +7 -0
  184. package/dist/components/SelectButton/SelectButton.d.cts.map +1 -0
  185. package/dist/components/SelectButton/SelectButton.d.mts +7 -0
  186. package/dist/components/SelectButton/SelectButton.d.mts.map +1 -0
  187. package/dist/components/SelectButton/SelectButton.mjs +53 -0
  188. package/dist/components/SelectButton/SelectButton.mjs.map +1 -0
  189. package/dist/components/SelectButton/SelectButton.types.cjs +3 -0
  190. package/dist/components/SelectButton/SelectButton.types.cjs.map +1 -0
  191. package/dist/components/SelectButton/SelectButton.types.d.cts +13 -0
  192. package/dist/components/SelectButton/SelectButton.types.d.cts.map +1 -0
  193. package/dist/components/SelectButton/SelectButton.types.d.mts +13 -0
  194. package/dist/components/SelectButton/SelectButton.types.d.mts.map +1 -0
  195. package/dist/components/SelectButton/SelectButton.types.mjs +2 -0
  196. package/dist/components/SelectButton/SelectButton.types.mjs.map +1 -0
  197. package/dist/components/SelectButton/index.cjs +9 -0
  198. package/dist/components/SelectButton/index.cjs.map +1 -0
  199. package/dist/components/SelectButton/index.d.cts +4 -0
  200. package/dist/components/SelectButton/index.d.cts.map +1 -0
  201. package/dist/components/SelectButton/index.d.mts +4 -0
  202. package/dist/components/SelectButton/index.d.mts.map +1 -0
  203. package/dist/components/SelectButton/index.mjs +3 -0
  204. package/dist/components/SelectButton/index.mjs.map +1 -0
  205. package/dist/components/SensitiveText/SensitiveText.cjs +4 -4
  206. package/dist/components/SensitiveText/SensitiveText.cjs.map +1 -1
  207. package/dist/components/SensitiveText/SensitiveText.d.cts.map +1 -1
  208. package/dist/components/SensitiveText/SensitiveText.d.mts.map +1 -1
  209. package/dist/components/SensitiveText/SensitiveText.mjs +1 -1
  210. package/dist/components/SensitiveText/SensitiveText.mjs.map +1 -1
  211. package/dist/components/SensitiveText/SensitiveText.types.cjs.map +1 -1
  212. package/dist/components/SensitiveText/SensitiveText.types.d.cts +6 -34
  213. package/dist/components/SensitiveText/SensitiveText.types.d.cts.map +1 -1
  214. package/dist/components/SensitiveText/SensitiveText.types.d.mts +6 -34
  215. package/dist/components/SensitiveText/SensitiveText.types.d.mts.map +1 -1
  216. package/dist/components/SensitiveText/SensitiveText.types.mjs.map +1 -1
  217. package/dist/components/SensitiveText/index.cjs +3 -3
  218. package/dist/components/SensitiveText/index.cjs.map +1 -1
  219. package/dist/components/SensitiveText/index.d.cts +1 -1
  220. package/dist/components/SensitiveText/index.d.cts.map +1 -1
  221. package/dist/components/SensitiveText/index.d.mts +1 -1
  222. package/dist/components/SensitiveText/index.d.mts.map +1 -1
  223. package/dist/components/SensitiveText/index.mjs +1 -1
  224. package/dist/components/SensitiveText/index.mjs.map +1 -1
  225. package/dist/components/TextArea/TextArea.cjs +38 -0
  226. package/dist/components/TextArea/TextArea.cjs.map +1 -0
  227. package/dist/components/TextArea/TextArea.d.cts +166 -0
  228. package/dist/components/TextArea/TextArea.d.cts.map +1 -0
  229. package/dist/components/TextArea/TextArea.d.mts +166 -0
  230. package/dist/components/TextArea/TextArea.d.mts.map +1 -0
  231. package/dist/components/TextArea/TextArea.mjs +35 -0
  232. package/dist/components/TextArea/TextArea.mjs.map +1 -0
  233. package/dist/components/TextArea/TextArea.types.cjs +3 -0
  234. package/dist/components/TextArea/TextArea.types.cjs.map +1 -0
  235. package/dist/components/TextArea/TextArea.types.d.cts +63 -0
  236. package/dist/components/TextArea/TextArea.types.d.cts.map +1 -0
  237. package/dist/components/TextArea/TextArea.types.d.mts +63 -0
  238. package/dist/components/TextArea/TextArea.types.d.mts.map +1 -0
  239. package/dist/components/TextArea/TextArea.types.mjs +2 -0
  240. package/dist/components/TextArea/TextArea.types.mjs.map +1 -0
  241. package/dist/components/TextArea/index.cjs +6 -0
  242. package/dist/components/TextArea/index.cjs.map +1 -0
  243. package/dist/components/TextArea/index.d.cts +3 -0
  244. package/dist/components/TextArea/index.d.cts.map +1 -0
  245. package/dist/components/TextArea/index.d.mts +3 -0
  246. package/dist/components/TextArea/index.d.mts.map +1 -0
  247. package/dist/components/TextArea/index.mjs +2 -0
  248. package/dist/components/TextArea/index.mjs.map +1 -0
  249. package/dist/components/TextField/TextField.cjs +1 -2
  250. package/dist/components/TextField/TextField.cjs.map +1 -1
  251. package/dist/components/TextField/TextField.d.cts +8 -2
  252. package/dist/components/TextField/TextField.d.cts.map +1 -1
  253. package/dist/components/TextField/TextField.d.mts +8 -2
  254. package/dist/components/TextField/TextField.d.mts.map +1 -1
  255. package/dist/components/TextField/TextField.mjs +1 -2
  256. package/dist/components/TextField/TextField.mjs.map +1 -1
  257. package/dist/components/TextField/TextField.types.cjs.map +1 -1
  258. package/dist/components/TextField/TextField.types.d.cts +5 -1
  259. package/dist/components/TextField/TextField.types.d.cts.map +1 -1
  260. package/dist/components/TextField/TextField.types.d.mts +5 -1
  261. package/dist/components/TextField/TextField.types.d.mts.map +1 -1
  262. package/dist/components/TextField/TextField.types.mjs.map +1 -1
  263. package/dist/components/TextFieldSearch/TextFieldSearch.d.cts +8 -2
  264. package/dist/components/TextFieldSearch/TextFieldSearch.d.cts.map +1 -1
  265. package/dist/components/TextFieldSearch/TextFieldSearch.d.mts +8 -2
  266. package/dist/components/TextFieldSearch/TextFieldSearch.d.mts.map +1 -1
  267. package/dist/components/Toast/Toast.cjs +43 -52
  268. package/dist/components/Toast/Toast.cjs.map +1 -1
  269. package/dist/components/Toast/Toast.constants.cjs +8 -1
  270. package/dist/components/Toast/Toast.constants.cjs.map +1 -1
  271. package/dist/components/Toast/Toast.constants.d.cts +5 -0
  272. package/dist/components/Toast/Toast.constants.d.cts.map +1 -1
  273. package/dist/components/Toast/Toast.constants.d.mts +5 -0
  274. package/dist/components/Toast/Toast.constants.d.mts.map +1 -1
  275. package/dist/components/Toast/Toast.constants.mjs +7 -0
  276. package/dist/components/Toast/Toast.constants.mjs.map +1 -1
  277. package/dist/components/Toast/Toast.d.cts +2 -17
  278. package/dist/components/Toast/Toast.d.cts.map +1 -1
  279. package/dist/components/Toast/Toast.d.mts +2 -17
  280. package/dist/components/Toast/Toast.d.mts.map +1 -1
  281. package/dist/components/Toast/Toast.mjs +40 -30
  282. package/dist/components/Toast/Toast.mjs.map +1 -1
  283. package/dist/components/Toast/Toast.types.cjs +9 -14
  284. package/dist/components/Toast/Toast.types.cjs.map +1 -1
  285. package/dist/components/Toast/Toast.types.d.cts +29 -91
  286. package/dist/components/Toast/Toast.types.d.cts.map +1 -1
  287. package/dist/components/Toast/Toast.types.d.mts +29 -91
  288. package/dist/components/Toast/Toast.types.d.mts.map +1 -1
  289. package/dist/components/Toast/Toast.types.mjs +8 -13
  290. package/dist/components/Toast/Toast.types.mjs.map +1 -1
  291. package/dist/components/Toast/Toaster.cjs +142 -0
  292. package/dist/components/Toast/Toaster.cjs.map +1 -0
  293. package/dist/components/Toast/Toaster.d.cts +11 -0
  294. package/dist/components/Toast/Toaster.d.cts.map +1 -0
  295. package/dist/components/Toast/Toaster.d.mts +11 -0
  296. package/dist/components/Toast/Toaster.d.mts.map +1 -0
  297. package/dist/components/Toast/Toaster.mjs +123 -0
  298. package/dist/components/Toast/Toaster.mjs.map +1 -0
  299. package/dist/components/Toast/index.cjs +5 -3
  300. package/dist/components/Toast/index.cjs.map +1 -1
  301. package/dist/components/Toast/index.d.cts +3 -2
  302. package/dist/components/Toast/index.d.cts.map +1 -1
  303. package/dist/components/Toast/index.d.mts +3 -2
  304. package/dist/components/Toast/index.d.mts.map +1 -1
  305. package/dist/components/Toast/index.mjs +2 -1
  306. package/dist/components/Toast/index.mjs.map +1 -1
  307. package/dist/components/index.cjs +21 -4
  308. package/dist/components/index.cjs.map +1 -1
  309. package/dist/components/index.d.cts +14 -2
  310. package/dist/components/index.d.cts.map +1 -1
  311. package/dist/components/index.d.mts +14 -2
  312. package/dist/components/index.d.mts.map +1 -1
  313. package/dist/components/index.mjs +7 -1
  314. package/dist/components/index.mjs.map +1 -1
  315. package/dist/components/temp-components/HeaderStandardCenterColumn/HeaderStandardCenterColumn.cjs +36 -0
  316. package/dist/components/temp-components/HeaderStandardCenterColumn/HeaderStandardCenterColumn.cjs.map +1 -0
  317. package/dist/components/temp-components/HeaderStandardCenterColumn/HeaderStandardCenterColumn.d.cts +4 -0
  318. package/dist/components/temp-components/HeaderStandardCenterColumn/HeaderStandardCenterColumn.d.cts.map +1 -0
  319. package/dist/components/temp-components/HeaderStandardCenterColumn/HeaderStandardCenterColumn.d.mts +4 -0
  320. package/dist/components/temp-components/HeaderStandardCenterColumn/HeaderStandardCenterColumn.d.mts.map +1 -0
  321. package/dist/components/temp-components/HeaderStandardCenterColumn/HeaderStandardCenterColumn.mjs +36 -0
  322. package/dist/components/temp-components/HeaderStandardCenterColumn/HeaderStandardCenterColumn.mjs.map +1 -0
  323. package/dist/components/temp-components/HeaderStandardCenterColumn/HeaderStandardCenterColumn.types.cjs +8 -0
  324. package/dist/components/temp-components/HeaderStandardCenterColumn/HeaderStandardCenterColumn.types.cjs.map +1 -0
  325. package/dist/components/temp-components/HeaderStandardCenterColumn/HeaderStandardCenterColumn.types.d.cts +39 -0
  326. package/dist/components/temp-components/HeaderStandardCenterColumn/HeaderStandardCenterColumn.types.d.cts.map +1 -0
  327. package/dist/components/temp-components/HeaderStandardCenterColumn/HeaderStandardCenterColumn.types.d.mts +39 -0
  328. package/dist/components/temp-components/HeaderStandardCenterColumn/HeaderStandardCenterColumn.types.d.mts.map +1 -0
  329. package/dist/components/temp-components/HeaderStandardCenterColumn/HeaderStandardCenterColumn.types.mjs +10 -0
  330. package/dist/components/temp-components/HeaderStandardCenterColumn/HeaderStandardCenterColumn.types.mjs.map +1 -0
  331. package/dist/components/temp-components/HeaderStandardCenterColumn/index.cjs +6 -0
  332. package/dist/components/temp-components/HeaderStandardCenterColumn/index.cjs.map +1 -0
  333. package/dist/components/temp-components/HeaderStandardCenterColumn/index.d.cts +3 -0
  334. package/dist/components/temp-components/HeaderStandardCenterColumn/index.d.cts.map +1 -0
  335. package/dist/components/temp-components/HeaderStandardCenterColumn/index.d.mts +3 -0
  336. package/dist/components/temp-components/HeaderStandardCenterColumn/index.d.mts.map +1 -0
  337. package/dist/components/temp-components/HeaderStandardCenterColumn/index.mjs +2 -0
  338. package/dist/components/temp-components/HeaderStandardCenterColumn/index.mjs.map +1 -0
  339. package/package.json +2 -2
  340. package/dist/components/SensitiveText/SensitiveText.constants.cjs +0 -14
  341. package/dist/components/SensitiveText/SensitiveText.constants.cjs.map +0 -1
  342. package/dist/components/SensitiveText/SensitiveText.constants.d.cts +0 -11
  343. package/dist/components/SensitiveText/SensitiveText.constants.d.cts.map +0 -1
  344. package/dist/components/SensitiveText/SensitiveText.constants.d.mts +0 -11
  345. package/dist/components/SensitiveText/SensitiveText.constants.d.mts.map +0 -1
  346. package/dist/components/SensitiveText/SensitiveText.constants.mjs +0 -11
  347. package/dist/components/SensitiveText/SensitiveText.constants.mjs.map +0 -1
  348. package/dist/components/Toast/ToastView.cjs +0 -174
  349. package/dist/components/Toast/ToastView.cjs.map +0 -1
  350. package/dist/components/Toast/ToastView.d.cts +0 -7
  351. package/dist/components/Toast/ToastView.d.cts.map +0 -1
  352. package/dist/components/Toast/ToastView.d.mts +0 -7
  353. package/dist/components/Toast/ToastView.d.mts.map +0 -1
  354. package/dist/components/Toast/ToastView.mjs +0 -155
  355. package/dist/components/Toast/ToastView.mjs.map +0 -1
@@ -1,117 +1,55 @@
1
- import type { AvatarIconSeverity, IconName } from "@metamask/design-system-shared";
2
- import type { ReactElement } from "react";
3
1
  import type { ViewProps } from "react-native/index.js";
4
- import type { AvatarAccountVariant } from "../AvatarAccount/index.mjs";
5
- import type { ButtonProps } from "../Button/index.mjs";
6
- import type { ButtonIconProps } from "../ButtonIcon/index.mjs";
7
- import type { ImageOrSvgSrc } from "../temp-components/ImageOrSvg/index.mjs";
2
+ import type { BannerBaseProps } from "../BannerBase/index.mjs";
3
+ import type { IconProps } from "../Icon/Icon.types.mjs";
8
4
  /**
9
- * Toast variants.
5
+ * Toast severity variants.
6
+ * `Default` renders no built-in leading icon.
10
7
  */
11
- export declare enum ToastVariant {
12
- Plain = "Plain",
13
- Account = "Account",
14
- Network = "Network",
15
- App = "App",
16
- Icon = "Icon"
17
- }
8
+ export declare const ToastSeverity: {
9
+ readonly Default: "default";
10
+ readonly Success: "success";
11
+ readonly Warning: "warning";
12
+ readonly Danger: "danger";
13
+ };
14
+ export type ToastSeverity = (typeof ToastSeverity)[keyof typeof ToastSeverity];
18
15
  /**
19
- * Options for the main text in the toast.
16
+ * Optional props for the leading severity `Icon`.
20
17
  */
21
- export type ToastLabelOptions = {
22
- label: string;
23
- isBold?: boolean;
24
- }[];
18
+ export type ToastIconProps = Omit<IconProps, 'name' | 'size' | 'color'>;
25
19
  /**
26
- * Options for the description text in the toast.
20
+ * Shared toast props aligned with BannerBase, plus optional severity/icon props.
27
21
  */
28
- export type ToastDescriptionOptions = {
29
- description: string;
22
+ export type ToastSharedProps = Omit<BannerBaseProps, 'closeButtonProps'> & {
23
+ closeButtonProps?: Omit<NonNullable<BannerBaseProps['closeButtonProps']>, 'onPress'>;
24
+ severity?: ToastSeverity;
25
+ iconAlertProps?: ToastIconProps;
30
26
  };
31
27
  /**
32
- * Options for displaying a Link in the toast.
28
+ * Toast options used by the imperative `toast(...)` API.
33
29
  */
34
- export type ToastLinkButtonOptions = {
35
- label: string;
36
- onPress: () => void;
37
- };
38
- /**
39
- * Common toast option shared between all other options.
40
- */
41
- type BaseToastVariants = {
42
- hasNoTimeout: boolean;
43
- labelOptions: ToastLabelOptions;
44
- descriptionOptions?: ToastDescriptionOptions;
45
- linkButtonOptions?: ToastLinkButtonOptions;
46
- closeButtonOptions?: ToastCloseButtonOptions;
47
- startAccessory?: ReactElement;
30
+ export type ToastOptions = ToastSharedProps & {
31
+ hasNoTimeout?: boolean;
48
32
  bottomOffset?: number;
49
33
  };
50
- export type ToastCloseButtonIconOptions = Omit<ButtonIconProps, 'variant'> & {
51
- variant: ToastCloseButtonVariant;
52
- };
53
- export type ToastCloseButtonOptions = ButtonProps | ToastCloseButtonIconOptions;
54
- export declare enum ToastCloseButtonVariant {
55
- Icon = "Icon"
56
- }
57
34
  /**
58
- * Plain toast option.
35
+ * Toaster component reference.
59
36
  */
60
- type PlainToastOption = {
61
- variant: ToastVariant.Plain;
62
- } & BaseToastVariants;
63
- /**
64
- * Account toast option.
65
- */
66
- type AccountToastOption = {
67
- variant: ToastVariant.Account;
68
- accountAddress: string;
69
- accountAvatarType: AvatarAccountVariant;
70
- } & BaseToastVariants;
71
- /**
72
- * Network toast option.
73
- */
74
- type NetworkToastOption = {
75
- variant: ToastVariant.Network;
76
- networkName?: string;
77
- networkImageSource: ImageOrSvgSrc;
78
- } & BaseToastVariants;
79
- /**
80
- * App toast option.
81
- */
82
- type AppToastOption = {
83
- variant: ToastVariant.App;
84
- appIconSource: ImageOrSvgSrc;
85
- } & BaseToastVariants;
86
- type IconToastOption = {
87
- variant: ToastVariant.Icon;
88
- iconName: IconName;
89
- severity?: AvatarIconSeverity;
90
- } & BaseToastVariants;
91
- /**
92
- * Different toast options combined in a union type.
93
- */
94
- export type ToastOptions = PlainToastOption | AccountToastOption | NetworkToastOption | AppToastOption | IconToastOption;
95
- /**
96
- * Toast component reference.
97
- */
98
- export type ToastRef = {
37
+ export type ToasterRef = {
99
38
  showToast: (toastOptions: ToastOptions) => void;
100
39
  closeToast: () => void;
101
40
  };
102
41
  /**
103
- * Toast component props.
42
+ * Toast component props intended for direct rendering of a single toast surface.
43
+ */
44
+ export type ToastProps = ToastSharedProps;
45
+ /**
46
+ * Toaster component props.
104
47
  * Extends ViewProps to inherit standard React Native props such as testID and accessibilityLabel.
105
48
  */
106
- export type ToastProps = {
49
+ export type ToasterProps = {
107
50
  /**
108
51
  * Optional Tailwind CSS classes for the toast container.
109
52
  */
110
53
  twClassName?: string;
111
- /**
112
- * Props spread to the labels container View (e.g., testID for testing).
113
- */
114
- labelsContainerProps?: Omit<ViewProps, 'children' | 'style'>;
115
54
  } & Omit<ViewProps, 'style'>;
116
- export {};
117
55
  //# sourceMappingURL=Toast.types.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Toast.types.d.mts","sourceRoot":"","sources":["../../../src/components/Toast/Toast.types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,kBAAkB,EAClB,QAAQ,EACT,uCAAuC;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,8BAAqB;AAG9C,OAAO,KAAK,EAAE,oBAAoB,EAAE,mCAAyB;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,4BAAkB;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,gCAAsB;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,gDAAsC;AAEnE;;GAEG;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AE,+BAA2B;AAEpD;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;CAKhB,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAE/E;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;AAExE;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG;IACzE,gBAAgB,CAAC,EAAE,IAAI,CACrB,WAAW,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,EAChD,SAAS,CACV,CAAC;IACF,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,gBAAgB,GAAG;IAC5C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,CAAC,YAAY,EAAE,YAAY,KAAK,IAAI,CAAC;IAChD,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,gBAAgB,CAAC;AAE1C;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC"}
@@ -1,16 +1,11 @@
1
1
  /**
2
- * Toast variants.
2
+ * Toast severity variants.
3
+ * `Default` renders no built-in leading icon.
3
4
  */
4
- export var ToastVariant;
5
- (function (ToastVariant) {
6
- ToastVariant["Plain"] = "Plain";
7
- ToastVariant["Account"] = "Account";
8
- ToastVariant["Network"] = "Network";
9
- ToastVariant["App"] = "App";
10
- ToastVariant["Icon"] = "Icon";
11
- })(ToastVariant || (ToastVariant = {}));
12
- export var ToastCloseButtonVariant;
13
- (function (ToastCloseButtonVariant) {
14
- ToastCloseButtonVariant["Icon"] = "Icon";
15
- })(ToastCloseButtonVariant || (ToastCloseButtonVariant = {}));
5
+ export const ToastSeverity = {
6
+ Default: 'default',
7
+ Success: 'success',
8
+ Warning: 'warning',
9
+ Danger: 'danger',
10
+ };
16
11
  //# sourceMappingURL=Toast.types.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Toast.types.mjs","sourceRoot":"","sources":["../../../src/components/Toast/Toast.types.ts"],"names":[],"mappings":"AAcA;;GAEG;AACH,MAAM,CAAN,IAAY,YAMX;AAND,WAAY,YAAY;IACtB,+BAAe,CAAA;IACf,mCAAmB,CAAA;IACnB,mCAAmB,CAAA;IACnB,2BAAW,CAAA;IACX,6BAAa,CAAA;AACf,CAAC,EANW,YAAY,KAAZ,YAAY,QAMvB;AA4CD,MAAM,CAAN,IAAY,uBAEX;AAFD,WAAY,uBAAuB;IACjC,wCAAa,CAAA;AACf,CAAC,EAFW,uBAAuB,KAAvB,uBAAuB,QAElC","sourcesContent":["// Third party dependencies.\nimport type {\n AvatarIconSeverity,\n IconName,\n} from '@metamask/design-system-shared';\nimport type { ReactElement } from 'react';\nimport type { ViewProps } from 'react-native';\n\n// External Dependencies.\nimport type { AvatarAccountVariant } from '../AvatarAccount';\nimport type { ButtonProps } from '../Button';\nimport type { ButtonIconProps } from '../ButtonIcon';\nimport type { ImageOrSvgSrc } from '../temp-components/ImageOrSvg';\n\n/**\n * Toast variants.\n */\nexport enum ToastVariant {\n Plain = 'Plain',\n Account = 'Account',\n Network = 'Network',\n App = 'App',\n Icon = 'Icon',\n}\n\n/**\n * Options for the main text in the toast.\n */\nexport type ToastLabelOptions = {\n label: string;\n isBold?: boolean;\n}[];\n\n/**\n * Options for the description text in the toast.\n */\nexport type ToastDescriptionOptions = {\n description: string;\n};\n\n/**\n * Options for displaying a Link in the toast.\n */\nexport type ToastLinkButtonOptions = {\n label: string;\n onPress: () => void;\n};\n\n/**\n * Common toast option shared between all other options.\n */\ntype BaseToastVariants = {\n hasNoTimeout: boolean;\n labelOptions: ToastLabelOptions;\n descriptionOptions?: ToastDescriptionOptions;\n linkButtonOptions?: ToastLinkButtonOptions;\n closeButtonOptions?: ToastCloseButtonOptions;\n startAccessory?: ReactElement;\n bottomOffset?: number;\n};\n\nexport type ToastCloseButtonIconOptions = Omit<ButtonIconProps, 'variant'> & {\n variant: ToastCloseButtonVariant;\n};\n\nexport type ToastCloseButtonOptions = ButtonProps | ToastCloseButtonIconOptions;\n\nexport enum ToastCloseButtonVariant {\n Icon = 'Icon',\n}\n\n/**\n * Plain toast option.\n */\ntype PlainToastOption = {\n variant: ToastVariant.Plain;\n} & BaseToastVariants;\n\n/**\n * Account toast option.\n */\ntype AccountToastOption = {\n variant: ToastVariant.Account;\n accountAddress: string;\n accountAvatarType: AvatarAccountVariant;\n} & BaseToastVariants;\n\n/**\n * Network toast option.\n */\ntype NetworkToastOption = {\n variant: ToastVariant.Network;\n networkName?: string;\n networkImageSource: ImageOrSvgSrc;\n} & BaseToastVariants;\n\n/**\n * App toast option.\n */\ntype AppToastOption = {\n variant: ToastVariant.App;\n appIconSource: ImageOrSvgSrc;\n} & BaseToastVariants;\n\ntype IconToastOption = {\n variant: ToastVariant.Icon;\n iconName: IconName;\n severity?: AvatarIconSeverity;\n} & BaseToastVariants;\n\n/**\n * Different toast options combined in a union type.\n */\nexport type ToastOptions =\n | PlainToastOption\n | AccountToastOption\n | NetworkToastOption\n | AppToastOption\n | IconToastOption;\n\n/**\n * Toast component reference.\n */\nexport type ToastRef = {\n showToast: (toastOptions: ToastOptions) => void;\n closeToast: () => void;\n};\n\n/**\n * Toast component props.\n * Extends ViewProps to inherit standard React Native props such as testID and accessibilityLabel.\n */\nexport type ToastProps = {\n /**\n * Optional Tailwind CSS classes for the toast container.\n */\n twClassName?: string;\n /**\n * Props spread to the labels container View (e.g., testID for testing).\n */\n labelsContainerProps?: Omit<ViewProps, 'children' | 'style'>;\n} & Omit<ViewProps, 'style'>;\n"]}
1
+ {"version":3,"file":"Toast.types.mjs","sourceRoot":"","sources":["../../../src/components/Toast/Toast.types.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;CACR,CAAC","sourcesContent":["import type { ViewProps } from 'react-native';\n\nimport type { BannerBaseProps } from '../BannerBase';\nimport type { IconProps } from '../Icon/Icon.types';\n\n/**\n * Toast severity variants.\n * `Default` renders no built-in leading icon.\n */\nexport const ToastSeverity = {\n Default: 'default',\n Success: 'success',\n Warning: 'warning',\n Danger: 'danger',\n} as const;\n\nexport type ToastSeverity = (typeof ToastSeverity)[keyof typeof ToastSeverity];\n\n/**\n * Optional props for the leading severity `Icon`.\n */\nexport type ToastIconProps = Omit<IconProps, 'name' | 'size' | 'color'>;\n\n/**\n * Shared toast props aligned with BannerBase, plus optional severity/icon props.\n */\nexport type ToastSharedProps = Omit<BannerBaseProps, 'closeButtonProps'> & {\n closeButtonProps?: Omit<\n NonNullable<BannerBaseProps['closeButtonProps']>,\n 'onPress'\n >;\n severity?: ToastSeverity;\n iconAlertProps?: ToastIconProps;\n};\n\n/**\n * Toast options used by the imperative `toast(...)` API.\n */\nexport type ToastOptions = ToastSharedProps & {\n hasNoTimeout?: boolean;\n bottomOffset?: number;\n};\n\n/**\n * Toaster component reference.\n */\nexport type ToasterRef = {\n showToast: (toastOptions: ToastOptions) => void;\n closeToast: () => void;\n};\n\n/**\n * Toast component props intended for direct rendering of a single toast surface.\n */\nexport type ToastProps = ToastSharedProps;\n\n/**\n * Toaster component props.\n * Extends ViewProps to inherit standard React Native props such as testID and accessibilityLabel.\n */\nexport type ToasterProps = {\n /**\n * Optional Tailwind CSS classes for the toast container.\n */\n twClassName?: string;\n} & Omit<ViewProps, 'style'>;\n"]}
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.toast = exports.Toaster = void 0;
27
+ // Third party dependencies.
28
+ const design_system_twrnc_preset_1 = require("@metamask/design-system-twrnc-preset");
29
+ const react_1 = __importStar(require("react"));
30
+ const react_native_1 = require("react-native/index.js");
31
+ const react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
32
+ const react_native_safe_area_context_1 = require("react-native-safe-area-context");
33
+ // Internal dependencies.
34
+ const Toast_1 = require("./Toast.cjs");
35
+ const Toast_constants_1 = require("./Toast.constants.cjs");
36
+ const screenHeight = react_native_1.Dimensions.get('window').height;
37
+ let registeredRef = null;
38
+ const assertRegisteredRef = (method) => {
39
+ if (!registeredRef?.current) {
40
+ const invocation = method === 'toast' ? 'toast()' : `toast.${method}()`;
41
+ throw new Error(`${invocation} called before <Toaster /> mounted. Render <Toaster /> once at the root of your app.`);
42
+ }
43
+ return registeredRef.current;
44
+ };
45
+ const getToastProps = ({ bottomOffset: _bottomOffset, hasNoTimeout: _hasNoTimeout, onClose: _onClose, twClassName: _twClassName, ...toastProps }) => toastProps;
46
+ const ToasterComponent = (0, react_1.forwardRef)(({ twClassName, ...props }, ref) => {
47
+ const tw = (0, design_system_twrnc_preset_1.useTailwind)();
48
+ const [toastOptions, setToastOptions] = (0, react_1.useState)(undefined);
49
+ const replacementTimerRef = (0, react_1.useRef)(null);
50
+ const { bottom: bottomNotchSpacing } = (0, react_native_safe_area_context_1.useSafeAreaInsets)();
51
+ const translateYProgress = (0, react_native_reanimated_1.useSharedValue)(screenHeight);
52
+ const bottomOffset = toastOptions?.bottomOffset ?? 0;
53
+ const animatedStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => ({
54
+ transform: [{ translateY: translateYProgress.value - bottomOffset }],
55
+ }));
56
+ const baseStyle = (0, react_1.useMemo)(() => [tw.style('absolute left-4 right-4 bottom-0'), animatedStyle], [tw, animatedStyle]);
57
+ const innerRef = (0, react_1.useRef)(null);
58
+ const resetState = () => setToastOptions(undefined);
59
+ const showToast = (options) => {
60
+ let timeoutDuration = 0;
61
+ const normalizedOptions = {
62
+ hasNoTimeout: false,
63
+ ...options,
64
+ };
65
+ if (toastOptions) {
66
+ (0, react_native_reanimated_1.cancelAnimation)(translateYProgress);
67
+ timeoutDuration = 100;
68
+ setToastOptions(undefined);
69
+ }
70
+ if (replacementTimerRef.current !== null) {
71
+ clearTimeout(replacementTimerRef.current);
72
+ }
73
+ replacementTimerRef.current = setTimeout(() => {
74
+ replacementTimerRef.current = null;
75
+ setToastOptions(normalizedOptions);
76
+ }, timeoutDuration);
77
+ };
78
+ const closeToast = () => {
79
+ if (replacementTimerRef.current !== null) {
80
+ clearTimeout(replacementTimerRef.current);
81
+ replacementTimerRef.current = null;
82
+ }
83
+ translateYProgress.value = (0, react_native_reanimated_1.withTiming)(screenHeight, { duration: Toast_constants_1.TOAST_ANIMATION_DURATION }, () => {
84
+ (0, react_native_reanimated_1.runOnJS)(resetState)();
85
+ });
86
+ };
87
+ innerRef.current = {
88
+ closeToast,
89
+ showToast,
90
+ };
91
+ (0, react_1.useImperativeHandle)(ref, () => innerRef.current);
92
+ (0, react_1.useLayoutEffect)(() => {
93
+ registeredRef = innerRef;
94
+ return () => {
95
+ if (registeredRef === innerRef) {
96
+ registeredRef = null;
97
+ }
98
+ };
99
+ }, []);
100
+ if (!toastOptions) {
101
+ return null;
102
+ }
103
+ const { onClose: toastOnClose, twClassName: toastTwClassName } = toastOptions;
104
+ const toastProps = getToastProps(toastOptions);
105
+ const { actionButtonLabel, actionButtonOnPress, ...restToastProps } = toastProps;
106
+ const toastTwClassNames = [twClassName, toastTwClassName]
107
+ .filter(Boolean)
108
+ .join(' ');
109
+ const onAnimatedViewLayout = (e) => {
110
+ const { height } = e.nativeEvent.layout;
111
+ const translateYToValue = -(Toast_constants_1.TOAST_BOTTOM_PADDING + bottomNotchSpacing);
112
+ translateYProgress.value = height;
113
+ if (toastOptions.hasNoTimeout) {
114
+ translateYProgress.value = (0, react_native_reanimated_1.withTiming)(translateYToValue, {
115
+ duration: Toast_constants_1.TOAST_ANIMATION_DURATION,
116
+ });
117
+ }
118
+ else {
119
+ translateYProgress.value = (0, react_native_reanimated_1.withTiming)(translateYToValue, { duration: Toast_constants_1.TOAST_ANIMATION_DURATION }, () => {
120
+ translateYProgress.value = (0, react_native_reanimated_1.withDelay)(Toast_constants_1.TOAST_VISIBILITY_DURATION, (0, react_native_reanimated_1.withTiming)(height, { duration: Toast_constants_1.TOAST_ANIMATION_DURATION }, (0, react_native_reanimated_1.runOnJS)(resetState)));
121
+ });
122
+ }
123
+ };
124
+ return (<react_native_reanimated_1.default.View onLayout={onAnimatedViewLayout} style={baseStyle} {...props}>
125
+ {actionButtonLabel && actionButtonOnPress ? (<Toast_1.Toast {...toastProps} actionButtonLabel={actionButtonLabel} actionButtonOnPress={actionButtonOnPress} onClose={() => {
126
+ closeToast();
127
+ toastOnClose?.();
128
+ }} twClassName={toastTwClassNames}/>) : (<Toast_1.Toast {...restToastProps} onClose={() => {
129
+ closeToast();
130
+ toastOnClose?.();
131
+ }} twClassName={toastTwClassNames}/>)}
132
+ </react_native_reanimated_1.default.View>);
133
+ });
134
+ ToasterComponent.displayName = 'Toaster';
135
+ exports.Toaster = ToasterComponent;
136
+ exports.toast = ((options) => {
137
+ assertRegisteredRef('toast').showToast(options);
138
+ });
139
+ exports.toast.dismiss = () => {
140
+ assertRegisteredRef('dismiss').closeToast();
141
+ };
142
+ //# sourceMappingURL=Toaster.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Toaster.cjs","sourceRoot":"","sources":["../../../src/components/Toast/Toaster.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4BAA4B;AAC5B,qFAAmE;AACnE,+CAOe;AAEf,wDAA0C;AAE1C,mFAOiC;AACjC,mFAAmE;AAEnE,yBAAyB;AACzB,uCAAgC;AAChC,2DAI2B;AAQ3B,MAAM,YAAY,GAAG,yBAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC;AAErD,IAAI,aAAa,GAAiC,IAAI,CAAC;AAEvD,MAAM,mBAAmB,GAAG,CAAC,MAA2B,EAAc,EAAE;IACtE,IAAI,CAAC,aAAa,EAAE,OAAO,EAAE;QAC3B,MAAM,UAAU,GAAG,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC;QACxE,MAAM,IAAI,KAAK,CACb,GAAG,UAAU,sFAAsF,CACpG,CAAC;KACH;IACD,OAAO,aAAa,CAAC,OAAO,CAAC;AAC/B,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,EACrB,YAAY,EAAE,aAAa,EAC3B,YAAY,EAAE,aAAa,EAC3B,OA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BAAoB,CAAC,CAC/B,KAAK,CAAC,CAAC,SAAS,CAAC,CACjB,IAAI,KAAK,CAAC,CAEV;QAAA,CAAC,iBAAiB,IAAI,mBAAmB,CAAC,CAAC,CAAC,CAC1C,CAAC,aAAK,CACJ,IAAI,UAAU,CAAC,CACf,iBAAiB,CAAC,CAAC,iBAAiB,CAAC,CACrC,mBAAmB,CAAC,CAAC,mBAAmB,CAAC,CACzC,OAAO,CAAC,CAAC,GAAG,EAAE;gBACZ,UAAU,EAAE,CAAC;gBACb,YAAY,EAAE,EAAE,CAAC;YACnB,CAAC,CAAC,CACF,WAAW,CAAC,CAAC,iBAAiB,CAAC,EAC/B,CACH,CAAC,CAAC,CAAC,CACF,CAAC,aAAK,CACJ,IAAI,cAAc,CAAC,CACnB,OAAO,CAAC,CAAC,GAAG,EAAE;gBACZ,UAAU,EAAE,CAAC;gBACb,YAAY,EAAE,EAAE,CAAC;YACnB,CAAC,CAAC,CACF,WAAW,CAAC,CAAC,iBAAiB,CAAC,EAC/B,CACH,CACH;MAAA,EAAE,iCAAQ,CAAC,IAAI,CAAC,CACjB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,gBAAgB,CAAC,WAAW,GAAG,SAAS,CAAC;AAM5B,QAAA,OAAO,GAAG,gBAAgB,CAAC;AAE3B,QAAA,KAAK,GAAG,CAAC,CAAC,OAAqB,EAAE,EAAE;IAC9C,mBAAmB,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AAClD,CAAC,CAAkB,CAAC;AAEpB,aAAK,CAAC,OAAO,GAAG,GAAG,EAAE;IACnB,mBAAmB,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,CAAC;AAC9C,CAAC,CAAC","sourcesContent":["// Third party dependencies.\nimport { useTailwind } from '@metamask/design-system-twrnc-preset';\nimport React, {\n forwardRef,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport type { RefObject } from 'react';\nimport { Dimensions } from 'react-native';\nimport type { LayoutChangeEvent, StyleProp, ViewStyle } from 'react-native';\nimport Animated, {\n cancelAnimation,\n runOnJS,\n useAnimatedStyle,\n useSharedValue,\n withDelay,\n withTiming,\n} from 'react-native-reanimated';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\n\n// Internal dependencies.\nimport { Toast } from './Toast';\nimport {\n TOAST_ANIMATION_DURATION,\n TOAST_BOTTOM_PADDING,\n TOAST_VISIBILITY_DURATION,\n} from './Toast.constants';\nimport type {\n ToastOptions,\n ToastProps,\n ToasterProps,\n ToasterRef,\n} from './Toast.types';\n\nconst screenHeight = Dimensions.get('window').height;\n\nlet registeredRef: RefObject<ToasterRef> | null = null;\n\nconst assertRegisteredRef = (method: 'dismiss' | 'toast'): ToasterRef => {\n if (!registeredRef?.current) {\n const invocation = method === 'toast' ? 'toast()' : `toast.${method}()`;\n throw new Error(\n `${invocation} called before <Toaster /> mounted. Render <Toaster /> once at the root of your app.`,\n );\n }\n return registeredRef.current;\n};\n\nconst getToastProps = ({\n bottomOffset: _bottomOffset,\n hasNoTimeout: _hasNoTimeout,\n onClose: _onClose,\n twClassName: _twClassName,\n ...toastProps\n}: ToastOptions): Omit<ToastProps, 'twClassName'> => toastProps;\n\nconst ToasterComponent = forwardRef<ToasterRef, ToasterProps>(\n ({ twClassName, ...props }, ref) => {\n const tw = useTailwind();\n const [toastOptions, setToastOptions] = useState<ToastOptions | undefined>(\n undefined,\n );\n const replacementTimerRef = useRef<ReturnType<typeof setTimeout> | null>(\n null,\n );\n const { bottom: bottomNotchSpacing } = useSafeAreaInsets();\n const translateYProgress = useSharedValue(screenHeight);\n const bottomOffset = toastOptions?.bottomOffset ?? 0;\n const animatedStyle = useAnimatedStyle(() => ({\n transform: [{ translateY: translateYProgress.value - bottomOffset }],\n }));\n const baseStyle: StyleProp<ViewStyle> = useMemo(\n () => [tw.style('absolute left-4 right-4 bottom-0'), animatedStyle],\n [tw, animatedStyle],\n );\n const innerRef = useRef<ToasterRef | null>(null);\n\n const resetState = () => setToastOptions(undefined);\n\n const showToast = (options: ToastOptions) => {\n let timeoutDuration = 0;\n const normalizedOptions = {\n hasNoTimeout: false,\n ...options,\n };\n if (toastOptions) {\n cancelAnimation(translateYProgress);\n timeoutDuration = 100;\n setToastOptions(undefined);\n }\n if (replacementTimerRef.current !== null) {\n clearTimeout(replacementTimerRef.current);\n }\n replacementTimerRef.current = setTimeout(() => {\n replacementTimerRef.current = null;\n setToastOptions(normalizedOptions);\n }, timeoutDuration);\n };\n\n const closeToast = () => {\n if (replacementTimerRef.current !== null) {\n clearTimeout(replacementTimerRef.current);\n replacementTimerRef.current = null;\n }\n translateYProgress.value = withTiming(\n screenHeight,\n { duration: TOAST_ANIMATION_DURATION },\n () => {\n runOnJS(resetState)();\n },\n );\n };\n\n innerRef.current = {\n closeToast,\n showToast,\n };\n\n useImperativeHandle(ref, () => innerRef.current as ToasterRef);\n\n useLayoutEffect(() => {\n registeredRef = innerRef;\n return () => {\n if (registeredRef === innerRef) {\n registeredRef = null;\n }\n };\n }, []);\n\n if (!toastOptions) {\n return null;\n }\n\n const { onClose: toastOnClose, twClassName: toastTwClassName } =\n toastOptions;\n const toastProps = getToastProps(toastOptions);\n const { actionButtonLabel, actionButtonOnPress, ...restToastProps } =\n toastProps;\n const toastTwClassNames = [twClassName, toastTwClassName]\n .filter(Boolean)\n .join(' ');\n\n const onAnimatedViewLayout = (e: LayoutChangeEvent) => {\n const { height } = e.nativeEvent.layout;\n const translateYToValue = -(TOAST_BOTTOM_PADDING + bottomNotchSpacing);\n\n translateYProgress.value = height;\n\n if (toastOptions.hasNoTimeout) {\n translateYProgress.value = withTiming(translateYToValue, {\n duration: TOAST_ANIMATION_DURATION,\n });\n } else {\n translateYProgress.value = withTiming(\n translateYToValue,\n { duration: TOAST_ANIMATION_DURATION },\n () => {\n translateYProgress.value = withDelay(\n TOAST_VISIBILITY_DURATION,\n withTiming(\n height,\n { duration: TOAST_ANIMATION_DURATION },\n runOnJS(resetState),\n ),\n );\n },\n );\n }\n };\n\n return (\n <Animated.View\n onLayout={onAnimatedViewLayout}\n style={baseStyle}\n {...props}\n >\n {actionButtonLabel && actionButtonOnPress ? (\n <Toast\n {...toastProps}\n actionButtonLabel={actionButtonLabel}\n actionButtonOnPress={actionButtonOnPress}\n onClose={() => {\n closeToast();\n toastOnClose?.();\n }}\n twClassName={toastTwClassNames}\n />\n ) : (\n <Toast\n {...restToastProps}\n onClose={() => {\n closeToast();\n toastOnClose?.();\n }}\n twClassName={toastTwClassNames}\n />\n )}\n </Animated.View>\n );\n },\n);\n\nToasterComponent.displayName = 'Toaster';\n\ntype ToastFunction = ((options: ToastOptions) => void) & {\n dismiss: () => void;\n};\n\nexport const Toaster = ToasterComponent;\n\nexport const toast = ((options: ToastOptions) => {\n assertRegisteredRef('toast').showToast(options);\n}) as ToastFunction;\n\ntoast.dismiss = () => {\n assertRegisteredRef('dismiss').closeToast();\n};\n"]}
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import type { ToastOptions, ToasterRef } from "./Toast.types.cjs";
3
+ type ToastFunction = ((options: ToastOptions) => void) & {
4
+ dismiss: () => void;
5
+ };
6
+ export declare const Toaster: React.ForwardRefExoticComponent<{
7
+ twClassName?: string | undefined;
8
+ } & Omit<import("react-native").ViewProps, "style"> & React.RefAttributes<ToasterRef>>;
9
+ export declare const toast: ToastFunction;
10
+ export {};
11
+ //# sourceMappingURL=Toaster.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Toaster.d.cts","sourceRoot":"","sources":["../../../src/components/Toast/Toaster.tsx"],"names":[],"mappings":"AAEA,OAAO,KAON,cAAc;AAqBf,OAAO,KAAK,EACV,YAAY,EAGZ,UAAU,EACX,0BAAsB;AA4KvB,KAAK,aAAa,GAAG,CAAC,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC,GAAG;IACvD,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,OAAO;;sFAAmB,CAAC;AAExC,eAAO,MAAM,KAAK,eAEC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import type { ToastOptions, ToasterRef } from "./Toast.types.mjs";
3
+ type ToastFunction = ((options: ToastOptions) => void) & {
4
+ dismiss: () => void;
5
+ };
6
+ export declare const Toaster: React.ForwardRefExoticComponent<{
7
+ twClassName?: string | undefined;
8
+ } & Omit<import("react-native").ViewProps, "style"> & React.RefAttributes<ToasterRef>>;
9
+ export declare const toast: ToastFunction;
10
+ export {};
11
+ //# sourceMappingURL=Toaster.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Toaster.d.mts","sourceRoot":"","sources":["../../../src/components/Toast/Toaster.tsx"],"names":[],"mappings":"AAEA,OAAO,KAON,cAAc;AAqBf,OAAO,KAAK,EACV,YAAY,EAGZ,UAAU,EACX,0BAAsB;AA4KvB,KAAK,aAAa,GAAG,CAAC,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC,GAAG;IACvD,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,OAAO;;sFAAmB,CAAC;AAExC,eAAO,MAAM,KAAK,eAEC,CAAC"}
@@ -0,0 +1,123 @@
1
+ function $importDefault(module) {
2
+ if (module?.__esModule) {
3
+ return module.default;
4
+ }
5
+ return module;
6
+ }
7
+ // Third party dependencies.
8
+ import { useTailwind } from "@metamask/design-system-twrnc-preset";
9
+ import $React, { forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
10
+ const React = $importDefault($React);
11
+ import { Dimensions } from "react-native/index.js";
12
+ import Animated, { cancelAnimation, runOnJS, useAnimatedStyle, useSharedValue, withDelay, withTiming } from "react-native-reanimated";
13
+ import { useSafeAreaInsets } from "react-native-safe-area-context";
14
+ // Internal dependencies.
15
+ import { Toast } from "./Toast.mjs";
16
+ import { TOAST_ANIMATION_DURATION, TOAST_BOTTOM_PADDING, TOAST_VISIBILITY_DURATION } from "./Toast.constants.mjs";
17
+ const screenHeight = Dimensions.get('window').height;
18
+ let registeredRef = null;
19
+ const assertRegisteredRef = (method) => {
20
+ if (!registeredRef?.current) {
21
+ const invocation = method === 'toast' ? 'toast()' : `toast.${method}()`;
22
+ throw new Error(`${invocation} called before <Toaster /> mounted. Render <Toaster /> once at the root of your app.`);
23
+ }
24
+ return registeredRef.current;
25
+ };
26
+ const getToastProps = ({ bottomOffset: _bottomOffset, hasNoTimeout: _hasNoTimeout, onClose: _onClose, twClassName: _twClassName, ...toastProps }) => toastProps;
27
+ const ToasterComponent = forwardRef(({ twClassName, ...props }, ref) => {
28
+ const tw = useTailwind();
29
+ const [toastOptions, setToastOptions] = useState(undefined);
30
+ const replacementTimerRef = useRef(null);
31
+ const { bottom: bottomNotchSpacing } = useSafeAreaInsets();
32
+ const translateYProgress = useSharedValue(screenHeight);
33
+ const bottomOffset = toastOptions?.bottomOffset ?? 0;
34
+ const animatedStyle = useAnimatedStyle(() => ({
35
+ transform: [{ translateY: translateYProgress.value - bottomOffset }],
36
+ }));
37
+ const baseStyle = useMemo(() => [tw.style('absolute left-4 right-4 bottom-0'), animatedStyle], [tw, animatedStyle]);
38
+ const innerRef = useRef(null);
39
+ const resetState = () => setToastOptions(undefined);
40
+ const showToast = (options) => {
41
+ let timeoutDuration = 0;
42
+ const normalizedOptions = {
43
+ hasNoTimeout: false,
44
+ ...options,
45
+ };
46
+ if (toastOptions) {
47
+ cancelAnimation(translateYProgress);
48
+ timeoutDuration = 100;
49
+ setToastOptions(undefined);
50
+ }
51
+ if (replacementTimerRef.current !== null) {
52
+ clearTimeout(replacementTimerRef.current);
53
+ }
54
+ replacementTimerRef.current = setTimeout(() => {
55
+ replacementTimerRef.current = null;
56
+ setToastOptions(normalizedOptions);
57
+ }, timeoutDuration);
58
+ };
59
+ const closeToast = () => {
60
+ if (replacementTimerRef.current !== null) {
61
+ clearTimeout(replacementTimerRef.current);
62
+ replacementTimerRef.current = null;
63
+ }
64
+ translateYProgress.value = withTiming(screenHeight, { duration: TOAST_ANIMATION_DURATION }, () => {
65
+ runOnJS(resetState)();
66
+ });
67
+ };
68
+ innerRef.current = {
69
+ closeToast,
70
+ showToast,
71
+ };
72
+ useImperativeHandle(ref, () => innerRef.current);
73
+ useLayoutEffect(() => {
74
+ registeredRef = innerRef;
75
+ return () => {
76
+ if (registeredRef === innerRef) {
77
+ registeredRef = null;
78
+ }
79
+ };
80
+ }, []);
81
+ if (!toastOptions) {
82
+ return null;
83
+ }
84
+ const { onClose: toastOnClose, twClassName: toastTwClassName } = toastOptions;
85
+ const toastProps = getToastProps(toastOptions);
86
+ const { actionButtonLabel, actionButtonOnPress, ...restToastProps } = toastProps;
87
+ const toastTwClassNames = [twClassName, toastTwClassName]
88
+ .filter(Boolean)
89
+ .join(' ');
90
+ const onAnimatedViewLayout = (e) => {
91
+ const { height } = e.nativeEvent.layout;
92
+ const translateYToValue = -(TOAST_BOTTOM_PADDING + bottomNotchSpacing);
93
+ translateYProgress.value = height;
94
+ if (toastOptions.hasNoTimeout) {
95
+ translateYProgress.value = withTiming(translateYToValue, {
96
+ duration: TOAST_ANIMATION_DURATION,
97
+ });
98
+ }
99
+ else {
100
+ translateYProgress.value = withTiming(translateYToValue, { duration: TOAST_ANIMATION_DURATION }, () => {
101
+ translateYProgress.value = withDelay(TOAST_VISIBILITY_DURATION, withTiming(height, { duration: TOAST_ANIMATION_DURATION }, runOnJS(resetState)));
102
+ });
103
+ }
104
+ };
105
+ return (<Animated.View onLayout={onAnimatedViewLayout} style={baseStyle} {...props}>
106
+ {actionButtonLabel && actionButtonOnPress ? (<Toast {...toastProps} actionButtonLabel={actionButtonLabel} actionButtonOnPress={actionButtonOnPress} onClose={() => {
107
+ closeToast();
108
+ toastOnClose?.();
109
+ }} twClassName={toastTwClassNames}/>) : (<Toast {...restToastProps} onClose={() => {
110
+ closeToast();
111
+ toastOnClose?.();
112
+ }} twClassName={toastTwClassNames}/>)}
113
+ </Animated.View>);
114
+ });
115
+ ToasterComponent.displayName = 'Toaster';
116
+ export const Toaster = ToasterComponent;
117
+ export const toast = ((options) => {
118
+ assertRegisteredRef('toast').showToast(options);
119
+ });
120
+ toast.dismiss = () => {
121
+ assertRegisteredRef('dismiss').closeToast();
122
+ };
123
+ //# sourceMappingURL=Toaster.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Toaster.mjs","sourceRoot":"","sources":["../../../src/components/Toast/Toaster.tsx"],"names":[],"mappings":";;;;;;AAAA,4BAA4B;AAC5B,OAAO,EAAE,WAAW,EAAE,6CAA6C;AACnE,OAAO,QAAO,EACZ,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,OAAO,EACP,MAAM,EACN,QAAQ,EACT,cAAc;;AAEf,OAAO,EAAE,UAAU,EAAE,8BAAqB;AAE1C,OAAO,QAAQ,EAAE,EACf,eAAe,EACf,OAAO,EACP,gBAAgB,EAChB,cAAc,EACd,SAAS,EACT,UAAU,EACX,gCAAgC;AACjC,OAAO,EAAE,iBAAiB,EAAE,uCAAuC;AAEnE,yBAAyB;AACzB,OAAO,EAAE,KAAK,EAAE,oBAAgB;AAChC,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,yBAAyB,EAC1B,8BAA0B;AAQ3B,MAAM,YAAY,GAAG,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC;AAErD,IAAI,aAAa,GAAiC,IAAI,CAAC;AAEvD,MAAM,mBAAmB,GAAG,CAAC,MAA2B,EAAc,EAAE;IACtE,IAAI,CAAC,aAAa,EAAE,OAAO,EAAE;QAC3B,MAAM,UAAU,GAAG,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC;QACxE,MAAM,IAAI,KAAK,CACb,GAAG,UAAU,sFAAsF,CACpG,CAAC;KACH;IACD,OAAO,aAAa,CAAC,OAAO,CAAC;AAC/B,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,EACr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AEV;QAAA,CAAC,iBAAiB,IAAI,mBAAmB,CAAC,CAAC,CAAC,CAC1C,CAAC,KAAK,CACJ,IAAI,UAAU,CAAC,CACf,iBAAiB,CAAC,CAAC,iBAAiB,CAAC,CACrC,mBAAmB,CAAC,CAAC,mBAAmB,CAAC,CACzC,OAAO,CAAC,CAAC,GAAG,EAAE;gBACZ,UAAU,EAAE,CAAC;gBACb,YAAY,EAAE,EAAE,CAAC;YACnB,CAAC,CAAC,CACF,WAAW,CAAC,CAAC,iBAAiB,CAAC,EAC/B,CACH,CAAC,CAAC,CAAC,CACF,CAAC,KAAK,CACJ,IAAI,cAAc,CAAC,CACnB,OAAO,CAAC,CAAC,GAAG,EAAE;gBACZ,UAAU,EAAE,CAAC;gBACb,YAAY,EAAE,EAAE,CAAC;YACnB,CAAC,CAAC,CACF,WAAW,CAAC,CAAC,iBAAiB,CAAC,EAC/B,CACH,CACH;MAAA,EAAE,QAAQ,CAAC,IAAI,CAAC,CACjB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,gBAAgB,CAAC,WAAW,GAAG,SAAS,CAAC;AAMzC,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAC;AAExC,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,OAAqB,EAAE,EAAE;IAC9C,mBAAmB,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AAClD,CAAC,CAAkB,CAAC;AAEpB,KAAK,CAAC,OAAO,GAAG,GAAG,EAAE;IACnB,mBAAmB,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,CAAC;AAC9C,CAAC,CAAC","sourcesContent":["// Third party dependencies.\nimport { useTailwind } from '@metamask/design-system-twrnc-preset';\nimport React, {\n forwardRef,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport type { RefObject } from 'react';\nimport { Dimensions } from 'react-native';\nimport type { LayoutChangeEvent, StyleProp, ViewStyle } from 'react-native';\nimport Animated, {\n cancelAnimation,\n runOnJS,\n useAnimatedStyle,\n useSharedValue,\n withDelay,\n withTiming,\n} from 'react-native-reanimated';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\n\n// Internal dependencies.\nimport { Toast } from './Toast';\nimport {\n TOAST_ANIMATION_DURATION,\n TOAST_BOTTOM_PADDING,\n TOAST_VISIBILITY_DURATION,\n} from './Toast.constants';\nimport type {\n ToastOptions,\n ToastProps,\n ToasterProps,\n ToasterRef,\n} from './Toast.types';\n\nconst screenHeight = Dimensions.get('window').height;\n\nlet registeredRef: RefObject<ToasterRef> | null = null;\n\nconst assertRegisteredRef = (method: 'dismiss' | 'toast'): ToasterRef => {\n if (!registeredRef?.current) {\n const invocation = method === 'toast' ? 'toast()' : `toast.${method}()`;\n throw new Error(\n `${invocation} called before <Toaster /> mounted. Render <Toaster /> once at the root of your app.`,\n );\n }\n return registeredRef.current;\n};\n\nconst getToastProps = ({\n bottomOffset: _bottomOffset,\n hasNoTimeout: _hasNoTimeout,\n onClose: _onClose,\n twClassName: _twClassName,\n ...toastProps\n}: ToastOptions): Omit<ToastProps, 'twClassName'> => toastProps;\n\nconst ToasterComponent = forwardRef<ToasterRef, ToasterProps>(\n ({ twClassName, ...props }, ref) => {\n const tw = useTailwind();\n const [toastOptions, setToastOptions] = useState<ToastOptions | undefined>(\n undefined,\n );\n const replacementTimerRef = useRef<ReturnType<typeof setTimeout> | null>(\n null,\n );\n const { bottom: bottomNotchSpacing } = useSafeAreaInsets();\n const translateYProgress = useSharedValue(screenHeight);\n const bottomOffset = toastOptions?.bottomOffset ?? 0;\n const animatedStyle = useAnimatedStyle(() => ({\n transform: [{ translateY: translateYProgress.value - bottomOffset }],\n }));\n const baseStyle: StyleProp<ViewStyle> = useMemo(\n () => [tw.style('absolute left-4 right-4 bottom-0'), animatedStyle],\n [tw, animatedStyle],\n );\n const innerRef = useRef<ToasterRef | null>(null);\n\n const resetState = () => setToastOptions(undefined);\n\n const showToast = (options: ToastOptions) => {\n let timeoutDuration = 0;\n const normalizedOptions = {\n hasNoTimeout: false,\n ...options,\n };\n if (toastOptions) {\n cancelAnimation(translateYProgress);\n timeoutDuration = 100;\n setToastOptions(undefined);\n }\n if (replacementTimerRef.current !== null) {\n clearTimeout(replacementTimerRef.current);\n }\n replacementTimerRef.current = setTimeout(() => {\n replacementTimerRef.current = null;\n setToastOptions(normalizedOptions);\n }, timeoutDuration);\n };\n\n const closeToast = () => {\n if (replacementTimerRef.current !== null) {\n clearTimeout(replacementTimerRef.current);\n replacementTimerRef.current = null;\n }\n translateYProgress.value = withTiming(\n screenHeight,\n { duration: TOAST_ANIMATION_DURATION },\n () => {\n runOnJS(resetState)();\n },\n );\n };\n\n innerRef.current = {\n closeToast,\n showToast,\n };\n\n useImperativeHandle(ref, () => innerRef.current as ToasterRef);\n\n useLayoutEffect(() => {\n registeredRef = innerRef;\n return () => {\n if (registeredRef === innerRef) {\n registeredRef = null;\n }\n };\n }, []);\n\n if (!toastOptions) {\n return null;\n }\n\n const { onClose: toastOnClose, twClassName: toastTwClassName } =\n toastOptions;\n const toastProps = getToastProps(toastOptions);\n const { actionButtonLabel, actionButtonOnPress, ...restToastProps } =\n toastProps;\n const toastTwClassNames = [twClassName, toastTwClassName]\n .filter(Boolean)\n .join(' ');\n\n const onAnimatedViewLayout = (e: LayoutChangeEvent) => {\n const { height } = e.nativeEvent.layout;\n const translateYToValue = -(TOAST_BOTTOM_PADDING + bottomNotchSpacing);\n\n translateYProgress.value = height;\n\n if (toastOptions.hasNoTimeout) {\n translateYProgress.value = withTiming(translateYToValue, {\n duration: TOAST_ANIMATION_DURATION,\n });\n } else {\n translateYProgress.value = withTiming(\n translateYToValue,\n { duration: TOAST_ANIMATION_DURATION },\n () => {\n translateYProgress.value = withDelay(\n TOAST_VISIBILITY_DURATION,\n withTiming(\n height,\n { duration: TOAST_ANIMATION_DURATION },\n runOnJS(resetState),\n ),\n );\n },\n );\n }\n };\n\n return (\n <Animated.View\n onLayout={onAnimatedViewLayout}\n style={baseStyle}\n {...props}\n >\n {actionButtonLabel && actionButtonOnPress ? (\n <Toast\n {...toastProps}\n actionButtonLabel={actionButtonLabel}\n actionButtonOnPress={actionButtonOnPress}\n onClose={() => {\n closeToast();\n toastOnClose?.();\n }}\n twClassName={toastTwClassNames}\n />\n ) : (\n <Toast\n {...restToastProps}\n onClose={() => {\n closeToast();\n toastOnClose?.();\n }}\n twClassName={toastTwClassNames}\n />\n )}\n </Animated.View>\n );\n },\n);\n\nToasterComponent.displayName = 'Toaster';\n\ntype ToastFunction = ((options: ToastOptions) => void) & {\n dismiss: () => void;\n};\n\nexport const Toaster = ToasterComponent;\n\nexport const toast = ((options: ToastOptions) => {\n assertRegisteredRef('toast').showToast(options);\n}) as ToastFunction;\n\ntoast.dismiss = () => {\n assertRegisteredRef('dismiss').closeToast();\n};\n"]}
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TOAST_BOTTOM_PADDING = exports.TOAST_ANIMATION_DURATION = exports.TOAST_VISIBILITY_DURATION = exports.ToastCloseButtonVariant = exports.ToastVariant = exports.Toast = void 0;
3
+ exports.TOAST_BOTTOM_PADDING = exports.TOAST_ANIMATION_DURATION = exports.TOAST_VISIBILITY_DURATION = exports.ToastSeverity = exports.toast = exports.Toaster = exports.Toast = void 0;
4
4
  var Toast_1 = require("./Toast.cjs");
5
5
  Object.defineProperty(exports, "Toast", { enumerable: true, get: function () { return Toast_1.Toast; } });
6
+ var Toaster_1 = require("./Toaster.cjs");
7
+ Object.defineProperty(exports, "Toaster", { enumerable: true, get: function () { return Toaster_1.Toaster; } });
8
+ Object.defineProperty(exports, "toast", { enumerable: true, get: function () { return Toaster_1.toast; } });
6
9
  var Toast_types_1 = require("./Toast.types.cjs");
7
- Object.defineProperty(exports, "ToastVariant", { enumerable: true, get: function () { return Toast_types_1.ToastVariant; } });
8
- Object.defineProperty(exports, "ToastCloseButtonVariant", { enumerable: true, get: function () { return Toast_types_1.ToastCloseButtonVariant; } });
10
+ Object.defineProperty(exports, "ToastSeverity", { enumerable: true, get: function () { return Toast_types_1.ToastSeverity; } });
9
11
  var Toast_constants_1 = require("./Toast.constants.cjs");
10
12
  Object.defineProperty(exports, "TOAST_VISIBILITY_DURATION", { enumerable: true, get: function () { return Toast_constants_1.TOAST_VISIBILITY_DURATION; } });
11
13
  Object.defineProperty(exports, "TOAST_ANIMATION_DURATION", { enumerable: true, get: function () { return Toast_constants_1.TOAST_ANIMATION_DURATION; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/components/Toast/index.ts"],"names":[],"mappings":";;;AAAA,qCAAgC;AAAvB,8FAAA,KAAK,OAAA;AACd,iDAAsE;AAA7D,2GAAA,YAAY,OAAA;AAAE,sHAAA,uBAAuB,OAAA;AAU9C,yDAI2B;AAHzB,4HAAA,yBAAyB,OAAA;AACzB,2HAAA,wBAAwB,OAAA;AACxB,uHAAA,oBAAoB,OAAA","sourcesContent":["export { Toast } from './Toast';\nexport { ToastVariant, ToastCloseButtonVariant } from './Toast.types';\nexport type {\n ToastOptions,\n ToastProps,\n ToastRef,\n ToastLabelOptions,\n ToastDescriptionOptions,\n ToastLinkButtonOptions,\n ToastCloseButtonOptions,\n} from './Toast.types';\nexport {\n TOAST_VISIBILITY_DURATION,\n TOAST_ANIMATION_DURATION,\n TOAST_BOTTOM_PADDING,\n} from './Toast.constants';\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/components/Toast/index.ts"],"names":[],"mappings":";;;AAAA,qCAAgC;AAAvB,8FAAA,KAAK,OAAA;AACd,yCAA2C;AAAlC,kGAAA,OAAO,OAAA;AAAE,gGAAA,KAAK,OAAA;AACvB,iDAA8C;AAArC,4GAAA,aAAa,OAAA;AAQtB,yDAI2B;AAHzB,4HAAA,yBAAyB,OAAA;AACzB,2HAAA,wBAAwB,OAAA;AACxB,uHAAA,oBAAoB,OAAA","sourcesContent":["export { Toast } from './Toast';\nexport { Toaster, toast } from './Toaster';\nexport { ToastSeverity } from './Toast.types';\nexport type {\n ToastOptions,\n ToastProps,\n ToastIconProps,\n ToasterProps,\n ToasterRef,\n} from './Toast.types';\nexport {\n TOAST_VISIBILITY_DURATION,\n TOAST_ANIMATION_DURATION,\n TOAST_BOTTOM_PADDING,\n} from './Toast.constants';\n"]}
@@ -1,5 +1,6 @@
1
1
  export { Toast } from "./Toast.cjs";
2
- export { ToastVariant, ToastCloseButtonVariant } from "./Toast.types.cjs";
3
- export type { ToastOptions, ToastProps, ToastRef, ToastLabelOptions, ToastDescriptionOptions, ToastLinkButtonOptions, ToastCloseButtonOptions, } from "./Toast.types.cjs";
2
+ export { Toaster, toast } from "./Toaster.cjs";
3
+ export { ToastSeverity } from "./Toast.types.cjs";
4
+ export type { ToastOptions, ToastProps, ToastIconProps, ToasterProps, ToasterRef, } from "./Toast.types.cjs";
4
5
  export { TOAST_VISIBILITY_DURATION, TOAST_ANIMATION_DURATION, TOAST_BOTTOM_PADDING, } from "./Toast.constants.cjs";
5
6
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/Toast/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,oBAAgB;AAChC,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,0BAAsB;AACtE,YAAY,EACV,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,iBAAiB,EACjB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,GACxB,0BAAsB;AACvB,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,GACrB,8BAA0B"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/Toast/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,oBAAgB;AAChC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,sBAAkB;AAC3C,OAAO,EAAE,aAAa,EAAE,0BAAsB;AAC9C,YAAY,EACV,YAAY,EACZ,UAAU,EACV,cAAc,EACd,YAAY,EACZ,UAAU,GACX,0BAAsB;AACvB,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,GACrB,8BAA0B"}
@@ -1,5 +1,6 @@
1
1
  export { Toast } from "./Toast.mjs";
2
- export { ToastVariant, ToastCloseButtonVariant } from "./Toast.types.mjs";
3
- export type { ToastOptions, ToastProps, ToastRef, ToastLabelOptions, ToastDescriptionOptions, ToastLinkButtonOptions, ToastCloseButtonOptions, } from "./Toast.types.mjs";
2
+ export { Toaster, toast } from "./Toaster.mjs";
3
+ export { ToastSeverity } from "./Toast.types.mjs";
4
+ export type { ToastOptions, ToastProps, ToastIconProps, ToasterProps, ToasterRef, } from "./Toast.types.mjs";
4
5
  export { TOAST_VISIBILITY_DURATION, TOAST_ANIMATION_DURATION, TOAST_BOTTOM_PADDING, } from "./Toast.constants.mjs";
5
6
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/components/Toast/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,oBAAgB;AAChC,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,0BAAsB;AACtE,YAAY,EACV,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,iBAAiB,EACjB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,GACxB,0BAAsB;AACvB,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,GACrB,8BAA0B"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/components/Toast/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,oBAAgB;AAChC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,sBAAkB;AAC3C,OAAO,EAAE,aAAa,EAAE,0BAAsB;AAC9C,YAAY,EACV,YAAY,EACZ,UAAU,EACV,cAAc,EACd,YAAY,EACZ,UAAU,GACX,0BAAsB;AACvB,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,GACrB,8BAA0B"}
@@ -1,4 +1,5 @@
1
1
  export { Toast } from "./Toast.mjs";
2
- export { ToastVariant, ToastCloseButtonVariant } from "./Toast.types.mjs";
2
+ export { Toaster, toast } from "./Toaster.mjs";
3
+ export { ToastSeverity } from "./Toast.types.mjs";
3
4
  export { TOAST_VISIBILITY_DURATION, TOAST_ANIMATION_DURATION, TOAST_BOTTOM_PADDING } from "./Toast.constants.mjs";
4
5
  //# sourceMappingURL=index.mjs.map