@tamagui/core 1.0.0-beta.8 → 1.0.1-beta.100

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 (559) hide show
  1. package/dist/cjs/Pressability.js +28 -0
  2. package/dist/cjs/Pressability.js.map +7 -0
  3. package/dist/cjs/Pressability.native.js +28 -0
  4. package/dist/cjs/Pressability.native.js.map +7 -0
  5. package/dist/cjs/Tamagui.js +6 -8
  6. package/dist/cjs/Tamagui.js.map +2 -2
  7. package/dist/cjs/ThemeManager.js +25 -32
  8. package/dist/cjs/ThemeManager.js.map +2 -2
  9. package/dist/cjs/conf.js +20 -15
  10. package/dist/cjs/conf.js.map +2 -2
  11. package/dist/cjs/constants/constants.js +1 -1
  12. package/dist/cjs/constants/constants.js.map +1 -1
  13. package/dist/cjs/constants/platform.js +8 -8
  14. package/dist/cjs/constants/platform.js.map +2 -2
  15. package/dist/cjs/constants/rnw.js +5 -19
  16. package/dist/cjs/constants/rnw.js.map +2 -2
  17. package/dist/cjs/constants/rnw.native.js +28 -0
  18. package/dist/cjs/constants/rnw.native.js.map +7 -0
  19. package/dist/cjs/createComponent.js +612 -295
  20. package/dist/cjs/createComponent.js.map +2 -2
  21. package/dist/cjs/createFont.js +2 -3
  22. package/dist/cjs/createFont.js.map +2 -2
  23. package/dist/cjs/createShorthands.js +0 -2
  24. package/dist/cjs/createShorthands.js.map +1 -1
  25. package/dist/cjs/createTamagui.js +147 -100
  26. package/dist/cjs/createTamagui.js.map +2 -2
  27. package/dist/cjs/createTheme.js +3 -2
  28. package/dist/cjs/createTheme.js.map +2 -2
  29. package/dist/cjs/createTokens.js +4 -21
  30. package/dist/cjs/createTokens.js.map +2 -2
  31. package/dist/cjs/createVariable.js +39 -14
  32. package/dist/cjs/createVariable.js.map +2 -2
  33. package/dist/cjs/createVariables.js +55 -0
  34. package/dist/cjs/createVariables.js.map +7 -0
  35. package/dist/cjs/helpers/areEqualSets.js +2 -3
  36. package/dist/cjs/helpers/areEqualSets.js.map +1 -1
  37. package/dist/cjs/helpers/assignNativePropsToWeb.js +187 -0
  38. package/dist/cjs/helpers/assignNativePropsToWeb.js.map +7 -0
  39. package/dist/cjs/helpers/assignNativePropsToWeb.native.js +29 -0
  40. package/dist/cjs/helpers/assignNativePropsToWeb.native.js.map +7 -0
  41. package/dist/cjs/helpers/calc.js +70 -0
  42. package/dist/cjs/helpers/calc.js.map +7 -0
  43. package/dist/cjs/helpers/createMediaStyle.js +4 -4
  44. package/dist/cjs/helpers/createMediaStyle.js.map +2 -2
  45. package/dist/cjs/helpers/createPropMapper.js +133 -113
  46. package/dist/cjs/helpers/createPropMapper.js.map +2 -2
  47. package/dist/cjs/helpers/createShallowUpdate.js +3 -4
  48. package/dist/cjs/helpers/createShallowUpdate.js.map +2 -2
  49. package/dist/cjs/helpers/createTamaguiProvider.js +16 -18
  50. package/dist/cjs/helpers/createTamaguiProvider.js.map +2 -2
  51. package/dist/cjs/helpers/cssHash.js +50 -0
  52. package/dist/cjs/helpers/cssHash.js.map +7 -0
  53. package/dist/cjs/helpers/expandStyle.js +111 -0
  54. package/dist/cjs/helpers/expandStyle.js.map +7 -0
  55. package/dist/cjs/helpers/expandStyles.js +126 -0
  56. package/dist/cjs/helpers/expandStyles.js.map +7 -0
  57. package/dist/cjs/helpers/extendStaticConfig.js +25 -17
  58. package/dist/cjs/helpers/extendStaticConfig.js.map +2 -2
  59. package/dist/cjs/helpers/fixNativeShadow.js +2 -3
  60. package/dist/cjs/helpers/fixNativeShadow.js.map +1 -1
  61. package/dist/cjs/helpers/getExpandedShorthands.js +0 -2
  62. package/dist/cjs/helpers/getExpandedShorthands.js.map +1 -1
  63. package/dist/cjs/helpers/getFont.js +61 -0
  64. package/dist/cjs/helpers/getFont.js.map +7 -0
  65. package/dist/cjs/helpers/getSize.js +17 -9
  66. package/dist/cjs/helpers/getSize.js.map +2 -2
  67. package/dist/cjs/helpers/getSplitStyles.js +268 -168
  68. package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
  69. package/dist/cjs/helpers/getStackSize.js +45 -0
  70. package/dist/cjs/helpers/getStackSize.js.map +7 -0
  71. package/dist/cjs/helpers/getStylesAtomic.js +178 -118
  72. package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
  73. package/dist/cjs/helpers/getStylesAtomic.native.js +0 -2
  74. package/dist/cjs/helpers/getStylesAtomic.native.js.map +1 -1
  75. package/dist/cjs/helpers/getTextSize.js +3 -4
  76. package/dist/cjs/helpers/getTextSize.js.map +2 -2
  77. package/dist/cjs/helpers/getVariantExtras.js +46 -0
  78. package/dist/cjs/helpers/getVariantExtras.js.map +7 -0
  79. package/dist/cjs/helpers/insertStyleRule.js +55 -37
  80. package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
  81. package/dist/cjs/helpers/isObj.js +1 -2
  82. package/dist/cjs/helpers/isObj.js.map +1 -1
  83. package/dist/cjs/helpers/isTamaguiComponent.js +36 -0
  84. package/dist/cjs/helpers/isTamaguiComponent.js.map +7 -0
  85. package/dist/cjs/helpers/isTamaguiElement.js +4 -5
  86. package/dist/cjs/helpers/isTamaguiElement.js.map +2 -2
  87. package/dist/cjs/helpers/matchMedia.js +2 -3
  88. package/dist/cjs/helpers/matchMedia.js.map +1 -1
  89. package/dist/cjs/helpers/matchMedia.native.js +1 -2
  90. package/dist/cjs/helpers/matchMedia.native.js.map +1 -1
  91. package/dist/cjs/helpers/mergeProps.js +49 -0
  92. package/dist/cjs/helpers/mergeProps.js.map +7 -0
  93. package/dist/cjs/helpers/mergeTransform.js +41 -0
  94. package/dist/cjs/helpers/mergeTransform.js.map +7 -0
  95. package/dist/cjs/helpers/nativeGestureHandler.native.js +18 -0
  96. package/dist/cjs/helpers/nativeGestureHandler.native.js.map +7 -0
  97. package/dist/cjs/helpers/normalizeColor.js +76 -0
  98. package/dist/cjs/helpers/normalizeColor.js.map +7 -0
  99. package/dist/cjs/helpers/normalizeValueWithProperty.js +90 -0
  100. package/dist/cjs/helpers/normalizeValueWithProperty.js.map +7 -0
  101. package/dist/cjs/helpers/proxyThemeVariables.js +1 -3
  102. package/dist/cjs/helpers/proxyThemeVariables.js.map +1 -1
  103. package/dist/cjs/helpers/pseudoDescriptors.js +41 -0
  104. package/dist/cjs/helpers/pseudoDescriptors.js.map +7 -0
  105. package/dist/cjs/helpers/registerCSSVariable.js +40 -0
  106. package/dist/cjs/helpers/registerCSSVariable.js.map +7 -0
  107. package/dist/cjs/helpers/themeable.js +3 -5
  108. package/dist/cjs/helpers/themeable.js.map +2 -2
  109. package/dist/cjs/helpers/validate.js +39 -37
  110. package/dist/cjs/helpers/validate.js.map +2 -2
  111. package/dist/cjs/helpers/withStaticProperties.js +2 -3
  112. package/dist/cjs/helpers/withStaticProperties.js.map +1 -1
  113. package/dist/cjs/helpers/wrapThemeManagerContext.js +0 -2
  114. package/dist/cjs/helpers/wrapThemeManagerContext.js.map +2 -2
  115. package/dist/cjs/hooks/useConstant.js +0 -2
  116. package/dist/cjs/hooks/useConstant.js.map +1 -1
  117. package/dist/cjs/hooks/useFeatures.js +22 -20
  118. package/dist/cjs/hooks/useFeatures.js.map +2 -2
  119. package/dist/cjs/hooks/useId.js +5 -6
  120. package/dist/cjs/hooks/useId.js.map +2 -2
  121. package/dist/cjs/hooks/useIsMounted.js +2 -4
  122. package/dist/cjs/hooks/useIsMounted.js.map +2 -2
  123. package/dist/cjs/hooks/useIsTouchDevice.js +3 -4
  124. package/dist/cjs/hooks/useIsTouchDevice.js.map +2 -2
  125. package/dist/cjs/hooks/useMedia.js +11 -15
  126. package/dist/cjs/hooks/useMedia.js.map +1 -1
  127. package/dist/cjs/hooks/usePressable.js +2 -3
  128. package/dist/cjs/hooks/usePressable.js.map +1 -1
  129. package/dist/cjs/hooks/usePrevious.js +1 -0
  130. package/dist/cjs/hooks/usePrevious.js.map +7 -0
  131. package/dist/cjs/hooks/useTheme.js +21 -33
  132. package/dist/cjs/hooks/useTheme.js.map +2 -2
  133. package/dist/cjs/hooks/useUnmountEffect.js +0 -2
  134. package/dist/cjs/hooks/useUnmountEffect.js.map +1 -1
  135. package/dist/cjs/index.js +21 -12
  136. package/dist/cjs/index.js.map +2 -2
  137. package/dist/cjs/insertFont.js +89 -0
  138. package/dist/cjs/insertFont.js.map +7 -0
  139. package/dist/cjs/static.js +3 -1
  140. package/dist/cjs/static.js.map +2 -2
  141. package/dist/cjs/styled.js +0 -3
  142. package/dist/cjs/styled.js.map +2 -2
  143. package/dist/cjs/types-rnw.js.map +1 -1
  144. package/dist/cjs/types.js.map +1 -1
  145. package/dist/cjs/views/Slot.js +40 -26
  146. package/dist/cjs/views/Slot.js.map +2 -2
  147. package/dist/cjs/views/Text.js +11 -15
  148. package/dist/cjs/views/Text.js.map +2 -2
  149. package/dist/cjs/views/TextAncestorContext.js +4 -6
  150. package/dist/cjs/views/TextAncestorContext.js.map +2 -2
  151. package/dist/cjs/views/Theme.js +6 -9
  152. package/dist/cjs/views/Theme.js.map +2 -2
  153. package/dist/cjs/views/ThemeInverse.js +7 -5
  154. package/dist/cjs/views/ThemeInverse.js.map +2 -2
  155. package/dist/cjs/views/ThemeProvider.js +6 -6
  156. package/dist/cjs/views/ThemeProvider.js.map +2 -2
  157. package/dist/cjs/views/ThemeReset.js +3 -3
  158. package/dist/cjs/views/ThemeReset.js.map +2 -2
  159. package/dist/esm/Pressability.js +5 -0
  160. package/dist/esm/Pressability.js.map +7 -0
  161. package/dist/esm/Pressability.native.js +5 -0
  162. package/dist/esm/Pressability.native.js.map +7 -0
  163. package/dist/esm/Tamagui.js +5 -8
  164. package/dist/esm/Tamagui.js.map +2 -2
  165. package/dist/esm/ThemeManager.js +25 -33
  166. package/dist/esm/ThemeManager.js.map +2 -2
  167. package/dist/esm/conf.js +18 -15
  168. package/dist/esm/conf.js.map +2 -2
  169. package/dist/esm/constants/constants.js +24 -9
  170. package/dist/esm/constants/constants.js.map +2 -2
  171. package/dist/esm/constants/platform.js +6 -6
  172. package/dist/esm/constants/platform.js.map +2 -2
  173. package/dist/esm/constants/rnw.js +2 -20
  174. package/dist/esm/constants/rnw.js.map +2 -2
  175. package/dist/esm/constants/rnw.native.js +5 -0
  176. package/dist/esm/constants/rnw.native.js.map +7 -0
  177. package/dist/esm/createComponent.js +705 -331
  178. package/dist/esm/createComponent.js.map +2 -2
  179. package/dist/esm/createFont.js +2 -4
  180. package/dist/esm/createFont.js.map +2 -2
  181. package/dist/esm/createShorthands.js +0 -3
  182. package/dist/esm/createShorthands.js.map +1 -1
  183. package/dist/esm/createTamagui.js +172 -105
  184. package/dist/esm/createTamagui.js.map +2 -2
  185. package/dist/esm/createTheme.js +3 -3
  186. package/dist/esm/createTheme.js.map +2 -2
  187. package/dist/esm/createTokens.js +3 -20
  188. package/dist/esm/createTokens.js.map +2 -2
  189. package/dist/esm/createVariable.js +38 -14
  190. package/dist/esm/createVariable.js.map +2 -2
  191. package/dist/esm/createVariables.js +32 -0
  192. package/dist/esm/createVariables.js.map +7 -0
  193. package/dist/esm/helpers/areEqualSets.js +2 -4
  194. package/dist/esm/helpers/areEqualSets.js.map +1 -1
  195. package/dist/esm/helpers/assignNativePropsToWeb.js +164 -0
  196. package/dist/esm/helpers/assignNativePropsToWeb.js.map +7 -0
  197. package/dist/esm/helpers/assignNativePropsToWeb.native.js +6 -0
  198. package/dist/esm/helpers/assignNativePropsToWeb.native.js.map +7 -0
  199. package/dist/esm/helpers/calc.js +47 -0
  200. package/dist/esm/helpers/calc.js.map +7 -0
  201. package/dist/esm/helpers/createMediaStyle.js +4 -5
  202. package/dist/esm/helpers/createMediaStyle.js.map +2 -2
  203. package/dist/esm/helpers/createPropMapper.js +131 -114
  204. package/dist/esm/helpers/createPropMapper.js.map +2 -2
  205. package/dist/esm/helpers/createShallowUpdate.js +19 -5
  206. package/dist/esm/helpers/createShallowUpdate.js.map +2 -2
  207. package/dist/esm/helpers/createTamaguiProvider.js +46 -19
  208. package/dist/esm/helpers/createTamaguiProvider.js.map +2 -2
  209. package/dist/esm/helpers/cssHash.js +27 -0
  210. package/dist/esm/helpers/cssHash.js.map +7 -0
  211. package/dist/esm/helpers/expandStyle.js +90 -0
  212. package/dist/esm/helpers/expandStyle.js.map +7 -0
  213. package/dist/esm/helpers/expandStyles.js +103 -0
  214. package/dist/esm/helpers/expandStyles.js.map +7 -0
  215. package/dist/esm/helpers/extendStaticConfig.js +46 -40
  216. package/dist/esm/helpers/extendStaticConfig.js.map +2 -2
  217. package/dist/esm/helpers/fixNativeShadow.js +2 -4
  218. package/dist/esm/helpers/fixNativeShadow.js.map +1 -1
  219. package/dist/esm/helpers/getExpandedShorthands.js +0 -3
  220. package/dist/esm/helpers/getExpandedShorthands.js.map +1 -1
  221. package/dist/{jsx/helpers/getTextSize.js → esm/helpers/getFont.js} +12 -7
  222. package/dist/esm/helpers/getFont.js.map +7 -0
  223. package/dist/esm/helpers/getSize.js +15 -9
  224. package/dist/esm/helpers/getSize.js.map +2 -2
  225. package/dist/esm/helpers/getSplitStyles.js +282 -176
  226. package/dist/esm/helpers/getSplitStyles.js.map +2 -2
  227. package/dist/esm/helpers/getStackSize.js +22 -0
  228. package/dist/esm/helpers/getStackSize.js.map +7 -0
  229. package/dist/esm/helpers/getStylesAtomic.js +188 -110
  230. package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
  231. package/dist/esm/helpers/getStylesAtomic.native.js +0 -3
  232. package/dist/esm/helpers/getStylesAtomic.native.js.map +1 -1
  233. package/dist/esm/helpers/getTextSize.js +3 -5
  234. package/dist/esm/helpers/getTextSize.js.map +2 -2
  235. package/dist/esm/helpers/getVariantExtras.js +23 -0
  236. package/dist/esm/helpers/getVariantExtras.js.map +7 -0
  237. package/dist/esm/helpers/insertStyleRule.js +55 -38
  238. package/dist/esm/helpers/insertStyleRule.js.map +2 -2
  239. package/dist/esm/helpers/isObj.js +1 -3
  240. package/dist/esm/helpers/isObj.js.map +1 -1
  241. package/dist/esm/helpers/isTamaguiComponent.js +13 -0
  242. package/dist/esm/helpers/isTamaguiComponent.js.map +7 -0
  243. package/dist/esm/helpers/isTamaguiElement.js +4 -6
  244. package/dist/esm/helpers/isTamaguiElement.js.map +2 -2
  245. package/dist/esm/helpers/matchMedia.js +2 -4
  246. package/dist/esm/helpers/matchMedia.js.map +1 -1
  247. package/dist/esm/helpers/matchMedia.native.js +1 -3
  248. package/dist/esm/helpers/matchMedia.native.js.map +1 -1
  249. package/dist/esm/helpers/mergeProps.js +26 -0
  250. package/dist/esm/helpers/mergeProps.js.map +7 -0
  251. package/dist/esm/helpers/mergeTransform.js +17 -0
  252. package/dist/esm/helpers/mergeTransform.js.map +7 -0
  253. package/dist/esm/helpers/nativeGestureHandler.native.js +2 -0
  254. package/dist/esm/helpers/nativeGestureHandler.native.js.map +7 -0
  255. package/dist/esm/helpers/normalizeColor.js +49 -0
  256. package/dist/esm/helpers/normalizeColor.js.map +7 -0
  257. package/dist/esm/helpers/normalizeValueWithProperty.js +67 -0
  258. package/dist/esm/helpers/normalizeValueWithProperty.js.map +7 -0
  259. package/dist/esm/helpers/proxyThemeVariables.js +1 -4
  260. package/dist/esm/helpers/proxyThemeVariables.js.map +1 -1
  261. package/dist/esm/helpers/pseudoDescriptors.js +18 -0
  262. package/dist/esm/helpers/pseudoDescriptors.js.map +7 -0
  263. package/dist/esm/helpers/registerCSSVariable.js +15 -0
  264. package/dist/esm/helpers/registerCSSVariable.js.map +7 -0
  265. package/dist/esm/helpers/themeable.js +34 -5
  266. package/dist/esm/helpers/themeable.js.map +2 -2
  267. package/dist/esm/helpers/validate.js +42 -19
  268. package/dist/esm/helpers/validate.js.map +2 -2
  269. package/dist/esm/helpers/withStaticProperties.js +2 -4
  270. package/dist/esm/helpers/withStaticProperties.js.map +1 -1
  271. package/dist/esm/helpers/wrapThemeManagerContext.js +0 -3
  272. package/dist/esm/helpers/wrapThemeManagerContext.js.map +2 -2
  273. package/dist/esm/hooks/useConstant.js +0 -3
  274. package/dist/esm/hooks/useConstant.js.map +1 -1
  275. package/dist/esm/hooks/useFeatures.js +59 -26
  276. package/dist/esm/hooks/useFeatures.js.map +2 -2
  277. package/dist/esm/hooks/useId.js +8 -11
  278. package/dist/esm/hooks/useId.js.map +2 -2
  279. package/dist/esm/hooks/useIsMounted.js +1 -4
  280. package/dist/esm/hooks/useIsMounted.js.map +2 -2
  281. package/dist/esm/hooks/useIsTouchDevice.js +4 -6
  282. package/dist/esm/hooks/useIsTouchDevice.js.map +2 -2
  283. package/dist/esm/hooks/useMedia.js +28 -21
  284. package/dist/esm/hooks/useMedia.js.map +1 -1
  285. package/dist/esm/hooks/usePressable.js +18 -5
  286. package/dist/esm/hooks/usePressable.js.map +1 -1
  287. package/dist/esm/hooks/usePrevious.js +1 -0
  288. package/dist/esm/hooks/usePrevious.js.map +7 -0
  289. package/dist/esm/hooks/useTheme.js +45 -41
  290. package/dist/esm/hooks/useTheme.js.map +2 -2
  291. package/dist/esm/hooks/useUnmountEffect.js +0 -3
  292. package/dist/esm/hooks/useUnmountEffect.js.map +1 -1
  293. package/dist/esm/index.js +18 -9
  294. package/dist/esm/index.js.map +2 -2
  295. package/dist/esm/insertFont.js +64 -0
  296. package/dist/esm/insertFont.js.map +7 -0
  297. package/dist/esm/static.js +3 -1
  298. package/dist/esm/static.js.map +2 -2
  299. package/dist/esm/styled.js +37 -12
  300. package/dist/esm/styled.js.map +2 -2
  301. package/dist/esm/views/Slot.js +74 -34
  302. package/dist/esm/views/Slot.js.map +2 -2
  303. package/dist/esm/views/Stack.js +21 -3
  304. package/dist/esm/views/Stack.js.map +1 -1
  305. package/dist/esm/views/Text.js +27 -19
  306. package/dist/esm/views/Text.js.map +2 -2
  307. package/dist/esm/views/TextAncestorContext.js +4 -7
  308. package/dist/esm/views/TextAncestorContext.js.map +2 -2
  309. package/dist/esm/views/Theme.js +6 -10
  310. package/dist/esm/views/Theme.js.map +2 -2
  311. package/dist/esm/views/ThemeInverse.js +8 -7
  312. package/dist/esm/views/ThemeInverse.js.map +2 -2
  313. package/dist/esm/views/ThemeProvider.js +6 -7
  314. package/dist/esm/views/ThemeProvider.js.map +2 -2
  315. package/dist/esm/views/ThemeReset.js +3 -4
  316. package/dist/esm/views/ThemeReset.js.map +2 -2
  317. package/package.json +18 -11
  318. package/reset.css +41 -0
  319. package/types/Pressability.d.ts +2 -0
  320. package/types/Pressability.native.d.ts +2 -0
  321. package/types/Tamagui.d.ts +4 -6
  322. package/types/Tamagui.d.ts.map +1 -1
  323. package/types/ThemeContext.d.ts +0 -0
  324. package/types/ThemeContext.d.ts.map +0 -0
  325. package/types/ThemeManager.d.ts +10 -7
  326. package/types/ThemeManager.d.ts.map +1 -1
  327. package/types/conf.d.ts +3 -4
  328. package/types/conf.d.ts.map +1 -1
  329. package/types/constants/constants.d.ts +1 -1
  330. package/types/constants/platform.d.ts +2 -2
  331. package/types/constants/rnw.d.ts +1 -1
  332. package/types/constants/rnw.d.ts.map +1 -1
  333. package/types/constants/rnw.native.d.ts +2 -0
  334. package/types/contexts/ButtonInsideButtonContext.d.ts +0 -0
  335. package/types/createComponent.d.ts +40 -15
  336. package/types/createComponent.d.ts.map +1 -1
  337. package/types/createFont.d.ts +0 -0
  338. package/types/createFont.d.ts.map +0 -0
  339. package/types/createShorthands.d.ts +0 -0
  340. package/types/createTamagui.d.ts +10 -2
  341. package/types/createTamagui.d.ts.map +1 -1
  342. package/types/createTheme.d.ts +1 -1
  343. package/types/createTokens.d.ts +0 -1
  344. package/types/createTokens.d.ts.map +1 -1
  345. package/types/createVariable.d.ts +16 -11
  346. package/types/createVariables.d.ts +10 -0
  347. package/types/defaultComponentState.d.ts +0 -0
  348. package/types/helpers/RNComponents.d.ts +0 -0
  349. package/types/helpers/areEqualSets.d.ts +0 -0
  350. package/types/helpers/assignNativePropsToWeb.d.ts +2 -0
  351. package/types/helpers/assignNativePropsToWeb.d.ts.map +1 -0
  352. package/types/helpers/assignNativePropsToWeb.native.d.ts +2 -0
  353. package/types/helpers/calc.d.ts +12 -0
  354. package/types/helpers/calc.d.ts.map +1 -0
  355. package/types/helpers/createMediaStyle.d.ts +1 -1
  356. package/types/helpers/createMediaStyle.d.ts.map +1 -1
  357. package/types/helpers/createPropMapper.d.ts +4 -3
  358. package/types/helpers/createPropMapper.d.ts.map +1 -1
  359. package/types/helpers/createShallowUpdate.d.ts +1 -2
  360. package/types/helpers/createTamaguiProvider.d.ts +2 -6
  361. package/types/helpers/createTamaguiProvider.d.ts.map +1 -1
  362. package/types/helpers/cssHash.d.ts +2 -0
  363. package/types/helpers/cssHash.d.ts.map +1 -0
  364. package/types/helpers/expandStyle.d.ts +2 -0
  365. package/types/helpers/expandStyle.d.ts.map +1 -0
  366. package/types/helpers/expandStyles.d.ts +7 -0
  367. package/types/helpers/expandStyles.d.ts.map +1 -0
  368. package/types/helpers/extendStaticConfig.d.ts +0 -0
  369. package/types/helpers/extendStaticConfig.d.ts.map +1 -1
  370. package/types/helpers/fixNativeShadow.d.ts +0 -0
  371. package/types/helpers/getExpandedShorthands.d.ts +0 -0
  372. package/types/helpers/getExpandedShorthands.d.ts.map +0 -0
  373. package/types/helpers/getFont.d.ts +3 -0
  374. package/types/helpers/getFont.d.ts.map +1 -0
  375. package/types/helpers/getSize.d.ts +3 -2
  376. package/types/helpers/getSize.d.ts.map +1 -1
  377. package/types/helpers/getSplitStyles.d.ts +10 -7
  378. package/types/helpers/getSplitStyles.d.ts.map +1 -1
  379. package/types/helpers/getStackSize.d.ts +8 -0
  380. package/types/helpers/getStackSize.d.ts.map +1 -0
  381. package/types/helpers/getStylesAtomic.d.ts +7 -17
  382. package/types/helpers/getStylesAtomic.d.ts.map +1 -1
  383. package/types/helpers/getStylesAtomic.native.d.ts +0 -0
  384. package/types/helpers/getVariantExtras.d.ts +7 -0
  385. package/types/helpers/getVariantExtras.d.ts.map +1 -0
  386. package/types/helpers/insertStyleRule.d.ts +1 -1
  387. package/types/helpers/isObj.d.ts +0 -0
  388. package/types/helpers/isTamaguiComponent.d.ts +5 -0
  389. package/types/helpers/isTamaguiComponent.d.ts.map +1 -0
  390. package/types/helpers/isTamaguiElement.d.ts +1 -1
  391. package/types/helpers/isTamaguiElement.d.ts.map +1 -1
  392. package/types/helpers/matchMedia.d.ts +0 -0
  393. package/types/helpers/matchMedia.native.d.ts +0 -0
  394. package/types/helpers/mergeProps.d.ts +2 -0
  395. package/types/helpers/mergeTransform.d.ts +7 -0
  396. package/types/helpers/nativeGestureHandler.native.d.ts +2 -0
  397. package/types/helpers/normalizeColor.d.ts +3 -0
  398. package/types/helpers/normalizeColor.d.ts.map +1 -0
  399. package/types/helpers/normalizeValueWithProperty.d.ts +2 -0
  400. package/types/helpers/normalizeValueWithProperty.d.ts.map +1 -0
  401. package/types/helpers/proxyThemeVariables.d.ts +0 -0
  402. package/types/helpers/pseudoDescriptors.d.ts +16 -0
  403. package/types/helpers/registerCSSVariable.d.ts +5 -0
  404. package/types/helpers/themeable.d.ts +0 -0
  405. package/types/helpers/themeable.d.ts.map +1 -1
  406. package/types/helpers/validate.d.ts +0 -0
  407. package/types/helpers/withStaticProperties.d.ts +0 -0
  408. package/types/helpers/wrapThemeManagerContext.d.ts +0 -0
  409. package/types/helpers/wrapThemeManagerContext.d.ts.map +0 -0
  410. package/types/hooks/useConstant.d.ts +0 -0
  411. package/types/hooks/useFeatures.d.ts +11 -5
  412. package/types/hooks/useFeatures.d.ts.map +1 -1
  413. package/types/hooks/useId.d.ts +0 -0
  414. package/types/hooks/useIsMounted.d.ts +0 -0
  415. package/types/hooks/useIsTouchDevice.d.ts +0 -0
  416. package/types/hooks/useMedia.d.ts +0 -0
  417. package/types/hooks/useMedia.d.ts.map +0 -0
  418. package/types/hooks/usePressable.d.ts +0 -0
  419. package/types/hooks/usePrevious.d.ts +1 -0
  420. package/types/hooks/useTheme.d.ts +15 -6
  421. package/types/hooks/useTheme.d.ts.map +1 -1
  422. package/types/hooks/useUnmountEffect.d.ts +0 -0
  423. package/types/index.d.ts +16 -6
  424. package/types/index.d.ts.map +1 -1
  425. package/types/insertFont.d.ts +6 -0
  426. package/types/insertFont.d.ts.map +1 -0
  427. package/types/static.d.ts +3 -1
  428. package/types/static.d.ts.map +1 -1
  429. package/types/styled.d.ts +2 -2
  430. package/types/styled.d.ts.map +1 -1
  431. package/types/types-rnw.d.ts +0 -0
  432. package/types/types.d.ts +71 -51
  433. package/types/types.d.ts.map +1 -1
  434. package/types/views/Slot.d.ts +1 -0
  435. package/types/views/Stack.d.ts +0 -0
  436. package/types/views/Stack.d.ts.map +0 -0
  437. package/types/views/Text.d.ts +0 -0
  438. package/types/views/Text.d.ts.map +1 -1
  439. package/types/views/TextAncestorContext.d.ts +0 -0
  440. package/types/views/TextAncestorContext.d.ts.map +1 -1
  441. package/types/views/Theme.d.ts +1 -9
  442. package/types/views/Theme.d.ts.map +1 -1
  443. package/types/views/ThemeInverse.d.ts +0 -0
  444. package/types/views/ThemeInverse.d.ts.map +1 -1
  445. package/types/views/ThemeProvider.d.ts +2 -0
  446. package/types/views/ThemeProvider.d.ts.map +1 -1
  447. package/types/views/ThemeReset.d.ts +0 -0
  448. package/types/views/ThemeReset.d.ts.map +0 -0
  449. package/dist/cjs/helpers/addStylesUsingClassname.js +0 -87
  450. package/dist/cjs/helpers/addStylesUsingClassname.js.map +0 -7
  451. package/dist/cjs/helpers/fixNativeShadow.native.js +0 -63
  452. package/dist/cjs/helpers/fixNativeShadow.native.js.map +0 -7
  453. package/dist/cjs/helpers/getButtonSize.js +0 -45
  454. package/dist/cjs/helpers/getButtonSize.js.map +0 -7
  455. package/dist/esm/helpers/addStylesUsingClassname.js +0 -64
  456. package/dist/esm/helpers/addStylesUsingClassname.js.map +0 -7
  457. package/dist/esm/helpers/fixNativeShadow.native.js +0 -41
  458. package/dist/esm/helpers/fixNativeShadow.native.js.map +0 -7
  459. package/dist/esm/helpers/getButtonSize.js +0 -24
  460. package/dist/esm/helpers/getButtonSize.js.map +0 -7
  461. package/dist/jsx/Tamagui.js +0 -41
  462. package/dist/jsx/ThemeContext.js +0 -5
  463. package/dist/jsx/ThemeManager.js +0 -186
  464. package/dist/jsx/conf.js +0 -35
  465. package/dist/jsx/constants/constants.js +0 -17
  466. package/dist/jsx/constants/platform.js +0 -25
  467. package/dist/jsx/constants/rnw.js +0 -23
  468. package/dist/jsx/contexts/ButtonInsideButtonContext.js +0 -5
  469. package/dist/jsx/createComponent.js +0 -617
  470. package/dist/jsx/createFont.js +0 -27
  471. package/dist/jsx/createShorthands.js +0 -9
  472. package/dist/jsx/createTamagui.js +0 -201
  473. package/dist/jsx/createTheme.js +0 -6
  474. package/dist/jsx/createTokens.js +0 -28
  475. package/dist/jsx/createVariable.js +0 -48
  476. package/dist/jsx/defaultComponentState.js +0 -0
  477. package/dist/jsx/helpers/RNComponents.js +0 -11
  478. package/dist/jsx/helpers/addStylesUsingClassname.js +0 -63
  479. package/dist/jsx/helpers/areEqualSets.js +0 -15
  480. package/dist/jsx/helpers/createMediaStyle.js +0 -30
  481. package/dist/jsx/helpers/createPropMapper.js +0 -237
  482. package/dist/jsx/helpers/createShallowUpdate.js +0 -18
  483. package/dist/jsx/helpers/createTamaguiProvider.js +0 -34
  484. package/dist/jsx/helpers/extendStaticConfig.js +0 -61
  485. package/dist/jsx/helpers/fixNativeShadow.js +0 -7
  486. package/dist/jsx/helpers/fixNativeShadow.native.js +0 -40
  487. package/dist/jsx/helpers/getButtonSize.js +0 -23
  488. package/dist/jsx/helpers/getExpandedShorthands.js +0 -18
  489. package/dist/jsx/helpers/getSize.js +0 -12
  490. package/dist/jsx/helpers/getSplitStyles.js +0 -302
  491. package/dist/jsx/helpers/getStylesAtomic.js +0 -130
  492. package/dist/jsx/helpers/getStylesAtomic.native.js +0 -9
  493. package/dist/jsx/helpers/insertStyleRule.js +0 -94
  494. package/dist/jsx/helpers/isObj.js +0 -6
  495. package/dist/jsx/helpers/isTamaguiElement.js +0 -10
  496. package/dist/jsx/helpers/matchMedia.js +0 -17
  497. package/dist/jsx/helpers/matchMedia.native.js +0 -8
  498. package/dist/jsx/helpers/proxyThemeVariables.js +0 -17
  499. package/dist/jsx/helpers/themeable.js +0 -24
  500. package/dist/jsx/helpers/validate.js +0 -75
  501. package/dist/jsx/helpers/withStaticProperties.js +0 -9
  502. package/dist/jsx/helpers/wrapThemeManagerContext.js +0 -10
  503. package/dist/jsx/hooks/useConstant.js +0 -14
  504. package/dist/jsx/hooks/useFeatures.js +0 -167
  505. package/dist/jsx/hooks/useId.js +0 -34
  506. package/dist/jsx/hooks/useIsMounted.js +0 -18
  507. package/dist/jsx/hooks/useIsTouchDevice.js +0 -16
  508. package/dist/jsx/hooks/useMedia.js +0 -158
  509. package/dist/jsx/hooks/usePressable.js +0 -13
  510. package/dist/jsx/hooks/useTheme.js +0 -177
  511. package/dist/jsx/hooks/useUnmountEffect.js +0 -10
  512. package/dist/jsx/index.js +0 -54
  513. package/dist/jsx/static.js +0 -16
  514. package/dist/jsx/styled.js +0 -48
  515. package/dist/jsx/types-rnw.js +0 -0
  516. package/dist/jsx/types.js +0 -0
  517. package/dist/jsx/views/Slot.js +0 -56
  518. package/dist/jsx/views/Stack.js +0 -12
  519. package/dist/jsx/views/Text.js +0 -61
  520. package/dist/jsx/views/TextAncestorContext.js +0 -15
  521. package/dist/jsx/views/Theme.js +0 -31
  522. package/dist/jsx/views/ThemeInverse.js +0 -22
  523. package/dist/jsx/views/ThemeProvider.js +0 -35
  524. package/dist/jsx/views/ThemeReset.js +0 -34
  525. package/types/constants/constants.d.ts.map +0 -1
  526. package/types/constants/platform.d.ts.map +0 -1
  527. package/types/contexts/ButtonInsideButtonContext.d.ts.map +0 -1
  528. package/types/createShorthands.d.ts.map +0 -1
  529. package/types/createTheme.d.ts.map +0 -1
  530. package/types/createVariable.d.ts.map +0 -1
  531. package/types/defaultComponentState.d.ts.map +0 -1
  532. package/types/helpers/RNComponents.d.ts.map +0 -1
  533. package/types/helpers/addStylesUsingClassname.d.ts +0 -3
  534. package/types/helpers/addStylesUsingClassname.d.ts.map +0 -1
  535. package/types/helpers/areEqualSets.d.ts.map +0 -1
  536. package/types/helpers/createShallowUpdate.d.ts.map +0 -1
  537. package/types/helpers/fixNativeShadow.d.ts.map +0 -1
  538. package/types/helpers/fixNativeShadow.native.d.ts +0 -2
  539. package/types/helpers/fixNativeShadow.native.d.ts.map +0 -1
  540. package/types/helpers/getButtonSize.d.ts +0 -8
  541. package/types/helpers/getButtonSize.d.ts.map +0 -1
  542. package/types/helpers/getStylesAtomic.native.d.ts.map +0 -1
  543. package/types/helpers/getTextSize.d.ts +0 -3
  544. package/types/helpers/getTextSize.d.ts.map +0 -1
  545. package/types/helpers/insertStyleRule.d.ts.map +0 -1
  546. package/types/helpers/isObj.d.ts.map +0 -1
  547. package/types/helpers/matchMedia.d.ts.map +0 -1
  548. package/types/helpers/matchMedia.native.d.ts.map +0 -1
  549. package/types/helpers/proxyThemeVariables.d.ts.map +0 -1
  550. package/types/helpers/validate.d.ts.map +0 -1
  551. package/types/helpers/withStaticProperties.d.ts.map +0 -1
  552. package/types/hooks/useConstant.d.ts.map +0 -1
  553. package/types/hooks/useId.d.ts.map +0 -1
  554. package/types/hooks/useIsMounted.d.ts.map +0 -1
  555. package/types/hooks/useIsTouchDevice.d.ts.map +0 -1
  556. package/types/hooks/usePressable.d.ts.map +0 -1
  557. package/types/hooks/useUnmountEffect.d.ts.map +0 -1
  558. package/types/types-rnw.d.ts.map +0 -1
  559. package/types/views/Slot.d.ts.map +0 -1
@@ -1,12 +1,37 @@
1
1
  var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
3
20
  import { configListeners, getHasConfigured, setConfig } from "./conf";
4
21
  import { THEME_CLASSNAME_PREFIX } from "./constants/constants";
5
22
  import { isWeb } from "./constants/platform";
6
- import { Variable, createCSSVariable, createVariable, isVariable } from "./createVariable";
23
+ import { createVariable, isVariable } from "./createVariable";
24
+ import { createVariables } from "./createVariables";
7
25
  import { createTamaguiProvider } from "./helpers/createTamaguiProvider";
8
26
  import { getInsertedRules } from "./helpers/insertStyleRule";
27
+ import {
28
+ registerCSSVariable,
29
+ tokenRules,
30
+ tokensValueToVariable
31
+ } from "./helpers/registerCSSVariable";
9
32
  import { configureMedia } from "./hooks/useMedia";
33
+ import { parseFont, registerFontVariables } from "./insertFont";
34
+ import { Tamagui } from "./Tamagui";
10
35
  const createdConfigs = /* @__PURE__ */ new WeakMap();
11
36
  function createTamagui(config) {
12
37
  if (createdConfigs.has(config)) {
@@ -19,157 +44,196 @@ function createTamagui(config) {
19
44
  if (!config.themes) {
20
45
  throw new Error(`No themes provided to Tamagui config`);
21
46
  }
47
+ if (!config.fonts) {
48
+ throw new Error(`No fonts provided to Tamagui config`);
49
+ }
22
50
  }
23
51
  if (getHasConfigured()) {
24
- console.warn("Called createTamagui twice! Should never do so");
52
+ console.warn(`Warning: createTamagui called twice (maybe HMR)`);
25
53
  }
26
54
  configureMedia({
27
55
  queries: config.media,
28
56
  defaultActive: config.mediaQueryDefaultActive
29
57
  });
58
+ const fontTokens = createVariables(config.fonts);
59
+ const fontsParsed = (() => {
60
+ const res = {};
61
+ for (const familyName in fontTokens) {
62
+ res[`$${familyName}`] = parseFont(fontTokens[familyName]);
63
+ }
64
+ return res;
65
+ })();
30
66
  const themeConfig = (() => {
31
- var _a, _b, _c;
67
+ const themes = __spreadValues({}, config.themes);
32
68
  let cssRules = [];
33
- const varsByValue = /* @__PURE__ */ new Map();
34
69
  if (isWeb) {
35
- const tokenRules = /* @__PURE__ */ new Set();
36
- const addVar = /* @__PURE__ */ __name((v) => {
37
- varsByValue[v.val] = v;
38
- const rule = `--${createCSSVariable(v.name, false)}:${typeof v.val === "number" ? `${v.val}px` : v.val}`;
39
- tokenRules.add(rule);
40
- }, "addVar");
41
70
  for (const key in config.tokens) {
42
71
  for (const skey in config.tokens[key]) {
43
72
  const val = config.tokens[key][skey];
44
- if (key === "font") {
45
- for (const fkey in val) {
46
- if (fkey === "family") {
47
- addVar(val[fkey]);
48
- } else {
49
- for (const fskey in val[fkey]) {
50
- addVar(val[fkey][fskey]);
51
- }
52
- }
53
- }
54
- } else {
55
- addVar(val);
56
- }
73
+ registerCSSVariable(val);
57
74
  }
58
75
  }
76
+ for (const key in fontsParsed) {
77
+ const fontParsed = fontsParsed[key];
78
+ registerFontVariables(fontParsed);
79
+ }
59
80
  const sep = process.env.NODE_ENV === "development" ? config.cssStyleSeparator || " " : "";
60
81
  cssRules.push(`:root {${sep}${[...tokenRules].join(`;${sep}`)}${sep}}`);
61
82
  }
62
83
  const hasDarkLight = "light" in config.themes && "dark" in config.themes;
63
84
  const CNP = `.${THEME_CLASSNAME_PREFIX}`;
64
- for (const themeName in config.themes) {
65
- const theme = { ...config.themes[themeName] };
66
- config.themes[themeName] = theme;
67
- let vars = "";
68
- for (const themeKey in theme) {
69
- if (isWeb) {
70
- const val = theme[themeKey];
71
- const varName = val instanceof Variable ? val.name : (_a = varsByValue[val]) == null ? void 0 : _a.name;
72
- vars += `--${themeKey}:${varName ? createCSSVariable(varName) : `${val}`};`;
73
- }
74
- ensureThemeVariable(theme, themeKey);
85
+ const dedupedThemes = {};
86
+ const existing = /* @__PURE__ */ new WeakMap();
87
+ for (const themeName in themes) {
88
+ const rawTheme = themes[themeName];
89
+ if (existing.has(rawTheme)) {
90
+ const e = existing.get(rawTheme);
91
+ themes[themeName] = e.theme;
92
+ e.names.push(themeName);
93
+ continue;
75
94
  }
76
- if (isWeb) {
95
+ const theme = __spreadValues({}, config.themes[themeName]);
96
+ for (const key in theme) {
97
+ ensureThemeVariable(theme, key);
98
+ }
99
+ themes[themeName] = theme;
100
+ dedupedThemes[themeName] = {
101
+ names: [themeName],
102
+ theme
103
+ };
104
+ existing.set(config.themes[themeName], dedupedThemes[themeName]);
105
+ }
106
+ if (isWeb) {
107
+ for (const themeName in dedupedThemes) {
108
+ const { theme, names } = dedupedThemes[themeName];
109
+ let vars = "";
110
+ for (const themeKey in theme) {
111
+ const variable = theme[themeKey];
112
+ let value = null;
113
+ if (variable.isFloating || !tokensValueToVariable.has(variable.val)) {
114
+ value = variable.val;
115
+ } else {
116
+ value = tokensValueToVariable.get(variable.val).variable;
117
+ }
118
+ vars += `--${themeKey}:${value};`;
119
+ }
77
120
  const isDarkOrLightBase = themeName === "dark" || themeName === "light";
78
- const isDark = themeName.startsWith("dark");
79
- const selector = `${CNP}${themeName}`;
80
- const selectors = [selector];
121
+ const selectors = names.map((name) => {
122
+ return `${CNP}${name}`;
123
+ });
81
124
  if (hasDarkLight) {
82
- const childSelector = `${CNP}${themeName.replace("dark_", "").replace("light_", "")}`;
83
- const order = isDark ? ["dark", "light"] : ["light", "dark"];
84
- if (isDarkOrLightBase) {
85
- order.reverse();
86
- }
87
- const [stronger, weaker] = order;
88
- const max = (_b = config.maxDarkLightNesting) != null ? _b : 3;
89
- new Array(max * 2).fill(void 0).forEach((_, pi) => {
90
- if (pi % 2 === 1)
91
- return;
92
- const parents = new Array(pi + 1).fill(void 0).map((_2, psi) => {
93
- return `${CNP}${psi % 2 === 0 ? stronger : weaker}`;
125
+ for (const subName of names) {
126
+ const isDark = isDarkOrLightBase || subName.startsWith("dark_");
127
+ const childSelector = `${CNP}${subName.replace(isDark ? "dark_" : "light_", "")}`;
128
+ const order = isDark ? ["dark", "light"] : ["light", "dark"];
129
+ if (isDarkOrLightBase) {
130
+ order.reverse();
131
+ }
132
+ const [stronger, weaker] = order;
133
+ const max = config.maxDarkLightNesting ?? 3;
134
+ new Array(Math.round(max * 1.5)).fill(void 0).forEach((_, pi) => {
135
+ const isOdd = pi % 2 === 1;
136
+ if (isOdd && pi < 3)
137
+ return;
138
+ const parents = new Array(pi + 1).fill(void 0).map((_2, psi) => {
139
+ return `${CNP}${psi % 2 === 0 ? stronger : weaker}`;
140
+ });
141
+ let parentSelectors = parents.length > 1 ? parents.slice(1) : parents;
142
+ if (isOdd) {
143
+ const [_first, second, ...rest] = parentSelectors;
144
+ parentSelectors = [second, ...rest, second];
145
+ }
146
+ selectors.push(`${parentSelectors.join(" ")} ${childSelector}`);
94
147
  });
95
- selectors.push(`${(parents.length > 1 ? parents.slice(1) : parents).join(" ")} ${childSelector}`);
96
- });
148
+ }
97
149
  }
98
150
  const rootSep = config.themeClassNameOnRoot ? "" : " ";
99
- cssRules.push(`${selectors.map((x) => `:root${rootSep}${x}`).join(", ")} {${vars}}`);
100
- if ((_c = config.shouldAddPrefersColorThemes) != null ? _c : true) {
101
- if (isDarkOrLightBase) {
102
- cssRules.push(`@media(prefers-color-scheme: ${isDark ? "dark" : "light"}) {
103
- body { background:${theme.background}; color: ${theme.color} }
104
- :root {${vars} }
105
- }`);
106
- }
151
+ const css2 = `${selectors.map((x) => `:root${rootSep}${x}`).join(", ")} {${vars}}`;
152
+ cssRules.push(css2);
153
+ if (config.shouldAddPrefersColorThemes && isDarkOrLightBase) {
154
+ const isDark = themeName.startsWith("dark");
155
+ cssRules.push(`@media(prefers-color-scheme: ${isDark ? "dark" : "light"}) {
156
+ body { background:${theme.background}; color: ${theme.color} }
157
+ :root {${vars} }
158
+ }`);
107
159
  }
108
160
  }
109
161
  }
110
- varsByValue.clear();
162
+ for (const themeName in themes) {
163
+ const cur = [];
164
+ const parents = themeName.split("_").slice(0, -1).map((part) => {
165
+ cur.push(part);
166
+ return cur.join("_");
167
+ });
168
+ if (!parents.length)
169
+ continue;
170
+ themes[themeName] = new Proxy(themes[themeName], {
171
+ get(target, key) {
172
+ if (Reflect.has(target, key)) {
173
+ return Reflect.get(target, key);
174
+ }
175
+ for (let i = parents.length - 1; i >= 0; i--) {
176
+ const parent = themes[parents[i]];
177
+ if (!parent) {
178
+ continue;
179
+ }
180
+ if (Reflect.has(parent, key)) {
181
+ return Reflect.get(parent, key);
182
+ }
183
+ }
184
+ }
185
+ });
186
+ }
187
+ tokensValueToVariable.clear();
111
188
  Object.freeze(cssRules);
112
189
  const css = cssRules.join("\n");
113
190
  return {
191
+ themes,
114
192
  cssRules,
115
193
  css
116
194
  };
117
195
  })();
118
196
  const tokensParsed = parseTokens(config.tokens);
119
- const fontsParsed = (() => {
120
- if (!config.fonts) {
121
- throw new Error(`No fonts defined!`);
122
- }
123
- const res = {};
124
- for (const familyName in config.fonts) {
125
- const family = config.fonts[familyName];
126
- const parsed = {};
127
- for (const attrKey in family) {
128
- const attr = family[attrKey];
129
- if (attrKey === "family") {
130
- parsed[attrKey] = attr;
131
- continue;
132
- }
133
- parsed[attrKey] = Object.keys(attr).reduce((acc, cur) => {
134
- acc[`$${cur}`] = attr[cur];
135
- return acc;
136
- }, {});
137
- }
138
- res[`$${familyName}`] = parsed;
139
- }
140
- return res;
141
- })();
142
- const getCSS = /* @__PURE__ */ __name(() => {
197
+ const getCSS = () => {
143
198
  return `${themeConfig.css}
144
199
  ${getInsertedRules().join("\n")}`;
145
- }, "getCSS");
146
- const next = {
200
+ };
201
+ if (config.shorthands) {
202
+ for (const key in config.shorthands) {
203
+ reversedShorthands[config.shorthands[key]] = key;
204
+ }
205
+ }
206
+ const next = __spreadProps(__spreadValues({
207
+ defaultTheme: "light",
147
208
  fonts: {},
148
209
  animations: {},
149
210
  shorthands: {},
150
- media: {},
151
- ...config,
152
- Provider: createTamaguiProvider({
153
- getCSS,
154
- defaultTheme: "light",
155
- ...config
156
- }),
211
+ media: {}
212
+ }, config), {
213
+ themes: themeConfig.themes,
157
214
  fontsParsed,
158
215
  themeConfig,
159
216
  tokensParsed,
160
217
  parsed: true,
161
- getCSS
162
- };
218
+ getCSS,
219
+ Provider: null
220
+ });
221
+ next.Provider = createTamaguiProvider(next);
163
222
  setConfig(next);
164
223
  if (configListeners.size) {
165
224
  configListeners.forEach((cb) => cb(next));
166
225
  configListeners.clear();
167
226
  }
168
227
  createdConfigs.set(next, true);
228
+ if (process.env.NODE_ENV === "development") {
229
+ if (!globalThis["Tamagui"]) {
230
+ globalThis["Tamagui"] = Tamagui;
231
+ }
232
+ }
169
233
  return next;
170
234
  }
171
- __name(createTamagui, "createTamagui");
172
- const parseTokens = /* @__PURE__ */ __name((tokens) => {
235
+ const reversedShorthands = {};
236
+ const parseTokens = (tokens) => {
173
237
  const res = {};
174
238
  for (const key in tokens) {
175
239
  res[key] = {};
@@ -178,25 +242,28 @@ const parseTokens = /* @__PURE__ */ __name((tokens) => {
178
242
  }
179
243
  }
180
244
  return res;
181
- }, "parseTokens");
245
+ };
182
246
  function ensureThemeVariable(theme, key) {
183
247
  const val = theme[key];
248
+ const themeKey = key;
184
249
  if (!isVariable(val)) {
185
250
  theme[key] = createVariable({
186
- name: key,
251
+ key: themeKey,
252
+ name: themeKey,
187
253
  val
188
254
  });
189
255
  } else {
190
- if (val.name !== key) {
256
+ if (val.name !== themeKey) {
191
257
  theme[key] = createVariable({
192
- name: key,
258
+ key: val.name,
259
+ name: themeKey,
193
260
  val: val.val
194
261
  });
195
262
  }
196
263
  }
197
264
  }
198
- __name(ensureThemeVariable, "ensureThemeVariable");
199
265
  export {
200
- createTamagui
266
+ createTamagui,
267
+ reversedShorthands
201
268
  };
202
269
  //# sourceMappingURL=createTamagui.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/createTamagui.ts"],
4
- "sourcesContent": ["import { configListeners, getHasConfigured, setConfig } from './conf'\nimport { THEME_CLASSNAME_PREFIX } from './constants/constants'\nimport { isWeb } from './constants/platform'\nimport { Variable, createCSSVariable, createVariable, isVariable } from './createVariable'\nimport { createTamaguiProvider } from './helpers/createTamaguiProvider'\nimport { getInsertedRules } from './helpers/insertStyleRule'\nimport { configureMedia } from './hooks/useMedia'\nimport {\n AnimationDriver,\n CreateTamaguiConfig,\n GenericTamaguiConfig,\n MediaQueryKey,\n TamaguiInternalConfig,\n} from './types'\n\nexport type CreateTamaguiProps =\n // user then re-defines the types after createTamagui returns the typed object they want\n Partial<Omit<GenericTamaguiConfig, 'themes' | 'tokens' | 'animations'>> & {\n animations?: AnimationDriver<any>\n tokens: GenericTamaguiConfig['tokens']\n themes: {\n [key: string]: {\n [key: string]: string | number | Variable\n }\n }\n\n // for the first render, determines which media queries are true\n // useful for SSR\n mediaQueryDefaultActive?: MediaQueryKey[]\n\n // what's between each CSS style rule, set to \"\\n\" to be easier to read\n // defaults: \"\\n\" when NODE_ENV=development, \"\" otherwise\n cssStyleSeparator?: string\n\n // (Advanced)\n // on the web, tamagui treats `dark` and `light` themes as special and\n // generates extra CSS to avoid having to re-render the entire page.\n // this CSS relies on specificity hacks that multiply by your sub-themes.\n // this sets the maxiumum number of nested dark/light themes you can do\n // defaults to 3 for a balance, but can be higher if you nest them deeply.\n maxDarkLightNesting?: number\n\n // adds @media(prefers-color-scheme) media queries for dark/light\n shouldAddPrefersColorThemes?: boolean\n\n // only if you put the theme classname on the html element we have to generate diff\n themeClassNameOnRoot?: boolean\n }\n\n// config is re-run by the @tamagui/static, dont double validate\nconst createdConfigs = new WeakMap<any, boolean>()\n\nexport function createTamagui<Conf extends CreateTamaguiProps>(\n config: Conf\n): Conf extends Partial<CreateTamaguiConfig<infer A, infer B, infer C, infer D, infer E, infer F>>\n ? TamaguiInternalConfig<A, B, C, D, E, F>\n : unknown {\n if (createdConfigs.has(config)) {\n return config as any\n }\n\n if (process.env.NODE_ENV === 'development') {\n if (!config.tokens) {\n throw new Error(`No tokens provided to Tamagui config`)\n }\n if (!config.themes) {\n throw new Error(`No themes provided to Tamagui config`)\n }\n }\n\n // test env loads a few times as it runs diff tests\n if (getHasConfigured()) {\n console.warn('Called createTamagui twice! Should never do so')\n // throw new Error(`#000 createTamagui called twice`)\n }\n\n configureMedia({\n queries: config.media as any,\n defaultActive: config.mediaQueryDefaultActive,\n })\n\n const themeConfig = (() => {\n let cssRules: string[] = []\n const varsByValue = new Map<string, Variable>()\n\n if (isWeb) {\n // tokens\n const tokenRules = new Set<string>()\n\n const addVar = (v: Variable) => {\n varsByValue[v.val] = v\n const rule = `--${createCSSVariable(v.name, false)}:${\n typeof v.val === 'number' ? `${v.val}px` : v.val\n }`\n tokenRules.add(rule)\n }\n\n for (const key in config.tokens) {\n for (const skey in config.tokens[key]) {\n const val = config.tokens[key][skey]\n if (key === 'font') {\n for (const fkey in val) {\n if (fkey === 'family') {\n addVar(val[fkey])\n } else {\n for (const fskey in val[fkey]) {\n addVar(val[fkey][fskey])\n }\n }\n }\n } else {\n addVar(val)\n }\n }\n }\n const sep = process.env.NODE_ENV === 'development' ? config.cssStyleSeparator || ' ' : ''\n cssRules.push(`:root {${sep}${[...tokenRules].join(`;${sep}`)}${sep}}`)\n }\n\n // special case for SSR\n const hasDarkLight = 'light' in config.themes && 'dark' in config.themes\n const CNP = `.${THEME_CLASSNAME_PREFIX}`\n\n // themes\n for (const themeName in config.themes) {\n // to allow using the same theme with diff names, be sure we don't mutate!\n const theme = { ...config.themes[themeName] }\n config.themes[themeName] = theme\n let vars = ''\n\n for (const themeKey in theme) {\n if (isWeb) {\n const val = theme[themeKey]\n // TODO sanity check is necessary\n const varName = val instanceof Variable ? val.name : varsByValue[val]?.name\n vars += `--${themeKey}:${varName ? createCSSVariable(varName) : `${val}`};`\n }\n // make sure properly names theme variables\n ensureThemeVariable(theme, themeKey)\n }\n\n if (isWeb) {\n const isDarkOrLightBase = themeName === 'dark' || themeName === 'light'\n const isDark = themeName.startsWith('dark')\n const selector = `${CNP}${themeName}`\n const selectors = [selector]\n\n // since we dont specify dark/light in classnames we have to do an awkward specificity war\n // use config.maxDarkLightNesting to determine how deep you can nest until it breaks\n if (hasDarkLight) {\n const childSelector = `${CNP}${themeName.replace('dark_', '').replace('light_', '')}`\n const order = isDark ? ['dark', 'light'] : ['light', 'dark']\n if (isDarkOrLightBase) {\n order.reverse()\n }\n const [stronger, weaker] = order\n const max = config.maxDarkLightNesting ?? 3\n new Array(max * 2).fill(undefined).forEach((_, pi) => {\n if (pi % 2 === 1) return\n const parents = new Array(pi + 1).fill(undefined).map((_, psi) => {\n return `${CNP}${psi % 2 === 0 ? stronger : weaker}`\n })\n selectors.push(\n `${(parents.length > 1 ? parents.slice(1) : parents).join(' ')} ${childSelector}`\n )\n })\n }\n\n const rootSep = config.themeClassNameOnRoot ? '' : ' '\n cssRules.push(`${selectors.map((x) => `:root${rootSep}${x}`).join(', ')} {${vars}}`)\n\n if (config.shouldAddPrefersColorThemes ?? true) {\n // add media prefers for dark/light base\n if (isDarkOrLightBase) {\n cssRules.push(\n `@media(prefers-color-scheme: ${isDark ? 'dark' : 'light'}) {\n body { background:${theme.background}; color: ${theme.color} }\n :root {${vars} } \n }`\n )\n }\n }\n }\n }\n\n varsByValue.clear()\n Object.freeze(cssRules)\n const css = cssRules.join('\\n')\n\n return {\n cssRules,\n css,\n }\n })()\n\n // faster lookups token keys become $keys to match input\n const tokensParsed: any = parseTokens(config.tokens)\n\n const fontsParsed = (() => {\n if (!config.fonts) {\n throw new Error(`No fonts defined!`)\n }\n const res = {} as typeof config.fonts\n for (const familyName in config.fonts) {\n const family = config.fonts[familyName]\n const parsed = {}\n for (const attrKey in family) {\n const attr = family[attrKey]\n if (attrKey === 'family') {\n parsed[attrKey] = attr\n continue\n }\n parsed[attrKey] = Object.keys(attr).reduce((acc, cur) => {\n acc[`$${cur}`] = attr[cur]\n return acc\n }, {})\n }\n res[`$${familyName}`] = parsed as any\n }\n return res!\n })()\n\n const getCSS = () => {\n return `${themeConfig.css}\\n${getInsertedRules().join('\\n')}`\n }\n\n const next: TamaguiInternalConfig = {\n fonts: {},\n animations: {} as any,\n shorthands: {},\n media: {},\n ...config,\n Provider: createTamaguiProvider({\n getCSS,\n defaultTheme: 'light',\n ...config,\n }),\n fontsParsed,\n themeConfig,\n tokensParsed,\n parsed: true,\n getCSS,\n }\n\n setConfig(next)\n\n if (configListeners.size) {\n configListeners.forEach((cb) => cb(next))\n configListeners.clear()\n }\n\n createdConfigs.set(next, true)\n\n // @ts-expect-error\n return next\n}\n\nconst parseTokens = (tokens: any) => {\n const res: any = {}\n for (const key in tokens) {\n res[key] = {}\n for (const skey in tokens[key]) {\n res[key][`$${skey}`] = tokens[key][skey]\n }\n }\n return res\n}\n\n// mutates, freeze after\n// shared by createTamagui so extracted here\nfunction ensureThemeVariable(theme: any, key: string) {\n const val = theme[key]\n if (!isVariable(val)) {\n theme[key] = createVariable({\n name: key,\n val,\n })\n } else {\n if (val.name !== key) {\n // rename to theme name\n theme[key] = createVariable({\n name: key,\n val: val.val,\n })\n }\n }\n}\n\n// for quick testing types:\n// const x = createTamagui({\n// shorthands: {},\n// media: {},\n// themes: {},\n// tokens: {\n// font: {},\n// color: {},\n// radius: {},\n// size: {},\n// space: {},\n// zIndex: {},\n// },\n// })\n"],
5
- "mappings": ";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AA4CA,MAAM,iBAAiB,oBAAI,QAAsB;AAE1C,uBACL,QAGU;AACV,MAAI,eAAe,IAAI,MAAM,GAAG;AAC9B,WAAO;AAAA,EACT;AAEA,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,CAAC,OAAO,QAAQ;AAClB,YAAM,IAAI,MAAM,sCAAsC;AAAA,IACxD;AACA,QAAI,CAAC,OAAO,QAAQ;AAClB,YAAM,IAAI,MAAM,sCAAsC;AAAA,IACxD;AAAA,EACF;AAGA,MAAI,iBAAiB,GAAG;AACtB,YAAQ,KAAK,gDAAgD;AAAA,EAE/D;AAEA,iBAAe;AAAA,IACb,SAAS,OAAO;AAAA,IAChB,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AI,gBAAgB,MAAM;AACxB,oBAAgB,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC;AACxC,oBAAgB,MAAM;AAAA,EACxB;AAEA,iBAAe,IAAI,MAAM,IAAI;AAG7B,SAAO;AACT;AA3MgB;AA6MhB,MAAM,cAAc,wBAAC,WAAgB;AACnC,QAAM,MAAW,CAAC;AAClB,aAAW,OAAO,QAAQ;AACxB,QAAI,OAAO,CAAC;AACZ,eAAW,QAAQ,OAAO,MAAM;AAC9B,UAAI,KAAK,IAAI,UAAU,OAAO,KAAK;AAAA,IACrC;AAAA,EACF;AACA,SAAO;AACT,GAToB;AAapB,6BAA6B,OAAY,KAAa;AACpD,QAAM,MAAM,MAAM;AAClB,MAAI,CAAC,WAAW,GAAG,GAAG;AACpB,UAAM,OAAO,eAAe;AAAA,MAC1B,MAAM;AAAA,MACN;AAAA,IACF,CAAC;AAAA,EACH,OAAO;AACL,QAAI,IAAI,SAAS,KAAK;AAEpB,YAAM,OAAO,eAAe;AAAA,QAC1B,MAAM;AAAA,QACN,KAAK,IAAI;AAAA,MACX,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAhBS;",
4
+ "sourcesContent": ["import { configListeners, getHasConfigured, setConfig } from './conf'\nimport { THEME_CLASSNAME_PREFIX } from './constants/constants'\nimport { isWeb } from './constants/platform'\nimport { SpacerProps } from './createComponent'\nimport { Variable, createVariable, isVariable } from './createVariable'\nimport { createVariables } from './createVariables'\nimport { createTamaguiProvider } from './helpers/createTamaguiProvider'\nimport { getInsertedRules } from './helpers/insertStyleRule'\nimport {\n registerCSSVariable,\n tokenRules,\n tokensValueToVariable,\n} from './helpers/registerCSSVariable'\nimport { configureMedia } from './hooks/useMedia'\nimport { parseFont, registerFontVariables } from './insertFont'\nimport { Tamagui } from './Tamagui'\nimport {\n AnimationDriver,\n CreateTamaguiConfig,\n GenericTamaguiConfig,\n MediaQueryKey,\n StackProps,\n TamaguiInternalConfig,\n TextProps,\n ThemeObject,\n} from './types'\n\nexport type CreateTamaguiProps =\n // user then re-defines the types after createTamagui returns the typed object they want\n Partial<Omit<GenericTamaguiConfig, 'themes' | 'tokens' | 'animations'>> & {\n animations?: AnimationDriver<any>\n tokens: GenericTamaguiConfig['tokens']\n themes: {\n [key: string]: {\n [key: string]: string | number | Variable\n }\n }\n\n defaultProps?: Record<string, any> & {\n Stack?: StackProps\n Text?: TextProps\n Spacer?: SpacerProps\n }\n\n // for the first render, determines which media queries are true\n // useful for SSR\n mediaQueryDefaultActive?: MediaQueryKey[]\n\n // what's between each CSS style rule, set to \"\\n\" to be easier to read\n // defaults: \"\\n\" when NODE_ENV=development, \"\" otherwise\n cssStyleSeparator?: string\n\n // (Advanced)\n // on the web, tamagui treats `dark` and `light` themes as special and\n // generates extra CSS to avoid having to re-render the entire page.\n // this CSS relies on specificity hacks that multiply by your sub-themes.\n // this sets the maxiumum number of nested dark/light themes you can do\n // defaults to 3 for a balance, but can be higher if you nest them deeply.\n maxDarkLightNesting?: number\n\n // adds @media(prefers-color-scheme) media queries for dark/light\n shouldAddPrefersColorThemes?: boolean\n\n // only if you put the theme classname on the html element we have to generate diff\n themeClassNameOnRoot?: boolean\n }\n\n// config is re-run by the @tamagui/static, dont double validate\nconst createdConfigs = new WeakMap<any, boolean>()\n\nexport type InferTamaguiConfig<Conf extends CreateTamaguiProps> = Conf extends Partial<\n CreateTamaguiConfig<infer A, infer B, infer C, infer D, infer E, infer F>\n>\n ? TamaguiInternalConfig<A, B, C, D, E, F>\n : unknown\n\nexport function createTamagui<Conf extends CreateTamaguiProps>(\n config: Conf\n): InferTamaguiConfig<Conf> {\n if (createdConfigs.has(config)) {\n return config as any\n }\n\n if (process.env.NODE_ENV === 'development') {\n if (!config.tokens) {\n throw new Error(`No tokens provided to Tamagui config`)\n }\n if (!config.themes) {\n throw new Error(`No themes provided to Tamagui config`)\n }\n if (!config.fonts) {\n throw new Error(`No fonts provided to Tamagui config`)\n }\n }\n\n // test env loads a few times as it runs diff tests\n if (getHasConfigured()) {\n console.warn(`Warning: createTamagui called twice (maybe HMR)`)\n }\n\n configureMedia({\n queries: config.media as any,\n defaultActive: config.mediaQueryDefaultActive,\n })\n\n const fontTokens = createVariables(config.fonts!)\n const fontsParsed = (() => {\n const res = {} as typeof fontTokens\n for (const familyName in fontTokens) {\n res[`$${familyName}`] = parseFont(fontTokens[familyName])\n }\n return res!\n })()\n\n const themeConfig = (() => {\n const themes = { ...config.themes }\n let cssRules: string[] = []\n\n if (isWeb) {\n for (const key in config.tokens) {\n for (const skey in config.tokens[key]) {\n const val = config.tokens[key][skey]\n registerCSSVariable(val)\n }\n }\n\n for (const key in fontsParsed) {\n const fontParsed = fontsParsed[key]\n registerFontVariables(fontParsed)\n }\n\n const sep = process.env.NODE_ENV === 'development' ? config.cssStyleSeparator || ' ' : ''\n cssRules.push(`:root {${sep}${[...tokenRules].join(`;${sep}`)}${sep}}`)\n }\n\n // special case for SSR\n const hasDarkLight = 'light' in config.themes && 'dark' in config.themes\n const CNP = `.${THEME_CLASSNAME_PREFIX}`\n\n // dedupe themes to avoid duplicate CSS generation\n type DedupedTheme = {\n names: string[]\n theme: ThemeObject\n }\n const dedupedThemes: {\n [key: string]: DedupedTheme\n } = {}\n const existing = new WeakMap<ThemeObject, DedupedTheme>()\n\n // first, de-dupe and parse them\n for (const themeName in themes) {\n const rawTheme = themes[themeName]\n\n // if existing, avoid\n if (existing.has(rawTheme)) {\n const e = existing.get(rawTheme)!\n themes[themeName] = e.theme\n e.names.push(themeName)\n continue\n }\n\n // parse into variables\n const theme = { ...config.themes[themeName] }\n for (const key in theme) {\n // make sure properly names theme variables\n ensureThemeVariable(theme, key)\n }\n themes[themeName] = theme\n\n // set deduped\n dedupedThemes[themeName] = {\n names: [themeName],\n theme,\n }\n existing.set(config.themes[themeName], dedupedThemes[themeName])\n }\n\n // then, generate from de-duped\n if (isWeb) {\n for (const themeName in dedupedThemes) {\n const { theme, names } = dedupedThemes[themeName]\n let vars = ''\n\n for (const themeKey in theme) {\n const variable = theme[themeKey] as Variable\n let value: any = null\n if (variable.isFloating || !tokensValueToVariable.has(variable.val)) {\n value = variable.val\n } else {\n value = tokensValueToVariable.get(variable.val)!.variable\n }\n vars += `--${themeKey}:${value};`\n }\n\n const isDarkOrLightBase = themeName === 'dark' || themeName === 'light'\n const selectors = names.map((name) => {\n return `${CNP}${name}`\n })\n\n // since we dont specify dark/light in classnames we have to do an awkward specificity war\n // use config.maxDarkLightNesting to determine how deep you can nest until it breaks\n if (hasDarkLight) {\n for (const subName of names) {\n const isDark = isDarkOrLightBase || subName.startsWith('dark_')\n const childSelector = `${CNP}${subName.replace(isDark ? 'dark_' : 'light_', '')}`\n const order = isDark ? ['dark', 'light'] : ['light', 'dark']\n if (isDarkOrLightBase) {\n order.reverse()\n }\n const [stronger, weaker] = order\n const max = config.maxDarkLightNesting ?? 3\n\n new Array(Math.round(max * 1.5)).fill(undefined).forEach((_, pi) => {\n const isOdd = pi % 2 === 1\n if (isOdd && pi < 3) return\n const parents = new Array(pi + 1).fill(undefined).map((_, psi) => {\n return `${CNP}${psi % 2 === 0 ? stronger : weaker}`\n })\n let parentSelectors = parents.length > 1 ? parents.slice(1) : parents\n if (isOdd) {\n const [_first, second, ...rest] = parentSelectors\n parentSelectors = [second, ...rest, second]\n }\n selectors.push(`${parentSelectors.join(' ')} ${childSelector}`)\n })\n }\n }\n\n const rootSep = config.themeClassNameOnRoot ? '' : ' '\n const css = `${selectors.map((x) => `:root${rootSep}${x}`).join(', ')} {${vars}}`\n cssRules.push(css)\n\n if (config.shouldAddPrefersColorThemes && isDarkOrLightBase) {\n // add media prefers for dark/light base\n const isDark = themeName.startsWith('dark')\n cssRules.push(\n `@media(prefers-color-scheme: ${isDark ? 'dark' : 'light'}) {\n body { background:${theme.background}; color: ${theme.color} }\n :root {${vars} } \n }`\n )\n }\n }\n }\n\n // proxy upwards to get parent variables (themes are subset going down)\n for (const themeName in themes) {\n // we could test if this is better as just a straight object spread or fancier proxy\n const cur: string[] = []\n // if theme is dark_blue_alt1_Button\n // this will be the parent names in order: ['dark', 'dark_blue', 'dark_blue_alt1\"]\n const parents = themeName\n .split('_')\n .slice(0, -1)\n .map((part) => {\n cur.push(part)\n return cur.join('_')\n })\n\n if (!parents.length) continue\n\n themes[themeName] = new Proxy(themes[themeName], {\n get(target, key) {\n if (Reflect.has(target, key)) {\n return Reflect.get(target, key)\n }\n // check parents\n for (let i = parents.length - 1; i >= 0; i--) {\n const parent = themes[parents[i]]\n if (!parent) {\n continue\n }\n if (Reflect.has(parent, key)) {\n return Reflect.get(parent, key)\n }\n }\n },\n })\n }\n\n tokensValueToVariable.clear()\n Object.freeze(cssRules)\n const css = cssRules.join('\\n')\n\n return {\n themes,\n cssRules,\n css,\n }\n })()\n\n // faster lookups token keys become $keys to match input\n const tokensParsed: any = parseTokens(config.tokens)\n\n const getCSS = () => {\n return `${themeConfig.css}\\n${getInsertedRules().join('\\n')}`\n }\n\n if (config.shorthands) {\n for (const key in config.shorthands) {\n reversedShorthands[config.shorthands[key]] = key\n }\n }\n\n const next: TamaguiInternalConfig = {\n defaultTheme: 'light',\n fonts: {},\n animations: {} as any,\n shorthands: {},\n media: {},\n ...config,\n themes: themeConfig.themes,\n fontsParsed,\n themeConfig,\n tokensParsed,\n parsed: true,\n getCSS,\n Provider: null as any,\n }\n\n next.Provider = createTamaguiProvider(next)\n\n setConfig(next)\n\n if (configListeners.size) {\n configListeners.forEach((cb) => cb(next))\n configListeners.clear()\n }\n\n createdConfigs.set(next, true)\n\n if (process.env.NODE_ENV === 'development') {\n if (!globalThis['Tamagui']) {\n globalThis['Tamagui'] = Tamagui\n }\n }\n\n // @ts-expect-error\n return next\n}\n\nexport const reversedShorthands: Record<string, string> = {}\n\nconst parseTokens = (tokens: any) => {\n const res: any = {}\n for (const key in tokens) {\n res[key] = {}\n for (const skey in tokens[key]) {\n res[key][`$${skey}`] = tokens[key][skey]\n }\n }\n return res\n}\n\n// mutates, freeze after\n// shared by createTamagui so extracted here\nfunction ensureThemeVariable(theme: any, key: string) {\n const val = theme[key]\n const themeKey = key\n if (!isVariable(val)) {\n theme[key] = createVariable({\n key: themeKey,\n name: themeKey,\n val,\n })\n } else {\n if (val.name !== themeKey) {\n // rename to theme name\n theme[key] = createVariable({\n key: val.name,\n name: themeKey,\n val: val.val,\n })\n }\n }\n}\n\n// for quick testing types:\n// const x = createTamagui({\n// shorthands: {},\n// media: {},\n// themes: {},\n// tokens: {\n// font: {},\n// color: {},\n// radius: {},\n// size: {},\n// space: {},\n// zIndex: {},\n// },\n// })\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAKA;AACA;AACA;AAqDA,MAAM,iBAAiB,oBAAI,QAAsB;AAQ1C,uBACL,QAC0B;AAC1B,MAAI,eAAe,IAAI,MAAM,GAAG;AAC9B,WAAO;AAAA,EACT;AAEA,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,CAAC,OAAO,QAAQ;AAClB,YAAM,IAAI,MAAM,sCAAsC;AAAA,IACxD;AACA,QAAI,CAAC,OAAO,QAAQ;AAClB,YAAM,IAAI,MAAM,sCAAsC;AAAA,IACxD;AACA,QAAI,CAAC,OAAO,OAAO;AACjB,YAAM,IAAI,MAAM,qCAAqC;AAAA,IACvD;AAAA,EACF;AAGA,MAAI,iBAAiB,GAAG;AACtB,YAAQ,KAAK,iDAAiD;AAAA,EAChE;AAEA,iBAAe;AAAA,IACb,SAAS,OAAO;AAAA,IAChB,eAAe,OAAO;AAAA,EACxB,CAAC;AAED,QAAM,aAAa,gBAAgB,OAAO,KAAM;AAChD,QAAM,cAAe,OAAM;AACzB,UAAM,MAAM,CAAC;AACb,eAAW,cAAc,YAAY;AACnC,UAAI,IAAI,gBAAgB,UAAU,WAAW,WAAW;AAAA,IAC1D;AACA,WAAO;AAAA,EACT,GAAG;AAEH,QAAM,cAAe,OAAM;AACzB,UAAM,SAAS,mBAAK,OAAO;AA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;AAAA,MACN;AAAA,IACF,CAAC;AAAA,EACH,OAAO;AACL,QAAI,IAAI,SAAS,UAAU;AAEzB,YAAM,OAAO,eAAe;AAAA,QAC1B,KAAK,IAAI;AAAA,QACT,MAAM;AAAA,QACN,KAAK,IAAI;AAAA,MACX,CAAC;AAAA,IACH;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,6 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- const createTheme = /* @__PURE__ */ __name((theme) => theme, "createTheme");
1
+ const createTheme = (theme) => {
2
+ return theme;
3
+ };
4
4
  export {
5
5
  createTheme
6
6
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/createTheme.ts"],
4
- "sourcesContent": ["import { Variable } from './createVariable'\n\ntype GenericTheme = { [key: string]: string | Variable }\n\nexport const createTheme = <Theme extends GenericTheme>(\n theme: Theme\n): {\n [K in keyof Theme]: Theme[K] | string | Variable\n} => theme\n"],
5
- "mappings": ";;AAIO,MAAM,cAAc,wBACzB,UAGG,OAJsB;",
4
+ "sourcesContent": ["import { Variable } from './createVariable'\n\ntype GenericTheme = { [key: string]: string | Variable }\n\nexport const createTheme = <Theme extends GenericTheme>(\n theme: Theme\n): {\n [K in keyof Theme]: Theme[K] | string | Variable\n} => {\n return theme\n}\n"],
5
+ "mappings": "AAIO,MAAM,cAAc,CACzB,UAGG;AACH,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -1,29 +1,12 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { createVariable } from "./createVariable";
1
+ import { createVariables } from "./createVariables";
4
2
  import { validateTokens } from "./helpers/validate";
5
3
  function createTokens(tokens) {
6
4
  if (process.env.NODE_ENV === "development") {
7
5
  validateTokens(tokens);
8
6
  }
9
- return mapTokensToVariables(tokens);
7
+ return createVariables(tokens);
10
8
  }
11
- __name(createTokens, "createTokens");
12
- const mapTokensToVariables = /* @__PURE__ */ __name((tokens, parentPath = "") => {
13
- const res = {};
14
- for (const key in tokens) {
15
- let val = tokens[key];
16
- const name = parentPath ? `${parentPath}-${key}` : key;
17
- if (val && typeof val === "object") {
18
- res[key] = mapTokensToVariables(tokens[key], name);
19
- } else {
20
- res[key] = createVariable({ val, name });
21
- }
22
- }
23
- return res;
24
- }, "mapTokensToVariables");
25
9
  export {
26
- createTokens,
27
- mapTokensToVariables
10
+ createTokens
28
11
  };
29
12
  //# sourceMappingURL=createTokens.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/createTokens.ts"],
4
- "sourcesContent": ["import { Variable, createVariable } from './createVariable'\nimport { validateTokens } from './helpers/validate'\nimport { CreateTokens } from './types'\n\n// tokens.color.dark.red ===> { var: `color-dark-red`, val: '' }\n\nexport function createTokens<T extends CreateTokens>(tokens: T): MakeTokens<T> {\n if (process.env.NODE_ENV === 'development') {\n validateTokens(tokens)\n }\n return mapTokensToVariables(tokens) as any\n}\n\nexport const mapTokensToVariables = (\n tokens: CreateTokens,\n parentPath = ''\n): CreateTokens<Variable> => {\n const res = {}\n for (const key in tokens) {\n let val = tokens[key]\n const name = parentPath ? `${parentPath}-${key}` : key\n if (val && typeof val === 'object') {\n res[key] = mapTokensToVariables(tokens[key], name)\n } else {\n res[key] = createVariable({ val, name })\n }\n }\n // @ts-expect-error\n return res\n}\n\n// verbose but gives us nice types...\ntype MakeTokens<T> = T extends {\n color: infer E\n space: infer F\n size: infer G\n radius: infer H\n zIndex: infer J\n}\n ? {\n color: {\n [key in keyof E]: Variable\n }\n space: {\n [key in keyof F]: Variable\n }\n size: {\n [key in keyof G]: Variable\n }\n radius: {\n [key in keyof H]: Variable\n }\n zIndex: {\n [key in keyof J]: Variable\n }\n }\n : never\n"],
5
- "mappings": ";;AAAA;AACA;AAKO,sBAA8C,QAA0B;AAC7E,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,mBAAe,MAAM;AAAA,EACvB;AACA,SAAO,qBAAqB,MAAM;AACpC;AALgB;AAOT,MAAM,uBAAuB,wBAClC,QACA,aAAa,OACc;AAC3B,QAAM,MAAM,CAAC;AACb,aAAW,OAAO,QAAQ;AACxB,QAAI,MAAM,OAAO;AACjB,UAAM,OAAO,aAAa,GAAG,cAAc,QAAQ;AACnD,QAAI,OAAO,OAAO,QAAQ,UAAU;AAClC,UAAI,OAAO,qBAAqB,OAAO,MAAM,IAAI;AAAA,IACnD,OAAO;AACL,UAAI,OAAO,eAAe,EAAE,KAAK,KAAK,CAAC;AAAA,IACzC;AAAA,EACF;AAEA,SAAO;AACT,GAhBoC;",
4
+ "sourcesContent": ["import { Variable } from './createVariable'\nimport { createVariables } from './createVariables'\nimport { validateTokens } from './helpers/validate'\nimport { CreateTokens } from './types'\n\n// tokens.color.dark.red ===> { var: `color-dark-red`, val: '' }\nexport function createTokens<T extends CreateTokens>(tokens: T): MakeTokens<T> {\n if (process.env.NODE_ENV === 'development') {\n validateTokens(tokens)\n }\n return createVariables(tokens as any) as any\n}\n\n// verbose but gives us nice types...\ntype MakeTokens<T> = T extends {\n color: infer E\n space: infer F\n size: infer G\n radius: infer H\n zIndex: infer J\n}\n ? {\n color: {\n [key in keyof E]: Variable\n }\n space: {\n [key in keyof F]: Variable\n }\n size: {\n [key in keyof G]: Variable\n }\n radius: {\n [key in keyof H]: Variable\n }\n zIndex: {\n [key in keyof J]: Variable\n }\n }\n : never\n"],
5
+ "mappings": "AACA;AACA;AAIO,sBAA8C,QAA0B;AAC7E,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,mBAAe,MAAM;AAAA,EACvB;AACA,SAAO,gBAAgB,MAAa;AACtC;",
6
6
  "names": []
7
7
  }
@@ -1,49 +1,73 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
1
  var _a;
4
2
  import { isWeb } from "./constants/platform";
5
3
  const IS_VARIABLE_SYMBOL = "__isVariable__";
6
4
  class Variable {
7
- constructor({ val, name }) {
5
+ constructor(props) {
8
6
  this[_a] = true;
7
+ this.isFloating = false;
8
+ const { val, name, key, isFloating } = props;
9
9
  this.val = isVariable(val) ? val.val : val;
10
10
  this.name = name;
11
- this.variable = isWeb ? createCSSVariable(name) : this.val;
11
+ this.key = key;
12
+ this.variable = isWeb ? createCSSVariable(name) : "";
13
+ if (isFloating) {
14
+ this.isFloating = true;
15
+ }
12
16
  }
13
17
  toString() {
14
18
  return `${isWeb ? this.variable : this.val}`;
15
19
  }
16
20
  }
17
- __name(Variable, "Variable");
18
21
  _a = IS_VARIABLE_SYMBOL;
19
- const createVariable = /* @__PURE__ */ __name((props) => new Variable(props), "createVariable");
22
+ const createVariable = (props) => {
23
+ if (isVariable(props)) {
24
+ return props;
25
+ }
26
+ return new Variable(props);
27
+ };
20
28
  function isVariable(v) {
21
- return v instanceof Variable || v && v[IS_VARIABLE_SYMBOL];
29
+ return !!(v instanceof Variable || v && v[IS_VARIABLE_SYMBOL]);
22
30
  }
23
- __name(isVariable, "isVariable");
24
31
  function getVariableValue(v) {
25
32
  if (isVariable(v))
26
33
  return v.val;
27
34
  return v;
28
35
  }
29
- __name(getVariableValue, "getVariableValue");
30
36
  function getVariableName(v) {
31
37
  if (isVariable(v))
32
38
  return v.name;
33
39
  return v;
34
40
  }
35
- __name(getVariableName, "getVariableName");
36
- const createCSSVariable = /* @__PURE__ */ __name((val, includeVar = true) => {
37
- const name = val.replace(/[^a-z0-9\_\-]+/i, "_");
41
+ function getVariableVariable(v) {
42
+ if (isVariable(v))
43
+ return v.variable;
44
+ return v;
45
+ }
46
+ const createCSSVariable = (nameProp, includeVar = true) => {
47
+ if (process.env.NODE_ENV === "development") {
48
+ if (!nameProp || typeof nameProp !== "string") {
49
+ console.warn("invalid name", nameProp);
50
+ return ``;
51
+ }
52
+ }
53
+ let name = "";
54
+ for (let i = 0; i < nameProp.length; i++) {
55
+ const code = nameProp.charCodeAt(i);
56
+ if (code >= 65 && code <= 90 || code >= 97 && code <= 122 || code == 95 || code === 45 || code >= 48 && code <= 57) {
57
+ name += nameProp[i];
58
+ } else {
59
+ name += `-c${code}-`;
60
+ }
61
+ }
38
62
  return includeVar ? `var(--${name})` : name;
39
- }, "createCSSVariable");
63
+ };
40
64
  export {
41
- IS_VARIABLE_SYMBOL,
42
65
  Variable,
43
66
  createCSSVariable,
44
67
  createVariable,
45
68
  getVariableName,
46
69
  getVariableValue,
70
+ getVariableVariable,
47
71
  isVariable
48
72
  };
49
73
  //# sourceMappingURL=createVariable.js.map