@tamagui/core 1.0.0-beta.187 → 1.0.0-beta.2

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 (273) hide show
  1. package/dist/cjs/Tamagui.js +18 -1
  2. package/dist/cjs/Tamagui.js.map +2 -2
  3. package/dist/cjs/ThemeContext.js +4 -0
  4. package/dist/cjs/ThemeManager.js +30 -14
  5. package/dist/cjs/ThemeManager.js.map +2 -2
  6. package/dist/cjs/conf.js +10 -1
  7. package/dist/cjs/conf.js.map +2 -2
  8. package/dist/cjs/constants/constants.js +6 -0
  9. package/dist/cjs/constants/platform.js +15 -0
  10. package/dist/cjs/constants/platform.js.map +2 -2
  11. package/dist/cjs/constants/rnw.js +4 -0
  12. package/dist/cjs/contexts/ButtonInsideButtonContext.js +4 -0
  13. package/dist/cjs/createComponent.js +156 -130
  14. package/dist/cjs/createComponent.js.map +2 -2
  15. package/dist/cjs/createFont.js +4 -0
  16. package/dist/cjs/createShorthands.js +4 -0
  17. package/dist/cjs/createTamagui.js +56 -27
  18. package/dist/cjs/createTamagui.js.map +2 -2
  19. package/dist/cjs/createTheme.js +4 -0
  20. package/dist/cjs/createTokens.js +7 -6
  21. package/dist/cjs/createTokens.js.map +2 -2
  22. package/dist/cjs/createVariable.js +18 -2
  23. package/dist/cjs/createVariable.js.map +2 -2
  24. package/dist/cjs/defaultComponentState.js +0 -30
  25. package/dist/cjs/defaultComponentState.js.map +3 -3
  26. package/dist/cjs/helpers/RNComponents.js +38 -0
  27. package/dist/cjs/helpers/RNComponents.js.map +7 -0
  28. package/dist/cjs/helpers/addStylesUsingClassname.js +19 -16
  29. package/dist/cjs/helpers/addStylesUsingClassname.js.map +2 -2
  30. package/dist/cjs/helpers/areEqualSets.js +4 -0
  31. package/dist/cjs/helpers/createMediaStyle.js +5 -0
  32. package/dist/cjs/helpers/createPropMapper.js +63 -61
  33. package/dist/cjs/helpers/createPropMapper.js.map +2 -2
  34. package/dist/cjs/helpers/createShallowUpdate.js +55 -0
  35. package/dist/cjs/helpers/createShallowUpdate.js.map +7 -0
  36. package/dist/cjs/helpers/createTamaguiProvider.js +5 -5
  37. package/dist/cjs/helpers/createTamaguiProvider.js.map +2 -2
  38. package/dist/cjs/helpers/extendStaticConfig.js +9 -6
  39. package/dist/cjs/helpers/extendStaticConfig.js.map +2 -2
  40. package/dist/cjs/helpers/fixNativeShadow.js +4 -0
  41. package/dist/cjs/helpers/fixNativeShadow.native.js +6 -2
  42. package/dist/cjs/helpers/fixNativeShadow.native.js.map +2 -2
  43. package/dist/cjs/helpers/getExpandedShorthands.js +4 -0
  44. package/dist/cjs/helpers/getSize.js +35 -0
  45. package/dist/cjs/helpers/getSize.js.map +7 -0
  46. package/dist/cjs/helpers/getSplitStyles.js +152 -64
  47. package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
  48. package/dist/cjs/helpers/getStylesAtomic.js +20 -2
  49. package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
  50. package/dist/cjs/helpers/getStylesAtomic.native.js +4 -0
  51. package/dist/cjs/helpers/insertStyleRule.js +46 -26
  52. package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
  53. package/dist/cjs/helpers/isObj.js +4 -0
  54. package/dist/cjs/helpers/isTamaguiElement.js +4 -0
  55. package/dist/cjs/helpers/matchMedia.js +4 -0
  56. package/dist/cjs/helpers/matchMedia.native.js +4 -0
  57. package/dist/cjs/helpers/proxyThemeVariables.js +40 -0
  58. package/dist/cjs/helpers/proxyThemeVariables.js.map +7 -0
  59. package/dist/cjs/helpers/themeable.js +7 -2
  60. package/dist/cjs/helpers/themeable.js.map +2 -2
  61. package/dist/cjs/helpers/validate.js +53 -11
  62. package/dist/cjs/helpers/validate.js.map +2 -2
  63. package/dist/cjs/helpers/withStaticProperties.js +4 -0
  64. package/dist/cjs/helpers/wrapThemeManagerContext.js +4 -0
  65. package/dist/cjs/hooks/useConstant.js +4 -0
  66. package/dist/cjs/hooks/useFeatures.js +101 -12
  67. package/dist/cjs/hooks/useFeatures.js.map +2 -2
  68. package/dist/cjs/hooks/useIsMounted.js +4 -0
  69. package/dist/cjs/hooks/useIsTouchDevice.js +8 -4
  70. package/dist/cjs/hooks/useIsTouchDevice.js.map +2 -2
  71. package/dist/cjs/hooks/useMedia.js +30 -12
  72. package/dist/cjs/hooks/useMedia.js.map +2 -2
  73. package/dist/cjs/hooks/usePressable.js +4 -0
  74. package/dist/cjs/hooks/useTheme.js +36 -23
  75. package/dist/cjs/hooks/useTheme.js.map +2 -2
  76. package/dist/cjs/hooks/useUnmountEffect.js +4 -0
  77. package/dist/cjs/index.js +15 -0
  78. package/dist/cjs/index.js.map +2 -2
  79. package/dist/cjs/static.js +3 -0
  80. package/dist/cjs/static.js.map +2 -2
  81. package/dist/cjs/styled.js +8 -15
  82. package/dist/cjs/styled.js.map +2 -2
  83. package/dist/cjs/types-rnw.js.map +1 -1
  84. package/dist/cjs/types.js.map +1 -1
  85. package/dist/cjs/views/Stack.js +5 -0
  86. package/dist/cjs/views/Stack.js.map +2 -2
  87. package/dist/cjs/views/Text.js +5 -0
  88. package/dist/cjs/views/Text.js.map +2 -2
  89. package/dist/cjs/views/TextAncestorContext.js +6 -0
  90. package/dist/cjs/views/Theme.js +11 -4
  91. package/dist/cjs/views/Theme.js.map +2 -2
  92. package/dist/cjs/views/ThemeInverse.js +5 -0
  93. package/dist/cjs/views/ThemeProvider.js +6 -1
  94. package/dist/cjs/views/ThemeProvider.js.map +2 -2
  95. package/dist/cjs/views/ThemeReset.js +4 -0
  96. package/dist/esm/Tamagui.js +10 -2
  97. package/dist/esm/Tamagui.js.map +2 -2
  98. package/dist/esm/ThemeManager.js +21 -11
  99. package/dist/esm/ThemeManager.js.map +2 -2
  100. package/dist/esm/conf.js +0 -1
  101. package/dist/esm/conf.js.map +2 -2
  102. package/dist/esm/constants/platform.js +2 -0
  103. package/dist/esm/constants/platform.js.map +2 -2
  104. package/dist/esm/createComponent.js +146 -133
  105. package/dist/esm/createComponent.js.map +2 -2
  106. package/dist/esm/createTamagui.js +53 -28
  107. package/dist/esm/createTamagui.js.map +2 -2
  108. package/dist/esm/createTokens.js +2 -6
  109. package/dist/esm/createTokens.js.map +2 -2
  110. package/dist/esm/createVariable.js +8 -2
  111. package/dist/esm/createVariable.js.map +2 -2
  112. package/dist/esm/defaultComponentState.js +0 -11
  113. package/dist/esm/defaultComponentState.js.map +3 -3
  114. package/dist/esm/helpers/RNComponents.js +12 -0
  115. package/dist/esm/helpers/RNComponents.js.map +7 -0
  116. package/dist/esm/helpers/addStylesUsingClassname.js +16 -18
  117. package/dist/esm/helpers/addStylesUsingClassname.js.map +2 -2
  118. package/dist/esm/helpers/createPropMapper.js +59 -61
  119. package/dist/esm/helpers/createPropMapper.js.map +2 -2
  120. package/dist/esm/helpers/createShallowUpdate.js +19 -0
  121. package/dist/esm/helpers/createShallowUpdate.js.map +7 -0
  122. package/dist/esm/helpers/createTamaguiProvider.js +1 -4
  123. package/dist/esm/helpers/createTamaguiProvider.js.map +2 -2
  124. package/dist/esm/helpers/extendStaticConfig.js +9 -6
  125. package/dist/esm/helpers/extendStaticConfig.js.map +2 -2
  126. package/dist/esm/helpers/fixNativeShadow.native.js +2 -2
  127. package/dist/esm/helpers/fixNativeShadow.native.js.map +2 -2
  128. package/dist/esm/helpers/getSize.js +13 -0
  129. package/dist/esm/helpers/getSize.js.map +7 -0
  130. package/dist/esm/helpers/getSplitStyles.js +152 -67
  131. package/dist/esm/helpers/getSplitStyles.js.map +2 -2
  132. package/dist/esm/helpers/getStylesAtomic.js +15 -2
  133. package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
  134. package/dist/esm/helpers/insertStyleRule.js +36 -26
  135. package/dist/esm/helpers/insertStyleRule.js.map +2 -2
  136. package/dist/esm/helpers/proxyThemeVariables.js +18 -0
  137. package/dist/esm/helpers/proxyThemeVariables.js.map +7 -0
  138. package/dist/esm/helpers/themeable.js +3 -2
  139. package/dist/esm/helpers/themeable.js.map +2 -2
  140. package/dist/esm/helpers/validate.js +24 -11
  141. package/dist/esm/helpers/validate.js.map +2 -2
  142. package/dist/esm/hooks/useFeatures.js +96 -17
  143. package/dist/esm/hooks/useFeatures.js.map +2 -2
  144. package/dist/esm/hooks/useIsTouchDevice.js +6 -6
  145. package/dist/esm/hooks/useIsTouchDevice.js.map +2 -2
  146. package/dist/esm/hooks/useMedia.js +19 -12
  147. package/dist/esm/hooks/useMedia.js.map +2 -2
  148. package/dist/esm/hooks/useTheme.js +28 -23
  149. package/dist/esm/hooks/useTheme.js.map +2 -2
  150. package/dist/esm/index.js +4 -0
  151. package/dist/esm/index.js.map +2 -2
  152. package/dist/esm/static.js +3 -0
  153. package/dist/esm/static.js.map +2 -2
  154. package/dist/esm/styled.js +4 -12
  155. package/dist/esm/styled.js.map +2 -2
  156. package/dist/esm/views/Stack.js +1 -0
  157. package/dist/esm/views/Stack.js.map +2 -2
  158. package/dist/esm/views/Text.js +1 -0
  159. package/dist/esm/views/Text.js.map +2 -2
  160. package/dist/esm/views/Theme.js +7 -4
  161. package/dist/esm/views/Theme.js.map +2 -2
  162. package/dist/esm/views/ThemeProvider.js +2 -1
  163. package/dist/esm/views/ThemeProvider.js.map +2 -2
  164. package/dist/jsx/Tamagui.js +10 -2
  165. package/dist/jsx/ThemeManager.js +21 -11
  166. package/dist/jsx/conf.js +0 -1
  167. package/dist/jsx/constants/platform.js +2 -0
  168. package/dist/jsx/createComponent.js +139 -127
  169. package/dist/jsx/createTamagui.js +53 -28
  170. package/dist/jsx/createTokens.js +2 -6
  171. package/dist/jsx/createVariable.js +8 -2
  172. package/dist/jsx/defaultComponentState.js +0 -11
  173. package/dist/jsx/helpers/RNComponents.js +11 -0
  174. package/dist/jsx/helpers/addStylesUsingClassname.js +16 -18
  175. package/dist/jsx/helpers/createPropMapper.js +59 -61
  176. package/dist/jsx/helpers/createShallowUpdate.js +18 -0
  177. package/dist/jsx/helpers/createTamaguiProvider.js +1 -2
  178. package/dist/jsx/helpers/extendStaticConfig.js +9 -6
  179. package/dist/jsx/helpers/fixNativeShadow.native.js +2 -2
  180. package/dist/jsx/helpers/getSize.js +12 -0
  181. package/dist/jsx/helpers/getSplitStyles.js +152 -67
  182. package/dist/jsx/helpers/getStylesAtomic.js +15 -2
  183. package/dist/jsx/helpers/insertStyleRule.js +36 -26
  184. package/dist/jsx/helpers/proxyThemeVariables.js +17 -0
  185. package/dist/jsx/helpers/themeable.js +3 -3
  186. package/dist/jsx/helpers/validate.js +24 -11
  187. package/dist/jsx/hooks/useFeatures.js +96 -17
  188. package/dist/jsx/hooks/useIsTouchDevice.js +6 -6
  189. package/dist/jsx/hooks/useMedia.js +19 -12
  190. package/dist/jsx/hooks/useTheme.js +28 -23
  191. package/dist/jsx/index.js +4 -0
  192. package/dist/jsx/static.js +3 -0
  193. package/dist/jsx/styled.js +4 -12
  194. package/dist/jsx/views/Stack.js +1 -0
  195. package/dist/jsx/views/Text.js +1 -0
  196. package/dist/jsx/views/Theme.js +7 -4
  197. package/dist/jsx/views/ThemeProvider.js +2 -2
  198. package/package.json +6 -6
  199. package/types/Tamagui.d.ts +18 -1
  200. package/types/Tamagui.d.ts.map +1 -1
  201. package/types/ThemeManager.d.ts +3 -3
  202. package/types/ThemeManager.d.ts.map +1 -1
  203. package/types/conf.d.ts +2 -0
  204. package/types/conf.d.ts.map +1 -1
  205. package/types/constants/platform.d.ts +1 -0
  206. package/types/constants/platform.d.ts.map +1 -1
  207. package/types/createComponent.d.ts +5 -7
  208. package/types/createComponent.d.ts.map +1 -1
  209. package/types/createFont.d.ts +1 -1
  210. package/types/createFont.d.ts.map +1 -1
  211. package/types/createTamagui.d.ts +3 -1
  212. package/types/createTamagui.d.ts.map +1 -1
  213. package/types/createTokens.d.ts +0 -26
  214. package/types/createTokens.d.ts.map +1 -1
  215. package/types/createVariable.d.ts +1 -0
  216. package/types/createVariable.d.ts.map +1 -1
  217. package/types/defaultComponentState.d.ts +0 -12
  218. package/types/defaultComponentState.d.ts.map +1 -1
  219. package/types/helpers/RNComponents.d.ts +2 -0
  220. package/types/helpers/RNComponents.d.ts.map +1 -0
  221. package/types/helpers/addStylesUsingClassname.d.ts.map +1 -1
  222. package/types/helpers/createPropMapper.d.ts +2 -2
  223. package/types/helpers/createPropMapper.d.ts.map +1 -1
  224. package/types/helpers/createShallowUpdate.d.ts +4 -0
  225. package/types/helpers/createShallowUpdate.d.ts.map +1 -0
  226. package/types/helpers/createTamaguiProvider.d.ts +1 -1
  227. package/types/helpers/createTamaguiProvider.d.ts.map +1 -1
  228. package/types/helpers/extendStaticConfig.d.ts +2 -2
  229. package/types/helpers/extendStaticConfig.d.ts.map +1 -1
  230. package/types/helpers/getSize.d.ts +3 -0
  231. package/types/helpers/getSize.d.ts.map +1 -0
  232. package/types/helpers/getSplitStyles.d.ts +15 -18
  233. package/types/helpers/getSplitStyles.d.ts.map +1 -1
  234. package/types/helpers/getStylesAtomic.d.ts.map +1 -1
  235. package/types/helpers/insertStyleRule.d.ts +2 -1
  236. package/types/helpers/insertStyleRule.d.ts.map +1 -1
  237. package/types/helpers/proxyThemeVariables.d.ts +2 -0
  238. package/types/helpers/proxyThemeVariables.d.ts.map +1 -0
  239. package/types/helpers/themeable.d.ts +3 -1
  240. package/types/helpers/themeable.d.ts.map +1 -1
  241. package/types/helpers/validate.d.ts.map +1 -1
  242. package/types/hooks/useFeatures.d.ts +7 -5
  243. package/types/hooks/useFeatures.d.ts.map +1 -1
  244. package/types/hooks/useMedia.d.ts +2 -6
  245. package/types/hooks/useMedia.d.ts.map +1 -1
  246. package/types/hooks/useTheme.d.ts +1 -1
  247. package/types/hooks/useTheme.d.ts.map +1 -1
  248. package/types/index.d.ts +2 -0
  249. package/types/index.d.ts.map +1 -1
  250. package/types/static.d.ts +3 -0
  251. package/types/static.d.ts.map +1 -1
  252. package/types/styled.d.ts +13 -8
  253. package/types/styled.d.ts.map +1 -1
  254. package/types/types-rnw.d.ts +0 -5
  255. package/types/types-rnw.d.ts.map +1 -1
  256. package/types/types.d.ts +147 -106
  257. package/types/types.d.ts.map +1 -1
  258. package/types/views/Stack.d.ts +2 -2
  259. package/types/views/Stack.d.ts.map +1 -1
  260. package/types/views/Text.d.ts +2 -2
  261. package/types/views/Text.d.ts.map +1 -1
  262. package/types/views/Theme.d.ts +1 -0
  263. package/types/views/Theme.d.ts.map +1 -1
  264. package/types/views/ThemeProvider.d.ts +1 -0
  265. package/types/views/ThemeProvider.d.ts.map +1 -1
  266. package/LICENSE +0 -21
  267. package/dist/cjs/spacedChildren.js +0 -86
  268. package/dist/cjs/spacedChildren.js.map +0 -7
  269. package/dist/esm/spacedChildren.js +0 -52
  270. package/dist/esm/spacedChildren.js.map +0 -7
  271. package/dist/jsx/spacedChildren.js +0 -44
  272. package/types/spacedChildren.d.ts +0 -9
  273. package/types/spacedChildren.d.ts.map +0 -1
@@ -1,26 +1,24 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { useInsertionEffect } from "react";
3
+ import { useInsertionEffect, useLayoutEffect } from "react";
4
4
  import { getStylesAtomic } from "./getStylesAtomic";
5
- import { insertStyleRule } from "./insertStyleRule";
5
+ import { insertStyleRule, updateInsertedCache } from "./insertStyleRule";
6
6
  let added = /* @__PURE__ */ new Set();
7
+ const effect = useInsertionEffect || useLayoutEffect;
7
8
  function useStylesAsClassname(styles, disable = false, debug = false) {
8
- if (!useInsertionEffect) {
9
- return addStylesUsingClassname(disable ? styles : [], debug);
10
- } else {
11
- const insertions = [];
12
- const className = addStylesUsingClassname(disable ? [] : styles, debug, (identifier, rules) => {
13
- for (const rule of rules) {
14
- insertions.push({ identifier, rule });
15
- }
16
- });
17
- useInsertionEffect(() => {
18
- for (const { identifier, rule } of insertions) {
19
- insertStyleRule(identifier, rule);
20
- }
21
- });
22
- return className;
23
- }
9
+ const insertions = [];
10
+ const className = addStylesUsingClassname(disable ? [] : styles, debug, (identifier, rules) => {
11
+ for (const rule of rules) {
12
+ insertions.push({ identifier, rule });
13
+ updateInsertedCache(identifier, rule);
14
+ }
15
+ });
16
+ effect(() => {
17
+ for (const { identifier, rule } of insertions) {
18
+ insertStyleRule(identifier, rule);
19
+ }
20
+ }, [className]);
21
+ return className;
24
22
  }
25
23
  __name(useStylesAsClassname, "useStylesAsClassname");
26
24
  function addStylesUsingClassname(styles, debug = false, onAdd) {
@@ -4,63 +4,67 @@ import { getConfig } from "../conf";
4
4
  import { isWeb } from "../constants/platform";
5
5
  import { isVariable } from "../createVariable";
6
6
  import { isObj } from "./isObj";
7
- const createPropMapper = /* @__PURE__ */ __name((c) => {
8
- const variants = c.variants || {};
9
- function getVariantFunction(variant, key, value) {
10
- for (const cat in tokenCategories) {
11
- if (key in tokenCategories[cat]) {
12
- const spreadVariant = variant[`...${cat}`];
13
- if (spreadVariant) {
14
- return spreadVariant;
15
- }
7
+ function getVariantFunction(variant, key, value) {
8
+ if (typeof variant === "function") {
9
+ return variant;
10
+ }
11
+ for (const cat in tokenCategories) {
12
+ if (key in tokenCategories[cat]) {
13
+ const spreadVariant = variant[`...${cat}`];
14
+ if (spreadVariant) {
15
+ return spreadVariant;
16
16
  }
17
17
  }
18
- let fn;
19
- if (typeof value === "number") {
20
- fn = variant[":number"];
21
- } else if (typeof value === "string") {
22
- fn = variant[":string"];
23
- } else if (value === true || value === false) {
24
- fn = variant[":boolean"];
25
- }
26
- fn = fn || variant[value];
27
- return fn || variant["..."] || variant["...size"];
28
18
  }
29
- __name(getVariantFunction, "getVariantFunction");
30
- const defaultProps = c.defaultProps || {};
31
- return (key, value, theme, props, staticConfig, returnVariablesAs = !!props.animation ? "value" : "auto", avoidDefaultProps = false) => {
19
+ let fn;
20
+ if (typeof value === "number") {
21
+ fn = variant[":number"];
22
+ } else if (typeof value === "string") {
23
+ fn = variant[":string"];
24
+ } else if (value === true || value === false) {
25
+ fn = variant[":boolean"];
26
+ }
27
+ fn = fn || variant[value];
28
+ return fn || variant["..."] || variant["...size"];
29
+ }
30
+ __name(getVariantFunction, "getVariantFunction");
31
+ const createPropMapper = /* @__PURE__ */ __name((staticConfig) => {
32
+ const variants = staticConfig.variants || {};
33
+ const defaultProps = staticConfig.defaultProps || {};
34
+ return (key, value, theme, props, returnVariablesAs = !!props.animation ? "value" : "auto", avoidDefaultProps = false) => {
32
35
  const conf = getConfig();
33
36
  if (!conf) {
34
37
  console.trace("no conf! err");
35
38
  return;
36
39
  }
37
- let fontFamily = props.fontFamily || defaultProps.fontFamily || "$body";
40
+ const fontFamily = props.fontFamily || defaultProps.fontFamily || "$body";
38
41
  const variant = variants && variants[key];
39
42
  if (variant && value !== void 0) {
40
43
  let variantValue = getVariantFunction(variant, key, value);
41
- if (!variantValue) {
42
- return value;
43
- }
44
- if (typeof variantValue === "function") {
45
- variantValue = variantValue(value, {
46
- tokens: conf.tokensParsed,
47
- theme,
48
- props: avoidDefaultProps ? props : new Proxy(props, {
49
- get(target, key2) {
50
- if (Reflect.has(target, key2)) {
51
- return Reflect.get(target, key2);
44
+ if (variantValue) {
45
+ if (typeof variantValue === "function") {
46
+ const fn = variantValue;
47
+ variantValue = fn(value, {
48
+ fonts: conf.fontsParsed,
49
+ tokens: conf.tokensParsed,
50
+ theme,
51
+ props: avoidDefaultProps ? props : new Proxy(props, {
52
+ get(target, key2) {
53
+ if (Reflect.has(target, key2)) {
54
+ return Reflect.get(target, key2);
55
+ }
56
+ if (defaultProps) {
57
+ return Reflect.get(defaultProps, key2);
58
+ }
52
59
  }
53
- if (staticConfig.defaultProps) {
54
- return Reflect.get(staticConfig.defaultProps, key2);
55
- }
56
- }
57
- })
58
- });
59
- }
60
- if (isObj(variantValue)) {
61
- variantValue = resolveTokens(variantValue, conf, theme, fontFamily, returnVariablesAs);
60
+ })
61
+ });
62
+ }
63
+ if (isObj(variantValue)) {
64
+ variantValue = resolveTokens(variantValue, conf, theme, fontFamily, returnVariablesAs);
65
+ }
66
+ return variantValue;
62
67
  }
63
- return variantValue;
64
68
  }
65
69
  let shouldReturn = false;
66
70
  if (conf.shorthands[key]) {
@@ -108,34 +112,28 @@ const resolveTokens = /* @__PURE__ */ __name((input, conf, theme, fontFamily, re
108
112
  }
109
113
  return res;
110
114
  }, "resolveTokens");
111
- const getToken = /* @__PURE__ */ __name((key, value, { tokensParsed }, theme, fontFamily = "$body", resolveAs) => {
112
- var _a, _b, _c, _d, _e;
115
+ const fontShorthand = {
116
+ fontSize: "size",
117
+ fontWeight: "weight"
118
+ };
119
+ const getToken = /* @__PURE__ */ __name((key, value, { tokensParsed, fontsParsed }, theme, fontFamily = "$body", resolveAs) => {
120
+ var _a, _b, _c;
113
121
  let valOrVar;
114
122
  let hasSet = false;
115
- const valueName = value[0] === "$" ? value.slice(1) : value;
116
- if (valueName in theme) {
117
- valOrVar = theme[valueName];
123
+ if (value in theme) {
124
+ valOrVar = theme[value];
118
125
  hasSet = true;
119
126
  } else {
120
127
  switch (key) {
121
128
  case "fontFamily":
122
- valOrVar = ((_a = tokensParsed.font[value]) == null ? void 0 : _a.family) || value;
129
+ valOrVar = ((_a = fontsParsed[value]) == null ? void 0 : _a.family) || value;
123
130
  hasSet = true;
124
131
  break;
125
132
  case "fontSize":
126
- valOrVar = ((_b = tokensParsed.font[fontFamily]) == null ? void 0 : _b.size[value]) || value;
127
- hasSet = true;
128
- break;
129
133
  case "lineHeight":
130
- valOrVar = ((_c = tokensParsed.font[fontFamily]) == null ? void 0 : _c.lineHeight[value]) || value;
131
- hasSet = true;
132
- break;
133
134
  case "letterSpacing":
134
- valOrVar = ((_d = tokensParsed.font[fontFamily]) == null ? void 0 : _d.letterSpacing[value]) || value;
135
- hasSet = true;
136
- break;
137
135
  case "fontWeight":
138
- valOrVar = ((_e = tokensParsed.font[fontFamily]) == null ? void 0 : _e.weight[value]) || value;
136
+ valOrVar = ((_c = (_b = fontsParsed[fontFamily]) == null ? void 0 : _b[fontShorthand[key] || key]) == null ? void 0 : _c[value]) || value;
139
137
  hasSet = true;
140
138
  break;
141
139
  }
@@ -161,7 +159,7 @@ const getToken = /* @__PURE__ */ __name((key, value, { tokensParsed }, theme, fo
161
159
  }
162
160
  if (process.env.NODE_ENV === "development") {
163
161
  if (value && value[0] === "$") {
164
- console.warn(`\u26A0\uFE0F Missing token in theme:`, value, theme);
162
+ console.warn(`\u26A0\uFE0F Missing token:`, key, value, fontFamily, theme, fontsParsed);
165
163
  return null;
166
164
  }
167
165
  }
@@ -0,0 +1,18 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ function createShallowUpdate(setter) {
4
+ return (next) => {
5
+ setter((prev) => {
6
+ for (const key in next) {
7
+ if (prev[key] !== next[key]) {
8
+ return { ...prev, ...next };
9
+ }
10
+ }
11
+ return prev;
12
+ });
13
+ };
14
+ }
15
+ __name(createShallowUpdate, "createShallowUpdate");
16
+ export {
17
+ createShallowUpdate
18
+ };
@@ -10,7 +10,6 @@ function createTamaguiProvider({
10
10
  }) {
11
11
  return /* @__PURE__ */ __name(function TamaguiProvider({
12
12
  injectCSS,
13
- fallback,
14
13
  children,
15
14
  ...themePropsProvider
16
15
  }) {
@@ -26,7 +25,7 @@ function createTamaguiProvider({
26
25
  };
27
26
  }, []);
28
27
  }
29
- return <ButtonInsideButtonContext.Provider value={false}><TextAncestorProvider><ThemeProvider {...themeProps} {...themePropsProvider}><React.Suspense fallback={fallback || null}>{children}</React.Suspense></ThemeProvider></TextAncestorProvider></ButtonInsideButtonContext.Provider>;
28
+ return <ButtonInsideButtonContext.Provider value={false}><TextAncestorProvider><ThemeProvider {...themeProps} {...themePropsProvider}>{children}</ThemeProvider></TextAncestorProvider></ButtonInsideButtonContext.Provider>;
30
29
  }, "TamaguiProvider");
31
30
  }
32
31
  __name(createTamaguiProvider, "createTamaguiProvider");
@@ -2,12 +2,9 @@ var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
  import { stylePropsView } from "@tamagui/helpers";
4
4
  import { createPropMapper } from "./createPropMapper";
5
- function extendStaticConfig(parent, config = {}) {
5
+ function extendStaticConfig(config, parent) {
6
6
  var _a;
7
- if (!parent) {
8
- throw new Error("no parent");
9
- }
10
- if (!("staticConfig" in parent)) {
7
+ if (!parent || !("staticConfig" in parent)) {
11
8
  return parseStaticConfig(config);
12
9
  }
13
10
  const variants = {
@@ -38,9 +35,15 @@ function extendStaticConfig(parent, config = {}) {
38
35
  ...parent.staticConfig.validStyles,
39
36
  ...config.validStyles
40
37
  } : parent.staticConfig.validStyles || stylePropsView,
38
+ defaultVariants: {
39
+ ...parent.staticConfig.defaultVariants,
40
+ ...config.defaultVariants
41
+ },
41
42
  defaultProps: {
42
43
  ...parent.staticConfig.defaultProps,
43
- ...config.defaultProps
44
+ ...parent.staticConfig.defaultVariants,
45
+ ...config.defaultProps,
46
+ ...config.defaultVariants
44
47
  }
45
48
  });
46
49
  }
@@ -18,8 +18,8 @@ function fixNativeShadow(props) {
18
18
  if ((c[0] === "r" || c[0] === "h") && c[3] === "a") {
19
19
  const [_, type, _1, _2, _3, a] = c.match(matchRgbaHsla) || [];
20
20
  if (typeof a !== "string") {
21
- console.warn("invalid", c, type);
22
- return;
21
+ console.trace("invalid", c, type);
22
+ throw new Error(`invalid style`);
23
23
  }
24
24
  props.shadowColor = `${type.replace("a", "")}(${_1},${_2},${_3})`;
25
25
  props.shadowOpacity = +a;
@@ -0,0 +1,12 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { getTokens } from "../conf";
4
+ const getSize = /* @__PURE__ */ __name((size, sizeUpOrDownBy = 0) => {
5
+ const sizes = getTokens().size;
6
+ const sizeNames = Object.keys(sizes);
7
+ const key = sizeNames[Math.max(0, sizeNames.indexOf(String(size || "$4")) + sizeUpOrDownBy)];
8
+ return sizes[key] || sizes["$4"];
9
+ }, "getSize");
10
+ export {
11
+ getSize
12
+ };
@@ -7,34 +7,31 @@ import {
7
7
  validPseudoKeys,
8
8
  validStyles
9
9
  } from "@tamagui/helpers";
10
- import { isWeb } from "../constants/platform";
10
+ import { useInsertionEffect } from "react";
11
+ import { getConfig } from "../conf";
12
+ import { isClient, isWeb, useIsomorphicLayoutEffect } from "../constants/platform";
11
13
  import { mediaQueryConfig, mediaState } from "../hooks/useMedia";
12
14
  import { createMediaStyle } from "./createMediaStyle";
13
15
  import { fixNativeShadow } from "./fixNativeShadow";
14
16
  import { getStylesAtomic } from "./getStylesAtomic";
15
- import { insertStyleRule, insertedTransforms, updateInserted } from "./insertStyleRule";
16
- const skipKeys = {
17
+ import {
18
+ insertStyleRule,
19
+ insertedTransforms,
20
+ updateInserted,
21
+ updateInsertedCache
22
+ } from "./insertStyleRule";
23
+ const skipProps = {
17
24
  animation: true,
18
- animated: true,
19
- children: true,
20
- key: true,
21
- ref: true
25
+ animateOnly: true,
26
+ debug: true
22
27
  };
23
- function normalizeStyleObject(style) {
24
- var _a, _b;
25
- if (typeof style.flex === "number") {
26
- const val = style.flex;
27
- delete style.flex;
28
- style.flexGrow = (_a = style.flexGrow) != null ? _a : val;
29
- style.flexShrink = (_b = style.flexShrink) != null ? _b : 1;
30
- }
31
- if (!isWeb) {
32
- fixNativeShadow(style);
33
- }
34
- }
35
- __name(normalizeStyleObject, "normalizeStyleObject");
28
+ let conf;
36
29
  const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state, defaultClassNames) => {
37
- var _a, _b, _c;
30
+ var _a;
31
+ if (process.env.NODE_ENV === "development" && props["debug"] === "verbose") {
32
+ console.log(" \xBB getSplitStyles", { props, state, defaultClassNames });
33
+ }
34
+ conf = conf || getConfig();
38
35
  const validStyleProps = staticConfig.isText ? stylePropsText : validStyles;
39
36
  const viewProps = {};
40
37
  const style = {};
@@ -43,23 +40,51 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
43
40
  };
44
41
  const pseudos = {};
45
42
  const medias = {};
43
+ const rulesToInsert = [];
44
+ function addStyle(prop, rule) {
45
+ rulesToInsert.push([prop, rule]);
46
+ updateInsertedCache(prop, rule);
47
+ }
48
+ __name(addStyle, "addStyle");
46
49
  let cur = null;
47
50
  let transforms = {};
48
51
  function mergeClassName(key, val) {
49
- if (!val)
52
+ if (!val) {
50
53
  return;
54
+ }
51
55
  if (val.startsWith("_transform-")) {
52
56
  const isMediaOrPseudo = key !== "transform";
53
57
  const isMedia = isMediaOrPseudo && key[11] === "_";
54
- const isPsuedo = isMediaOrPseudo && !isMedia;
58
+ const isPsuedo = isMediaOrPseudo && key[11] === "0" || key.endsWith("Style");
55
59
  const namespace = isMedia ? key.split("_")[2] : isPsuedo ? key.split("-")[1] : "transform";
56
- if (!insertedTransforms[val]) {
57
- updateInserted();
60
+ let transform = insertedTransforms[val];
61
+ if (isClient) {
62
+ if (!transform) {
63
+ updateInserted();
64
+ transform = insertedTransforms[val];
65
+ }
66
+ if (!transform) {
67
+ if (isWeb && val[0] !== "_") {
68
+ transform = val;
69
+ } else {
70
+ console.trace("?", key, val, cur, props, state);
71
+ }
72
+ }
73
+ if (process.env.NODE_ENV === "development" && props["debug"] === "verbose") {
74
+ console.log(" \xBB getSplitStyles mergeClassName transform", { key, val, namespace, transform, insertedTransforms });
75
+ }
76
+ if (process.env.NODE_ENV === "development") {
77
+ if (!transform) {
78
+ console.trace("NO TRANSFORM?", { key, val, transform });
79
+ }
80
+ }
58
81
  }
59
- const transform = insertedTransforms[val];
60
82
  transforms[namespace] = transforms[namespace] || ["", ""];
61
- transforms[namespace][0] += val.replace("_transform", "");
62
- transforms[namespace][1] += transform;
83
+ const identifier = val.replace("_transform", "");
84
+ transforms[namespace][0] += identifier;
85
+ if (transform) {
86
+ transforms[namespace][1] += transform;
87
+ }
63
88
  } else {
64
89
  classNames[key] = val;
65
90
  }
@@ -69,17 +94,21 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
69
94
  if (!cur)
70
95
  return;
71
96
  normalizeStyleObject(cur);
97
+ if (process.env.NODE_ENV === "development" && props["debug"] === "verbose") {
98
+ console.log(" \xBB getSplitStyles push", cur, state);
99
+ }
72
100
  if (isWeb && !state.noClassNames) {
73
101
  const atomic = getStylesAtomic(cur);
74
102
  for (const atomicStyle of atomic) {
75
103
  if (!state.noClassNames) {
104
+ addStyle(atomicStyle.identifier, atomicStyle.rules[0]);
76
105
  mergeClassName(atomicStyle.property, atomicStyle.identifier);
77
- insertStyleRule(atomicStyle.identifier, atomicStyle.rules[0]);
78
106
  } else {
79
107
  style[atomicStyle.property] = atomicStyle.value;
80
108
  }
81
109
  }
82
- } else {
110
+ }
111
+ if (!isWeb || state.noClassNames || state.resolveVariablesAs === "value" || state.resolveVariablesAs === "both") {
83
112
  for (const key in cur) {
84
113
  if (key in stylePropsTransform) {
85
114
  mergeTransform(style, key, cur[key]);
@@ -92,30 +121,40 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
92
121
  }
93
122
  __name(push, "push");
94
123
  for (const keyInit in props) {
124
+ if (skipProps[keyInit]) {
125
+ continue;
126
+ }
95
127
  const valInit = props[keyInit];
96
- if (skipKeys[keyInit]) {
97
- viewProps[keyInit] = valInit;
128
+ if (keyInit === "style" || keyInit.startsWith("_style")) {
129
+ push();
130
+ cur = valInit;
131
+ push();
98
132
  continue;
99
133
  }
100
134
  if (keyInit === "className" || validStyleProps[keyInit] && valInit && valInit[0] === "_") {
101
135
  push();
102
136
  mergeClassName(keyInit, valInit);
103
- if (cur) {
104
- if (cur[keyInit])
105
- console.warn("just want to see how used");
106
- delete cur[keyInit];
107
- }
108
137
  continue;
109
138
  }
139
+ if (state.keepVariantsAsProps && staticConfig.defaultVariants && keyInit in staticConfig.defaultVariants) {
140
+ viewProps[keyInit] = valInit;
141
+ }
110
142
  let isMedia = keyInit[0] === "$";
111
143
  let isPseudo = validPseudoKeys[keyInit];
112
- const out = isMedia || isPseudo ? true : staticConfig.propMapper(keyInit, valInit, theme, props, staticConfig, state.resolveVariablesAs);
144
+ if (!isMedia && !isPseudo && !((_a = staticConfig.variants) == null ? void 0 : _a[keyInit]) && !validStyleProps[keyInit] && !conf.shorthands[keyInit]) {
145
+ viewProps[keyInit] = valInit;
146
+ continue;
147
+ }
148
+ const out = isMedia || isPseudo ? true : staticConfig.propMapper(keyInit, valInit, theme, state.fallbackProps || props, state.resolveVariablesAs);
113
149
  const expanded = out === true || !out ? [[keyInit, valInit]] : Object.entries(out);
150
+ if (process.env.NODE_ENV === "development" && props["debug"] === "verbose") {
151
+ console.log(" \xBB getSplitStyles", keyInit, expanded);
152
+ }
114
153
  for (const [key, val] of expanded) {
115
154
  if (val === void 0) {
116
155
  continue;
117
156
  }
118
- if (val && val[0] === "_") {
157
+ if (key !== "target" && val && val[0] === "_") {
119
158
  mergeClassName(key, val);
120
159
  continue;
121
160
  }
@@ -131,48 +170,46 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
131
170
  continue;
132
171
  }
133
172
  pseudos[key] = pseudos[key] || {};
134
- pseudos[key] = getSubStyle(val, staticConfig, theme, props, state.resolveVariablesAs, true);
173
+ pseudos[key] = getSubStyle(val, staticConfig, theme, props, state, true);
135
174
  if (isWeb && !state.noClassNames) {
136
175
  const pseudoStyles = getStylesAtomic({ [key]: pseudos[key] });
137
- if ((_b = (_a = pseudoStyles[0]) == null ? void 0 : _a.identifier) == null ? void 0 : _b.includes("undefined")) {
138
- console.warn("undefined bug?", (_c = pseudoStyles[0]) == null ? void 0 : _c.identifier);
139
- }
140
176
  for (const style2 of pseudoStyles) {
177
+ addStyle(style2.identifier, style2.rules[0]);
141
178
  mergeClassName(`${style2.property}-${key}`, style2.identifier);
142
- insertStyleRule(style2.identifier, style2.rules[0]);
143
179
  }
144
180
  }
145
181
  continue;
146
182
  }
147
183
  if (isMedia) {
148
- const mediaKey = key.slice(1);
149
- if (!mediaQueryConfig[mediaKey]) {
150
- viewProps[key] = valInit;
184
+ const mediaKey = key;
185
+ const mediaKeyShort = mediaKey.slice(1);
186
+ if (!mediaQueryConfig[mediaKeyShort]) {
187
+ viewProps[key] = val;
151
188
  continue;
152
189
  }
153
- const mediaStyle = getSubStyle(valInit, staticConfig, theme, props, state.resolveVariablesAs, true);
154
- if (isWeb) {
190
+ const mediaStyle = getSubStyle(val, staticConfig, theme, props, state);
191
+ if (process.env.NODE_ENV === "development" && props["debug"] === "verbose") {
192
+ console.log(" \xBB getSplitStyles mediaStyle", mediaKey, mediaStyle, props);
193
+ }
194
+ const shouldDoClasses = isWeb && !state.noClassNames;
195
+ if (shouldDoClasses) {
155
196
  const mediaStyles = getStylesAtomic(mediaStyle);
156
197
  for (const style2 of mediaStyles) {
157
- const out2 = createMediaStyle(style2, mediaKey, mediaQueryConfig);
198
+ const out2 = createMediaStyle(style2, mediaKeyShort, mediaQueryConfig);
199
+ addStyle(out2.identifier, out2.styleRule);
158
200
  mergeClassName(`${out2.identifier}-${mediaKey}`, out2.identifier);
159
- insertStyleRule(out2.identifier, out2.styleRule);
160
- }
161
- if (mediaState[mediaKey]) {
162
- Object.assign(medias, mediaStyle);
163
201
  }
164
202
  } else {
165
203
  if (mediaState[mediaKey]) {
166
- Object.assign(style, mediaStyle);
204
+ push();
205
+ if (process.env.NODE_ENV === "development" && props["debug"]) {
206
+ console.log("apply media style", mediaKey, mediaState);
207
+ }
208
+ Object.assign(shouldDoClasses ? medias : style, mediaStyle);
167
209
  }
168
210
  }
169
211
  continue;
170
212
  }
171
- if (key === "style" || key.startsWith("_style")) {
172
- push();
173
- Object.assign(style, val);
174
- continue;
175
- }
176
213
  if (!isWeb && key === "pointerEvents") {
177
214
  viewProps[key] = val;
178
215
  continue;
@@ -195,26 +232,49 @@ const getSplitStyles = /* @__PURE__ */ __name((props, staticConfig, theme, state
195
232
  for (const namespace in transforms) {
196
233
  const [hash, val] = transforms[namespace];
197
234
  const identifier = `_transform${hash}`;
198
- if (!insertedTransforms[identifier]) {
199
- const rule = `.${identifier} { transform: ${val}; }`;
200
- insertStyleRule(identifier, rule);
235
+ if (isClient) {
236
+ if (!insertedTransforms[identifier]) {
237
+ const rule = `.${identifier} { transform: ${val}; }`;
238
+ addStyle(identifier, rule);
239
+ }
201
240
  }
202
241
  classNames[namespace] = identifier;
203
242
  }
204
243
  }
244
+ if (process.env.NODE_ENV === "development" && props["debug"] === "verbose") {
245
+ console.log(" \xBB getSplitStyles out", { style, pseudos, medias, classNames, viewProps, state });
246
+ }
205
247
  return {
206
248
  viewProps,
207
249
  style,
208
250
  medias,
209
251
  pseudos,
210
- classNames
252
+ classNames,
253
+ rulesToInsert
211
254
  };
212
255
  }, "getSplitStyles");
213
- const getSubStyle = /* @__PURE__ */ __name((styleIn, staticConfig, theme, props, resolveVariablesAs, avoidDefaultProps) => {
256
+ const insertSplitStyles = /* @__PURE__ */ __name((...args) => {
257
+ const res = getSplitStyles(...args);
258
+ for (const [prop, rule] of res.rulesToInsert) {
259
+ insertStyleRule(prop, rule);
260
+ }
261
+ return res;
262
+ }, "insertSplitStyles");
263
+ const effect = useInsertionEffect || useIsomorphicLayoutEffect;
264
+ const useSplitStyles = /* @__PURE__ */ __name((...args) => {
265
+ const res = getSplitStyles(...args);
266
+ effect(() => {
267
+ for (const [prop, rule] of res.rulesToInsert) {
268
+ insertStyleRule(prop, rule);
269
+ }
270
+ });
271
+ return res;
272
+ }, "useSplitStyles");
273
+ const getSubStyle = /* @__PURE__ */ __name((styleIn, staticConfig, theme, props, state, avoidDefaultProps) => {
214
274
  const styleOut = {};
215
275
  for (const key in styleIn) {
216
276
  const val = styleIn[key];
217
- const out = staticConfig.propMapper(key, val, theme, props, staticConfig, resolveVariablesAs, avoidDefaultProps);
277
+ const out = staticConfig.propMapper(key, val, theme, state.fallbackProps || props, state.resolveVariablesAs, avoidDefaultProps);
218
278
  const expanded = out === true || !out ? [[key, val]] : Object.entries(out);
219
279
  for (const [skey, sval] of expanded) {
220
280
  if (skey in stylePropsTransform) {
@@ -227,6 +287,31 @@ const getSubStyle = /* @__PURE__ */ __name((styleIn, staticConfig, theme, props,
227
287
  normalizeStyleObject(styleOut);
228
288
  return styleOut;
229
289
  }, "getSubStyle");
290
+ function normalizeStyleObject(style) {
291
+ var _a, _b;
292
+ if (style.padding) {
293
+ const val = style.padding;
294
+ delete style.padding;
295
+ style.paddingLeft = val;
296
+ style.paddingTop = val;
297
+ style.paddingRight = val;
298
+ style.paddingBottom = val;
299
+ }
300
+ if (typeof style.flex === "number") {
301
+ const val = style.flex;
302
+ delete style.flex;
303
+ style.flexGrow = (_a = style.flexGrow) != null ? _a : val;
304
+ style.flexShrink = (_b = style.flexShrink) != null ? _b : 1;
305
+ }
306
+ if (!isWeb) {
307
+ fixNativeShadow(style);
308
+ }
309
+ }
310
+ __name(normalizeStyleObject, "normalizeStyleObject");
230
311
  export {
231
- getSplitStyles
312
+ getSplitStyles,
313
+ getSubStyle,
314
+ insertSplitStyles,
315
+ normalizeStyleObject,
316
+ useSplitStyles
232
317
  };