@tamagui/core 1.0.0-beta.149 → 1.0.0-beta.15

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 (294) hide show
  1. package/README.md +1 -0
  2. package/dist/cjs/Tamagui.js +13 -1
  3. package/dist/cjs/Tamagui.js.map +2 -2
  4. package/dist/cjs/ThemeContext.js +4 -0
  5. package/dist/cjs/ThemeManager.js +30 -14
  6. package/dist/cjs/ThemeManager.js.map +2 -2
  7. package/dist/cjs/conf.js +10 -1
  8. package/dist/cjs/conf.js.map +2 -2
  9. package/dist/cjs/constants/constants.js +6 -0
  10. package/dist/cjs/constants/platform.js +15 -0
  11. package/dist/cjs/constants/platform.js.map +2 -2
  12. package/dist/cjs/constants/rnw.js +4 -0
  13. package/dist/cjs/contexts/ButtonInsideButtonContext.js +4 -0
  14. package/dist/cjs/createComponent.js +175 -96
  15. package/dist/cjs/createComponent.js.map +2 -2
  16. package/dist/cjs/createFont.js +4 -0
  17. package/dist/cjs/createShorthands.js +4 -0
  18. package/dist/cjs/createTamagui.js +48 -27
  19. package/dist/cjs/createTamagui.js.map +2 -2
  20. package/dist/cjs/createTheme.js +4 -0
  21. package/dist/cjs/createTokens.js +7 -6
  22. package/dist/cjs/createTokens.js.map +2 -2
  23. package/dist/cjs/createVariable.js +18 -2
  24. package/dist/cjs/createVariable.js.map +2 -2
  25. package/dist/cjs/helpers/RNComponents.js +4 -0
  26. package/dist/cjs/helpers/addStylesUsingClassname.js +8 -0
  27. package/dist/cjs/helpers/addStylesUsingClassname.js.map +2 -2
  28. package/dist/cjs/helpers/areEqualSets.js +4 -0
  29. package/dist/cjs/helpers/createMediaStyle.js +5 -2
  30. package/dist/cjs/helpers/createMediaStyle.js.map +2 -2
  31. package/dist/cjs/helpers/createPropMapper.js +53 -22
  32. package/dist/cjs/helpers/createPropMapper.js.map +2 -2
  33. package/dist/cjs/helpers/createShallowUpdate.js +4 -0
  34. package/dist/cjs/helpers/createTamaguiProvider.js +4 -0
  35. package/dist/cjs/helpers/extendStaticConfig.js +9 -6
  36. package/dist/cjs/helpers/extendStaticConfig.js.map +2 -2
  37. package/dist/cjs/helpers/fixNativeShadow.js +4 -0
  38. package/dist/cjs/helpers/fixNativeShadow.native.js +10 -9
  39. package/dist/cjs/helpers/fixNativeShadow.native.js.map +2 -2
  40. package/dist/cjs/helpers/getButtonSize.js +45 -0
  41. package/dist/cjs/helpers/getButtonSize.js.map +7 -0
  42. package/dist/cjs/helpers/getExpandedShorthands.js +4 -0
  43. package/dist/cjs/{constants/pseudos.js → helpers/getSize.js} +17 -19
  44. package/dist/cjs/helpers/getSize.js.map +7 -0
  45. package/dist/cjs/helpers/getSplitStyles.js +137 -55
  46. package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
  47. package/dist/cjs/helpers/getStylesAtomic.js +20 -3
  48. package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
  49. package/dist/cjs/helpers/getStylesAtomic.native.js +4 -0
  50. package/dist/cjs/helpers/getTextSize.js +56 -0
  51. package/dist/cjs/helpers/getTextSize.js.map +7 -0
  52. package/dist/cjs/helpers/insertStyleRule.js +42 -27
  53. package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
  54. package/dist/cjs/helpers/isObj.js +4 -0
  55. package/dist/cjs/helpers/isTamaguiElement.js +4 -0
  56. package/dist/cjs/helpers/matchMedia.js +4 -0
  57. package/dist/cjs/helpers/matchMedia.native.js +4 -0
  58. package/dist/cjs/helpers/proxyThemeVariables.js +40 -0
  59. package/dist/cjs/helpers/proxyThemeVariables.js.map +7 -0
  60. package/dist/cjs/helpers/themeable.js +7 -2
  61. package/dist/cjs/helpers/themeable.js.map +2 -2
  62. package/dist/cjs/helpers/validate.js +53 -11
  63. package/dist/cjs/helpers/validate.js.map +2 -2
  64. package/dist/cjs/helpers/withStaticProperties.js +4 -0
  65. package/dist/cjs/helpers/wrapThemeManagerContext.js +4 -0
  66. package/dist/cjs/hooks/useConstant.js +4 -0
  67. package/dist/cjs/hooks/useFeatures.js +4 -0
  68. package/dist/cjs/hooks/useId.js +59 -0
  69. package/dist/cjs/hooks/useId.js.map +7 -0
  70. package/dist/cjs/hooks/useIsMounted.js +4 -0
  71. package/dist/cjs/hooks/useIsTouchDevice.js +8 -4
  72. package/dist/cjs/hooks/useIsTouchDevice.js.map +2 -2
  73. package/dist/cjs/hooks/useMedia.js +14 -0
  74. package/dist/cjs/hooks/useMedia.js.map +2 -2
  75. package/dist/cjs/hooks/usePressable.js +4 -0
  76. package/dist/cjs/hooks/usePrevious.js +1 -0
  77. package/dist/cjs/{createShallowUpdate.js.map → hooks/usePrevious.js.map} +0 -0
  78. package/dist/cjs/hooks/useTheme.js +30 -16
  79. package/dist/cjs/hooks/useTheme.js.map +2 -2
  80. package/dist/cjs/hooks/useUnmountEffect.js +4 -0
  81. package/dist/cjs/index.js +24 -6
  82. package/dist/cjs/index.js.map +2 -2
  83. package/dist/cjs/static.js +3 -0
  84. package/dist/cjs/static.js.map +2 -2
  85. package/dist/cjs/styled.js +11 -5
  86. package/dist/cjs/styled.js.map +2 -2
  87. package/dist/cjs/types.js.map +1 -1
  88. package/dist/cjs/views/Slot.js +134 -0
  89. package/dist/cjs/views/Slot.js.map +7 -0
  90. package/dist/cjs/views/Stack.js +4 -0
  91. package/dist/cjs/views/Text.js +13 -14
  92. package/dist/cjs/views/Text.js.map +2 -2
  93. package/dist/cjs/views/TextAncestorContext.js +6 -0
  94. package/dist/cjs/views/Theme.js +7 -3
  95. package/dist/cjs/views/Theme.js.map +2 -2
  96. package/dist/cjs/views/ThemeInverse.js +10 -1
  97. package/dist/cjs/views/ThemeInverse.js.map +2 -2
  98. package/dist/cjs/views/ThemeProvider.js +6 -1
  99. package/dist/cjs/views/ThemeProvider.js.map +2 -2
  100. package/dist/cjs/views/ThemeReset.js +4 -0
  101. package/dist/esm/Tamagui.js +8 -2
  102. package/dist/esm/Tamagui.js.map +2 -2
  103. package/dist/esm/ThemeManager.js +21 -11
  104. package/dist/esm/ThemeManager.js.map +2 -2
  105. package/dist/esm/conf.js +0 -1
  106. package/dist/esm/conf.js.map +2 -2
  107. package/dist/esm/constants/platform.js +2 -0
  108. package/dist/esm/constants/platform.js.map +2 -2
  109. package/dist/esm/createComponent.js +170 -104
  110. package/dist/esm/createComponent.js.map +2 -2
  111. package/dist/esm/createTamagui.js +45 -28
  112. package/dist/esm/createTamagui.js.map +2 -2
  113. package/dist/esm/createTokens.js +2 -6
  114. package/dist/esm/createTokens.js.map +2 -2
  115. package/dist/esm/createVariable.js +8 -2
  116. package/dist/esm/createVariable.js.map +2 -2
  117. package/dist/esm/helpers/addStylesUsingClassname.js +4 -1
  118. package/dist/esm/helpers/addStylesUsingClassname.js.map +2 -2
  119. package/dist/esm/helpers/createMediaStyle.js +0 -2
  120. package/dist/esm/helpers/createMediaStyle.js.map +2 -2
  121. package/dist/esm/helpers/createPropMapper.js +50 -22
  122. package/dist/esm/helpers/createPropMapper.js.map +2 -2
  123. package/dist/esm/helpers/extendStaticConfig.js +9 -6
  124. package/dist/esm/helpers/extendStaticConfig.js.map +2 -2
  125. package/dist/esm/helpers/fixNativeShadow.native.js +7 -9
  126. package/dist/esm/helpers/fixNativeShadow.native.js.map +2 -2
  127. package/dist/esm/helpers/getButtonSize.js +24 -0
  128. package/dist/esm/helpers/getButtonSize.js.map +7 -0
  129. package/dist/esm/helpers/getSize.js +13 -0
  130. package/dist/esm/helpers/getSize.js.map +7 -0
  131. package/dist/esm/helpers/getSplitStyles.js +136 -57
  132. package/dist/esm/helpers/getSplitStyles.js.map +2 -2
  133. package/dist/esm/helpers/getStylesAtomic.js +15 -3
  134. package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
  135. package/dist/esm/helpers/getTextSize.js +34 -0
  136. package/dist/esm/helpers/getTextSize.js.map +7 -0
  137. package/dist/esm/helpers/insertStyleRule.js +32 -27
  138. package/dist/esm/helpers/insertStyleRule.js.map +2 -2
  139. package/dist/esm/helpers/proxyThemeVariables.js +18 -0
  140. package/dist/esm/helpers/proxyThemeVariables.js.map +7 -0
  141. package/dist/esm/helpers/themeable.js +3 -2
  142. package/dist/esm/helpers/themeable.js.map +2 -2
  143. package/dist/esm/helpers/validate.js +24 -11
  144. package/dist/esm/helpers/validate.js.map +2 -2
  145. package/dist/esm/hooks/useId.js +35 -0
  146. package/dist/esm/hooks/useId.js.map +7 -0
  147. package/dist/esm/hooks/useIsTouchDevice.js +6 -6
  148. package/dist/esm/hooks/useIsTouchDevice.js.map +2 -2
  149. package/dist/esm/hooks/useMedia.js +3 -0
  150. package/dist/esm/hooks/useMedia.js.map +2 -2
  151. package/dist/esm/hooks/usePrevious.js +1 -0
  152. package/dist/esm/{createShallowUpdate.js.map → hooks/usePrevious.js.map} +0 -0
  153. package/dist/esm/hooks/useTheme.js +22 -16
  154. package/dist/esm/hooks/useTheme.js.map +2 -2
  155. package/dist/esm/index.js +13 -6
  156. package/dist/esm/index.js.map +2 -2
  157. package/dist/esm/static.js +3 -0
  158. package/dist/esm/static.js.map +2 -2
  159. package/dist/esm/styled.js +7 -5
  160. package/dist/esm/styled.js.map +2 -2
  161. package/dist/esm/views/Slot.js +82 -0
  162. package/dist/esm/views/Slot.js.map +7 -0
  163. package/dist/esm/views/Text.js +9 -14
  164. package/dist/esm/views/Text.js.map +2 -2
  165. package/dist/esm/views/Theme.js +3 -3
  166. package/dist/esm/views/Theme.js.map +2 -2
  167. package/dist/esm/views/ThemeInverse.js +6 -2
  168. package/dist/esm/views/ThemeInverse.js.map +2 -2
  169. package/dist/esm/views/ThemeProvider.js +2 -1
  170. package/dist/esm/views/ThemeProvider.js.map +2 -2
  171. package/dist/jsx/Tamagui.js +8 -2
  172. package/dist/jsx/ThemeManager.js +21 -11
  173. package/dist/jsx/conf.js +0 -1
  174. package/dist/jsx/constants/platform.js +2 -0
  175. package/dist/jsx/createComponent.js +161 -100
  176. package/dist/jsx/createTamagui.js +45 -28
  177. package/dist/jsx/createTokens.js +2 -6
  178. package/dist/jsx/createVariable.js +8 -2
  179. package/dist/jsx/helpers/addStylesUsingClassname.js +4 -1
  180. package/dist/jsx/helpers/createMediaStyle.js +0 -2
  181. package/dist/jsx/helpers/createPropMapper.js +50 -22
  182. package/dist/jsx/helpers/extendStaticConfig.js +9 -6
  183. package/dist/jsx/helpers/fixNativeShadow.native.js +7 -9
  184. package/dist/jsx/helpers/getButtonSize.js +23 -0
  185. package/dist/jsx/helpers/getSize.js +12 -0
  186. package/dist/jsx/helpers/getSplitStyles.js +136 -57
  187. package/dist/jsx/helpers/getStylesAtomic.js +15 -3
  188. package/dist/jsx/helpers/getTextSize.js +33 -0
  189. package/dist/jsx/helpers/insertStyleRule.js +32 -27
  190. package/dist/jsx/helpers/proxyThemeVariables.js +17 -0
  191. package/dist/jsx/helpers/themeable.js +3 -3
  192. package/dist/jsx/helpers/validate.js +24 -11
  193. package/dist/jsx/hooks/useId.js +34 -0
  194. package/dist/jsx/hooks/useIsTouchDevice.js +6 -6
  195. package/dist/jsx/hooks/useMedia.js +3 -0
  196. package/dist/jsx/{createShallowUpdate.js → hooks/usePrevious.js} +0 -0
  197. package/dist/jsx/hooks/useTheme.js +22 -16
  198. package/dist/jsx/index.js +13 -6
  199. package/dist/jsx/static.js +3 -0
  200. package/dist/jsx/styled.js +7 -5
  201. package/dist/jsx/views/Slot.js +75 -0
  202. package/dist/jsx/views/Text.js +9 -14
  203. package/dist/jsx/views/Theme.js +4 -4
  204. package/dist/jsx/views/ThemeInverse.js +6 -1
  205. package/dist/jsx/views/ThemeProvider.js +2 -2
  206. package/package.json +8 -6
  207. package/types/Tamagui.d.ts +16 -1
  208. package/types/Tamagui.d.ts.map +1 -1
  209. package/types/ThemeManager.d.ts +3 -3
  210. package/types/ThemeManager.d.ts.map +1 -1
  211. package/types/conf.d.ts +2 -0
  212. package/types/conf.d.ts.map +1 -1
  213. package/types/constants/platform.d.ts +1 -0
  214. package/types/constants/platform.d.ts.map +1 -1
  215. package/types/createComponent.d.ts +3 -4
  216. package/types/createComponent.d.ts.map +1 -1
  217. package/types/createTamagui.d.ts +3 -1
  218. package/types/createTamagui.d.ts.map +1 -1
  219. package/types/createTokens.d.ts +0 -26
  220. package/types/createTokens.d.ts.map +1 -1
  221. package/types/createVariable.d.ts +1 -0
  222. package/types/createVariable.d.ts.map +1 -1
  223. package/types/helpers/addStylesUsingClassname.d.ts.map +1 -1
  224. package/types/helpers/createMediaStyle.d.ts.map +1 -1
  225. package/types/helpers/createPropMapper.d.ts +1 -1
  226. package/types/helpers/createPropMapper.d.ts.map +1 -1
  227. package/types/helpers/extendStaticConfig.d.ts +2 -2
  228. package/types/helpers/extendStaticConfig.d.ts.map +1 -1
  229. package/types/helpers/fixNativeShadow.native.d.ts +2 -1
  230. package/types/helpers/fixNativeShadow.native.d.ts.map +1 -1
  231. package/types/helpers/getButtonSize.d.ts +8 -0
  232. package/types/helpers/getButtonSize.d.ts.map +1 -0
  233. package/types/helpers/getSize.d.ts +3 -0
  234. package/types/helpers/getSize.d.ts.map +1 -0
  235. package/types/helpers/getSplitStyles.d.ts +14 -6
  236. package/types/helpers/getSplitStyles.d.ts.map +1 -1
  237. package/types/helpers/getStylesAtomic.d.ts.map +1 -1
  238. package/types/helpers/getTextSize.d.ts +3 -0
  239. package/types/helpers/getTextSize.d.ts.map +1 -0
  240. package/types/helpers/insertStyleRule.d.ts +2 -1
  241. package/types/helpers/insertStyleRule.d.ts.map +1 -1
  242. package/types/helpers/proxyThemeVariables.d.ts +2 -0
  243. package/types/helpers/proxyThemeVariables.d.ts.map +1 -0
  244. package/types/helpers/themeable.d.ts +3 -1
  245. package/types/helpers/themeable.d.ts.map +1 -1
  246. package/types/helpers/validate.d.ts.map +1 -1
  247. package/types/hooks/useId.d.ts +9 -0
  248. package/types/hooks/useId.d.ts.map +1 -0
  249. package/types/hooks/useMedia.d.ts +2 -6
  250. package/types/hooks/useMedia.d.ts.map +1 -1
  251. package/types/hooks/usePrevious.d.ts +1 -0
  252. package/types/hooks/usePrevious.d.ts.map +1 -0
  253. package/types/hooks/useTheme.d.ts +1 -1
  254. package/types/hooks/useTheme.d.ts.map +1 -1
  255. package/types/index.d.ts +11 -6
  256. package/types/index.d.ts.map +1 -1
  257. package/types/static.d.ts +3 -0
  258. package/types/static.d.ts.map +1 -1
  259. package/types/styled.d.ts +12 -3
  260. package/types/styled.d.ts.map +1 -1
  261. package/types/types.d.ts +86 -46
  262. package/types/types.d.ts.map +1 -1
  263. package/types/views/Slot.d.ts +9 -0
  264. package/types/views/Slot.d.ts.map +1 -0
  265. package/types/views/Text.d.ts.map +1 -1
  266. package/types/views/Theme.d.ts +1 -0
  267. package/types/views/Theme.d.ts.map +1 -1
  268. package/types/views/ThemeInverse.d.ts.map +1 -1
  269. package/types/views/ThemeProvider.d.ts +1 -0
  270. package/types/views/ThemeProvider.d.ts.map +1 -1
  271. package/LICENSE +0 -21
  272. package/dist/cjs/constants/pseudos.js.map +0 -7
  273. package/dist/cjs/createShallowUpdate.js +0 -1
  274. package/dist/cjs/devtools.js +0 -32
  275. package/dist/cjs/devtools.js.map +0 -7
  276. package/dist/cjs/spacedChildren.js +0 -86
  277. package/dist/cjs/spacedChildren.js.map +0 -7
  278. package/dist/cjs/tamagui-base.css +0 -8
  279. package/dist/cjs/tamagui-base.css.map +0 -7
  280. package/dist/esm/constants/pseudos.js +0 -18
  281. package/dist/esm/constants/pseudos.js.map +0 -7
  282. package/dist/esm/createShallowUpdate.js +0 -1
  283. package/dist/esm/devtools.js +0 -14
  284. package/dist/esm/devtools.js.map +0 -7
  285. package/dist/esm/spacedChildren.js +0 -52
  286. package/dist/esm/spacedChildren.js.map +0 -7
  287. package/dist/esm/tamagui-base.css +0 -8
  288. package/dist/esm/tamagui-base.css.map +0 -7
  289. package/dist/jsx/constants/pseudos.js +0 -17
  290. package/dist/jsx/devtools.js +0 -13
  291. package/dist/jsx/spacedChildren.js +0 -44
  292. package/dist/jsx/tamagui-base.css +0 -7
  293. package/types/spacedChildren.d.ts +0 -9
  294. package/types/spacedChildren.d.ts.map +0 -1
@@ -0,0 +1,134 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
25
+ var __objRest = (source, exclude) => {
26
+ var target = {};
27
+ for (var prop in source)
28
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
29
+ target[prop] = source[prop];
30
+ if (source != null && __getOwnPropSymbols)
31
+ for (var prop of __getOwnPropSymbols(source)) {
32
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
33
+ target[prop] = source[prop];
34
+ }
35
+ return target;
36
+ };
37
+ var __export = (target, all) => {
38
+ for (var name in all)
39
+ __defProp(target, name, { get: all[name], enumerable: true });
40
+ };
41
+ var __copyProps = (to, from, except, desc) => {
42
+ if (from && typeof from === "object" || typeof from === "function") {
43
+ for (let key of __getOwnPropNames(from))
44
+ if (!__hasOwnProp.call(to, key) && key !== except)
45
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
46
+ }
47
+ return to;
48
+ };
49
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
50
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
51
+ var Slot_exports = {};
52
+ __export(Slot_exports, {
53
+ Slot: () => Slot,
54
+ Slottable: () => Slottable
55
+ });
56
+ module.exports = __toCommonJS(Slot_exports);
57
+ var import_compose_refs = require("@tamagui/compose-refs");
58
+ var React = __toESM(require("react"));
59
+ const Slot = React.forwardRef((props, forwardedRef) => {
60
+ const _a = props, { children } = _a, slotProps = __objRest(_a, ["children"]);
61
+ if (React.Children.toArray(children).some(isSlottable)) {
62
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, React.Children.map(children, (child) => {
63
+ return isSlottable(child) ? /* @__PURE__ */ React.createElement(SlotClone, __spreadProps(__spreadValues({}, slotProps), {
64
+ ref: forwardedRef
65
+ }), child.props.children) : child;
66
+ }));
67
+ }
68
+ return /* @__PURE__ */ React.createElement(SlotClone, __spreadProps(__spreadValues({}, slotProps), {
69
+ ref: forwardedRef
70
+ }), children);
71
+ });
72
+ Slot.displayName = "Slot";
73
+ const SlotClone = React.forwardRef((props, forwardedRef) => {
74
+ const _a = props, { children } = _a, slotProps = __objRest(_a, ["children"]);
75
+ if (React.isValidElement(children)) {
76
+ return React.cloneElement(children, __spreadProps(__spreadValues({}, mergeProps(children, slotProps)), {
77
+ ref: (0, import_compose_refs.composeRefs)(forwardedRef, children.ref)
78
+ }));
79
+ }
80
+ return React.Children.count(children) > 1 ? React.Children.only(null) : null;
81
+ });
82
+ SlotClone.displayName = "SlotClone";
83
+ const Slottable = /* @__PURE__ */ __name(({ children }) => {
84
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
85
+ }, "Slottable");
86
+ function isSlottable(child) {
87
+ return React.isValidElement(child);
88
+ }
89
+ __name(isSlottable, "isSlottable");
90
+ const pressMap = {
91
+ onPress: "onClick",
92
+ onPressOut: "onMouseOut",
93
+ onPressIn: "onMouseIn"
94
+ };
95
+ function mergeProps(child, slotProps) {
96
+ const childProps = child.props;
97
+ const overrideProps = __spreadValues({}, childProps);
98
+ const isHTMLChild = typeof child.type === "string";
99
+ if (isHTMLChild) {
100
+ for (const key in pressMap) {
101
+ if (key in slotProps) {
102
+ slotProps[pressMap[key]] = slotProps[key];
103
+ delete slotProps[key];
104
+ }
105
+ }
106
+ }
107
+ for (let propName in childProps) {
108
+ const slotPropValue = slotProps[propName];
109
+ const childPropValue = childProps[propName];
110
+ if (isHTMLChild && pressMap[propName]) {
111
+ propName = pressMap[propName];
112
+ delete overrideProps[propName];
113
+ }
114
+ const isHandler = /^on[A-Z]/.test(propName);
115
+ if (isHandler) {
116
+ overrideProps[propName] = (...args) => {
117
+ childPropValue == null ? void 0 : childPropValue(...args);
118
+ slotPropValue == null ? void 0 : slotPropValue(...args);
119
+ };
120
+ } else if (propName === "style") {
121
+ overrideProps[propName] = __spreadValues(__spreadValues({}, slotPropValue), childPropValue);
122
+ } else if (propName === "className") {
123
+ overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
124
+ }
125
+ }
126
+ return __spreadValues(__spreadValues({}, slotProps), overrideProps);
127
+ }
128
+ __name(mergeProps, "mergeProps");
129
+ // Annotate the CommonJS export names for ESM import in node:
130
+ 0 && (module.exports = {
131
+ Slot,
132
+ Slottable
133
+ });
134
+ //# sourceMappingURL=Slot.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/views/Slot.tsx"],
4
+ "sourcesContent": ["// via radix\n\nimport { composeRefs } from '@tamagui/compose-refs'\nimport * as React from 'react'\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * -----------------------------------------------------------------------------------------------*/\n\nexport type SlotProps = {\n children?: React.ReactNode\n}\n\nexport const Slot = React.forwardRef<HTMLElement, SlotProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props\n\n if (React.Children.toArray(children).some(isSlottable)) {\n return (\n <>\n {React.Children.map(children, (child) => {\n return isSlottable(child) ? (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {child.props.children}\n </SlotClone>\n ) : (\n child\n )\n })}\n </>\n )\n }\n\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {children}\n </SlotClone>\n )\n})\n\nSlot.displayName = 'Slot'\n\n/* -------------------------------------------------------------------------------------------------\n * SlotClone\n * -----------------------------------------------------------------------------------------------*/\n\ninterface SlotCloneProps {\n children: React.ReactNode\n}\n\nconst SlotClone = React.forwardRef<any, SlotCloneProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props\n\n if (React.isValidElement(children)) {\n return React.cloneElement(children, {\n ...mergeProps(children, slotProps),\n ref: composeRefs(forwardedRef, (children as any).ref),\n })\n }\n\n return React.Children.count(children) > 1 ? React.Children.only(null) : null\n})\n\nSlotClone.displayName = 'SlotClone'\n\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * -----------------------------------------------------------------------------------------------*/\n\nexport const Slottable = ({ children }: { children: React.ReactNode }) => {\n return <>{children}</>\n}\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype AnyProps = Record<string, any>\n\nfunction isSlottable(child: React.ReactNode): child is React.ReactElement {\n return React.isValidElement(child)\n}\n\nconst pressMap = {\n onPress: 'onClick',\n onPressOut: 'onMouseOut',\n onPressIn: 'onMouseIn',\n}\n\nfunction mergeProps(child: any, slotProps: AnyProps) {\n const childProps = child.props\n\n // all child props should override\n const overrideProps = { ...childProps }\n\n const isHTMLChild = typeof child.type === 'string'\n\n if (isHTMLChild) {\n for (const key in pressMap) {\n if (key in slotProps) {\n slotProps[pressMap[key]] = slotProps[key]\n delete slotProps[key]\n }\n }\n }\n\n for (let propName in childProps) {\n const slotPropValue = slotProps[propName]\n const childPropValue = childProps[propName]\n\n if (isHTMLChild && pressMap[propName]) {\n propName = pressMap[propName]\n delete overrideProps[propName]\n }\n\n const isHandler = /^on[A-Z]/.test(propName)\n // if it's a handler, modify the override by composing the base handler\n if (isHandler) {\n overrideProps[propName] = (...args: unknown[]) => {\n childPropValue?.(...args)\n slotPropValue?.(...args)\n }\n }\n // if it's `style`, we merge them\n else if (propName === 'style') {\n overrideProps[propName] = { ...slotPropValue, ...childPropValue }\n } else if (propName === 'className') {\n overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(' ')\n }\n }\n\n return { ...slotProps, ...overrideProps }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,0BAA4B;AAC5B,YAAuB;AAUhB,MAAM,OAAO,MAAM,WAAmC,CAAC,OAAO,iBAAiB;AACpF,QAAmC,YAA3B,eAA2B,IAAd,sBAAc,IAAd,CAAb;AAER,MAAI,MAAM,SAAS,QAAQ,QAAQ,EAAE,KAAK,WAAW,GAAG;AACtD,WACE,0DACG,MAAM,SAAS,IAAI,UAAU,CAAC,UAAU;AACvC,aAAO,YAAY,KAAK,IACtB,oCAAC,4CAAc,YAAd;AAAA,QAAyB,KAAK;AAAA,UAC5B,MAAM,MAAM,QACf,IAEA;AAAA,IAEJ,CAAC,CACH;AAAA,EAEJ;AAEA,SACE,oCAAC,4CAAc,YAAd;AAAA,IAAyB,KAAK;AAAA,MAC5B,QACH;AAEJ,CAAC;AAED,KAAK,cAAc;AAUnB,MAAM,YAAY,MAAM,WAAgC,CAAC,OAAO,iBAAiB;AAC/E,QAAmC,YAA3B,eAA2B,IAAd,sBAAc,IAAd,CAAb;AAER,MAAI,MAAM,eAAe,QAAQ,GAAG;AAClC,WAAO,MAAM,aAAa,UAAU,iCAC/B,WAAW,UAAU,SAAS,IADC;AAAA,MAElC,KAAK,qCAAY,c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ponent)({
45
45
  flexDirection: "column"
46
46
  })
47
47
  });
48
+ // Annotate the CommonJS export names for ESM import in node:
49
+ 0 && (module.exports = {
50
+ Stack
51
+ });
48
52
  //# sourceMappingURL=Stack.js.map
@@ -46,16 +46,18 @@ const ellipseStyle = {
46
46
  const Text = (0, import_createComponent.createComponent)({
47
47
  componentName: "Text",
48
48
  isText: true,
49
- defaultProps: {
50
- display: import_platform.isWeb ? "inline" : "flex",
49
+ defaultProps: __spreadValues({
50
+ display: "flex",
51
+ fontFamily: "System"
52
+ }, import_platform.isWeb && {
53
+ display: "inline",
51
54
  boxSizing: "border-box",
52
- fontFamily: "System",
53
55
  wordWrap: "break-word"
54
- },
56
+ }),
55
57
  variants: {
56
58
  numberOfLines: {
57
- 1: ellipseStyle,
58
- ":number": (lines) => lines > 1 ? { WebkitLineClamp: 1 } : null
59
+ 1: import_platform.isWeb ? ellipseStyle : { numberOfLines: 1 },
60
+ ":number": (numberOfLines) => import_platform.isWeb ? numberOfLines >= 1 ? { WebkitLineClamp: numberOfLines } : null : { numberOfLines }
59
61
  },
60
62
  selectable: {
61
63
  true: {
@@ -79,13 +81,10 @@ const Text = (0, import_createComponent.createComponent)({
79
81
  }
80
82
  },
81
83
  deoptProps: new Set(import_platform.isWeb ? [] : ["ellipse"]),
82
- validStyles: __spreadValues(__spreadValues(__spreadValues({}, import_helpers.validStyles), import_helpers.stylePropsTextOnly), import_platform.isWeb && {
83
- userSelect: true,
84
- textOverflow: true,
85
- whiteSpace: true,
86
- wordWrap: true,
87
- selectable: true,
88
- cursor: true
89
- })
84
+ validStyles: __spreadValues(__spreadValues({}, import_helpers.validStyles), import_helpers.stylePropsTextOnly)
85
+ });
86
+ // Annotate the CommonJS export names for ESM import in node:
87
+ 0 && (module.exports = {
88
+ Text
90
89
  });
91
90
  //# sourceMappingURL=Text.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/views/Text.tsx"],
4
- "sourcesContent": ["import { stylePropsTextOnly, validStyles } from '@tamagui/helpers'\nimport { Text as TextView } from 'react-native'\n\nimport { isWeb } from '../constants/platform'\nimport { createComponent } from '../createComponent'\nimport { TextProps, TextPropsBase } from '../types'\n\nconst ellipseStyle = {\n maxWidth: '100%',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n}\n\nexport const Text = createComponent<TextProps, TextView, TextPropsBase>({\n componentName: 'Text',\n isText: true,\n defaultProps: {\n display: isWeb ? 'inline' : 'flex',\n boxSizing: 'border-box',\n fontFamily: 'System',\n wordWrap: 'break-word',\n },\n variants: {\n numberOfLines: {\n 1: ellipseStyle,\n // TODO imply fn, test 1, could do types `>1` `<2`\n ':number': (lines) => (lines > 1 ? { WebkitLineClamp: 1 } : null),\n },\n\n selectable: {\n true: {\n userSelect: 'text',\n cursor: 'text',\n },\n false: {\n userSelect: 'none',\n },\n },\n\n pressable: {\n true: {\n cursor: 'pointer',\n },\n },\n\n ellipse: {\n true: isWeb\n ? ellipseStyle\n : {\n numberOfLines: 1,\n lineBreakMode: 'clip',\n },\n },\n },\n deoptProps: new Set(isWeb ? [] : ['ellipse']),\n validStyles: {\n ...validStyles,\n ...stylePropsTextOnly,\n ...(isWeb && {\n userSelect: true,\n textOverflow: true,\n whiteSpace: true,\n wordWrap: true,\n selectable: true,\n cursor: true,\n }),\n },\n})\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAgD;AAGhD,sBAAsB;AACtB,6BAAgC;AAGhC,MAAM,eAAe;AAAA,EACnB,UAAU;AAAA,EACV,UAAU;AAAA,EACV,cAAc;AAAA,EACd,YAAY;AACd;AAEO,MAAM,OAAO,4CAAoD;AAAA,EACtE,eAAe;AAAA,EACf,QAAQ;AAAA,EACR,cAAc;AAAA,IACZ,SAAS,wBAAQ,WAAW;AAAA,IAC5B,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,UAAU;AAAA,EACZ;AAAA,EACA,UAAU;AAAA,IACR,eAAe;AAAA,MACb,GAAG;AAAA,MAEH,WAAW,CAAC,UAAW,QAAQ,IAAI,EAAE,iBAAiB,EAAE,IAAI;AAAA,IAC9D;AAAA,IAEA,YAAY;AAAA,MACV,MAAM;AAAA,QACJ,YAAY;AAAA,QACZ,QAAQ;AAAA,MACV;AAAA,MACA,OAAO;AAAA,QACL,YAAY;AAAA,MACd;AAAA,IACF;AAAA,IAEA,WAAW;AAAA,MACT,MAAM;AAAA,QACJ,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,IAEA,SAAS;AAAA,MACP,MAAM,wBACF,eACA;AAAA,QACE,eAAe;AAAA,QACf,eAAe;AAAA,MACjB;AAAA,IACN;AAAA,EACF;AAAA,EACA,YAAY,IAAI,IAAI,wBAAQ,CAAC,IAAI,CAAC,SAAS,CAAC;AAAA,EAC5C,aAAa,iDACR,6BACA,oCACC,yBAAS;AAAA,IACX,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,QAAQ;AAAA,EACV;AAEJ,CAAC;",
4
+ "sourcesContent": ["import { stylePropsTextOnly, validStyles } from '@tamagui/helpers'\nimport { Text as TextView } from 'react-native'\n\nimport { isWeb } from '../constants/platform'\nimport { createComponent } from '../createComponent'\nimport { TextProps, TextPropsBase } from '../types'\n\nconst ellipseStyle = {\n maxWidth: '100%',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n}\n\nexport const Text = createComponent<TextProps, TextView, TextPropsBase>({\n componentName: 'Text',\n isText: true,\n\n defaultProps: {\n display: 'flex',\n fontFamily: 'System',\n ...(isWeb && {\n display: 'inline',\n boxSizing: 'border-box',\n wordWrap: 'break-word',\n }),\n },\n\n variants: {\n numberOfLines: {\n 1: isWeb ? ellipseStyle : { numberOfLines: 1 },\n\n ':number': (numberOfLines) =>\n isWeb\n ? numberOfLines >= 1\n ? { WebkitLineClamp: numberOfLines }\n : null\n : { numberOfLines },\n },\n\n selectable: {\n true: {\n userSelect: 'text',\n cursor: 'text',\n },\n false: {\n userSelect: 'none',\n },\n },\n\n pressable: {\n true: {\n cursor: 'pointer',\n },\n },\n\n ellipse: {\n true: isWeb\n ? ellipseStyle\n : {\n numberOfLines: 1,\n lineBreakMode: 'clip',\n },\n },\n },\n\n deoptProps: new Set(isWeb ? [] : ['ellipse']),\n\n validStyles: {\n ...validStyles,\n ...stylePropsTextOnly,\n },\n})\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAgD;AAGhD,sBAAsB;AACtB,6BAAgC;AAGhC,MAAM,eAAe;AAAA,EACnB,UAAU;AAAA,EACV,UAAU;AAAA,EACV,cAAc;AAAA,EACd,YAAY;AACd;AAEO,MAAM,OAAO,4CAAoD;AAAA,EACtE,eAAe;AAAA,EACf,QAAQ;AAAA,EAER,cAAc;AAAA,IACZ,SAAS;AAAA,IACT,YAAY;AAAA,KACR,yBAAS;AAAA,IACX,SAAS;AAAA,IACT,WAAW;AAAA,IACX,UAAU;AAAA,EACZ;AAAA,EAGF,UAAU;AAAA,IACR,eAAe;AAAA,MACb,GAAG,wBAAQ,eAAe,EAAE,eAAe,EAAE;AAAA,MAE7C,WAAW,CAAC,kBACV,wBACI,iBAAiB,IACf,EAAE,iBAAiB,cAAc,IACjC,OACF,EAAE,cAAc;AAAA,IACxB;AAAA,IAEA,YAAY;AAAA,MACV,MAAM;AAAA,QACJ,YAAY;AAAA,QACZ,QAAQ;AAAA,MACV;AAAA,MACA,OAAO;AAAA,QACL,YAAY;AAAA,MACd;AAAA,IACF;AAAA,IAEA,WAAW;AAAA,MACT,MAAM;AAAA,QACJ,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,IAEA,SAAS;AAAA,MACP,MAAM,wBACF,eACA;AAAA,QACE,eAAe;AAAA,QACf,eAAe;AAAA,MACjB;AAAA,IACN;AAAA,EACF;AAAA,EAEA,YAAY,IAAI,IAAI,wBAAQ,CAAC,IAAI,CAAC,SAAS,CAAC;AAAA,EAE5C,aAAa,kCACR,6BACA;AAEP,CAAC;",
6
6
  "names": []
7
7
  }
@@ -36,4 +36,10 @@ const TextAncestorProvider = /* @__PURE__ */ __name((props) => {
36
36
  value: false
37
37
  }, props.children);
38
38
  }, "TextAncestorProvider");
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ FallbackNativeContext,
42
+ TextAncestorContext,
43
+ TextAncestorProvider
44
+ });
39
45
  //# sourceMappingURL=TextAncestorContext.js.map
@@ -27,11 +27,11 @@ module.exports = __toCommonJS(Theme_exports);
27
27
  var import_react = __toESM(require("react"));
28
28
  var import_platform = require("../constants/platform");
29
29
  var import_wrapThemeManagerContext = require("../helpers/wrapThemeManagerContext");
30
- var import_static = require("../static");
30
+ var import_useTheme = require("../hooks/useTheme");
31
31
  import_react.default["createElement"];
32
32
  const Theme = (0, import_react.memo)(/* @__PURE__ */ __name(function Theme2(props) {
33
33
  var _a, _b;
34
- const { name, theme, themeManager, themes, className } = (0, import_static.useChangeThemeEffect)(props.name, void 0, props);
34
+ const { name, theme, themeManager, themes, className } = (0, import_useTheme.useChangeThemeEffect)(props.name, props.componentName, props);
35
35
  if (!themes || !name || !theme) {
36
36
  if (name && !theme && process.env.NODE_ENV === "development") {
37
37
  console.warn(`No theme found by name ${name}`);
@@ -40,7 +40,7 @@ const Theme = (0, import_react.memo)(/* @__PURE__ */ __name(function Theme2(prop
40
40
  }
41
41
  const contents = (0, import_react.useMemo)(() => (0, import_wrapThemeManagerContext.wrapThemeManagerContext)(props.children, themeManager), [props.children, themeManager]);
42
42
  if (import_platform.isWeb) {
43
- return /* @__PURE__ */ import_react.default.createElement("div", {
43
+ return /* @__PURE__ */ import_react.default.createElement("span", {
44
44
  className: [
45
45
  `tui_Theme`,
46
46
  ...!props.disableThemeClass ? [props.className, className].filter(Boolean) : []
@@ -53,4 +53,8 @@ const Theme = (0, import_react.memo)(/* @__PURE__ */ __name(function Theme2(prop
53
53
  }
54
54
  return contents;
55
55
  }, "Theme"));
56
+ // Annotate the CommonJS export names for ESM import in node:
57
+ 0 && (module.exports = {
58
+ Theme
59
+ });
56
60
  //# sourceMappingURL=Theme.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/views/Theme.tsx"],
4
- "sourcesContent": ["import React, { memo, useMemo } from 'react'\n\nimport { isWeb } from '../constants/platform'\nimport { wrapThemeManagerContext } from '../helpers/wrapThemeManagerContext'\nimport { useChangeThemeEffect } from '../static'\nimport { ThemeName } from '../types'\n\n// bugfix esbuild strips react jsx: 'preserve'\nReact['createElement']\n\nexport type ThemeProps = {\n className?: string\n disableThemeClass?: boolean\n name: Exclude<ThemeName, number> | null\n children?: any\n debug?: boolean\n}\n\nexport const Theme = memo(function Theme(props: ThemeProps) {\n const { name, theme, themeManager, themes, className } = useChangeThemeEffect(\n props.name,\n undefined,\n props\n )\n\n if (!themes || !name || !theme) {\n if (name && !theme && process.env.NODE_ENV === 'development') {\n console.warn(`No theme found by name ${name}`)\n }\n return props.children\n }\n\n // memo here, changing theme without re-rendering all children is a critical optimization\n // may require some effort of end user to memoize but without this memo they'd have no option\n const contents = useMemo(\n () => wrapThemeManagerContext(props.children, themeManager),\n [props.children, themeManager]\n )\n\n if (isWeb) {\n return (\n <div\n className={[\n `tui_Theme`,\n ...(!props.disableThemeClass ? [props.className, className].filter(Boolean) : []),\n ].join(' ')}\n style={{\n display: 'contents',\n // in order to provide currentColor, set color by default\n color: themes[name]?.color?.toString(),\n }}\n >\n {contents}\n </div>\n )\n }\n\n return contents\n})\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAqC;AAErC,sBAAsB;AACtB,qCAAwC;AACxC,oBAAqC;AAIrC,qBAAM;AAUC,MAAM,QAAQ,uBAAK,uCAAe,OAAmB;AAlB5D;AAmBE,QAAM,EAAE,MAAM,OAAO,cAAc,QAAQ,cAAc,wCACvD,MAAM,MACN,QACA,KACF;AAEA,MAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO;AAC9B,QAAI,QAAQ,CAAC,SAAS,QAAQ,IAAI,aAAa,eAAe;AAC5D,cAAQ,KAAK,0BAA0B,MAAM;AAAA,IAC/C;AACA,WAAO,MAAM;AAAA,EACf;AAIA,QAAM,WAAW,0BACf,MAAM,4DAAwB,MAAM,UAAU,YAAY,GAC1D,CAAC,MAAM,UAAU,YAAY,CAC/B;AAEA,MAAI,uBAAO;AACT,WACE,mDAAC;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA,GAAI,CAAC,MAAM,oBAAoB,CAAC,MAAM,WAAW,SAAS,EAAE,OAAO,OAAO,IAAI,CAAC;AAAA,MACjF,EAAE,KAAK,GAAG;AAAA,MACV,OAAO;AAAA,QACL,SAAS;AAAA,QAET,OAAO,mBAAO,UAAP,mBAAc,UAAd,mBAAqB;AAAA,MAC9B;AAAA,OAEC,QACH;AAAA,EAEJ;AAEA,SAAO;AACT,GAxC0B,QAwCzB;",
4
+ "sourcesContent": ["import React, { memo, useMemo } from 'react'\n\nimport { isWeb } from '../constants/platform'\nimport { wrapThemeManagerContext } from '../helpers/wrapThemeManagerContext'\nimport { useChangeThemeEffect } from '../hooks/useTheme'\nimport { ThemeName } from '../types'\n\n// bugfix esbuild strips react jsx: 'preserve'\nReact['createElement']\n\nexport type ThemeProps = {\n className?: string\n disableThemeClass?: boolean\n name: Exclude<ThemeName, number> | null\n componentName?: string\n children?: any\n debug?: boolean\n}\n\nexport const Theme = memo(function Theme(props: ThemeProps) {\n const { name, theme, themeManager, themes, className } = useChangeThemeEffect(\n props.name,\n props.componentName,\n props\n )\n\n if (!themes || !name || !theme) {\n if (name && !theme && process.env.NODE_ENV === 'development') {\n console.warn(`No theme found by name ${name}`)\n }\n return props.children\n }\n\n // memo here, changing theme without re-rendering all children is a critical optimization\n // may require some effort of end user to memoize but without this memo they'd have no option\n const contents = useMemo(\n () => wrapThemeManagerContext(props.children, themeManager),\n [props.children, themeManager]\n )\n\n if (isWeb) {\n return (\n <span\n className={[\n `tui_Theme`,\n ...(!props.disableThemeClass ? [props.className, className].filter(Boolean) : []),\n ].join(' ')}\n style={{\n display: 'contents',\n // in order to provide currentColor, set color by default\n color: themes[name]?.color?.toString(),\n }}\n >\n {contents}\n </span>\n )\n }\n\n return contents\n})\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAqC;AAErC,sBAAsB;AACtB,qCAAwC;AACxC,sBAAqC;AAIrC,qBAAM;AAWC,MAAM,QAAQ,uBAAK,uCAAe,OAAmB;AAnB5D;AAoBE,QAAM,EAAE,MAAM,OAAO,cAAc,QAAQ,cAAc,0CACvD,MAAM,MACN,MAAM,eACN,KACF;AAEA,MAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO;AAC9B,QAAI,QAAQ,CAAC,SAAS,QAAQ,IAAI,aAAa,eAAe;AAC5D,cAAQ,KAAK,0BAA0B,MAAM;AAAA,IAC/C;AACA,WAAO,MAAM;AAAA,EACf;AAIA,QAAM,WAAW,0BACf,MAAM,4DAAwB,MAAM,UAAU,YAAY,GAC1D,CAAC,MAAM,UAAU,YAAY,CAC/B;AAEA,MAAI,uBAAO;AACT,WACE,mDAAC;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA,GAAI,CAAC,MAAM,oBAAoB,CAAC,MAAM,WAAW,SAAS,EAAE,OAAO,OAAO,IAAI,CAAC;AAAA,MACjF,EAAE,KAAK,GAAG;AAAA,MACV,OAAO;AAAA,QACL,SAAS;AAAA,QAET,OAAO,mBAAO,UAAP,mBAAc,UAAd,mBAAqB;AAAA,MAC9B;AAAA,OAEC,QACH;AAAA,EAEJ;AAEA,SAAO;AACT,GAxC0B,QAwCzB;",
6
6
  "names": []
7
7
  }
@@ -26,6 +26,7 @@ __export(ThemeInverse_exports, {
26
26
  });
27
27
  module.exports = __toCommonJS(ThemeInverse_exports);
28
28
  var import_react = __toESM(require("react"));
29
+ var import_platform = require("../constants/platform");
29
30
  var import_useTheme = require("../hooks/useTheme");
30
31
  var import_Theme = require("./Theme");
31
32
  let inversions = {
@@ -39,9 +40,17 @@ __name(setThemeInversions, "setThemeInversions");
39
40
  const ThemeInverse = /* @__PURE__ */ __name((props) => {
40
41
  const themeName = (0, import_useTheme.useThemeName)();
41
42
  const defaultTheme = (0, import_useTheme.useDefaultThemeName)();
42
- const name = inversions[themeName] || inversions[defaultTheme || ""] || null;
43
+ const [name, setName] = (0, import_react.useState)(null);
44
+ (0, import_platform.useIsomorphicLayoutEffect)(() => {
45
+ setName(inversions[themeName] || inversions[defaultTheme || ""] || null);
46
+ }, [defaultTheme, themeName]);
43
47
  return /* @__PURE__ */ import_react.default.createElement(import_Theme.Theme, {
44
48
  name
45
49
  }, props.children);
46
50
  }, "ThemeInverse");
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ ThemeInverse,
54
+ setThemeInversions
55
+ });
47
56
  //# sourceMappingURL=ThemeInverse.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/views/ThemeInverse.tsx"],
4
- "sourcesContent": ["import React from 'react'\n\nimport { useDefaultThemeName, useThemeName } from '../hooks/useTheme'\nimport { Theme } from './Theme'\n\ntype StringRecord = { [key: string]: string }\n\nlet inversions: StringRecord = {\n light: 'dark',\n dark: 'light',\n}\n\nexport function setThemeInversions(next: StringRecord) {\n inversions = next\n}\n\nexport const ThemeInverse = (props: { children: any }) => {\n const themeName = useThemeName()\n const defaultTheme = useDefaultThemeName()\n const name = inversions[themeName] || inversions[defaultTheme || ''] || null\n return <Theme name={name}>{props.children}</Theme>\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAElB,sBAAkD;AAClD,mBAAsB;AAItB,IAAI,aAA2B;AAAA,EAC7B,OAAO;AAAA,EACP,MAAM;AACR;AAEO,4BAA4B,MAAoB;AACrD,eAAa;AACf;AAFgB;AAIT,MAAM,eAAe,wBAAC,UAA6B;AACxD,QAAM,YAAY,kCAAa;AAC/B,QAAM,eAAe,yCAAoB;AACzC,QAAM,OAAO,WAAW,cAAc,WAAW,gBAAgB,OAAO;AACxE,SAAO,mDAAC;AAAA,IAAM;AAAA,KAAa,MAAM,QAAS;AAC5C,GAL4B;",
4
+ "sourcesContent": ["import React, { useState } from 'react'\n\nimport { useIsomorphicLayoutEffect } from '../constants/platform'\nimport { useDefaultThemeName, useThemeName } from '../hooks/useTheme'\nimport { Theme } from './Theme'\n\ntype StringRecord = { [key: string]: string }\n\nlet inversions: StringRecord = {\n light: 'dark',\n dark: 'light',\n}\n\nexport function setThemeInversions(next: StringRecord) {\n inversions = next\n}\n\nexport const ThemeInverse = (props: { children: any }) => {\n const themeName = useThemeName()\n const defaultTheme = useDefaultThemeName()\n const [name, setName] = useState<null | string>(null)\n\n // ssr\n useIsomorphicLayoutEffect(() => {\n setName(inversions[themeName] || inversions[defaultTheme || ''] || null)\n }, [defaultTheme, themeName])\n\n return <Theme name={name}>{props.children}</Theme>\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAgC;AAEhC,sBAA0C;AAC1C,sBAAkD;AAClD,mBAAsB;AAItB,IAAI,aAA2B;AAAA,EAC7B,OAAO;AAAA,EACP,MAAM;AACR;AAEO,4BAA4B,MAAoB;AACrD,eAAa;AACf;AAFgB;AAIT,MAAM,eAAe,wBAAC,UAA6B;AACxD,QAAM,YAAY,kCAAa;AAC/B,QAAM,eAAe,yCAAoB;AACzC,QAAM,CAAC,MAAM,WAAW,2BAAwB,IAAI;AAGpD,iDAA0B,MAAM;AAC9B,YAAQ,WAAW,cAAc,WAAW,gBAAgB,OAAO,IAAI;AAAA,EACzE,GAAG,CAAC,cAAc,SAAS,CAAC;AAE5B,SAAO,mDAAC;AAAA,IAAM;AAAA,KAAa,MAAM,QAAS;AAC5C,GAX4B;",
6
6
  "names": []
7
7
  }
@@ -44,7 +44,7 @@ const ThemeProvider = /* @__PURE__ */ __name((props) => {
44
44
  return () => {
45
45
  document.body.classList.remove(cn);
46
46
  };
47
- }, []);
47
+ }, [props.disableRootThemeClass]);
48
48
  }
49
49
  const themeContext = (0, import_react.useMemo)(() => {
50
50
  return {
@@ -55,8 +55,13 @@ const ThemeProvider = /* @__PURE__ */ __name((props) => {
55
55
  return /* @__PURE__ */ import_react.default.createElement(import_ThemeContext.ThemeContext.Provider, {
56
56
  value: themeContext
57
57
  }, /* @__PURE__ */ import_react.default.createElement(import_Theme.Theme, {
58
+ className: props.className,
58
59
  name: props.defaultTheme,
59
60
  disableThemeClass: props.disableRootThemeClass
60
61
  }, props.children));
61
62
  }, "ThemeProvider");
63
+ // Annotate the CommonJS export names for ESM import in node:
64
+ 0 && (module.exports = {
65
+ ThemeProvider
66
+ });
62
67
  //# sourceMappingURL=ThemeProvider.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/views/ThemeProvider.tsx"],
4
- "sourcesContent": ["import React, { useLayoutEffect, useMemo } from 'react'\n\nimport { getHasConfigured } from '../conf'\nimport { THEME_CLASSNAME_PREFIX } from '../constants/constants'\nimport { ThemeContext } from '../ThemeContext'\nimport { Theme } from './Theme'\n\n// bugfix esbuild strips react jsx: 'preserve'\nReact['createElement']\n\nexport type ThemeProviderProps = {\n themes: any\n defaultTheme: string\n disableRootThemeClass?: boolean\n children?: any\n}\n\nexport const ThemeProvider = (props: ThemeProviderProps) => {\n if (!getHasConfigured()) {\n throw new Error(`Missing configureThemes() call, add to your root file`)\n }\n\n // ensure theme is attached to root body node as well to work with modals by default\n if (typeof document !== 'undefined') {\n useLayoutEffect(() => {\n if (props.disableRootThemeClass) {\n return\n }\n const cn = `${THEME_CLASSNAME_PREFIX}${props.defaultTheme}`\n document.body.classList.add(cn)\n return () => {\n document.body.classList.remove(cn)\n }\n }, [])\n }\n\n const themeContext = useMemo(() => {\n return {\n themes: props.themes,\n defaultTheme: props.defaultTheme,\n }\n }, [props.themes])\n\n return (\n <ThemeContext.Provider value={themeContext}>\n <Theme name={props.defaultTheme} disableThemeClass={props.disableRootThemeClass}>\n {props.children}\n </Theme>\n </ThemeContext.Provider>\n )\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAgD;AAEhD,kBAAiC;AACjC,uBAAuC;AACvC,0BAA6B;AAC7B,mBAAsB;AAGtB,qBAAM;AASC,MAAM,gBAAgB,wBAAC,UAA8B;AAC1D,MAAI,CAAC,kCAAiB,GAAG;AACvB,UAAM,IAAI,MAAM,uDAAuD;AAAA,EACzE;AAGA,MAAI,OAAO,aAAa,aAAa;AACnC,sCAAgB,MAAM;AACpB,UAAI,MAAM,uBAAuB;AAC/B;AAAA,MACF;AACA,YAAM,KAAK,GAAG,0CAAyB,MAAM;AAC7C,eAAS,KAAK,UAAU,IAAI,EAAE;AAC9B,aAAO,MAAM;AACX,iBAAS,KAAK,UAAU,OAAO,EAAE;AAAA,MACnC;AAAA,IACF,GAAG,CAAC,CAAC;AAAA,EACP;AAEA,QAAM,eAAe,0BAAQ,MAAM;AACjC,WAAO;AAAA,MACL,QAAQ,MAAM;AAAA,MACd,cAAc,MAAM;AAAA,IACtB;AAAA,EACF,GAAG,CAAC,MAAM,MAAM,CAAC;AAEjB,SACE,mDAAC,iCAAa,UAAb;AAAA,IAAsB,OAAO;AAAA,KAC5B,mDAAC;AAAA,IAAM,MAAM,MAAM;AAAA,IAAc,mBAAmB,MAAM;AAAA,KACvD,MAAM,QACT,CACF;AAEJ,GAjC6B;",
4
+ "sourcesContent": ["import React, { useLayoutEffect, useMemo } from 'react'\n\nimport { getHasConfigured } from '../conf'\nimport { THEME_CLASSNAME_PREFIX } from '../constants/constants'\nimport { ThemeContext } from '../ThemeContext'\nimport { Theme } from './Theme'\n\n// bugfix esbuild strips react jsx: 'preserve'\nReact['createElement']\n\nexport type ThemeProviderProps = {\n className?: string\n themes: any\n defaultTheme: string\n disableRootThemeClass?: boolean\n children?: any\n}\n\nexport const ThemeProvider = (props: ThemeProviderProps) => {\n if (!getHasConfigured()) {\n throw new Error(`Missing configureThemes() call, add to your root file`)\n }\n\n // ensure theme is attached to root body node as well to work with modals by default\n if (typeof document !== 'undefined') {\n useLayoutEffect(() => {\n if (props.disableRootThemeClass) {\n return\n }\n const cn = `${THEME_CLASSNAME_PREFIX}${props.defaultTheme}`\n document.body.classList.add(cn)\n return () => {\n document.body.classList.remove(cn)\n }\n }, [props.disableRootThemeClass])\n }\n\n const themeContext = useMemo(() => {\n return {\n themes: props.themes,\n defaultTheme: props.defaultTheme,\n }\n }, [props.themes])\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;AAAA,mBAAgD;AAEhD,kBAAiC;AACjC,uBAAuC;AACvC,0BAA6B;AAC7B,mBAAsB;AAGtB,qBAAM;AAUC,MAAM,gBAAgB,wBAAC,UAA8B;AAC1D,MAAI,CAAC,kCAAiB,GAAG;AACvB,UAAM,IAAI,MAAM,uDAAuD;AAAA,EACzE;AAGA,MAAI,OAAO,aAAa,aAAa;AACnC,sCAAgB,MAAM;AACpB,UAAI,MAAM,uBAAuB;AAC/B;AAAA,MACF;AACA,YAAM,KAAK,GAAG,0CAAyB,MAAM;AAC7C,eAAS,KAAK,UAAU,IAAI,EAAE;AAC9B,aAAO,MAAM;AACX,iBAAS,KAAK,UAAU,OAAO,EAAE;AAAA,MACnC;AAAA,IACF,GAAG,CAAC,MAAM,qBAAqB,CAAC;AAAA,EAClC;AAEA,QAAM,eAAe,0BAAQ,MAAM;AACjC,WAAO;AAAA,MACL,QAAQ,MAAM;AAAA,MACd,cAAc,MAAM;AAAA,IACtB;AAAA,EACF,GAAG,CAAC,MAAM,MAAM,CAAC;AAEjB,SACE,mDAAC,iCAAa,UAAb;AAAA,IAAsB,OAAO;AAAA,KAC5B,mDAAC;AAAA,IACC,WAAW,MAAM;AAAA,IACjB,MAAM,MAAM;AAAA,IACZ,mBAAmB,MAAM;AAAA,KAExB,MAAM,QACT,CACF;AAEJ,GArC6B;",
6
6
  "names": []
7
7
  }
@@ -56,4 +56,8 @@ const ThemeReset = /* @__PURE__ */ __name((props) => {
56
56
  name
57
57
  }, props.children);
58
58
  }, "ThemeReset");
59
+ // Annotate the CommonJS export names for ESM import in node:
60
+ 0 && (module.exports = {
61
+ ThemeReset
62
+ });
59
63
  //# sourceMappingURL=ThemeReset.js.map
@@ -1,14 +1,20 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
  import * as Helpers from "@tamagui/helpers";
4
+ import { getConfig } from "./conf";
4
5
  import { rnw } from "./constants/rnw";
5
- import { getAllSelectors, getAllTransforms } from "./helpers/insertStyleRule";
6
+ import { getAllSelectors, getAllTransforms, getInsertedRules } from "./helpers/insertStyleRule";
6
7
  class TamaguiManager {
7
8
  constructor() {
8
- this.config = null;
9
9
  this.rnw = rnw;
10
10
  this.Helpers = Helpers;
11
11
  }
12
+ get config() {
13
+ return getConfig();
14
+ }
15
+ get insertedRules() {
16
+ return getInsertedRules();
17
+ }
12
18
  get allSelectors() {
13
19
  return getAllSelectors();
14
20
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/Tamagui.ts"],
4
- "sourcesContent": ["import * as Helpers from '@tamagui/helpers'\n\nimport { rnw } from './constants/rnw'\nimport { getAllSelectors, getAllTransforms } from './helpers/insertStyleRule'\nimport { TamaguiInternalConfig } from './types'\n\n// serves a central store for state\n\nclass TamaguiManager {\n config: TamaguiInternalConfig | null = null\n rnw = rnw\n Helpers = Helpers\n\n get allSelectors() {\n return getAllSelectors()\n }\n\n get allTransforms() {\n return getAllTransforms()\n }\n\n get identifierToValue() {\n return identifierToValue\n }\n}\n\nexport const Tamagui = new TamaguiManager()\n\nconst identifierToValue = new Map<string, any>()\n\nexport const getValueFromIdentifier = (identifier: string) => {\n return identifierToValue.get(identifier)\n}\n\nexport const setIdentifierValue = (identifier: string, value: any) => {\n identifierToValue.set(identifier, value)\n}\n"],
5
- "mappings": ";;AAAA;AAEA;AACA;AAKA,MAAM,eAAe;AAAA,EAArB;AACE,kBAAuC;AACvC,eAAM;AACN,mBAAU;AAAA;AAAA,MAEN,eAAe;AACjB,WAAO,gBAAgB;AAAA,EACzB;AAAA,MAEI,gBAAgB;AAClB,WAAO,iBAAiB;AAAA,EAC1B;AAAA,MAEI,oBAAoB;AACtB,WAAO;AAAA,EACT;AACF;AAhBA;AAkBO,MAAM,UAAU,IAAI,eAAe;AAE1C,MAAM,oBAAoB,oBAAI,IAAiB;AAExC,MAAM,yBAAyB,wBAAC,eAAuB;AAC5D,SAAO,kBAAkB,IAAI,UAAU;AACzC,GAFsC;AAI/B,MAAM,qBAAqB,wBAAC,YAAoB,UAAe;AACpE,oBAAkB,IAAI,YAAY,KAAK;AACzC,GAFkC;",
4
+ "sourcesContent": ["import * as Helpers from '@tamagui/helpers'\n\nimport { getConfig } from './conf'\nimport { rnw } from './constants/rnw'\nimport { getAllSelectors, getAllTransforms, getInsertedRules } from './helpers/insertStyleRule'\nimport { TamaguiInternalConfig } from './types'\n\n// serves a central store for state\n\nclass TamaguiManager {\n rnw = rnw\n Helpers = Helpers\n\n get config() {\n return getConfig()\n }\n\n get insertedRules() {\n return getInsertedRules()\n }\n\n get allSelectors() {\n return getAllSelectors()\n }\n\n get allTransforms() {\n return getAllTransforms()\n }\n\n get identifierToValue() {\n return identifierToValue\n }\n}\n\nexport const Tamagui = new TamaguiManager()\n\nconst identifierToValue = new Map<string, any>()\n\nexport const getValueFromIdentifier = (identifier: string) => {\n return identifierToValue.get(identifier)\n}\n\nexport const setIdentifierValue = (identifier: string, value: any) => {\n identifierToValue.set(identifier, value)\n}\n"],
5
+ "mappings": ";;AAAA;AAEA;AACA;AACA;AAKA,MAAM,eAAe;AAAA,EAArB;AACE,eAAM;AACN,mBAAU;AAAA;AAAA,MAEN,SAAS;AACX,WAAO,UAAU;AAAA,EACnB;AAAA,MAEI,gBAAgB;AAClB,WAAO,iBAAiB;AAAA,EAC1B;AAAA,MAEI,eAAe;AACjB,WAAO,gBAAgB;AAAA,EACzB;AAAA,MAEI,gBAAgB;AAClB,WAAO,iBAAiB;AAAA,EAC1B;AAAA,MAEI,oBAAoB;AACtB,WAAO;AAAA,EACT;AACF;AAvBA;AAyBO,MAAM,UAAU,IAAI,eAAe;AAE1C,MAAM,oBAAoB,oBAAI,IAAiB;AAExC,MAAM,yBAAyB,wBAAC,eAAuB;AAC5D,SAAO,kBAAkB,IAAI,UAAU;AACzC,GAFsC;AAI/B,MAAM,qBAAqB,wBAAC,YAAoB,UAAe;AACpE,oBAAkB,IAAI,YAAY,KAAK;AACzC,GAFkC;",
6
6
  "names": []
7
7
  }
@@ -16,9 +16,9 @@ var __privateMethod = (obj, member, method) => {
16
16
  var _getClassName, getClassName_fn;
17
17
  import { createContext } from "react";
18
18
  import { getThemes } from "./conf";
19
- import { THEME_CLASSNAME_PREFIX, THEME_NAME_SEPARATOR } from "./static";
19
+ import { THEME_CLASSNAME_PREFIX, THEME_NAME_SEPARATOR } from "./constants/constants";
20
20
  class ThemeManager {
21
- constructor(name = null, theme = null, parentManager = null) {
21
+ constructor(name = "", theme = null, parentManager = null) {
22
22
  this.name = name;
23
23
  this.theme = theme;
24
24
  this.parentManager = parentManager;
@@ -76,7 +76,7 @@ class ThemeManager {
76
76
  return false;
77
77
  }
78
78
  this.className = className || null;
79
- this.name = name || null;
79
+ this.name = name || "";
80
80
  this.theme = theme;
81
81
  this.notifyListeners();
82
82
  return true;
@@ -85,10 +85,14 @@ class ThemeManager {
85
85
  const { themes = getThemes(), name, componentName } = opts;
86
86
  if (!name) {
87
87
  if (componentName) {
88
- const name2 = `${this.name}_${componentName}`;
89
- const theme2 = themes[name2];
90
- if (theme2) {
91
- return { name: name2, theme: theme2, className: __privateMethod(this, _getClassName, getClassName_fn).call(this, name2) };
88
+ const names = [
89
+ `${this.name}_${componentName}`,
90
+ `${withoutComponentName(this.name)}_${componentName}`
91
+ ];
92
+ for (const name2 of names) {
93
+ if (name2 in themes) {
94
+ return { name: name2, theme: themes[name2], className: __privateMethod(this, _getClassName, getClassName_fn).call(this, name2) };
95
+ }
92
96
  }
93
97
  }
94
98
  return {
@@ -113,9 +117,14 @@ class ThemeManager {
113
117
  parentName = parentName.slice(0, parentName.lastIndexOf(THEME_NAME_SEPARATOR));
114
118
  }
115
119
  if (componentName) {
116
- const componentThemeName = `${nextName}_${componentName}`;
117
- if (componentThemeName in themes) {
118
- nextName = componentThemeName;
120
+ const names = [
121
+ `${nextName}_${componentName}`,
122
+ `${withoutComponentName(nextName)}_${componentName}`
123
+ ];
124
+ for (const name2 of names) {
125
+ if (name2 in themes) {
126
+ nextName = name2;
127
+ }
119
128
  }
120
129
  }
121
130
  let theme = themes[nextName];
@@ -123,7 +132,7 @@ class ThemeManager {
123
132
  theme = themes[`light_${nextName}`];
124
133
  }
125
134
  if (process.env.NODE_ENV === "development" && props && props["debug"]) {
126
- console.log("getNextTheme", { opts, nextName, parentName }, this);
135
+ console.log("getNextTheme", { name: opts.name, nextName, parentName });
127
136
  }
128
137
  return {
129
138
  name: nextName,
@@ -169,6 +178,7 @@ getClassName_fn = /* @__PURE__ */ __name(function(name) {
169
178
  }, "#getClassName");
170
179
  const ThemeManagerContext = createContext(null);
171
180
  const emptyManager = new ThemeManager();
181
+ const withoutComponentName = /* @__PURE__ */ __name((name) => name.replace(/\_[A-Z][a-z]+$/, ""), "withoutComponentName");
172
182
  export {
173
183
  ThemeManager,
174
184
  ThemeManagerContext,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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 './static'\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 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 | null = null,\n public theme: ThemeObject | null = null,\n public parentManager: ThemeManager | null = null\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 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 sameNameOrClassName = this.className\n ? // == instead of === (sometimes its undefined/null)\n className == this.className\n : name === this.name\n if (sameNameOrClassName) {\n return false\n }\n this.className = className || null\n this.name = name || null\n this.theme = theme\n this.notifyListeners()\n return true\n }\n\n getNextTheme(\n opts: { themes?: Themes; name?: string | null; componentName?: string | null } = {},\n props?: any\n ) {\n const { themes = getThemes(), name, componentName } = opts\n\n if (!name) {\n if (componentName) {\n const name = `${this.name}_${componentName}`\n const theme = themes[name]\n if (theme) {\n return { name, theme, className: this.#getClassName(name) }\n }\n }\n return {\n name: this.name,\n theme: this.theme,\n }\n }\n\n let nextName = name || this.name || ''\n let parentName = 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 break\n }\n // go up one\n parentName = parentName.slice(0, parentName.lastIndexOf(THEME_NAME_SEPARATOR))\n }\n\n if (componentName) {\n const componentThemeName = `${nextName}_${componentName}`\n if (componentThemeName in themes) {\n nextName = componentThemeName\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' && props && props['debug']) {\n console.log('getNextTheme', { opts, nextName, parentName }, this)\n }\n\n return {\n name: nextName,\n theme,\n className: this.#getClassName(nextName),\n }\n }\n\n #getClassName(name: string) {\n return `${THEME_CLASSNAME_PREFIX}${name} tui_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"],
5
- "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAEA;AACA;AAYO,MAAM,aAAa;AAAA,EAMxB,YACS,OAAsB,MACtB,QAA4B,MAC5B,gBAAqC,MAC5C;AAHO;AACA;AACA;AAoIT;AA5IA,gBAAO,oBAAI,IAAsB;AACjC,qBAAY,oBAAI,IAAmB;AACnC,0BAAiB,oBAAI,IAAmB;AACxC,qBAA2B;AAQzB,QAAI,SAAS;AACb,QAAI,QAAQ;AACZ,WAAO,MAAM;AACX;AACA,UAAI,QAAQ,IAAI;AACd,cAAM,IAAI,MAAM,oDAAoD;AAAA,MACtE;AACA,UAAI,CAAC;AAAQ;AACb,UAAI,OAAO,SAAS,MAAM;AAExB,iBAAS,OAAO;AAAA,MAClB,OAAO;AACL,aAAK,gBAAgB;AACrB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,MAEI,aAAa;AA7CnB;AA8CI,WAAO,YAAK,kBAAL,mBAAoB,SAAQ;AAAA,EACrC;AAAA,MAEI,WAAmB;AACrB,WAAO,KAAK,aAAa,EAAE,QAAQ,KAAK,QAAQ;AAAA,EAKlD;AAAA,EAGA,SAAS,KAAa;AACpB,QAAI,QAAQ,KAAK;AACjB,QAAI,UAAU;AACd,WAAO,MAAM;AACX,UAAI,CAAC;AAAO;AACZ,UAAI,OAAO,OAAO;AAChB,eAAO,MAAM;AAAA,MACf;AACA,gBAAU,KAAK;AACf,UAAI,CAAC,SAAS;AACZ;AAAA,MACF;AACA,UAAI,QAAQ,UAAU,OAAO;AAC3B;AAAA,MACF;AACA,cAAQ,QAAQ;AAAA,IAClB;AAAA,EACF;AAAA,EAEA,OAAO,EAAE,MAAM,OAAO,cAAmC,CAAC,GAAG;AAE3D,UAAM,sBAAsB,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,UAAU,WAAW,GAAG,IAAI;AAAA,IAClE;AAEA,WAAO;AAAA,MACL,MAAM;AAAA,MACN;AAAA,MACA,WAAW,sBAAK,gCAAL,WAAmB;AAAA,IAChC;AAAA,EACF;AAAA,EAMA,MAAM,MAAW,MAAmB;AAClC,QAAI,CAAC,KAAK;AAAM;AAChB,SAAK,KAAK,IAAI,MAAM,IAAI;AAAA,EAC1B;AAAA,EAEA,kBAAkB;AArKpB;AAsKI,QAAI,CAAC,KAAK,MAAM;AACd,WAAK,KAAK,MAAM;AAAA,IAClB;AACA,eAAW,CAAC,MAAM,SAAS,KAAK,KAAK,QAAQ,GAAG;AAC9C,UAAI,KAAK,MAAM;AACb,mBAAK,UAAU,IAAI,IAAI,MAAvB;AAAA,MACF;AAAA,IACF;AACA,SAAK,eAAe,QAAQ,CAAC,OAAO,GAAG,KAAK,MAAM,IAAI,CAAC;AAAA,EACzD;AAAA,EAEA,cAAc,IAAmB;AAC/B,SAAK,eAAe,IAAI,EAAE;AAC1B,WAAO,MAAM;AACX,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;AAhLO;AA6IL;AAAA,kBAAa,gCAAC,MAAc;AAC1B,SAAO,GAAG,yBAAyB,iBAAiB,QAAQ,UAAU,EAAE,EAAE,QAAQ,SAAS,EAAE;AAC/F,GAFa;AAqCR,MAAM,sBAAsB,cAAmC,IAAI;AACnE,MAAM,eAAe,IAAI,aAAa;",
4
+ "sourcesContent": ["import { createContext } from 'react'\n\nimport { getThemes } from './conf'\nimport { THEME_CLASSNAME_PREFIX, THEME_NAME_SEPARATOR } from './constants/constants'\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 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 ) {\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 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 sameNameOrClassName = this.className\n ? // == instead of === (sometimes its undefined/null)\n className == this.className\n : name === this.name\n if (sameNameOrClassName) {\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(\n opts: { themes?: Themes; name?: string | null; componentName?: string | null } = {},\n props?: any\n ) {\n const { themes = getThemes(), name, componentName } = opts\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 return { name, theme: themes[name], className: this.#getClassName(name) }\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 = 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 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' && props && props['debug']) {\n console.log('getNextTheme', { name: opts.name, nextName, parentName })\n }\n\n return {\n name: nextName,\n theme,\n className: this.#getClassName(nextName),\n }\n }\n\n #getClassName(name: string) {\n return `${THEME_CLASSNAME_PREFIX}${name} tui_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-z]+$/, '')\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;A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__PURE__ */ __name((cb) => {
21
21
  configListeners.add(cb);
22
22
  }
23
23
  if (!globalThis["Tamagui"]) {
24
- Tamagui.config = conf;
25
24
  globalThis["Tamagui"] = Tamagui;
26
25
  }
27
26
  }, "onConfiguredOnce");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/conf.ts"],
4
- "sourcesContent": ["import { Tamagui } from './Tamagui'\nimport { 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 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 if (!globalThis['Tamagui']) {\n Tamagui.config = conf\n globalThis['Tamagui'] = Tamagui\n }\n}\n"],
5
- "mappings": ";;AAAA;AAGA,IAAI;AAEG,MAAM,YAAY,wBAAC,SAAgC;AACxD,SAAO;AACP,MAAI,gBAAgB,MAAM;AACxB,oBAAgB,QAAQ,CAAC,OAAO,GAAG,IAAK,CAAC;AACzC,oBAAgB,MAAM;AAAA,EACxB;AACF,GANyB;AAQlB,MAAM,mBAAmB,6BAAM,CAAC,CAAC,MAAR;AACzB,MAAM,YAAY,6BAAM,MAAN;AAClB,MAAM,YAAY,6BAAM,KAAM,cAAZ;AAClB,MAAM,YAAY,6BAAM,KAAM,QAAZ;AAElB,MAAM,kBAAkB,oBAAI,IAAoB;AAEhD,MAAM,mBAAmB,wBAAC,OAAuB;AACtD,MAAI,MAAM;AACR,OAAG,IAAI;AAAA,EACT,OAAO;AACL,oBAAgB,IAAI,EAAE;AAAA,EACxB;AAEA,MAAI,CAAC,WAAW,YAAY;AAC1B,YAAQ,SAAS;AACjB,eAAW,aAAa;AAAA,EAC1B;AACF,GAXgC;",
4
+ "sourcesContent": ["import { Tamagui } from './Tamagui'\nimport { 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 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 if (!globalThis['Tamagui']) {\n globalThis['Tamagui'] = Tamagui\n }\n}\n"],
5
+ "mappings": ";;AAAA;AAGA,IAAI;AAEG,MAAM,YAAY,wBAAC,SAAgC;AACxD,SAAO;AACP,MAAI,gBAAgB,MAAM;AACxB,oBAAgB,QAAQ,CAAC,OAAO,GAAG,IAAK,CAAC;AACzC,oBAAgB,MAAM;AAAA,EACxB;AACF,GANyB;AAQlB,MAAM,mBAAmB,6BAAM,CAAC,CAAC,MAAR;AACzB,MAAM,YAAY,6BAAM,MAAN;AAClB,MAAM,YAAY,6BAAM,KAAM,cAAZ;AAClB,MAAM,YAAY,6BAAM,KAAM,QAAZ;AAElB,MAAM,kBAAkB,oBAAI,IAAoB;AAEhD,MAAM,mBAAmB,wBAAC,OAAuB;AACtD,MAAI,MAAM;AACR,OAAG,IAAK;AAAA,EACV,OAAO;AACL,oBAAgB,IAAI,EAAE;AAAA,EACxB;AAEA,MAAI,CAAC,WAAW,YAAY;AAC1B,eAAW,aAAa;AAAA,EAC1B;AACF,GAVgC;",
6
6
  "names": []
7
7
  }
@@ -5,6 +5,7 @@ const isAndroid = ((_a = Platform) == null ? void 0 : _a.OS) === "android";
5
5
  const isIOS = ((_b = Platform) == null ? void 0 : _b.OS) === "ios";
6
6
  const isWeb = process.env.TAMAGUI_TARGET !== "native" && (process.env.TAMAGUI_TARGET === "web" || ((_c = Platform) == null ? void 0 : _c.OS) === "web");
7
7
  const isSSR = isWeb && typeof window === "undefined";
8
+ const isClient = isWeb && typeof window !== "undefined";
8
9
  const useIsomorphicLayoutEffect = isSSR ? useEffect : useLayoutEffect;
9
10
  const isChrome = typeof navigator !== "undefined" && /Chrome/.test(navigator.userAgent || "");
10
11
  const supportsTouchWeb = typeof window !== "undefined" && "ontouchstart" in window;
@@ -13,6 +14,7 @@ const isWebIOS = isWeb && typeof navigator !== "undefined" && (/iPad|iPhone|iPod
13
14
  export {
14
15
  isAndroid,
15
16
  isChrome,
17
+ isClient,
16
18
  isIOS,
17
19
  isSSR,
18
20
  isTouchDevice,
@@ -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'\n\nexport const isWeb =\n process.env.TAMAGUI_TARGET !== 'native' &&\n (process.env.TAMAGUI_TARGET === 'web' || Platform?.OS === 'web')\n\nexport const isSSR = isWeb && typeof window === 'undefined'\nexport const useIsomorphicLayoutEffect = isSSR ? useEffect : useLayoutEffect\nexport const isChrome = typeof navigator !== 'undefined' && /Chrome/.test(navigator.userAgent || '')\nexport const supportsTouchWeb = typeof window !== 'undefined' && 'ontouchstart' in window\nexport const isTouchDevice = !isWeb || supportsTouchWeb\nexport const isWebIOS =\n isWeb &&\n typeof navigator !== 'undefined' &&\n (/iPad|iPhone|iPod/.test(navigator.platform) ||\n (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) &&\n !window['MSStream']\n"],
5
- "mappings": "AAAA;AAAA;AACA;AAEO,MAAM,YAAY,uCAAU,QAAO;AACnC,MAAM,QAAQ,uCAAU,QAAO;AAE/B,MAAM,QACX,QAAQ,IAAI,mBAAmB,YAC9B,SAAQ,IAAI,mBAAmB,SAAS,uCAAU,QAAO;AAErD,MAAM,QAAQ,SAAS,OAAO,WAAW;AACzC,MAAM,4BAA4B,QAAQ,YAAY;AACtD,MAAM,WAAW,OAAO,cAAc,eAAe,SAAS,KAAK,UAAU,aAAa,EAAE;AAC5F,MAAM,mBAAmB,OAAO,WAAW,eAAe,kBAAkB;AAC5E,MAAM,gBAAgB,CAAC,SAAS;AAChC,MAAM,WACX,SACA,OAAO,cAAc,eACpB,oBAAmB,KAAK,UAAU,QAAQ,KACxC,UAAU,aAAa,cAAc,UAAU,iBAAiB,MACnE,CAAC,OAAO;",
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'\n\nexport const isWeb =\n process.env.TAMAGUI_TARGET !== 'native' &&\n (process.env.TAMAGUI_TARGET === 'web' || Platform?.OS === 'web')\n\nexport const isSSR = isWeb && typeof window === 'undefined'\nexport const isClient = isWeb && typeof window !== 'undefined'\nexport const useIsomorphicLayoutEffect = isSSR ? useEffect : useLayoutEffect\nexport const isChrome = typeof navigator !== 'undefined' && /Chrome/.test(navigator.userAgent || '')\nexport const supportsTouchWeb = typeof window !== 'undefined' && 'ontouchstart' in window\nexport const isTouchDevice = !isWeb || supportsTouchWeb\nexport const isWebIOS =\n isWeb &&\n typeof navigator !== 'undefined' &&\n (/iPad|iPhone|iPod/.test(navigator.platform) ||\n (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) &&\n !window['MSStream']\n"],
5
+ "mappings": "AAAA;AAAA;AACA;AAEO,MAAM,YAAY,uCAAU,QAAO;AACnC,MAAM,QAAQ,uCAAU,QAAO;AAE/B,MAAM,QACX,QAAQ,IAAI,mBAAmB,YAC9B,SAAQ,IAAI,mBAAmB,SAAS,uCAAU,QAAO;AAErD,MAAM,QAAQ,SAAS,OAAO,WAAW;AACzC,MAAM,WAAW,SAAS,OAAO,WAAW;AAC5C,MAAM,4BAA4B,QAAQ,YAAY;AACtD,MAAM,WAAW,OAAO,cAAc,eAAe,SAAS,KAAK,UAAU,aAAa,EAAE;AAC5F,MAAM,mBAAmB,OAAO,WAAW,eAAe,kBAAkB;AAC5E,MAAM,gBAAgB,CAAC,SAAS;AAChC,MAAM,WACX,SACA,OAAO,cAAc,eACpB,oBAAmB,KAAK,UAAU,QAAQ,KACxC,UAAU,aAAa,cAAc,UAAU,iBAAiB,MACnE,CAAC,OAAO;",
6
6
  "names": []
7
7
  }