@tamagui/web 1.2.5

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 (556) hide show
  1. package/README.md +1 -0
  2. package/dist/cjs/Tamagui.js +77 -0
  3. package/dist/cjs/Tamagui.js.map +7 -0
  4. package/dist/cjs/addTheme.js +78 -0
  5. package/dist/cjs/addTheme.js.map +7 -0
  6. package/dist/cjs/config.js +91 -0
  7. package/dist/cjs/config.js.map +7 -0
  8. package/dist/cjs/constants/constants.js +49 -0
  9. package/dist/cjs/constants/constants.js.map +7 -0
  10. package/dist/cjs/constants/isDevTools.js +37 -0
  11. package/dist/cjs/constants/isDevTools.js.map +7 -0
  12. package/dist/cjs/contexts/ButtonNestingContext.js +30 -0
  13. package/dist/cjs/contexts/ButtonNestingContext.js.map +7 -0
  14. package/dist/cjs/contexts/FontLanguageContext.js +30 -0
  15. package/dist/cjs/contexts/FontLanguageContext.js.map +7 -0
  16. package/dist/cjs/contexts/TextAncestorContext.js +30 -0
  17. package/dist/cjs/contexts/TextAncestorContext.js.map +7 -0
  18. package/dist/cjs/createComponent.js +874 -0
  19. package/dist/cjs/createComponent.js.map +7 -0
  20. package/dist/cjs/createFont.js +69 -0
  21. package/dist/cjs/createFont.js.map +7 -0
  22. package/dist/cjs/createShorthands.js +31 -0
  23. package/dist/cjs/createShorthands.js.map +7 -0
  24. package/dist/cjs/createTamagui.js +206 -0
  25. package/dist/cjs/createTamagui.js.map +7 -0
  26. package/dist/cjs/createTheme.js +31 -0
  27. package/dist/cjs/createTheme.js.map +7 -0
  28. package/dist/cjs/createTokens.js +39 -0
  29. package/dist/cjs/createTokens.js.map +7 -0
  30. package/dist/cjs/createVariable.js +111 -0
  31. package/dist/cjs/createVariable.js.map +7 -0
  32. package/dist/cjs/createVariables.js +60 -0
  33. package/dist/cjs/createVariables.js.map +7 -0
  34. package/dist/cjs/helpers/RNComponents.js +40 -0
  35. package/dist/cjs/helpers/RNComponents.js.map +7 -0
  36. package/dist/cjs/helpers/ThemeManager.js +234 -0
  37. package/dist/cjs/helpers/ThemeManager.js.map +7 -0
  38. package/dist/cjs/helpers/ThemeManagerContext.js +30 -0
  39. package/dist/cjs/helpers/ThemeManagerContext.js.map +7 -0
  40. package/dist/cjs/helpers/createMediaStyle.js +67 -0
  41. package/dist/cjs/helpers/createMediaStyle.js.map +7 -0
  42. package/dist/cjs/helpers/createPropMapper.js +423 -0
  43. package/dist/cjs/helpers/createPropMapper.js.map +7 -0
  44. package/dist/cjs/helpers/createProxy.js +43 -0
  45. package/dist/cjs/helpers/createProxy.js.map +7 -0
  46. package/dist/cjs/helpers/expandStyle.js +95 -0
  47. package/dist/cjs/helpers/expandStyle.js.map +7 -0
  48. package/dist/cjs/helpers/expandStyles.js +116 -0
  49. package/dist/cjs/helpers/expandStyles.js.map +7 -0
  50. package/dist/cjs/helpers/extendStaticConfig.js +91 -0
  51. package/dist/cjs/helpers/extendStaticConfig.js.map +7 -0
  52. package/dist/cjs/helpers/getAnimationDriver.js +32 -0
  53. package/dist/cjs/helpers/getAnimationDriver.js.map +7 -0
  54. package/dist/cjs/helpers/getExpandedShorthands.js +40 -0
  55. package/dist/cjs/helpers/getExpandedShorthands.js.map +7 -0
  56. package/dist/cjs/helpers/getFontLanguage.js +29 -0
  57. package/dist/cjs/helpers/getFontLanguage.js.map +7 -0
  58. package/dist/cjs/helpers/getSplitStyles.js +850 -0
  59. package/dist/cjs/helpers/getSplitStyles.js.map +7 -0
  60. package/dist/cjs/helpers/getStylesAtomic.js +226 -0
  61. package/dist/cjs/helpers/getStylesAtomic.js.map +7 -0
  62. package/dist/cjs/helpers/getStylesAtomic.native.js +38 -0
  63. package/dist/cjs/helpers/getStylesAtomic.native.js.map +7 -0
  64. package/dist/cjs/helpers/getThemeCSSRules.js +110 -0
  65. package/dist/cjs/helpers/getThemeCSSRules.js.map +7 -0
  66. package/dist/cjs/helpers/getThemeCSSRules.native.js +31 -0
  67. package/dist/cjs/helpers/getThemeCSSRules.native.js.map +7 -0
  68. package/dist/cjs/helpers/getVariantExtras.js +92 -0
  69. package/dist/cjs/helpers/getVariantExtras.js.map +7 -0
  70. package/dist/cjs/helpers/insertStyleRule.js +218 -0
  71. package/dist/cjs/helpers/insertStyleRule.js.map +7 -0
  72. package/dist/cjs/helpers/isObj.js +29 -0
  73. package/dist/cjs/helpers/isObj.js.map +7 -0
  74. package/dist/cjs/helpers/isTamaguiComponent.js +32 -0
  75. package/dist/cjs/helpers/isTamaguiComponent.js.map +7 -0
  76. package/dist/cjs/helpers/isTamaguiElement.js +33 -0
  77. package/dist/cjs/helpers/isTamaguiElement.js.map +7 -0
  78. package/dist/cjs/helpers/matchMedia.js +42 -0
  79. package/dist/cjs/helpers/matchMedia.js.map +7 -0
  80. package/dist/cjs/helpers/matchMedia.native.js +48 -0
  81. package/dist/cjs/helpers/matchMedia.native.js.map +7 -0
  82. package/dist/cjs/helpers/mergeProps.js +54 -0
  83. package/dist/cjs/helpers/mergeProps.js.map +7 -0
  84. package/dist/cjs/helpers/mergeTransform.js +47 -0
  85. package/dist/cjs/helpers/mergeTransform.js.map +7 -0
  86. package/dist/cjs/helpers/normalizeColor.js +71 -0
  87. package/dist/cjs/helpers/normalizeColor.js.map +7 -0
  88. package/dist/cjs/helpers/normalizeValueWithProperty.js +138 -0
  89. package/dist/cjs/helpers/normalizeValueWithProperty.js.map +7 -0
  90. package/dist/cjs/helpers/proxyThemeVariables.js +40 -0
  91. package/dist/cjs/helpers/proxyThemeVariables.js.map +7 -0
  92. package/dist/cjs/helpers/pseudoDescriptors.js +53 -0
  93. package/dist/cjs/helpers/pseudoDescriptors.js.map +7 -0
  94. package/dist/cjs/helpers/registerCSSVariable.js +40 -0
  95. package/dist/cjs/helpers/registerCSSVariable.js.map +7 -0
  96. package/dist/cjs/helpers/themeable.js +62 -0
  97. package/dist/cjs/helpers/themeable.js.map +7 -0
  98. package/dist/cjs/helpers/themes.js +78 -0
  99. package/dist/cjs/helpers/themes.js.map +7 -0
  100. package/dist/cjs/helpers/timer.js +35 -0
  101. package/dist/cjs/helpers/timer.js.map +7 -0
  102. package/dist/cjs/helpers/useShallowSetState.js +59 -0
  103. package/dist/cjs/helpers/useShallowSetState.js.map +7 -0
  104. package/dist/cjs/helpers/warnOnce.js +38 -0
  105. package/dist/cjs/helpers/warnOnce.js.map +7 -0
  106. package/dist/cjs/helpers/withStaticProperties.js +32 -0
  107. package/dist/cjs/helpers/withStaticProperties.js.map +7 -0
  108. package/dist/cjs/hooks/getThemeUnwrapped.js +34 -0
  109. package/dist/cjs/hooks/getThemeUnwrapped.js.map +7 -0
  110. package/dist/cjs/hooks/useId.js +29 -0
  111. package/dist/cjs/hooks/useId.js.map +7 -0
  112. package/dist/cjs/hooks/useIsTouchDevice.js +33 -0
  113. package/dist/cjs/hooks/useIsTouchDevice.js.map +7 -0
  114. package/dist/cjs/hooks/useMedia.js +263 -0
  115. package/dist/cjs/hooks/useMedia.js.map +7 -0
  116. package/dist/cjs/hooks/useSafeRef.js +59 -0
  117. package/dist/cjs/hooks/useSafeRef.js.map +7 -0
  118. package/dist/cjs/hooks/useServerHooks.js +36 -0
  119. package/dist/cjs/hooks/useServerHooks.js.map +7 -0
  120. package/dist/cjs/hooks/useStyle.js +61 -0
  121. package/dist/cjs/hooks/useStyle.js.map +7 -0
  122. package/dist/cjs/hooks/useTheme.js +230 -0
  123. package/dist/cjs/hooks/useTheme.js.map +7 -0
  124. package/dist/cjs/hooks/useThemeName.js +52 -0
  125. package/dist/cjs/hooks/useThemeName.js.map +7 -0
  126. package/dist/cjs/index.js +104 -0
  127. package/dist/cjs/index.js.map +7 -0
  128. package/dist/cjs/inject-styles.js +40 -0
  129. package/dist/cjs/inject-styles.js.map +7 -0
  130. package/dist/cjs/insertFont.js +93 -0
  131. package/dist/cjs/insertFont.js.map +7 -0
  132. package/dist/cjs/setupHooks.js +34 -0
  133. package/dist/cjs/setupHooks.js.map +7 -0
  134. package/dist/cjs/setupReactNative.js +51 -0
  135. package/dist/cjs/setupReactNative.js.map +7 -0
  136. package/dist/cjs/styled.js +95 -0
  137. package/dist/cjs/styled.js.map +7 -0
  138. package/dist/cjs/types.js +17 -0
  139. package/dist/cjs/types.js.map +7 -0
  140. package/dist/cjs/updateTheme.js +47 -0
  141. package/dist/cjs/updateTheme.js.map +7 -0
  142. package/dist/cjs/views/FontLanguage.js +41 -0
  143. package/dist/cjs/views/FontLanguage.js.map +7 -0
  144. package/dist/cjs/views/FontLanguage.native.js +35 -0
  145. package/dist/cjs/views/FontLanguage.native.js.map +7 -0
  146. package/dist/cjs/views/FontLanguage.types.js +17 -0
  147. package/dist/cjs/views/FontLanguage.types.js.map +7 -0
  148. package/dist/cjs/views/Slot.js +92 -0
  149. package/dist/cjs/views/Slot.js.map +7 -0
  150. package/dist/cjs/views/Stack.js +38 -0
  151. package/dist/cjs/views/Stack.js.map +7 -0
  152. package/dist/cjs/views/TamaguiProvider.js +90 -0
  153. package/dist/cjs/views/TamaguiProvider.js.map +7 -0
  154. package/dist/cjs/views/Text.js +94 -0
  155. package/dist/cjs/views/Text.js.map +7 -0
  156. package/dist/cjs/views/Theme.js +88 -0
  157. package/dist/cjs/views/Theme.js.map +7 -0
  158. package/dist/cjs/views/ThemeProvider.js +70 -0
  159. package/dist/cjs/views/ThemeProvider.js.map +7 -0
  160. package/dist/esm/Tamagui.js +41 -0
  161. package/dist/esm/Tamagui.js.map +7 -0
  162. package/dist/esm/addTheme.js +54 -0
  163. package/dist/esm/addTheme.js.map +7 -0
  164. package/dist/esm/config.js +58 -0
  165. package/dist/esm/config.js.map +7 -0
  166. package/dist/esm/constants/constants.js +22 -0
  167. package/dist/esm/constants/constants.js.map +7 -0
  168. package/dist/esm/constants/isDevTools.js +13 -0
  169. package/dist/esm/constants/isDevTools.js.map +7 -0
  170. package/dist/esm/contexts/ButtonNestingContext.js +6 -0
  171. package/dist/esm/contexts/ButtonNestingContext.js.map +7 -0
  172. package/dist/esm/contexts/FontLanguageContext.js +6 -0
  173. package/dist/esm/contexts/FontLanguageContext.js.map +7 -0
  174. package/dist/esm/contexts/TextAncestorContext.js +6 -0
  175. package/dist/esm/contexts/TextAncestorContext.js.map +7 -0
  176. package/dist/esm/createComponent.js +849 -0
  177. package/dist/esm/createComponent.js.map +7 -0
  178. package/dist/esm/createFont.js +45 -0
  179. package/dist/esm/createFont.js.map +7 -0
  180. package/dist/esm/createShorthands.js +7 -0
  181. package/dist/esm/createShorthands.js.map +7 -0
  182. package/dist/esm/createTamagui.js +190 -0
  183. package/dist/esm/createTamagui.js.map +7 -0
  184. package/dist/esm/createTheme.js +7 -0
  185. package/dist/esm/createTheme.js.map +7 -0
  186. package/dist/esm/createTokens.js +15 -0
  187. package/dist/esm/createTokens.js.map +7 -0
  188. package/dist/esm/createVariable.js +78 -0
  189. package/dist/esm/createVariable.js.map +7 -0
  190. package/dist/esm/createVariables.js +35 -0
  191. package/dist/esm/createVariables.js.map +7 -0
  192. package/dist/esm/helpers/RNComponents.js +16 -0
  193. package/dist/esm/helpers/RNComponents.js.map +7 -0
  194. package/dist/esm/helpers/ThemeManager.js +209 -0
  195. package/dist/esm/helpers/ThemeManager.js.map +7 -0
  196. package/dist/esm/helpers/ThemeManagerContext.js +6 -0
  197. package/dist/esm/helpers/ThemeManagerContext.js.map +7 -0
  198. package/dist/esm/helpers/createMediaStyle.js +42 -0
  199. package/dist/esm/helpers/createMediaStyle.js.map +7 -0
  200. package/dist/esm/helpers/createPropMapper.js +396 -0
  201. package/dist/esm/helpers/createPropMapper.js.map +7 -0
  202. package/dist/esm/helpers/createProxy.js +19 -0
  203. package/dist/esm/helpers/createProxy.js.map +7 -0
  204. package/dist/esm/helpers/expandStyle.js +71 -0
  205. package/dist/esm/helpers/expandStyle.js.map +7 -0
  206. package/dist/esm/helpers/expandStyles.js +90 -0
  207. package/dist/esm/helpers/expandStyles.js.map +7 -0
  208. package/dist/esm/helpers/extendStaticConfig.js +66 -0
  209. package/dist/esm/helpers/extendStaticConfig.js.map +7 -0
  210. package/dist/esm/helpers/getAnimationDriver.js +8 -0
  211. package/dist/esm/helpers/getAnimationDriver.js.map +7 -0
  212. package/dist/esm/helpers/getExpandedShorthands.js +16 -0
  213. package/dist/esm/helpers/getExpandedShorthands.js.map +7 -0
  214. package/dist/esm/helpers/getFontLanguage.js +5 -0
  215. package/dist/esm/helpers/getFontLanguage.js.map +7 -0
  216. package/dist/esm/helpers/getSplitStyles.js +849 -0
  217. package/dist/esm/helpers/getSplitStyles.js.map +7 -0
  218. package/dist/esm/helpers/getStylesAtomic.js +200 -0
  219. package/dist/esm/helpers/getStylesAtomic.js.map +7 -0
  220. package/dist/esm/helpers/getStylesAtomic.native.js +12 -0
  221. package/dist/esm/helpers/getStylesAtomic.native.js.map +7 -0
  222. package/dist/esm/helpers/getThemeCSSRules.js +86 -0
  223. package/dist/esm/helpers/getThemeCSSRules.js.map +7 -0
  224. package/dist/esm/helpers/getThemeCSSRules.native.js +7 -0
  225. package/dist/esm/helpers/getThemeCSSRules.native.js.map +7 -0
  226. package/dist/esm/helpers/getVariantExtras.js +67 -0
  227. package/dist/esm/helpers/getVariantExtras.js.map +7 -0
  228. package/dist/esm/helpers/insertStyleRule.js +186 -0
  229. package/dist/esm/helpers/insertStyleRule.js.map +7 -0
  230. package/dist/esm/helpers/isObj.js +5 -0
  231. package/dist/esm/helpers/isObj.js.map +7 -0
  232. package/dist/esm/helpers/isTamaguiComponent.js +8 -0
  233. package/dist/esm/helpers/isTamaguiComponent.js.map +7 -0
  234. package/dist/esm/helpers/isTamaguiElement.js +9 -0
  235. package/dist/esm/helpers/isTamaguiElement.js.map +7 -0
  236. package/dist/esm/helpers/matchMedia.js +17 -0
  237. package/dist/esm/helpers/matchMedia.js.map +7 -0
  238. package/dist/esm/helpers/matchMedia.native.js +23 -0
  239. package/dist/esm/helpers/matchMedia.native.js.map +7 -0
  240. package/dist/esm/helpers/mergeProps.js +30 -0
  241. package/dist/esm/helpers/mergeProps.js.map +7 -0
  242. package/dist/esm/helpers/mergeTransform.js +21 -0
  243. package/dist/esm/helpers/mergeTransform.js.map +7 -0
  244. package/dist/esm/helpers/normalizeColor.js +36 -0
  245. package/dist/esm/helpers/normalizeColor.js.map +7 -0
  246. package/dist/esm/helpers/normalizeValueWithProperty.js +113 -0
  247. package/dist/esm/helpers/normalizeValueWithProperty.js.map +7 -0
  248. package/dist/esm/helpers/proxyThemeVariables.js +16 -0
  249. package/dist/esm/helpers/proxyThemeVariables.js.map +7 -0
  250. package/dist/esm/helpers/pseudoDescriptors.js +29 -0
  251. package/dist/esm/helpers/pseudoDescriptors.js.map +7 -0
  252. package/dist/esm/helpers/registerCSSVariable.js +14 -0
  253. package/dist/esm/helpers/registerCSSVariable.js.map +7 -0
  254. package/dist/esm/helpers/themeable.js +28 -0
  255. package/dist/esm/helpers/themeable.js.map +7 -0
  256. package/dist/esm/helpers/themes.js +53 -0
  257. package/dist/esm/helpers/themes.js.map +7 -0
  258. package/dist/esm/helpers/timer.js +11 -0
  259. package/dist/esm/helpers/timer.js.map +7 -0
  260. package/dist/esm/helpers/useShallowSetState.js +35 -0
  261. package/dist/esm/helpers/useShallowSetState.js.map +7 -0
  262. package/dist/esm/helpers/warnOnce.js +14 -0
  263. package/dist/esm/helpers/warnOnce.js.map +7 -0
  264. package/dist/esm/helpers/withStaticProperties.js +8 -0
  265. package/dist/esm/helpers/withStaticProperties.js.map +7 -0
  266. package/dist/esm/hooks/getThemeUnwrapped.js +9 -0
  267. package/dist/esm/hooks/getThemeUnwrapped.js.map +7 -0
  268. package/dist/esm/hooks/useId.js +5 -0
  269. package/dist/esm/hooks/useId.js.map +7 -0
  270. package/dist/esm/hooks/useIsTouchDevice.js +9 -0
  271. package/dist/esm/hooks/useIsTouchDevice.js.map +7 -0
  272. package/dist/esm/hooks/useMedia.js +225 -0
  273. package/dist/esm/hooks/useMedia.js.map +7 -0
  274. package/dist/esm/hooks/useSafeRef.js +35 -0
  275. package/dist/esm/hooks/useSafeRef.js.map +7 -0
  276. package/dist/esm/hooks/useServerHooks.js +11 -0
  277. package/dist/esm/hooks/useServerHooks.js.map +7 -0
  278. package/dist/esm/hooks/useStyle.js +37 -0
  279. package/dist/esm/hooks/useStyle.js.map +7 -0
  280. package/dist/esm/hooks/useTheme.js +205 -0
  281. package/dist/esm/hooks/useTheme.js.map +7 -0
  282. package/dist/esm/hooks/useThemeName.js +28 -0
  283. package/dist/esm/hooks/useThemeName.js.map +7 -0
  284. package/dist/esm/index.js +77 -0
  285. package/dist/esm/index.js.map +7 -0
  286. package/dist/esm/inject-styles.js +16 -0
  287. package/dist/esm/inject-styles.js.map +7 -0
  288. package/dist/esm/insertFont.js +67 -0
  289. package/dist/esm/insertFont.js.map +7 -0
  290. package/dist/esm/setupHooks.js +9 -0
  291. package/dist/esm/setupHooks.js.map +7 -0
  292. package/dist/esm/setupReactNative.js +25 -0
  293. package/dist/esm/setupReactNative.js.map +7 -0
  294. package/dist/esm/styled.js +71 -0
  295. package/dist/esm/styled.js.map +7 -0
  296. package/dist/esm/types.js +1 -0
  297. package/dist/esm/types.js.map +7 -0
  298. package/dist/esm/updateTheme.js +23 -0
  299. package/dist/esm/updateTheme.js.map +7 -0
  300. package/dist/esm/views/FontLanguage.js +17 -0
  301. package/dist/esm/views/FontLanguage.js.map +7 -0
  302. package/dist/esm/views/FontLanguage.native.js +11 -0
  303. package/dist/esm/views/FontLanguage.native.js.map +7 -0
  304. package/dist/esm/views/FontLanguage.types.js +1 -0
  305. package/dist/esm/views/FontLanguage.types.js.map +7 -0
  306. package/dist/esm/views/Slot.js +66 -0
  307. package/dist/esm/views/Slot.js.map +7 -0
  308. package/dist/esm/views/Stack.js +14 -0
  309. package/dist/esm/views/Stack.js.map +7 -0
  310. package/dist/esm/views/TamaguiProvider.js +56 -0
  311. package/dist/esm/views/TamaguiProvider.js.map +7 -0
  312. package/dist/esm/views/Text.js +70 -0
  313. package/dist/esm/views/Text.js.map +7 -0
  314. package/dist/esm/views/Theme.js +63 -0
  315. package/dist/esm/views/Theme.js.map +7 -0
  316. package/dist/esm/views/ThemeProvider.js +45 -0
  317. package/dist/esm/views/ThemeProvider.js.map +7 -0
  318. package/package.json +73 -0
  319. package/reset.css +37 -0
  320. package/src/Tamagui.ts +48 -0
  321. package/src/addTheme.ts +65 -0
  322. package/src/config.ts +62 -0
  323. package/src/constants/constants.ts +17 -0
  324. package/src/constants/isDevTools.ts +12 -0
  325. package/src/contexts/ButtonNestingContext.tsx +3 -0
  326. package/src/contexts/FontLanguageContext.tsx +5 -0
  327. package/src/contexts/TextAncestorContext.tsx +3 -0
  328. package/src/createComponent.tsx +1133 -0
  329. package/src/createFont.ts +50 -0
  330. package/src/createShorthands.ts +7 -0
  331. package/src/createTamagui.ts +253 -0
  332. package/src/createTheme.ts +13 -0
  333. package/src/createTokens.ts +46 -0
  334. package/src/createVariable.ts +93 -0
  335. package/src/createVariables.ts +55 -0
  336. package/src/helpers/RNComponents.tsx +14 -0
  337. package/src/helpers/ThemeManager.tsx +285 -0
  338. package/src/helpers/ThemeManagerContext.tsx +5 -0
  339. package/src/helpers/createMediaStyle.ts +55 -0
  340. package/src/helpers/createPropMapper.ts +562 -0
  341. package/src/helpers/createProxy.ts +16 -0
  342. package/src/helpers/expandStyle.ts +82 -0
  343. package/src/helpers/expandStyles.ts +107 -0
  344. package/src/helpers/extendStaticConfig.ts +78 -0
  345. package/src/helpers/getAnimationDriver.tsx +5 -0
  346. package/src/helpers/getExpandedShorthands.ts +17 -0
  347. package/src/helpers/getFontLanguage.ts +2 -0
  348. package/src/helpers/getSplitStyles.tsx +1133 -0
  349. package/src/helpers/getStylesAtomic.native.ts +8 -0
  350. package/src/helpers/getStylesAtomic.ts +274 -0
  351. package/src/helpers/getThemeCSSRules.native.ts +3 -0
  352. package/src/helpers/getThemeCSSRules.ts +120 -0
  353. package/src/helpers/getVariantExtras.tsx +85 -0
  354. package/src/helpers/insertStyleRule.tsx +218 -0
  355. package/src/helpers/isObj.ts +1 -0
  356. package/src/helpers/isTamaguiComponent.tsx +11 -0
  357. package/src/helpers/isTamaguiElement.tsx +11 -0
  358. package/src/helpers/matchMedia.native.ts +23 -0
  359. package/src/helpers/matchMedia.ts +16 -0
  360. package/src/helpers/mergeProps.ts +56 -0
  361. package/src/helpers/mergeTransform.ts +30 -0
  362. package/src/helpers/normalizeColor.ts +38 -0
  363. package/src/helpers/normalizeValueWithProperty.ts +129 -0
  364. package/src/helpers/proxyThemeVariables.tsx +15 -0
  365. package/src/helpers/pseudoDescriptors.ts +40 -0
  366. package/src/helpers/registerCSSVariable.ts +13 -0
  367. package/src/helpers/themeable.tsx +44 -0
  368. package/src/helpers/themes.ts +67 -0
  369. package/src/helpers/timer.ts +9 -0
  370. package/src/helpers/useShallowSetState.tsx +41 -0
  371. package/src/helpers/warnOnce.tsx +11 -0
  372. package/src/helpers/withStaticProperties.tsx +7 -0
  373. package/src/hooks/getThemeUnwrapped.tsx +5 -0
  374. package/src/hooks/useId.tsx +1 -0
  375. package/src/hooks/useIsTouchDevice.tsx +6 -0
  376. package/src/hooks/useMedia.tsx +298 -0
  377. package/src/hooks/useSafeRef.ts +45 -0
  378. package/src/hooks/useServerHooks.tsx +12 -0
  379. package/src/hooks/useStyle.tsx +49 -0
  380. package/src/hooks/useTheme.tsx +274 -0
  381. package/src/hooks/useThemeName.tsx +27 -0
  382. package/src/index.ts +72 -0
  383. package/src/inject-styles.ts +20 -0
  384. package/src/insertFont.ts +73 -0
  385. package/src/setupHooks.ts +35 -0
  386. package/src/setupReactNative.ts +22 -0
  387. package/src/styled.tsx +195 -0
  388. package/src/types.tsx +1459 -0
  389. package/src/updateTheme.ts +26 -0
  390. package/src/views/FontLanguage.native.tsx +12 -0
  391. package/src/views/FontLanguage.tsx +16 -0
  392. package/src/views/FontLanguage.types.ts +13 -0
  393. package/src/views/Slot.tsx +95 -0
  394. package/src/views/Stack.tsx +25 -0
  395. package/src/views/TamaguiProvider.tsx +65 -0
  396. package/src/views/Text.tsx +87 -0
  397. package/src/views/Theme.tsx +83 -0
  398. package/src/views/ThemeProvider.tsx +55 -0
  399. package/types/Tamagui.d.ts +30 -0
  400. package/types/Tamagui.d.ts.map +1 -0
  401. package/types/addTheme.d.ts +32 -0
  402. package/types/addTheme.d.ts.map +1 -0
  403. package/types/config.d.ts +49 -0
  404. package/types/config.d.ts.map +1 -0
  405. package/types/constants/constants.d.ts +21 -0
  406. package/types/constants/constants.d.ts.map +1 -0
  407. package/types/constants/isDevTools.d.ts +2 -0
  408. package/types/constants/isDevTools.d.ts.map +1 -0
  409. package/types/contexts/ButtonNestingContext.d.ts +3 -0
  410. package/types/contexts/ButtonNestingContext.d.ts.map +1 -0
  411. package/types/contexts/FontLanguageContext.d.ts +5 -0
  412. package/types/contexts/FontLanguageContext.d.ts.map +1 -0
  413. package/types/contexts/TextAncestorContext.d.ts +3 -0
  414. package/types/contexts/TextAncestorContext.d.ts.map +1 -0
  415. package/types/createComponent.d.ts +23 -0
  416. package/types/createComponent.d.ts.map +1 -0
  417. package/types/createFont.d.ts +3 -0
  418. package/types/createFont.d.ts.map +1 -0
  419. package/types/createShorthands.d.ts +3 -0
  420. package/types/createShorthands.d.ts.map +1 -0
  421. package/types/createTamagui.d.ts +3 -0
  422. package/types/createTamagui.d.ts.map +1 -0
  423. package/types/createTheme.d.ts +7 -0
  424. package/types/createTheme.d.ts.map +1 -0
  425. package/types/createTokens.d.ts +28 -0
  426. package/types/createTokens.d.ts.map +1 -0
  427. package/types/createVariable.d.ts +26 -0
  428. package/types/createVariable.d.ts.map +1 -0
  429. package/types/createVariables.d.ts +11 -0
  430. package/types/createVariables.d.ts.map +1 -0
  431. package/types/helpers/RNComponents.d.ts +2 -0
  432. package/types/helpers/RNComponents.d.ts.map +1 -0
  433. package/types/helpers/ThemeManager.d.ts +36 -0
  434. package/types/helpers/ThemeManager.d.ts.map +1 -0
  435. package/types/helpers/ThemeManagerContext.d.ts +4 -0
  436. package/types/helpers/ThemeManagerContext.d.ts.map +1 -0
  437. package/types/helpers/createMediaStyle.d.ts +5 -0
  438. package/types/helpers/createMediaStyle.d.ts.map +1 -0
  439. package/types/helpers/createPropMapper.d.ts +7 -0
  440. package/types/helpers/createPropMapper.d.ts.map +1 -0
  441. package/types/helpers/createProxy.d.ts +2 -0
  442. package/types/helpers/createProxy.d.ts.map +1 -0
  443. package/types/helpers/expandStyle.d.ts +6 -0
  444. package/types/helpers/expandStyle.d.ts.map +1 -0
  445. package/types/helpers/expandStyles.d.ts +26 -0
  446. package/types/helpers/expandStyles.d.ts.map +1 -0
  447. package/types/helpers/extendStaticConfig.d.ts +4 -0
  448. package/types/helpers/extendStaticConfig.d.ts.map +1 -0
  449. package/types/helpers/getAnimationDriver.d.ts +6 -0
  450. package/types/helpers/getAnimationDriver.d.ts.map +1 -0
  451. package/types/helpers/getExpandedShorthands.d.ts +3 -0
  452. package/types/helpers/getExpandedShorthands.d.ts.map +1 -0
  453. package/types/helpers/getFontLanguage.d.ts +2 -0
  454. package/types/helpers/getFontLanguage.d.ts.map +1 -0
  455. package/types/helpers/getSplitStyles.d.ts +31 -0
  456. package/types/helpers/getSplitStyles.d.ts.map +1 -0
  457. package/types/helpers/getStylesAtomic.d.ts +18 -0
  458. package/types/helpers/getStylesAtomic.d.ts.map +1 -0
  459. package/types/helpers/getStylesAtomic.native.d.ts +4 -0
  460. package/types/helpers/getStylesAtomic.native.d.ts.map +1 -0
  461. package/types/helpers/getThemeCSSRules.d.ts +8 -0
  462. package/types/helpers/getThemeCSSRules.d.ts.map +1 -0
  463. package/types/helpers/getThemeCSSRules.native.d.ts +2 -0
  464. package/types/helpers/getThemeCSSRules.native.d.ts.map +1 -0
  465. package/types/helpers/getVariantExtras.d.ts +5 -0
  466. package/types/helpers/getVariantExtras.d.ts.map +1 -0
  467. package/types/helpers/insertStyleRule.d.ts +11 -0
  468. package/types/helpers/insertStyleRule.d.ts.map +1 -0
  469. package/types/helpers/isObj.d.ts +2 -0
  470. package/types/helpers/isObj.d.ts.map +1 -0
  471. package/types/helpers/isTamaguiComponent.d.ts +5 -0
  472. package/types/helpers/isTamaguiComponent.d.ts.map +1 -0
  473. package/types/helpers/isTamaguiElement.d.ts +3 -0
  474. package/types/helpers/isTamaguiElement.d.ts.map +1 -0
  475. package/types/helpers/matchMedia.d.ts +6 -0
  476. package/types/helpers/matchMedia.d.ts.map +1 -0
  477. package/types/helpers/matchMedia.native.d.ts +4 -0
  478. package/types/helpers/matchMedia.native.d.ts.map +1 -0
  479. package/types/helpers/mergeProps.d.ts +17 -0
  480. package/types/helpers/mergeProps.d.ts.map +1 -0
  481. package/types/helpers/mergeTransform.d.ts +9 -0
  482. package/types/helpers/mergeTransform.d.ts.map +1 -0
  483. package/types/helpers/normalizeColor.d.ts +4 -0
  484. package/types/helpers/normalizeColor.d.ts.map +1 -0
  485. package/types/helpers/normalizeValueWithProperty.d.ts +7 -0
  486. package/types/helpers/normalizeValueWithProperty.d.ts.map +1 -0
  487. package/types/helpers/proxyThemeVariables.d.ts +2 -0
  488. package/types/helpers/proxyThemeVariables.d.ts.map +1 -0
  489. package/types/helpers/pseudoDescriptors.d.ts +10 -0
  490. package/types/helpers/pseudoDescriptors.d.ts.map +1 -0
  491. package/types/helpers/registerCSSVariable.d.ts +5 -0
  492. package/types/helpers/registerCSSVariable.d.ts.map +1 -0
  493. package/types/helpers/themeable.d.ts +12 -0
  494. package/types/helpers/themeable.d.ts.map +1 -0
  495. package/types/helpers/themes.d.ts +4 -0
  496. package/types/helpers/themes.d.ts.map +1 -0
  497. package/types/helpers/timer.d.ts +2 -0
  498. package/types/helpers/timer.d.ts.map +1 -0
  499. package/types/helpers/useShallowSetState.d.ts +5 -0
  500. package/types/helpers/useShallowSetState.d.ts.map +1 -0
  501. package/types/helpers/warnOnce.d.ts +2 -0
  502. package/types/helpers/warnOnce.d.ts.map +1 -0
  503. package/types/helpers/withStaticProperties.d.ts +2 -0
  504. package/types/helpers/withStaticProperties.d.ts.map +1 -0
  505. package/types/hooks/getThemeUnwrapped.d.ts +3 -0
  506. package/types/hooks/getThemeUnwrapped.d.ts.map +1 -0
  507. package/types/hooks/useId.d.ts +2 -0
  508. package/types/hooks/useId.d.ts.map +1 -0
  509. package/types/hooks/useIsTouchDevice.d.ts +2 -0
  510. package/types/hooks/useIsTouchDevice.d.ts.map +1 -0
  511. package/types/hooks/useMedia.d.ts +33 -0
  512. package/types/hooks/useMedia.d.ts.map +1 -0
  513. package/types/hooks/useSafeRef.d.ts +4 -0
  514. package/types/hooks/useSafeRef.d.ts.map +1 -0
  515. package/types/hooks/useServerHooks.d.ts +4 -0
  516. package/types/hooks/useServerHooks.d.ts.map +1 -0
  517. package/types/hooks/useStyle.d.ts +8 -0
  518. package/types/hooks/useStyle.d.ts.map +1 -0
  519. package/types/hooks/useTheme.d.ts +25 -0
  520. package/types/hooks/useTheme.d.ts.map +1 -0
  521. package/types/hooks/useThemeName.d.ts +5 -0
  522. package/types/hooks/useThemeName.d.ts.map +1 -0
  523. package/types/index.d.ts +56 -0
  524. package/types/index.d.ts.map +1 -0
  525. package/types/inject-styles.d.ts +7 -0
  526. package/types/inject-styles.d.ts.map +1 -0
  527. package/types/insertFont.d.ts +9 -0
  528. package/types/insertFont.d.ts.map +1 -0
  529. package/types/setupHooks.d.ts +14 -0
  530. package/types/setupHooks.d.ts.map +1 -0
  531. package/types/setupReactNative.d.ts +5 -0
  532. package/types/setupReactNative.d.ts.map +1 -0
  533. package/types/styled.d.ts +20 -0
  534. package/types/styled.d.ts.map +1 -0
  535. package/types/types.d.ts +715 -0
  536. package/types/types.d.ts.map +1 -0
  537. package/types/updateTheme.d.ts +30 -0
  538. package/types/updateTheme.d.ts.map +1 -0
  539. package/types/views/FontLanguage.d.ts +4 -0
  540. package/types/views/FontLanguage.d.ts.map +1 -0
  541. package/types/views/FontLanguage.native.d.ts +4 -0
  542. package/types/views/FontLanguage.native.d.ts.map +1 -0
  543. package/types/views/FontLanguage.types.d.ts +11 -0
  544. package/types/views/FontLanguage.types.d.ts.map +1 -0
  545. package/types/views/Slot.d.ts +11 -0
  546. package/types/views/Slot.d.ts.map +1 -0
  547. package/types/views/Stack.d.ts +4 -0
  548. package/types/views/Stack.d.ts.map +1 -0
  549. package/types/views/TamaguiProvider.d.ts +4 -0
  550. package/types/views/TamaguiProvider.d.ts.map +1 -0
  551. package/types/views/Text.d.ts +4 -0
  552. package/types/views/Text.d.ts.map +1 -0
  553. package/types/views/Theme.d.ts +8 -0
  554. package/types/views/Theme.d.ts.map +1 -0
  555. package/types/views/ThemeProvider.d.ts +12 -0
  556. package/types/views/ThemeProvider.d.ts.map +1 -0
package/src/types.tsx ADDED
@@ -0,0 +1,1459 @@
1
+ // TODO split this into own package @tamagui/types to share with animations packages
2
+
3
+ import type { StyleObject } from '@tamagui/helpers'
4
+ import type { Properties } from 'csstype'
5
+ import type {
6
+ ComponentType,
7
+ ForwardRefExoticComponent,
8
+ FunctionComponent,
9
+ HTMLAttributes,
10
+ ReactNode,
11
+ RefAttributes,
12
+ RefObject,
13
+ } from 'react'
14
+ import type {
15
+ GestureResponderHandlers,
16
+ Image,
17
+ PressableProps,
18
+ TextProps as ReactTextProps,
19
+ Text,
20
+ TextInput,
21
+ TextStyle,
22
+ View,
23
+ ViewProps,
24
+ ViewStyle,
25
+ } from 'react-native'
26
+
27
+ import type { Variable } from './createVariable'
28
+ import type { ResolveVariableTypes } from './helpers/createPropMapper'
29
+ import type { FontLanguageProps } from './views/FontLanguage.types'
30
+ import type { ThemeProviderProps } from './views/ThemeProvider'
31
+
32
+ export type SpaceDirection = 'vertical' | 'horizontal' | 'both'
33
+
34
+ export type TamaguiElement = HTMLElement | View
35
+
36
+ export type DebugProp = boolean | 'break' | 'verbose'
37
+
38
+ // base props that are accepted by createComponent (additional to react-native-web)
39
+
40
+ type DivAttributes = HTMLAttributes<HTMLDivElement>
41
+
42
+ export type TamaguiReactElement<P = any> = React.ReactElement<P> & {
43
+ type: TamaguiComponent
44
+ }
45
+
46
+ export type TamaguiComponentPropsBase = {
47
+ target?: string
48
+ hitSlop?: PressableProps['hitSlop']
49
+ asChild?: boolean
50
+ space?: SpaceTokens | null
51
+ spaceDirection?: SpaceDirection
52
+ separator?: ReactNode
53
+ dangerouslySetInnerHTML?: { __html: string }
54
+ animation?: AnimationProp | null
55
+ animateOnly?: string[]
56
+ children?: any | any[]
57
+ debug?: DebugProp
58
+ disabled?: boolean
59
+ className?: string
60
+ themeShallow?: boolean
61
+ id?: string
62
+ tag?: string
63
+ theme?: ThemeName | null
64
+ componentName?: string
65
+ /**
66
+ * Forces the pseudo style state to be on
67
+ */
68
+ forceStyle?: 'hover' | 'press' | 'focus'
69
+ onPress?: PressableProps['onPress']
70
+ onPressIn?: PressableProps['onPress']
71
+ onPressOut?: PressableProps['onPress']
72
+
73
+ // WEB ONLY TODO probably remove these in favor of something better
74
+ onHoverIn?: DivAttributes['onMouseEnter']
75
+ onHoverOut?: DivAttributes['onMouseLeave']
76
+ onMouseEnter?: DivAttributes['onMouseEnter']
77
+ onMouseLeave?: DivAttributes['onMouseLeave']
78
+ onMouseDown?: DivAttributes['onMouseDown']
79
+ onMouseUp?: DivAttributes['onMouseUp']
80
+ onFocus?: (event: React.FocusEvent<HTMLDivElement>) => void
81
+ onScroll?: (event: React.UIEvent<HTMLDivElement, UIEvent>) => void
82
+ }
83
+
84
+ export type ReactComponentWithRef<Props, Ref> = ForwardRefExoticComponent<
85
+ Props & RefAttributes<Ref>
86
+ >
87
+
88
+ export type ConfigListener = (conf: TamaguiInternalConfig) => void
89
+
90
+ // to prevent things from going circular, hoisting some types in this file
91
+ // to generally order them as building up towards TamaguiConfig
92
+
93
+ export type VariableVal = number | string | Variable
94
+ export type VariableColorVal = string | Variable
95
+
96
+ type GenericKey = string | number | symbol
97
+
98
+ export interface CreateTokens<Val extends VariableVal = VariableVal> {
99
+ color: { [key: GenericKey]: Val }
100
+ space: { [key: GenericKey]: Val }
101
+ size: { [key: GenericKey]: Val }
102
+ radius: { [key: GenericKey]: Val }
103
+ zIndex: { [key: GenericKey]: Val }
104
+ }
105
+
106
+ type Tokenify<A extends GenericTokens> = {
107
+ color: TokenifyRecord<A['color']>
108
+ space: TokenifyRecord<A['space']>
109
+ size: TokenifyRecord<A['size']>
110
+ radius: TokenifyRecord<A['radius']>
111
+ zIndex: TokenifyRecord<A['zIndex']>
112
+ }
113
+
114
+ type TokenifyRecord<A extends CreateTokens[keyof CreateTokens]> = {
115
+ [Key in keyof A]: A[Key] extends Variable ? A[Key] : Variable<A[Key]>
116
+ }
117
+
118
+ export type TamaguiBaseTheme = {
119
+ // defined for our tamagui kit , we could do this inside `tamagui`
120
+ // but maybe helpful to have some sort of universally shared things +
121
+ // + enforce if they want their own, redefine in their design sys
122
+ background: VariableColorVal
123
+ backgroundHover: VariableColorVal
124
+ backgroundPress: VariableColorVal
125
+ backgroundFocus: VariableColorVal
126
+ color: VariableColorVal
127
+ colorHover: VariableColorVal
128
+ colorPress: VariableColorVal
129
+ colorFocus: VariableColorVal
130
+ borderColor: VariableColorVal
131
+ borderColorHover: VariableColorVal
132
+ borderColorPress: VariableColorVal
133
+ borderColorFocus: VariableColorVal
134
+ shadowColor: VariableColorVal
135
+ shadowColorHover: VariableColorVal
136
+ shadowColorPress: VariableColorVal
137
+ shadowColorFocus: VariableColorVal
138
+ }
139
+
140
+ type GenericTokens = CreateTokens
141
+ type GenericThemes = {
142
+ [key: string]:
143
+ | Partial<TamaguiBaseTheme> & {
144
+ [key: string]: VariableVal
145
+ }
146
+ }
147
+
148
+ type AllStyleKeys = keyof StackStylePropsBase | keyof TextStylePropsBase
149
+
150
+ export type CreateShorthands = {
151
+ [key: string]: AllStyleKeys
152
+ }
153
+
154
+ export type GenericShorthands = {}
155
+
156
+ // sm: { minWidth: 100 }
157
+ type GenericMedia = {
158
+ [key: string]: {
159
+ [key: string]: number | string
160
+ }
161
+ }
162
+
163
+ export type GenericFonts = Record<string, GenericFont>
164
+
165
+ type GenericAnimations = {
166
+ [key: string]:
167
+ | string
168
+ | {
169
+ [key: string]: any
170
+ }
171
+ | any[]
172
+ }
173
+
174
+ // this is the "main" typed object, which users re-define
175
+ // (internal) keep all types directly on this object and reference them from elsewhere
176
+ //
177
+ // const config = createTamagui(...)
178
+ // type MyConfig = typeof config
179
+ // declare module 'tamagui' {
180
+ // export interface TamaguiCustomConfig extends MyConfig {}
181
+ // }
182
+ // now your whole app/kit should be typed correctly
183
+ //
184
+ export interface TamaguiCustomConfig {}
185
+
186
+ export interface TamaguiConfig
187
+ extends Omit<GenericTamaguiConfig, keyof TamaguiCustomConfig>,
188
+ TamaguiCustomConfig {}
189
+
190
+ export type CreateTamaguiConfig<
191
+ A extends GenericTokens,
192
+ B extends GenericThemes,
193
+ C extends GenericShorthands = GenericShorthands,
194
+ D extends GenericMedia = GenericMedia,
195
+ E extends GenericAnimations = GenericAnimations,
196
+ F extends GenericFonts = GenericFonts
197
+ > = {
198
+ fonts: RemoveLanguagePostfixes<F>
199
+ fontLanguages: GetLanguagePostfixes<F> extends never
200
+ ? string[]
201
+ : GetLanguagePostfixes<F>[]
202
+ tokens: A
203
+ // parsed
204
+ themes: {
205
+ [Name in keyof B]: {
206
+ [Key in keyof B[Name]]: Variable
207
+ }
208
+ }
209
+ shorthands: C
210
+ media: D
211
+ animations: AnimationDriver<E>
212
+ }
213
+
214
+ type GetLanguagePostfix<Set> = Set extends string
215
+ ? Set extends `${string}_${infer Postfix}`
216
+ ? Postfix
217
+ : never
218
+ : never
219
+
220
+ type OmitLanguagePostfix<Set> = Set extends string
221
+ ? Set extends `${infer Prefix}_${string}`
222
+ ? Prefix
223
+ : Set
224
+ : never
225
+
226
+ type RemoveLanguagePostfixes<F extends GenericFonts> = {
227
+ [Key in OmitLanguagePostfix<keyof F>]: F[Key]
228
+ }
229
+
230
+ type GetLanguagePostfixes<F extends GenericFonts> = GetLanguagePostfix<keyof F>
231
+
232
+ // test RemoveLanguagePostfixes
233
+ // type x = CreateTamaguiConfig<any, any, any, any, any, {
234
+ // body: any,
235
+ // body_en: any
236
+ // }>['fonts']
237
+
238
+ type ConfProps<
239
+ A extends GenericTokens,
240
+ B extends GenericThemes,
241
+ C extends GenericShorthands = GenericShorthands,
242
+ D extends GenericMedia = GenericMedia,
243
+ E extends GenericAnimations = GenericAnimations,
244
+ F extends GenericFonts = GenericFonts
245
+ > = {
246
+ tokens: A
247
+ themes: B
248
+ shorthands?: C
249
+ media?: D
250
+ animations?: AnimationDriver<E>
251
+ fonts: F
252
+ }
253
+
254
+ export type InferTamaguiConfig<Conf> = Conf extends ConfProps<
255
+ infer A,
256
+ infer B,
257
+ infer C,
258
+ infer D,
259
+ infer E,
260
+ infer F
261
+ >
262
+ ? TamaguiInternalConfig<A, B, C, D, E, F>
263
+ : unknown
264
+
265
+ // for use in creation functions so it doesnt get overwritten
266
+ export type GenericTamaguiConfig = CreateTamaguiConfig<
267
+ GenericTokens,
268
+ GenericThemes,
269
+ GenericShorthands,
270
+ GenericMedia,
271
+ GenericAnimations,
272
+ GenericFonts
273
+ >
274
+
275
+ // since TamaguiConfig will be re-declared, these will all be typed globally
276
+ export type ThemeDefinition = TamaguiConfig['themes'][keyof TamaguiConfig['themes']]
277
+ export type ThemeKeys = keyof ThemeDefinition
278
+ export type ThemeParsed = {
279
+ [key in ThemeKeys]: Variable<any>
280
+ }
281
+ export type Tokens = TamaguiConfig['tokens']
282
+ export type Shorthands = TamaguiConfig['shorthands']
283
+ export type Media = TamaguiConfig['media']
284
+ export type Themes = TamaguiConfig['themes']
285
+ export type ThemeName = Exclude<GetAltThemeNames<keyof Themes>, number>
286
+ export type ThemeTokens = `$${ThemeKeys}`
287
+ export type AnimationKeys = TamaguiConfig['animations'] extends AnimationDriver<
288
+ infer Config
289
+ >
290
+ ? keyof Config
291
+ : string
292
+ export type FontLanguages = ArrayIntersection<TamaguiConfig['fontLanguages']>
293
+
294
+ export interface ThemeProps {
295
+ className?: string
296
+ name?: Exclude<ThemeName, number> | null
297
+ componentName?: string
298
+ children?: any
299
+ reset?: boolean
300
+ debug?: boolean | 'verbose'
301
+ inverse?: boolean
302
+ // on the web, for portals we need to re-insert className
303
+ forceClassName?: boolean
304
+ // allows for disabling the auto-update behavior
305
+ shouldUpdate?: () => boolean
306
+ }
307
+
308
+ type ArrayIntersection<A extends any[]> = A[keyof A]
309
+
310
+ type GetAltThemeNames<S> =
311
+ | (S extends `${string}_${infer Alt}` ? GetAltThemeNames<Alt> : S)
312
+ | S
313
+
314
+ type SpacerPropsBase = {
315
+ size?: number | SpaceTokens | null
316
+ flex?: boolean | number
317
+ direction?: SpaceDirection
318
+ }
319
+ type SpacerOwnProps = SpacerPropsBase &
320
+ //
321
+ WithThemeShorthandsPseudosMediaAnimation<SpacerPropsBase>
322
+
323
+ export type SpacerProps = Omit<StackProps, 'flex' | 'direction' | 'size'> &
324
+ //
325
+ SpacerOwnProps
326
+
327
+ export type CreateTamaguiProps = {
328
+ reactNative?: any
329
+ shorthands?: CreateShorthands
330
+ media?: GenericTamaguiConfig['media']
331
+ animations?: AnimationDriver<any>
332
+ fonts: GenericTamaguiConfig['fonts']
333
+ tokens: GenericTamaguiConfig['tokens']
334
+ themes: {
335
+ [key: string]: {
336
+ [key: string]: string | number | Variable
337
+ }
338
+ }
339
+
340
+ /**
341
+ * *Advanced use case* For all CSS extracted views, this has no effect.
342
+ *
343
+ * For SSR compatibility on the web, Tamagui will render once with the settings
344
+ * from `mediaQueryDefaultActive` set for all media queries. Then, it will render
345
+ * again after the initial render using the proper media query values. This is so that
346
+ * hydration will match perfectly with the server.
347
+ *
348
+ * Setting disableSSR will avoid this second render by setting the media query state
349
+ * to the actual browser dimensions on initial load. This is only useful for client-only
350
+ * apps.
351
+ *
352
+ */
353
+ disableSSR?: boolean
354
+
355
+ /**
356
+ * Disable inserting a theme class in the DOM or context, allowing you to manually place it higher.
357
+ * For custom use cases like integration with next-theme.
358
+ */
359
+ disableRootThemeClass?: boolean
360
+
361
+ defaultProps?: Record<string, any> & {
362
+ Stack?: StackProps
363
+ Text?: TextProps
364
+ Spacer?: SpacerProps
365
+ }
366
+
367
+ // for the first render, determines which media queries are true
368
+ // useful for SSR
369
+ mediaQueryDefaultActive?: Record<MediaQueryKey, boolean>
370
+
371
+ // what's between each CSS style rule, set to "\n" to be easier to read
372
+ // defaults: "\n" when NODE_ENV=development, "" otherwise
373
+ cssStyleSeparator?: string
374
+
375
+ // (Advanced)
376
+ // on the web, tamagui treats `dark` and `light` themes as special and
377
+ // generates extra CSS to avoid having to re-render the entire page.
378
+ // this CSS relies on specificity hacks that multiply by your sub-themes.
379
+ // this sets the maxiumum number of nested dark/light themes you can do
380
+ // defaults to 3 for a balance, but can be higher if you nest them deeply.
381
+ maxDarkLightNesting?: number
382
+
383
+ // adds @media(prefers-color-scheme) media queries for dark/light
384
+ shouldAddPrefersColorThemes?: boolean
385
+
386
+ // only if you put the theme classname on the html element we have to generate diff
387
+ themeClassNameOnRoot?: boolean
388
+ }
389
+
390
+ // this is the config generated via createTamagui()
391
+ export type TamaguiInternalConfig<
392
+ A extends GenericTokens = GenericTokens,
393
+ B extends GenericThemes = GenericThemes,
394
+ C extends GenericShorthands = GenericShorthands,
395
+ D extends GenericMedia = GenericMedia,
396
+ E extends GenericAnimations = GenericAnimations,
397
+ F extends GenericFonts = GenericFonts
398
+ > = Omit<CreateTamaguiProps, keyof GenericTamaguiConfig> &
399
+ Omit<CreateTamaguiConfig<A, B, C, D, E, F>, 'tokens'> & {
400
+ // TODO need to make it this but this breaks types, revisit
401
+ // animations: E //AnimationDriver<E>
402
+ // with $ prefixes for fast lookups (one time cost at startup vs every render)
403
+ tokens: Tokenify<A>
404
+ tokensParsed: Tokenify<A>
405
+ themeConfig: any
406
+ fontsParsed: GenericFonts
407
+ getCSS: () => string
408
+ parsed: boolean
409
+ inverseShorthands: Record<string, string>
410
+ reactNative?: any
411
+ }
412
+
413
+ export type GetAnimationKeys<A extends GenericTamaguiConfig> = keyof A['animations']
414
+
415
+ // prevents const intersections from being clobbered into string, keeping the consts
416
+ export type UnionableString = string & {}
417
+ export type UnionableNumber = number & {}
418
+
419
+ export type GenericFont<Key extends number | string = number | string> = {
420
+ size: { [key in Key]: number | Variable }
421
+ lineHeight: Partial<{ [key in Key]: number | Variable }>
422
+ letterSpacing: Partial<{ [key in Key]: number | Variable }>
423
+ weight: Partial<{ [key in Key]: number | string | Variable }>
424
+ family: string | Variable
425
+ style?: Partial<{ [key in Key]: TextStyle['fontStyle'] | Variable }>
426
+ transform?: Partial<{ [key in Key]: TextStyle['textTransform'] | Variable }>
427
+ color?: Partial<{ [key in Key]: string | Variable }>
428
+ // for native use only, lets you map to alternative fonts
429
+ face?: Partial<{
430
+ [key in FontWeightSteps]: { normal?: string; italic?: string }
431
+ }>
432
+ }
433
+
434
+ // media
435
+ export type MediaQueryObject = { [key: string]: string | number | string }
436
+ export type MediaQueryKey = keyof Media
437
+ export type MediaPropKeys = `$${MediaQueryKey}`
438
+ export type MediaQueryState = { [key in MediaQueryKey]: boolean }
439
+ export type MediaProps<A> = {
440
+ [key in MediaPropKeys]?: A
441
+ }
442
+ export type MediaQueries = {
443
+ [key in MediaQueryKey]: MediaQueryObject
444
+ }
445
+
446
+ export interface MediaQueryList {
447
+ addListener(listener?: any): void
448
+ removeListener(listener?: any): void
449
+ matches: boolean
450
+ }
451
+
452
+ export type MatchMedia = (query: string) => MediaQueryList
453
+
454
+ export type TransformStyleProps = {
455
+ x?: number
456
+ y?: number
457
+ perspective?: number
458
+ scale?: number
459
+ scaleX?: number
460
+ scaleY?: number
461
+ skewX?: string
462
+ skewY?: string
463
+ matrix?: number[]
464
+ rotate?: string
465
+ rotateY?: string
466
+ rotateX?: string
467
+ rotateZ?: string
468
+ }
469
+
470
+ // createComponent props helpers
471
+
472
+ // animation="bouncy"
473
+ // animation={['bouncy', { }]}
474
+ // { all: 'name' }
475
+
476
+ // TODO can override for better types
477
+ export type AnimationConfigType = any
478
+
479
+ export type AnimationProp =
480
+ | AnimationKeys
481
+ | {
482
+ [key: string]:
483
+ | AnimationKeys
484
+ | {
485
+ type: AnimationKeys
486
+ [key: string]: any
487
+ }
488
+ }
489
+ | [
490
+ AnimationKeys,
491
+ {
492
+ [key: string]:
493
+ | AnimationKeys
494
+ | {
495
+ type?: AnimationKeys
496
+ [key: string]: any
497
+ }
498
+ }
499
+ ]
500
+
501
+ type GetTokenFontKeysFor<
502
+ A extends
503
+ | 'size'
504
+ | 'weight'
505
+ | 'letterSpacing'
506
+ | 'family'
507
+ | 'lineHeight'
508
+ | 'transform'
509
+ | 'style'
510
+ | 'color'
511
+ > = keyof TamaguiConfig['fonts']['body'][A]
512
+
513
+ type GetTokenString<A> = A extends string | number ? `$${A}` : `$${string}`
514
+
515
+ // base tokens
516
+ export type SizeTokens = GetTokenString<keyof Tokens['size']> | number
517
+ export type SpaceTokens = GetTokenString<keyof Tokens['space']> | number | boolean
518
+
519
+ export type ColorTokens =
520
+ | GetTokenString<keyof Tokens['color']>
521
+ | GetTokenString<keyof ThemeParsed>
522
+ | CSSColorNames
523
+ export type ZIndexTokens = GetTokenString<keyof Tokens['zIndex']> | number
524
+ export type RadiusTokens = GetTokenString<keyof Tokens['radius']> | number
525
+
526
+ // font tokens
527
+ export type FontTokens = GetTokenString<keyof TamaguiConfig['fonts']>
528
+ export type FontSizeTokens = GetTokenString<GetTokenFontKeysFor<'size'>> | number
529
+ export type FontLineHeightTokens = `$${GetTokenFontKeysFor<'lineHeight'>}` | number
530
+ export type FontWeightSteps = `${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}00`
531
+ export type FontWeightTokens = `$${GetTokenFontKeysFor<'weight'>}` | FontWeightSteps
532
+ export type FontColorTokens = `$${GetTokenFontKeysFor<'color'>}` | number
533
+ export type FontLetterSpacingTokens = `$${GetTokenFontKeysFor<'letterSpacing'>}` | number
534
+ export type FontStyleTokens = `$${GetTokenFontKeysFor<'style'>}` | TextStyle['fontStyle']
535
+ export type FontTransformTokens =
536
+ | `$${GetTokenFontKeysFor<'transform'>}`
537
+ | TextStyle['textTransform']
538
+
539
+ //
540
+ // adds theme short values to relevant props
541
+ //
542
+
543
+ export type ThemeValueByCategory<K extends string | number | symbol> = K extends 'theme'
544
+ ? ThemeTokens
545
+ : K extends 'size'
546
+ ? SizeTokens
547
+ : K extends 'font'
548
+ ? FontTokens
549
+ : K extends 'fontSize'
550
+ ? FontSizeTokens
551
+ : K extends 'space'
552
+ ? SpaceTokens
553
+ : K extends 'color'
554
+ ? ColorTokens
555
+ : K extends 'zIndex'
556
+ ? ZIndexTokens
557
+ : K extends 'lineHeight'
558
+ ? FontLineHeightTokens
559
+ : K extends 'fontWeight'
560
+ ? FontWeightTokens
561
+ : K extends 'letterSpacing'
562
+ ? FontLetterSpacingTokens
563
+ : {}
564
+
565
+ type FontKeys = 'fontFamily'
566
+ type FontSizeKeys = 'fontSize'
567
+ type FontWeightKeys = 'fontWeight'
568
+ type FontLetterSpacingKeys = 'letterSpacing'
569
+ type LineHeightKeys = 'lineHeight'
570
+ type ZIndexKeys = 'zIndex'
571
+
572
+ export type ThemeValueGet<K extends string | number | symbol> = K extends 'theme'
573
+ ? ThemeTokens
574
+ : K extends SizeKeys
575
+ ? SizeTokens
576
+ : K extends FontKeys
577
+ ? FontTokens
578
+ : K extends FontSizeKeys
579
+ ? FontSizeTokens
580
+ : K extends `${`border${string | ''}Radius`}`
581
+ ? RadiusTokens
582
+ : K extends SpaceKeys
583
+ ? K extends 'shadowOffset'
584
+ ? { width: SpaceTokens; height: SpaceTokens }
585
+ : SpaceTokens
586
+ : K extends ColorKeys
587
+ ? ColorTokens
588
+ : K extends ZIndexKeys
589
+ ? ZIndexTokens
590
+ : K extends LineHeightKeys
591
+ ? FontLineHeightTokens
592
+ : K extends FontWeightKeys
593
+ ? FontWeightTokens
594
+ : K extends FontLetterSpacingKeys
595
+ ? FontLetterSpacingTokens
596
+ : never
597
+
598
+ export type ThemeValueFallback = UnionableString | Variable
599
+
600
+ export type WithThemeValues<T extends object> = {
601
+ [K in keyof T]: ThemeValueGet<K> extends never
602
+ ? T[K]
603
+ : ThemeValueGet<K> | Exclude<T[K], string> | ThemeValueFallback
604
+ }
605
+
606
+ // adds shorthand props
607
+ export type WithShorthands<StyleProps> = {
608
+ [Key in keyof Shorthands]?: Shorthands[Key] extends keyof StyleProps
609
+ ? StyleProps[Shorthands[Key]] | null
610
+ : undefined
611
+ }
612
+
613
+ // adds pseudo props
614
+ export type PseudoProps<A> = {
615
+ hoverStyle?: A | null
616
+ pressStyle?: A | null
617
+ focusStyle?: A | null
618
+ exitStyle?: A | null
619
+ enterStyle?: A | null
620
+ }
621
+
622
+ export type PseudoPropKeys = keyof PseudoProps<any>
623
+
624
+ export type PseudoStyles = {
625
+ hoverStyle?: ViewStyle
626
+ pressStyle?: ViewStyle
627
+ focusStyle?: ViewStyle
628
+ enterStyle?: ViewStyle
629
+ exitStyle?: ViewStyle
630
+ }
631
+
632
+ //
633
+ // add both theme and shorthands
634
+ //
635
+ type WithThemeAndShorthands<A extends object> = WithThemeValues<A> &
636
+ WithShorthands<WithThemeValues<A>>
637
+
638
+ //
639
+ // combines all of theme, shorthands, pseudos...
640
+ //
641
+ type WithThemeShorthandsAndPseudos<A extends object> =
642
+ | WithThemeAndShorthands<A> & PseudoProps<WithThemeAndShorthands<A>>
643
+
644
+ //
645
+ // ... media queries and animations
646
+ //
647
+ type WithThemeShorthandsPseudosMediaAnimation<A extends object> =
648
+ WithThemeShorthandsAndPseudos<A> & MediaProps<WithThemeShorthandsAndPseudos<A>>
649
+
650
+ /**
651
+ * Base style-only props (no media, pseudo):
652
+ */
653
+
654
+ type PropsWebOnly = {
655
+ pointerEvents?: ViewProps['pointerEvents']
656
+ cursor?: Properties['cursor']
657
+ contain?: Properties['contain']
658
+ display?: 'inherit' | 'none' | 'inline' | 'block' | 'contents' | 'flex' | 'inline-flex'
659
+ userSelect?: Properties['userSelect']
660
+ outlineColor?: Properties['outlineColor']
661
+ outlineStyle?: Properties['outlineStyle']
662
+ outlineOffset?: Properties['outlineOffset']
663
+ outlineWidth?: Properties['outlineWidth']
664
+ tabIndex?: string | number
665
+ role?: string
666
+ }
667
+
668
+ export type StackStylePropsBase = Omit<
669
+ ViewStyle,
670
+ 'display' | 'backfaceVisibility' | 'elevation'
671
+ > &
672
+ TransformStyleProps &
673
+ PropsWebOnly
674
+
675
+ export type TextStylePropsBase = Omit<TextStyle, 'display' | 'backfaceVisibility'> &
676
+ TransformStyleProps &
677
+ PropsWebOnly & {
678
+ ellipse?: boolean
679
+ textDecorationDistance?: number
680
+ textOverflow?: Properties['textOverflow']
681
+ whiteSpace?: Properties['whiteSpace']
682
+ wordWrap?: Properties['wordWrap']
683
+ }
684
+
685
+ export interface ExtendBaseStackProps {}
686
+ export interface ExtendsBaseTextProps {}
687
+
688
+ //
689
+ // Stack
690
+ //
691
+
692
+ // these are added back in by core
693
+ type OmitRemovedNonWebProps = 'onLayout' | keyof GestureResponderHandlers
694
+
695
+ export type StackNonStyleProps = Omit<
696
+ ViewProps,
697
+ 'display' | 'children' | OmitRemovedNonWebProps
698
+ > &
699
+ ExtendBaseStackProps &
700
+ TamaguiComponentPropsBase
701
+
702
+ export type StackStyleProps =
703
+ WithThemeShorthandsPseudosMediaAnimation<StackStylePropsBase>
704
+ export type StackPropsBase = StackNonStyleProps &
705
+ WithThemeAndShorthands<StackStylePropsBase>
706
+ export type StackProps = StackNonStyleProps & StackStyleProps
707
+
708
+ //
709
+ // Text props
710
+ //
711
+
712
+ export type TextNonStyleProps = Omit<
713
+ ReactTextProps,
714
+ 'children' | OmitRemovedNonWebProps
715
+ > &
716
+ ExtendsBaseTextProps &
717
+ TamaguiComponentPropsBase
718
+
719
+ export type TextPropsBase = TextNonStyleProps & WithThemeAndShorthands<TextStylePropsBase>
720
+
721
+ export type TextStyleProps = WithThemeShorthandsPseudosMediaAnimation<TextStylePropsBase>
722
+ export type TextProps = TextNonStyleProps & TextStyleProps
723
+
724
+ // could actually infer from parent
725
+ export type ViewOrTextProps = WithThemeShorthandsPseudosMediaAnimation<
726
+ Omit<TextStylePropsBase, keyof StackStylePropsBase> & StackStylePropsBase
727
+ >
728
+
729
+ //
730
+ // StaticComponent
731
+ //
732
+
733
+ export type TamaguiComponent<
734
+ Props = any,
735
+ Ref = any,
736
+ BaseProps = {},
737
+ VariantProps = {}
738
+ > = ReactComponentWithRef<Props, Ref> & StaticComponentObject
739
+
740
+ type StaticComponentObject = {
741
+ staticConfig: StaticConfigParsed
742
+ /*
743
+ * Only needed for more complex components
744
+ * If you create a styled frame component this is a HoC to extract
745
+ * styles from all parents.
746
+ */
747
+ extractable: <X>(a: X, opts?: Partial<StaticConfig>) => X
748
+ }
749
+
750
+ export type TamaguiProviderProps = Partial<Omit<ThemeProviderProps, 'children'>> & {
751
+ config: TamaguiInternalConfig
752
+ disableInjectCSS?: boolean
753
+ children?: ReactNode
754
+ }
755
+
756
+ export type PropMapper = (
757
+ key: string,
758
+ value: any,
759
+ theme: ThemeParsed,
760
+ props: Record<string, any>,
761
+ state: Partial<SplitStyleState>,
762
+ languageContext?: FontLanguageProps,
763
+ avoidDefaultProps?: boolean,
764
+ debug?: DebugProp
765
+ ) => undefined | [string, any][]
766
+
767
+ export type StaticConfigParsed = StaticConfig & {
768
+ parsed: true
769
+ propMapper: PropMapper
770
+ variantsParsed?: {
771
+ [key: string]: {
772
+ [key: string]: any
773
+ }
774
+ }
775
+ }
776
+
777
+ export type GenericVariantDefinitions = {
778
+ [key: string]: {
779
+ [key: string]:
780
+ | ((a: any, b: any) => any)
781
+ | {
782
+ [key: string]: any
783
+ }
784
+ }
785
+ }
786
+
787
+ export type StaticConfigPublic = {
788
+ /**
789
+ * (compiler) If you need to pass context or something, prevents from ever
790
+ * flattening. The 'jsx' option means it will never flatten. if you
791
+ * pass JSX as a children (if its purely string, it will still flatten).
792
+ */
793
+ neverFlatten?: boolean | 'jsx'
794
+
795
+ /**
796
+ * Determines ultimate output tag (Text vs View)
797
+ */
798
+ isText?: boolean
799
+
800
+ /**
801
+ * Which style keys are allowed to be extracted.
802
+ */
803
+ validStyles?: { [key: string]: boolean }
804
+
805
+ /**
806
+ * (compiler) If these props are encountered, bail on all optimization.
807
+ */
808
+ deoptProps?: Set<string>
809
+
810
+ /**
811
+ * (compiler) If these props are encountered, leave them un-extracted.
812
+ */
813
+ inlineProps?: Set<string>
814
+
815
+ /**
816
+ * (compiler) If not flattening, leave this prop as original value.
817
+ * Only applies to style attributes
818
+ */
819
+ inlineWhenUnflattened?: Set<string>
820
+
821
+ /**
822
+ * (compiler) A bit odd, only for more advanced heirarchies.
823
+ * Indicates that the component will set this prop so the
824
+ * static extraction can ensure it sets them to ={undefined}
825
+ * so they get overriddent. In the future, this can be smarter.
826
+ */
827
+ ensureOverriddenProp?: { [key: string]: boolean }
828
+
829
+ /**
830
+ * Auto-detected, but can ovverride. Wraps children to space them on top
831
+ */
832
+ isZStack?: boolean
833
+
834
+ /**
835
+ * Auto-detect, but can override, passes styles properly to react-native-web
836
+ */
837
+ isReactNative?: boolean
838
+
839
+ /**
840
+ * By default if styled() doesn't recognize a parent Tamagui compoent or specific react-native views,
841
+ * it will assume the passed in component only accepts style={} for react-native compatibility.
842
+ * Setting `acceptsClassName: true` indicates Tamagui can pass in className props.
843
+ */
844
+ acceptsClassName?: boolean
845
+ }
846
+
847
+ export type StaticConfig = StaticConfigPublic & {
848
+ Component?: FunctionComponent<any> & StaticComponentObject
849
+
850
+ variants?: GenericVariantDefinitions
851
+
852
+ /**
853
+ * Used for applying sub theme style
854
+ */
855
+ componentName?: string
856
+
857
+ /**
858
+ * Same as React.defaultProps, be sure to sync
859
+ */
860
+ defaultProps: Record<string, any>
861
+
862
+ /**
863
+ * Merges into defaultProps later on, used internally yonly
864
+ */
865
+ defaultVariants?: { [key: string]: any }
866
+
867
+ /**
868
+ * Memoize the component
869
+ */
870
+ memo?: boolean
871
+
872
+ /**
873
+ * Used insternally to attach default props to names
874
+ */
875
+ parentNames?: string[]
876
+
877
+ /**
878
+ * By default if styled() doesn't recognize a parent Tamagui compoent or specific react-native views,
879
+ * it will assume the passed in component only accepts style={} for react-native compatibility.
880
+ * Setting `acceptsClassName: true` indicates Tamagui can pass in className props.
881
+ */
882
+ acceptsClassName?: boolean
883
+
884
+ /**
885
+ * Used internally for handling focus
886
+ */
887
+ isInput?: boolean
888
+
889
+ /**
890
+ * Used internally for knowing how to handle when a HOC is in-between styled()
891
+ */
892
+ isHOC?: boolean
893
+ }
894
+
895
+ /**
896
+ * --------------------------------------------
897
+ * variants
898
+ * --------------------------------------------
899
+ */
900
+
901
+ export type StylableComponent =
902
+ | TamaguiComponent
903
+ // * excessively deep type instantiation
904
+ // | TamaguiReactElement
905
+ | ComponentType<any>
906
+ | ForwardRefExoticComponent<any>
907
+ | ReactComponentWithRef<any, any>
908
+ | (new (props: any) => any)
909
+ | typeof View
910
+ | typeof Text
911
+ | typeof TextInput
912
+ | typeof Image
913
+
914
+ export type GetStyledVariants<A extends TamaguiComponent> = A extends TamaguiComponent<
915
+ any,
916
+ any,
917
+ any,
918
+ infer Variants
919
+ >
920
+ ? Variants
921
+ : never
922
+
923
+ export type GetBaseProps<A extends StylableComponent> = A extends TamaguiComponent<
924
+ any,
925
+ any,
926
+ infer BaseProps
927
+ >
928
+ ? BaseProps
929
+ : never
930
+
931
+ export type GetProps<A extends StylableComponent> = A extends TamaguiComponent<
932
+ infer Props
933
+ >
934
+ ? Props
935
+ : A extends TamaguiReactElement<infer Props>
936
+ ? Props
937
+ : A extends ComponentType<infer Props>
938
+ ? GetGenericComponentTamaguiProps<Props>
939
+ : A extends new (props: infer Props) => any
940
+ ? GetGenericComponentTamaguiProps<Props>
941
+ : {}
942
+
943
+ type GetGenericComponentTamaguiProps<P> = P &
944
+ Omit<'textAlign' extends keyof P ? TextProps : StackProps, keyof P>
945
+
946
+ export type SpreadKeys =
947
+ | '...fontSize'
948
+ | '...fontStyle'
949
+ | '...fontTransform'
950
+ | '...lineHeight'
951
+ | '...letterSpacing'
952
+ | '...size'
953
+ | '...space'
954
+ | '...color'
955
+ | '...zIndex'
956
+ | '...theme'
957
+ | '...radius'
958
+
959
+ export type VariantDefinitions<
960
+ Parent extends StylableComponent = TamaguiComponent,
961
+ MyProps extends Object = GetProps<Parent>,
962
+ Val = any
963
+ > = VariantDefinitionFromProps<MyProps, Val>
964
+
965
+ export type VariantDefinitionFromProps<MyProps, Val> = MyProps extends Object
966
+ ? {
967
+ [propName: string]:
968
+ | VariantSpreadFunction<MyProps, Val>
969
+ | ({
970
+ [Key in SpreadKeys]?: Key extends '...fontSize'
971
+ ? FontSizeVariantSpreadFunction<MyProps>
972
+ : Key extends '...size'
973
+ ? SizeVariantSpreadFunction<MyProps>
974
+ : Key extends '...space'
975
+ ? SpaceVariantSpreadFunction<MyProps>
976
+ : Key extends '...color'
977
+ ? ColorVariantSpreadFunction<MyProps>
978
+ : Key extends '...lineHeight'
979
+ ? FontLineHeightVariantSpreadFunction<MyProps>
980
+ : Key extends '...fontTransform'
981
+ ? FontTransformVariantSpreadFunction<MyProps>
982
+ : Key extends '...fontStyle'
983
+ ? FontStyleVariantSpreadFunction<MyProps>
984
+ : Key extends '...letterSpacing'
985
+ ? FontLetterSpacingVariantSpreadFunction<MyProps>
986
+ : Key extends '...zIndex'
987
+ ? ZIndexVariantSpreadFunction<MyProps>
988
+ : Key extends '...radius'
989
+ ? RadiusVariantSpreadFunction<MyProps>
990
+ : Key extends '...theme'
991
+ ? ThemeVariantSpreadFunction<MyProps>
992
+ : never
993
+ } & {
994
+ [Key in string | number | 'true' | 'false']?:
995
+ | MyProps
996
+ | VariantSpreadFunction<MyProps, Val>
997
+ } & {
998
+ [Key in VariantTypeKeys]?: Key extends ':number'
999
+ ? VariantSpreadFunction<MyProps, number>
1000
+ : Key extends ':boolean'
1001
+ ? VariantSpreadFunction<MyProps, boolean>
1002
+ : Key extends ':string'
1003
+ ? VariantSpreadFunction<MyProps, string>
1004
+ : never
1005
+ })
1006
+ }
1007
+ : never
1008
+
1009
+ export type GenericStackVariants = VariantDefinitionFromProps<StackProps, any>
1010
+ export type GenericTextVariants = VariantDefinitionFromProps<StackProps, any>
1011
+
1012
+ export type GetVariantProps<Variants> = {
1013
+ [Key in keyof Variants]?: Variants[Key] extends VariantSpreadFunction<any, infer Val>
1014
+ ? Val
1015
+ : GetVariantValues<keyof Variants[Key]>
1016
+ }
1017
+
1018
+ export type VariantSpreadExtras<Props> = {
1019
+ fonts: TamaguiConfig['fonts']
1020
+ tokens: TamaguiConfig['tokens']
1021
+ theme: Themes extends { [key: string]: infer B } ? B : unknown
1022
+ props: Props
1023
+ }
1024
+
1025
+ type PropLike = { [key: string]: any }
1026
+
1027
+ export type VariantSpreadFunction<Props extends PropLike, Val = any> = (
1028
+ val: Val,
1029
+ config: VariantSpreadExtras<Props>
1030
+ ) =>
1031
+ | {
1032
+ [Key in keyof Props]: Props[Key] | Variable
1033
+ }
1034
+ | null
1035
+ | undefined
1036
+
1037
+ export type VariantTypeKeys = ':string' | ':boolean' | ':number'
1038
+
1039
+ export type GetVariantValues<Key> = Key extends `...${infer VariantSpread}`
1040
+ ? ThemeValueByCategory<VariantSpread>
1041
+ : Key extends 'true' | 'false'
1042
+ ? boolean
1043
+ : Key extends ':string'
1044
+ ? string
1045
+ : Key extends ':boolean'
1046
+ ? boolean
1047
+ : Key extends ':number'
1048
+ ? number
1049
+ : Key
1050
+
1051
+ export type FontSizeVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<
1052
+ A,
1053
+ FontSizeTokens
1054
+ >
1055
+ export type SizeVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<
1056
+ A,
1057
+ SizeTokens
1058
+ >
1059
+ export type SpaceVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<
1060
+ A,
1061
+ SpaceTokens
1062
+ >
1063
+ export type ColorVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<
1064
+ A,
1065
+ ColorTokens
1066
+ >
1067
+ export type FontLineHeightVariantSpreadFunction<A extends PropLike> =
1068
+ VariantSpreadFunction<A, FontLineHeightTokens>
1069
+ export type FontLetterSpacingVariantSpreadFunction<A extends PropLike> =
1070
+ VariantSpreadFunction<A, FontLetterSpacingTokens>
1071
+ export type FontStyleVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<
1072
+ A,
1073
+ FontStyleTokens
1074
+ >
1075
+ export type FontTransformVariantSpreadFunction<A extends PropLike> =
1076
+ VariantSpreadFunction<A, FontTransformTokens>
1077
+ export type ZIndexVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<
1078
+ A,
1079
+ ZIndexTokens
1080
+ >
1081
+ export type RadiusVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<
1082
+ A,
1083
+ RadiusTokens
1084
+ >
1085
+ export type ThemeVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<
1086
+ A,
1087
+ ThemeTokens
1088
+ >
1089
+
1090
+ /**
1091
+ * --------------------------------------------
1092
+ * end variants
1093
+ * --------------------------------------------
1094
+ */
1095
+
1096
+ type SizeKeys =
1097
+ | 'width'
1098
+ | 'height'
1099
+ | 'minWidth'
1100
+ | 'minHeight'
1101
+ | 'maxWidth'
1102
+ | 'maxHeight'
1103
+ | 'shadowRadius'
1104
+
1105
+ type ColorKeys =
1106
+ | 'color'
1107
+ | 'backgroundColor'
1108
+ | 'borderColor'
1109
+ | 'borderBottomColor'
1110
+ | 'borderTopColor'
1111
+ | 'borderLeftColor'
1112
+ | 'borderRightColor'
1113
+ | 'shadowColor'
1114
+ | 'textShadowColor'
1115
+
1116
+ type SpaceKeys =
1117
+ | 'space'
1118
+ | 'padding'
1119
+ | 'paddingHorizontal'
1120
+ | 'paddingVertical'
1121
+ | 'paddingLeft'
1122
+ | 'paddingTop'
1123
+ | 'paddingBottom'
1124
+ | 'paddingLeft'
1125
+ | 'paddingRight'
1126
+ | 'paddingEnd'
1127
+ | 'paddingStart'
1128
+ | 'margin'
1129
+ | 'marginHorizontal'
1130
+ | 'marginVertical'
1131
+ | 'marginLeft'
1132
+ | 'marginTop'
1133
+ | 'marginBottom'
1134
+ | 'marginLeft'
1135
+ | 'marginRight'
1136
+ | 'marginEnd'
1137
+ | 'marginStart'
1138
+ | 'x'
1139
+ | 'y'
1140
+ | 'scale'
1141
+ | 'scaleX'
1142
+ | 'scaleY'
1143
+ | 'borderTopEndRadius'
1144
+ | 'borderTopLeftRadius'
1145
+ | 'borderTopRightRadius'
1146
+ | 'borderTopStartRadius'
1147
+ | 'borderBottomEndRadius'
1148
+ | 'borderBottomLeftRadius'
1149
+ | 'borderBottomRightRadius'
1150
+ | 'borderBottomStartRadius'
1151
+ | 'borderBottomWidth'
1152
+ | 'borderLeftWidth'
1153
+ | 'borderRadius'
1154
+ | 'borderRightWidth'
1155
+ | 'borderTopEndRadius'
1156
+ | 'borderTopLeftRadius'
1157
+ | 'borderTopRightRadius'
1158
+ | 'borderEndWidth'
1159
+ | 'borderStartWidth'
1160
+ | 'borderTopStartRadius'
1161
+ | 'borderTopWidth'
1162
+ | 'borderWidth'
1163
+ | 'left'
1164
+ | 'top'
1165
+ | 'right'
1166
+ | 'bottom'
1167
+ | 'shadowOffset'
1168
+
1169
+ type CSSColorNames =
1170
+ | 'aliceblue'
1171
+ | 'antiquewhite'
1172
+ | 'aqua'
1173
+ | 'aquamarine'
1174
+ | 'azure'
1175
+ | 'beige'
1176
+ | 'bisque'
1177
+ | 'black'
1178
+ | 'blanchedalmond'
1179
+ | 'blue'
1180
+ | 'blueviolet'
1181
+ | 'brown'
1182
+ | 'burlywood'
1183
+ | 'cadetblue'
1184
+ | 'chartreuse'
1185
+ | 'chocolate'
1186
+ | 'coral'
1187
+ | 'cornflowerblue'
1188
+ | 'cornsilk'
1189
+ | 'crimson'
1190
+ | 'cyan'
1191
+ | 'darkblue'
1192
+ | 'darkcyan'
1193
+ | 'darkgoldenrod'
1194
+ | 'darkgray'
1195
+ | 'darkgreen'
1196
+ | 'darkkhaki'
1197
+ | 'darkmagenta'
1198
+ | 'darkolivegreen'
1199
+ | 'darkorange'
1200
+ | 'darkorchid'
1201
+ | 'darkred'
1202
+ | 'darksalmon'
1203
+ | 'darkseagreen'
1204
+ | 'darkslateblue'
1205
+ | 'darkslategray'
1206
+ | 'darkturquoise'
1207
+ | 'darkviolet'
1208
+ | 'deeppink'
1209
+ | 'deepskyblue'
1210
+ | 'dimgray'
1211
+ | 'dodgerblue'
1212
+ | 'firebrick'
1213
+ | 'floralwhite'
1214
+ | 'forestgreen'
1215
+ | 'fuchsia'
1216
+ | 'gainsboro'
1217
+ | 'ghostwhite'
1218
+ | 'gold'
1219
+ | 'goldenrod'
1220
+ | 'gray'
1221
+ | 'green'
1222
+ | 'greenyellow'
1223
+ | 'honeydew'
1224
+ | 'hotpink'
1225
+ | 'indianred '
1226
+ | 'indigo '
1227
+ | 'ivory'
1228
+ | 'khaki'
1229
+ | 'lavender'
1230
+ | 'lavenderblush'
1231
+ | 'lawngreen'
1232
+ | 'lemonchiffon'
1233
+ | 'lightblue'
1234
+ | 'lightcoral'
1235
+ | 'lightcyan'
1236
+ | 'lightgoldenrodyellow'
1237
+ | 'lightgrey'
1238
+ | 'lightgreen'
1239
+ | 'lightpink'
1240
+ | 'lightsalmon'
1241
+ | 'lightseagreen'
1242
+ | 'lightskyblue'
1243
+ | 'lightslategray'
1244
+ | 'lightsteelblue'
1245
+ | 'lightyellow'
1246
+ | 'lime'
1247
+ | 'limegreen'
1248
+ | 'linen'
1249
+ | 'magenta'
1250
+ | 'maroon'
1251
+ | 'mediumaquamarine'
1252
+ | 'mediumblue'
1253
+ | 'mediumorchid'
1254
+ | 'mediumpurple'
1255
+ | 'mediumseagreen'
1256
+ | 'mediumslateblue'
1257
+ | 'mediumspringgreen'
1258
+ | 'mediumturquoise'
1259
+ | 'mediumvioletred'
1260
+ | 'midnightblue'
1261
+ | 'mintcream'
1262
+ | 'mistyrose'
1263
+ | 'moccasin'
1264
+ | 'navajowhite'
1265
+ | 'navy'
1266
+ | 'oldlace'
1267
+ | 'olive'
1268
+ | 'olivedrab'
1269
+ | 'orange'
1270
+ | 'orangered'
1271
+ | 'orchid'
1272
+ | 'palegoldenrod'
1273
+ | 'palegreen'
1274
+ | 'paleturquoise'
1275
+ | 'palevioletred'
1276
+ | 'papayawhip'
1277
+ | 'peachpuff'
1278
+ | 'peru'
1279
+ | 'pink'
1280
+ | 'plum'
1281
+ | 'powderblue'
1282
+ | 'purple'
1283
+ | 'red'
1284
+ | 'rosybrown'
1285
+ | 'royalblue'
1286
+ | 'saddlebrown'
1287
+ | 'salmon'
1288
+ | 'sandybrown'
1289
+ | 'seagreen'
1290
+ | 'seashell'
1291
+ | 'sienna'
1292
+ | 'silver'
1293
+ | 'skyblue'
1294
+ | 'slateblue'
1295
+ | 'slategray'
1296
+ | 'snow'
1297
+ | 'springgreen'
1298
+ | 'steelblue'
1299
+ | 'tan'
1300
+ | 'teal'
1301
+ | 'thistle'
1302
+ | 'tomato'
1303
+ | 'turquoise'
1304
+ | 'violet'
1305
+ | 'wheat'
1306
+ | 'white'
1307
+ | 'whitesmoke'
1308
+ | 'yellow'
1309
+ | 'yellowgreen'
1310
+
1311
+ export type TamaguiComponentState = {
1312
+ hover: boolean
1313
+ press: boolean
1314
+ pressIn: boolean
1315
+ focus: boolean
1316
+ unmounted: boolean
1317
+ animation?: null | {
1318
+ style?: any
1319
+ avoidClasses?: boolean
1320
+ }
1321
+ }
1322
+
1323
+ export type SplitStyleState = TamaguiComponentState & {
1324
+ mediaState?: Record<string, boolean>
1325
+ noClassNames?: boolean
1326
+ dynamicStylesInline?: boolean
1327
+ resolveVariablesAs?: ResolveVariableTypes
1328
+ fallbackProps?: Record<string, any>
1329
+ keepVariantsAsProps?: boolean
1330
+ hasTextAncestor?: boolean
1331
+
1332
+ // for animations
1333
+ isExiting?: boolean
1334
+ exitVariant?: string
1335
+ enterVariant?: string
1336
+ }
1337
+
1338
+ // Presence
1339
+
1340
+ export interface PresenceContextProps {
1341
+ id: string
1342
+ isPresent: boolean
1343
+ register: (id: string) => () => void
1344
+ onExitComplete?: (id: string) => void
1345
+ initial?: false | string | string[]
1346
+ custom?: any
1347
+ exitVariant?: string | null
1348
+ enterVariant?: string | null
1349
+ }
1350
+
1351
+ type SafeToRemoveCallback = () => void
1352
+ type AlwaysPresent = [true, null, null]
1353
+ type Present = [true, undefined, PresenceContextProps]
1354
+ type NotPresent = [false, SafeToRemoveCallback, PresenceContextProps]
1355
+
1356
+ export type UsePresenceResult = AlwaysPresent | Present | NotPresent
1357
+
1358
+ // Animations:
1359
+
1360
+ type AnimationConfig = {
1361
+ [key: string]: any
1362
+ }
1363
+
1364
+ // includes a very limited adapter between various impls for number => style
1365
+ // this is useful only in limited scenarios like `Sheet`, but necessary in those cases
1366
+
1367
+ export type AnimatedNumberStrategy =
1368
+ // only values shared between reanimated/react-native for now
1369
+ | {
1370
+ type: 'spring'
1371
+ stiffness?: number
1372
+ damping?: number
1373
+ mass?: number
1374
+ overshootClamping?: boolean
1375
+ restSpeedThreshold?: number
1376
+ restDisplacementThreshold?: number
1377
+ }
1378
+ | { type: 'timing'; duration: number }
1379
+ | { type: 'direct' }
1380
+
1381
+ export type UniversalAnimatedNumber<A> = {
1382
+ getInstance(): A
1383
+ getValue(): number
1384
+ setValue(next: number, config?: AnimatedNumberStrategy): void
1385
+ stop(): void
1386
+ }
1387
+
1388
+ export type AnimationDriver<A extends AnimationConfig = AnimationConfig> = {
1389
+ isReactNative?: boolean
1390
+ useAnimations: UseAnimationHook
1391
+ usePresence: () => UsePresenceResult
1392
+ useAnimatedNumber: (initial: number) => UniversalAnimatedNumber<any>
1393
+ useAnimatedNumberStyle: <V extends UniversalAnimatedNumber<any>>(
1394
+ val: V,
1395
+ getStyle: (current: any) => any
1396
+ ) => any
1397
+ useAnimatedNumberReaction: (
1398
+ val: UniversalAnimatedNumber<any>,
1399
+ onValue: (current: number) => void
1400
+ ) => void
1401
+ animations: A
1402
+ View?: any
1403
+ Text?: any
1404
+ }
1405
+
1406
+ export type UseAnimationProps = TamaguiComponentPropsBase & Record<string, any>
1407
+
1408
+ export type UseAnimationHook = (props: {
1409
+ style: Record<string, any>
1410
+ props: Record<string, any>
1411
+ presence?: UsePresenceResult | null
1412
+ hostRef: RefObject<HTMLElement | View>
1413
+ staticConfig: StaticConfigParsed
1414
+ state: SplitStyleState
1415
+ pseudos: PseudoProps<ViewStyle> | null
1416
+ onDidAnimate?: any
1417
+ delay?: number
1418
+ }) => null | {
1419
+ style?: StackStylePropsBase | StackStylePropsBase[]
1420
+ }
1421
+
1422
+ export type GestureReponderEvent = Exclude<
1423
+ View['props']['onResponderMove'],
1424
+ void
1425
+ > extends (event: infer Event) => void
1426
+ ? Event
1427
+ : never
1428
+
1429
+ export type PartialStyleObject = Pick<StyleObject, 'identifier' | 'property' | 'rules'>
1430
+ export type RulesToInsert = PartialStyleObject[]
1431
+
1432
+ export type GetStyleResult = {
1433
+ pseudos?: PseudoStyles
1434
+ style: ViewStyle
1435
+ classNames: ClassNamesObject
1436
+ rulesToInsert: RulesToInsert
1437
+ viewProps: StackProps & Record<string, any>
1438
+ fontFamily: string | undefined
1439
+ space?: any // SpaceTokens?
1440
+ hasMedia: boolean | 'space'
1441
+ }
1442
+
1443
+ export type ClassNamesObject = Record<string, string>
1444
+
1445
+ export type TamaguiComponentEvents = {
1446
+ cancelable?: boolean | undefined
1447
+ disabled?: any
1448
+ hitSlop?: any
1449
+ delayLongPress?: any
1450
+ delayPressIn?: any
1451
+ delayPressOut?: any
1452
+ focusable?: any
1453
+ minPressDuration?: number | undefined
1454
+ onPressIn: ((e: any) => void) | undefined
1455
+ onPress: ((e: any) => void) | undefined
1456
+ onMouseEnter?: ((e: any) => void) | undefined
1457
+ onMouseLeave?: ((e: any) => void) | undefined
1458
+ onPressOut: ((e: any) => void) | undefined
1459
+ }