@tamagui/core 1.0.1-beta.18 → 1.0.1-beta.181

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 (768) hide show
  1. package/dist/cjs/Tamagui.js +14 -12
  2. package/dist/cjs/Tamagui.js.map +2 -2
  3. package/dist/cjs/addTheme.js +80 -0
  4. package/dist/cjs/addTheme.js.map +7 -0
  5. package/dist/cjs/{conf.js → config.js} +33 -19
  6. package/dist/cjs/config.js.map +7 -0
  7. package/dist/cjs/constants/constants.js +10 -22
  8. package/dist/cjs/constants/constants.js.map +2 -2
  9. package/dist/cjs/{helpers/nativeGestureHandler.js → constants/isDevTools.js} +8 -8
  10. package/dist/cjs/constants/isDevTools.js.map +7 -0
  11. package/dist/cjs/constants/platform.js +23 -16
  12. package/dist/cjs/constants/platform.js.map +2 -2
  13. package/dist/cjs/constants/platform.native.js +62 -0
  14. package/dist/cjs/constants/platform.native.js.map +7 -0
  15. package/dist/cjs/contexts/ButtonInsideButtonContext.js +1 -0
  16. package/dist/cjs/contexts/ButtonInsideButtonContext.js.map +1 -1
  17. package/dist/cjs/contexts/FontLanguageContext.js +30 -0
  18. package/dist/cjs/contexts/FontLanguageContext.js.map +7 -0
  19. package/dist/cjs/{views → contexts}/TextAncestorContext.js +11 -13
  20. package/dist/cjs/contexts/TextAncestorContext.js.map +7 -0
  21. package/dist/cjs/{ThemeContext.js → contexts/ThemeContext.js} +1 -0
  22. package/dist/cjs/contexts/ThemeContext.js.map +7 -0
  23. package/dist/cjs/createComponent.js +917 -480
  24. package/dist/cjs/createComponent.js.map +3 -3
  25. package/dist/cjs/createFont.js +5 -8
  26. package/dist/cjs/createFont.js.map +2 -2
  27. package/dist/cjs/createShorthands.js +1 -2
  28. package/dist/cjs/createShorthands.js.map +1 -1
  29. package/dist/cjs/createTamagui.js +127 -175
  30. package/dist/cjs/createTamagui.js.map +3 -3
  31. package/dist/cjs/createTheme.js +4 -2
  32. package/dist/cjs/createTheme.js.map +2 -2
  33. package/dist/cjs/createTokens.js +5 -25
  34. package/dist/cjs/createTokens.js.map +2 -2
  35. package/dist/cjs/createVariable.js +50 -27
  36. package/dist/cjs/createVariable.js.map +2 -2
  37. package/dist/cjs/createVariables.js +52 -0
  38. package/dist/cjs/createVariables.js.map +7 -0
  39. package/dist/cjs/helpers/RNComponents.js +12 -11
  40. package/dist/cjs/helpers/RNComponents.js.map +2 -2
  41. package/dist/cjs/{ThemeManager.js → helpers/ThemeManager.js} +54 -52
  42. package/dist/cjs/helpers/ThemeManager.js.map +7 -0
  43. package/dist/cjs/helpers/areEqualSets.js +3 -3
  44. package/dist/cjs/helpers/areEqualSets.js.map +1 -1
  45. package/dist/cjs/helpers/assignNativePropsToWeb.js +188 -0
  46. package/dist/cjs/helpers/assignNativePropsToWeb.js.map +7 -0
  47. package/dist/cjs/helpers/assignNativePropsToWeb.native.js +30 -0
  48. package/dist/cjs/helpers/assignNativePropsToWeb.native.js.map +7 -0
  49. package/dist/cjs/helpers/calc.js +71 -0
  50. package/dist/cjs/helpers/calc.js.map +7 -0
  51. package/dist/cjs/helpers/createMediaStyle.js +17 -9
  52. package/dist/cjs/helpers/createMediaStyle.js.map +2 -2
  53. package/dist/cjs/helpers/createPropMapper.js +266 -118
  54. package/dist/cjs/helpers/createPropMapper.js.map +2 -2
  55. package/dist/cjs/helpers/createShallowUpdate.js +14 -25
  56. package/dist/cjs/helpers/createShallowUpdate.js.map +2 -2
  57. package/dist/cjs/helpers/expandStyle.js +90 -0
  58. package/dist/cjs/helpers/expandStyle.js.map +7 -0
  59. package/dist/cjs/helpers/expandStyles.js +115 -0
  60. package/dist/cjs/helpers/expandStyles.js.map +7 -0
  61. package/dist/cjs/helpers/extendStaticConfig.js +49 -37
  62. package/dist/cjs/helpers/extendStaticConfig.js.map +2 -2
  63. package/dist/cjs/helpers/fixNativeShadow.js +3 -3
  64. package/dist/cjs/helpers/fixNativeShadow.js.map +1 -1
  65. package/dist/cjs/helpers/getAnimationDriver.js +32 -0
  66. package/dist/cjs/helpers/getAnimationDriver.js.map +7 -0
  67. package/dist/cjs/helpers/getExpandedShorthands.js +4 -5
  68. package/dist/cjs/helpers/getExpandedShorthands.js.map +2 -2
  69. package/dist/cjs/helpers/{getTextSize.js → getFont.js} +22 -12
  70. package/dist/cjs/helpers/getFont.js.map +7 -0
  71. package/dist/cjs/helpers/getFontLanguage.js +29 -0
  72. package/dist/cjs/helpers/getFontLanguage.js.map +7 -0
  73. package/dist/cjs/helpers/getSize.js +19 -10
  74. package/dist/cjs/helpers/getSize.js.map +2 -2
  75. package/dist/cjs/helpers/getSplitStyles.js +379 -206
  76. package/dist/cjs/helpers/getSplitStyles.js.map +3 -3
  77. package/dist/cjs/helpers/getStackSize.js +46 -0
  78. package/dist/cjs/helpers/getStackSize.js.map +7 -0
  79. package/dist/cjs/helpers/getStylesAtomic.js +199 -133
  80. package/dist/cjs/helpers/getStylesAtomic.js.map +3 -3
  81. package/dist/cjs/helpers/getStylesAtomic.native.js +1 -2
  82. package/dist/cjs/helpers/getStylesAtomic.native.js.map +1 -1
  83. package/dist/cjs/helpers/getThemeCSSRules.js +103 -0
  84. package/dist/cjs/helpers/getThemeCSSRules.js.map +7 -0
  85. package/dist/cjs/{nativeGestureHandler.native.js → helpers/getThemeCSSRules.native.js} +18 -5
  86. package/dist/cjs/helpers/getThemeCSSRules.native.js.map +7 -0
  87. package/dist/cjs/helpers/getVariantExtras.js +88 -0
  88. package/dist/cjs/helpers/getVariantExtras.js.map +7 -0
  89. package/dist/cjs/helpers/insertStyleRule.js +87 -52
  90. package/dist/cjs/helpers/insertStyleRule.js.map +3 -3
  91. package/dist/cjs/helpers/isObj.js +2 -2
  92. package/dist/cjs/helpers/isObj.js.map +1 -1
  93. package/dist/cjs/helpers/isTamaguiComponent.js +37 -0
  94. package/dist/cjs/helpers/isTamaguiComponent.js.map +7 -0
  95. package/dist/cjs/helpers/isTamaguiElement.js +5 -5
  96. package/dist/cjs/helpers/isTamaguiElement.js.map +2 -2
  97. package/dist/cjs/helpers/matchMedia.js +7 -6
  98. package/dist/cjs/helpers/matchMedia.js.map +2 -2
  99. package/dist/cjs/helpers/matchMedia.native.js +6 -3
  100. package/dist/cjs/helpers/matchMedia.native.js.map +2 -2
  101. package/dist/cjs/helpers/mergeProps.js +54 -0
  102. package/dist/cjs/helpers/mergeProps.js.map +7 -0
  103. package/dist/cjs/helpers/mergeTransform.js +42 -0
  104. package/dist/cjs/helpers/mergeTransform.js.map +7 -0
  105. package/dist/cjs/helpers/normalizeColor.js +80 -0
  106. package/dist/cjs/helpers/normalizeColor.js.map +7 -0
  107. package/dist/cjs/helpers/normalizeValueWithProperty.js +93 -0
  108. package/dist/cjs/helpers/normalizeValueWithProperty.js.map +7 -0
  109. package/dist/cjs/helpers/proxyThemeVariables.js +7 -4
  110. package/dist/cjs/helpers/proxyThemeVariables.js.map +2 -2
  111. package/dist/cjs/helpers/pseudoDescriptors.js +42 -0
  112. package/dist/cjs/helpers/pseudoDescriptors.js.map +7 -0
  113. package/dist/cjs/helpers/registerCSSVariable.js +40 -0
  114. package/dist/cjs/helpers/registerCSSVariable.js.map +7 -0
  115. package/dist/cjs/helpers/{wrapThemeManagerContext.js → startTransition.js} +12 -15
  116. package/dist/cjs/helpers/startTransition.js.map +7 -0
  117. package/dist/cjs/helpers/themeable.js +17 -40
  118. package/dist/cjs/helpers/themeable.js.map +3 -3
  119. package/dist/cjs/helpers/themes.js +79 -0
  120. package/dist/cjs/helpers/themes.js.map +7 -0
  121. package/dist/cjs/helpers/useShallowSetState.js +44 -0
  122. package/dist/cjs/helpers/useShallowSetState.js.map +7 -0
  123. package/dist/cjs/helpers/validate.js +1 -122
  124. package/dist/cjs/helpers/validate.js.map +3 -3
  125. package/dist/cjs/helpers/withStaticProperties.js +3 -3
  126. package/dist/cjs/helpers/withStaticProperties.js.map +1 -1
  127. package/dist/cjs/hooks/getThemeUnwrapped.js +39 -0
  128. package/dist/cjs/hooks/getThemeUnwrapped.js.map +7 -0
  129. package/dist/cjs/hooks/useConstant.js +4 -2
  130. package/dist/cjs/hooks/useConstant.js.map +2 -2
  131. package/dist/cjs/hooks/useId.js +3 -33
  132. package/dist/cjs/hooks/useId.js.map +2 -2
  133. package/dist/cjs/hooks/useIsMounted.js +3 -4
  134. package/dist/cjs/hooks/useIsMounted.js.map +2 -2
  135. package/dist/cjs/hooks/useIsSSR.js +46 -0
  136. package/dist/cjs/hooks/useIsSSR.js.map +7 -0
  137. package/dist/cjs/hooks/useIsTouchDevice.js +10 -8
  138. package/dist/cjs/hooks/useIsTouchDevice.js.map +2 -2
  139. package/dist/cjs/hooks/useMedia.js +154 -116
  140. package/dist/cjs/hooks/useMedia.js.map +3 -3
  141. package/dist/cjs/hooks/usePressable.js +4 -18
  142. package/dist/cjs/hooks/usePressable.js.map +1 -1
  143. package/dist/cjs/hooks/useSafeRef.js +60 -0
  144. package/dist/cjs/hooks/useSafeRef.js.map +7 -0
  145. package/dist/cjs/hooks/useServerHooks.js +36 -0
  146. package/dist/cjs/hooks/useServerHooks.js.map +7 -0
  147. package/dist/cjs/hooks/useTheme.js +163 -129
  148. package/dist/cjs/hooks/useTheme.js.map +3 -3
  149. package/dist/cjs/hooks/useUnmountEffect.js +1 -2
  150. package/dist/cjs/hooks/useUnmountEffect.js.map +1 -1
  151. package/dist/cjs/index.js +57 -20
  152. package/dist/cjs/index.js.map +2 -2
  153. package/dist/cjs/injectStyles.js +40 -0
  154. package/dist/cjs/injectStyles.js.map +7 -0
  155. package/dist/cjs/insertFont.js +93 -0
  156. package/dist/cjs/insertFont.js.map +7 -0
  157. package/dist/cjs/static.js +22 -15
  158. package/dist/cjs/static.js.map +2 -2
  159. package/dist/cjs/styled.js +47 -44
  160. package/dist/cjs/styled.js.map +2 -2
  161. package/dist/cjs/types-rnw.js +1 -0
  162. package/dist/cjs/types-rnw.js.map +2 -2
  163. package/dist/cjs/types.js +1 -0
  164. package/dist/cjs/types.js.map +2 -2
  165. package/dist/cjs/updateTheme.js +47 -0
  166. package/dist/cjs/updateTheme.js.map +7 -0
  167. package/dist/cjs/vendor/Pressability.js +32 -0
  168. package/dist/cjs/vendor/Pressability.js.map +7 -0
  169. package/dist/cjs/vendor/Pressability.native.js +32 -0
  170. package/dist/cjs/vendor/Pressability.native.js.map +7 -0
  171. package/dist/cjs/views/FontLanguage.js +38 -0
  172. package/dist/cjs/views/FontLanguage.js.map +7 -0
  173. package/dist/cjs/views/FontLanguage.native.js +38 -0
  174. package/dist/cjs/views/FontLanguage.native.js.map +7 -0
  175. package/dist/cjs/{helpers/nativeGestureHandler.native.js → views/FontLanguage.types.js} +4 -5
  176. package/dist/cjs/views/FontLanguage.types.js.map +7 -0
  177. package/dist/cjs/views/Slot.js +63 -65
  178. package/dist/cjs/views/Slot.js.map +2 -2
  179. package/dist/cjs/views/Stack.js +4 -19
  180. package/dist/cjs/views/Stack.js.map +1 -1
  181. package/dist/cjs/views/TamaguiProvider.js +82 -0
  182. package/dist/cjs/views/TamaguiProvider.js.map +7 -0
  183. package/dist/cjs/views/Text.js +25 -26
  184. package/dist/cjs/views/Text.js.map +2 -2
  185. package/dist/cjs/views/Theme.js +41 -19
  186. package/dist/cjs/views/Theme.js.map +3 -3
  187. package/dist/cjs/views/ThemeInverse.js +23 -23
  188. package/dist/cjs/views/ThemeInverse.js.map +2 -2
  189. package/dist/cjs/views/ThemeProvider.js +31 -20
  190. package/dist/cjs/views/ThemeProvider.js.map +3 -3
  191. package/dist/cjs/views/ThemeReset.js +14 -8
  192. package/dist/cjs/views/ThemeReset.js.map +3 -3
  193. package/dist/esm/Tamagui.js +8 -11
  194. package/dist/esm/Tamagui.js.map +2 -2
  195. package/dist/esm/addTheme.js +56 -0
  196. package/dist/esm/addTheme.js.map +7 -0
  197. package/dist/esm/config.js +45 -0
  198. package/dist/esm/config.js.map +7 -0
  199. package/dist/esm/constants/constants.js +1 -1
  200. package/dist/esm/constants/constants.js.map +2 -2
  201. package/dist/esm/constants/isDevTools.js +5 -0
  202. package/dist/esm/constants/isDevTools.js.map +7 -0
  203. package/dist/esm/constants/platform.js +16 -12
  204. package/dist/esm/constants/platform.js.map +2 -2
  205. package/dist/esm/constants/platform.native.js +28 -0
  206. package/dist/esm/constants/platform.native.js.map +7 -0
  207. package/dist/esm/contexts/ButtonInsideButtonContext.js +0 -0
  208. package/dist/esm/contexts/ButtonInsideButtonContext.js.map +1 -1
  209. package/dist/esm/contexts/FontLanguageContext.js +6 -0
  210. package/dist/esm/contexts/FontLanguageContext.js.map +7 -0
  211. package/dist/esm/contexts/TextAncestorContext.js +17 -0
  212. package/dist/esm/contexts/TextAncestorContext.js.map +7 -0
  213. package/dist/esm/{ThemeContext.js → contexts/ThemeContext.js} +0 -0
  214. package/dist/esm/contexts/ThemeContext.js.map +7 -0
  215. package/dist/esm/createComponent.js +890 -389
  216. package/dist/esm/createComponent.js.map +3 -3
  217. package/dist/esm/createFont.js +4 -9
  218. package/dist/esm/createFont.js.map +2 -2
  219. package/dist/esm/createShorthands.js +0 -3
  220. package/dist/esm/createShorthands.js.map +1 -1
  221. package/dist/esm/createTamagui.js +128 -158
  222. package/dist/esm/createTamagui.js.map +3 -3
  223. package/dist/esm/createTheme.js +3 -3
  224. package/dist/esm/createTheme.js.map +2 -2
  225. package/dist/esm/createTokens.js +3 -24
  226. package/dist/esm/createTokens.js.map +2 -2
  227. package/dist/esm/createVariable.js +45 -25
  228. package/dist/esm/createVariable.js.map +2 -2
  229. package/dist/esm/createVariables.js +28 -0
  230. package/dist/esm/createVariables.js.map +7 -0
  231. package/dist/esm/helpers/RNComponents.js +11 -8
  232. package/dist/esm/helpers/RNComponents.js.map +2 -2
  233. package/dist/esm/{ThemeManager.js → helpers/ThemeManager.js} +53 -53
  234. package/dist/esm/helpers/ThemeManager.js.map +7 -0
  235. package/dist/esm/helpers/areEqualSets.js +2 -4
  236. package/dist/esm/helpers/areEqualSets.js.map +1 -1
  237. package/dist/esm/helpers/assignNativePropsToWeb.js +164 -0
  238. package/dist/esm/helpers/assignNativePropsToWeb.js.map +7 -0
  239. package/dist/esm/helpers/assignNativePropsToWeb.native.js +6 -0
  240. package/dist/esm/helpers/assignNativePropsToWeb.native.js.map +7 -0
  241. package/dist/esm/helpers/calc.js +47 -0
  242. package/dist/esm/helpers/calc.js.map +7 -0
  243. package/dist/esm/helpers/createMediaStyle.js +16 -10
  244. package/dist/esm/helpers/createMediaStyle.js.map +2 -2
  245. package/dist/esm/helpers/createPropMapper.js +262 -120
  246. package/dist/esm/helpers/createPropMapper.js.map +2 -2
  247. package/dist/esm/helpers/createShallowUpdate.js +13 -12
  248. package/dist/esm/helpers/createShallowUpdate.js.map +2 -2
  249. package/dist/esm/helpers/expandStyle.js +66 -0
  250. package/dist/esm/helpers/expandStyle.js.map +7 -0
  251. package/dist/esm/helpers/expandStyles.js +89 -0
  252. package/dist/esm/helpers/expandStyles.js.map +7 -0
  253. package/dist/esm/helpers/extendStaticConfig.js +35 -28
  254. package/dist/esm/helpers/extendStaticConfig.js.map +2 -2
  255. package/dist/esm/helpers/fixNativeShadow.js +2 -4
  256. package/dist/esm/helpers/fixNativeShadow.js.map +1 -1
  257. package/dist/esm/helpers/getAnimationDriver.js +8 -0
  258. package/dist/esm/helpers/getAnimationDriver.js.map +7 -0
  259. package/dist/esm/helpers/getExpandedShorthands.js +2 -5
  260. package/dist/esm/helpers/getExpandedShorthands.js.map +2 -2
  261. package/dist/esm/helpers/{getTextSize.js → getFont.js} +17 -9
  262. package/dist/esm/helpers/getFont.js.map +7 -0
  263. package/dist/esm/helpers/getFontLanguage.js +5 -0
  264. package/dist/esm/helpers/getFontLanguage.js.map +7 -0
  265. package/dist/esm/helpers/getSize.js +16 -10
  266. package/dist/esm/helpers/getSize.js.map +2 -2
  267. package/dist/esm/helpers/getSplitStyles.js +364 -188
  268. package/dist/esm/helpers/getSplitStyles.js.map +3 -3
  269. package/dist/esm/helpers/getStackSize.js +22 -0
  270. package/dist/esm/helpers/getStackSize.js.map +7 -0
  271. package/dist/esm/helpers/getStylesAtomic.js +187 -108
  272. package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
  273. package/dist/esm/helpers/getStylesAtomic.native.js +0 -3
  274. package/dist/esm/helpers/getStylesAtomic.native.js.map +1 -1
  275. package/dist/esm/helpers/getThemeCSSRules.js +79 -0
  276. package/dist/esm/helpers/getThemeCSSRules.js.map +7 -0
  277. package/dist/esm/helpers/getThemeCSSRules.native.js +7 -0
  278. package/dist/esm/helpers/getThemeCSSRules.native.js.map +7 -0
  279. package/dist/esm/helpers/getVariantExtras.js +63 -0
  280. package/dist/esm/helpers/getVariantExtras.js.map +7 -0
  281. package/dist/esm/helpers/insertStyleRule.js +82 -50
  282. package/dist/esm/helpers/insertStyleRule.js.map +3 -3
  283. package/dist/esm/helpers/isObj.js +1 -3
  284. package/dist/esm/helpers/isObj.js.map +1 -1
  285. package/dist/esm/helpers/isTamaguiComponent.js +13 -0
  286. package/dist/esm/helpers/isTamaguiComponent.js.map +7 -0
  287. package/dist/esm/helpers/isTamaguiElement.js +4 -6
  288. package/dist/esm/helpers/isTamaguiElement.js.map +2 -2
  289. package/dist/esm/helpers/matchMedia.js +6 -7
  290. package/dist/esm/helpers/matchMedia.js.map +2 -2
  291. package/dist/esm/helpers/matchMedia.native.js +1 -3
  292. package/dist/esm/helpers/matchMedia.native.js.map +1 -1
  293. package/dist/esm/helpers/mergeProps.js +30 -0
  294. package/dist/esm/helpers/mergeProps.js.map +7 -0
  295. package/dist/esm/helpers/mergeTransform.js +17 -0
  296. package/dist/esm/helpers/mergeTransform.js.map +7 -0
  297. package/dist/esm/helpers/normalizeColor.js +49 -0
  298. package/dist/esm/helpers/normalizeColor.js.map +7 -0
  299. package/dist/esm/helpers/normalizeValueWithProperty.js +69 -0
  300. package/dist/esm/helpers/normalizeValueWithProperty.js.map +7 -0
  301. package/dist/esm/helpers/proxyThemeVariables.js +6 -5
  302. package/dist/esm/helpers/proxyThemeVariables.js.map +2 -2
  303. package/dist/esm/helpers/pseudoDescriptors.js +18 -0
  304. package/dist/esm/helpers/pseudoDescriptors.js.map +7 -0
  305. package/dist/esm/helpers/registerCSSVariable.js +14 -0
  306. package/dist/esm/helpers/registerCSSVariable.js.map +7 -0
  307. package/dist/esm/helpers/startTransition.js +6 -0
  308. package/dist/esm/helpers/startTransition.js.map +7 -0
  309. package/dist/esm/helpers/themeable.js +11 -9
  310. package/dist/esm/helpers/themeable.js.map +2 -2
  311. package/dist/esm/helpers/themes.js +54 -0
  312. package/dist/esm/helpers/themes.js.map +7 -0
  313. package/dist/esm/helpers/useShallowSetState.js +20 -0
  314. package/dist/esm/helpers/useShallowSetState.js.map +7 -0
  315. package/dist/esm/helpers/validate.js +0 -75
  316. package/dist/esm/helpers/validate.js.map +3 -3
  317. package/dist/esm/helpers/withStaticProperties.js +2 -4
  318. package/dist/esm/helpers/withStaticProperties.js.map +1 -1
  319. package/dist/esm/hooks/getThemeUnwrapped.js +14 -0
  320. package/dist/esm/hooks/getThemeUnwrapped.js.map +7 -0
  321. package/dist/esm/hooks/useConstant.js +4 -4
  322. package/dist/esm/hooks/useConstant.js.map +2 -2
  323. package/dist/esm/hooks/useId.js +1 -31
  324. package/dist/esm/hooks/useId.js.map +2 -2
  325. package/dist/esm/hooks/useIsMounted.js +1 -4
  326. package/dist/esm/hooks/useIsMounted.js.map +2 -2
  327. package/dist/esm/hooks/useIsSSR.js +22 -0
  328. package/dist/esm/hooks/useIsSSR.js.map +7 -0
  329. package/dist/esm/hooks/useIsTouchDevice.js +10 -10
  330. package/dist/esm/hooks/useIsTouchDevice.js.map +2 -2
  331. package/dist/esm/hooks/useMedia.js +150 -107
  332. package/dist/esm/hooks/useMedia.js.map +3 -3
  333. package/dist/esm/hooks/usePressable.js +2 -4
  334. package/dist/esm/hooks/usePressable.js.map +1 -1
  335. package/dist/esm/hooks/useSafeRef.js +36 -0
  336. package/dist/esm/hooks/useSafeRef.js.map +7 -0
  337. package/dist/esm/hooks/useServerHooks.js +11 -0
  338. package/dist/esm/hooks/useServerHooks.js.map +7 -0
  339. package/dist/esm/hooks/useTheme.js +159 -109
  340. package/dist/esm/hooks/useTheme.js.map +3 -3
  341. package/dist/esm/hooks/useUnmountEffect.js +0 -3
  342. package/dist/esm/hooks/useUnmountEffect.js.map +1 -1
  343. package/dist/esm/index.js +49 -12
  344. package/dist/esm/index.js.map +2 -2
  345. package/dist/esm/injectStyles.js +16 -0
  346. package/dist/esm/injectStyles.js.map +7 -0
  347. package/dist/esm/insertFont.js +67 -0
  348. package/dist/esm/insertFont.js.map +7 -0
  349. package/dist/esm/static.js +15 -15
  350. package/dist/esm/static.js.map +2 -2
  351. package/dist/esm/styled.js +40 -12
  352. package/dist/esm/styled.js.map +2 -2
  353. package/dist/esm/types-rnw.js +0 -0
  354. package/dist/esm/types-rnw.js.map +0 -0
  355. package/dist/esm/types.js +0 -0
  356. package/dist/esm/types.js.map +0 -0
  357. package/dist/esm/updateTheme.js +23 -0
  358. package/dist/esm/updateTheme.js.map +7 -0
  359. package/dist/esm/vendor/Pressability.js +7 -0
  360. package/dist/esm/vendor/Pressability.js.map +7 -0
  361. package/dist/esm/vendor/Pressability.native.js +7 -0
  362. package/dist/esm/vendor/Pressability.native.js.map +7 -0
  363. package/dist/esm/views/FontLanguage.js +14 -0
  364. package/dist/esm/views/FontLanguage.js.map +7 -0
  365. package/dist/esm/views/FontLanguage.native.js +14 -0
  366. package/dist/esm/views/FontLanguage.native.js.map +7 -0
  367. package/dist/esm/views/FontLanguage.types.js +1 -0
  368. package/dist/{cjs/defaultComponentState.js.map → esm/views/FontLanguage.types.js.map} +0 -0
  369. package/dist/esm/views/Slot.js +50 -32
  370. package/dist/esm/views/Slot.js.map +2 -2
  371. package/dist/esm/views/Stack.js +0 -0
  372. package/dist/esm/views/Stack.js.map +1 -1
  373. package/dist/esm/views/TamaguiProvider.js +52 -0
  374. package/dist/esm/views/TamaguiProvider.js.map +7 -0
  375. package/dist/esm/views/Text.js +12 -4
  376. package/dist/esm/views/Text.js.map +2 -2
  377. package/dist/esm/views/Theme.js +34 -18
  378. package/dist/esm/views/Theme.js.map +3 -3
  379. package/dist/esm/views/ThemeInverse.js +21 -19
  380. package/dist/esm/views/ThemeInverse.js.map +2 -2
  381. package/dist/esm/views/ThemeProvider.js +26 -20
  382. package/dist/esm/views/ThemeProvider.js.map +2 -2
  383. package/dist/esm/views/ThemeReset.js +9 -8
  384. package/dist/esm/views/ThemeReset.js.map +2 -2
  385. package/package.json +49 -17
  386. package/reset.css +41 -0
  387. package/src/Tamagui.ts +44 -0
  388. package/src/addTheme.ts +66 -0
  389. package/src/config.ts +42 -0
  390. package/src/constants/constants.ts +15 -0
  391. package/src/constants/isDevTools.ts +6 -0
  392. package/src/constants/platform.native.ts +14 -0
  393. package/src/constants/platform.ts +25 -0
  394. package/src/contexts/ButtonInsideButtonContext.tsx +3 -0
  395. package/src/contexts/FontLanguageContext.tsx +5 -0
  396. package/src/contexts/TextAncestorContext.tsx +10 -0
  397. package/src/contexts/ThemeContext.tsx +5 -0
  398. package/src/createComponent.tsx +1596 -0
  399. package/src/createFont.ts +29 -0
  400. package/src/createShorthands.ts +5 -0
  401. package/src/createTamagui.ts +228 -0
  402. package/src/createTheme.ts +13 -0
  403. package/src/createTokens.ts +35 -0
  404. package/src/createVariable.ts +83 -0
  405. package/src/createVariables.ts +42 -0
  406. package/src/helpers/RNComponents.tsx +14 -0
  407. package/src/helpers/ThemeManager.tsx +235 -0
  408. package/src/helpers/areEqualSets.tsx +9 -0
  409. package/src/helpers/assignNativePropsToWeb.native.tsx +1 -0
  410. package/src/helpers/assignNativePropsToWeb.tsx +178 -0
  411. package/src/helpers/calc.ts +67 -0
  412. package/src/helpers/createMediaStyle.ts +48 -0
  413. package/src/helpers/createPropMapper.ts +522 -0
  414. package/src/helpers/expandStyle.ts +81 -0
  415. package/src/helpers/expandStyles.ts +105 -0
  416. package/src/helpers/extendStaticConfig.ts +76 -0
  417. package/src/helpers/fixNativeShadow.tsx +2 -0
  418. package/src/helpers/getAnimationDriver.tsx +5 -0
  419. package/src/helpers/getExpandedShorthands.ts +15 -0
  420. package/src/helpers/getFont.tsx +43 -0
  421. package/src/helpers/getFontLanguage.ts +2 -0
  422. package/src/helpers/getSize.ts +22 -0
  423. package/src/helpers/getSplitStyles.tsx +738 -0
  424. package/src/helpers/getStackSize.ts +22 -0
  425. package/src/helpers/getStylesAtomic.native.ts +3 -0
  426. package/src/helpers/getStylesAtomic.ts +292 -0
  427. package/src/helpers/getThemeCSSRules.native.ts +3 -0
  428. package/src/helpers/getThemeCSSRules.ts +105 -0
  429. package/src/helpers/getVariantExtras.tsx +84 -0
  430. package/src/helpers/insertStyleRule.tsx +150 -0
  431. package/src/helpers/isObj.ts +1 -0
  432. package/src/helpers/isTamaguiComponent.tsx +15 -0
  433. package/src/helpers/isTamaguiElement.tsx +12 -0
  434. package/src/helpers/matchMedia.native.ts +6 -0
  435. package/src/helpers/matchMedia.ts +16 -0
  436. package/src/helpers/mergeProps.ts +56 -0
  437. package/src/helpers/mergeTransform.ts +16 -0
  438. package/src/helpers/normalizeColor.ts +53 -0
  439. package/src/helpers/normalizeValueWithProperty.ts +80 -0
  440. package/src/helpers/proxyThemeVariables.tsx +18 -0
  441. package/src/helpers/pseudoDescriptors.ts +18 -0
  442. package/src/helpers/registerCSSVariable.ts +11 -0
  443. package/src/helpers/startTransition.ts +4 -0
  444. package/src/helpers/themeable.tsx +45 -0
  445. package/src/helpers/themes.ts +69 -0
  446. package/src/helpers/useShallowSetState.tsx +20 -0
  447. package/src/helpers/validate.ts +80 -0
  448. package/src/helpers/withStaticProperties.tsx +7 -0
  449. package/src/hooks/getThemeUnwrapped.tsx +8 -0
  450. package/src/hooks/useConstant.tsx +19 -0
  451. package/src/hooks/useId.tsx +1 -0
  452. package/src/hooks/useIsMounted.ts +17 -0
  453. package/src/hooks/useIsSSR.tsx +25 -0
  454. package/src/hooks/useIsTouchDevice.tsx +21 -0
  455. package/src/hooks/useMedia.tsx +254 -0
  456. package/src/hooks/usePressable.tsx +9 -0
  457. package/src/hooks/useSafeRef.ts +50 -0
  458. package/src/hooks/useServerHooks.tsx +13 -0
  459. package/src/hooks/useTheme.tsx +299 -0
  460. package/src/hooks/useUnmountEffect.ts +5 -0
  461. package/src/index.ts +81 -0
  462. package/src/injectStyles.ts +20 -0
  463. package/src/insertFont.ts +70 -0
  464. package/src/static.ts +15 -0
  465. package/src/styled.tsx +198 -0
  466. package/src/types-rnw.tsx +162 -0
  467. package/src/types.tsx +1306 -0
  468. package/src/updateTheme.ts +23 -0
  469. package/src/vendor/Pressability.native.tsx +3 -0
  470. package/src/vendor/Pressability.tsx +2 -0
  471. package/src/views/FontLanguage.native.tsx +9 -0
  472. package/src/views/FontLanguage.tsx +18 -0
  473. package/src/views/FontLanguage.types.ts +13 -0
  474. package/src/views/Slot.tsx +152 -0
  475. package/src/views/Stack.tsx +24 -0
  476. package/src/views/TamaguiProvider.tsx +56 -0
  477. package/src/views/Text.tsx +79 -0
  478. package/src/views/Theme.tsx +72 -0
  479. package/src/views/ThemeInverse.tsx +33 -0
  480. package/src/views/ThemeProvider.tsx +62 -0
  481. package/src/views/ThemeReset.tsx +43 -0
  482. package/types/Tamagui.d.ts +6 -8
  483. package/types/addTheme.d.ts +11 -0
  484. package/types/conf.d.ts +4 -5
  485. package/types/config.d.ts +47 -0
  486. package/types/constants/constants.d.ts +1 -1
  487. package/types/constants/isDevTools.d.ts +2 -0
  488. package/types/constants/platform.d.ts +5 -4
  489. package/types/constants/platform.native.d.ts +13 -0
  490. package/types/contexts/FontLanguageContext.d.ts +5 -0
  491. package/types/{views → contexts}/TextAncestorContext.d.ts +0 -0
  492. package/types/{ThemeContext.d.ts → contexts/ThemeContext.d.ts} +1 -1
  493. package/types/createComponent.d.ts +32 -15
  494. package/types/createComponent.server.d.ts +36 -0
  495. package/types/createTamagui.d.ts +2 -17
  496. package/types/createTheme.d.ts +1 -1
  497. package/types/createTokens.d.ts +5 -6
  498. package/types/createVariable.d.ts +24 -12
  499. package/types/createVariables.d.ts +10 -0
  500. package/types/helpers/RNComponents.d.ts +1 -1
  501. package/types/helpers/ThemeManager.d.ts +46 -0
  502. package/types/helpers/assignNativePropsToWeb.d.ts +2 -0
  503. package/types/helpers/assignNativePropsToWeb.native.d.ts +2 -0
  504. package/types/helpers/calc.d.ts +17 -0
  505. package/types/helpers/createMediaStyle.d.ts +2 -4
  506. package/types/helpers/createPropMapper.d.ts +6 -3
  507. package/types/helpers/createShallowUpdate.d.ts +1 -2
  508. package/types/helpers/cssHash.d.ts +2 -0
  509. package/types/helpers/expandStyle.d.ts +6 -0
  510. package/types/helpers/expandStyles.d.ts +26 -0
  511. package/types/helpers/getAnimationDriver.d.ts +6 -0
  512. package/types/helpers/getFont.d.ts +3 -0
  513. package/types/helpers/getFontLanguage.d.ts +2 -0
  514. package/types/helpers/getSize.d.ts +3 -2
  515. package/types/helpers/getSplitStyles.d.ts +16 -9
  516. package/types/helpers/getStackSize.d.ts +8 -0
  517. package/types/helpers/getStylesAtomic.d.ts +17 -22
  518. package/types/helpers/getThemeCSSRules.d.ts +8 -0
  519. package/types/helpers/getThemeCSSRules.native.d.ts +2 -0
  520. package/types/helpers/getVariantExtras.d.ts +5 -0
  521. package/types/helpers/insertStyleRule.d.ts +7 -3
  522. package/types/helpers/isTamaguiComponent.d.ts +5 -0
  523. package/types/helpers/isTamaguiElement.d.ts +5 -1
  524. package/types/helpers/matchMedia.d.ts +1 -1
  525. package/types/helpers/mergeProps.d.ts +17 -0
  526. package/types/helpers/mergeTransform.d.ts +7 -0
  527. package/types/helpers/normalizeColor.d.ts +3 -0
  528. package/types/helpers/normalizeValueWithProperty.d.ts +6 -0
  529. package/types/helpers/pseudoDescriptors.d.ts +16 -0
  530. package/types/helpers/registerCSSVariable.d.ts +5 -0
  531. package/types/helpers/startTransition.d.ts +3 -0
  532. package/types/helpers/themes.d.ts +4 -0
  533. package/types/helpers/useAnimationDriver.d.ts +1 -0
  534. package/types/helpers/useShallowSetState.d.ts +3 -0
  535. package/types/helpers/validate.d.ts +0 -3
  536. package/types/hooks/getThemeUnwrapped.d.ts +3 -0
  537. package/types/hooks/useAnimationDriver.d.ts +1 -0
  538. package/types/hooks/useFeatures.d.ts +10 -5
  539. package/types/hooks/useId.d.ts +1 -8
  540. package/types/hooks/useIsSSR.d.ts +4 -0
  541. package/types/hooks/useMedia.d.ts +20 -6
  542. package/types/hooks/useSafeRef.d.ts +4 -0
  543. package/types/hooks/useServerContext.d.ts +2 -0
  544. package/types/hooks/useServerHooks.d.ts +4 -0
  545. package/types/hooks/useTheme.d.ts +21 -31
  546. package/types/index.d.ts +27 -8
  547. package/types/injectStyles.d.ts +7 -0
  548. package/types/insertFont.d.ts +9 -0
  549. package/types/static.d.ts +2 -15
  550. package/types/styled.d.ts +7 -3
  551. package/types/types.d.ts +276 -77
  552. package/types/updateTheme.d.ts +9 -0
  553. package/types/vendor/Pressability.d.ts +3 -0
  554. package/types/vendor/Pressability.native.d.ts +3 -0
  555. package/types/views/FontLanguage.d.ts +4 -0
  556. package/types/views/FontLanguage.native.d.ts +4 -0
  557. package/types/views/FontLanguage.types.d.ts +11 -0
  558. package/types/views/Slot.d.ts +1 -0
  559. package/types/views/TamaguiProvider.d.ts +4 -0
  560. package/types/views/Theme.d.ts +3 -9
  561. package/types/views/ThemeInverse.d.ts +4 -8
  562. package/types/views/ThemeProvider.d.ts +2 -1
  563. package/dist/cjs/ThemeContext.js.map +0 -7
  564. package/dist/cjs/ThemeManager.js.map +0 -7
  565. package/dist/cjs/conf.js.map +0 -7
  566. package/dist/cjs/constants/rnw.js +0 -46
  567. package/dist/cjs/constants/rnw.js.map +0 -7
  568. package/dist/cjs/defaultComponentState.js +0 -1
  569. package/dist/cjs/helpers/addStylesUsingClassname.js +0 -87
  570. package/dist/cjs/helpers/addStylesUsingClassname.js.map +0 -7
  571. package/dist/cjs/helpers/createTamaguiProvider.js +0 -93
  572. package/dist/cjs/helpers/createTamaguiProvider.js.map +0 -7
  573. package/dist/cjs/helpers/fixNativeShadow.native.js +0 -53
  574. package/dist/cjs/helpers/fixNativeShadow.native.js.map +0 -7
  575. package/dist/cjs/helpers/getButtonSize.js +0 -45
  576. package/dist/cjs/helpers/getButtonSize.js.map +0 -7
  577. package/dist/cjs/helpers/getTextSize.js.map +0 -7
  578. package/dist/cjs/helpers/nativeGestureHandler.js.map +0 -7
  579. package/dist/cjs/helpers/nativeGestureHandler.native.js.map +0 -7
  580. package/dist/cjs/helpers/wrapThemeManagerContext.js.map +0 -7
  581. package/dist/cjs/hooks/useFeatures.js +0 -228
  582. package/dist/cjs/hooks/useFeatures.js.map +0 -7
  583. package/dist/cjs/hooks/usePrevious.js +0 -1
  584. package/dist/cjs/hooks/usePrevious.js.map +0 -7
  585. package/dist/cjs/nativeGestureHandler.native.js.map +0 -7
  586. package/dist/cjs/views/TextAncestorContext.js.map +0 -7
  587. package/dist/esm/ThemeContext.js.map +0 -7
  588. package/dist/esm/ThemeManager.js.map +0 -7
  589. package/dist/esm/conf.js +0 -36
  590. package/dist/esm/conf.js.map +0 -7
  591. package/dist/esm/constants/rnw.js +0 -24
  592. package/dist/esm/constants/rnw.js.map +0 -7
  593. package/dist/esm/defaultComponentState.js +0 -1
  594. package/dist/esm/defaultComponentState.js.map +0 -7
  595. package/dist/esm/helpers/addStylesUsingClassname.js +0 -64
  596. package/dist/esm/helpers/addStylesUsingClassname.js.map +0 -7
  597. package/dist/esm/helpers/createTamaguiProvider.js +0 -40
  598. package/dist/esm/helpers/createTamaguiProvider.js.map +0 -7
  599. package/dist/esm/helpers/fixNativeShadow.native.js +0 -32
  600. package/dist/esm/helpers/fixNativeShadow.native.js.map +0 -7
  601. package/dist/esm/helpers/getButtonSize.js +0 -24
  602. package/dist/esm/helpers/getButtonSize.js.map +0 -7
  603. package/dist/esm/helpers/getTextSize.js.map +0 -7
  604. package/dist/esm/helpers/nativeGestureHandler.js +0 -7
  605. package/dist/esm/helpers/nativeGestureHandler.js.map +0 -7
  606. package/dist/esm/helpers/nativeGestureHandler.native.js +0 -2
  607. package/dist/esm/helpers/nativeGestureHandler.native.js.map +0 -7
  608. package/dist/esm/helpers/wrapThemeManagerContext.js +0 -14
  609. package/dist/esm/helpers/wrapThemeManagerContext.js.map +0 -7
  610. package/dist/esm/hooks/useFeatures.js +0 -173
  611. package/dist/esm/hooks/useFeatures.js.map +0 -7
  612. package/dist/esm/hooks/usePrevious.js +0 -1
  613. package/dist/esm/hooks/usePrevious.js.map +0 -7
  614. package/dist/esm/nativeGestureHandler.native.js +0 -2
  615. package/dist/esm/nativeGestureHandler.native.js.map +0 -7
  616. package/dist/esm/views/TextAncestorContext.js +0 -18
  617. package/dist/esm/views/TextAncestorContext.js.map +0 -7
  618. package/dist/jsx/Tamagui.js +0 -41
  619. package/dist/jsx/ThemeContext.js +0 -5
  620. package/dist/jsx/ThemeManager.js +0 -186
  621. package/dist/jsx/conf.js +0 -35
  622. package/dist/jsx/constants/constants.js +0 -17
  623. package/dist/jsx/constants/platform.js +0 -25
  624. package/dist/jsx/constants/rnw.js +0 -23
  625. package/dist/jsx/contexts/ButtonInsideButtonContext.js +0 -5
  626. package/dist/jsx/createComponent.js +0 -636
  627. package/dist/jsx/createFont.js +0 -27
  628. package/dist/jsx/createShorthands.js +0 -9
  629. package/dist/jsx/createTamagui.js +0 -201
  630. package/dist/jsx/createTheme.js +0 -6
  631. package/dist/jsx/createTokens.js +0 -28
  632. package/dist/jsx/createVariable.js +0 -48
  633. package/dist/jsx/defaultComponentState.js +0 -0
  634. package/dist/jsx/helpers/RNComponents.js +0 -11
  635. package/dist/jsx/helpers/addStylesUsingClassname.js +0 -63
  636. package/dist/jsx/helpers/areEqualSets.js +0 -15
  637. package/dist/jsx/helpers/createMediaStyle.js +0 -30
  638. package/dist/jsx/helpers/createPropMapper.js +0 -237
  639. package/dist/jsx/helpers/createShallowUpdate.js +0 -18
  640. package/dist/jsx/helpers/createTamaguiProvider.js +0 -34
  641. package/dist/jsx/helpers/extendStaticConfig.js +0 -61
  642. package/dist/jsx/helpers/fixNativeShadow.js +0 -7
  643. package/dist/jsx/helpers/fixNativeShadow.native.js +0 -31
  644. package/dist/jsx/helpers/getButtonSize.js +0 -23
  645. package/dist/jsx/helpers/getExpandedShorthands.js +0 -18
  646. package/dist/jsx/helpers/getSize.js +0 -12
  647. package/dist/jsx/helpers/getSplitStyles.js +0 -322
  648. package/dist/jsx/helpers/getStylesAtomic.js +0 -130
  649. package/dist/jsx/helpers/getStylesAtomic.native.js +0 -9
  650. package/dist/jsx/helpers/getTextSize.js +0 -33
  651. package/dist/jsx/helpers/insertStyleRule.js +0 -94
  652. package/dist/jsx/helpers/isObj.js +0 -6
  653. package/dist/jsx/helpers/isTamaguiElement.js +0 -10
  654. package/dist/jsx/helpers/matchMedia.js +0 -17
  655. package/dist/jsx/helpers/matchMedia.native.js +0 -8
  656. package/dist/jsx/helpers/nativeGestureHandler.js +0 -6
  657. package/dist/jsx/helpers/nativeGestureHandler.native.js +0 -1
  658. package/dist/jsx/helpers/proxyThemeVariables.js +0 -17
  659. package/dist/jsx/helpers/themeable.js +0 -24
  660. package/dist/jsx/helpers/validate.js +0 -75
  661. package/dist/jsx/helpers/withStaticProperties.js +0 -9
  662. package/dist/jsx/helpers/wrapThemeManagerContext.js +0 -10
  663. package/dist/jsx/hooks/useConstant.js +0 -14
  664. package/dist/jsx/hooks/useFeatures.js +0 -167
  665. package/dist/jsx/hooks/useId.js +0 -34
  666. package/dist/jsx/hooks/useIsMounted.js +0 -18
  667. package/dist/jsx/hooks/useIsTouchDevice.js +0 -16
  668. package/dist/jsx/hooks/useMedia.js +0 -158
  669. package/dist/jsx/hooks/usePressable.js +0 -13
  670. package/dist/jsx/hooks/usePrevious.js +0 -0
  671. package/dist/jsx/hooks/useTheme.js +0 -177
  672. package/dist/jsx/hooks/useUnmountEffect.js +0 -10
  673. package/dist/jsx/index.js +0 -54
  674. package/dist/jsx/nativeGestureHandler.native.js +0 -1
  675. package/dist/jsx/static.js +0 -16
  676. package/dist/jsx/styled.js +0 -47
  677. package/dist/jsx/types-rnw.js +0 -0
  678. package/dist/jsx/types.js +0 -0
  679. package/dist/jsx/views/Slot.js +0 -75
  680. package/dist/jsx/views/Stack.js +0 -12
  681. package/dist/jsx/views/Text.js +0 -56
  682. package/dist/jsx/views/TextAncestorContext.js +0 -15
  683. package/dist/jsx/views/Theme.js +0 -31
  684. package/dist/jsx/views/ThemeInverse.js +0 -27
  685. package/dist/jsx/views/ThemeProvider.js +0 -35
  686. package/dist/jsx/views/ThemeReset.js +0 -34
  687. package/types/Tamagui.d.ts.map +0 -1
  688. package/types/ThemeContext.d.ts.map +0 -1
  689. package/types/ThemeManager.d.ts +0 -49
  690. package/types/ThemeManager.d.ts.map +0 -1
  691. package/types/conf.d.ts.map +0 -1
  692. package/types/constants/constants.d.ts.map +0 -1
  693. package/types/constants/platform.d.ts.map +0 -1
  694. package/types/constants/rnw.d.ts +0 -2
  695. package/types/constants/rnw.d.ts.map +0 -1
  696. package/types/contexts/ButtonInsideButtonContext.d.ts.map +0 -1
  697. package/types/createComponent.d.ts.map +0 -1
  698. package/types/createFont.d.ts.map +0 -1
  699. package/types/createShorthands.d.ts.map +0 -1
  700. package/types/createTamagui.d.ts.map +0 -1
  701. package/types/createTheme.d.ts.map +0 -1
  702. package/types/createTokens.d.ts.map +0 -1
  703. package/types/createVariable.d.ts.map +0 -1
  704. package/types/defaultComponentState.d.ts +0 -1
  705. package/types/defaultComponentState.d.ts.map +0 -1
  706. package/types/helpers/RNComponents.d.ts.map +0 -1
  707. package/types/helpers/addStylesUsingClassname.d.ts +0 -3
  708. package/types/helpers/addStylesUsingClassname.d.ts.map +0 -1
  709. package/types/helpers/areEqualSets.d.ts.map +0 -1
  710. package/types/helpers/createMediaStyle.d.ts.map +0 -1
  711. package/types/helpers/createPropMapper.d.ts.map +0 -1
  712. package/types/helpers/createShallowUpdate.d.ts.map +0 -1
  713. package/types/helpers/createTamaguiProvider.d.ts +0 -7
  714. package/types/helpers/createTamaguiProvider.d.ts.map +0 -1
  715. package/types/helpers/extendStaticConfig.d.ts.map +0 -1
  716. package/types/helpers/fixNativeShadow.d.ts.map +0 -1
  717. package/types/helpers/fixNativeShadow.native.d.ts +0 -3
  718. package/types/helpers/fixNativeShadow.native.d.ts.map +0 -1
  719. package/types/helpers/getButtonSize.d.ts +0 -8
  720. package/types/helpers/getButtonSize.d.ts.map +0 -1
  721. package/types/helpers/getExpandedShorthands.d.ts.map +0 -1
  722. package/types/helpers/getSize.d.ts.map +0 -1
  723. package/types/helpers/getSplitStyles.d.ts.map +0 -1
  724. package/types/helpers/getStylesAtomic.d.ts.map +0 -1
  725. package/types/helpers/getStylesAtomic.native.d.ts.map +0 -1
  726. package/types/helpers/getTextSize.d.ts +0 -3
  727. package/types/helpers/getTextSize.d.ts.map +0 -1
  728. package/types/helpers/insertStyleRule.d.ts.map +0 -1
  729. package/types/helpers/isObj.d.ts.map +0 -1
  730. package/types/helpers/isTamaguiElement.d.ts.map +0 -1
  731. package/types/helpers/matchMedia.d.ts.map +0 -1
  732. package/types/helpers/matchMedia.native.d.ts.map +0 -1
  733. package/types/helpers/nativeGestureHandler.d.ts +0 -2
  734. package/types/helpers/nativeGestureHandler.d.ts.map +0 -1
  735. package/types/helpers/nativeGestureHandler.native.d.ts +0 -2
  736. package/types/helpers/nativeGestureHandler.native.d.ts.map +0 -1
  737. package/types/helpers/proxyThemeVariables.d.ts.map +0 -1
  738. package/types/helpers/themeable.d.ts.map +0 -1
  739. package/types/helpers/validate.d.ts.map +0 -1
  740. package/types/helpers/withStaticProperties.d.ts.map +0 -1
  741. package/types/helpers/wrapThemeManagerContext.d.ts +0 -3
  742. package/types/helpers/wrapThemeManagerContext.d.ts.map +0 -1
  743. package/types/hooks/useConstant.d.ts.map +0 -1
  744. package/types/hooks/useFeatures.d.ts.map +0 -1
  745. package/types/hooks/useId.d.ts.map +0 -1
  746. package/types/hooks/useIsMounted.d.ts.map +0 -1
  747. package/types/hooks/useIsTouchDevice.d.ts.map +0 -1
  748. package/types/hooks/useMedia.d.ts.map +0 -1
  749. package/types/hooks/usePressable.d.ts.map +0 -1
  750. package/types/hooks/usePrevious.d.ts +0 -1
  751. package/types/hooks/usePrevious.d.ts.map +0 -1
  752. package/types/hooks/useTheme.d.ts.map +0 -1
  753. package/types/hooks/useUnmountEffect.d.ts.map +0 -1
  754. package/types/index.d.ts.map +0 -1
  755. package/types/nativeGestureHandler.native.d.ts +0 -2
  756. package/types/nativeGestureHandler.native.d.ts.map +0 -1
  757. package/types/static.d.ts.map +0 -1
  758. package/types/styled.d.ts.map +0 -1
  759. package/types/types-rnw.d.ts.map +0 -1
  760. package/types/types.d.ts.map +0 -1
  761. package/types/views/Slot.d.ts.map +0 -1
  762. package/types/views/Stack.d.ts.map +0 -1
  763. package/types/views/Text.d.ts.map +0 -1
  764. package/types/views/TextAncestorContext.d.ts.map +0 -1
  765. package/types/views/Theme.d.ts.map +0 -1
  766. package/types/views/ThemeInverse.d.ts.map +0 -1
  767. package/types/views/ThemeProvider.d.ts.map +0 -1
  768. package/types/views/ThemeReset.d.ts.map +0 -1
@@ -0,0 +1,522 @@
1
+ import { getConfig } from '../config'
2
+ import { isDevTools } from '../constants/isDevTools'
3
+ import { isWeb } from '../constants/platform'
4
+ import { Variable, getVariableValue, isVariable } from '../createVariable'
5
+ import {
6
+ DebugProp,
7
+ GenericVariantDefinitions,
8
+ PropMapper,
9
+ SplitStyleState,
10
+ StaticConfigParsed,
11
+ TamaguiInternalConfig,
12
+ VariantSpreadFunction,
13
+ } from '../types'
14
+ import { LanguageContextType } from '../views/FontLanguage.types'
15
+ import { expandStyle } from './expandStyle'
16
+ import { expandStyles } from './expandStyles'
17
+ import { getFontsForLanguage, getVariantExtras } from './getVariantExtras'
18
+ import { isObj } from './isObj'
19
+ import { mergeProps } from './mergeProps'
20
+
21
+ export type ResolveVariableTypes = 'auto' | 'value' | 'variable' | 'both' | 'non-color-value'
22
+
23
+ export const getReturnVariablesAs = (props: any, state: Partial<SplitStyleState>) => {
24
+ return !!props.animation || state.resolveVariablesAs === 'value'
25
+ ? isWeb
26
+ ? 'non-color-value'
27
+ : 'value'
28
+ : 'auto'
29
+ }
30
+
31
+ export const createPropMapper = (staticConfig: StaticConfigParsed) => {
32
+ const variants = staticConfig.variants || {}
33
+
34
+ // temp remove classnames
35
+ const defaultProps = mergeProps(staticConfig.defaultProps || {}, {}, false)[0]
36
+
37
+ const mapper: PropMapper = (
38
+ key,
39
+ value,
40
+ theme,
41
+ propsIn,
42
+ state,
43
+ languageContext,
44
+ avoidDefaultProps = false,
45
+ debug
46
+ ) => {
47
+ const conf = getConfig()
48
+ if (!conf) {
49
+ throw new Error(`No tamagui config setup`)
50
+ }
51
+
52
+ const props = state.fallbackProps || propsIn
53
+ const returnVariablesAs = getReturnVariablesAs(props, state)
54
+
55
+ // handled here because we need to resolve this off tokens, its the only one-off like this
56
+ const fontFamily =
57
+ props[conf.inverseShorthands.fontFamily] ||
58
+ props.fontFamily ||
59
+ defaultProps.fontFamily ||
60
+ propsIn.fontFamily ||
61
+ '$body'
62
+
63
+ const variantValue = resolveVariants(
64
+ key,
65
+ value,
66
+ props,
67
+ defaultProps,
68
+ theme,
69
+ variants,
70
+ fontFamily,
71
+ conf,
72
+ returnVariablesAs,
73
+ staticConfig,
74
+ '',
75
+ languageContext,
76
+ avoidDefaultProps,
77
+ debug
78
+ )
79
+
80
+ if (variantValue) {
81
+ return variantValue
82
+ }
83
+
84
+ let shouldReturn = value !== undefined && value !== null
85
+
86
+ // handle shorthands
87
+ if (conf.shorthands[key]) {
88
+ shouldReturn = true
89
+ key = conf.shorthands[key]
90
+ }
91
+
92
+ if (value) {
93
+ if (value[0] === '$') {
94
+ value = getToken(
95
+ key,
96
+ value,
97
+ conf,
98
+ theme,
99
+ fontFamily,
100
+ languageContext,
101
+ returnVariablesAs,
102
+ debug
103
+ )
104
+ } else if (isVariable(value)) {
105
+ value = resolveVariableValue(key, value, returnVariablesAs)
106
+ }
107
+ }
108
+
109
+ if (shouldReturn) {
110
+ return expandStyle(key, value) || [[key, value]]
111
+ }
112
+ }
113
+
114
+ return mapper
115
+ }
116
+
117
+ type StyleResolver = (
118
+ key: string,
119
+ value: any,
120
+ props: Record<string, any>,
121
+ defaultProps: any,
122
+ theme: any,
123
+ variants: GenericVariantDefinitions,
124
+ fontFamily: string,
125
+ conf: TamaguiInternalConfig,
126
+ returnVariablesAs: 'auto' | 'value' | 'non-color-value',
127
+ staticConfig: StaticConfigParsed,
128
+ parentVariantKey: string,
129
+ languageContext?: LanguageContextType,
130
+ avoidDefaultProps?: boolean,
131
+ debug?: DebugProp
132
+ ) => any
133
+
134
+ const resolveVariants: StyleResolver = (
135
+ key,
136
+ value,
137
+ props,
138
+ defaultProps,
139
+ theme,
140
+ variants,
141
+ fontFamily,
142
+ conf,
143
+ returnVariablesAs,
144
+ staticConfig,
145
+ parentVariantKey,
146
+ languageContext,
147
+ avoidDefaultProps = false,
148
+ debug
149
+ ) => {
150
+ const variant = variants && variants[key]
151
+ if (!variant || value === undefined) {
152
+ return
153
+ }
154
+
155
+ let variantValue = getVariantDefinition(variant, key, value, conf)
156
+
157
+ if (!variantValue) {
158
+ // variant at key exists, but no matching variant value, return nothing
159
+ if (process.env.NODE_ENV === 'development') {
160
+ if (staticConfig.validStyles?.[key]) {
161
+ return null
162
+ }
163
+ if (value === false) {
164
+ // don't warn on missing false values, common to only use true
165
+ return null
166
+ }
167
+ const name = staticConfig.componentName || '[UnnamedComponent]'
168
+ // eslint-disable-next-line no-console
169
+ console.warn(
170
+ `No variant found: ${name} has variant "${key}", but no matching value "${value}"`
171
+ )
172
+ }
173
+ return
174
+ }
175
+
176
+ if (typeof variantValue === 'function') {
177
+ const fn = variantValue as VariantSpreadFunction<any>
178
+ variantValue = fn(
179
+ value,
180
+ getVariantExtras(props, languageContext, theme, defaultProps, avoidDefaultProps)
181
+ )
182
+ }
183
+
184
+ let fontFamilyResult: any
185
+
186
+ if (isObj(variantValue)) {
187
+ const fontFamilyUpdate =
188
+ variantValue.fontFamily || variantValue[conf.inverseShorthands.fontFamily]
189
+
190
+ if (fontFamilyUpdate) {
191
+ fontFamilyResult = getFontFamilyFromNameOrVariable(fontFamilyUpdate, conf)
192
+ }
193
+
194
+ variantValue = resolveTokensAndVariants(
195
+ key,
196
+ variantValue,
197
+ props,
198
+ defaultProps,
199
+ theme,
200
+ variants,
201
+ fontFamilyResult || fontFamily,
202
+ conf,
203
+ returnVariablesAs,
204
+ staticConfig,
205
+ parentVariantKey,
206
+ languageContext,
207
+ avoidDefaultProps,
208
+ debug
209
+ )
210
+ }
211
+
212
+ if (variantValue) {
213
+ const next = Object.entries(expandStyles(variantValue))
214
+
215
+ // store any changed font family (only support variables for now)
216
+ if (fontFamilyResult && fontFamilyResult[0] === '$') {
217
+ fontFamilyCache.set(next, getVariableValue(fontFamilyResult))
218
+ }
219
+
220
+ return next
221
+ }
222
+ }
223
+
224
+ // handles finding and resolving the fontFamily to the token name
225
+ // this is used as `font_[name]` in className for nice css variable support
226
+ export function getFontFamilyFromNameOrVariable(input: any, conf: TamaguiInternalConfig) {
227
+ if (isVariable(input)) {
228
+ const val = variableToFontNameCache.get(input)
229
+ if (val) {
230
+ return val
231
+ } else {
232
+ for (const key in conf.fontsParsed) {
233
+ const familyVariable = conf.fontsParsed[key].family
234
+ if (isVariable(familyVariable)) {
235
+ variableToFontNameCache.set(familyVariable, key)
236
+ if (familyVariable === input) {
237
+ return key
238
+ }
239
+ }
240
+ }
241
+ }
242
+ } else if (typeof input === 'string') {
243
+ if (input?.[0] === '$') {
244
+ return input
245
+ } else {
246
+ // this could be mapped back to
247
+ if (process.env.NODE_ENV === 'development') {
248
+ // eslint-disable-next-line no-console
249
+ console.log('[tamagui] should map back', input)
250
+ }
251
+ }
252
+ }
253
+ }
254
+
255
+ const variableToFontNameCache = new WeakMap<Variable, string>()
256
+
257
+ // special helper for special font family
258
+ const fontFamilyCache = new WeakMap()
259
+ export const getPropMappedFontFamily = (expanded?: any) => {
260
+ return expanded && fontFamilyCache.get(expanded)
261
+ }
262
+
263
+ const resolveTokensAndVariants: StyleResolver = (
264
+ key, // we dont use key assume value is object instead
265
+ value,
266
+ props,
267
+ defaultProps,
268
+ theme,
269
+ variants,
270
+ fontFamily,
271
+ conf,
272
+ returnVariablesAs,
273
+ staticConfig,
274
+ parentVariantKey,
275
+ languageContext,
276
+ avoidDefaultProps,
277
+ debug
278
+ ) => {
279
+ const res = {}
280
+ for (const rKey in value) {
281
+ const fKey = conf.shorthands[rKey] || rKey
282
+ const val = value[rKey]
283
+
284
+ if (isVariable(val)) {
285
+ res[fKey] = !isWeb || returnVariablesAs === 'value' ? val.val : val.variable
286
+ } else if (variants[fKey]) {
287
+ // avoids infinite loop if variant is matching a style prop
288
+ // eg: { variants: { flex: { true: { flex: 2 } } } }
289
+ if (parentVariantKey === key) {
290
+ res[fKey] = val
291
+ } else {
292
+ Object.assign(
293
+ res,
294
+ Object.fromEntries(
295
+ resolveVariants(
296
+ fKey,
297
+ val,
298
+ props,
299
+ defaultProps,
300
+ theme,
301
+ variants,
302
+ fontFamily,
303
+ conf,
304
+ returnVariablesAs,
305
+ staticConfig,
306
+ key,
307
+ languageContext,
308
+ avoidDefaultProps,
309
+ debug
310
+ )
311
+ )
312
+ )
313
+ }
314
+ } else if (typeof val === 'string') {
315
+ const fVal =
316
+ val[0] === '$'
317
+ ? getToken(fKey, val, conf, theme, fontFamily, languageContext, returnVariablesAs, debug)
318
+ : val
319
+ res[fKey] = fVal
320
+ } else {
321
+ if (isObj(val)) {
322
+ // sub-objects: media queries, pseudos, shadowOffset
323
+ res[fKey] = resolveTokensAndVariants(
324
+ fKey,
325
+ val,
326
+ props,
327
+ defaultProps,
328
+ theme,
329
+ variants,
330
+ fontFamily,
331
+ conf,
332
+ returnVariablesAs,
333
+ staticConfig,
334
+ key,
335
+ languageContext,
336
+ avoidDefaultProps,
337
+ debug
338
+ )
339
+ } else {
340
+ // nullish values cant be tokens, need no extra parsing
341
+ res[fKey] = value[fKey]
342
+ }
343
+ }
344
+ if (process.env.NODE_ENV === 'development') {
345
+ if (res[fKey]?.[0] === '$') {
346
+ console.warn(`⚠️ Missing token in theme ${theme.name}:`, fKey, res[fKey])
347
+ }
348
+ }
349
+ }
350
+ return res
351
+ }
352
+
353
+ // goes through specificity finding best matching variant function
354
+ function getVariantDefinition(variant: any, key: string, value: any, conf: TamaguiInternalConfig) {
355
+ if (typeof variant === 'function') {
356
+ return variant
357
+ }
358
+ if (variant[value]) {
359
+ return variant[value]
360
+ }
361
+ const { tokensParsed } = conf
362
+ if (variant['...size'] && value in tokensParsed.size) {
363
+ return variant['...size']
364
+ }
365
+ if (variant['...color'] && value in tokensParsed.color) {
366
+ return variant['...color']
367
+ }
368
+ if (variant['...radius'] && value in tokensParsed.radius) {
369
+ return variant['...radius']
370
+ }
371
+ if (variant['...space'] && value in tokensParsed.space) {
372
+ return variant['...space']
373
+ }
374
+ if (variant['...zIndex'] && value in tokensParsed.zIndex) {
375
+ return variant['...zIndex']
376
+ }
377
+ let fn: any
378
+ if (typeof value === 'number') {
379
+ fn = variant[':number']
380
+ } else if (typeof value === 'string') {
381
+ fn = variant[':string']
382
+ } else if (value === true || value === false) {
383
+ fn = variant[':boolean']
384
+ }
385
+ // fallback to catch all or size
386
+ return fn || variant['...'] || variant['...size']
387
+ }
388
+
389
+ const fontShorthand = {
390
+ fontSize: 'size',
391
+ fontWeight: 'weight',
392
+ }
393
+
394
+ const getToken = (
395
+ key: string,
396
+ value: string,
397
+ conf: TamaguiInternalConfig,
398
+ theme: any,
399
+ fontFamily: string | undefined = '$body',
400
+ languageContext?: LanguageContextType,
401
+ resolveAs?: ResolveVariableTypes,
402
+ debug?: DebugProp
403
+ ) => {
404
+ const tokensParsed = conf.tokensParsed
405
+ const fontsParsed = languageContext
406
+ ? getFontsForLanguage(conf.fontsParsed, languageContext)
407
+ : conf.fontsParsed
408
+ let valOrVar: any
409
+ let hasSet = false
410
+ if (theme[value]) {
411
+ valOrVar = theme[value]
412
+ hasSet = true
413
+ } else {
414
+ switch (key) {
415
+ case 'fontFamily':
416
+ valOrVar = fontsParsed[value]?.family || value
417
+ hasSet = true
418
+ break
419
+ case 'fontSize':
420
+ case 'lineHeight':
421
+ case 'letterSpacing':
422
+ case 'fontWeight':
423
+ valOrVar = fontsParsed[fontFamily]?.[fontShorthand[key] || key]?.[value] || value
424
+ hasSet = true
425
+ break
426
+ }
427
+ for (const cat in tokenCategories) {
428
+ if (key in tokenCategories[cat]) {
429
+ const res = tokensParsed[cat][value]
430
+ if (res) {
431
+ valOrVar = res
432
+ hasSet = true
433
+ }
434
+ }
435
+ }
436
+ if (!hasSet) {
437
+ const spaceVar = tokensParsed.space[value]
438
+ if (spaceVar) {
439
+ valOrVar = spaceVar
440
+ hasSet = true
441
+ }
442
+ }
443
+ }
444
+ if (hasSet) {
445
+ if (process.env.NODE_ENV === 'development' && isDevTools && debug === 'verbose') {
446
+ // eslint-disable-next-line no-console
447
+ console.log(` ﹒ propMapper getToken`, key, valOrVar)
448
+ }
449
+ return resolveVariableValue(key, valOrVar, resolveAs)
450
+ }
451
+ if (process.env.NODE_ENV === 'development') {
452
+ if (value && value[0] === '$') {
453
+ // eslint-disable-next-line no-console
454
+ console.trace(
455
+ `⚠️ You've passed the value "${value}" to the style property "${key}", but there's no theme or token with the key "${value}". Using theme "${theme.name}".
456
+
457
+ Set the debug prop to true to see more detailed debug information.`
458
+ )
459
+ if (debug) {
460
+ if (isDevTools) {
461
+ // eslint-disable-next-line no-console
462
+ console.log('Looked in:', { theme, tokensParsed, fontsParsed })
463
+ }
464
+ }
465
+ return null
466
+ }
467
+ }
468
+ return value
469
+ }
470
+
471
+ function resolveVariableValue(
472
+ key: string,
473
+ valOrVar: Variable | any,
474
+ resolveAs: ResolveVariableTypes = 'auto'
475
+ ) {
476
+ if (isVariable(valOrVar)) {
477
+ if (resolveAs === 'variable') {
478
+ return valOrVar
479
+ }
480
+ if (resolveAs === 'non-color-value') {
481
+ if (isWeb) {
482
+ if (key in tokenCategories.color) {
483
+ return valOrVar.variable
484
+ }
485
+ }
486
+ return valOrVar.val
487
+ }
488
+ if (!isWeb || resolveAs === 'value') {
489
+ return valOrVar.val
490
+ }
491
+ return valOrVar.variable
492
+ }
493
+ return valOrVar
494
+ }
495
+
496
+ // just specificy the least costly, all else go to `space` (most keys - we can exclude)
497
+ const tokenCategories = {
498
+ radius: {
499
+ borderRadius: true,
500
+ borderTopLeftRadius: true,
501
+ borderTopRightRadius: true,
502
+ borderBottomLeftRadius: true,
503
+ borderBottomRightRadius: true,
504
+ },
505
+ size: {
506
+ width: true,
507
+ height: true,
508
+ minWidth: true,
509
+ minHeight: true,
510
+ maxWidth: true,
511
+ maxHeight: true,
512
+ },
513
+ color: {
514
+ color: true,
515
+ backgroundColor: true,
516
+ borderColor: true,
517
+ borderBottomColor: true,
518
+ borderTopColor: true,
519
+ borderLeftColor: true,
520
+ borderRightColor: true,
521
+ },
522
+ }
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Some parts adapted from react-native-web
3
+ * Copyright (c) Nicolas Gallagher licensed under the MIT license.
4
+ */
5
+
6
+ import { isWeb } from '../constants/platform'
7
+
8
+ export function expandStyle(key: string, value: any) {
9
+ if (process.env.TAMAGUI_TARGET === 'web') {
10
+ if (key === 'flex') {
11
+ // The 'flex' property value in React Native must be a positive integer,
12
+ // 0, or -1.
13
+ if (value <= -1) {
14
+ return [
15
+ ['flexGrow', 0],
16
+ ['flexShrink', 1],
17
+ ['flexBasis', 'auto'],
18
+ ]
19
+ }
20
+ // normalizing to better align with native
21
+ // see spec for flex shorthand https://developer.mozilla.org/en-US/docs/Web/CSS/flex
22
+ if (value >= 0) {
23
+ return [
24
+ ['flexGrow', value],
25
+ ['flexShrink', 1],
26
+ ]
27
+ }
28
+ return
29
+ }
30
+
31
+ // web only
32
+ switch (key) {
33
+ case 'aspectRatio': {
34
+ return [[key, value.toString()]]
35
+ }
36
+
37
+ case 'textAlignVertical': {
38
+ return [['verticalAlign', value === 'center' ? 'middle' : value]]
39
+ }
40
+
41
+ case 'textDecorationLine': {
42
+ return [['textDecorationLine', value]]
43
+ }
44
+
45
+ case 'writingDirection': {
46
+ return [['direction', value]]
47
+ }
48
+ }
49
+ }
50
+
51
+ const longKey = STYLE_SHORT_FORM_EXPANSIONS[key]
52
+ if (longKey) {
53
+ return longKey.map((key) => {
54
+ return [key, value]
55
+ })
56
+ }
57
+ }
58
+
59
+ const STYLE_SHORT_FORM_EXPANSIONS: Record<string, string[]> = {
60
+ borderColor: ['borderTopColor', 'borderRightColor', 'borderBottomColor', 'borderLeftColor'],
61
+ borderRadius: [
62
+ 'borderTopLeftRadius',
63
+ 'borderTopRightRadius',
64
+ 'borderBottomRightRadius',
65
+ 'borderBottomLeftRadius',
66
+ ],
67
+ borderWidth: ['borderTopWidth', 'borderRightWidth', 'borderBottomWidth', 'borderLeftWidth'],
68
+ margin: ['marginTop', 'marginRight', 'marginBottom', 'marginLeft'],
69
+ marginHorizontal: ['marginRight', 'marginLeft'],
70
+ marginVertical: ['marginTop', 'marginBottom'],
71
+ overscrollBehavior: ['overscrollBehaviorX', 'overscrollBehaviorY'],
72
+ padding: ['paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft'],
73
+ paddingHorizontal: ['paddingRight', 'paddingLeft'],
74
+ paddingVertical: ['paddingTop', 'paddingBottom'],
75
+ ...(isWeb && {
76
+ // react-native only supports borderStyle
77
+ borderStyle: ['borderTopStyle', 'borderRightStyle', 'borderBottomStyle', 'borderLeftStyle'],
78
+ // react-native doesn't support X / Y
79
+ overflow: ['overflowX', 'overflowY'],
80
+ }),
81
+ }
@@ -0,0 +1,105 @@
1
+ import { getConfig } from '../config'
2
+ import { isWeb } from '../constants/platform'
3
+ import { expandStyle } from './expandStyle'
4
+ import { colorToRGBA, normalizeColor } from './normalizeColor'
5
+ import { normalizeValueWithProperty } from './normalizeValueWithProperty.js'
6
+ import { pseudoDescriptors } from './pseudoDescriptors'
7
+
8
+ let shorthands: Record<string, string> | null = null
9
+ export const defaultOffset = { height: 0, width: 0 }
10
+
11
+ /**
12
+ * This is what you want to run before Object.assign() a style onto another.
13
+ * It does the following:
14
+ * 1. Turns user shorthands into longhands, ie px = paddingHorizontal
15
+ * 2. Normalizes various inconsistent styles to be more consistent
16
+ * 3. Expands react-native shorthands, ie paddingHorizontal => paddingLeft, paddingRight
17
+ */
18
+
19
+ export function expandStyles(style: Record<string, any>, config = getConfig()) {
20
+ const res: Record<string, any> = {}
21
+
22
+ for (let key in style) {
23
+ shorthands = shorthands || (config ? config.shorthands : null)
24
+ if (shorthands) {
25
+ key = shorthands[key] || key
26
+ }
27
+ if (key in pseudoDescriptors) {
28
+ res[key] = expandStyles(style[key])
29
+ continue
30
+ }
31
+ const val = normalizeValueWithProperty(style[key], key)
32
+ // expand react-native shorthands
33
+ const out = expandStyle(key, val)
34
+ if (out) {
35
+ Object.assign(res, Object.fromEntries(out))
36
+ } else {
37
+ res[key] = val
38
+ }
39
+ }
40
+
41
+ fixStyles(res)
42
+
43
+ return res
44
+ }
45
+
46
+ export function fixStyles(style: Record<string, any>) {
47
+ if (style.shadowRadius) {
48
+ Object.assign(style, normalizeShadow(style))
49
+ }
50
+
51
+ // ensure border style set by default to solid
52
+ for (const key in borderDefaults) {
53
+ if (style[key] && !style[borderDefaults[key]]) {
54
+ style[borderDefaults[key]] = 'solid'
55
+ }
56
+ }
57
+ }
58
+
59
+ const borderDefaults = {
60
+ borderWidth: 'borderStyle',
61
+ borderBottomWidth: 'borderBottomStyle',
62
+ borderTopWidth: 'borderTopStyle',
63
+ borderLeftWidth: 'borderLeftStyle',
64
+ borderRightWidth: 'borderRightStyle',
65
+ }
66
+
67
+ function normalizeShadow({
68
+ shadowColor,
69
+ shadowOffset,
70
+ shadowOpacity,
71
+ shadowRadius,
72
+ }: Record<string, any>) {
73
+ const { height, width } = shadowOffset || defaultOffset
74
+ const colorStr = String(shadowColor || 'black')
75
+ return {
76
+ shadowOffset: {
77
+ width: normalizeValueWithProperty(width || 0),
78
+ height: normalizeValueWithProperty(height || 0),
79
+ },
80
+ shadowRadius: normalizeValueWithProperty(shadowRadius || 0),
81
+ ...(isWeb && {
82
+ shadowColor: normalizeColor(colorStr, shadowOpacity),
83
+ }),
84
+ ...(process.env.TAMAGUI_TARGET === 'native' &&
85
+ (() => {
86
+ // on native fix bug - shadows behave better if turned into non-alpha rgb() + shadowOpacity
87
+ const rgba = colorToRGBA(colorStr)
88
+ if (!rgba) {
89
+ if (process.env.NODE_ENV === 'development') {
90
+ // eslint-disable-next-line no-console
91
+ console.warn('No rgba form', colorStr)
92
+ }
93
+ return {
94
+ shadowColor,
95
+ shadowOpacity,
96
+ }
97
+ }
98
+ const [r, g, b, a] = rgba
99
+ return {
100
+ shadowColor: `rgb(${r},${g},${b})`,
101
+ shadowOpacity: shadowOpacity ?? a,
102
+ }
103
+ })()),
104
+ }
105
+ }