@tamagui/core 1.0.1-rc.8 → 1.0.1

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 (200) hide show
  1. package/dist/cjs/Pressability.js +32 -0
  2. package/dist/cjs/Pressability.js.map +7 -0
  3. package/dist/cjs/Pressability.native.js +32 -0
  4. package/dist/cjs/Pressability.native.js.map +7 -0
  5. package/dist/cjs/ThemeContext.js +30 -0
  6. package/dist/cjs/ThemeContext.js.map +7 -0
  7. package/dist/cjs/ThemeManager.js +211 -0
  8. package/dist/cjs/ThemeManager.js.map +7 -0
  9. package/dist/cjs/conf.js +70 -0
  10. package/dist/cjs/conf.js.map +7 -0
  11. package/dist/cjs/constants/platform.js +4 -10
  12. package/dist/cjs/constants/platform.js.map +2 -2
  13. package/dist/cjs/constants/rnw.native.js +28 -0
  14. package/dist/cjs/constants/rnw.native.js.map +7 -0
  15. package/dist/cjs/contexts/ButtonInsideButtonContext.js.map +1 -1
  16. package/dist/cjs/createComponent.js +25 -27
  17. package/dist/cjs/createComponent.js.map +2 -2
  18. package/dist/cjs/createTamagui.js +4 -1
  19. package/dist/cjs/createTamagui.js.map +2 -2
  20. package/dist/cjs/defaultComponentState.js +2 -0
  21. package/dist/cjs/defaultComponentState.js.map +7 -0
  22. package/dist/cjs/helpers/ThemeManager.js +4 -2
  23. package/dist/cjs/helpers/ThemeManager.js.map +2 -2
  24. package/dist/cjs/helpers/Unwrap.js +29 -0
  25. package/dist/cjs/helpers/Unwrap.js.map +7 -0
  26. package/dist/cjs/helpers/assignNativePropsToWeb.js.map +1 -1
  27. package/dist/cjs/helpers/assignNativePropsToWeb.native.js.map +1 -1
  28. package/dist/cjs/helpers/cache.js +7 -11
  29. package/dist/cjs/helpers/cache.js.map +2 -2
  30. package/dist/cjs/helpers/calc.js.map +2 -2
  31. package/dist/cjs/helpers/createShallowUpdate.js +9 -12
  32. package/dist/cjs/helpers/createShallowUpdate.js.map +1 -1
  33. package/dist/cjs/helpers/createTamaguiProvider.js +65 -0
  34. package/dist/cjs/helpers/createTamaguiProvider.js.map +7 -0
  35. package/dist/cjs/helpers/cssHash.js +51 -0
  36. package/dist/cjs/helpers/cssHash.js.map +7 -0
  37. package/dist/cjs/helpers/expandStyle.js +29 -41
  38. package/dist/cjs/helpers/expandStyle.js.map +2 -2
  39. package/dist/cjs/helpers/expandStyle.test.js +10 -0
  40. package/dist/cjs/helpers/expandStyle.test.js.map +7 -0
  41. package/dist/cjs/helpers/getFont.js +2 -6
  42. package/dist/cjs/helpers/getFont.js.map +2 -2
  43. package/dist/cjs/helpers/getSplitStyles.js +22 -23
  44. package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
  45. package/dist/cjs/helpers/getStackSize.js.map +1 -1
  46. package/dist/cjs/helpers/getStylesAtomic.js +10 -11
  47. package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
  48. package/dist/cjs/helpers/insertStyleRule.js +58 -27
  49. package/dist/cjs/helpers/insertStyleRule.js.map +3 -3
  50. package/dist/cjs/helpers/nativeGestureHandler.native.js +19 -0
  51. package/dist/cjs/helpers/nativeGestureHandler.native.js.map +7 -0
  52. package/dist/cjs/helpers/normalizeValueWithProperty.js +3 -3
  53. package/dist/cjs/helpers/normalizeValueWithProperty.js.map +2 -2
  54. package/dist/cjs/helpers/startTransition.js +1 -4
  55. package/dist/cjs/helpers/startTransition.js.map +2 -2
  56. package/dist/cjs/helpers/themeable.js +2 -2
  57. package/dist/cjs/helpers/themeable.js.map +2 -2
  58. package/dist/cjs/helpers/wrapThemeManagerContext.js +37 -0
  59. package/dist/cjs/helpers/wrapThemeManagerContext.js.map +7 -0
  60. package/dist/cjs/hooks/useConstant.js +0 -3
  61. package/dist/cjs/hooks/useConstant.js.map +2 -2
  62. package/dist/cjs/hooks/useElementLayout.js +1 -1
  63. package/dist/cjs/hooks/useElementLayout.js.map +2 -2
  64. package/dist/cjs/hooks/useFeatures.js +201 -0
  65. package/dist/cjs/hooks/useFeatures.js.map +7 -0
  66. package/dist/cjs/hooks/useIsMounted.js.map +1 -1
  67. package/dist/cjs/hooks/useIsSSR.js +6 -10
  68. package/dist/cjs/hooks/useIsSSR.js.map +2 -2
  69. package/dist/cjs/hooks/useMedia.js +5 -0
  70. package/dist/cjs/hooks/useMedia.js.map +2 -2
  71. package/dist/cjs/hooks/usePressable.js.map +1 -1
  72. package/dist/cjs/hooks/usePrevious.js +1 -0
  73. package/dist/cjs/hooks/usePrevious.js.map +7 -0
  74. package/dist/cjs/hooks/useTheme.js +45 -50
  75. package/dist/cjs/hooks/useTheme.js.map +3 -3
  76. package/dist/cjs/hooks/useUnmountEffect.js.map +1 -1
  77. package/dist/cjs/styled.js +12 -0
  78. package/dist/cjs/styled.js.map +2 -2
  79. package/dist/cjs/views/TamaguiProvider.js +3 -0
  80. package/dist/cjs/views/TamaguiProvider.js.map +2 -2
  81. package/dist/cjs/views/TextAncestorContext.js +44 -0
  82. package/dist/cjs/views/TextAncestorContext.js.map +7 -0
  83. package/dist/cjs/views/Theme.js +15 -21
  84. package/dist/cjs/views/Theme.js.map +3 -3
  85. package/dist/cjs/views/ThemeInverse.js +20 -21
  86. package/dist/cjs/views/ThemeInverse.js.map +2 -2
  87. package/dist/cjs/views/ThemeReset.js +5 -10
  88. package/dist/cjs/views/ThemeReset.js.map +3 -3
  89. package/dist/esm/Pressability.js +7 -0
  90. package/dist/esm/Pressability.js.map +7 -0
  91. package/dist/esm/Pressability.native.js +7 -0
  92. package/dist/esm/Pressability.native.js.map +7 -0
  93. package/dist/esm/ThemeContext.js +6 -0
  94. package/dist/esm/ThemeContext.js.map +7 -0
  95. package/dist/esm/ThemeManager.js +185 -0
  96. package/dist/esm/ThemeManager.js.map +7 -0
  97. package/dist/esm/conf.js +39 -0
  98. package/dist/esm/conf.js.map +7 -0
  99. package/dist/esm/constants/platform.js +3 -7
  100. package/dist/esm/constants/platform.js.map +2 -2
  101. package/dist/esm/constants/rnw.native.js +5 -0
  102. package/dist/esm/constants/rnw.native.js.map +7 -0
  103. package/dist/esm/contexts/ButtonInsideButtonContext.js.map +1 -1
  104. package/dist/esm/createComponent.js +26 -28
  105. package/dist/esm/createComponent.js.map +2 -2
  106. package/dist/esm/createTamagui.js +9 -2
  107. package/dist/esm/createTamagui.js.map +2 -2
  108. package/dist/esm/defaultComponentState.js +1 -0
  109. package/dist/esm/defaultComponentState.js.map +7 -0
  110. package/dist/esm/helpers/ThemeManager.js +4 -2
  111. package/dist/esm/helpers/ThemeManager.js.map +2 -2
  112. package/dist/esm/helpers/Unwrap.js +5 -0
  113. package/dist/esm/helpers/Unwrap.js.map +7 -0
  114. package/dist/esm/helpers/assignNativePropsToWeb.js.map +1 -1
  115. package/dist/esm/helpers/assignNativePropsToWeb.native.js.map +1 -1
  116. package/dist/esm/helpers/cache.js +7 -10
  117. package/dist/esm/helpers/cache.js.map +2 -2
  118. package/dist/esm/helpers/calc.js.map +2 -2
  119. package/dist/esm/helpers/createShallowUpdate.js +9 -12
  120. package/dist/esm/helpers/createShallowUpdate.js.map +1 -1
  121. package/dist/esm/helpers/createTamaguiProvider.js +38 -0
  122. package/dist/esm/helpers/createTamaguiProvider.js.map +7 -0
  123. package/dist/esm/helpers/cssHash.js +27 -0
  124. package/dist/esm/helpers/cssHash.js.map +7 -0
  125. package/dist/esm/helpers/expandStyle.js +26 -38
  126. package/dist/esm/helpers/expandStyle.js.map +2 -2
  127. package/dist/esm/helpers/expandStyle.test.js +9 -0
  128. package/dist/esm/helpers/expandStyle.test.js.map +7 -0
  129. package/dist/esm/helpers/getFont.js +2 -6
  130. package/dist/esm/helpers/getFont.js.map +2 -2
  131. package/dist/esm/helpers/getSplitStyles.js +24 -24
  132. package/dist/esm/helpers/getSplitStyles.js.map +2 -2
  133. package/dist/esm/helpers/getStackSize.js.map +1 -1
  134. package/dist/esm/helpers/getStylesAtomic.js +10 -11
  135. package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
  136. package/dist/esm/helpers/insertStyleRule.js +56 -26
  137. package/dist/esm/helpers/insertStyleRule.js.map +3 -3
  138. package/dist/esm/helpers/nativeGestureHandler.native.js +2 -0
  139. package/dist/esm/helpers/nativeGestureHandler.native.js.map +7 -0
  140. package/dist/esm/helpers/normalizeValueWithProperty.js +3 -3
  141. package/dist/esm/helpers/normalizeValueWithProperty.js.map +2 -2
  142. package/dist/esm/helpers/startTransition.js.map +1 -1
  143. package/dist/esm/helpers/themeable.js +2 -2
  144. package/dist/esm/helpers/themeable.js.map +2 -2
  145. package/dist/esm/helpers/wrapThemeManagerContext.js +11 -0
  146. package/dist/esm/helpers/wrapThemeManagerContext.js.map +7 -0
  147. package/dist/esm/hooks/useConstant.js +1 -4
  148. package/dist/esm/hooks/useConstant.js.map +2 -2
  149. package/dist/esm/hooks/useElementLayout.js +1 -1
  150. package/dist/esm/hooks/useElementLayout.js.map +2 -2
  151. package/dist/esm/hooks/useFeatures.js +174 -0
  152. package/dist/esm/hooks/useFeatures.js.map +7 -0
  153. package/dist/esm/hooks/useIsMounted.js.map +1 -1
  154. package/dist/esm/hooks/useIsSSR.js +8 -12
  155. package/dist/esm/hooks/useIsSSR.js.map +2 -2
  156. package/dist/esm/hooks/useMedia.js +4 -0
  157. package/dist/esm/hooks/useMedia.js.map +2 -2
  158. package/dist/esm/hooks/usePressable.js.map +1 -1
  159. package/dist/esm/hooks/usePrevious.js +1 -0
  160. package/dist/esm/hooks/usePrevious.js.map +7 -0
  161. package/dist/esm/hooks/useTheme.js +45 -50
  162. package/dist/esm/hooks/useTheme.js.map +3 -3
  163. package/dist/esm/hooks/useUnmountEffect.js.map +1 -1
  164. package/dist/esm/styled.js +12 -0
  165. package/dist/esm/styled.js.map +2 -2
  166. package/dist/esm/views/TamaguiProvider.js +3 -0
  167. package/dist/esm/views/TamaguiProvider.js.map +2 -2
  168. package/dist/esm/views/TextAncestorContext.js +15 -0
  169. package/dist/esm/views/TextAncestorContext.js.map +7 -0
  170. package/dist/esm/views/Theme.js +14 -14
  171. package/dist/esm/views/Theme.js.map +2 -2
  172. package/dist/esm/views/ThemeInverse.js +15 -20
  173. package/dist/esm/views/ThemeInverse.js.map +2 -2
  174. package/dist/esm/views/ThemeReset.js +4 -6
  175. package/dist/esm/views/ThemeReset.js.map +2 -2
  176. package/package.json +13 -14
  177. package/src/createComponent.tsx +47 -43
  178. package/src/createTamagui.ts +10 -2
  179. package/src/helpers/ThemeManager.tsx +7 -2
  180. package/src/helpers/cache.ts +7 -9
  181. package/src/helpers/expandStyle.ts +27 -41
  182. package/src/helpers/getSplitStyles.tsx +40 -23
  183. package/src/helpers/getStylesAtomic.ts +15 -15
  184. package/src/helpers/insertStyleRule.tsx +68 -38
  185. package/src/helpers/normalizeValueWithProperty.ts +3 -3
  186. package/src/helpers/themeable.tsx +3 -3
  187. package/src/hooks/useElementLayout.tsx +1 -1
  188. package/src/hooks/useMedia.tsx +3 -0
  189. package/src/hooks/useTheme.tsx +67 -48
  190. package/src/styled.tsx +15 -0
  191. package/src/views/TamaguiProvider.tsx +6 -0
  192. package/src/views/Theme.tsx +15 -22
  193. package/types/createComponent.d.ts +1 -1
  194. package/types/helpers/ThemeManager.d.ts +1 -1
  195. package/types/helpers/cache.d.ts +2 -4
  196. package/types/helpers/insertStyleRule.d.ts +2 -1
  197. package/types/helpers/themeable.d.ts +1 -1
  198. package/types/hooks/useMedia.d.ts +1 -0
  199. package/types/hooks/useTheme.d.ts +1 -1
  200. package/types/views/Theme.d.ts +1 -1
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var Pressability_exports = {};
20
+ __export(Pressability_exports, {
21
+ Pressability: () => Pressability,
22
+ usePressability: () => usePressability
23
+ });
24
+ module.exports = __toCommonJS(Pressability_exports);
25
+ const Pressability = {};
26
+ const usePressability = {};
27
+ // Annotate the CommonJS export names for ESM import in node:
28
+ 0 && (module.exports = {
29
+ Pressability,
30
+ usePressability
31
+ });
32
+ //# sourceMappingURL=Pressability.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Pressability.tsx"],
4
+ "sourcesContent": ["export const Pressability = {} as any\nexport const usePressability = {} as Function\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,eAAe,CAAC;AACtB,MAAM,kBAAkB,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var Pressability_native_exports = {};
20
+ __export(Pressability_native_exports, {
21
+ Pressability: () => Pressability,
22
+ usePressability: () => usePressability
23
+ });
24
+ module.exports = __toCommonJS(Pressability_native_exports);
25
+ const Pressability = require("react-native/Libraries/Pressability/Pressability").default;
26
+ const usePressability = require("react-native/Libraries/Pressability/usePressability").default;
27
+ // Annotate the CommonJS export names for ESM import in node:
28
+ 0 && (module.exports = {
29
+ Pressability,
30
+ usePressability
31
+ });
32
+ //# sourceMappingURL=Pressability.native.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Pressability.native.tsx"],
4
+ "sourcesContent": ["export const Pressability = require('react-native/Libraries/Pressability/Pressability').default\nexport const usePressability =\n require('react-native/Libraries/Pressability/usePressability').default\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,eAAe,QAAQ,kDAAkD,EAAE;AACjF,MAAM,kBACX,QAAQ,qDAAqD,EAAE;",
6
+ "names": []
7
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var ThemeContext_exports = {};
20
+ __export(ThemeContext_exports, {
21
+ ThemeContext: () => ThemeContext
22
+ });
23
+ module.exports = __toCommonJS(ThemeContext_exports);
24
+ var import_react = require("react");
25
+ const ThemeContext = (0, import_react.createContext)(null);
26
+ // Annotate the CommonJS export names for ESM import in node:
27
+ 0 && (module.exports = {
28
+ ThemeContext
29
+ });
30
+ //# sourceMappingURL=ThemeContext.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/ThemeContext.tsx"],
4
+ "sourcesContent": ["import { createContext } from 'react'\n\nimport { ThemeName, Themes } from './types'\n\nexport const ThemeContext = createContext<{ themes: Themes; defaultTheme: ThemeName } | null>(null)\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA8B;AAIvB,MAAM,eAAe,gCAAkE,IAAI;",
6
+ "names": []
7
+ }
@@ -0,0 +1,211 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var ThemeManager_exports = {};
20
+ __export(ThemeManager_exports, {
21
+ ThemeManager: () => ThemeManager,
22
+ ThemeManagerContext: () => ThemeManagerContext,
23
+ emptyManager: () => emptyManager
24
+ });
25
+ module.exports = __toCommonJS(ThemeManager_exports);
26
+ var import_react = require("react");
27
+ var import_conf = require("./conf");
28
+ var import_constants = require("./constants/constants");
29
+ var import_getThemeUnwrapped = require("./hooks/getThemeUnwrapped");
30
+ class ThemeManager {
31
+ constructor(name = "", theme = null, parentManager = null, reset = false) {
32
+ this.name = name;
33
+ this.theme = theme;
34
+ this.parentManager = parentManager;
35
+ this.reset = reset;
36
+ this.keys = /* @__PURE__ */ new Map();
37
+ this.listeners = /* @__PURE__ */ new Map();
38
+ this.themeListeners = /* @__PURE__ */ new Set();
39
+ this.className = null;
40
+ let parent = parentManager;
41
+ let tries = 0;
42
+ while (true) {
43
+ tries++;
44
+ if (tries > 10) {
45
+ throw new Error(`Nested 10 of the same theme in a row, likely error`);
46
+ }
47
+ if (!parent)
48
+ break;
49
+ if (parent.name === name) {
50
+ parent = parent.parentManager;
51
+ } else {
52
+ this.parentManager = parent;
53
+ break;
54
+ }
55
+ }
56
+ }
57
+ get didChangeTheme() {
58
+ return this.parentManager && this.name !== this.parentManager.fullName;
59
+ }
60
+ get parentName() {
61
+ var _a;
62
+ return ((_a = this.parentManager) == null ? void 0 : _a.name) || null;
63
+ }
64
+ get fullName() {
65
+ return this.getNextTheme().name || this.name || "";
66
+ }
67
+ getValue(key) {
68
+ let theme = this.theme;
69
+ let manager = this;
70
+ while (true) {
71
+ if (!theme)
72
+ return;
73
+ if (key in theme) {
74
+ return theme[key];
75
+ }
76
+ manager = this.parentManager;
77
+ if (!manager) {
78
+ return;
79
+ }
80
+ if (manager.theme === theme) {
81
+ return;
82
+ }
83
+ theme = manager.theme;
84
+ }
85
+ }
86
+ update({ name, theme, className } = {}) {
87
+ const nameChanged = name !== this.name;
88
+ if (!nameChanged) {
89
+ return false;
90
+ }
91
+ this.className = className || null;
92
+ this.name = name || "";
93
+ this.theme = theme;
94
+ this.notifyListeners();
95
+ return true;
96
+ }
97
+ getNextTheme(props = {}, debug) {
98
+ var _a;
99
+ const { themes = (0, import_conf.getThemes)(), name, componentName } = props;
100
+ if (props.reset && name) {
101
+ return {
102
+ name,
103
+ theme: themes[name],
104
+ className: this.getClassName(name)
105
+ };
106
+ }
107
+ const parentIsReset = (_a = this.parentManager) == null ? void 0 : _a.reset;
108
+ if (!name) {
109
+ if (componentName) {
110
+ const names = [
111
+ `${this.name}_${componentName}`,
112
+ `${withoutComponentName(this.name)}_${componentName}`
113
+ ];
114
+ for (const name2 of names) {
115
+ if (name2 in themes) {
116
+ const className = this.getClassName(name2);
117
+ return { name: name2, theme: themes[name2], className };
118
+ }
119
+ }
120
+ }
121
+ return {
122
+ name: this.name,
123
+ theme: this.theme
124
+ };
125
+ }
126
+ let nextName = name || this.name || "";
127
+ let parentName = parentIsReset ? this.parentName || this.fullName : this.fullName;
128
+ while (true) {
129
+ if (nextName in themes) {
130
+ break;
131
+ }
132
+ nextName = `${parentName}_${name}`;
133
+ if (nextName in themes) {
134
+ break;
135
+ }
136
+ if (!parentName.includes(import_constants.THEME_NAME_SEPARATOR)) {
137
+ console.warn("theme not found", name);
138
+ break;
139
+ }
140
+ parentName = parentName.slice(0, parentName.lastIndexOf(import_constants.THEME_NAME_SEPARATOR));
141
+ }
142
+ if (componentName) {
143
+ const names = [
144
+ `${nextName}_${componentName}`,
145
+ `${withoutComponentName(nextName)}_${componentName}`
146
+ ];
147
+ for (const name2 of names) {
148
+ if (name2 in themes) {
149
+ nextName = name2;
150
+ }
151
+ }
152
+ }
153
+ let theme = themes[nextName];
154
+ if (!theme) {
155
+ theme = themes[`light_${nextName}`];
156
+ }
157
+ if (process.env.NODE_ENV === "development") {
158
+ if (debug) {
159
+ console.log("getNextTheme", this.getClassName(nextName), { props, nextName, parentName });
160
+ }
161
+ }
162
+ return {
163
+ name: nextName,
164
+ theme: (0, import_getThemeUnwrapped.getThemeUnwrapped)(theme),
165
+ className: this.getClassName(nextName)
166
+ };
167
+ }
168
+ getClassName(name) {
169
+ return `${import_constants.THEME_CLASSNAME_PREFIX}${name} t_Theme`.replace("light_", "").replace("dark_", "");
170
+ }
171
+ track(uuid, keys) {
172
+ if (!this.name)
173
+ return;
174
+ this.keys.set(uuid, keys);
175
+ }
176
+ notifyListeners() {
177
+ var _a;
178
+ if (!this.name) {
179
+ this.keys.clear();
180
+ }
181
+ for (const [uuid, keys] of this.keys.entries()) {
182
+ if (keys.size) {
183
+ (_a = this.listeners.get(uuid)) == null ? void 0 : _a();
184
+ }
185
+ }
186
+ this.themeListeners.forEach((cb) => cb(this.name, this));
187
+ }
188
+ onChangeTheme(cb) {
189
+ this.themeListeners.add(cb);
190
+ return () => {
191
+ this.themeListeners.delete(cb);
192
+ };
193
+ }
194
+ onUpdate(uuid, cb) {
195
+ this.listeners.set(uuid, cb);
196
+ return () => {
197
+ this.listeners.delete(uuid);
198
+ this.keys.delete(uuid);
199
+ };
200
+ }
201
+ }
202
+ const ThemeManagerContext = (0, import_react.createContext)(null);
203
+ const emptyManager = new ThemeManager();
204
+ const withoutComponentName = (name) => name.replace(/(\_[A-Z][a-zA-Z]+)+$/g, "");
205
+ // Annotate the CommonJS export names for ESM import in node:
206
+ 0 && (module.exports = {
207
+ ThemeManager,
208
+ ThemeManagerContext,
209
+ emptyManager
210
+ });
211
+ //# sourceMappingURL=ThemeManager.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/ThemeManager.tsx"],
4
+ "sourcesContent": ["import { createContext } from 'react'\n\nimport { getThemes } from './conf'\nimport { THEME_CLASSNAME_PREFIX, THEME_NAME_SEPARATOR } from './constants/constants'\nimport { getThemeUnwrapped } from './hooks/getThemeUnwrapped'\nimport { ThemeObject, Themes } from './types'\n\ntype ThemeListener = (name: string | null, themeManager: ThemeManager) => void\n\nexport type SetActiveThemeProps = {\n className?: string\n parentManager?: ThemeManager | null\n name?: string | null\n theme?: any\n}\n\nexport type GetNextThemeProps = {\n themes?: Themes\n name?: string | null\n componentName?: string | null\n reset?: boolean\n}\n\nexport class ThemeManager {\n keys = new Map<any, Set<string>>()\n listeners = new Map<any, Function>()\n themeListeners = new Set<ThemeListener>()\n className: string | null = null\n\n constructor(\n public name: string = '',\n public theme: ThemeObject | null = null,\n public parentManager: ThemeManager | null = null,\n public reset: boolean = false\n ) {\n // find the nearest different parentManager\n let parent = parentManager\n let tries = 0\n while (true) {\n tries++\n if (tries > 10) {\n throw new Error(`Nested 10 of the same theme in a row, likely error`)\n }\n if (!parent) break\n if (parent.name === name) {\n // go up if same\n parent = parent.parentManager\n } else {\n this.parentManager = parent\n break\n }\n }\n }\n\n get didChangeTheme() {\n return this.parentManager && this.name !== this.parentManager.fullName\n }\n\n get parentName() {\n return this.parentManager?.name || null\n }\n\n get fullName(): string {\n return this.getNextTheme().name || this.name || ''\n // const parentName = this.parentManager?.fullName || ''\n // const name = this.name || ''\n // const parts = [...new Set([...`${parentName}_${name}`.split('_')])].filter(Boolean)\n // return parts.join('_')\n }\n\n // gets value going up to parents\n getValue(key: string) {\n let theme = this.theme\n let manager = this as ThemeManager | null\n while (true) {\n if (!theme) return\n if (key in theme) {\n return theme[key]\n }\n manager = this.parentManager\n if (!manager) {\n return\n }\n if (manager.theme === theme) {\n return\n }\n theme = manager.theme\n }\n }\n\n update({ name, theme, className }: SetActiveThemeProps = {}) {\n // className compare on web, avoids light/dark re-renders\n const nameChanged = name !== this.name\n if (!nameChanged) {\n return false\n }\n this.className = className || null\n this.name = name || ''\n this.theme = theme\n this.notifyListeners()\n return true\n }\n\n getNextTheme(props: GetNextThemeProps = {}, debug?: any) {\n const { themes = getThemes(), name, componentName } = props\n\n if (props.reset && name) {\n return {\n name: name,\n theme: themes[name],\n className: this.getClassName(name),\n }\n }\n\n const parentIsReset = this.parentManager?.reset\n\n if (!name) {\n if (componentName) {\n // allow for _Card_Button or just _Button\n const names = [\n `${this.name}_${componentName}`,\n `${withoutComponentName(this.name)}_${componentName}`,\n ]\n for (const name of names) {\n if (name in themes) {\n const className = this.getClassName(name)\n return { name, theme: themes[name], className }\n }\n }\n }\n return {\n name: this.name,\n theme: this.theme,\n }\n }\n\n let nextName = name || this.name || ''\n let parentName = parentIsReset ? this.parentName || this.fullName : this.fullName\n\n while (true) {\n if (nextName in themes) {\n break\n }\n nextName = `${parentName}_${name}`\n if (nextName in themes) {\n break\n }\n if (!parentName.includes(THEME_NAME_SEPARATOR)) {\n // not found!\n console.warn('theme not found', name)\n // this happens in next during _document.getInitialProps and has a terrible/non-existent stack trace\n // throw new Error(`Theme not found: ${name}`)\n break\n }\n // go up one\n parentName = parentName.slice(0, parentName.lastIndexOf(THEME_NAME_SEPARATOR))\n }\n\n if (componentName) {\n // allow for _Card_Button or just _Button\n const names = [\n `${nextName}_${componentName}`,\n `${withoutComponentName(nextName)}_${componentName}`,\n ]\n for (const name of names) {\n if (name in themes) {\n nextName = name\n }\n }\n }\n\n let theme = themes[nextName]\n if (!theme) {\n theme = themes[`light_${nextName}`]\n }\n\n if (process.env.NODE_ENV === 'development') {\n if (debug) {\n console.log('getNextTheme', this.getClassName(nextName), { props, nextName, parentName })\n }\n }\n\n return {\n name: nextName,\n theme: getThemeUnwrapped(theme),\n className: this.getClassName(nextName),\n }\n }\n\n getClassName(name: string) {\n return `${THEME_CLASSNAME_PREFIX}${name} t_Theme`.replace('light_', '').replace('dark_', '')\n }\n\n track(uuid: any, keys: Set<string>) {\n if (!this.name) return\n this.keys.set(uuid, keys)\n }\n\n notifyListeners() {\n if (!this.name) {\n this.keys.clear()\n }\n for (const [uuid, keys] of this.keys.entries()) {\n if (keys.size) {\n this.listeners.get(uuid)?.()\n }\n }\n this.themeListeners.forEach((cb) => cb(this.name, this))\n }\n\n onChangeTheme(cb: ThemeListener) {\n this.themeListeners.add(cb)\n return () => {\n this.themeListeners.delete(cb)\n }\n }\n\n onUpdate(uuid: any, cb: Function) {\n this.listeners.set(uuid, cb)\n return () => {\n this.listeners.delete(uuid)\n this.keys.delete(uuid)\n }\n }\n}\n\nexport const ThemeManagerContext = createContext<ThemeManager | null>(null)\nexport const emptyManager = new ThemeManager()\n\nconst withoutComponentName = (name: string) => name.replace(/(\\_[A-Z][a-zA-Z]+)+$/g, '')\n"],
5
+ "mappings":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ACX,WAAK,eAAe,OAAO,EAAE;AAAA,IAC/B;AAAA,EACF;AAAA,EAEA,SAAS,MAAW,IAAc;AAChC,SAAK,UAAU,IAAI,MAAM,EAAE;AAC3B,WAAO,MAAM;AACX,WAAK,UAAU,OAAO,IAAI;AAC1B,WAAK,KAAK,OAAO,IAAI;AAAA,IACvB;AAAA,EACF;AACF;AAEO,MAAM,sBAAsB,gCAAmC,IAAI;AACnE,MAAM,eAAe,IAAI,aAAa;AAE7C,MAAM,uBAAuB,CAAC,SAAiB,KAAK,QAAQ,yBAAyB,EAAE;",
6
+ "names": []
7
+ }
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var conf_exports = {};
20
+ __export(conf_exports, {
21
+ configListeners: () => configListeners,
22
+ getConfig: () => getConfig,
23
+ getHasConfigured: () => getHasConfigured,
24
+ getThemes: () => getThemes,
25
+ getTokens: () => getTokens,
26
+ onConfiguredOnce: () => onConfiguredOnce,
27
+ setConfig: () => setConfig,
28
+ setConfigFont: () => setConfigFont
29
+ });
30
+ module.exports = __toCommonJS(conf_exports);
31
+ let conf;
32
+ const setConfig = (next) => {
33
+ conf = next;
34
+ if (configListeners.size) {
35
+ configListeners.forEach((cb) => cb(conf));
36
+ configListeners.clear();
37
+ }
38
+ };
39
+ const setConfigFont = (name, font, fontParsed) => {
40
+ if (process.env.NODE_ENV === "development") {
41
+ if (!conf)
42
+ throw new Error(`Haven't called createTamagui yet`);
43
+ }
44
+ Object.assign(conf.fonts, { [name]: font });
45
+ Object.assign(conf.fontsParsed, { [`$${name}`]: fontParsed });
46
+ };
47
+ const getHasConfigured = () => !!conf;
48
+ const getConfig = () => conf;
49
+ const getTokens = () => conf.tokensParsed;
50
+ const getThemes = () => conf.themes;
51
+ const configListeners = /* @__PURE__ */ new Set();
52
+ const onConfiguredOnce = (cb) => {
53
+ if (conf) {
54
+ cb(conf);
55
+ } else {
56
+ configListeners.add(cb);
57
+ }
58
+ };
59
+ // Annotate the CommonJS export names for ESM import in node:
60
+ 0 && (module.exports = {
61
+ configListeners,
62
+ getConfig,
63
+ getHasConfigured,
64
+ getThemes,
65
+ getTokens,
66
+ onConfiguredOnce,
67
+ setConfig,
68
+ setConfigFont
69
+ });
70
+ //# sourceMappingURL=conf.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/conf.ts"],
4
+ "sourcesContent": ["import { ConfigListener, TamaguiInternalConfig } 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(conf!))\n configListeners.clear()\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 = () => conf!.tokensParsed\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"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAI;AAEG,MAAM,YAAY,CAAC,SAAgC;AACxD,SAAO;AACP,MAAI,gBAAgB,MAAM;AACxB,oBAAgB,QAAQ,CAAC,OAAO,GAAG,IAAK,CAAC;AACzC,oBAAgB,MAAM;AAAA,EACxB;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,MAAM,KAAM;AAC9B,MAAM,YAAY,MAAM,KAAM;AAE9B,MAAM,kBAAkB,oBAAI,IAAoB;AAEhD,MAAM,mBAAmB,CAAC,OAAuB;AACtD,MAAI,MAAM;AACR,OAAG,IAAK;AAAA,EACV,OAAO;AACL,oBAAgB,IAAI,EAAE;AAAA,EACxB;AACF;",
6
+ "names": []
7
+ }
@@ -22,8 +22,7 @@ __export(platform_exports, {
22
22
  isChrome: () => isChrome,
23
23
  isClient: () => isClient,
24
24
  isIOS: () => isIOS,
25
- isRSC: () => isRSC,
26
- isServer: () => isServer,
25
+ isSSR: () => isSSR,
27
26
  isTouchable: () => isTouchable,
28
27
  isWeb: () => isWeb,
29
28
  isWebTouchable: () => isWebTouchable,
@@ -33,18 +32,14 @@ __export(platform_exports, {
33
32
  module.exports = __toCommonJS(platform_exports);
34
33
  var import_react = require("react");
35
34
  var import_react_native = require("react-native");
36
- const import_meta = {};
37
35
  var _a, _b;
38
36
  const isAndroid = ((_a = import_react_native.Platform) == null ? void 0 : _a.OS) === "android";
39
37
  const isIOS = ((_b = import_react_native.Platform) == null ? void 0 : _b.OS) === "ios";
40
38
  const isWeb = process.env.TAMAGUI_TARGET === "web";
41
39
  const isWindowDefined = typeof window !== "undefined";
42
- const isServer = isWeb && !isWindowDefined;
40
+ const isSSR = isWeb && !isWindowDefined;
43
41
  const isClient = isWeb && isWindowDefined;
44
- const isRSC = process.env.ENABLE_RSC ? import_meta.env ? import_meta.env.SSR : false : false;
45
- const idFn = () => {
46
- };
47
- const useIsomorphicLayoutEffect = isRSC ? idFn : isServer ? import_react.useEffect : import_react.useLayoutEffect;
42
+ const useIsomorphicLayoutEffect = isSSR ? import_react.useEffect : import_react.useLayoutEffect;
48
43
  const isChrome = typeof navigator !== "undefined" && /Chrome/.test(navigator.userAgent || "");
49
44
  const isWebTouchable = isClient && "ontouchstart" in window;
50
45
  const isTouchable = !isWeb || isWebTouchable;
@@ -54,8 +49,7 @@ const isTouchable = !isWeb || isWebTouchable;
54
49
  isChrome,
55
50
  isClient,
56
51
  isIOS,
57
- isRSC,
58
- isServer,
52
+ isSSR,
59
53
  isTouchable,
60
54
  isWeb,
61
55
  isWebTouchable,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/constants/platform.ts"],
4
- "sourcesContent": ["import { useEffect, useLayoutEffect } from 'react'\nimport { Platform } from 'react-native'\n\nexport const isAndroid = Platform?.OS === 'android'\nexport const isIOS = Platform?.OS === 'ios'\nexport const isWeb = process.env.TAMAGUI_TARGET === 'web'\nexport const isWindowDefined = typeof window !== 'undefined'\nexport const isServer = isWeb && !isWindowDefined\nexport const isClient = isWeb && isWindowDefined\n\n// may want to move to VITE_RSC_BUILD\nexport const isRSC = process.env.ENABLE_RSC\n ? // note this is statically analyzed so no funny business, just access it without optional chaining\n // @ts-ignore\n import.meta.env\n ? // @ts-ignore\n import.meta.env.SSR\n : false\n : false\n\nconst idFn = () => {}\nexport const useIsomorphicLayoutEffect = isRSC ? idFn : isServer ? useEffect : useLayoutEffect\nexport const isChrome = typeof navigator !== 'undefined' && /Chrome/.test(navigator.userAgent || '')\nexport const isWebTouchable = isClient && 'ontouchstart' in window\nexport const isTouchable = !isWeb || isWebTouchable\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA2C;AAC3C,0BAAyB;AADzB;AAAA;AAGO,MAAM,cAAY,yDAAU,QAAO;AACnC,MAAM,UAAQ,yDAAU,QAAO;AAC/B,MAAM,QAAQ,QAAQ,IAAI,mBAAmB;AAC7C,MAAM,kBAAkB,OAAO,WAAW;AAC1C,MAAM,WAAW,SAAS,CAAC;AAC3B,MAAM,WAAW,SAAS;AAG1B,MAAM,QAAQ,QAAQ,IAAI,aAG7B,YAAY,MAEV,YAAY,IAAI,MAChB,QACF;AAEJ,MAAM,OAAO,MAAM;AAAC;AACb,MAAM,4BAA4B,QAAQ,OAAO,WAAW,yBAAY;AACxE,MAAM,WAAW,OAAO,cAAc,eAAe,SAAS,KAAK,UAAU,aAAa,EAAE;AAC5F,MAAM,iBAAiB,YAAY,kBAAkB;AACrD,MAAM,cAAc,CAAC,SAAS;",
4
+ "sourcesContent": ["import { useEffect, useLayoutEffect } from 'react'\nimport { Platform } from 'react-native'\n\nexport const isAndroid = Platform?.OS === 'android'\nexport const isIOS = Platform?.OS === 'ios'\nexport const isWeb = process.env.TAMAGUI_TARGET === 'web'\nexport const isWindowDefined = typeof window !== 'undefined'\nexport const isSSR = isWeb && !isWindowDefined\nexport const isClient = isWeb && isWindowDefined\nexport const useIsomorphicLayoutEffect = isSSR ? useEffect : useLayoutEffect\nexport const isChrome = typeof navigator !== 'undefined' && /Chrome/.test(navigator.userAgent || '')\nexport const isWebTouchable = isClient && 'ontouchstart' in window\nexport const isTouchable = !isWeb || isWebTouchable\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA2C;AAC3C,0BAAyB;AADzB;AAGO,MAAM,YAAY,2DAAU,QAAO;AACnC,MAAM,QAAQ,2DAAU,QAAO;AAC/B,MAAM,QAAQ,QAAQ,IAAI,mBAAmB;AAC7C,MAAM,kBAAkB,OAAO,WAAW;AAC1C,MAAM,QAAQ,SAAS,CAAC;AACxB,MAAM,WAAW,SAAS;AAC1B,MAAM,4BAA4B,QAAQ,yBAAY;AACtD,MAAM,WAAW,OAAO,cAAc,eAAe,SAAS,KAAK,UAAU,aAAa,EAAE;AAC5F,MAAM,iBAAiB,YAAY,kBAAkB;AACrD,MAAM,cAAc,CAAC,SAAS;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,28 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var rnw_native_exports = {};
19
+ __export(rnw_native_exports, {
20
+ rnw: () => rnw
21
+ });
22
+ module.exports = __toCommonJS(rnw_native_exports);
23
+ const rnw = {};
24
+ // Annotate the CommonJS export names for ESM import in node:
25
+ 0 && (module.exports = {
26
+ rnw
27
+ });
28
+ //# sourceMappingURL=rnw.native.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/constants/rnw.native.tsx"],
4
+ "sourcesContent": ["export const rnw = {} as any\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,MAAM,CAAC;",
6
+ "names": []
7
+ }
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../src/contexts/ButtonInsideButtonContext.tsx"],
4
4
  "sourcesContent": ["import { createContext } from 'react'\n\nexport const ButtonInsideButtonContext = createContext(false)\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA8B;AAEvB,MAAM,gCAA4B,4BAAc,KAAK;",
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA8B;AAEvB,MAAM,4BAA4B,gCAAc,KAAK;",
6
6
  "names": []
7
7
  }
@@ -380,7 +380,7 @@ function createComponent(configIn, ParentComponent) {
380
380
  viewProps.ref = (0, import_compose_refs.useComposedRefs)(hostRef, forwardedRef);
381
381
  if (process.env.NODE_ENV === "development" && !isText && import_constants.isWeb) {
382
382
  import_react.Children.toArray(props.children).forEach((item) => {
383
- if (typeof item === "string") {
383
+ if (typeof item === "string" && item !== "\n") {
384
384
  console.error(
385
385
  `Unexpected text node: ${item}. A text node cannot be a child of a <View>.`
386
386
  );
@@ -404,10 +404,16 @@ function createComponent(configIn, ParentComponent) {
404
404
  (0, import_react.useEffect)(() => {
405
405
  if (!shouldSetMounted)
406
406
  return;
407
+ if (state.unmounted === true && needsMount) {
408
+ setStateShallow({
409
+ unmounted: false
410
+ });
411
+ return;
412
+ }
407
413
  setStateShallow({
408
414
  unmounted: false
409
415
  });
410
- }, [shouldSetMounted]);
416
+ }, [shouldSetMounted, state.unmounted]);
411
417
  let styles;
412
418
  if (isStringElement && shouldAvoidClasses && !shouldForcePseudo) {
413
419
  styles = {
@@ -428,6 +434,7 @@ function createComponent(configIn, ParentComponent) {
428
434
  }
429
435
  const fontFamilyClassName = fontFamily ? `font_${fontFamily}` : "";
430
436
  const classList = [
437
+ hasEnterStyle && (state.unmounted && needsMount || !import_constants.isClient) ? "t_will-mount" : "",
431
438
  componentName ? componentClassName : "",
432
439
  fontFamilyClassName,
433
440
  themeIsNew ? theme.className : "",
@@ -568,7 +575,7 @@ function createComponent(configIn, ParentComponent) {
568
575
  if (themeShouldReset) {
569
576
  stateRef.current.themeShouldReset = true;
570
577
  }
571
- const childEls = !children || asChild ? children : (0, import_Theme.wrapThemeManagerContext)(
578
+ const innerContent = (0, import_Theme.useThemeManagerContext)(
572
579
  spacedChildren({
573
580
  separator,
574
581
  children,
@@ -579,7 +586,7 @@ function createComponent(configIn, ParentComponent) {
579
586
  stateRef.current.hasProvidedThemeManager ? themeManager : void 0,
580
587
  stateRef.current.themeShouldReset
581
588
  );
582
- let content;
589
+ let content = !children || asChild ? children : innerContent;
583
590
  if (asChild) {
584
591
  elementType = import_Slot.Slot;
585
592
  viewProps = {
@@ -608,7 +615,7 @@ function createComponent(configIn, ParentComponent) {
608
615
  }
609
616
  }
610
617
  }
611
- content = (0, import_react.createElement)(elementType, viewProps, childEls);
618
+ content = (0, import_react.createElement)(elementType, viewProps, content);
612
619
  if (process.env.TAMAGUI_TARGET === "web") {
613
620
  if (events || isAnimatedReactNativeWeb) {
614
621
  content = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
@@ -654,7 +661,6 @@ function createComponent(configIn, ParentComponent) {
654
661
  styles,
655
662
  pseudos,
656
663
  content,
657
- childEls,
658
664
  shouldAvoidClasses,
659
665
  avoidClasses: avoidClassesWhileAnimating,
660
666
  animation: props.animation,
@@ -834,15 +840,9 @@ const Spacer = createComponent({
834
840
  }
835
841
  }
836
842
  });
837
- function spacedChildren({
838
- isZStack,
839
- children,
840
- space,
841
- direction,
842
- spaceFlex,
843
- separator
844
- }) {
845
- var _a;
843
+ function spacedChildren(props) {
844
+ var _a, _b, _c;
845
+ const { isZStack, children, space, direction, spaceFlex, separator } = props;
846
846
  const hasSpace = !!(space || spaceFlex);
847
847
  const hasSeparator = !(separator === void 0 || separator === null);
848
848
  if (!(hasSpace || hasSeparator || isZStack)) {
@@ -850,22 +850,20 @@ function spacedChildren({
850
850
  }
851
851
  const childrenList = import_react.Children.toArray(children);
852
852
  const len = childrenList.length;
853
- if (len <= 1 && !isZStack) {
854
- if (len === 1) {
855
- const [onlyChild] = childrenList;
856
- if (import_react.default.isValidElement(onlyChild) && ((_a = onlyChild.type) == null ? void 0 : _a["shouldForwardSpace"])) {
857
- return import_react.default.cloneElement(onlyChild, {
858
- space,
859
- spaceFlex,
860
- separator
861
- });
862
- }
863
- }
853
+ if (len <= 1 && !isZStack && !((_b = (_a = childrenList[0]) == null ? void 0 : _a["type"]) == null ? void 0 : _b["shouldForwardSpace"])) {
864
854
  return childrenList;
865
855
  }
866
856
  const final = [];
867
- for (const [index, child] of childrenList.entries()) {
857
+ for (let [index, child] of childrenList.entries()) {
868
858
  const isEmpty = child === null || child === void 0 || Array.isArray(child) && child.length === 0;
859
+ if (!isEmpty && import_react.default.isValidElement(child) && ((_c = child.type) == null ? void 0 : _c["shouldForwardSpace"])) {
860
+ child = import_react.default.cloneElement(child, {
861
+ space,
862
+ spaceFlex,
863
+ separator,
864
+ key: child.key
865
+ });
866
+ }
869
867
  if (isEmpty || !child || child["key"] && !isZStack) {
870
868
  final.push(child);
871
869
  } else {