@tamagui/core 1.0.0-beta.152 → 1.0.0-beta.17

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 (315) hide show
  1. package/README.md +1 -0
  2. package/dist/cjs/Tamagui.js +13 -1
  3. package/dist/cjs/Tamagui.js.map +2 -2
  4. package/dist/cjs/ThemeContext.js +4 -0
  5. package/dist/cjs/ThemeManager.js +30 -14
  6. package/dist/cjs/ThemeManager.js.map +2 -2
  7. package/dist/cjs/conf.js +10 -1
  8. package/dist/cjs/conf.js.map +2 -2
  9. package/dist/cjs/constants/constants.js +6 -0
  10. package/dist/cjs/constants/platform.js +15 -0
  11. package/dist/cjs/constants/platform.js.map +2 -2
  12. package/dist/cjs/constants/rnw.js +4 -0
  13. package/dist/cjs/contexts/ButtonInsideButtonContext.js +4 -0
  14. package/dist/cjs/createComponent.js +191 -113
  15. package/dist/cjs/createComponent.js.map +2 -2
  16. package/dist/cjs/createFont.js +4 -0
  17. package/dist/cjs/createShorthands.js +4 -0
  18. package/dist/cjs/createTamagui.js +48 -27
  19. package/dist/cjs/createTamagui.js.map +2 -2
  20. package/dist/cjs/createTheme.js +4 -0
  21. package/dist/cjs/createTokens.js +7 -6
  22. package/dist/cjs/createTokens.js.map +2 -2
  23. package/dist/cjs/createVariable.js +18 -2
  24. package/dist/cjs/createVariable.js.map +2 -2
  25. package/dist/cjs/helpers/RNComponents.js +4 -0
  26. package/dist/cjs/helpers/addStylesUsingClassname.js +8 -0
  27. package/dist/cjs/helpers/addStylesUsingClassname.js.map +2 -2
  28. package/dist/cjs/helpers/areEqualSets.js +4 -0
  29. package/dist/cjs/helpers/createMediaStyle.js +5 -2
  30. package/dist/cjs/helpers/createMediaStyle.js.map +2 -2
  31. package/dist/cjs/helpers/createPropMapper.js +53 -22
  32. package/dist/cjs/helpers/createPropMapper.js.map +2 -2
  33. package/dist/cjs/helpers/createShallowUpdate.js +4 -0
  34. package/dist/cjs/helpers/createTamaguiProvider.js +4 -0
  35. package/dist/cjs/helpers/extendStaticConfig.js +9 -6
  36. package/dist/cjs/helpers/extendStaticConfig.js.map +2 -2
  37. package/dist/cjs/helpers/fixNativeShadow.js +4 -0
  38. package/dist/cjs/helpers/fixNativeShadow.native.js +10 -9
  39. package/dist/cjs/helpers/fixNativeShadow.native.js.map +2 -2
  40. package/dist/cjs/helpers/getButtonSize.js +45 -0
  41. package/dist/cjs/helpers/getButtonSize.js.map +7 -0
  42. package/dist/cjs/helpers/getExpandedShorthands.js +4 -0
  43. package/dist/cjs/helpers/getSize.js +35 -0
  44. package/dist/cjs/helpers/getSize.js.map +7 -0
  45. package/dist/cjs/helpers/getSplitStyles.js +137 -55
  46. package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
  47. package/dist/cjs/helpers/getStylesAtomic.js +20 -3
  48. package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
  49. package/dist/cjs/helpers/getStylesAtomic.native.js +4 -0
  50. package/dist/cjs/helpers/getTextSize.js +56 -0
  51. package/dist/cjs/helpers/getTextSize.js.map +7 -0
  52. package/dist/cjs/helpers/insertStyleRule.js +42 -27
  53. package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
  54. package/dist/cjs/helpers/isObj.js +4 -0
  55. package/dist/cjs/helpers/isTamaguiElement.js +4 -0
  56. package/dist/cjs/helpers/matchMedia.js +4 -0
  57. package/dist/cjs/helpers/matchMedia.native.js +4 -0
  58. package/dist/cjs/{constants/pseudos.js → helpers/nativeGestureHandler.js} +11 -19
  59. package/dist/cjs/helpers/nativeGestureHandler.js.map +7 -0
  60. package/dist/cjs/helpers/nativeGestureHandler.native.js +18 -0
  61. package/dist/cjs/helpers/nativeGestureHandler.native.js.map +7 -0
  62. package/dist/cjs/helpers/proxyThemeVariables.js +40 -0
  63. package/dist/cjs/helpers/proxyThemeVariables.js.map +7 -0
  64. package/dist/cjs/helpers/themeable.js +7 -2
  65. package/dist/cjs/helpers/themeable.js.map +2 -2
  66. package/dist/cjs/helpers/validate.js +53 -11
  67. package/dist/cjs/helpers/validate.js.map +2 -2
  68. package/dist/cjs/helpers/withStaticProperties.js +4 -0
  69. package/dist/cjs/helpers/wrapThemeManagerContext.js +4 -0
  70. package/dist/cjs/hooks/useConstant.js +4 -0
  71. package/dist/cjs/hooks/useFeatures.js +4 -0
  72. package/dist/cjs/hooks/useId.js +59 -0
  73. package/dist/cjs/hooks/useId.js.map +7 -0
  74. package/dist/cjs/hooks/useIsMounted.js +4 -0
  75. package/dist/cjs/hooks/useIsTouchDevice.js +8 -4
  76. package/dist/cjs/hooks/useIsTouchDevice.js.map +2 -2
  77. package/dist/cjs/hooks/useMedia.js +14 -0
  78. package/dist/cjs/hooks/useMedia.js.map +2 -2
  79. package/dist/cjs/hooks/usePressable.js +4 -0
  80. package/dist/cjs/hooks/usePrevious.js +1 -0
  81. package/dist/cjs/{createShallowUpdate.js.map → hooks/usePrevious.js.map} +0 -0
  82. package/dist/cjs/hooks/useTheme.js +30 -16
  83. package/dist/cjs/hooks/useTheme.js.map +2 -2
  84. package/dist/cjs/hooks/useUnmountEffect.js +4 -0
  85. package/dist/cjs/index.js +24 -6
  86. package/dist/cjs/index.js.map +2 -2
  87. package/dist/cjs/nativeGestureHandler.native.js +18 -0
  88. package/dist/cjs/nativeGestureHandler.native.js.map +7 -0
  89. package/dist/cjs/static.js +3 -0
  90. package/dist/cjs/static.js.map +2 -2
  91. package/dist/cjs/styled.js +11 -5
  92. package/dist/cjs/styled.js.map +2 -2
  93. package/dist/cjs/types.js.map +1 -1
  94. package/dist/cjs/views/Slot.js +134 -0
  95. package/dist/cjs/views/Slot.js.map +7 -0
  96. package/dist/cjs/views/Stack.js +4 -0
  97. package/dist/cjs/views/Text.js +13 -14
  98. package/dist/cjs/views/Text.js.map +2 -2
  99. package/dist/cjs/views/TextAncestorContext.js +6 -0
  100. package/dist/cjs/views/Theme.js +7 -3
  101. package/dist/cjs/views/Theme.js.map +2 -2
  102. package/dist/cjs/views/ThemeInverse.js +10 -1
  103. package/dist/cjs/views/ThemeInverse.js.map +2 -2
  104. package/dist/cjs/views/ThemeProvider.js +6 -1
  105. package/dist/cjs/views/ThemeProvider.js.map +2 -2
  106. package/dist/cjs/views/ThemeReset.js +4 -0
  107. package/dist/esm/Tamagui.js +8 -2
  108. package/dist/esm/Tamagui.js.map +2 -2
  109. package/dist/esm/ThemeManager.js +21 -11
  110. package/dist/esm/ThemeManager.js.map +2 -2
  111. package/dist/esm/conf.js +0 -1
  112. package/dist/esm/conf.js.map +2 -2
  113. package/dist/esm/constants/platform.js +2 -0
  114. package/dist/esm/constants/platform.js.map +2 -2
  115. package/dist/esm/createComponent.js +187 -122
  116. package/dist/esm/createComponent.js.map +2 -2
  117. package/dist/esm/createTamagui.js +45 -28
  118. package/dist/esm/createTamagui.js.map +2 -2
  119. package/dist/esm/createTokens.js +2 -6
  120. package/dist/esm/createTokens.js.map +2 -2
  121. package/dist/esm/createVariable.js +8 -2
  122. package/dist/esm/createVariable.js.map +2 -2
  123. package/dist/esm/helpers/addStylesUsingClassname.js +4 -1
  124. package/dist/esm/helpers/addStylesUsingClassname.js.map +2 -2
  125. package/dist/esm/helpers/createMediaStyle.js +0 -2
  126. package/dist/esm/helpers/createMediaStyle.js.map +2 -2
  127. package/dist/esm/helpers/createPropMapper.js +50 -22
  128. package/dist/esm/helpers/createPropMapper.js.map +2 -2
  129. package/dist/esm/helpers/extendStaticConfig.js +9 -6
  130. package/dist/esm/helpers/extendStaticConfig.js.map +2 -2
  131. package/dist/esm/helpers/fixNativeShadow.native.js +7 -9
  132. package/dist/esm/helpers/fixNativeShadow.native.js.map +2 -2
  133. package/dist/esm/helpers/getButtonSize.js +24 -0
  134. package/dist/esm/helpers/getButtonSize.js.map +7 -0
  135. package/dist/esm/helpers/getSize.js +13 -0
  136. package/dist/esm/helpers/getSize.js.map +7 -0
  137. package/dist/esm/helpers/getSplitStyles.js +136 -57
  138. package/dist/esm/helpers/getSplitStyles.js.map +2 -2
  139. package/dist/esm/helpers/getStylesAtomic.js +15 -3
  140. package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
  141. package/dist/esm/helpers/getTextSize.js +34 -0
  142. package/dist/esm/helpers/getTextSize.js.map +7 -0
  143. package/dist/esm/helpers/insertStyleRule.js +32 -27
  144. package/dist/esm/helpers/insertStyleRule.js.map +2 -2
  145. package/dist/esm/helpers/nativeGestureHandler.js +7 -0
  146. package/dist/esm/helpers/nativeGestureHandler.js.map +7 -0
  147. package/dist/esm/helpers/nativeGestureHandler.native.js +2 -0
  148. package/dist/esm/helpers/nativeGestureHandler.native.js.map +7 -0
  149. package/dist/esm/helpers/proxyThemeVariables.js +18 -0
  150. package/dist/esm/helpers/proxyThemeVariables.js.map +7 -0
  151. package/dist/esm/helpers/themeable.js +3 -2
  152. package/dist/esm/helpers/themeable.js.map +2 -2
  153. package/dist/esm/helpers/validate.js +24 -11
  154. package/dist/esm/helpers/validate.js.map +2 -2
  155. package/dist/esm/hooks/useId.js +35 -0
  156. package/dist/esm/hooks/useId.js.map +7 -0
  157. package/dist/esm/hooks/useIsTouchDevice.js +6 -6
  158. package/dist/esm/hooks/useIsTouchDevice.js.map +2 -2
  159. package/dist/esm/hooks/useMedia.js +3 -0
  160. package/dist/esm/hooks/useMedia.js.map +2 -2
  161. package/dist/esm/hooks/usePrevious.js +1 -0
  162. package/dist/esm/{createShallowUpdate.js.map → hooks/usePrevious.js.map} +0 -0
  163. package/dist/esm/hooks/useTheme.js +22 -16
  164. package/dist/esm/hooks/useTheme.js.map +2 -2
  165. package/dist/esm/index.js +13 -6
  166. package/dist/esm/index.js.map +2 -2
  167. package/dist/esm/nativeGestureHandler.native.js +2 -0
  168. package/dist/esm/nativeGestureHandler.native.js.map +7 -0
  169. package/dist/esm/static.js +3 -0
  170. package/dist/esm/static.js.map +2 -2
  171. package/dist/esm/styled.js +7 -5
  172. package/dist/esm/styled.js.map +2 -2
  173. package/dist/esm/views/Slot.js +82 -0
  174. package/dist/esm/views/Slot.js.map +7 -0
  175. package/dist/esm/views/Text.js +9 -14
  176. package/dist/esm/views/Text.js.map +2 -2
  177. package/dist/esm/views/Theme.js +3 -3
  178. package/dist/esm/views/Theme.js.map +2 -2
  179. package/dist/esm/views/ThemeInverse.js +6 -2
  180. package/dist/esm/views/ThemeInverse.js.map +2 -2
  181. package/dist/esm/views/ThemeProvider.js +2 -1
  182. package/dist/esm/views/ThemeProvider.js.map +2 -2
  183. package/dist/jsx/Tamagui.js +8 -2
  184. package/dist/jsx/ThemeManager.js +21 -11
  185. package/dist/jsx/conf.js +0 -1
  186. package/dist/jsx/constants/platform.js +2 -0
  187. package/dist/jsx/createComponent.js +173 -113
  188. package/dist/jsx/createTamagui.js +45 -28
  189. package/dist/jsx/createTokens.js +2 -6
  190. package/dist/jsx/createVariable.js +8 -2
  191. package/dist/jsx/helpers/addStylesUsingClassname.js +4 -1
  192. package/dist/jsx/helpers/createMediaStyle.js +0 -2
  193. package/dist/jsx/helpers/createPropMapper.js +50 -22
  194. package/dist/jsx/helpers/extendStaticConfig.js +9 -6
  195. package/dist/jsx/helpers/fixNativeShadow.native.js +7 -9
  196. package/dist/jsx/helpers/getButtonSize.js +23 -0
  197. package/dist/jsx/helpers/getSize.js +12 -0
  198. package/dist/jsx/helpers/getSplitStyles.js +136 -57
  199. package/dist/jsx/helpers/getStylesAtomic.js +15 -3
  200. package/dist/jsx/helpers/getTextSize.js +33 -0
  201. package/dist/jsx/helpers/insertStyleRule.js +32 -27
  202. package/dist/jsx/helpers/nativeGestureHandler.js +6 -0
  203. package/dist/jsx/helpers/nativeGestureHandler.native.js +1 -0
  204. package/dist/jsx/helpers/proxyThemeVariables.js +17 -0
  205. package/dist/jsx/helpers/themeable.js +3 -3
  206. package/dist/jsx/helpers/validate.js +24 -11
  207. package/dist/jsx/hooks/useId.js +34 -0
  208. package/dist/jsx/hooks/useIsTouchDevice.js +6 -6
  209. package/dist/jsx/hooks/useMedia.js +3 -0
  210. package/dist/jsx/{createShallowUpdate.js → hooks/usePrevious.js} +0 -0
  211. package/dist/jsx/hooks/useTheme.js +22 -16
  212. package/dist/jsx/index.js +13 -6
  213. package/dist/jsx/nativeGestureHandler.native.js +1 -0
  214. package/dist/jsx/static.js +3 -0
  215. package/dist/jsx/styled.js +7 -5
  216. package/dist/jsx/views/Slot.js +75 -0
  217. package/dist/jsx/views/Text.js +9 -14
  218. package/dist/jsx/views/Theme.js +4 -4
  219. package/dist/jsx/views/ThemeInverse.js +6 -1
  220. package/dist/jsx/views/ThemeProvider.js +2 -2
  221. package/package.json +8 -6
  222. package/types/Tamagui.d.ts +16 -1
  223. package/types/Tamagui.d.ts.map +1 -1
  224. package/types/ThemeManager.d.ts +3 -3
  225. package/types/ThemeManager.d.ts.map +1 -1
  226. package/types/conf.d.ts +2 -0
  227. package/types/conf.d.ts.map +1 -1
  228. package/types/constants/platform.d.ts +1 -0
  229. package/types/constants/platform.d.ts.map +1 -1
  230. package/types/createComponent.d.ts +3 -4
  231. package/types/createComponent.d.ts.map +1 -1
  232. package/types/createTamagui.d.ts +3 -1
  233. package/types/createTamagui.d.ts.map +1 -1
  234. package/types/createTokens.d.ts +0 -26
  235. package/types/createTokens.d.ts.map +1 -1
  236. package/types/createVariable.d.ts +1 -0
  237. package/types/createVariable.d.ts.map +1 -1
  238. package/types/helpers/addStylesUsingClassname.d.ts.map +1 -1
  239. package/types/helpers/createMediaStyle.d.ts.map +1 -1
  240. package/types/helpers/createPropMapper.d.ts +1 -1
  241. package/types/helpers/createPropMapper.d.ts.map +1 -1
  242. package/types/helpers/extendStaticConfig.d.ts +2 -2
  243. package/types/helpers/extendStaticConfig.d.ts.map +1 -1
  244. package/types/helpers/fixNativeShadow.native.d.ts +2 -1
  245. package/types/helpers/fixNativeShadow.native.d.ts.map +1 -1
  246. package/types/helpers/getButtonSize.d.ts +8 -0
  247. package/types/helpers/getButtonSize.d.ts.map +1 -0
  248. package/types/helpers/getSize.d.ts +3 -0
  249. package/types/helpers/getSize.d.ts.map +1 -0
  250. package/types/helpers/getSplitStyles.d.ts +14 -6
  251. package/types/helpers/getSplitStyles.d.ts.map +1 -1
  252. package/types/helpers/getStylesAtomic.d.ts.map +1 -1
  253. package/types/helpers/getTextSize.d.ts +3 -0
  254. package/types/helpers/getTextSize.d.ts.map +1 -0
  255. package/types/helpers/insertStyleRule.d.ts +2 -1
  256. package/types/helpers/insertStyleRule.d.ts.map +1 -1
  257. package/types/helpers/nativeGestureHandler.d.ts +2 -0
  258. package/types/helpers/nativeGestureHandler.d.ts.map +1 -0
  259. package/types/helpers/nativeGestureHandler.native.d.ts +2 -0
  260. package/types/helpers/nativeGestureHandler.native.d.ts.map +1 -0
  261. package/types/helpers/proxyThemeVariables.d.ts +2 -0
  262. package/types/helpers/proxyThemeVariables.d.ts.map +1 -0
  263. package/types/helpers/themeable.d.ts +3 -1
  264. package/types/helpers/themeable.d.ts.map +1 -1
  265. package/types/helpers/validate.d.ts.map +1 -1
  266. package/types/hooks/useId.d.ts +9 -0
  267. package/types/hooks/useId.d.ts.map +1 -0
  268. package/types/hooks/useMedia.d.ts +2 -6
  269. package/types/hooks/useMedia.d.ts.map +1 -1
  270. package/types/hooks/usePrevious.d.ts +1 -0
  271. package/types/hooks/usePrevious.d.ts.map +1 -0
  272. package/types/hooks/useTheme.d.ts +1 -1
  273. package/types/hooks/useTheme.d.ts.map +1 -1
  274. package/types/index.d.ts +11 -6
  275. package/types/index.d.ts.map +1 -1
  276. package/types/nativeGestureHandler.native.d.ts +2 -0
  277. package/types/nativeGestureHandler.native.d.ts.map +1 -0
  278. package/types/static.d.ts +3 -0
  279. package/types/static.d.ts.map +1 -1
  280. package/types/styled.d.ts +12 -3
  281. package/types/styled.d.ts.map +1 -1
  282. package/types/types.d.ts +86 -46
  283. package/types/types.d.ts.map +1 -1
  284. package/types/views/Slot.d.ts +9 -0
  285. package/types/views/Slot.d.ts.map +1 -0
  286. package/types/views/Text.d.ts.map +1 -1
  287. package/types/views/Theme.d.ts +1 -0
  288. package/types/views/Theme.d.ts.map +1 -1
  289. package/types/views/ThemeInverse.d.ts.map +1 -1
  290. package/types/views/ThemeProvider.d.ts +1 -0
  291. package/types/views/ThemeProvider.d.ts.map +1 -1
  292. package/LICENSE +0 -21
  293. package/dist/cjs/constants/pseudos.js.map +0 -7
  294. package/dist/cjs/createShallowUpdate.js +0 -1
  295. package/dist/cjs/devtools.js +0 -32
  296. package/dist/cjs/devtools.js.map +0 -7
  297. package/dist/cjs/spacedChildren.js +0 -86
  298. package/dist/cjs/spacedChildren.js.map +0 -7
  299. package/dist/cjs/tamagui-base.css +0 -8
  300. package/dist/cjs/tamagui-base.css.map +0 -7
  301. package/dist/esm/constants/pseudos.js +0 -18
  302. package/dist/esm/constants/pseudos.js.map +0 -7
  303. package/dist/esm/createShallowUpdate.js +0 -1
  304. package/dist/esm/devtools.js +0 -14
  305. package/dist/esm/devtools.js.map +0 -7
  306. package/dist/esm/spacedChildren.js +0 -52
  307. package/dist/esm/spacedChildren.js.map +0 -7
  308. package/dist/esm/tamagui-base.css +0 -8
  309. package/dist/esm/tamagui-base.css.map +0 -7
  310. package/dist/jsx/constants/pseudos.js +0 -17
  311. package/dist/jsx/devtools.js +0 -13
  312. package/dist/jsx/spacedChildren.js +0 -44
  313. package/dist/jsx/tamagui-base.css +0 -7
  314. package/types/spacedChildren.d.ts +0 -9
  315. package/types/spacedChildren.d.ts.map +0 -1
@@ -13,20 +13,23 @@ import React, {
13
13
  useRef,
14
14
  useState
15
15
  } from "react";
16
- import { StyleSheet, Text, View } from "react-native";
16
+ import { Pressable, StyleSheet, Text, View } from "react-native";
17
17
  import { onConfiguredOnce } from "./conf";
18
18
  import { stackDefaultStyles } from "./constants/constants";
19
- import { isAndroid, isTouchDevice, isWeb, useIsomorphicLayoutEffect } from "./constants/platform";
19
+ import { isAndroid, isWeb, useIsomorphicLayoutEffect } from "./constants/platform";
20
20
  import { rnw } from "./constants/rnw";
21
- import { isVariable } from "./createVariable";
22
21
  import { createShallowUpdate } from "./helpers/createShallowUpdate";
23
22
  import { extendStaticConfig, parseStaticConfig } from "./helpers/extendStaticConfig";
24
- import { getSplitStyles } from "./helpers/getSplitStyles";
23
+ import { insertSplitStyles, useSplitStyles } from "./helpers/getSplitStyles";
25
24
  import { getAllSelectors } from "./helpers/insertStyleRule";
25
+ import { BaseButton } from "./helpers/nativeGestureHandler";
26
+ import { proxyThemeVariables } from "./helpers/proxyThemeVariables";
26
27
  import { wrapThemeManagerContext } from "./helpers/wrapThemeManagerContext";
27
28
  import { useFeatures } from "./hooks/useFeatures";
29
+ import { useIsTouchDevice } from "./hooks/useIsTouchDevice";
28
30
  import { usePressable } from "./hooks/usePressable";
29
31
  import { getThemeManagerIfChanged, useTheme } from "./hooks/useTheme";
32
+ import { Slot } from "./views/Slot";
30
33
  import { TextAncestorContext } from "./views/TextAncestorContext";
31
34
  React["keep"];
32
35
  const defaultComponentState = {
@@ -43,55 +46,70 @@ if (typeof document !== "undefined") {
43
46
  mouseUps.forEach((x) => x());
44
47
  mouseUps.clear();
45
48
  });
49
+ document.addEventListener("touchend", () => {
50
+ mouseUps.forEach((x) => x());
51
+ mouseUps.clear();
52
+ });
53
+ document.addEventListener("touchcancel", () => {
54
+ mouseUps.forEach((x) => x());
55
+ mouseUps.clear();
56
+ });
46
57
  }
47
- function createComponent(configIn) {
48
- let staticConfig;
49
- if ("parsed" in configIn) {
50
- staticConfig = configIn;
51
- } else {
52
- staticConfig = parseStaticConfig(configIn);
58
+ function mergeShorthands({ defaultProps }, { shorthands }) {
59
+ for (const key in defaultProps) {
60
+ defaultProps[shorthands[key] || key] = defaultProps[key];
53
61
  }
54
- const { Component, validStyles, isText, isZStack, componentName } = staticConfig;
55
- const componentClassName = `is_${componentName}`;
56
- const validStyleProps = validStyles || stylePropsView;
62
+ }
63
+ __name(mergeShorthands, "mergeShorthands");
64
+ let initialTheme;
65
+ function createComponent(configIn, ParentComponent) {
66
+ const staticConfig = (() => {
67
+ const config = extendStaticConfig(configIn, ParentComponent);
68
+ if ("parsed" in config) {
69
+ return config;
70
+ } else {
71
+ return parseStaticConfig(config);
72
+ }
73
+ })();
74
+ const componentClassName = `is_${staticConfig.componentName}`;
57
75
  let tamaguiConfig;
58
76
  let AnimatedText;
59
77
  let AnimatedView;
60
78
  let avoidClasses = true;
61
- let defaultPseudos = {};
62
79
  let defaultNativeStyle;
63
- let defaultNativeStyleSheet = null;
64
- let defaultsClassName = null;
65
- let initialTheme;
66
- let defaultSplitStyleResult = null;
80
+ let defaultNativeStyleSheet;
81
+ let tamaguiDefaultProps;
82
+ let initialSplitStyles;
67
83
  function addPseudoToStyles(styles, name, pseudos) {
68
84
  const pseudoStyle = pseudos[name];
69
85
  const shouldNestObject = isWeb && name !== "enterStyle" && name !== "exitStyle";
70
- if (pseudoStyle) {
71
- styles.push(shouldNestObject ? { [name]: pseudoStyle } : pseudoStyle);
72
- }
73
- const defaultPseudoStyle = defaultPseudos[name];
86
+ const defaultPseudoStyle = initialSplitStyles.pseudos[name];
74
87
  if (defaultPseudoStyle) {
75
88
  styles.push(shouldNestObject ? { [name]: defaultPseudoStyle } : defaultPseudoStyle);
76
89
  }
90
+ if (pseudoStyle) {
91
+ styles.push(shouldNestObject ? { [name]: pseudoStyle } : pseudoStyle);
92
+ }
77
93
  }
78
94
  __name(addPseudoToStyles, "addPseudoToStyles");
79
95
  const component = forwardRef((props, forwardedRef) => {
80
96
  var _a, _b, _c, _d;
97
+ props = tamaguiDefaultProps && !props.asChild ? { ...tamaguiDefaultProps, ...props } : props;
98
+ const { Component, componentName, isText, isZStack } = staticConfig;
81
99
  if (process.env.NODE_ENV === "development") {
82
100
  if (props["debug"]) {
83
- console.warn(componentName || (Component == null ? void 0 : Component.displayName) || (Component == null ? void 0 : Component.name) || "[Unnamed Component]", "debug on");
84
- console.log("props in:", props);
101
+ console.log("\u26A0\uFE0F", staticConfig.componentName || (Component == null ? void 0 : Component.displayName) || (Component == null ? void 0 : Component.name) || "[Unnamed Component]", "debug on");
102
+ console.log("props in:", props, Object.keys(props));
85
103
  if (props["debug"] === "break")
86
104
  debugger;
87
105
  }
88
106
  }
89
107
  const forceUpdate = useForceUpdate();
90
- const theme = useTheme(props.theme, componentName, props, forceUpdate);
108
+ const theme = useTheme(props.theme, staticConfig.componentName, props, forceUpdate);
91
109
  const [state, set_] = useState(defaultComponentState);
92
110
  const setStateShallow = createShallowUpdate(set_);
93
111
  const shouldAvoidClasses = !!(props.animation && avoidClasses);
94
- const splitStyles = getSplitStyles(props, staticConfig, theme, shouldAvoidClasses ? { ...state, noClassNames: true, resolveVariablesAs: "value" } : state, shouldAvoidClasses ? null : defaultsClassName);
112
+ const splitStyles = useSplitStyles(props, staticConfig, theme, shouldAvoidClasses ? { ...state, noClassNames: true, resolveVariablesAs: "value" } : state, shouldAvoidClasses || props.asChild ? null : initialSplitStyles.classNames);
95
113
  const { viewProps: viewPropsIn, pseudos, medias, style, classNames } = splitStyles;
96
114
  const useAnimations = (_a = tamaguiConfig.animations) == null ? void 0 : _a.useAnimations;
97
115
  const isAnimated = !!(useAnimations && props.animation);
@@ -110,6 +128,7 @@ function createComponent(configIn) {
110
128
  const {
111
129
  tag,
112
130
  hitSlop,
131
+ asChild,
113
132
  children,
114
133
  pointerEvents,
115
134
  onPress,
@@ -144,6 +163,7 @@ function createComponent(configIn) {
144
163
  accessibilityRole,
145
164
  collapsable,
146
165
  focusable,
166
+ onClick,
147
167
  theme: _themeProp,
148
168
  defaultVariants,
149
169
  onLayout,
@@ -166,7 +186,7 @@ function createComponent(configIn) {
166
186
  };
167
187
  }
168
188
  useIsomorphicLayoutEffect(() => {
169
- if (typeof window !== "undefined") {
189
+ if (typeof window !== "undefined" && (hasEnterStyle || props.animation)) {
170
190
  setStateShallow({
171
191
  mounted: true
172
192
  });
@@ -176,7 +196,7 @@ function createComponent(configIn) {
176
196
  mouseUps.delete(unPress);
177
197
  internal.current.isMounted = false;
178
198
  };
179
- }, [hasEnterStyle]);
199
+ }, [hasEnterStyle, props.animation]);
180
200
  if (nativeID) {
181
201
  viewProps.id = nativeID;
182
202
  }
@@ -192,7 +212,7 @@ function createComponent(configIn) {
192
212
  if (accessibilityRole)
193
213
  viewProps.accessibilityRole = accessibilityRole;
194
214
  }
195
- if (isWeb) {
215
+ if (isWeb && !asChild) {
196
216
  rnw.useResponderEvents(hostRef, {
197
217
  onMoveShouldSetResponder,
198
218
  onMoveShouldSetResponderCapture,
@@ -253,7 +273,7 @@ function createComponent(configIn) {
253
273
  const className = classList.join(" ");
254
274
  if (process.env.NODE_ENV === "development") {
255
275
  if (props["debug"]) {
256
- console.log(" \xBB className", { isStringElement, pseudos, state, defaultsClassName, classNames, propsClassName: props.className, style, classList, className: className.trim().split(" "), themeClassName: theme.className, values: Object.fromEntries(Object.entries(classNames).map(([k, v]) => [v, getAllSelectors()[v]])) });
276
+ console.log(" \xBB className", { isStringElement, pseudos, state, classNames, propsClassName: props.className, style, classList, className: className.trim().split(" "), themeClassName: theme.className, values: Object.fromEntries(Object.entries(classNames).map(([k, v]) => [v, getAllSelectors()[v]])) });
257
277
  }
258
278
  }
259
279
  viewProps.className = className;
@@ -294,11 +314,16 @@ function createComponent(configIn) {
294
314
  viewProps.ref = forwardedRef;
295
315
  }
296
316
  }
297
- const attachPress = !!(pseudos && pseudos.pressStyle || defaultPseudos && defaultPseudos.pressStyle || onPress || onPressOut || onPressIn);
298
- const isHoverable = isWeb && !isTouchDevice;
317
+ const initialPseudos = initialSplitStyles.pseudos;
318
+ const attachPress = !!(pseudos && pseudos.pressStyle || initialPseudos && initialPseudos.pressStyle || onPress || onPressOut || onPressIn || onClick);
319
+ const isTouch = useIsTouchDevice();
320
+ const isHoverable = isWeb && !isTouch;
299
321
  const attachHover = isHoverable && !!(pseudos && pseudos.hoverStyle || onHoverIn || onHoverOut || onMouseEnter || onMouseLeave);
300
- const pressEventKey = isStringElement ? "onClick" : "onPress";
301
- const shouldAttach = attachPress || attachHover || "pressStyle" in props || "onPress" in props || "onPressIn" in props || "onPressOut" in props || isWeb && ("hoverStyle" in props || "onHoverIn" in props || "onHoverOut" in props || "onMouseEnter" in props || "onMouseLeave" in props);
322
+ const handlesPressEvents = !isStringElement && !asChild;
323
+ const pressKey = handlesPressEvents ? "onPress" : "onClick";
324
+ const pressInKey = handlesPressEvents ? "onPressIn" : "onMouseDown";
325
+ const pressOutKey = handlesPressEvents ? "onPressOut" : "onMouseUp";
326
+ const shouldAttach = !asChild && (attachPress || attachHover || "pressStyle" in props || "onPress" in props || "onPressIn" in props || "onPressOut" in props || isWeb && ("hoverStyle" in props || "onHoverIn" in props || "onHoverOut" in props || "onMouseEnter" in props || "onMouseLeave" in props));
302
327
  const unPress = useCallback(() => {
303
328
  if (!internal.current.isMounted)
304
329
  return;
@@ -308,12 +333,10 @@ function createComponent(configIn) {
308
333
  });
309
334
  }, []);
310
335
  const events = shouldAttach ? {
311
- ...!isWeb && {
312
- onPressOut: (e) => {
313
- unPress();
314
- onPressOut == null ? void 0 : onPressOut(e);
315
- }
316
- },
336
+ [pressOutKey]: attachPress ? (e) => {
337
+ unPress();
338
+ onPressOut == null ? void 0 : onPressOut(e);
339
+ } : void 0,
317
340
  ...isHoverable && {
318
341
  onMouseEnter: attachHover ? (e) => {
319
342
  let next = {};
@@ -346,37 +369,29 @@ function createComponent(configIn) {
346
369
  onMouseLeave == null ? void 0 : onMouseLeave(e);
347
370
  } : void 0
348
371
  },
349
- onMouseDown: attachPress ? (e) => {
372
+ [pressInKey]: attachPress ? (e) => {
350
373
  setStateShallow({
351
374
  press: true,
352
375
  pressIn: true
353
376
  });
354
377
  onPressIn == null ? void 0 : onPressIn(e);
355
378
  onMouseDown == null ? void 0 : onMouseDown(e);
379
+ if (isWeb) {
380
+ mouseUps.add(unPress);
381
+ }
356
382
  } : null,
357
- [pressEventKey]: attachPress ? (e) => {
358
- onPress == null ? void 0 : onPress(e);
383
+ [pressKey]: attachPress ? (e) => {
359
384
  unPress();
360
- onPressOut == null ? void 0 : onPressOut(e);
385
+ onClick == null ? void 0 : onClick(e);
386
+ onPress == null ? void 0 : onPress(e);
361
387
  } : null
362
388
  } : null;
363
- let childEls = !children ? children : wrapThemeManagerContext(spacedChildren({
389
+ const childEls = !children || asChild ? children : wrapThemeManagerContext(spacedChildren({
364
390
  children,
365
391
  space,
366
392
  flexDirection: props.flexDirection || ((_b = staticConfig.defaultProps) == null ? void 0 : _b.flexDirection),
367
393
  isZStack
368
394
  }), getThemeManagerIfChanged(theme));
369
- const [pressProps] = usePressable(events ? {
370
- disabled,
371
- ...hitSlop && {
372
- hitSlop
373
- },
374
- onPressIn: events.onMouseDown,
375
- onPressOut: events.onPressOut,
376
- onPress: events[pressEventKey]
377
- } : {
378
- disabled: true
379
- });
380
395
  let content;
381
396
  if (isWeb) {
382
397
  if (staticConfig.isReactNativeWeb) {
@@ -393,14 +408,41 @@ function createComponent(configIn) {
393
408
  }
394
409
  }
395
410
  }
396
- if (events) {
397
- if (!isStringElement) {
398
- Object.assign(viewProps, pressProps);
399
- } else {
400
- Object.assign(viewProps, events);
411
+ if (asChild) {
412
+ ViewComponent = Slot;
413
+ const onlyChild = React.Children.only(children);
414
+ Object.assign(viewProps, onlyChild.props);
415
+ }
416
+ if (isWeb) {
417
+ const [pressableProps] = usePressable(events ? {
418
+ disabled,
419
+ ...hitSlop && {
420
+ hitSlop
421
+ },
422
+ onPressOut: events[pressOutKey],
423
+ onPressIn: events[pressInKey],
424
+ onPress: events[pressKey]
425
+ } : {
426
+ disabled: true
427
+ });
428
+ if (events) {
429
+ if (handlesPressEvents) {
430
+ Object.assign(viewProps, pressableProps);
431
+ } else {
432
+ Object.assign(viewProps, events);
433
+ }
401
434
  }
402
435
  }
403
436
  content = createElement(ViewComponent, viewProps, childEls);
437
+ if (!isWeb) {
438
+ if (attachPress && events) {
439
+ content = <Pressable onPressIn={events[pressInKey]} onPress={events[pressKey]}><BaseButton onActiveStateChange={(isActive) => {
440
+ if (!isActive) {
441
+ unPress();
442
+ }
443
+ }}>{content}</BaseButton></Pressable>;
444
+ }
445
+ }
404
446
  if (isWeb && events && attachHover) {
405
447
  content = <span className="tui_Hoverable" style={{
406
448
  display: "contents"
@@ -408,8 +450,7 @@ function createComponent(configIn) {
408
450
  }
409
451
  if (process.env.NODE_ENV === "development") {
410
452
  if (props["debug"]) {
411
- viewProps["debug"] = true;
412
- console.log(" \xBB ", { propsIn: { ...props }, propsOut: { ...viewProps }, state, splitStyles, defaultsClassName, animationStyles, isStringElement, classNamesIn: (_c = props.className) == null ? void 0 : _c.split(" "), classNamesOut: (_d = viewProps.className) == null ? void 0 : _d.split(" "), pressProps, events, shouldAttach, ViewComponent, viewProps, styles, pseudos, content, childEls, shouldAvoidClasses, avoidClasses, animation: props.animation, style, defaultNativeStyle, defaultSplitStyleResult, ...typeof window !== "undefined" ? { theme, themeState: theme.__state, themeClassName: theme.className, staticConfig, tamaguiConfig } : null });
453
+ console.log(" \xBB ", { propsIn: { ...props }, propsOut: { ...viewProps }, state, splitStyles, animationStyles, isStringElement, classNamesIn: (_c = props.className) == null ? void 0 : _c.split(" "), classNamesOut: (_d = viewProps.className) == null ? void 0 : _d.split(" "), events, shouldAttach, ViewComponent, viewProps, styles, pseudos, content, childEls, shouldAvoidClasses, avoidClasses, animation: props.animation, style, defaultNativeStyle, initialSplitStyles, ...typeof window !== "undefined" ? { theme, themeState: theme.__state, themeClassName: theme.className, staticConfig, tamaguiConfig } : null });
413
454
  }
414
455
  }
415
456
  if (features.length) {
@@ -420,66 +461,81 @@ function createComponent(configIn) {
420
461
  }
421
462
  return content;
422
463
  });
464
+ component.displayName = staticConfig.componentName;
423
465
  onConfiguredOnce((conf) => {
424
466
  var _a, _b, _c, _d;
425
467
  if (process.env.IS_STATIC === "is_static") {
426
468
  return;
427
469
  }
428
- const shouldDebug = (_a = staticConfig.defaultProps) == null ? void 0 : _a.debug;
429
470
  tamaguiConfig = conf;
430
- avoidClasses = !!((_b = tamaguiConfig.animations) == null ? void 0 : _b.avoidClasses);
431
- AnimatedText = (_c = tamaguiConfig.animations) == null ? void 0 : _c.Text;
432
- AnimatedView = (_d = tamaguiConfig == null ? void 0 : tamaguiConfig.animations) == null ? void 0 : _d.View;
433
- initialTheme = conf.themes[conf.defaultTheme || Object.keys(conf.themes)[0]];
434
- defaultSplitStyleResult = getSplitStyles(staticConfig.defaultProps, staticConfig, initialTheme, {
471
+ mergeShorthands(staticConfig, tamaguiConfig);
472
+ avoidClasses = !!((_a = tamaguiConfig.animations) == null ? void 0 : _a.avoidClasses);
473
+ AnimatedText = (_b = tamaguiConfig.animations) == null ? void 0 : _b.Text;
474
+ AnimatedView = (_c = tamaguiConfig == null ? void 0 : tamaguiConfig.animations) == null ? void 0 : _c.View;
475
+ initialTheme = initialTheme || proxyThemeVariables(conf.themes[conf.defaultTheme || Object.keys(conf.themes)[0]]);
476
+ initialSplitStyles = insertSplitStyles(staticConfig.defaultProps, staticConfig, initialTheme, {
435
477
  mounted: true,
436
478
  hover: false,
437
479
  press: false,
438
480
  pressIn: false,
439
481
  focus: false,
440
- resolveVariablesAs: "both"
482
+ resolveVariablesAs: "both",
483
+ keepVariantsAsProps: true
441
484
  });
442
- const { classNames, pseudos, style, viewProps } = defaultSplitStyleResult;
443
- if (isWeb) {
444
- defaultsClassName = classNames;
445
- }
446
- defaultPseudos = pseudos;
485
+ const defaults = {
486
+ ...component.defaultProps,
487
+ ...initialSplitStyles.viewProps
488
+ };
447
489
  defaultNativeStyle = {};
448
- for (const key in style) {
449
- const v = style[key];
450
- defaultNativeStyle[key] = isVariable(v) ? v.val : v;
490
+ const validStyles = staticConfig.validStyles || stylePropsView;
491
+ for (const key in staticConfig.defaultProps) {
492
+ const val = staticConfig.defaultProps[key];
493
+ if (typeof val === "string" && val[0] === "$" || !validStyles[key]) {
494
+ defaults[key] = val;
495
+ } else {
496
+ defaultNativeStyle[key] = val;
497
+ }
451
498
  }
452
499
  defaultNativeStyleSheet = StyleSheet.create({
453
500
  base: defaultNativeStyle
454
501
  });
455
- component.displayName = staticConfig.componentName;
456
- component.defaultProps = {
457
- ...viewProps,
458
- ...component.defaultProps
459
- };
460
- if (process.env.NODE_ENV === "development" && shouldDebug && process.env.IS_STATIC !== "is_static") {
461
- console.log(`\u{1F41B} [${staticConfig.componentName || "Component"}]`, { staticConfig, ...defaultSplitStyleResult });
502
+ if (Object.keys(defaults).length) {
503
+ tamaguiDefaultProps = defaults;
504
+ }
505
+ if (process.env.NODE_ENV === "development" && ((_d = staticConfig.defaultProps) == null ? void 0 : _d.debug)) {
506
+ if (process.env.IS_STATIC !== "is_static") {
507
+ console.log(`\u{1F41B} [${staticConfig.componentName || "Component"}]`, {
508
+ staticConfig,
509
+ initialSplitStyles,
510
+ tamaguiDefaultProps,
511
+ defaultNativeStyle,
512
+ defaults
513
+ });
514
+ }
462
515
  }
463
516
  });
464
517
  let res = component;
465
518
  if (configIn.memo) {
466
519
  res = memo(res);
467
520
  }
468
- res["whyDidYouRender"] = true;
469
521
  res["staticConfig"] = {
470
- validStyles: validStyleProps,
522
+ validStyles: staticConfig.validStyles || stylePropsView,
471
523
  ...staticConfig
472
524
  };
473
- res["extractable"] = (Component2, conf) => {
474
- Component2["staticConfig"] = extendStaticConfig(res, {
525
+ if (process.env.NODE_ENV === "development") {
526
+ res["whyDidYouRender"] = true;
527
+ }
528
+ res["extractable"] = (Component, conf) => {
529
+ Component["staticConfig"] = extendStaticConfig({
530
+ Component,
475
531
  ...conf,
476
532
  neverFlatten: true,
477
533
  defaultProps: {
478
- ...Component2.defaultProps,
534
+ ...Component.defaultProps,
479
535
  ...conf == null ? void 0 : conf.defaultProps
480
536
  }
481
- });
482
- return Component2;
537
+ }, res);
538
+ return Component;
483
539
  };
484
540
  return res;
485
541
  }
@@ -520,6 +576,9 @@ const Spacer = createComponent({
520
576
  minWidth: 0
521
577
  }
522
578
  }
579
+ },
580
+ defaultVariants: {
581
+ direction: "horizontal"
523
582
  }
524
583
  });
525
584
  function spacedChildren({
@@ -530,47 +589,48 @@ function spacedChildren({
530
589
  spaceFlex
531
590
  }) {
532
591
  var _a;
533
- const childrenList = Children.toArray(children);
592
+ const childrenList = Array.isArray(children) ? children : Children.toArray(children);
534
593
  const len = childrenList.length;
535
- if (len === 1) {
594
+ if (len <= 1) {
536
595
  return childrenList;
537
596
  }
538
- const next = [];
597
+ const final = [];
539
598
  for (const [index, child] of childrenList.entries()) {
540
- if (child === null || child === void 0) {
599
+ if (child === null || child === void 0 || child === false || Array.isArray(child) && child.length === 0) {
541
600
  continue;
542
601
  }
543
602
  if (!child || child["key"] && !isZStack) {
544
- next.push(child);
603
+ final.push(child);
545
604
  } else {
546
- next.push(<Fragment key={index}>{isZStack ? <AbsoluteFill>{child}</AbsoluteFill> : child}</Fragment>);
605
+ final.push(<Fragment key={index}>{isZStack ? <AbsoluteFill>{child}</AbsoluteFill> : child}</Fragment>);
547
606
  }
548
607
  if ((_a = child["type"]) == null ? void 0 : _a["isVisuallyHidden"]) {
549
608
  continue;
550
609
  }
551
- if (index !== len - 1) {
552
- if (space) {
553
- next.push(<Spacer key={`_${index}_spacer`} direction={flexDirection === "row" || flexDirection === "row-reverse" ? "horizontal" : "vertical"} size={space} {...spaceFlex && {
554
- flex: spaceFlex
555
- }} />);
556
- }
610
+ const next = childrenList[index + 1];
611
+ if (next && space) {
612
+ final.push(<Spacer key={`_${index}_spacer`} direction={flexDirection === "row" || flexDirection === "row-reverse" ? "horizontal" : "vertical"} size={space} {...spaceFlex && {
613
+ flex: spaceFlex
614
+ }} />);
557
615
  }
558
616
  }
559
- return next;
617
+ return final;
560
618
  }
561
619
  __name(spacedChildren, "spacedChildren");
562
- const AbsoluteFill = /* @__PURE__ */ __name((props) => isWeb ? <div style={{
563
- position: "absolute",
564
- top: 0,
565
- left: 0,
566
- right: 0,
567
- bottom: 0
568
- }}>{props.children}</div> : <View style={StyleSheet.absoluteFill}>{props.child}</View>, "AbsoluteFill");
620
+ function AbsoluteFill(props) {
621
+ return isWeb ? <div style={{
622
+ position: "absolute",
623
+ top: 0,
624
+ left: 0,
625
+ right: 0,
626
+ bottom: 0
627
+ }}>{props.children}</div> : <View style={StyleSheet.absoluteFill}>{props.child}</View>;
628
+ }
629
+ __name(AbsoluteFill, "AbsoluteFill");
569
630
  export {
570
631
  AbsoluteFill,
571
632
  Spacer,
572
633
  createComponent,
573
- defaultComponentState,
574
634
  mouseUps,
575
635
  spacedChildren
576
636
  };
@@ -28,7 +28,7 @@ function createTamagui(config) {
28
28
  defaultActive: config.mediaQueryDefaultActive
29
29
  });
30
30
  const themeConfig = (() => {
31
- var _a, _b;
31
+ var _a, _b, _c;
32
32
  let cssRules = [];
33
33
  const varsByValue = /* @__PURE__ */ new Map();
34
34
  if (isWeb) {
@@ -75,13 +75,16 @@ function createTamagui(config) {
75
75
  }
76
76
  if (isWeb) {
77
77
  const isDarkOrLightBase = themeName === "dark" || themeName === "light";
78
- const isDark = themeName.includes("dark_");
78
+ const isDark = themeName.startsWith("dark");
79
79
  const selector = `${CNP}${themeName}`;
80
- const addDarkLightSels = hasDarkLight && !isDarkOrLightBase;
81
80
  const selectors = [selector];
82
- if (addDarkLightSels) {
81
+ if (hasDarkLight) {
83
82
  const childSelector = `${CNP}${themeName.replace("dark_", "").replace("light_", "")}`;
84
- const [stronger, weaker] = isDark ? ["dark", "light"] : ["light", "dark"];
83
+ const order = isDark ? ["dark", "light"] : ["light", "dark"];
84
+ if (isDarkOrLightBase) {
85
+ order.reverse();
86
+ }
87
+ const [stronger, weaker] = order;
85
88
  const max = (_b = config.maxDarkLightNesting) != null ? _b : 3;
86
89
  new Array(max * 2).fill(void 0).forEach((_, pi) => {
87
90
  if (pi % 2 === 1)
@@ -92,25 +95,56 @@ function createTamagui(config) {
92
95
  selectors.push(`${(parents.length > 1 ? parents.slice(1) : parents).join(" ")} ${childSelector}`);
93
96
  });
94
97
  }
95
- const cssRule = `${selectors.join(", ")} {
96
- ${vars}
97
- }`;
98
- cssRules.push(cssRule);
98
+ 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
+ }
107
+ }
99
108
  }
100
109
  }
101
110
  varsByValue.clear();
102
111
  Object.freeze(cssRules);
112
+ const css = cssRules.join("\n");
103
113
  return {
104
114
  cssRules,
105
- css: cssRules.join("\n")
115
+ css
106
116
  };
107
117
  })();
108
118
  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
+ })();
109
142
  const getCSS = /* @__PURE__ */ __name(() => {
110
143
  return `${themeConfig.css}
111
144
  ${getInsertedRules().join("\n")}`;
112
145
  }, "getCSS");
113
146
  const next = {
147
+ fonts: {},
114
148
  animations: {},
115
149
  shorthands: {},
116
150
  media: {},
@@ -120,6 +154,7 @@ ${getInsertedRules().join("\n")}`;
120
154
  defaultTheme: "light",
121
155
  ...config
122
156
  }),
157
+ fontsParsed,
123
158
  themeConfig,
124
159
  tokensParsed,
125
160
  parsed: true,
@@ -138,24 +173,6 @@ const parseTokens = /* @__PURE__ */ __name((tokens) => {
138
173
  const res = {};
139
174
  for (const key in tokens) {
140
175
  res[key] = {};
141
- if (key === "font") {
142
- for (const family in tokens.font) {
143
- const obj = {};
144
- res.font[`$${family}`] = obj;
145
- for (const attrKey in tokens.font[family]) {
146
- const attr = tokens.font[family][attrKey];
147
- if (attrKey === "family") {
148
- obj[attrKey] = attr;
149
- continue;
150
- }
151
- obj[attrKey] = Object.keys(attr).reduce((acc, cur) => {
152
- acc[`$${cur}`] = attr[cur];
153
- return acc;
154
- }, {});
155
- }
156
- }
157
- continue;
158
- }
159
176
  for (const skey in tokens[key]) {
160
177
  res[key][`$${skey}`] = tokens[key][skey];
161
178
  }
@@ -6,17 +6,13 @@ function createTokens(tokens) {
6
6
  if (process.env.NODE_ENV === "development") {
7
7
  validateTokens(tokens);
8
8
  }
9
- return setupTokens(tokens);
10
- }
11
- __name(createTokens, "createTokens");
12
- function setupTokens(tokens) {
13
9
  return mapTokensToVariables(tokens);
14
10
  }
15
- __name(setupTokens, "setupTokens");
11
+ __name(createTokens, "createTokens");
16
12
  const mapTokensToVariables = /* @__PURE__ */ __name((tokens, parentPath = "") => {
17
13
  const res = {};
18
14
  for (const key in tokens) {
19
- const val = tokens[key];
15
+ let val = tokens[key];
20
16
  const name = parentPath ? `${parentPath}-${key}` : key;
21
17
  if (val && typeof val === "object") {
22
18
  res[key] = mapTokensToVariables(tokens[key], name);
@@ -22,12 +22,17 @@ function isVariable(v) {
22
22
  }
23
23
  __name(isVariable, "isVariable");
24
24
  function getVariableValue(v) {
25
- if (isVariable(v)) {
25
+ if (isVariable(v))
26
26
  return v.val;
27
- }
28
27
  return v;
29
28
  }
30
29
  __name(getVariableValue, "getVariableValue");
30
+ function getVariableName(v) {
31
+ if (isVariable(v))
32
+ return v.name;
33
+ return v;
34
+ }
35
+ __name(getVariableName, "getVariableName");
31
36
  const createCSSVariable = /* @__PURE__ */ __name((val, includeVar = true) => {
32
37
  const name = val.replace(/[^a-z0-9\_\-]+/i, "_");
33
38
  return includeVar ? `var(--${name})` : name;
@@ -37,6 +42,7 @@ export {
37
42
  Variable,
38
43
  createCSSVariable,
39
44
  createVariable,
45
+ getVariableName,
40
46
  getVariableValue,
41
47
  isVariable
42
48
  };