@tamagui/core 1.0.1-beta.220 → 1.0.1-beta.221

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 (284) hide show
  1. package/dist/cjs/addTheme.js +7 -10
  2. package/dist/cjs/addTheme.js.map +3 -3
  3. package/dist/cjs/config.js +8 -4
  4. package/dist/cjs/config.js.map +2 -2
  5. package/dist/cjs/{hooks/useUnmountEffect.js → contexts/ButtonNestingContext.js} +7 -9
  6. package/dist/cjs/contexts/ButtonNestingContext.js.map +7 -0
  7. package/dist/cjs/createComponent.js +63 -67
  8. package/dist/cjs/createComponent.js.map +3 -3
  9. package/dist/cjs/createTamagui.js +13 -12
  10. package/dist/cjs/createTamagui.js.map +2 -2
  11. package/dist/cjs/createTokens.js.map +2 -2
  12. package/dist/cjs/createTokens.test.js +27 -0
  13. package/dist/cjs/createTokens.test.js.map +7 -0
  14. package/dist/cjs/createVariable.js +4 -9
  15. package/dist/cjs/createVariable.js.map +2 -2
  16. package/dist/cjs/createVariable.test.js +7 -0
  17. package/dist/cjs/createVariable.test.js.map +7 -0
  18. package/dist/cjs/createVariables.js +6 -7
  19. package/dist/cjs/createVariables.js.map +2 -2
  20. package/dist/cjs/helpers/ThemeManager.js +161 -147
  21. package/dist/cjs/helpers/ThemeManager.js.map +3 -3
  22. package/dist/cjs/helpers/ThemeManager.test.js +421 -34
  23. package/dist/cjs/helpers/ThemeManager.test.js.map +2 -2
  24. package/dist/cjs/helpers/{getTokens.js → ThemeManagerContext.js} +8 -8
  25. package/dist/cjs/helpers/ThemeManagerContext.js.map +7 -0
  26. package/dist/cjs/helpers/createPropMapper.js +4 -4
  27. package/dist/cjs/helpers/createPropMapper.js.map +2 -2
  28. package/dist/cjs/helpers/extendStaticConfig.js +2 -4
  29. package/dist/cjs/helpers/extendStaticConfig.js.map +2 -2
  30. package/dist/cjs/helpers/{assignNativePropsToWeb.native.js → getBoundingClientRect.js} +15 -8
  31. package/dist/cjs/helpers/getBoundingClientRect.js.map +7 -0
  32. package/dist/cjs/{hooks/useConstant.js → helpers/getRect.js} +14 -17
  33. package/dist/cjs/helpers/getRect.js.map +7 -0
  34. package/dist/cjs/helpers/getSplitStyles.js +82 -85
  35. package/dist/cjs/helpers/getSplitStyles.js.map +3 -3
  36. package/dist/cjs/helpers/getThemeCSSRules.js +6 -2
  37. package/dist/cjs/helpers/getThemeCSSRules.js.map +2 -2
  38. package/dist/cjs/helpers/insertStyleRule.js +1 -1
  39. package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
  40. package/dist/cjs/helpers/mergeTransform.js +11 -8
  41. package/dist/cjs/helpers/mergeTransform.js.map +2 -2
  42. package/dist/cjs/helpers/pseudoDescriptors.js +1 -0
  43. package/dist/cjs/helpers/pseudoDescriptors.js.map +2 -2
  44. package/dist/cjs/helpers/themeable.js +9 -9
  45. package/dist/cjs/helpers/themeable.js.map +2 -2
  46. package/dist/cjs/hooks/useElementLayout.js +4 -12
  47. package/dist/cjs/hooks/useElementLayout.js.map +2 -2
  48. package/dist/cjs/hooks/useMedia.js +2 -1
  49. package/dist/cjs/hooks/useMedia.js.map +2 -2
  50. package/dist/cjs/hooks/useTheme.js +114 -156
  51. package/dist/cjs/hooks/useTheme.js.map +3 -3
  52. package/dist/cjs/hooks/{useIsMounted.js → useThemeName.js} +23 -14
  53. package/dist/cjs/hooks/useThemeName.js.map +7 -0
  54. package/dist/cjs/index.js +2 -5
  55. package/dist/cjs/index.js.map +2 -2
  56. package/dist/cjs/setupReactNative.js +20 -7
  57. package/dist/cjs/setupReactNative.js.map +2 -2
  58. package/dist/cjs/styled.js +2 -19
  59. package/dist/cjs/styled.js.map +2 -2
  60. package/dist/cjs/types.js.map +1 -1
  61. package/dist/cjs/updateTheme.js +9 -9
  62. package/dist/cjs/updateTheme.js.map +2 -2
  63. package/dist/cjs/views/TamaguiProvider.js +3 -3
  64. package/dist/cjs/views/TamaguiProvider.js.map +2 -2
  65. package/dist/cjs/views/Theme.js +39 -28
  66. package/dist/cjs/views/Theme.js.map +3 -3
  67. package/dist/cjs/views/ThemeProvider.js +8 -33
  68. package/dist/cjs/views/ThemeProvider.js.map +3 -3
  69. package/dist/esm/addTheme.js +7 -10
  70. package/dist/esm/addTheme.js.map +3 -3
  71. package/dist/esm/config.js +8 -3
  72. package/dist/esm/config.js.map +2 -2
  73. package/dist/esm/contexts/ButtonNestingContext.js +6 -0
  74. package/dist/esm/contexts/ButtonNestingContext.js.map +7 -0
  75. package/dist/esm/createComponent.js +65 -70
  76. package/dist/esm/createComponent.js.map +3 -3
  77. package/dist/esm/createTamagui.js +13 -12
  78. package/dist/esm/createTamagui.js.map +2 -2
  79. package/dist/esm/createTokens.js.map +2 -2
  80. package/dist/esm/createTokens.test.js +26 -0
  81. package/dist/esm/createTokens.test.js.map +7 -0
  82. package/dist/esm/createVariable.js +4 -9
  83. package/dist/esm/createVariable.js.map +2 -2
  84. package/dist/esm/createVariable.test.js +6 -0
  85. package/dist/esm/createVariable.test.js.map +7 -0
  86. package/dist/esm/createVariables.js +6 -7
  87. package/dist/esm/createVariables.js.map +2 -2
  88. package/dist/esm/helpers/ThemeManager.js +140 -144
  89. package/dist/esm/helpers/ThemeManager.js.map +3 -3
  90. package/dist/esm/helpers/ThemeManager.test.js +421 -34
  91. package/dist/esm/helpers/ThemeManager.test.js.map +2 -2
  92. package/dist/esm/helpers/ThemeManagerContext.js +6 -0
  93. package/dist/esm/helpers/ThemeManagerContext.js.map +7 -0
  94. package/dist/esm/helpers/createPropMapper.js +4 -4
  95. package/dist/esm/helpers/createPropMapper.js.map +2 -2
  96. package/dist/esm/helpers/extendStaticConfig.js +2 -4
  97. package/dist/esm/helpers/extendStaticConfig.js.map +2 -2
  98. package/dist/esm/helpers/getBoundingClientRect.js +13 -0
  99. package/dist/esm/helpers/getBoundingClientRect.js.map +7 -0
  100. package/dist/esm/helpers/getRect.js +12 -0
  101. package/dist/esm/helpers/getRect.js.map +7 -0
  102. package/dist/esm/helpers/getSplitStyles.js +90 -87
  103. package/dist/esm/helpers/getSplitStyles.js.map +3 -3
  104. package/dist/esm/helpers/getThemeCSSRules.js +6 -2
  105. package/dist/esm/helpers/getThemeCSSRules.js.map +2 -2
  106. package/dist/esm/helpers/insertStyleRule.js +1 -1
  107. package/dist/esm/helpers/insertStyleRule.js.map +2 -2
  108. package/dist/esm/helpers/mergeTransform.js +8 -6
  109. package/dist/esm/helpers/mergeTransform.js.map +2 -2
  110. package/dist/esm/helpers/pseudoDescriptors.js +1 -0
  111. package/dist/esm/helpers/pseudoDescriptors.js.map +2 -2
  112. package/dist/esm/helpers/themeable.js +9 -9
  113. package/dist/esm/helpers/themeable.js.map +2 -2
  114. package/dist/esm/hooks/useElementLayout.js +2 -9
  115. package/dist/esm/hooks/useElementLayout.js.map +2 -2
  116. package/dist/esm/hooks/useMedia.js +3 -2
  117. package/dist/esm/hooks/useMedia.js.map +2 -2
  118. package/dist/esm/hooks/useTheme.js +114 -159
  119. package/dist/esm/hooks/useTheme.js.map +3 -3
  120. package/dist/esm/hooks/useThemeName.js +25 -0
  121. package/dist/esm/hooks/useThemeName.js.map +7 -0
  122. package/dist/esm/index.js +3 -5
  123. package/dist/esm/index.js.map +2 -2
  124. package/dist/esm/setupReactNative.js +18 -6
  125. package/dist/esm/setupReactNative.js.map +2 -2
  126. package/dist/esm/styled.js +3 -20
  127. package/dist/esm/styled.js.map +2 -2
  128. package/dist/esm/updateTheme.js +9 -9
  129. package/dist/esm/updateTheme.js.map +2 -2
  130. package/dist/esm/views/TamaguiProvider.js +4 -4
  131. package/dist/esm/views/TamaguiProvider.js.map +2 -2
  132. package/dist/esm/views/Theme.js +40 -29
  133. package/dist/esm/views/Theme.js.map +3 -3
  134. package/dist/esm/views/ThemeProvider.js +8 -27
  135. package/dist/esm/views/ThemeProvider.js.map +2 -2
  136. package/package.json +12 -12
  137. package/src/__snapshots__/createTokens.test.ts.snap +877 -0
  138. package/src/addTheme.ts +9 -12
  139. package/src/config.ts +10 -2
  140. package/src/contexts/ButtonNestingContext.tsx +3 -0
  141. package/src/createComponent.tsx +117 -108
  142. package/src/createTamagui.ts +16 -14
  143. package/src/createTokens.test.ts +29 -0
  144. package/src/createTokens.ts +1 -1
  145. package/src/createVariable.test.ts +7 -0
  146. package/src/createVariable.ts +4 -10
  147. package/src/createVariables.ts +7 -7
  148. package/src/helpers/ThemeManager.test.tsx +480 -0
  149. package/src/helpers/ThemeManager.tsx +171 -166
  150. package/src/helpers/ThemeManagerContext.tsx +5 -0
  151. package/src/helpers/createPropMapper.ts +4 -4
  152. package/src/helpers/extendStaticConfig.ts +4 -4
  153. package/src/helpers/getBoundingClientRect.tsx +7 -0
  154. package/src/helpers/getRect.tsx +8 -0
  155. package/src/helpers/getSplitStyles.tsx +98 -93
  156. package/src/helpers/getThemeCSSRules.ts +9 -2
  157. package/src/helpers/insertStyleRule.tsx +2 -2
  158. package/src/helpers/mergeTransform.ts +13 -6
  159. package/src/helpers/pseudoDescriptors.ts +1 -0
  160. package/src/helpers/themeable.tsx +17 -9
  161. package/src/hooks/useElementLayout.tsx +3 -8
  162. package/src/hooks/useMedia.tsx +3 -3
  163. package/src/hooks/useTheme.tsx +138 -211
  164. package/src/hooks/useThemeName.tsx +25 -0
  165. package/src/index.ts +3 -4
  166. package/src/setupReactNative.ts +16 -5
  167. package/src/styled.tsx +4 -23
  168. package/src/types.tsx +42 -17
  169. package/src/updateTheme.ts +12 -9
  170. package/src/views/TamaguiProvider.tsx +5 -5
  171. package/src/views/Theme.tsx +48 -39
  172. package/src/views/ThemeProvider.tsx +11 -33
  173. package/types/Tamagui.d.ts +1 -1
  174. package/types/addTheme.d.ts +23 -2
  175. package/types/config.d.ts +0 -1
  176. package/types/contexts/ButtonNestingContext.d.ts +3 -0
  177. package/types/createTokens.test.d.ts +2 -0
  178. package/types/createVariable.d.ts +2 -2
  179. package/types/createVariable.test.d.ts +2 -0
  180. package/types/helpers/ThemeManager.d.ts +20 -30
  181. package/types/helpers/ThemeManager.test.d.ts +2 -0
  182. package/types/helpers/ThemeManagerContext.d.ts +4 -0
  183. package/types/helpers/getBoundingClientRect.d.ts +2 -0
  184. package/types/helpers/getRect.d.ts +9 -0
  185. package/types/helpers/insertStyleRule.d.ts +1 -1
  186. package/types/helpers/mergeTransform.d.ts +5 -3
  187. package/types/helpers/themeable.d.ts +3 -0
  188. package/types/hooks/useElementLayout.d.ts +0 -8
  189. package/types/hooks/useTheme.d.ts +10 -20
  190. package/types/hooks/useThemeName.d.ts +5 -0
  191. package/types/index.d.ts +3 -4
  192. package/types/setupReactNative.d.ts +4 -2
  193. package/types/types.d.ts +35 -10
  194. package/types/updateTheme.d.ts +23 -2
  195. package/types/views/Theme.d.ts +3 -4
  196. package/dist/cjs/constants/platform.js +0 -74
  197. package/dist/cjs/constants/platform.js.map +0 -7
  198. package/dist/cjs/constants/platform.native.js +0 -62
  199. package/dist/cjs/constants/platform.native.js.map +0 -7
  200. package/dist/cjs/helpers/assignNativePropsToWeb.js +0 -188
  201. package/dist/cjs/helpers/assignNativePropsToWeb.js.map +0 -7
  202. package/dist/cjs/helpers/assignNativePropsToWeb.native.js.map +0 -7
  203. package/dist/cjs/helpers/calc.js +0 -71
  204. package/dist/cjs/helpers/calc.js.map +0 -7
  205. package/dist/cjs/helpers/getFont.js +0 -66
  206. package/dist/cjs/helpers/getFont.js.map +0 -7
  207. package/dist/cjs/helpers/getStackSize.js +0 -46
  208. package/dist/cjs/helpers/getStackSize.js.map +0 -7
  209. package/dist/cjs/helpers/getTokens.js.map +0 -7
  210. package/dist/cjs/helpers/startTransition.js +0 -36
  211. package/dist/cjs/helpers/startTransition.js.map +0 -7
  212. package/dist/cjs/helpers/validate.js +0 -2
  213. package/dist/cjs/helpers/validate.js.map +0 -7
  214. package/dist/cjs/hooks/useConstant.js.map +0 -7
  215. package/dist/cjs/hooks/useIsMounted.js.map +0 -7
  216. package/dist/cjs/hooks/usePressable.js +0 -36
  217. package/dist/cjs/hooks/usePressable.js.map +0 -7
  218. package/dist/cjs/hooks/useUnmountEffect.js.map +0 -7
  219. package/dist/cjs/injectStyles.js +0 -40
  220. package/dist/cjs/injectStyles.js.map +0 -7
  221. package/dist/cjs/react-native.js +0 -22
  222. package/dist/cjs/react-native.js.map +0 -7
  223. package/dist/esm/constants/platform.js +0 -39
  224. package/dist/esm/constants/platform.js.map +0 -7
  225. package/dist/esm/constants/platform.native.js +0 -28
  226. package/dist/esm/constants/platform.native.js.map +0 -7
  227. package/dist/esm/helpers/assignNativePropsToWeb.js +0 -164
  228. package/dist/esm/helpers/assignNativePropsToWeb.js.map +0 -7
  229. package/dist/esm/helpers/assignNativePropsToWeb.native.js +0 -6
  230. package/dist/esm/helpers/assignNativePropsToWeb.native.js.map +0 -7
  231. package/dist/esm/helpers/calc.js +0 -47
  232. package/dist/esm/helpers/calc.js.map +0 -7
  233. package/dist/esm/helpers/getFont.js +0 -42
  234. package/dist/esm/helpers/getFont.js.map +0 -7
  235. package/dist/esm/helpers/getStackSize.js +0 -22
  236. package/dist/esm/helpers/getStackSize.js.map +0 -7
  237. package/dist/esm/helpers/getTokens.js +0 -6
  238. package/dist/esm/helpers/getTokens.js.map +0 -7
  239. package/dist/esm/helpers/startTransition.js +0 -6
  240. package/dist/esm/helpers/startTransition.js.map +0 -7
  241. package/dist/esm/helpers/validate.js +0 -1
  242. package/dist/esm/helpers/validate.js.map +0 -7
  243. package/dist/esm/hooks/useConstant.js +0 -15
  244. package/dist/esm/hooks/useConstant.js.map +0 -7
  245. package/dist/esm/hooks/useIsMounted.js +0 -16
  246. package/dist/esm/hooks/useIsMounted.js.map +0 -7
  247. package/dist/esm/hooks/usePressable.js +0 -12
  248. package/dist/esm/hooks/usePressable.js.map +0 -7
  249. package/dist/esm/hooks/useUnmountEffect.js +0 -8
  250. package/dist/esm/hooks/useUnmountEffect.js.map +0 -7
  251. package/dist/esm/injectStyles.js +0 -16
  252. package/dist/esm/injectStyles.js.map +0 -7
  253. package/dist/esm/react-native.js +0 -3
  254. package/dist/esm/react-native.js.map +0 -7
  255. package/src/contexts/ButtonInsideButtonContext.tsx +0 -3
  256. package/src/contexts/ThemeContext.tsx +0 -5
  257. package/src/helpers/areEqualSets.tsx +0 -9
  258. package/src/views/ThemeInverse.tsx +0 -43
  259. package/src/views/ThemeReset.tsx +0 -43
  260. package/types/constants/platform.d.ts +0 -13
  261. package/types/constants/platform.native.d.ts +0 -13
  262. package/types/contexts/ButtonInsideButtonContext.d.ts +0 -3
  263. package/types/contexts/ThemeContext.d.ts +0 -7
  264. package/types/helpers/areEqualSets.d.ts +0 -2
  265. package/types/helpers/assignNativePropsToWeb.d.ts +0 -2
  266. package/types/helpers/assignNativePropsToWeb.native.d.ts +0 -2
  267. package/types/helpers/calc.d.ts +0 -1
  268. package/types/helpers/getFont.d.ts +0 -3
  269. package/types/helpers/getStackSize.d.ts +0 -8
  270. package/types/helpers/getTokens.d.ts +0 -2
  271. package/types/helpers/startTransition.d.ts +0 -3
  272. package/types/helpers/validate.d.ts +0 -1
  273. package/types/hooks/useConstant.d.ts +0 -2
  274. package/types/hooks/useIsMounted.d.ts +0 -3
  275. package/types/hooks/useMedia.test.d.ts +0 -1
  276. package/types/hooks/usePressable.d.ts +0 -3
  277. package/types/hooks/usePressablePressResponder.d.ts +0 -84
  278. package/types/hooks/useUnmountEffect.d.ts +0 -2
  279. package/types/injectStyles.d.ts +0 -7
  280. package/types/react-native.d.ts +0 -8
  281. package/types/views/AbsoluteFill.d.ts +0 -5
  282. package/types/views/AbsoluteFill.native.d.ts +0 -3
  283. package/types/views/ThemeInverse.d.ts +0 -9
  284. package/types/views/ThemeReset.d.ts +0 -4
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,10 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
19
  var ThemeProvider_exports = {};
26
20
  __export(ThemeProvider_exports, {
@@ -29,23 +23,14 @@ __export(ThemeProvider_exports, {
29
23
  module.exports = __toCommonJS(ThemeProvider_exports);
30
24
  var import_jsx_runtime = require("react/jsx-runtime");
31
25
  var import_constants = require("@tamagui/constants");
32
- var import_react = __toESM(require("react"));
33
- var import_config = require("../config");
26
+ var import_react = require("react");
34
27
  var import_constants2 = require("../constants/constants");
35
- var import_ThemeContext = require("../contexts/ThemeContext");
36
28
  var import_Theme = require("./Theme");
37
- import_react.default["createElement"];
38
29
  const ThemeProvider = (props) => {
39
- if (process.env.NODE_ENV === "development") {
40
- if (!(0, import_config.getHasConfigured)()) {
41
- throw new Error(`Missing configureThemes() call, add to your root file`);
42
- }
43
- }
44
30
  if (import_constants.isClient) {
45
31
  (0, import_react.useLayoutEffect)(() => {
46
- if (props.disableRootThemeClass) {
32
+ if (props.disableRootThemeClass)
47
33
  return;
48
- }
49
34
  const cn = `${import_constants2.THEME_CLASSNAME_PREFIX}${props.defaultTheme}`;
50
35
  const target = props.themeClassNameOnRoot ? document.documentElement : document.body;
51
36
  target.classList.add(cn);
@@ -54,22 +39,12 @@ const ThemeProvider = (props) => {
54
39
  };
55
40
  }, [props.defaultTheme, props.disableRootThemeClass, props.themeClassNameOnRoot]);
56
41
  }
57
- const themeContext = (0, import_react.useMemo)(() => {
58
- return {
59
- get themes() {
60
- return (0, import_config.getConfig)().themes;
61
- },
62
- defaultTheme: props.defaultTheme
63
- };
64
- }, [props.defaultTheme]);
65
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ThemeContext.ThemeContext.Provider, {
66
- value: themeContext,
67
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Theme.Theme, {
68
- className: props.className,
69
- name: props.defaultTheme,
70
- disableThemeClass: props.disableRootThemeClass,
71
- children: props.children
72
- })
42
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Theme.Theme, {
43
+ className: props.className,
44
+ name: props.defaultTheme,
45
+ disableThemeClass: props.disableRootThemeClass,
46
+ _isRoot: true,
47
+ children: props.children
73
48
  });
74
49
  };
75
50
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/views/ThemeProvider.tsx"],
4
- "sourcesContent": ["import { isClient } from '@tamagui/constants'\nimport React, { useLayoutEffect, useMemo } from 'react'\n\nimport { getConfig, getHasConfigured } from '../config'\nimport { THEME_CLASSNAME_PREFIX } from '../constants/constants'\nimport { ThemeContext } from '../contexts/ThemeContext'\nimport { Theme } from './Theme'\n\n// bugfix esbuild strips react jsx: 'preserve'\nReact['createElement']\n\nexport type ThemeProviderProps = {\n className?: string\n defaultTheme: string\n disableRootThemeClass?: boolean\n themeClassNameOnRoot?: boolean\n children?: any\n reset?: boolean\n}\n\nexport const ThemeProvider = (props: ThemeProviderProps) => {\n if (process.env.NODE_ENV === 'development') {\n if (!getHasConfigured()) {\n throw new Error(`Missing configureThemes() call, add to your root file`)\n }\n }\n\n // ensure theme is attached to root body node as well to work with modals by default\n if (isClient) {\n useLayoutEffect(() => {\n if (props.disableRootThemeClass) {\n return\n }\n const cn = `${THEME_CLASSNAME_PREFIX}${props.defaultTheme}`\n const target = props.themeClassNameOnRoot ? document.documentElement : document.body\n target.classList.add(cn)\n return () => {\n target.classList.remove(cn)\n }\n }, [props.defaultTheme, props.disableRootThemeClass, props.themeClassNameOnRoot])\n }\n\n const themeContext = useMemo(() => {\n return {\n get themes() {\n return getConfig().themes\n },\n defaultTheme: props.defaultTheme,\n }\n }, [props.defaultTheme])\n\n return (\n <ThemeContext.Provider value={themeContext}>\n <Theme\n className={props.className}\n name={props.defaultTheme}\n disableThemeClass={props.disableRootThemeClass}\n >\n {props.children}\n </Theme>\n </ThemeContext.Provider>\n )\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqDM;AArDN,uBAAyB;AACzB,mBAAgD;AAEhD,oBAA4C;AAC5C,IAAAA,oBAAuC;AACvC,0BAA6B;AAC7B,mBAAsB;AAGtB,aAAAC,QAAM;AAWC,MAAM,gBAAgB,CAAC,UAA8B;AAC1D,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,KAAC,gCAAiB,GAAG;AACvB,YAAM,IAAI,MAAM,uDAAuD;AAAA,IACzE;AAAA,EACF;AAGA,MAAI,2BAAU;AACZ,sCAAgB,MAAM;AACpB,UAAI,MAAM,uBAAuB;AAC/B;AAAA,MACF;AACA,YAAM,KAAK,GAAG,2CAAyB,MAAM;AAC7C,YAAM,SAAS,MAAM,uBAAuB,SAAS,kBAAkB,SAAS;AAChF,aAAO,UAAU,IAAI,EAAE;AACvB,aAAO,MAAM;AACX,eAAO,UAAU,OAAO,EAAE;AAAA,MAC5B;AAAA,IACF,GAAG,CAAC,MAAM,cAAc,MAAM,uBAAuB,MAAM,oBAAoB,CAAC;AAAA,EAClF;AAEA,QAAM,mBAAe,sBAAQ,MAAM;AACjC,WAAO;AAAA,MACL,IAAI,SAAS;AACX,mBAAO,yBAAU,EAAE;AAAA,MACrB;AAAA,MACA,cAAc,MAAM;AAAA,IACtB;AAAA,EACF,GAAG,CAAC,MAAM,YAAY,CAAC;AAEvB,SACE,4CAAC,iCAAa,UAAb;AAAA,IAAsB,OAAO;AAAA,IAC5B,sDAAC;AAAA,MACC,WAAW,MAAM;AAAA,MACjB,MAAM,MAAM;AAAA,MACZ,mBAAmB,MAAM;AAAA,MAExB,gBAAM;AAAA,KACT;AAAA,GACF;AAEJ;",
6
- "names": ["import_constants", "React"]
4
+ "sourcesContent": ["import { isClient } from '@tamagui/constants'\nimport { useLayoutEffect } from 'react'\n\nimport { THEME_CLASSNAME_PREFIX } from '../constants/constants'\nimport { Theme } from './Theme'\n\nexport type ThemeProviderProps = {\n className?: string\n defaultTheme: string\n disableRootThemeClass?: boolean\n themeClassNameOnRoot?: boolean\n children?: any\n reset?: boolean\n}\n\nexport const ThemeProvider = (props: ThemeProviderProps) => {\n // ensure theme is attached to root body node as well to work with modals by default\n if (isClient) {\n useLayoutEffect(() => {\n if (props.disableRootThemeClass) return\n const cn = `${THEME_CLASSNAME_PREFIX}${props.defaultTheme}`\n const target = props.themeClassNameOnRoot ? document.documentElement : document.body\n target.classList.add(cn)\n return () => {\n target.classList.remove(cn)\n }\n }, [props.defaultTheme, props.disableRootThemeClass, props.themeClassNameOnRoot])\n }\n\n return (\n <Theme\n className={props.className}\n name={props.defaultTheme}\n disableThemeClass={props.disableRootThemeClass}\n // @ts-expect-error\n _isRoot\n >\n {props.children}\n </Theme>\n )\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA8BI;AA9BJ,uBAAyB;AACzB,mBAAgC;AAEhC,IAAAA,oBAAuC;AACvC,mBAAsB;AAWf,MAAM,gBAAgB,CAAC,UAA8B;AAE1D,MAAI,2BAAU;AACZ,sCAAgB,MAAM;AACpB,UAAI,MAAM;AAAuB;AACjC,YAAM,KAAK,GAAG,2CAAyB,MAAM;AAC7C,YAAM,SAAS,MAAM,uBAAuB,SAAS,kBAAkB,SAAS;AAChF,aAAO,UAAU,IAAI,EAAE;AACvB,aAAO,MAAM;AACX,eAAO,UAAU,OAAO,EAAE;AAAA,MAC5B;AAAA,IACF,GAAG,CAAC,MAAM,cAAc,MAAM,uBAAuB,MAAM,oBAAoB,CAAC;AAAA,EAClF;AAEA,SACE,4CAAC;AAAA,IACC,WAAW,MAAM;AAAA,IACjB,MAAM,MAAM;AAAA,IACZ,mBAAmB,MAAM;AAAA,IAEzB,SAAO;AAAA,IAEN,gBAAM;AAAA,GACT;AAEJ;",
6
+ "names": ["import_constants"]
7
7
  }
@@ -2,22 +2,19 @@ import { isWeb } from "@tamagui/constants";
2
2
  import { getConfig, updateConfig } from "./config";
3
3
  import { getThemeCSSRules } from "./helpers/getThemeCSSRules";
4
4
  import { ensureThemeVariable, proxyThemeToParents } from "./helpers/themes";
5
- function addTheme({
6
- name: themeName,
7
- theme: themeIn,
8
- insertCSS,
9
- update
10
- }) {
5
+ function addTheme(props) {
11
6
  var _a;
12
7
  const config = getConfig();
13
8
  if (process.env.NODE_ENV === "development") {
14
9
  if (!config) {
15
- throw new Error(`Must run createTamagui once before loading theme`);
10
+ throw new Error(`No config`);
16
11
  }
17
- if (!update && config.themes[themeName]) {
18
- throw new Error(`Already defined theme "${themeName}", use updateTheme to change values`);
12
+ const theme2 = config.themes[props.name];
13
+ if (!props.update && theme2) {
14
+ return { theme: theme2 };
19
15
  }
20
16
  }
17
+ const { name: themeName, theme: themeIn, insertCSS } = props;
21
18
  const theme = { ...themeIn };
22
19
  for (const key in theme) {
23
20
  ensureThemeVariable(theme, key);
@@ -33,7 +30,7 @@ function addTheme({
33
30
  names: [themeName],
34
31
  theme
35
32
  });
36
- const id = `tamagui_theme_style_${themeName}`;
33
+ const id = `t_theme_style_${themeName}`;
37
34
  const existing = document.querySelector(`#${id}`);
38
35
  const style = document.createElement("style");
39
36
  style.id = id;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/addTheme.ts"],
4
- "sourcesContent": ["import { isWeb } from '@tamagui/constants'\n\nimport { getConfig, updateConfig } from './config'\nimport { getThemeCSSRules } from './helpers/getThemeCSSRules'\nimport { ensureThemeVariable, proxyThemeToParents } from './helpers/themes'\nimport { ThemeDefinition, ThemeParsed } from './types'\n\nexport function addTheme({\n name: themeName,\n theme: themeIn,\n insertCSS,\n update,\n}: {\n name: string\n theme: ThemeDefinition\n insertCSS?: boolean\n update?: boolean\n}) {\n const config = getConfig()\n if (process.env.NODE_ENV === 'development') {\n if (!config) {\n throw new Error(`Must run createTamagui once before loading theme`)\n }\n if (!update && config.themes[themeName]) {\n throw new Error(`Already defined theme \"${themeName}\", use updateTheme to change values`)\n }\n }\n\n const theme = { ...themeIn } as ThemeParsed\n for (const key in theme) {\n ensureThemeVariable(theme, key)\n }\n\n const themeProxied = proxyThemeToParents(themeName, theme, config.themes)\n config.themes[themeName] = themeProxied\n\n let cssRules: string[] = []\n\n if (isWeb) {\n if (insertCSS) {\n cssRules = getThemeCSSRules({\n // @ts-ignore this works but should be fixed types\n config,\n themeName,\n names: [themeName],\n theme,\n })\n const id = `tamagui_theme_style_${themeName}`\n const existing = document.querySelector(`#${id}`)\n const style = document.createElement('style')\n style.id = id\n style.appendChild(document.createTextNode(cssRules.join('\\n')))\n document.head.appendChild(style)\n if (existing) {\n existing.parentElement?.removeChild(existing)\n }\n }\n }\n\n updateConfig('themes', { ...config.themes, [themeName]: themeProxied })\n\n // trigger updates in components\n\n return {\n theme: themeProxied,\n cssRules,\n }\n}\n"],
5
- "mappings": "AAAA,SAAS,aAAa;AAEtB,SAAS,WAAW,oBAAoB;AACxC,SAAS,wBAAwB;AACjC,SAAS,qBAAqB,2BAA2B;AAGlD,SAAS,SAAS;AAAA,EACvB,MAAM;AAAA,EACN,OAAO;AAAA,EACP;AAAA,EACA;AACF,GAKG;AAjBH;AAkBE,QAAM,SAAS,UAAU;AACzB,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI,MAAM,kDAAkD;AAAA,IACpE;AACA,QAAI,CAAC,UAAU,OAAO,OAAO,YAAY;AACvC,YAAM,IAAI,MAAM,0BAA0B,8CAA8C;AAAA,IAC1F;AAAA,EACF;AAEA,QAAM,QAAQ,EAAE,GAAG,QAAQ;AAC3B,aAAW,OAAO,OAAO;AACvB,wBAAoB,OAAO,GAAG;AAAA,EAChC;AAEA,QAAM,eAAe,oBAAoB,WAAW,OAAO,OAAO,MAAM;AACxE,SAAO,OAAO,aAAa;AAE3B,MAAI,WAAqB,CAAC;AAE1B,MAAI,OAAO;AACT,QAAI,WAAW;AACb,iBAAW,iBAAiB;AAAA,QAE1B;AAAA,QACA;AAAA,QACA,OAAO,CAAC,SAAS;AAAA,QACjB;AAAA,MACF,CAAC;AACD,YAAM,KAAK,uBAAuB;AAClC,YAAM,WAAW,SAAS,cAAc,IAAI,IAAI;AAChD,YAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,YAAM,KAAK;AACX,YAAM,YAAY,SAAS,eAAe,SAAS,KAAK,IAAI,CAAC,CAAC;AAC9D,eAAS,KAAK,YAAY,KAAK;AAC/B,UAAI,UAAU;AACZ,uBAAS,kBAAT,mBAAwB,YAAY;AAAA,MACtC;AAAA,IACF;AAAA,EACF;AAEA,eAAa,UAAU,EAAE,GAAG,OAAO,QAAQ,CAAC,YAAY,aAAa,CAAC;AAItE,SAAO;AAAA,IACL,OAAO;AAAA,IACP;AAAA,EACF;AACF;",
6
- "names": []
4
+ "sourcesContent": ["import { isWeb } from '@tamagui/constants'\n\nimport { getConfig, updateConfig } from './config'\nimport { getThemeCSSRules } from './helpers/getThemeCSSRules'\nimport { ensureThemeVariable, proxyThemeToParents } from './helpers/themes'\nimport { ThemeDefinition, ThemeParsed } from './types'\n\nexport function addTheme(props: {\n name: string\n theme: Partial<Record<keyof ThemeDefinition, any>>\n insertCSS?: boolean\n update?: boolean\n}) {\n const config = getConfig()\n\n if (process.env.NODE_ENV === 'development') {\n if (!config) {\n throw new Error(`No config`)\n }\n const theme = config.themes[props.name]\n if (!props.update && theme) {\n return { theme }\n }\n }\n\n const { name: themeName, theme: themeIn, insertCSS } = props\n const theme = { ...themeIn } as ThemeParsed\n for (const key in theme) {\n ensureThemeVariable(theme, key)\n }\n\n const themeProxied = proxyThemeToParents(themeName, theme, config.themes)\n config.themes[themeName] = themeProxied\n\n let cssRules: string[] = []\n\n if (isWeb) {\n if (insertCSS) {\n cssRules = getThemeCSSRules({\n // @ts-ignore this works but should be fixed types\n config,\n themeName,\n names: [themeName],\n theme,\n })\n const id = `t_theme_style_${themeName}`\n const existing = document.querySelector(`#${id}`)\n const style = document.createElement('style')\n style.id = id\n style.appendChild(document.createTextNode(cssRules.join('\\n')))\n document.head.appendChild(style)\n if (existing) {\n existing.parentElement?.removeChild(existing)\n }\n }\n }\n\n updateConfig('themes', { ...config.themes, [themeName]: themeProxied })\n\n // trigger updates in components\n return {\n theme: themeProxied,\n cssRules,\n }\n}\n"],
5
+ "mappings": "AAAA,SAAS,aAAa;AAEtB,SAAS,WAAW,oBAAoB;AACxC,SAAS,wBAAwB;AACjC,SAAS,qBAAqB,2BAA2B;AAGlD,SAAS,SAAS,OAKtB;AAZH;AAaE,QAAM,SAAS,UAAU;AAEzB,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI,MAAM,WAAW;AAAA,IAC7B;AACA,UAAMA,SAAQ,OAAO,OAAO,MAAM;AAClC,QAAI,CAAC,MAAM,UAAUA,QAAO;AAC1B,aAAO,EAAE,OAAAA,OAAM;AAAA,IACjB;AAAA,EACF;AAEA,QAAM,EAAE,MAAM,WAAW,OAAO,SAAS,UAAU,IAAI;AACvD,QAAM,QAAQ,EAAE,GAAG,QAAQ;AAC3B,aAAW,OAAO,OAAO;AACvB,wBAAoB,OAAO,GAAG;AAAA,EAChC;AAEA,QAAM,eAAe,oBAAoB,WAAW,OAAO,OAAO,MAAM;AACxE,SAAO,OAAO,aAAa;AAE3B,MAAI,WAAqB,CAAC;AAE1B,MAAI,OAAO;AACT,QAAI,WAAW;AACb,iBAAW,iBAAiB;AAAA,QAE1B;AAAA,QACA;AAAA,QACA,OAAO,CAAC,SAAS;AAAA,QACjB;AAAA,MACF,CAAC;AACD,YAAM,KAAK,iBAAiB;AAC5B,YAAM,WAAW,SAAS,cAAc,IAAI,IAAI;AAChD,YAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,YAAM,KAAK;AACX,YAAM,YAAY,SAAS,eAAe,SAAS,KAAK,IAAI,CAAC,CAAC;AAC9D,eAAS,KAAK,YAAY,KAAK;AAC/B,UAAI,UAAU;AACZ,uBAAS,kBAAT,mBAAwB,YAAY;AAAA,MACtC;AAAA,IACF;AAAA,EACF;AAEA,eAAa,UAAU,EAAE,GAAG,OAAO,QAAQ,CAAC,YAAY,aAAa,CAAC;AAGtE,SAAO;AAAA,IACL,OAAO;AAAA,IACP;AAAA,EACF;AACF;",
6
+ "names": ["theme"]
7
7
  }
@@ -13,8 +13,14 @@ const setConfigFont = (name, font, fontParsed) => {
13
13
  Object.assign(conf.fonts, { [name]: font });
14
14
  Object.assign(conf.fontsParsed, { [`$${name}`]: fontParsed });
15
15
  };
16
- const getHasConfigured = () => !!conf;
17
- const getConfig = () => conf;
16
+ const getConfig = () => {
17
+ if (!conf) {
18
+ throw new Error(
19
+ process.env.NODE_ENV === "development" ? `Missing tamagui config, you either have a duplicate config, or haven't set it up. Be sure createTamagui is called before rendering.` : `Err0`
20
+ );
21
+ }
22
+ return conf;
23
+ };
18
24
  const getTokens = (prefixed) => prefixed ? conf.tokensParsed : conf.tokens;
19
25
  const useTokens = getTokens;
20
26
  const getThemes = () => conf.themes;
@@ -32,7 +38,6 @@ const updateConfig = (key, value) => {
32
38
  export {
33
39
  configListeners,
34
40
  getConfig,
35
- getHasConfigured,
36
41
  getThemes,
37
42
  getTokens,
38
43
  onConfiguredOnce,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/config.ts"],
4
- "sourcesContent": ["import { ConfigListener, TamaguiInternalConfig, ThemeParsed, Tokens } from './types'\n\nlet conf: TamaguiInternalConfig | null\n\nexport const setConfig = (next: TamaguiInternalConfig) => {\n conf = next\n if (configListeners.size) {\n configListeners.forEach((cb) => cb(next))\n }\n}\n\nexport const setConfigFont = (name: string, font: any, fontParsed: any) => {\n if (process.env.NODE_ENV === 'development') {\n if (!conf) throw new Error(`Haven't called createTamagui yet`)\n }\n Object.assign(conf!.fonts, { [name]: font })\n Object.assign(conf!.fontsParsed, { [`$${name}`]: fontParsed })\n}\n\nexport const getHasConfigured = () => !!conf\nexport const getConfig = () => conf!\nexport const getTokens = (prefixed?: boolean): Tokens =>\n prefixed ? conf!.tokensParsed : conf!.tokens\n\n/**\n * Note: this is the same as `getTokens`\n */\nexport const useTokens = getTokens\n\nexport const getThemes = () => conf!.themes\n\nexport const configListeners = new Set<ConfigListener>()\n\nexport const onConfiguredOnce = (cb: ConfigListener) => {\n if (conf) {\n cb(conf)\n } else {\n configListeners.add(cb)\n }\n}\n\nexport const updateConfig = (key: string, value: any) => {\n Object.assign(key, value)\n}\n"],
5
- "mappings": "AAEA,IAAI;AAEG,MAAM,YAAY,CAAC,SAAgC;AACxD,SAAO;AACP,MAAI,gBAAgB,MAAM;AACxB,oBAAgB,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC;AAAA,EAC1C;AACF;AAEO,MAAM,gBAAgB,CAAC,MAAc,MAAW,eAAoB;AACzE,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,CAAC;AAAM,YAAM,IAAI,MAAM,kCAAkC;AAAA,EAC/D;AACA,SAAO,OAAO,KAAM,OAAO,EAAE,CAAC,OAAO,KAAK,CAAC;AAC3C,SAAO,OAAO,KAAM,aAAa,EAAE,CAAC,IAAI,SAAS,WAAW,CAAC;AAC/D;AAEO,MAAM,mBAAmB,MAAM,CAAC,CAAC;AACjC,MAAM,YAAY,MAAM;AACxB,MAAM,YAAY,CAAC,aACxB,WAAW,KAAM,eAAe,KAAM;AAKjC,MAAM,YAAY;AAElB,MAAM,YAAY,MAAM,KAAM;AAE9B,MAAM,kBAAkB,oBAAI,IAAoB;AAEhD,MAAM,mBAAmB,CAAC,OAAuB;AACtD,MAAI,MAAM;AACR,OAAG,IAAI;AAAA,EACT,OAAO;AACL,oBAAgB,IAAI,EAAE;AAAA,EACxB;AACF;AAEO,MAAM,eAAe,CAAC,KAAa,UAAe;AACvD,SAAO,OAAO,KAAK,KAAK;AAC1B;",
4
+ "sourcesContent": ["import { ConfigListener, TamaguiInternalConfig, ThemeParsed, Tokens } from './types'\n\nlet conf: TamaguiInternalConfig | null\n\nexport const setConfig = (next: TamaguiInternalConfig) => {\n conf = next\n if (configListeners.size) {\n configListeners.forEach((cb) => cb(next))\n }\n}\n\nexport const setConfigFont = (name: string, font: any, fontParsed: any) => {\n if (process.env.NODE_ENV === 'development') {\n if (!conf) throw new Error(`Haven't called createTamagui yet`)\n }\n Object.assign(conf!.fonts, { [name]: font })\n Object.assign(conf!.fontsParsed, { [`$${name}`]: fontParsed })\n}\n\nexport const getConfig = () => {\n if (!conf) {\n throw new Error(\n process.env.NODE_ENV === 'development'\n ? `Missing tamagui config, you either have a duplicate config, or haven't set it up. Be sure createTamagui is called before rendering.`\n : `Err0`\n )\n }\n return conf\n}\nexport const getTokens = (prefixed?: boolean): Tokens =>\n prefixed ? conf!.tokensParsed : conf!.tokens\n\n/**\n * Note: this is the same as `getTokens`\n */\nexport const useTokens = getTokens\n\nexport const getThemes = () => conf!.themes\n\nexport const configListeners = new Set<ConfigListener>()\n\nexport const onConfiguredOnce = (cb: ConfigListener) => {\n if (conf) {\n cb(conf)\n } else {\n configListeners.add(cb)\n }\n}\n\nexport const updateConfig = (key: string, value: any) => {\n Object.assign(key, value)\n}\n"],
5
+ "mappings": "AAEA,IAAI;AAEG,MAAM,YAAY,CAAC,SAAgC;AACxD,SAAO;AACP,MAAI,gBAAgB,MAAM;AACxB,oBAAgB,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC;AAAA,EAC1C;AACF;AAEO,MAAM,gBAAgB,CAAC,MAAc,MAAW,eAAoB;AACzE,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,CAAC;AAAM,YAAM,IAAI,MAAM,kCAAkC;AAAA,EAC/D;AACA,SAAO,OAAO,KAAM,OAAO,EAAE,CAAC,OAAO,KAAK,CAAC;AAC3C,SAAO,OAAO,KAAM,aAAa,EAAE,CAAC,IAAI,SAAS,WAAW,CAAC;AAC/D;AAEO,MAAM,YAAY,MAAM;AAC7B,MAAI,CAAC,MAAM;AACT,UAAM,IAAI;AAAA,MACR,QAAQ,IAAI,aAAa,gBACrB,wIACA;AAAA,IACN;AAAA,EACF;AACA,SAAO;AACT;AACO,MAAM,YAAY,CAAC,aACxB,WAAW,KAAM,eAAe,KAAM;AAKjC,MAAM,YAAY;AAElB,MAAM,YAAY,MAAM,KAAM;AAE9B,MAAM,kBAAkB,oBAAI,IAAoB;AAEhD,MAAM,mBAAmB,CAAC,OAAuB;AACtD,MAAI,MAAM;AACR,OAAG,IAAI;AAAA,EACT,OAAO;AACL,oBAAgB,IAAI,EAAE;AAAA,EACxB;AACF;AAEO,MAAM,eAAe,CAAC,KAAa,UAAe;AACvD,SAAO,OAAO,KAAK,KAAK;AAC1B;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,6 @@
1
+ import { createContext } from "react";
2
+ const ButtonNestingContext = createContext(false);
3
+ export {
4
+ ButtonNestingContext
5
+ };
6
+ //# sourceMappingURL=ButtonNestingContext.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/contexts/ButtonNestingContext.tsx"],
4
+ "sourcesContent": ["import { createContext } from 'react'\n\nexport const ButtonNestingContext = createContext(false)\n"],
5
+ "mappings": "AAAA,SAAS,qBAAqB;AAEvB,MAAM,uBAAuB,cAAc,KAAK;",
6
+ "names": []
7
+ }
@@ -3,13 +3,11 @@ import { useComposedRefs } from "@tamagui/compose-refs";
3
3
  import { isClient, isRSC, isServer, isWeb, useIsomorphicLayoutEffect } from "@tamagui/constants";
4
4
  import {
5
5
  composeEventHandlers,
6
- stylePropsTransform,
7
6
  stylePropsView,
8
7
  validPseudoKeys,
9
8
  validStyles
10
9
  } from "@tamagui/helpers";
11
10
  import { useResponderEvents } from "@tamagui/react-native-use-responder-events";
12
- import { useForceUpdate } from "@tamagui/use-force-update";
13
11
  import React, {
14
12
  Children,
15
13
  Fragment,
@@ -26,20 +24,19 @@ import { stackDefaultStyles } from "./constants/constants";
26
24
  import { FontLanguageContext } from "./contexts/FontLanguageContext";
27
25
  import { TextAncestorContext } from "./contexts/TextAncestorContext";
28
26
  import { extendStaticConfig, parseStaticConfig } from "./helpers/extendStaticConfig";
29
- import { getSubStyle, useSplitStyles } from "./helpers/getSplitStyles";
27
+ import { getRect } from "./helpers/getRect";
28
+ import { useSplitStyles } from "./helpers/getSplitStyles";
30
29
  import { getAllSelectors } from "./helpers/insertStyleRule";
31
30
  import { mergeProps } from "./helpers/mergeProps";
32
- import { mergeTransform } from "./helpers/mergeTransform";
33
31
  import { proxyThemeVariables } from "./helpers/proxyThemeVariables";
34
32
  import { useShallowSetState } from "./helpers/useShallowSetState";
35
- import { getRect, measureLayout, useElementLayout } from "./hooks/useElementLayout";
33
+ import { measureLayout, useElementLayout } from "./hooks/useElementLayout";
36
34
  import { addMediaQueryListener, getInitialMediaState } from "./hooks/useMedia";
37
35
  import { useServerRef, useServerState } from "./hooks/useServerHooks";
38
- import { getThemeManager, useTheme } from "./hooks/useTheme";
36
+ import { getThemeIsNewTheme, getThemeManager, useTheme } from "./hooks/useTheme";
39
37
  import { usePressability } from "./vendor/Pressability";
40
38
  import { Slot, mergeEvent } from "./views/Slot";
41
39
  import { wrapThemeManagerContext } from "./views/Theme";
42
- React["keep"];
43
40
  process.env.TAMAGUI_TARGET;
44
41
  let defaultComponentState = null;
45
42
  let defaultComponentStateMounted = null;
@@ -79,7 +76,6 @@ function createComponent(configIn, ParentComponent) {
79
76
  }
80
77
  })();
81
78
  const defaultComponentClassName = `is_${staticConfig.componentName}`;
82
- const avoidClassesWhileAnimating = true;
83
79
  let defaultNativeStyle;
84
80
  let tamaguiDefaultProps;
85
81
  let defaultTag;
@@ -95,6 +91,9 @@ function createComponent(configIn, ParentComponent) {
95
91
  const { Component, isText, isZStack } = staticConfig;
96
92
  const componentName = props.componentName || staticConfig.componentName;
97
93
  const componentClassName = props.asChild ? "" : props.componentName ? `is_${props.componentName}` : defaultComponentClassName;
94
+ const animationsConfig = tamaguiConfig.animations;
95
+ const useAnimations = animationsConfig == null ? void 0 : animationsConfig.useAnimations;
96
+ const avoidClassesWhileAnimating = animationsConfig.isReactNative;
98
97
  const hasEnterStyle = !!props.enterStyle;
99
98
  const needsMount = Boolean((isWeb ? isClient : true) && (hasEnterStyle || props.animation));
100
99
  const states = useServerState(
@@ -103,15 +102,28 @@ function createComponent(configIn, ParentComponent) {
103
102
  const state = propsIn.forceStyle ? { ...states[0], [propsIn.forceStyle]: true } : states[0];
104
103
  const setState = states[1];
105
104
  const setStateShallow = useShallowSetState(setState, debugProp, componentName);
106
- const useAnimations = (_a = tamaguiConfig.animations) == null ? void 0 : _a.useAnimations;
107
- const hasEverAnimated = useRef(false);
105
+ const stateRef = useRef(
106
+ void 0
107
+ );
108
+ stateRef.current ??= {};
108
109
  const isAnimated = (() => {
109
110
  const next = !!(useAnimations && props.animation);
110
- if (next && !hasEverAnimated.current) {
111
- hasEverAnimated.current = true;
111
+ if (next && !stateRef.current.hasAnimated) {
112
+ stateRef.current.hasAnimated = true;
112
113
  }
113
- return next || hasEverAnimated.current;
114
+ return next || stateRef.current.hasAnimated;
114
115
  })();
116
+ const usePresence = (_a = tamaguiConfig.animations) == null ? void 0 : _a.usePresence;
117
+ const presence = !isRSC && isAnimated ? usePresence() : null;
118
+ if (isAnimated && presence) {
119
+ const presenceState = presence[2];
120
+ if (presenceState) {
121
+ if (presenceState.enterVariant)
122
+ props[presenceState.enterVariant] = true;
123
+ if (presenceState.exitVariant)
124
+ props[presenceState.exitVariant] = true;
125
+ }
126
+ }
115
127
  const isReactNative = Boolean(
116
128
  staticConfig.isReactNative || isAnimated && tamaguiConfig.animations.isReactNative
117
129
  );
@@ -124,18 +136,22 @@ function createComponent(configIn, ParentComponent) {
124
136
  console.group(`%c ${banner}`, "background: yellow;");
125
137
  if (!isServer) {
126
138
  console.log(`state`, state);
127
- console.groupCollapsed("props");
128
- console.log(props);
129
- console.log("order", Object.keys(props));
130
- console.groupEnd();
131
139
  }
132
140
  }
133
141
  }
134
142
  const shouldAvoidClasses = !isWeb || !!(props.animation && avoidClassesWhileAnimating) || !staticConfig.acceptsClassName;
135
143
  const shouldForcePseudo = !!propsIn.forceStyle;
136
144
  const noClassNames = shouldAvoidClasses || shouldForcePseudo;
137
- const forceUpdate = useForceUpdate();
138
- const theme = useTheme(props.theme, componentName, props, forceUpdate, !noClassNames);
145
+ const theme = useTheme({
146
+ name: props.theme,
147
+ componentName,
148
+ reset: props.reset,
149
+ inverse: props.themeInverse,
150
+ disable: props["data-themeable"],
151
+ debug: props.debug
152
+ });
153
+ const themeManager = getThemeManager(theme);
154
+ const themeIsNew = getThemeIsNewTheme(theme);
139
155
  const shouldSetMounted = needsMount && state.unmounted;
140
156
  const setMounted = shouldSetMounted ? () => {
141
157
  setTimeout(
@@ -157,6 +173,7 @@ function createComponent(configIn, ParentComponent) {
157
173
  let elementType = isText ? (isAnimated ? AnimatedText : null) || BaseTextComponent : (isAnimated ? AnimatedView : null) || BaseViewComponent;
158
174
  elementType = Component || elementType;
159
175
  const isStringElement = typeof elementType === "string";
176
+ const isExiting = (presence == null ? void 0 : presence[0]) === false;
160
177
  const splitStyles = useSplitStyles(
161
178
  props,
162
179
  staticConfig,
@@ -166,7 +183,8 @@ function createComponent(configIn, ParentComponent) {
166
183
  noClassNames,
167
184
  dynamicStylesInline: noClassNames,
168
185
  hasTextAncestor,
169
- resolveVariablesAs: "value"
186
+ resolveVariablesAs: "value",
187
+ isExiting
170
188
  },
171
189
  null,
172
190
  languageContext || void 0,
@@ -204,41 +222,15 @@ function createComponent(configIn, ParentComponent) {
204
222
  const propsWithAnimation = props;
205
223
  let animationStyles;
206
224
  if (!isRSC && isAnimated && useAnimations) {
207
- const animations = useAnimations(propsWithAnimation, {
225
+ const animations = useAnimations({
226
+ props: propsWithAnimation,
227
+ style: splitStylesStyle,
228
+ presence,
208
229
  state,
209
230
  pseudos,
210
231
  onDidAnimate: props.onDidAnimate,
211
232
  hostRef,
212
- staticConfig,
213
- getStyle({ isExiting, isEntering, exitVariant, enterVariant } = {}) {
214
- var _a2, _b2, _c2, _d2;
215
- const animationStyle = { ...defaultNativeStyle, ...splitStylesStyle };
216
- const enterStyle = isEntering ? enterVariant && ((_a2 = staticConfig.variants) == null ? void 0 : _a2[enterVariant]["true"]) ? getSubStyle(
217
- "",
218
- (_b2 = staticConfig.variants) == null ? void 0 : _b2[enterVariant]["true"],
219
- staticConfig,
220
- theme,
221
- props,
222
- state,
223
- tamaguiConfig
224
- ) : null : null;
225
- const exitStyle = isExiting ? exitVariant && ((_c2 = staticConfig.variants) == null ? void 0 : _c2[exitVariant]["true"]) ? getSubStyle(
226
- "",
227
- (_d2 = staticConfig.variants) == null ? void 0 : _d2[exitVariant]["true"],
228
- staticConfig,
229
- theme,
230
- props,
231
- state,
232
- tamaguiConfig
233
- ) : pseudos.exitStyle : null;
234
- if (isEntering && enterStyle) {
235
- merge(animationStyle, enterStyle);
236
- }
237
- if (isExiting && exitStyle) {
238
- merge(animationStyle, exitStyle);
239
- }
240
- return animationStyle;
241
- }
233
+ staticConfig
242
234
  });
243
235
  if (animations) {
244
236
  animationStyles = animations.style;
@@ -423,7 +415,7 @@ function createComponent(configIn, ParentComponent) {
423
415
  const classList = [
424
416
  componentName ? componentClassName : "",
425
417
  fontFamilyClassName,
426
- theme.className,
418
+ themeIsNew ? theme.className : "",
427
419
  classNames ? Object.values(classNames).join(" ") : ""
428
420
  ];
429
421
  const className = classList.join(" ");
@@ -556,16 +548,19 @@ function createComponent(configIn, ParentComponent) {
556
548
  let space = spaceProp;
557
549
  if (state.mediaState && mediaKeys.length) {
558
550
  for (const key in state.mediaState) {
559
- if (state.mediaState[key] && props[key] && props[key].space !== void 0) {
551
+ if (key in state.mediaState && key in props && props[key].space !== void 0) {
560
552
  space = props[key].space;
561
553
  }
562
554
  }
563
555
  }
564
- const themeManager = getThemeManager(theme);
565
- const shouldSetChildrenThemeToParent = Boolean(
566
- themeShallow && themeManager && themeManager.didChangeTheme
567
- );
568
- const shouldProvideThemeManager = shouldSetChildrenThemeToParent || themeManager && themeManager.didChangeTheme;
556
+ const themeShouldReset = Boolean(themeShallow && themeManager && themeIsNew);
557
+ const shouldProvideThemeManager = themeShouldReset || themeManager && themeIsNew;
558
+ if (shouldProvideThemeManager) {
559
+ stateRef.current.hasProvidedThemeManager = true;
560
+ }
561
+ if (themeShouldReset) {
562
+ stateRef.current.themeShouldReset = true;
563
+ }
569
564
  const childEls = !children || asChild ? children : wrapThemeManagerContext(
570
565
  spacedChildren({
571
566
  separator,
@@ -574,8 +569,8 @@ function createComponent(configIn, ParentComponent) {
574
569
  direction: props.spaceDirection || "both",
575
570
  isZStack
576
571
  }),
577
- shouldProvideThemeManager ? themeManager : void 0,
578
- shouldSetChildrenThemeToParent
572
+ stateRef.current.hasProvidedThemeManager ? themeManager : void 0,
573
+ stateRef.current.themeShouldReset
579
574
  );
580
575
  let content;
581
576
  if (asChild) {
@@ -905,16 +900,6 @@ function mergeConfigDefaultProps(name, props, configDefaults, parentNames, conf)
905
900
  }
906
901
  return props;
907
902
  }
908
- function merge(base, next) {
909
- for (const key in next) {
910
- const val = next[key];
911
- if (key in stylePropsTransform) {
912
- mergeTransform(base, key, val, true);
913
- } else {
914
- base[key] = val;
915
- }
916
- }
917
- }
918
903
  function usePlatformMethods(hostRef) {
919
904
  useIsomorphicLayoutEffect(() => {
920
905
  const node = hostRef.current;
@@ -951,6 +936,16 @@ const dontComposePressabilityKeys = {
951
936
  function getMediaStateObject(obj) {
952
937
  return Object.fromEntries(Object.entries(obj).flatMap(([k, v]) => v ? [[`$${k}`, v]] : []));
953
938
  }
939
+ const baseDefaults = {
940
+ opacity: 1
941
+ };
942
+ const transformDefaults = {
943
+ opacity: 1,
944
+ scale: 1,
945
+ rotate: "0deg",
946
+ rotateY: "0deg",
947
+ rotateX: "0deg"
948
+ };
954
949
  export {
955
950
  Spacer,
956
951
  Unspaced,