react-native-terra-ui 0.1.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 (379) hide show
  1. package/README.md +70 -0
  2. package/lib/module/components/avatar/Avatar.js +121 -0
  3. package/lib/module/components/avatar/Avatar.js.map +1 -0
  4. package/lib/module/components/avatar/index.js +4 -0
  5. package/lib/module/components/avatar/index.js.map +1 -0
  6. package/lib/module/components/avatar/types.js +4 -0
  7. package/lib/module/components/avatar/types.js.map +1 -0
  8. package/lib/module/components/box/Box.js +49 -0
  9. package/lib/module/components/box/Box.js.map +1 -0
  10. package/lib/module/components/box/index.js +4 -0
  11. package/lib/module/components/box/index.js.map +1 -0
  12. package/lib/module/components/box/utils.js +95 -0
  13. package/lib/module/components/box/utils.js.map +1 -0
  14. package/lib/module/components/button/Button.js +281 -0
  15. package/lib/module/components/button/Button.js.map +1 -0
  16. package/lib/module/components/button/index.js +4 -0
  17. package/lib/module/components/button/index.js.map +1 -0
  18. package/lib/module/components/header/Header.js +25 -0
  19. package/lib/module/components/header/Header.js.map +1 -0
  20. package/lib/module/components/header/header-buttons.js +65 -0
  21. package/lib/module/components/header/header-buttons.js.map +1 -0
  22. package/lib/module/components/header/index.js +7 -0
  23. package/lib/module/components/header/index.js.map +1 -0
  24. package/lib/module/components/header/variants/LargeTitleHeader/index.js +335 -0
  25. package/lib/module/components/header/variants/LargeTitleHeader/index.js.map +1 -0
  26. package/lib/module/components/header/variants/TitleHeader/index.js +184 -0
  27. package/lib/module/components/header/variants/TitleHeader/index.js.map +1 -0
  28. package/lib/module/components/icon/Icon.js +53 -0
  29. package/lib/module/components/icon/Icon.js.map +1 -0
  30. package/lib/module/components/icon/index.js +4 -0
  31. package/lib/module/components/icon/index.js.map +1 -0
  32. package/lib/module/components/icon/utils.js +188 -0
  33. package/lib/module/components/icon/utils.js.map +1 -0
  34. package/lib/module/components/index.js +16 -0
  35. package/lib/module/components/index.js.map +1 -0
  36. package/lib/module/components/page-indicator/PageIndicator.js +49 -0
  37. package/lib/module/components/page-indicator/PageIndicator.js.map +1 -0
  38. package/lib/module/components/page-indicator/PageIndicatorRoot.js +24 -0
  39. package/lib/module/components/page-indicator/PageIndicatorRoot.js.map +1 -0
  40. package/lib/module/components/page-indicator/hooks/use-page-indicator-colors.js +24 -0
  41. package/lib/module/components/page-indicator/hooks/use-page-indicator-colors.js.map +1 -0
  42. package/lib/module/components/page-indicator/hooks/use-page-indicator-core.js +20 -0
  43. package/lib/module/components/page-indicator/hooks/use-page-indicator-core.js.map +1 -0
  44. package/lib/module/components/page-indicator/hooks/use-page-indicator-progress.js +68 -0
  45. package/lib/module/components/page-indicator/hooks/use-page-indicator-progress.js.map +1 -0
  46. package/lib/module/components/page-indicator/index.js +5 -0
  47. package/lib/module/components/page-indicator/index.js.map +1 -0
  48. package/lib/module/components/page-indicator/utils.js +127 -0
  49. package/lib/module/components/page-indicator/utils.js.map +1 -0
  50. package/lib/module/components/page-indicator/variants/DotIndicator/InactiveDot.js +50 -0
  51. package/lib/module/components/page-indicator/variants/DotIndicator/InactiveDot.js.map +1 -0
  52. package/lib/module/components/page-indicator/variants/DotIndicator/LoadingOrbit.js +165 -0
  53. package/lib/module/components/page-indicator/variants/DotIndicator/LoadingOrbit.js.map +1 -0
  54. package/lib/module/components/page-indicator/variants/DotIndicator/TravelingPill.js +60 -0
  55. package/lib/module/components/page-indicator/variants/DotIndicator/TravelingPill.js.map +1 -0
  56. package/lib/module/components/page-indicator/variants/DotIndicator/index.js +87 -0
  57. package/lib/module/components/page-indicator/variants/DotIndicator/index.js.map +1 -0
  58. package/lib/module/components/page-indicator/variants/DotIndicator/utils.js +28 -0
  59. package/lib/module/components/page-indicator/variants/DotIndicator/utils.js.map +1 -0
  60. package/lib/module/components/page-indicator/variants/PillIndicator/PillIndicatorDot.js +53 -0
  61. package/lib/module/components/page-indicator/variants/PillIndicator/PillIndicatorDot.js.map +1 -0
  62. package/lib/module/components/page-indicator/variants/PillIndicator/index.js +76 -0
  63. package/lib/module/components/page-indicator/variants/PillIndicator/index.js.map +1 -0
  64. package/lib/module/components/page-indicator/variants/PillIndicator/utils.js +47 -0
  65. package/lib/module/components/page-indicator/variants/PillIndicator/utils.js.map +1 -0
  66. package/lib/module/components/portal/PortalContext.js +20 -0
  67. package/lib/module/components/portal/PortalContext.js.map +1 -0
  68. package/lib/module/components/portal/PortalHost.js +23 -0
  69. package/lib/module/components/portal/PortalHost.js.map +1 -0
  70. package/lib/module/components/portal/PortalProvider.js +40 -0
  71. package/lib/module/components/portal/PortalProvider.js.map +1 -0
  72. package/lib/module/components/portal/index.js +6 -0
  73. package/lib/module/components/portal/index.js.map +1 -0
  74. package/lib/module/components/screen/Screen.js +100 -0
  75. package/lib/module/components/screen/Screen.js.map +1 -0
  76. package/lib/module/components/screen/ScreenContext.js +66 -0
  77. package/lib/module/components/screen/ScreenContext.js.map +1 -0
  78. package/lib/module/components/screen/ScreenFlatList.js +75 -0
  79. package/lib/module/components/screen/ScreenFlatList.js.map +1 -0
  80. package/lib/module/components/screen/ScreenScrollView.js +82 -0
  81. package/lib/module/components/screen/ScreenScrollView.js.map +1 -0
  82. package/lib/module/components/screen/index.js +7 -0
  83. package/lib/module/components/screen/index.js.map +1 -0
  84. package/lib/module/components/screen/utils.js +13 -0
  85. package/lib/module/components/screen/utils.js.map +1 -0
  86. package/lib/module/components/slot/Slot.js +38 -0
  87. package/lib/module/components/slot/Slot.js.map +1 -0
  88. package/lib/module/components/slot/index.js +10 -0
  89. package/lib/module/components/slot/index.js.map +1 -0
  90. package/lib/module/components/slot/utils.js +55 -0
  91. package/lib/module/components/slot/utils.js.map +1 -0
  92. package/lib/module/components/spinner/Spinner.js +132 -0
  93. package/lib/module/components/spinner/Spinner.js.map +1 -0
  94. package/lib/module/components/spinner/index.js +4 -0
  95. package/lib/module/components/spinner/index.js.map +1 -0
  96. package/lib/module/components/surface/Surface.js +74 -0
  97. package/lib/module/components/surface/Surface.js.map +1 -0
  98. package/lib/module/components/surface/index.js +4 -0
  99. package/lib/module/components/surface/index.js.map +1 -0
  100. package/lib/module/components/text/Text.js +67 -0
  101. package/lib/module/components/text/Text.js.map +1 -0
  102. package/lib/module/components/text/index.js +4 -0
  103. package/lib/module/components/text/index.js.map +1 -0
  104. package/lib/module/components/toast/Toast.js +350 -0
  105. package/lib/module/components/toast/Toast.js.map +1 -0
  106. package/lib/module/components/toast/ToastProvider.js +272 -0
  107. package/lib/module/components/toast/ToastProvider.js.map +1 -0
  108. package/lib/module/components/toast/index.js +5 -0
  109. package/lib/module/components/toast/index.js.map +1 -0
  110. package/lib/module/components/toast/parts/ToastAnimatedItem.js +168 -0
  111. package/lib/module/components/toast/parts/ToastAnimatedItem.js.map +1 -0
  112. package/lib/module/components/toast/types.js +4 -0
  113. package/lib/module/components/toast/types.js.map +1 -0
  114. package/lib/module/components/toast/utils/controller.js +19 -0
  115. package/lib/module/components/toast/utils/controller.js.map +1 -0
  116. package/lib/module/context/ThemeProvider.js +66 -0
  117. package/lib/module/context/ThemeProvider.js.map +1 -0
  118. package/lib/module/context/index.js +4 -0
  119. package/lib/module/context/index.js.map +1 -0
  120. package/lib/module/index.js +8 -0
  121. package/lib/module/index.js.map +1 -0
  122. package/lib/module/package.json +1 -0
  123. package/lib/module/theme/configure.js +152 -0
  124. package/lib/module/theme/configure.js.map +1 -0
  125. package/lib/module/theme/index.js +22 -0
  126. package/lib/module/theme/index.js.map +1 -0
  127. package/lib/module/theme/runtime.js +25 -0
  128. package/lib/module/theme/runtime.js.map +1 -0
  129. package/lib/module/theme/theme.js +121 -0
  130. package/lib/module/theme/theme.js.map +1 -0
  131. package/lib/module/theme/tokens/dark.js +109 -0
  132. package/lib/module/theme/tokens/dark.js.map +1 -0
  133. package/lib/module/theme/tokens/light.js +115 -0
  134. package/lib/module/theme/tokens/light.js.map +1 -0
  135. package/lib/module/theme/tokens/primitives.js +228 -0
  136. package/lib/module/theme/tokens/primitives.js.map +1 -0
  137. package/lib/module/theme/types.js +4 -0
  138. package/lib/module/theme/types.js.map +1 -0
  139. package/lib/module/types.js +2 -0
  140. package/lib/module/types.js.map +1 -0
  141. package/lib/module/utils/accent-utils.js +52 -0
  142. package/lib/module/utils/accent-utils.js.map +1 -0
  143. package/lib/module/utils/color-utils.js +53 -0
  144. package/lib/module/utils/color-utils.js.map +1 -0
  145. package/lib/module/utils/deep-merge.js +28 -0
  146. package/lib/module/utils/deep-merge.js.map +1 -0
  147. package/lib/module/utils/resolve-theme-color.js +20 -0
  148. package/lib/module/utils/resolve-theme-color.js.map +1 -0
  149. package/lib/module/utils/typography.js +13 -0
  150. package/lib/module/utils/typography.js.map +1 -0
  151. package/lib/module/utils/unflatten.js +35 -0
  152. package/lib/module/utils/unflatten.js.map +1 -0
  153. package/lib/typescript/package.json +1 -0
  154. package/lib/typescript/src/components/avatar/Avatar.d.ts +3 -0
  155. package/lib/typescript/src/components/avatar/Avatar.d.ts.map +1 -0
  156. package/lib/typescript/src/components/avatar/index.d.ts +3 -0
  157. package/lib/typescript/src/components/avatar/index.d.ts.map +1 -0
  158. package/lib/typescript/src/components/avatar/types.d.ts +30 -0
  159. package/lib/typescript/src/components/avatar/types.d.ts.map +1 -0
  160. package/lib/typescript/src/components/box/Box.d.ts +12 -0
  161. package/lib/typescript/src/components/box/Box.d.ts.map +1 -0
  162. package/lib/typescript/src/components/box/index.d.ts +4 -0
  163. package/lib/typescript/src/components/box/index.d.ts.map +1 -0
  164. package/lib/typescript/src/components/box/utils.d.ts +39 -0
  165. package/lib/typescript/src/components/box/utils.d.ts.map +1 -0
  166. package/lib/typescript/src/components/button/Button.d.ts +46 -0
  167. package/lib/typescript/src/components/button/Button.d.ts.map +1 -0
  168. package/lib/typescript/src/components/button/index.d.ts +3 -0
  169. package/lib/typescript/src/components/button/index.d.ts.map +1 -0
  170. package/lib/typescript/src/components/header/Header.d.ts +22 -0
  171. package/lib/typescript/src/components/header/Header.d.ts.map +1 -0
  172. package/lib/typescript/src/components/header/header-buttons.d.ts +16 -0
  173. package/lib/typescript/src/components/header/header-buttons.d.ts.map +1 -0
  174. package/lib/typescript/src/components/header/index.d.ts +7 -0
  175. package/lib/typescript/src/components/header/index.d.ts.map +1 -0
  176. package/lib/typescript/src/components/header/variants/LargeTitleHeader/index.d.ts +25 -0
  177. package/lib/typescript/src/components/header/variants/LargeTitleHeader/index.d.ts.map +1 -0
  178. package/lib/typescript/src/components/header/variants/TitleHeader/index.d.ts +28 -0
  179. package/lib/typescript/src/components/header/variants/TitleHeader/index.d.ts.map +1 -0
  180. package/lib/typescript/src/components/icon/Icon.d.ts +22 -0
  181. package/lib/typescript/src/components/icon/Icon.d.ts.map +1 -0
  182. package/lib/typescript/src/components/icon/index.d.ts +3 -0
  183. package/lib/typescript/src/components/icon/index.d.ts.map +1 -0
  184. package/lib/typescript/src/components/icon/utils.d.ts +4 -0
  185. package/lib/typescript/src/components/icon/utils.d.ts.map +1 -0
  186. package/lib/typescript/src/components/index.d.ts +14 -0
  187. package/lib/typescript/src/components/index.d.ts.map +1 -0
  188. package/lib/typescript/src/components/page-indicator/PageIndicator.d.ts +48 -0
  189. package/lib/typescript/src/components/page-indicator/PageIndicator.d.ts.map +1 -0
  190. package/lib/typescript/src/components/page-indicator/PageIndicatorRoot.d.ts +13 -0
  191. package/lib/typescript/src/components/page-indicator/PageIndicatorRoot.d.ts.map +1 -0
  192. package/lib/typescript/src/components/page-indicator/hooks/use-page-indicator-colors.d.ts +14 -0
  193. package/lib/typescript/src/components/page-indicator/hooks/use-page-indicator-colors.d.ts.map +1 -0
  194. package/lib/typescript/src/components/page-indicator/hooks/use-page-indicator-core.d.ts +11 -0
  195. package/lib/typescript/src/components/page-indicator/hooks/use-page-indicator-core.d.ts.map +1 -0
  196. package/lib/typescript/src/components/page-indicator/hooks/use-page-indicator-progress.d.ts +19 -0
  197. package/lib/typescript/src/components/page-indicator/hooks/use-page-indicator-progress.d.ts.map +1 -0
  198. package/lib/typescript/src/components/page-indicator/index.d.ts +4 -0
  199. package/lib/typescript/src/components/page-indicator/index.d.ts.map +1 -0
  200. package/lib/typescript/src/components/page-indicator/utils.d.ts +36 -0
  201. package/lib/typescript/src/components/page-indicator/utils.d.ts.map +1 -0
  202. package/lib/typescript/src/components/page-indicator/variants/DotIndicator/InactiveDot.d.ts +14 -0
  203. package/lib/typescript/src/components/page-indicator/variants/DotIndicator/InactiveDot.d.ts.map +1 -0
  204. package/lib/typescript/src/components/page-indicator/variants/DotIndicator/LoadingOrbit.d.ts +11 -0
  205. package/lib/typescript/src/components/page-indicator/variants/DotIndicator/LoadingOrbit.d.ts.map +1 -0
  206. package/lib/typescript/src/components/page-indicator/variants/DotIndicator/TravelingPill.d.ts +15 -0
  207. package/lib/typescript/src/components/page-indicator/variants/DotIndicator/TravelingPill.d.ts.map +1 -0
  208. package/lib/typescript/src/components/page-indicator/variants/DotIndicator/index.d.ts +32 -0
  209. package/lib/typescript/src/components/page-indicator/variants/DotIndicator/index.d.ts.map +1 -0
  210. package/lib/typescript/src/components/page-indicator/variants/DotIndicator/utils.d.ts +14 -0
  211. package/lib/typescript/src/components/page-indicator/variants/DotIndicator/utils.d.ts.map +1 -0
  212. package/lib/typescript/src/components/page-indicator/variants/PillIndicator/PillIndicatorDot.d.ts +16 -0
  213. package/lib/typescript/src/components/page-indicator/variants/PillIndicator/PillIndicatorDot.d.ts.map +1 -0
  214. package/lib/typescript/src/components/page-indicator/variants/PillIndicator/index.d.ts +28 -0
  215. package/lib/typescript/src/components/page-indicator/variants/PillIndicator/index.d.ts.map +1 -0
  216. package/lib/typescript/src/components/page-indicator/variants/PillIndicator/utils.d.ts +21 -0
  217. package/lib/typescript/src/components/page-indicator/variants/PillIndicator/utils.d.ts.map +1 -0
  218. package/lib/typescript/src/components/portal/PortalContext.d.ts +19 -0
  219. package/lib/typescript/src/components/portal/PortalContext.d.ts.map +1 -0
  220. package/lib/typescript/src/components/portal/PortalHost.d.ts +7 -0
  221. package/lib/typescript/src/components/portal/PortalHost.d.ts.map +1 -0
  222. package/lib/typescript/src/components/portal/PortalProvider.d.ts +11 -0
  223. package/lib/typescript/src/components/portal/PortalProvider.d.ts.map +1 -0
  224. package/lib/typescript/src/components/portal/index.d.ts +6 -0
  225. package/lib/typescript/src/components/portal/index.d.ts.map +1 -0
  226. package/lib/typescript/src/components/screen/Screen.d.ts +53 -0
  227. package/lib/typescript/src/components/screen/Screen.d.ts.map +1 -0
  228. package/lib/typescript/src/components/screen/ScreenContext.d.ts +64 -0
  229. package/lib/typescript/src/components/screen/ScreenContext.d.ts.map +1 -0
  230. package/lib/typescript/src/components/screen/ScreenFlatList.d.ts +26 -0
  231. package/lib/typescript/src/components/screen/ScreenFlatList.d.ts.map +1 -0
  232. package/lib/typescript/src/components/screen/ScreenScrollView.d.ts +36 -0
  233. package/lib/typescript/src/components/screen/ScreenScrollView.d.ts.map +1 -0
  234. package/lib/typescript/src/components/screen/index.d.ts +9 -0
  235. package/lib/typescript/src/components/screen/index.d.ts.map +1 -0
  236. package/lib/typescript/src/components/screen/utils.d.ts +10 -0
  237. package/lib/typescript/src/components/screen/utils.d.ts.map +1 -0
  238. package/lib/typescript/src/components/slot/Slot.d.ts +17 -0
  239. package/lib/typescript/src/components/slot/Slot.d.ts.map +1 -0
  240. package/lib/typescript/src/components/slot/index.d.ts +8 -0
  241. package/lib/typescript/src/components/slot/index.d.ts.map +1 -0
  242. package/lib/typescript/src/components/slot/utils.d.ts +17 -0
  243. package/lib/typescript/src/components/slot/utils.d.ts.map +1 -0
  244. package/lib/typescript/src/components/spinner/Spinner.d.ts +18 -0
  245. package/lib/typescript/src/components/spinner/Spinner.d.ts.map +1 -0
  246. package/lib/typescript/src/components/spinner/index.d.ts +3 -0
  247. package/lib/typescript/src/components/spinner/index.d.ts.map +1 -0
  248. package/lib/typescript/src/components/surface/Surface.d.ts +31 -0
  249. package/lib/typescript/src/components/surface/Surface.d.ts.map +1 -0
  250. package/lib/typescript/src/components/surface/index.d.ts +3 -0
  251. package/lib/typescript/src/components/surface/index.d.ts.map +1 -0
  252. package/lib/typescript/src/components/text/Text.d.ts +23 -0
  253. package/lib/typescript/src/components/text/Text.d.ts.map +1 -0
  254. package/lib/typescript/src/components/text/index.d.ts +3 -0
  255. package/lib/typescript/src/components/text/index.d.ts.map +1 -0
  256. package/lib/typescript/src/components/toast/Toast.d.ts +71 -0
  257. package/lib/typescript/src/components/toast/Toast.d.ts.map +1 -0
  258. package/lib/typescript/src/components/toast/ToastProvider.d.ts +4 -0
  259. package/lib/typescript/src/components/toast/ToastProvider.d.ts.map +1 -0
  260. package/lib/typescript/src/components/toast/index.d.ts +5 -0
  261. package/lib/typescript/src/components/toast/index.d.ts.map +1 -0
  262. package/lib/typescript/src/components/toast/parts/ToastAnimatedItem.d.ts +18 -0
  263. package/lib/typescript/src/components/toast/parts/ToastAnimatedItem.d.ts.map +1 -0
  264. package/lib/typescript/src/components/toast/types.d.ts +62 -0
  265. package/lib/typescript/src/components/toast/types.d.ts.map +1 -0
  266. package/lib/typescript/src/components/toast/utils/controller.d.ts +5 -0
  267. package/lib/typescript/src/components/toast/utils/controller.d.ts.map +1 -0
  268. package/lib/typescript/src/context/ThemeProvider.d.ts +29 -0
  269. package/lib/typescript/src/context/ThemeProvider.d.ts.map +1 -0
  270. package/lib/typescript/src/context/index.d.ts +3 -0
  271. package/lib/typescript/src/context/index.d.ts.map +1 -0
  272. package/lib/typescript/src/index.d.ts +4 -0
  273. package/lib/typescript/src/index.d.ts.map +1 -0
  274. package/lib/typescript/src/theme/configure.d.ts +47 -0
  275. package/lib/typescript/src/theme/configure.d.ts.map +1 -0
  276. package/lib/typescript/src/theme/index.d.ts +11 -0
  277. package/lib/typescript/src/theme/index.d.ts.map +1 -0
  278. package/lib/typescript/src/theme/runtime.d.ts +7 -0
  279. package/lib/typescript/src/theme/runtime.d.ts.map +1 -0
  280. package/lib/typescript/src/theme/theme.d.ts +22 -0
  281. package/lib/typescript/src/theme/theme.d.ts.map +1 -0
  282. package/lib/typescript/src/theme/tokens/dark.d.ts +100 -0
  283. package/lib/typescript/src/theme/tokens/dark.d.ts.map +1 -0
  284. package/lib/typescript/src/theme/tokens/light.d.ts +106 -0
  285. package/lib/typescript/src/theme/tokens/light.d.ts.map +1 -0
  286. package/lib/typescript/src/theme/tokens/primitives.d.ts +212 -0
  287. package/lib/typescript/src/theme/tokens/primitives.d.ts.map +1 -0
  288. package/lib/typescript/src/theme/types.d.ts +273 -0
  289. package/lib/typescript/src/theme/types.d.ts.map +1 -0
  290. package/lib/typescript/src/types.d.ts +4 -0
  291. package/lib/typescript/src/types.d.ts.map +1 -0
  292. package/lib/typescript/src/utils/accent-utils.d.ts +4 -0
  293. package/lib/typescript/src/utils/accent-utils.d.ts.map +1 -0
  294. package/lib/typescript/src/utils/color-utils.d.ts +11 -0
  295. package/lib/typescript/src/utils/color-utils.d.ts.map +1 -0
  296. package/lib/typescript/src/utils/deep-merge.d.ts +11 -0
  297. package/lib/typescript/src/utils/deep-merge.d.ts.map +1 -0
  298. package/lib/typescript/src/utils/resolve-theme-color.d.ts +12 -0
  299. package/lib/typescript/src/utils/resolve-theme-color.d.ts.map +1 -0
  300. package/lib/typescript/src/utils/typography.d.ts +6 -0
  301. package/lib/typescript/src/utils/typography.d.ts.map +1 -0
  302. package/lib/typescript/src/utils/unflatten.d.ts +12 -0
  303. package/lib/typescript/src/utils/unflatten.d.ts.map +1 -0
  304. package/package.json +137 -0
  305. package/src/components/avatar/Avatar.tsx +146 -0
  306. package/src/components/avatar/index.ts +8 -0
  307. package/src/components/avatar/types.ts +35 -0
  308. package/src/components/box/Box.tsx +59 -0
  309. package/src/components/box/index.ts +8 -0
  310. package/src/components/box/utils.ts +181 -0
  311. package/src/components/button/Button.tsx +313 -0
  312. package/src/components/button/index.ts +8 -0
  313. package/src/components/header/Header.ts +22 -0
  314. package/src/components/header/header-buttons.tsx +103 -0
  315. package/src/components/header/index.ts +11 -0
  316. package/src/components/header/variants/LargeTitleHeader/index.tsx +390 -0
  317. package/src/components/header/variants/TitleHeader/index.tsx +194 -0
  318. package/src/components/icon/Icon.tsx +74 -0
  319. package/src/components/icon/index.ts +2 -0
  320. package/src/components/icon/utils.tsx +147 -0
  321. package/src/components/index.ts +13 -0
  322. package/src/components/page-indicator/PageIndicator.tsx +100 -0
  323. package/src/components/page-indicator/PageIndicatorRoot.tsx +41 -0
  324. package/src/components/page-indicator/hooks/use-page-indicator-colors.ts +65 -0
  325. package/src/components/page-indicator/hooks/use-page-indicator-core.ts +34 -0
  326. package/src/components/page-indicator/hooks/use-page-indicator-progress.ts +122 -0
  327. package/src/components/page-indicator/index.ts +13 -0
  328. package/src/components/page-indicator/utils.ts +208 -0
  329. package/src/components/page-indicator/variants/DotIndicator/InactiveDot.tsx +70 -0
  330. package/src/components/page-indicator/variants/DotIndicator/LoadingOrbit.tsx +201 -0
  331. package/src/components/page-indicator/variants/DotIndicator/TravelingPill.tsx +80 -0
  332. package/src/components/page-indicator/variants/DotIndicator/index.tsx +145 -0
  333. package/src/components/page-indicator/variants/DotIndicator/utils.ts +28 -0
  334. package/src/components/page-indicator/variants/PillIndicator/PillIndicatorDot.tsx +107 -0
  335. package/src/components/page-indicator/variants/PillIndicator/index.tsx +149 -0
  336. package/src/components/page-indicator/variants/PillIndicator/utils.ts +63 -0
  337. package/src/components/portal/PortalContext.tsx +27 -0
  338. package/src/components/portal/PortalHost.tsx +20 -0
  339. package/src/components/portal/PortalProvider.tsx +44 -0
  340. package/src/components/portal/index.ts +5 -0
  341. package/src/components/screen/Screen.tsx +163 -0
  342. package/src/components/screen/ScreenContext.tsx +144 -0
  343. package/src/components/screen/ScreenFlatList.tsx +121 -0
  344. package/src/components/screen/ScreenScrollView.tsx +130 -0
  345. package/src/components/screen/index.ts +8 -0
  346. package/src/components/screen/utils.ts +17 -0
  347. package/src/components/slot/Slot.tsx +56 -0
  348. package/src/components/slot/index.ts +8 -0
  349. package/src/components/slot/utils.ts +61 -0
  350. package/src/components/spinner/Spinner.tsx +153 -0
  351. package/src/components/spinner/index.ts +2 -0
  352. package/src/components/surface/Surface.tsx +100 -0
  353. package/src/components/surface/index.ts +2 -0
  354. package/src/components/text/Text.tsx +115 -0
  355. package/src/components/text/index.ts +2 -0
  356. package/src/components/toast/Toast.tsx +477 -0
  357. package/src/components/toast/ToastProvider.tsx +403 -0
  358. package/src/components/toast/index.ts +26 -0
  359. package/src/components/toast/parts/ToastAnimatedItem.tsx +184 -0
  360. package/src/components/toast/types.ts +75 -0
  361. package/src/components/toast/utils/controller.ts +23 -0
  362. package/src/context/ThemeProvider.tsx +97 -0
  363. package/src/context/index.ts +2 -0
  364. package/src/index.tsx +6 -0
  365. package/src/theme/configure.ts +215 -0
  366. package/src/theme/index.ts +72 -0
  367. package/src/theme/runtime.ts +27 -0
  368. package/src/theme/theme.ts +152 -0
  369. package/src/theme/tokens/dark.ts +117 -0
  370. package/src/theme/tokens/light.ts +123 -0
  371. package/src/theme/tokens/primitives.ts +232 -0
  372. package/src/theme/types.ts +384 -0
  373. package/src/types.ts +1 -0
  374. package/src/utils/accent-utils.ts +58 -0
  375. package/src/utils/color-utils.ts +51 -0
  376. package/src/utils/deep-merge.ts +36 -0
  377. package/src/utils/resolve-theme-color.ts +27 -0
  378. package/src/utils/typography.ts +15 -0
  379. package/src/utils/unflatten.ts +36 -0
@@ -0,0 +1,100 @@
1
+ import { type ComponentRef, forwardRef } from 'react';
2
+ import type { View, ViewStyle } from 'react-native';
3
+
4
+ import { useUnistyles } from 'react-native-unistyles';
5
+
6
+ import { getDefaultRadius, getSurfaceElevation } from '#theme/configure';
7
+ import type { ColorToken, ElevationKey } from '#theme/types';
8
+
9
+ import { type BorderWidthInput, Box, type BoxProps } from '../box';
10
+
11
+ /** Background level of a {@link Surface}. */
12
+ export type SurfaceVariant = 'base' | 'raised' | 'sunken' | 'transparent';
13
+
14
+ export interface SurfaceProps extends Omit<BoxProps, 'bg'> {
15
+ /** Background surface level. Defaults to `'base'`. */
16
+ variant?: SurfaceVariant;
17
+ /**
18
+ * Drop-shadow depth (platform-aware shadow + Android elevation).
19
+ * Defaults to `'sm'` for `variant="raised"`, otherwise the configured
20
+ * surface elevation (`'none'` if unset). Note: a shadow needs a
21
+ * non-transparent background to render, so `variant="transparent"` shows no
22
+ * shadow.
23
+ */
24
+ elevation?: ElevationKey;
25
+ }
26
+
27
+ const VARIANT_BG: Record<SurfaceVariant, ColorToken> = {
28
+ base: 'surface.default',
29
+ raised: 'surface.raised',
30
+ sunken: 'surface.sunken',
31
+ transparent: 'transparent',
32
+ };
33
+
34
+ /** Variant-aware hairline borders improve edge definition when fills are close. */
35
+ const VARIANT_BORDER: Record<
36
+ SurfaceVariant,
37
+ { borderWidth?: BorderWidthInput; borderColor?: ColorToken }
38
+ > = {
39
+ base: {},
40
+ raised: { borderWidth: 'hairline', borderColor: 'border.subtle' },
41
+ sunken: { borderWidth: 'hairline', borderColor: 'border.default' },
42
+ transparent: {},
43
+ };
44
+
45
+ const resolveElevation = (
46
+ variant: SurfaceVariant,
47
+ elevation?: ElevationKey
48
+ ): ElevationKey => {
49
+ if (elevation !== undefined) return elevation;
50
+ if (variant === 'raised') return 'sm';
51
+ return getSurfaceElevation();
52
+ };
53
+
54
+ /**
55
+ * Themed container built on {@link Box}. Picks its background from a semantic
56
+ * surface `variant`, its corner radius from the configured `surface`
57
+ * default (overridable via `radius`), and an optional drop shadow via
58
+ * `elevation`. All other Box style-props are accepted.
59
+ *
60
+ * @example
61
+ * ```tsx
62
+ * <Surface variant="raised" elevation="md" p="4" radius="lg">
63
+ * <Text variant="title-sm">Card title</Text>
64
+ * </Surface>
65
+ * ```
66
+ */
67
+ export const Surface = forwardRef<ComponentRef<typeof View>, SurfaceProps>(
68
+ function Surface(
69
+ {
70
+ variant = 'base',
71
+ elevation,
72
+ radius,
73
+ borderWidth,
74
+ borderColor,
75
+ style,
76
+ ...rest
77
+ },
78
+ ref
79
+ ) {
80
+ const { theme } = useUnistyles();
81
+ const resolvedElevation = resolveElevation(variant, elevation);
82
+ const variantBorder = VARIANT_BORDER[variant];
83
+ const shadowStyle =
84
+ variant !== 'transparent' && resolvedElevation !== 'none'
85
+ ? (theme.elevation[resolvedElevation] as ViewStyle)
86
+ : undefined;
87
+
88
+ return (
89
+ <Box
90
+ ref={ref}
91
+ bg={VARIANT_BG[variant]}
92
+ radius={radius ?? getDefaultRadius('surface')}
93
+ borderWidth={borderWidth ?? variantBorder.borderWidth}
94
+ borderColor={borderColor ?? variantBorder.borderColor}
95
+ style={shadowStyle ? [shadowStyle, style] : style}
96
+ {...rest}
97
+ />
98
+ );
99
+ }
100
+ );
@@ -0,0 +1,2 @@
1
+ export type { SurfaceProps, SurfaceVariant } from './Surface';
2
+ export { Surface } from './Surface';
@@ -0,0 +1,115 @@
1
+ import { type ComponentRef, forwardRef } from 'react';
2
+ import {
3
+ Text as RNText,
4
+ type TextProps as RNTextProps,
5
+ type TextStyle,
6
+ } from 'react-native';
7
+
8
+ import { useUnistyles } from 'react-native-unistyles';
9
+ import type {
10
+ ColorToken,
11
+ FontWeightToken,
12
+ HeadingTextVariant,
13
+ RoleTextVariant,
14
+ TextVariant,
15
+ } from '#theme/types';
16
+ import type { Mutable } from '#types';
17
+ import { resolveThemeColor } from '#utils/resolve-theme-color';
18
+ import { FONT_WEIGHT_VALUE, SYSTEM_FONT } from '#utils/typography';
19
+
20
+ export type TextAlign = 'left' | 'center' | 'right' | 'justify';
21
+
22
+ const HEADING_VARIANT_ALIAS: Record<HeadingTextVariant, RoleTextVariant> = {
23
+ h1: 'headline-lg',
24
+ h2: 'headline-md',
25
+ h3: 'title-lg',
26
+ h4: 'title-md',
27
+ h5: 'title-sm',
28
+ h6: 'label-lg',
29
+ };
30
+
31
+ function resolveTextVariant(variant: TextVariant): RoleTextVariant {
32
+ return variant in HEADING_VARIANT_ALIAS
33
+ ? HEADING_VARIANT_ALIAS[variant as HeadingTextVariant]
34
+ : (variant as RoleTextVariant);
35
+ }
36
+
37
+ export interface TextProps extends RNTextProps {
38
+ /** Typographic role. Defaults to `body-md`. */
39
+ variant?: TextVariant;
40
+ /** Semantic color token (e.g. `content.secondary`, `status.danger.solid`). */
41
+ color?: ColorToken;
42
+ /** Override the variant's default weight. */
43
+ weight?: FontWeightToken;
44
+ align?: TextAlign;
45
+ italic?: boolean;
46
+ underline?: boolean;
47
+ strikeThrough?: boolean;
48
+ /** Truncate to a single line with a trailing ellipsis. */
49
+ isTruncated?: boolean;
50
+ }
51
+
52
+ /**
53
+ * Themed text primitive. Reads its scale from `theme.typography` and resolves
54
+ * fonts by weight, honoring Dynamic Type with a per-variant scaling cap.
55
+ */
56
+ export const Text = forwardRef<ComponentRef<typeof RNText>, TextProps>(
57
+ function Text(
58
+ {
59
+ variant = 'body-md',
60
+ color,
61
+ weight,
62
+ align,
63
+ italic,
64
+ underline,
65
+ strikeThrough,
66
+ isTruncated,
67
+ style,
68
+ numberOfLines,
69
+ ellipsizeMode,
70
+ maxFontSizeMultiplier,
71
+ ...rest
72
+ },
73
+ ref
74
+ ) {
75
+ const { theme } = useUnistyles();
76
+ const resolvedVariant = resolveTextVariant(variant);
77
+ const v = theme.typography.variants[resolvedVariant];
78
+ const effectiveWeight: FontWeightToken = weight ?? v.fontWeight;
79
+ const fontFamily = theme.typography.fonts[effectiveWeight];
80
+ const isSystemFont = fontFamily === SYSTEM_FONT;
81
+
82
+ const base: Mutable<TextStyle> = {
83
+ fontSize: v.fontSize,
84
+ lineHeight: v.lineHeight,
85
+ letterSpacing: v.letterSpacing,
86
+ color:
87
+ resolveThemeColor(color, theme) ??
88
+ (theme.color as unknown as Record<string, string | undefined>)[
89
+ 'text.default'
90
+ ] ??
91
+ '',
92
+ };
93
+ // System font: apply numeric weight. Custom font: family encodes the weight.
94
+ if (isSystemFont) base.fontWeight = FONT_WEIGHT_VALUE[effectiveWeight];
95
+ else base.fontFamily = fontFamily;
96
+
97
+ if (align) base.textAlign = align;
98
+ if (italic) base.fontStyle = 'italic';
99
+ if (underline && strikeThrough)
100
+ base.textDecorationLine = 'underline line-through';
101
+ else if (underline) base.textDecorationLine = 'underline';
102
+ else if (strikeThrough) base.textDecorationLine = 'line-through';
103
+
104
+ return (
105
+ <RNText
106
+ ref={ref}
107
+ style={[base, style]}
108
+ maxFontSizeMultiplier={maxFontSizeMultiplier ?? v.maxFontSizeMultiplier}
109
+ numberOfLines={isTruncated ? 1 : numberOfLines}
110
+ ellipsizeMode={isTruncated ? 'tail' : ellipsizeMode}
111
+ {...rest}
112
+ />
113
+ );
114
+ }
115
+ );
@@ -0,0 +1,2 @@
1
+ export type { TextAlign, TextProps } from './Text';
2
+ export { Text } from './Text';
@@ -0,0 +1,477 @@
1
+ import {
2
+ type ComponentRef,
3
+ createContext,
4
+ forwardRef,
5
+ type ReactNode,
6
+ useContext,
7
+ useId,
8
+ useMemo,
9
+ } from 'react';
10
+ import type { GestureResponderEvent, PressableProps, View } from 'react-native';
11
+ import { Pressable, StyleSheet } from 'react-native';
12
+
13
+ import { useUnistyles } from 'react-native-unistyles';
14
+
15
+ import type { TerraIconName, TerraTheme } from '#theme/types';
16
+
17
+ import { Box } from '../box';
18
+ import { Button, type ButtonProps } from '../button';
19
+ import { Icon, type IconProps } from '../icon';
20
+ import { Surface, type SurfaceProps } from '../surface';
21
+ import { Text, type TextProps } from '../text';
22
+ import type { ToastId as StackToastId, ToastShowOptions } from './types';
23
+ import { hideToast, showToast } from './utils/controller';
24
+
25
+ export type ToastVariant =
26
+ | 'default'
27
+ | 'accent'
28
+ | 'info'
29
+ | 'success'
30
+ | 'warning'
31
+ | 'danger';
32
+
33
+ type ToastInstanceId = string | number;
34
+
35
+ export interface ToastControls {
36
+ hide?: (id: ToastInstanceId) => void;
37
+ id?: ToastInstanceId;
38
+ }
39
+
40
+ interface ToastContextValue extends ToastControls {
41
+ nativeID: string;
42
+ variant: ToastVariant;
43
+ onClose?: () => void;
44
+ }
45
+
46
+ const ToastContext = createContext<ToastContextValue | null>(null);
47
+
48
+ function useToastContext(): ToastContextValue {
49
+ const context = useContext(ToastContext);
50
+ if (!context) {
51
+ throw new Error(
52
+ 'Toast compound components must be rendered inside <Toast>.'
53
+ );
54
+ }
55
+ return context;
56
+ }
57
+
58
+ interface ToastColors {
59
+ bg: string;
60
+ border: string;
61
+ title: string;
62
+ description: string;
63
+ icon: string;
64
+ actionBg: string;
65
+ actionFg: string;
66
+ }
67
+
68
+ function getToastColors(variant: ToastVariant, theme: TerraTheme): ToastColors {
69
+ const c = theme.color as unknown as Record<string, string | undefined>;
70
+ const get = (key: string): string => c[key] ?? '';
71
+ const base = {
72
+ bg: get('surface.default'),
73
+ border: get('border.subtle'),
74
+ description: get('text.muted'),
75
+ };
76
+
77
+ switch (variant) {
78
+ case 'accent':
79
+ return {
80
+ ...base,
81
+ title: get('action.fg.subtle'),
82
+ icon: get('text.accent'),
83
+ actionBg: get('action.bg.primary'),
84
+ actionFg: get('action.fg.primary'),
85
+ };
86
+ case 'info':
87
+ case 'success':
88
+ case 'warning':
89
+ case 'danger':
90
+ return {
91
+ ...base,
92
+ title: get(`status.bg.${variant}`),
93
+ icon: get(`status.bg.${variant}`),
94
+ actionBg: get(`status.bg.${variant}`),
95
+ actionFg: get(`status.fg.${variant}`),
96
+ };
97
+ case 'default':
98
+ return {
99
+ ...base,
100
+ title: get('text.default'),
101
+ icon: get('text.subtle'),
102
+ actionBg: get('action.bg.neutral.hover'),
103
+ actionFg: get('action.fg.neutral'),
104
+ };
105
+ }
106
+ }
107
+
108
+ export interface ToastProps extends Omit<SurfaceProps, 'id' | 'variant'> {
109
+ /** Visual tone for the toast. Defaults to `default`. */
110
+ variant?: ToastVariant;
111
+ /** Optional identifier passed back to `hide` when `Toast.Close` is pressed. */
112
+ id?: ToastInstanceId;
113
+ /** Imperative hide callback used by toast queues/providers. */
114
+ hide?: (id: ToastInstanceId) => void;
115
+ /** Local close callback used by `Toast.Close`. */
116
+ onClose?: () => void;
117
+ }
118
+
119
+ const ToastRoot = forwardRef<ComponentRef<typeof View>, ToastProps>(
120
+ function Toast(
121
+ {
122
+ variant = 'default',
123
+ id,
124
+ hide,
125
+ onClose,
126
+ children,
127
+ nativeID: nativeIDProp,
128
+ style,
129
+ accessibilityRole = 'alert',
130
+ ...rest
131
+ },
132
+ ref
133
+ ) {
134
+ const { theme } = useUnistyles();
135
+ const generatedNativeID = useId();
136
+ const nativeID = nativeIDProp ?? String(id ?? generatedNativeID);
137
+ const colors = getToastColors(variant, theme);
138
+ const contextValue = useMemo<ToastContextValue>(
139
+ () => ({ nativeID, variant, id, hide, onClose }),
140
+ [nativeID, variant, id, hide, onClose]
141
+ );
142
+
143
+ return (
144
+ <ToastContext.Provider value={contextValue}>
145
+ <Surface
146
+ ref={ref}
147
+ variant="raised"
148
+ elevation="md"
149
+ radius="xl"
150
+ p="4"
151
+ row
152
+ align="center"
153
+ gap="3"
154
+ accessibilityRole={accessibilityRole}
155
+ accessibilityLiveRegion="polite"
156
+ borderWidth="hairline"
157
+ nativeID={nativeID}
158
+ style={[
159
+ styles.root,
160
+ {
161
+ backgroundColor: colors.bg,
162
+ borderColor: colors.border,
163
+ },
164
+ style,
165
+ ]}
166
+ {...rest}
167
+ >
168
+ {children}
169
+ </Surface>
170
+ </ToastContext.Provider>
171
+ );
172
+ }
173
+ );
174
+
175
+ export interface ToastTitleProps extends TextProps {}
176
+
177
+ const ToastTitle = forwardRef<ComponentRef<typeof Text>, ToastTitleProps>(
178
+ function ToastTitle(
179
+ {
180
+ accessibilityRole = 'header',
181
+ color,
182
+ nativeID,
183
+ variant = 'label-lg',
184
+ weight,
185
+ ...rest
186
+ },
187
+ ref
188
+ ) {
189
+ const { theme } = useUnistyles();
190
+ const { nativeID: rootNativeID, variant: toastVariant } = useToastContext();
191
+ const colors = getToastColors(toastVariant, theme);
192
+
193
+ return (
194
+ <Text
195
+ ref={ref}
196
+ accessibilityRole={accessibilityRole}
197
+ color={color ?? colors.title}
198
+ nativeID={nativeID ?? `${rootNativeID}_label`}
199
+ variant={variant}
200
+ weight={weight ?? 'semibold'}
201
+ {...rest}
202
+ />
203
+ );
204
+ }
205
+ );
206
+
207
+ export interface ToastDescriptionProps extends TextProps {}
208
+
209
+ const ToastDescription = forwardRef<
210
+ ComponentRef<typeof Text>,
211
+ ToastDescriptionProps
212
+ >(function ToastDescription(
213
+ { color, nativeID, variant = 'body-sm', ...rest },
214
+ ref
215
+ ) {
216
+ const { theme } = useUnistyles();
217
+ const { nativeID: rootNativeID, variant: toastVariant } = useToastContext();
218
+ const colors = getToastColors(toastVariant, theme);
219
+
220
+ return (
221
+ <Text
222
+ ref={ref}
223
+ color={color ?? colors.description}
224
+ nativeID={nativeID ?? `${rootNativeID}_desc`}
225
+ variant={variant}
226
+ {...rest}
227
+ />
228
+ );
229
+ });
230
+
231
+ export interface ToastActionProps
232
+ extends Omit<PressableProps, 'children' | 'disabled' | 'style'> {
233
+ children?: ReactNode;
234
+ /** Override the action button colour. Defaults to the parent Toast variant. */
235
+ variant?: ToastVariant;
236
+ fullWidth?: boolean;
237
+ isDisabled?: boolean;
238
+ size?: 'sm' | 'md' | 'lg';
239
+ style?: PressableProps['style'];
240
+ }
241
+
242
+ function renderActionChildren(children: ReactNode, color: string): ReactNode {
243
+ if (typeof children === 'string' || typeof children === 'number') {
244
+ return (
245
+ <Text variant="label-lg" weight="semibold" style={{ color }}>
246
+ {children}
247
+ </Text>
248
+ );
249
+ }
250
+ return children;
251
+ }
252
+
253
+ const ToastAction = forwardRef<
254
+ ComponentRef<typeof Pressable>,
255
+ ToastActionProps
256
+ >(function ToastAction(
257
+ {
258
+ children,
259
+ variant,
260
+ fullWidth = false,
261
+ isDisabled = false,
262
+ size = 'sm',
263
+ style,
264
+ onPress,
265
+ ...rest
266
+ },
267
+ ref
268
+ ) {
269
+ const { theme } = useUnistyles();
270
+ const { variant: toastVariant } = useToastContext();
271
+ const colors = getToastColors(variant ?? toastVariant, theme);
272
+
273
+ return (
274
+ <Pressable
275
+ ref={ref}
276
+ accessibilityRole="button"
277
+ accessibilityState={{ disabled: isDisabled }}
278
+ disabled={isDisabled}
279
+ onPress={isDisabled ? undefined : onPress}
280
+ {...rest}
281
+ style={(state) => [
282
+ styles.action,
283
+ styles[`action_${size}`],
284
+ fullWidth ? styles.actionFullWidth : null,
285
+ {
286
+ backgroundColor: colors.actionBg,
287
+ opacity:
288
+ state.pressed && !isDisabled
289
+ ? theme.opacity.pressed
290
+ : isDisabled
291
+ ? theme.opacity.disabled
292
+ : 1,
293
+ },
294
+ typeof style === 'function' ? style(state) : style,
295
+ ]}
296
+ >
297
+ {renderActionChildren(children, colors.actionFg)}
298
+ </Pressable>
299
+ );
300
+ });
301
+
302
+ export interface ToastCloseProps extends Omit<ButtonProps, 'children'> {
303
+ children?: ReactNode;
304
+ iconProps?: Omit<IconProps, 'name'>;
305
+ }
306
+
307
+ const ToastClose = forwardRef<ComponentRef<typeof Button>, ToastCloseProps>(
308
+ function ToastClose(
309
+ {
310
+ children,
311
+ iconProps,
312
+ size = 'sm',
313
+ fullWidth = false,
314
+ isIconOnly = true,
315
+ variant = 'ghost',
316
+ accessibilityLabel = 'Close',
317
+ onPress,
318
+ ...rest
319
+ },
320
+ ref
321
+ ) {
322
+ const { theme } = useUnistyles();
323
+ const { id, hide, onClose, variant: toastVariant } = useToastContext();
324
+ const colors = getToastColors(toastVariant, theme);
325
+ const handlePress = (event: GestureResponderEvent) => {
326
+ if (id !== undefined) hide?.(id);
327
+ onClose?.();
328
+ onPress?.(event);
329
+ };
330
+
331
+ return (
332
+ <Button
333
+ ref={ref}
334
+ accessibilityLabel={accessibilityLabel}
335
+ fullWidth={fullWidth}
336
+ isIconOnly={isIconOnly}
337
+ onPress={handlePress}
338
+ size={size}
339
+ compact
340
+ variant={variant}
341
+ {...rest}
342
+ >
343
+ {children ?? (
344
+ <Icon
345
+ name="navigation.close"
346
+ size={iconProps?.size ?? 20}
347
+ color={iconProps?.color ?? colors.icon}
348
+ strokeWidth={iconProps?.strokeWidth}
349
+ style={iconProps?.style}
350
+ />
351
+ )}
352
+ </Button>
353
+ );
354
+ }
355
+ );
356
+
357
+ export interface ToastIconProps extends Omit<IconProps, 'name'> {
358
+ name?: TerraIconName;
359
+ }
360
+
361
+ const VARIANT_ICON: Partial<Record<ToastVariant, TerraIconName>> = {
362
+ info: 'status.info',
363
+ success: 'status.success',
364
+ warning: 'status.warning',
365
+ danger: 'status.danger',
366
+ };
367
+
368
+ const ToastIcon = forwardRef<ComponentRef<typeof View>, ToastIconProps>(
369
+ function ToastIcon({ name, color, size = 20, ...rest }, ref) {
370
+ const { theme } = useUnistyles();
371
+ const { variant } = useToastContext();
372
+ const colors = getToastColors(variant, theme);
373
+ const iconName = name ?? VARIANT_ICON[variant] ?? 'status.info';
374
+
375
+ return (
376
+ <Icon
377
+ ref={ref}
378
+ color={color ?? colors.icon}
379
+ name={iconName}
380
+ size={size}
381
+ {...rest}
382
+ />
383
+ );
384
+ }
385
+ );
386
+
387
+ export interface DefaultToastProps extends Omit<ToastProps, 'children'> {
388
+ label?: ReactNode;
389
+ description?: ReactNode;
390
+ actionLabel?: ReactNode;
391
+ onActionPress?: (controls: ToastControls) => void;
392
+ icon?: ReactNode | false;
393
+ showCloseButton?: boolean;
394
+ }
395
+
396
+ export function DefaultToast({
397
+ label,
398
+ description,
399
+ actionLabel,
400
+ onActionPress,
401
+ icon,
402
+ showCloseButton,
403
+ id,
404
+ hide,
405
+ variant = 'default',
406
+ ...rest
407
+ }: DefaultToastProps) {
408
+ const shouldRenderIcon = icon !== false && (icon || variant !== 'default');
409
+ const handleActionPress = () => {
410
+ onActionPress?.({ id, hide });
411
+ };
412
+
413
+ return (
414
+ <ToastRoot id={id} hide={hide} variant={variant} {...rest}>
415
+ {shouldRenderIcon ? (
416
+ <Box alignSelf="start">{icon ?? <ToastIcon />}</Box>
417
+ ) : null}
418
+ <Box flex={1} gap="1">
419
+ {label ? <ToastTitle>{label}</ToastTitle> : null}
420
+ {description ? (
421
+ <ToastDescription>{description}</ToastDescription>
422
+ ) : null}
423
+ </Box>
424
+ {actionLabel ? (
425
+ <ToastAction onPress={handleActionPress}>{actionLabel}</ToastAction>
426
+ ) : null}
427
+ {showCloseButton ? <ToastClose /> : null}
428
+ </ToastRoot>
429
+ );
430
+ }
431
+
432
+ type ToastComponent = typeof ToastRoot & {
433
+ Title: typeof ToastTitle;
434
+ Description: typeof ToastDescription;
435
+ Action: typeof ToastAction;
436
+ Close: typeof ToastClose;
437
+ Icon: typeof ToastIcon;
438
+ show: (options: ToastShowOptions) => StackToastId;
439
+ hide: (id?: StackToastId | StackToastId[] | 'all') => void;
440
+ };
441
+
442
+ export const Toast = ToastRoot as ToastComponent;
443
+ Toast.Title = ToastTitle;
444
+ Toast.Description = ToastDescription;
445
+ Toast.Action = ToastAction;
446
+ Toast.Close = ToastClose;
447
+ Toast.Icon = ToastIcon;
448
+ Toast.show = showToast;
449
+ Toast.hide = hideToast;
450
+
451
+ const styles = StyleSheet.create({
452
+ root: {
453
+ alignSelf: 'stretch',
454
+ minHeight: 64,
455
+ },
456
+ action: {
457
+ alignItems: 'center',
458
+ alignSelf: 'flex-start',
459
+ borderRadius: 9999,
460
+ justifyContent: 'center',
461
+ },
462
+ action_sm: {
463
+ minHeight: 36,
464
+ paddingHorizontal: 14,
465
+ },
466
+ action_md: {
467
+ minHeight: 44,
468
+ paddingHorizontal: 16,
469
+ },
470
+ action_lg: {
471
+ minHeight: 52,
472
+ paddingHorizontal: 20,
473
+ },
474
+ actionFullWidth: {
475
+ alignSelf: 'stretch',
476
+ },
477
+ });