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,390 @@
1
+ import { useCallback, useEffect, useId } from 'react';
2
+ import { type LayoutChangeEvent, Text, View } from 'react-native';
3
+
4
+ import Animated, {
5
+ interpolate,
6
+ useAnimatedStyle,
7
+ useSharedValue,
8
+ } from 'react-native-reanimated';
9
+ import { useSafeAreaInsets } from 'react-native-safe-area-context';
10
+ import Svg, {
11
+ Defs,
12
+ Rect,
13
+ Stop,
14
+ LinearGradient as SvgLinearGradient,
15
+ } from 'react-native-svg';
16
+ import { StyleSheet, useUnistyles } from 'react-native-unistyles';
17
+
18
+ import { resolveThemeColor } from '#utils/resolve-theme-color';
19
+ import { FONT_WEIGHT_VALUE } from '#utils/typography';
20
+
21
+ import { usePortal } from '../../../portal';
22
+ import { useScreen } from '../../../screen/ScreenContext';
23
+ import { HeaderDismissButton } from '../../header-buttons';
24
+ import type { TitleHeaderProps } from '../TitleHeader';
25
+
26
+ const AnimatedText = Animated.createAnimatedComponent(Text);
27
+
28
+ /** Compact title offset (px) when the large title is fully expanded. */
29
+ const COMPACT_TITLE_SLIDE_OFFSET = 8;
30
+ /** Large title offset (px) when fully collapsed. */
31
+ const LARGE_TITLE_SLIDE_OFFSET = 6;
32
+
33
+ export interface LargeTitleHeaderProps extends TitleHeaderProps {
34
+ /** Optional secondary line shown under the large title. */
35
+ caption?: string;
36
+ /** Hide the large title (keeps the compact bar). Defaults to `false`. */
37
+ isLargeTitleHidden?: boolean;
38
+ }
39
+
40
+ function LargeTitlePortalContent({
41
+ title,
42
+ caption,
43
+ onLayout,
44
+ }: Pick<LargeTitleHeaderProps, 'title' | 'caption'> & {
45
+ onLayout: (event: LayoutChangeEvent) => void;
46
+ }) {
47
+ const { theme } = useUnistyles();
48
+ const { scrollY, headerCollapseHeight } = useScreen();
49
+
50
+ const largeTitleAnimatedStyle = useAnimatedStyle(() => {
51
+ const height = headerCollapseHeight.value;
52
+ if (height <= 0) {
53
+ return { opacity: 1, transform: [{ translateY: 0 }] };
54
+ }
55
+
56
+ return {
57
+ opacity: interpolate(scrollY.value, [0, height], [1, 0], 'clamp'),
58
+ transform: [
59
+ {
60
+ translateY: interpolate(
61
+ scrollY.value,
62
+ [0, height],
63
+ [0, -LARGE_TITLE_SLIDE_OFFSET],
64
+ 'clamp'
65
+ ),
66
+ },
67
+ ],
68
+ };
69
+ });
70
+
71
+ return (
72
+ <Animated.View
73
+ style={[styles.portalContent, largeTitleAnimatedStyle]}
74
+ onLayout={onLayout}
75
+ >
76
+ <Text
77
+ style={styles.largeTitle}
78
+ maxFontSizeMultiplier={
79
+ theme.typography.variants['headline-lg'].maxFontSizeMultiplier
80
+ }
81
+ >
82
+ {title}
83
+ </Text>
84
+ {!!caption && (
85
+ <Text
86
+ style={styles.caption}
87
+ maxFontSizeMultiplier={
88
+ theme.typography.variants['body-lg'].maxFontSizeMultiplier
89
+ }
90
+ >
91
+ {caption}
92
+ </Text>
93
+ )}
94
+ </Animated.View>
95
+ );
96
+ }
97
+
98
+ /**
99
+ * iOS-style collapsing large-title header. The large title is injected (via the
100
+ * `Screen`'s portal) into the top of the scroll content, so it scrolls away
101
+ * naturally; the compact bar title cross-fades and slides in over the measured
102
+ * portal height. Native scroll snap (`snapToOffsets`) settles between expanded
103
+ * and collapsed when released mid-collapse.
104
+ *
105
+ * Must be used inside a `Screen` with a `Screen.ScrollView` / `Screen.FlatList`.
106
+ *
107
+ * @example
108
+ * ```tsx
109
+ * <Screen.Header>
110
+ * <Header.LargeTitle title="Meditate" caption="Good morning" />
111
+ * </Screen.Header>
112
+ * ```
113
+ */
114
+ export function LargeTitleHeader({
115
+ title,
116
+ caption,
117
+ LeftComponent,
118
+ RightComponent,
119
+ dismissAction = 'none',
120
+ navigation,
121
+ onDismiss,
122
+ titleAlignment = 'center',
123
+ isLargeTitleHidden = false,
124
+ bg = 'surface.default',
125
+ }: LargeTitleHeaderProps) {
126
+ const { theme } = useUnistyles();
127
+ const { top } = useSafeAreaInsets();
128
+ const gradientId = useId();
129
+ const bgColor =
130
+ resolveThemeColor(bg, theme) ??
131
+ (theme.color as unknown as Record<string, string | undefined>)[
132
+ 'surface.default'
133
+ ] ??
134
+ '';
135
+ const isTransparent = bgColor === 'transparent';
136
+ const gradientColor = isTransparent ? theme.color.background : bgColor;
137
+ const { scrollY, headerCollapseHeight, setHeaderCollapseHeight } =
138
+ useScreen();
139
+ const { registerContent, unregisterContent } = usePortal();
140
+ const portalId = useId();
141
+ const isLargeTitleHiddenValue = useSharedValue(isLargeTitleHidden);
142
+
143
+ styles.useVariants({ titleAlignment });
144
+
145
+ const handlePortalLayout = useCallback(
146
+ (event: LayoutChangeEvent) => {
147
+ setHeaderCollapseHeight(event.nativeEvent.layout.height);
148
+ },
149
+ [setHeaderCollapseHeight]
150
+ );
151
+
152
+ // Animate the gradient overlay's opacity: 0 (expanded) → 1 (collapsed).
153
+ const gradientOpacityStyle = useAnimatedStyle(() => {
154
+ if (isLargeTitleHiddenValue.value) {
155
+ return { opacity: 1 };
156
+ }
157
+ const height = headerCollapseHeight.value;
158
+ if (height <= 0) {
159
+ return { opacity: 0 };
160
+ }
161
+ return {
162
+ opacity: interpolate(scrollY.value, [0, height], [0, 1], 'clamp'),
163
+ };
164
+ });
165
+
166
+ const compactTitleAnimatedStyle = useAnimatedStyle(() => {
167
+ if (isLargeTitleHiddenValue.value) {
168
+ return { opacity: 1, transform: [{ translateY: 0 }] };
169
+ }
170
+
171
+ const height = headerCollapseHeight.value;
172
+ if (height <= 0) {
173
+ return {
174
+ opacity: 0,
175
+ transform: [{ translateY: COMPACT_TITLE_SLIDE_OFFSET }],
176
+ };
177
+ }
178
+
179
+ return {
180
+ opacity: interpolate(scrollY.value, [0, height], [0, 1], 'clamp'),
181
+ transform: [
182
+ {
183
+ translateY: interpolate(
184
+ scrollY.value,
185
+ [0, height],
186
+ [COMPACT_TITLE_SLIDE_OFFSET, 0],
187
+ 'clamp'
188
+ ),
189
+ },
190
+ ],
191
+ };
192
+ });
193
+
194
+ useEffect(() => {
195
+ isLargeTitleHiddenValue.value = isLargeTitleHidden;
196
+ }, [isLargeTitleHidden, isLargeTitleHiddenValue]);
197
+
198
+ useEffect(() => {
199
+ if (isLargeTitleHidden) {
200
+ setHeaderCollapseHeight(0);
201
+ unregisterContent(portalId);
202
+ return;
203
+ }
204
+
205
+ setHeaderCollapseHeight(0);
206
+
207
+ registerContent(
208
+ portalId,
209
+ <LargeTitlePortalContent
210
+ title={title}
211
+ caption={caption}
212
+ onLayout={handlePortalLayout}
213
+ />
214
+ );
215
+
216
+ return () => unregisterContent(portalId);
217
+ }, [
218
+ portalId,
219
+ title,
220
+ caption,
221
+ isLargeTitleHidden,
222
+ setHeaderCollapseHeight,
223
+ handlePortalLayout,
224
+ registerContent,
225
+ unregisterContent,
226
+ ]);
227
+
228
+ const leading =
229
+ dismissAction === 'back' ? (
230
+ <>
231
+ <HeaderDismissButton
232
+ dismissAction={dismissAction}
233
+ navigation={navigation}
234
+ onDismiss={onDismiss}
235
+ />
236
+ {LeftComponent}
237
+ </>
238
+ ) : (
239
+ LeftComponent
240
+ );
241
+
242
+ const trailing =
243
+ dismissAction === 'close' ? (
244
+ <>
245
+ {RightComponent}
246
+ <HeaderDismissButton
247
+ dismissAction={dismissAction}
248
+ navigation={navigation}
249
+ onDismiss={onDismiss}
250
+ />
251
+ </>
252
+ ) : (
253
+ RightComponent
254
+ );
255
+
256
+ return (
257
+ <View style={styles.safeArea}>
258
+ <Animated.View
259
+ style={[
260
+ { height: top, backgroundColor: gradientColor },
261
+ gradientOpacityStyle,
262
+ ]}
263
+ />
264
+ <View style={styles.bar}>
265
+ <Animated.View
266
+ style={[styles.gradient, gradientOpacityStyle]}
267
+ pointerEvents="none"
268
+ >
269
+ <Svg height="100%" width="100%">
270
+ <Defs>
271
+ <SvgLinearGradient id={gradientId} x1="0" y1="0" x2="0" y2="1">
272
+ <Stop offset="0" stopColor={gradientColor} stopOpacity="1" />
273
+ <Stop offset="1" stopColor={gradientColor} stopOpacity="0" />
274
+ </SvgLinearGradient>
275
+ </Defs>
276
+ <Rect width="100%" height="100%" fill={`url(#${gradientId})`} />
277
+ </Svg>
278
+ </Animated.View>
279
+ {leading != null && <View style={styles.slot}>{leading}</View>}
280
+ <Animated.View
281
+ style={[styles.titleContainer, compactTitleAnimatedStyle]}
282
+ pointerEvents="none"
283
+ >
284
+ <AnimatedText
285
+ style={styles.compactTitle}
286
+ maxFontSizeMultiplier={
287
+ theme.typography.variants['title-md'].maxFontSizeMultiplier
288
+ }
289
+ >
290
+ {title}
291
+ </AnimatedText>
292
+ </Animated.View>
293
+ {trailing != null && <View style={styles.slotEnd}>{trailing}</View>}
294
+ </View>
295
+ </View>
296
+ );
297
+ }
298
+
299
+ const styles = StyleSheet.create((theme) => ({
300
+ safeArea: {
301
+ position: 'absolute',
302
+ top: 0,
303
+ left: 0,
304
+ right: 0,
305
+ zIndex: 1000,
306
+ },
307
+ gradient: {
308
+ position: 'absolute',
309
+ top: 0,
310
+ left: 0,
311
+ right: 0,
312
+ bottom: 0,
313
+ },
314
+ bar: {
315
+ height: theme.layout.header.height,
316
+ flexDirection: 'row',
317
+ alignItems: 'center',
318
+ justifyContent: 'space-between',
319
+ paddingHorizontal: theme.layout.screen.margin.x,
320
+ gap: theme.spacing['3'],
321
+ },
322
+ slot: {
323
+ flexDirection: 'row',
324
+ alignItems: 'center',
325
+ gap: theme.spacing['2'],
326
+ },
327
+ slotEnd: {
328
+ flexDirection: 'row',
329
+ alignItems: 'center',
330
+ justifyContent: 'flex-end',
331
+ gap: theme.spacing['2'],
332
+ },
333
+ portalContent: {
334
+ marginTop: theme.spacing['1'],
335
+ marginBottom: theme.spacing['3'],
336
+ },
337
+ largeTitle: {
338
+ fontSize: theme.typography.variants['headline-lg'].fontSize,
339
+ lineHeight: theme.typography.variants['headline-lg'].lineHeight,
340
+ letterSpacing: theme.typography.variants['headline-lg'].letterSpacing,
341
+ fontWeight:
342
+ FONT_WEIGHT_VALUE[theme.typography.variants['headline-lg'].fontWeight],
343
+ color:
344
+ (theme.color as unknown as Record<string, string | undefined>)[
345
+ 'text.default'
346
+ ] ?? '',
347
+ },
348
+ caption: {
349
+ fontSize: theme.typography.variants['body-lg'].fontSize,
350
+ lineHeight: theme.typography.variants['body-lg'].lineHeight,
351
+ letterSpacing: theme.typography.variants['body-lg'].letterSpacing,
352
+ color:
353
+ (theme.color as unknown as Record<string, string | undefined>)[
354
+ 'text.subtle'
355
+ ] ?? '',
356
+ },
357
+ compactTitle: {
358
+ fontSize: theme.typography.variants['title-md'].fontSize,
359
+ lineHeight: theme.typography.variants['title-md'].lineHeight,
360
+ letterSpacing: theme.typography.variants['title-md'].letterSpacing,
361
+ fontWeight:
362
+ FONT_WEIGHT_VALUE[theme.typography.variants['title-md'].fontWeight],
363
+ color:
364
+ (theme.color as unknown as Record<string, string | undefined>)[
365
+ 'text.default'
366
+ ] ?? '',
367
+ variants: {
368
+ titleAlignment: {
369
+ center: { textAlign: 'center' },
370
+ left: { textAlign: 'left' },
371
+ },
372
+ },
373
+ },
374
+ titleContainer: {
375
+ variants: {
376
+ titleAlignment: {
377
+ center: {
378
+ position: 'absolute',
379
+ left: 0,
380
+ right: 0,
381
+ alignItems: 'center',
382
+ },
383
+ left: {
384
+ flex: 1,
385
+ alignItems: 'flex-start',
386
+ },
387
+ },
388
+ },
389
+ },
390
+ }));
@@ -0,0 +1,194 @@
1
+ import { type ReactNode, useId } from 'react';
2
+ import { Text, View } from 'react-native';
3
+
4
+ import { useSafeAreaInsets } from 'react-native-safe-area-context';
5
+ import Svg, {
6
+ Defs,
7
+ Rect,
8
+ Stop,
9
+ LinearGradient as SvgLinearGradient,
10
+ } from 'react-native-svg';
11
+ import { StyleSheet, useUnistyles } from 'react-native-unistyles';
12
+
13
+ import type { ColorToken } from '#theme/types';
14
+ import { resolveThemeColor } from '#utils/resolve-theme-color';
15
+ import { FONT_WEIGHT_VALUE } from '#utils/typography';
16
+
17
+ import {
18
+ HeaderDismissButton,
19
+ type HeaderDismissProps,
20
+ } from '../../header-buttons';
21
+
22
+ export interface TitleHeaderProps extends HeaderDismissProps {
23
+ title?: string;
24
+ /** Content on the leading side (e.g. a back button). */
25
+ LeftComponent?: ReactNode;
26
+ /** Content on the trailing side (e.g. an action). */
27
+ RightComponent?: ReactNode;
28
+ /** Title placement within the bar. Defaults to `'center'`. */
29
+ titleAlignment?: 'center' | 'left';
30
+ /** Background color token. Defaults to `surface.default`. */
31
+ bg?: ColorToken;
32
+ }
33
+
34
+ /**
35
+ * Compact title bar (leading slot · title · trailing slot) with a top safe-area
36
+ * inset. The inline counterpart to `Header.LargeTitle`; use it for screens that
37
+ * don't need a collapsing large title.
38
+ *
39
+ * @example
40
+ * ```tsx
41
+ * <Screen.Header>
42
+ * <Header.Title title="Stats" RightComponent={<Button>Edit</Button>} />
43
+ * </Screen.Header>
44
+ * ```
45
+ */
46
+ export function TitleHeader({
47
+ title,
48
+ LeftComponent,
49
+ RightComponent,
50
+ dismissAction = 'none',
51
+ navigation,
52
+ onDismiss,
53
+ titleAlignment = 'center',
54
+ bg = 'surface.default',
55
+ }: TitleHeaderProps) {
56
+ const { theme } = useUnistyles();
57
+ const { top } = useSafeAreaInsets();
58
+ const gradientId = useId();
59
+ const bgColor = resolveThemeColor(bg, theme) as string;
60
+ const isTransparent = bgColor === 'transparent';
61
+ const gradientColor = isTransparent
62
+ ? theme.color['surface.default']
63
+ : bgColor;
64
+ styles.useVariants({ titleAlignment });
65
+
66
+ const leading =
67
+ dismissAction === 'back' ? (
68
+ <>
69
+ <HeaderDismissButton
70
+ dismissAction={dismissAction}
71
+ navigation={navigation}
72
+ onDismiss={onDismiss}
73
+ />
74
+ {LeftComponent}
75
+ </>
76
+ ) : (
77
+ LeftComponent
78
+ );
79
+
80
+ const trailing =
81
+ dismissAction === 'close' ? (
82
+ <>
83
+ {RightComponent}
84
+ <HeaderDismissButton
85
+ dismissAction={dismissAction}
86
+ navigation={navigation}
87
+ onDismiss={onDismiss}
88
+ />
89
+ </>
90
+ ) : (
91
+ RightComponent
92
+ );
93
+ return (
94
+ <View style={styles.safeArea}>
95
+ <View
96
+ style={{
97
+ height: top,
98
+ backgroundColor: isTransparent ? 'transparent' : bgColor,
99
+ }}
100
+ />
101
+ <View style={styles.bar}>
102
+ <View style={styles.gradient} pointerEvents="none">
103
+ <Svg height="100%" width="100%">
104
+ <Defs>
105
+ <SvgLinearGradient id={gradientId} x1="0" y1="0.4" x2="0" y2="1">
106
+ <Stop offset="0" stopColor={gradientColor} stopOpacity="0.9" />
107
+ <Stop
108
+ offset="0.9"
109
+ stopColor={gradientColor}
110
+ stopOpacity="0.1"
111
+ />
112
+ </SvgLinearGradient>
113
+ </Defs>
114
+ <Rect width="100%" height="100%" fill={`url(#${gradientId})`} />
115
+ </Svg>
116
+ </View>
117
+ {leading != null && <View style={styles.slot}>{leading}</View>}
118
+ <View style={styles.titleContainer} pointerEvents="none">
119
+ {!!title && <Text style={styles.title}>{title}</Text>}
120
+ </View>
121
+ {trailing != null && <View style={styles.slotEnd}>{trailing}</View>}
122
+ </View>
123
+ </View>
124
+ );
125
+ }
126
+
127
+ const styles = StyleSheet.create((theme) => ({
128
+ safeArea: {
129
+ position: 'absolute',
130
+ top: 0,
131
+ left: 0,
132
+ right: 0,
133
+ zIndex: 1000,
134
+ },
135
+ gradient: {
136
+ position: 'absolute',
137
+ top: 0,
138
+ left: 0,
139
+ right: 0,
140
+ bottom: 0,
141
+ },
142
+ bar: {
143
+ height: theme.layout.header.height,
144
+ flexDirection: 'row',
145
+ alignItems: 'center',
146
+ justifyContent: 'space-between',
147
+ paddingHorizontal: theme.layout.screen.margin.x,
148
+ gap: theme.spacing['3'],
149
+ },
150
+ slot: {
151
+ flexDirection: 'row',
152
+ alignItems: 'center',
153
+ gap: theme.spacing['2'],
154
+ },
155
+ slotEnd: {
156
+ flexDirection: 'row',
157
+ alignItems: 'center',
158
+ justifyContent: 'flex-end',
159
+ gap: theme.spacing['2'],
160
+ },
161
+ titleContainer: {
162
+ variants: {
163
+ titleAlignment: {
164
+ center: {
165
+ position: 'absolute',
166
+ left: 0,
167
+ right: 0,
168
+ alignItems: 'center',
169
+ },
170
+ left: {
171
+ flex: 1,
172
+ alignItems: 'flex-start',
173
+ },
174
+ },
175
+ },
176
+ },
177
+ title: {
178
+ fontSize: theme.typography.variants['title-md'].fontSize,
179
+ lineHeight: theme.typography.variants['title-md'].lineHeight,
180
+ letterSpacing: theme.typography.variants['title-md'].letterSpacing,
181
+ fontWeight:
182
+ FONT_WEIGHT_VALUE[theme.typography.variants['title-md'].fontWeight],
183
+ color:
184
+ (theme.color as unknown as Record<string, string | undefined>)[
185
+ 'text.default'
186
+ ] ?? '',
187
+ variants: {
188
+ titleAlignment: {
189
+ center: { textAlign: 'center' },
190
+ left: { textAlign: 'left' },
191
+ },
192
+ },
193
+ },
194
+ }));
@@ -0,0 +1,74 @@
1
+ import type { ComponentRef } from 'react';
2
+ import { forwardRef } from 'react';
3
+ import { View, type ViewProps } from 'react-native';
4
+
5
+ import { useUnistyles } from 'react-native-unistyles';
6
+
7
+ import { getIcon } from '#theme/configure';
8
+ import type { ColorToken, TerraIconName } from '#theme/types';
9
+ import { resolveThemeColor } from '#utils/resolve-theme-color';
10
+
11
+ export interface IconProps extends Omit<ViewProps, 'children'> {
12
+ /** Semantic or configured icon name from the theme registry. */
13
+ name: TerraIconName;
14
+ /** Icon size in density-independent pixels. Defaults to `20`. */
15
+ size?: number;
16
+ /** Theme color token or raw CSS color. Defaults to `text.default`. */
17
+ color?: ColorToken;
18
+ strokeWidth?: number;
19
+ }
20
+
21
+ /**
22
+ * Renders an icon from the Terra UI icon registry (`configureTerraUI({ icons })`
23
+ * plus built-in semantic names like `navigation.back`).
24
+ *
25
+ * @example
26
+ * ```tsx
27
+ * <Icon name="navigation.close" size={24} color="text.default" />
28
+ * ```
29
+ */
30
+ export const Icon = forwardRef<ComponentRef<typeof View>, IconProps>(
31
+ function Icon(
32
+ { name, size = 20, color = 'text.default', strokeWidth, style, ...rest },
33
+ ref
34
+ ) {
35
+ const { theme } = useUnistyles();
36
+ const IconComponent = getIcon(name);
37
+
38
+ if (!IconComponent) {
39
+ if (__DEV__) {
40
+ console.warn(`[react-native-terra-ui] Unknown icon "${name}".`);
41
+ }
42
+ return null;
43
+ }
44
+
45
+ const resolvedColor =
46
+ resolveThemeColor(color, theme) ??
47
+ (theme.color as unknown as Record<string, string | undefined>)[
48
+ 'text.default'
49
+ ] ??
50
+ '';
51
+
52
+ return (
53
+ <View
54
+ ref={ref}
55
+ style={[
56
+ {
57
+ width: size,
58
+ height: size,
59
+ alignItems: 'center',
60
+ justifyContent: 'center',
61
+ },
62
+ style,
63
+ ]}
64
+ {...rest}
65
+ >
66
+ <IconComponent
67
+ color={resolvedColor}
68
+ size={size}
69
+ strokeWidth={strokeWidth}
70
+ />
71
+ </View>
72
+ );
73
+ }
74
+ );
@@ -0,0 +1,2 @@
1
+ export type { IconProps } from './Icon';
2
+ export { Icon } from './Icon';