@tamagui/web 1.82.0 → 1.82.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 (187) hide show
  1. package/dist/cjs/createComponent.js +2 -2
  2. package/dist/cjs/createComponent.js.map +1 -1
  3. package/dist/cjs/createComponent.native.js +2 -2
  4. package/dist/cjs/createComponent.native.js.map +1 -1
  5. package/dist/cjs/helpers/ThemeManager.js +12 -8
  6. package/dist/cjs/helpers/ThemeManager.js.map +1 -1
  7. package/dist/cjs/helpers/ThemeManager.native.js +12 -8
  8. package/dist/cjs/helpers/ThemeManager.native.js.map +1 -1
  9. package/dist/cjs/helpers/expandStyles.js +1 -1
  10. package/dist/cjs/helpers/expandStyles.js.map +1 -1
  11. package/dist/cjs/helpers/expandStyles.native.js +1 -1
  12. package/dist/cjs/helpers/expandStyles.native.js.map +1 -1
  13. package/dist/cjs/helpers/expandStylesAndRemoveNullishValues.js.map +1 -1
  14. package/dist/cjs/helpers/expandStylesAndRemoveNullishValues.native.js.map +1 -1
  15. package/dist/cjs/helpers/getExpandedShorthands.js.map +1 -1
  16. package/dist/cjs/helpers/getExpandedShorthands.native.js.map +1 -1
  17. package/dist/cjs/helpers/getSplitStyles.js +1 -1
  18. package/dist/cjs/helpers/getSplitStyles.js.map +1 -1
  19. package/dist/cjs/helpers/getSplitStyles.native.js +1 -1
  20. package/dist/cjs/helpers/getSplitStyles.native.js.map +1 -1
  21. package/dist/cjs/helpers/getVariantExtras.js +2 -2
  22. package/dist/cjs/helpers/getVariantExtras.js.map +1 -1
  23. package/dist/cjs/helpers/getVariantExtras.native.js +2 -2
  24. package/dist/cjs/helpers/getVariantExtras.native.js.map +1 -1
  25. package/dist/cjs/helpers/mergeVariants.js +8 -21
  26. package/dist/cjs/helpers/mergeVariants.js.map +1 -1
  27. package/dist/cjs/helpers/mergeVariants.native.js +8 -21
  28. package/dist/cjs/helpers/mergeVariants.native.js.map +1 -1
  29. package/dist/cjs/helpers/normalizeColor.js +2 -2
  30. package/dist/cjs/helpers/normalizeColor.js.map +1 -1
  31. package/dist/cjs/helpers/normalizeColor.native.js +2 -2
  32. package/dist/cjs/helpers/normalizeColor.native.js.map +1 -1
  33. package/dist/cjs/helpers/propMapper.js +2 -2
  34. package/dist/cjs/helpers/propMapper.js.map +1 -1
  35. package/dist/cjs/helpers/propMapper.native.js +2 -2
  36. package/dist/cjs/helpers/propMapper.native.js.map +1 -1
  37. package/dist/cjs/helpers/proxyThemeToParents.js +5 -9
  38. package/dist/cjs/helpers/proxyThemeToParents.js.map +1 -1
  39. package/dist/cjs/helpers/proxyThemeToParents.native.js +5 -9
  40. package/dist/cjs/helpers/proxyThemeToParents.native.js.map +1 -1
  41. package/dist/cjs/helpers/proxyThemeVariables.js +1 -2
  42. package/dist/cjs/helpers/proxyThemeVariables.js.map +1 -1
  43. package/dist/cjs/helpers/proxyThemeVariables.native.js +1 -2
  44. package/dist/cjs/helpers/proxyThemeVariables.native.js.map +1 -1
  45. package/dist/cjs/helpers/themeable.js +4 -1
  46. package/dist/cjs/helpers/themeable.js.map +1 -1
  47. package/dist/cjs/helpers/themeable.native.js +4 -1
  48. package/dist/cjs/helpers/themeable.native.js.map +1 -1
  49. package/dist/cjs/helpers/themes.js +5 -5
  50. package/dist/cjs/helpers/themes.js.map +1 -1
  51. package/dist/cjs/helpers/themes.native.js +5 -5
  52. package/dist/cjs/helpers/themes.native.js.map +1 -1
  53. package/dist/cjs/hooks/useDisableSSR.js +4 -10
  54. package/dist/cjs/hooks/useDisableSSR.js.map +1 -1
  55. package/dist/cjs/hooks/useDisableSSR.native.js +4 -10
  56. package/dist/cjs/hooks/useDisableSSR.native.js.map +1 -1
  57. package/dist/cjs/hooks/useMedia.js +3 -3
  58. package/dist/cjs/hooks/useMedia.js.map +1 -1
  59. package/dist/cjs/hooks/useMedia.native.js +3 -3
  60. package/dist/cjs/hooks/useMedia.native.js.map +1 -1
  61. package/dist/cjs/hooks/useTheme.js +3 -5
  62. package/dist/cjs/hooks/useTheme.js.map +1 -1
  63. package/dist/cjs/hooks/useTheme.native.js +3 -5
  64. package/dist/cjs/hooks/useTheme.native.js.map +1 -1
  65. package/dist/cjs/views/Theme.js +28 -27
  66. package/dist/cjs/views/Theme.js.map +2 -2
  67. package/dist/cjs/views/Theme.native.js +28 -27
  68. package/dist/cjs/views/Theme.native.js.map +2 -2
  69. package/dist/cjs/views/ThemeDebug.js +3 -5
  70. package/dist/cjs/views/ThemeDebug.js.map +1 -1
  71. package/dist/esm/createComponent.js +3 -3
  72. package/dist/esm/createComponent.js.map +1 -1
  73. package/dist/esm/createComponent.native.js +3 -3
  74. package/dist/esm/createComponent.native.js.map +1 -1
  75. package/dist/esm/helpers/ThemeManager.js +12 -8
  76. package/dist/esm/helpers/ThemeManager.js.map +1 -1
  77. package/dist/esm/helpers/ThemeManager.native.js +12 -8
  78. package/dist/esm/helpers/ThemeManager.native.js.map +1 -1
  79. package/dist/esm/helpers/expandStyles.js +1 -1
  80. package/dist/esm/helpers/expandStyles.js.map +1 -1
  81. package/dist/esm/helpers/expandStyles.native.js +1 -1
  82. package/dist/esm/helpers/expandStyles.native.js.map +1 -1
  83. package/dist/esm/helpers/expandStylesAndRemoveNullishValues.js.map +1 -1
  84. package/dist/esm/helpers/expandStylesAndRemoveNullishValues.native.js.map +1 -1
  85. package/dist/esm/helpers/getExpandedShorthands.js.map +1 -1
  86. package/dist/esm/helpers/getExpandedShorthands.native.js.map +1 -1
  87. package/dist/esm/helpers/getSplitStyles.js +1 -1
  88. package/dist/esm/helpers/getSplitStyles.js.map +1 -1
  89. package/dist/esm/helpers/getSplitStyles.native.js +1 -1
  90. package/dist/esm/helpers/getSplitStyles.native.js.map +1 -1
  91. package/dist/esm/helpers/getVariantExtras.js +1 -2
  92. package/dist/esm/helpers/getVariantExtras.js.map +1 -1
  93. package/dist/esm/helpers/getVariantExtras.native.js +1 -2
  94. package/dist/esm/helpers/getVariantExtras.native.js.map +1 -1
  95. package/dist/esm/helpers/mergeVariants.js +8 -21
  96. package/dist/esm/helpers/mergeVariants.js.map +1 -1
  97. package/dist/esm/helpers/mergeVariants.native.js +8 -21
  98. package/dist/esm/helpers/mergeVariants.native.js.map +1 -1
  99. package/dist/esm/helpers/normalizeColor.js +1 -2
  100. package/dist/esm/helpers/normalizeColor.js.map +1 -1
  101. package/dist/esm/helpers/normalizeColor.native.js +1 -2
  102. package/dist/esm/helpers/normalizeColor.native.js.map +1 -1
  103. package/dist/esm/helpers/propMapper.js +2 -2
  104. package/dist/esm/helpers/propMapper.js.map +1 -1
  105. package/dist/esm/helpers/propMapper.native.js +2 -2
  106. package/dist/esm/helpers/propMapper.native.js.map +1 -1
  107. package/dist/esm/helpers/proxyThemeToParents.js +3 -7
  108. package/dist/esm/helpers/proxyThemeToParents.js.map +1 -1
  109. package/dist/esm/helpers/proxyThemeToParents.native.js +3 -7
  110. package/dist/esm/helpers/proxyThemeToParents.native.js.map +1 -1
  111. package/dist/esm/helpers/proxyThemeVariables.js +1 -2
  112. package/dist/esm/helpers/proxyThemeVariables.js.map +1 -1
  113. package/dist/esm/helpers/proxyThemeVariables.native.js +1 -2
  114. package/dist/esm/helpers/proxyThemeVariables.native.js.map +1 -1
  115. package/dist/esm/helpers/themeable.js +4 -1
  116. package/dist/esm/helpers/themeable.js.map +1 -1
  117. package/dist/esm/helpers/themeable.native.js +4 -1
  118. package/dist/esm/helpers/themeable.native.js.map +1 -1
  119. package/dist/esm/helpers/themes.js +5 -5
  120. package/dist/esm/helpers/themes.js.map +1 -1
  121. package/dist/esm/helpers/themes.native.js +5 -5
  122. package/dist/esm/helpers/themes.native.js.map +1 -1
  123. package/dist/esm/hooks/useDisableSSR.js +2 -9
  124. package/dist/esm/hooks/useDisableSSR.js.map +1 -1
  125. package/dist/esm/hooks/useDisableSSR.native.js +2 -9
  126. package/dist/esm/hooks/useDisableSSR.native.js.map +1 -1
  127. package/dist/esm/hooks/useMedia.js +3 -4
  128. package/dist/esm/hooks/useMedia.js.map +1 -1
  129. package/dist/esm/hooks/useMedia.native.js +3 -4
  130. package/dist/esm/hooks/useMedia.native.js.map +1 -1
  131. package/dist/esm/hooks/useTheme.js +2 -6
  132. package/dist/esm/hooks/useTheme.js.map +1 -1
  133. package/dist/esm/hooks/useTheme.native.js +2 -6
  134. package/dist/esm/hooks/useTheme.native.js.map +1 -1
  135. package/dist/esm/views/Theme.js +28 -34
  136. package/dist/esm/views/Theme.js.map +2 -2
  137. package/dist/esm/views/Theme.native.js +28 -34
  138. package/dist/esm/views/Theme.native.js.map +2 -2
  139. package/dist/esm/views/ThemeDebug.js +3 -4
  140. package/dist/esm/views/ThemeDebug.js.map +1 -1
  141. package/package.json +10 -10
  142. package/src/createComponent.tsx +3 -3
  143. package/src/helpers/ThemeManager.tsx +12 -8
  144. package/src/helpers/expandStyles.ts +2 -2
  145. package/src/helpers/expandStylesAndRemoveNullishValues.ts +0 -1
  146. package/src/helpers/getExpandedShorthands.ts +3 -0
  147. package/src/helpers/getSplitStyles.tsx +1 -1
  148. package/src/helpers/getVariantExtras.tsx +1 -2
  149. package/src/helpers/mergeVariants.ts +13 -32
  150. package/src/helpers/normalizeColor.ts +1 -5
  151. package/src/helpers/propMapper.ts +3 -1
  152. package/src/helpers/proxyThemeToParents.ts +5 -8
  153. package/src/helpers/proxyThemeVariables.tsx +1 -3
  154. package/src/helpers/themeable.tsx +5 -3
  155. package/src/helpers/themes.ts +4 -5
  156. package/src/hooks/useDisableSSR.tsx +2 -10
  157. package/src/hooks/useMedia.tsx +4 -5
  158. package/src/hooks/useTheme.tsx +2 -8
  159. package/src/views/Theme.tsx +44 -52
  160. package/src/views/ThemeDebug.tsx +7 -5
  161. package/types/helpers/ThemeManager.d.ts +1 -1
  162. package/types/helpers/ThemeManager.d.ts.map +1 -1
  163. package/types/helpers/expandStylesAndRemoveNullishValues.d.ts.map +1 -1
  164. package/types/helpers/getExpandedShorthands.d.ts +3 -0
  165. package/types/helpers/getExpandedShorthands.d.ts.map +1 -1
  166. package/types/helpers/getVariantExtras.d.ts.map +1 -1
  167. package/types/helpers/mergeVariants.d.ts +1 -1
  168. package/types/helpers/mergeVariants.d.ts.map +1 -1
  169. package/types/helpers/normalizeColor.d.ts.map +1 -1
  170. package/types/helpers/propMapper.d.ts.map +1 -1
  171. package/types/helpers/proxyThemeToParents.d.ts +0 -1
  172. package/types/helpers/proxyThemeToParents.d.ts.map +1 -1
  173. package/types/helpers/proxyThemeVariables.d.ts.map +1 -1
  174. package/types/helpers/themeable.d.ts.map +1 -1
  175. package/types/helpers/themes.d.ts.map +1 -1
  176. package/types/hooks/useDisableSSR.d.ts +1 -2
  177. package/types/hooks/useDisableSSR.d.ts.map +1 -1
  178. package/types/hooks/useMedia.d.ts.map +1 -1
  179. package/types/hooks/useTheme.d.ts.map +1 -1
  180. package/types/views/Theme.d.ts +1 -1
  181. package/types/views/Theme.d.ts.map +1 -1
  182. package/types/views/ThemeDebug.d.ts.map +1 -1
  183. package/src/helpers/createChainedWeakCache.tsx +0 -39
  184. package/src/helpers/createProxy.ts +0 -15
  185. package/src/hooks/getThemeUnwrapped.tsx +0 -5
  186. package/src/hooks/useId.tsx +0 -1
  187. package/src/hooks/useMemoDebug.tsx +0 -18
@@ -1,48 +1,42 @@
1
1
  import { isWeb } from "@tamagui/constants";
2
- import React, {
3
- Children,
4
- cloneElement,
5
- forwardRef,
6
- isValidElement,
7
- useMemo,
8
- useRef
9
- } from "react";
2
+ import React, { Children, cloneElement, forwardRef, isValidElement, useRef } from "react";
10
3
  import { variableToString } from "../createVariable";
11
4
  import { ThemeManagerContext } from "../helpers/ThemeManagerContext";
12
5
  import { useChangeThemeEffect } from "../hooks/useTheme";
13
6
  import { ThemeDebug } from "./ThemeDebug";
14
7
  import { jsx } from "react/jsx-runtime";
15
- const Theme = forwardRef(function(props, ref) {
8
+ const Theme = forwardRef(function({ children, ...props }, ref) {
16
9
  if (props.disable)
17
- return props.children;
18
- const isRoot = !!props._isRoot, disableDirectChildTheme = props["disable-child-theme"], themeState = useChangeThemeEffect(props, isRoot), children = useMemo(() => {
19
- let children2 = disableDirectChildTheme ? Children.map(
20
- props.children,
21
- (child) => cloneElement(child, { "data-disable-theme": !0 })
22
- ) : props.children;
23
- if (ref)
24
- try {
25
- React.Children.only(children2), children2 = cloneElement(children2, { ref });
26
- } catch {
27
- }
28
- return process.env.NODE_ENV === "development" && props.debug === "visualize" && (children2 = /* @__PURE__ */ jsx(ThemeDebug, { themeState, themeProps: props, children: children2 })), children2;
29
- }, [props.children, disableDirectChildTheme]);
30
- return useThemedChildren(themeState, children, props, isRoot);
10
+ return children;
11
+ const isRoot = !!props._isRoot, themeState = useChangeThemeEffect(props, isRoot);
12
+ let finalChildren = props["disable-child-theme"] ? Children.map(
13
+ children,
14
+ (child) => cloneElement(child, { "data-disable-theme": !0 })
15
+ ) : children;
16
+ if (ref)
17
+ try {
18
+ React.Children.only(finalChildren), finalChildren = cloneElement(finalChildren, { ref });
19
+ } catch {
20
+ }
21
+ return process.env.NODE_ENV === "development" && props.debug === "visualize" && (finalChildren = /* @__PURE__ */ jsx(ThemeDebug, { themeState, themeProps: props, children: finalChildren })), getThemedChildren(themeState, finalChildren, props, isRoot);
31
22
  });
32
23
  Theme.displayName = "Theme";
33
24
  Theme.avoidForwardRef = !0;
34
- function useThemedChildren(themeState, children, props, isRoot = !1, avoidWrap = !1) {
35
- const { themeManager, isNewTheme } = themeState, { shallow, forceClassName } = props, hasEverThemed = useRef(!1);
36
- if (isNewTheme && (hasEverThemed.current = !0), !(isNewTheme || props.inverse || hasEverThemed.current || forceClassName || isRoot))
25
+ function getThemedChildren(themeState, children, props, isRoot = !1) {
26
+ const { themeManager, isNewTheme } = themeState;
27
+ if (!themeManager)
28
+ throw "\u274C";
29
+ const { shallow, forceClassName } = props, hasEverThemed = useRef(!1), shouldRenderChildrenWithTheme = isNewTheme || props.inverse || hasEverThemed.current || forceClassName || isRoot;
30
+ if (shouldRenderChildrenWithTheme && (hasEverThemed.current = !0), !shouldRenderChildrenWithTheme)
37
31
  return children;
38
32
  let next = children;
39
- shallow && themeManager && (next = Children.toArray(children).map((child) => isValidElement(child) ? cloneElement(
33
+ shallow && (next = Children.toArray(children).map((child) => isValidElement(child) ? cloneElement(
40
34
  child,
41
35
  void 0,
42
36
  /* @__PURE__ */ jsx(Theme, { name: themeManager.state.parentName, children: child.props.children })
43
37
  ) : child));
44
- const elementsWithContext = themeManager ? /* @__PURE__ */ jsx(ThemeManagerContext.Provider, { value: themeManager, children: next }) : next;
45
- return forceClassName === !1 ? elementsWithContext : isWeb && !avoidWrap ? wrapThemeElements({
38
+ const elementsWithContext = /* @__PURE__ */ jsx(ThemeManagerContext.Provider, { value: themeManager, children: next });
39
+ return forceClassName === !1 ? elementsWithContext : isWeb ? wrapThemeElements({
46
40
  children: elementsWithContext,
47
41
  themeState,
48
42
  forceClassName,
@@ -57,10 +51,7 @@ function wrapThemeElements({
57
51
  }) {
58
52
  if (isRoot && forceClassName === !1)
59
53
  return children;
60
- const inverse = themeState.inversed, requiresExtraWrapper = inverse != null || forceClassName;
61
- if (!themeState.isNewTheme && !requiresExtraWrapper)
62
- return /* @__PURE__ */ jsx("span", { className: "_dsp_contents is_Theme", children });
63
- const { className, style } = getThemeClassNameAndStyle(themeState, isRoot);
54
+ const inverse = themeState.inversed, requiresExtraWrapper = inverse != null || forceClassName, { className, style } = getThemeClassNameAndStyle(themeState, isRoot);
64
55
  let themedChildren = /* @__PURE__ */ jsx("span", { className: `${className} _dsp_contents is_Theme`, style, children });
65
56
  if (requiresExtraWrapper) {
66
57
  const name = themeState.state?.name || "", inverseClassName = name.startsWith("light") ? "t_light is_inversed" : name.startsWith("dark") ? "t_dark is_inversed" : "";
@@ -68,7 +59,10 @@ function wrapThemeElements({
68
59
  }
69
60
  return themedChildren;
70
61
  }
62
+ const emptyObj = {};
71
63
  function getThemeClassNameAndStyle(themeState, isRoot = !1) {
64
+ if (!themeState.isNewTheme)
65
+ return { className: "", style: emptyObj };
72
66
  const themeColor = themeState.state?.theme && themeState.isNewTheme ? variableToString(themeState.state.theme.color) : "", style = themeColor ? {
73
67
  color: themeColor
74
68
  } : void 0;
@@ -77,6 +71,6 @@ function getThemeClassNameAndStyle(themeState, isRoot = !1) {
77
71
  }
78
72
  export {
79
73
  Theme,
80
- useThemedChildren
74
+ getThemedChildren
81
75
  };
82
76
  //# sourceMappingURL=Theme.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/views/Theme.tsx"],
4
- "mappings": "AAAA,SAAS,aAAa;AACtB,OAAO;AAAA,EACL;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AACpC,SAA+B,4BAA4B;AAE3D,SAAS,kBAAkB;AA+BjB;AA7BH,MAAM,QAAQ,WAAW,SAAe,OAAmB,KAAK;AAErE,MAAI,MAAM;AACR,WAAO,MAAM;AAGf,QAAM,SAAS,CAAC,CAAC,MAAM,SACjB,0BAA0B,MAAM,qBAAqB,GACrD,aAAa,qBAAqB,OAAO,MAAM,GAE/C,WAAW,QAAQ,MAAM;AAC7B,QAAIA,YAAW,0BACX,SAAS;AAAA,MAAI,MAAM;AAAA,MAAU,CAAC,UAC5B,aAAa,OAAO,EAAG,sBAAuB,GAAK,CAAC;AAAA,IACtD,IACA,MAAM;AAEV,QAAI;AACF,UAAI;AACF,cAAM,SAAS,KAAKA,SAAQ,GAC5BA,YAAW,aAAaA,WAAU,EAAE,IAAI,CAAC;AAAA,MAC3C,QAAQ;AAAA,MAER;AAGF,WAAI,QAAQ,IAAI,aAAa,iBACvB,MAAM,UAAU,gBAClBA,YACE,oBAAC,cAAW,YAAwB,YAAY,OAC7C,UAAAA,WACH,IAKCA;AAAA,EACT,GAAG,CAAC,MAAM,UAAU,uBAAuB,CAAC;AAE5C,SAAO,kBAAkB,YAAY,UAAU,OAAO,MAAM;AAC9D,CAAC;AACD,MAAM,cAAiB;AACvB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AS,IAAO;AACnF,MAAI,CAAC,WAAW;AACd,WAAO,EAAE,WAAW,IAAI,OAAO,SAAS;AAI1C,QAAM,aACJ,WAAW,OAAO,SAAS,WAAW,aAClC,iBAAiB,WAAW,MAAM,MAAM,KAAK,IAC7C,IAEA,QAAQ,aACV;AAAA,IACE,OAAO;AAAA,EACT,IACA;AAEJ,MAAI,YAAY,WAAW,OAAO,aAAa;AAC/C,SAAI,WACF,YAAY,UAAU,QAAQ,eAAe,EAAE,IAE1C,EAAE,OAAO,UAAU;AAC5B;",
5
+ "names": []
6
6
  }
@@ -1,48 +1,42 @@
1
1
  import { isWeb } from "@tamagui/constants";
2
- import React, {
3
- Children,
4
- cloneElement,
5
- forwardRef,
6
- isValidElement,
7
- useMemo,
8
- useRef
9
- } from "react";
2
+ import React, { Children, cloneElement, forwardRef, isValidElement, useRef } from "react";
10
3
  import { variableToString } from "../createVariable";
11
4
  import { ThemeManagerContext } from "../helpers/ThemeManagerContext";
12
5
  import { useChangeThemeEffect } from "../hooks/useTheme";
13
6
  import { ThemeDebug } from "./ThemeDebug";
14
7
  import { jsx } from "react/jsx-runtime";
15
- const Theme = forwardRef(function(props, ref) {
8
+ const Theme = forwardRef(function({ children, ...props }, ref) {
16
9
  if (props.disable)
17
- return props.children;
18
- const isRoot = !!props._isRoot, disableDirectChildTheme = props["disable-child-theme"], themeState = useChangeThemeEffect(props, isRoot), children = useMemo(() => {
19
- let children2 = disableDirectChildTheme ? Children.map(
20
- props.children,
21
- (child) => cloneElement(child, { "data-disable-theme": !0 })
22
- ) : props.children;
23
- if (ref)
24
- try {
25
- React.Children.only(children2), children2 = cloneElement(children2, { ref });
26
- } catch {
27
- }
28
- return process.env.NODE_ENV === "development" && props.debug === "visualize" && (children2 = /* @__PURE__ */ jsx(ThemeDebug, { themeState, themeProps: props, children: children2 })), children2;
29
- }, [props.children, disableDirectChildTheme]);
30
- return useThemedChildren(themeState, children, props, isRoot);
10
+ return children;
11
+ const isRoot = !!props._isRoot, themeState = useChangeThemeEffect(props, isRoot);
12
+ let finalChildren = props["disable-child-theme"] ? Children.map(
13
+ children,
14
+ (child) => cloneElement(child, { "data-disable-theme": !0 })
15
+ ) : children;
16
+ if (ref)
17
+ try {
18
+ React.Children.only(finalChildren), finalChildren = cloneElement(finalChildren, { ref });
19
+ } catch {
20
+ }
21
+ return process.env.NODE_ENV === "development" && props.debug === "visualize" && (finalChildren = /* @__PURE__ */ jsx(ThemeDebug, { themeState, themeProps: props, children: finalChildren })), getThemedChildren(themeState, finalChildren, props, isRoot);
31
22
  });
32
23
  Theme.displayName = "Theme";
33
24
  Theme.avoidForwardRef = !0;
34
- function useThemedChildren(themeState, children, props, isRoot = !1, avoidWrap = !1) {
35
- const { themeManager, isNewTheme } = themeState, { shallow, forceClassName } = props, hasEverThemed = useRef(!1);
36
- if (isNewTheme && (hasEverThemed.current = !0), !(isNewTheme || props.inverse || hasEverThemed.current || forceClassName || isRoot))
25
+ function getThemedChildren(themeState, children, props, isRoot = !1) {
26
+ const { themeManager, isNewTheme } = themeState;
27
+ if (!themeManager)
28
+ throw "\u274C";
29
+ const { shallow, forceClassName } = props, hasEverThemed = useRef(!1), shouldRenderChildrenWithTheme = isNewTheme || props.inverse || hasEverThemed.current || forceClassName || isRoot;
30
+ if (shouldRenderChildrenWithTheme && (hasEverThemed.current = !0), !shouldRenderChildrenWithTheme)
37
31
  return children;
38
32
  let next = children;
39
- shallow && themeManager && (next = Children.toArray(children).map((child) => isValidElement(child) ? cloneElement(
33
+ shallow && (next = Children.toArray(children).map((child) => isValidElement(child) ? cloneElement(
40
34
  child,
41
35
  void 0,
42
36
  /* @__PURE__ */ jsx(Theme, { name: themeManager.state.parentName, children: child.props.children })
43
37
  ) : child));
44
- const elementsWithContext = themeManager ? /* @__PURE__ */ jsx(ThemeManagerContext.Provider, { value: themeManager, children: next }) : next;
45
- return forceClassName === !1 ? elementsWithContext : isWeb && !avoidWrap ? wrapThemeElements({
38
+ const elementsWithContext = /* @__PURE__ */ jsx(ThemeManagerContext.Provider, { value: themeManager, children: next });
39
+ return forceClassName === !1 ? elementsWithContext : isWeb ? wrapThemeElements({
46
40
  children: elementsWithContext,
47
41
  themeState,
48
42
  forceClassName,
@@ -57,10 +51,7 @@ function wrapThemeElements({
57
51
  }) {
58
52
  if (isRoot && forceClassName === !1)
59
53
  return children;
60
- const inverse = themeState.inversed, requiresExtraWrapper = inverse != null || forceClassName;
61
- if (!themeState.isNewTheme && !requiresExtraWrapper)
62
- return /* @__PURE__ */ jsx("span", { className: "_dsp_contents is_Theme", children });
63
- const { className, style } = getThemeClassNameAndStyle(themeState, isRoot);
54
+ const inverse = themeState.inversed, requiresExtraWrapper = inverse != null || forceClassName, { className, style } = getThemeClassNameAndStyle(themeState, isRoot);
64
55
  let themedChildren = /* @__PURE__ */ jsx("span", { className: `${className} _dsp_contents is_Theme`, style, children });
65
56
  if (requiresExtraWrapper) {
66
57
  const name = themeState.state?.name || "", inverseClassName = name.startsWith("light") ? "t_light is_inversed" : name.startsWith("dark") ? "t_dark is_inversed" : "";
@@ -68,7 +59,10 @@ function wrapThemeElements({
68
59
  }
69
60
  return themedChildren;
70
61
  }
62
+ const emptyObj = {};
71
63
  function getThemeClassNameAndStyle(themeState, isRoot = !1) {
64
+ if (!themeState.isNewTheme)
65
+ return { className: "", style: emptyObj };
72
66
  const themeColor = themeState.state?.theme && themeState.isNewTheme ? variableToString(themeState.state.theme.color) : "", style = themeColor ? {
73
67
  color: themeColor
74
68
  } : void 0;
@@ -77,6 +71,6 @@ function getThemeClassNameAndStyle(themeState, isRoot = !1) {
77
71
  }
78
72
  export {
79
73
  Theme,
80
- useThemedChildren
74
+ getThemedChildren
81
75
  };
82
76
  //# sourceMappingURL=Theme.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/views/Theme.tsx"],
4
- "mappings": "AAAA,SAAS,aAAa;AACtB,OAAO;AAAA,EACL;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAA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SR } from "@tamagui/use-did-finish-ssr";
1
2
  import { useForceUpdate } from "@tamagui/use-force-update";
2
3
  import { useEffect, useId, useState } from "react";
3
4
  import { createPortal } from "react-dom";
@@ -8,10 +9,8 @@ function ThemeDebug({
8
9
  themeProps,
9
10
  children
10
11
  }) {
11
- if (themeProps["disable-child-theme"])
12
- return children;
13
12
  if (process.env.NODE_ENV === "development") {
14
- const [onChangeCount, setOnChangeCount] = useState(0), rerender = useForceUpdate(), id = useId();
13
+ const isHydrated = useDidFinishSSR(), [onChangeCount, setOnChangeCount] = useState(0), rerender = useForceUpdate(), id = useId();
15
14
  return process.env.NODE_ENV === "development" && typeof document < "u" && (node || (node = document.createElement("div"), node.style.height = "200px", node.style.overflowY = "scroll", node.style.position = "fixed", node.style.zIndex = 1e7, node.style.bottom = "30px", node.style.left = "30px", node.style.right = "30px", node.style.display = "flex", node.style.border = "1px solid #888", node.style.flexDirection = "row", node.style.background = "var(--background)", document.body.appendChild(node))), useEffect(() => {
16
15
  themeState.themeManager?.parentManager?.onChangeTheme((name, manager) => {
17
16
  setOnChangeCount((p) => ++p), console.warn(
@@ -22,7 +21,7 @@ function ThemeDebug({
22
21
  }, [themeState.themeManager]), useEffect(() => {
23
22
  const tm = setInterval(rerender, 1e3);
24
23
  return () => clearTimeout(tm);
25
- }, []), /* @__PURE__ */ jsxs(Fragment, { children: [
24
+ }, []), themeProps["disable-child-theme"] || !isHydrated ? children : /* @__PURE__ */ jsxs(Fragment, { children: [
26
25
  createPortal(
27
26
  /* @__PURE__ */ jsxs(
28
27
  "code",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/views/ThemeDebug.tsx"],
4
- "mappings": "AAAA,SAAS,sBAAsB;AAC/B,SAAS,WAAW,OAAO,gBAAgB;AAC3C,SAAS,oBAAoB;AA6DvB,mBA+BE,KA7BE,YAFJ;AAxDN,IAAI;AAEG,SAAS,WAAW;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AACF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"names": []
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/web",
3
- "version": "1.82.0",
3
+ "version": "1.82.2",
4
4
  "source": "src/index.ts",
5
5
  "main": "dist/cjs",
6
6
  "module": "dist/esm",
@@ -27,20 +27,20 @@
27
27
  "reset.css"
28
28
  ],
29
29
  "dependencies": {
30
- "@tamagui/compose-refs": "1.82.0",
31
- "@tamagui/constants": "1.82.0",
32
- "@tamagui/helpers": "1.82.0",
33
- "@tamagui/normalize-css-color": "1.82.0",
34
- "@tamagui/timer": "1.82.0",
35
- "@tamagui/use-did-finish-ssr": "1.82.0",
36
- "@tamagui/use-event": "1.82.0",
37
- "@tamagui/use-force-update": "1.82.0"
30
+ "@tamagui/compose-refs": "1.82.2",
31
+ "@tamagui/constants": "1.82.2",
32
+ "@tamagui/helpers": "1.82.2",
33
+ "@tamagui/normalize-css-color": "1.82.2",
34
+ "@tamagui/timer": "1.82.2",
35
+ "@tamagui/use-did-finish-ssr": "1.82.2",
36
+ "@tamagui/use-event": "1.82.2",
37
+ "@tamagui/use-force-update": "1.82.2"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "react": "*"
41
41
  },
42
42
  "devDependencies": {
43
- "@tamagui/build": "1.82.0",
43
+ "@tamagui/build": "1.82.2",
44
44
  "@testing-library/react": "^14.0.0",
45
45
  "csstype": "^3.0.10",
46
46
  "react": "^18.2.0",
@@ -65,7 +65,7 @@ import {
65
65
  WebOnlyPressEvents,
66
66
  } from './types'
67
67
  import { Slot } from './views/Slot'
68
- import { useThemedChildren } from './views/Theme'
68
+ import { getThemedChildren } from './views/Theme'
69
69
  import { ThemeDebug } from './views/ThemeDebug'
70
70
 
71
71
  // this appears to fix expo / babel not picking this up sometimes? really odd
@@ -1205,9 +1205,9 @@ export function createComponent<
1205
1205
  if (process.env.NODE_ENV === 'development' && time) time`group-context`
1206
1206
 
1207
1207
  // disable theme prop is deterministic so conditional hook ok here
1208
- content = disableThemeProp
1208
+ content = disableTheme
1209
1209
  ? content
1210
- : useThemedChildren(themeState, content, themeStateProps, false)
1210
+ : getThemedChildren(themeState, content, themeStateProps, false)
1211
1211
 
1212
1212
  if (process.env.NODE_ENV === 'development' && time) time`themed-children`
1213
1213
 
@@ -30,7 +30,7 @@ export type ThemeManagerState = {
30
30
  const emptyState: ThemeManagerState = { name: '' }
31
31
 
32
32
  export function getHasThemeUpdatingProps(props: ThemeProps) {
33
- return props.name || props.componentName || props.inverse || props.reset
33
+ return Boolean(props.name || props.componentName || props.inverse || props.reset)
34
34
  }
35
35
 
36
36
  let uid = 0
@@ -228,7 +228,7 @@ function getState(
228
228
 
229
229
  if (
230
230
  process.env.NODE_ENV !== 'production' &&
231
- typeof props.debug === 'string' &&
231
+ props.debug &&
232
232
  typeof window !== 'undefined'
233
233
  ) {
234
234
  console.groupCollapsed('ThemeManager.getState()')
@@ -257,19 +257,22 @@ function getState(
257
257
  }
258
258
 
259
259
  if (componentName && !props.reset) {
260
+ const baseLen = base.length
260
261
  let componentPotentials: string[] = []
261
262
  // components only look for component themes
262
- if (nextName) {
263
- const beforeSeparator = prefix.slice(0, prefix.indexOf(THEME_NAME_SEPARATOR))
263
+ if (nextName && baseLen > 1) {
264
+ const beforeSeparator = base[0]
264
265
  componentPotentials.push(`${beforeSeparator}_${nextName}_${componentName}`)
265
266
  }
266
267
  componentPotentials.push(`${prefix}_${componentName}`)
267
268
  if (nextName) {
268
269
  // do this one and one level up
269
- const prefixLessOne = base.slice(0, i - 1).join(THEME_NAME_SEPARATOR)
270
- if (prefixLessOne) {
271
- const lessSpecific = `${prefixLessOne}_${nextName}_${componentName}`
272
- componentPotentials.unshift(lessSpecific)
270
+ if (i > baseLen) {
271
+ const prefixLessOne = base.slice(0, i - 1).join(THEME_NAME_SEPARATOR)
272
+ if (prefixLessOne) {
273
+ const lessSpecific = `${prefixLessOne}_${nextName}_${componentName}`
274
+ componentPotentials.unshift(lessSpecific)
275
+ }
273
276
  }
274
277
  const moreSpecific = `${prefix}_${nextName}_${componentName}`
275
278
  componentPotentials.unshift(moreSpecific)
@@ -282,6 +285,7 @@ function getState(
282
285
 
283
286
  if (process.env.NODE_ENV !== 'production' && typeof props.debug === 'string') {
284
287
  console.info(' getState ', {
288
+ props,
285
289
  found,
286
290
  potentials,
287
291
  baseManager,
@@ -24,8 +24,8 @@ export function fixStyles(style: Record<string, any>) {
24
24
  // TODO could be native-only
25
25
  // ensure border style set by default to solid
26
26
  for (const key in borderDefaults) {
27
- if (key in style && !style[borderDefaults[key]]) {
28
- style[borderDefaults[key]] = 'solid'
27
+ if (key in style) {
28
+ style[borderDefaults[key]] ||= 'solid'
29
29
  }
30
30
  }
31
31
  }
@@ -1,4 +1,3 @@
1
- import { SplitStyleProps } from '../types'
2
1
  import { expandStyle } from './expandStyle'
3
2
  import { fixStyles } from './expandStyles'
4
3
  import { normalizeValueWithProperty } from './normalizeValueWithProperty'
@@ -1,6 +1,9 @@
1
1
  import { getConfig } from '../config'
2
2
  import { Shorthands } from '../types'
3
3
 
4
+ /**
5
+ * @deprecated use useProps instead
6
+ */
4
7
  export function getExpandedShorthands<A extends Object>(
5
8
  props: A
6
9
  ): Omit<A, keyof Shorthands> {
@@ -284,7 +284,7 @@ export const getSplitStyles: StyleSplitter = (
284
284
  }
285
285
 
286
286
  // keyInit === 'style' is handled in skipProps
287
- if (keyInit in skipProps && !isHOC) {
287
+ if (keyInit in skipProps && !styleProps.noSkip && !isHOC) {
288
288
  if (keyInit === 'group') {
289
289
  if (process.env.TAMAGUI_TARGET === 'web') {
290
290
  // add container style
@@ -1,7 +1,6 @@
1
1
  import { getVariableValue } from '../createVariable'
2
2
  import { GenericFonts, GetStyleState } from '../types'
3
3
  import { LanguageContextType } from '../views/FontLanguage.types'
4
- import { createProxy } from './createProxy'
5
4
 
6
5
  export function getVariantExtras(styleState: GetStyleState) {
7
6
  const { curProps, conf, context, theme } = styleState
@@ -23,7 +22,7 @@ export function getVariantExtras(styleState: GetStyleState) {
23
22
  font: fonts[fontFamily] || fonts[styleState.conf.defaultFont!],
24
23
  // TODO do this in splitstlye
25
24
  // we avoid passing in default props for media queries because that would confuse things like SizableText.size:
26
- props: createProxy(curProps, {
25
+ props: new Proxy(curProps, {
27
26
  // handles shorthands
28
27
  get(target, key) {
29
28
  const shorthand = conf.inverseShorthands[key as any]
@@ -5,51 +5,32 @@ import type { GenericVariantDefinitions } from '../types'
5
5
 
6
6
  export const mergeVariants = (
7
7
  parentVariants: GenericVariantDefinitions,
8
- ourVariants: GenericVariantDefinitions
8
+ ourVariants: GenericVariantDefinitions,
9
+ level = 0
9
10
  ) => {
10
11
  const variants = {}
11
12
 
12
13
  for (const key in ourVariants) {
13
14
  const parentVariant = parentVariants?.[key]
14
15
  const ourVariant = ourVariants[key]
15
-
16
- // do some early checks to avoid bad merges
17
16
  if (!parentVariant || typeof ourVariant === 'function') {
18
17
  variants[key] = ourVariant
19
- continue
20
- }
21
-
22
- // do some early checks to avoid bad merges
23
- if (parentVariant && !ourVariant) {
18
+ } else if (parentVariant && !ourVariant) {
24
19
  variants[key] = parentVariant[key]
25
- continue
26
- }
27
-
28
- variants[key] = {}
29
-
30
- for (const subKey in ourVariant) {
31
- const val = ourVariant[subKey]
32
- const parentVal = parentVariant?.[subKey]
33
- if (typeof val === 'function') {
34
- variants[key][subKey] = val
35
- } else if (!parentVal || typeof parentVal === 'function') {
36
- variants[key][subKey] = val
20
+ } else {
21
+ if (level === 0) {
22
+ variants[key] = mergeVariants(
23
+ parentVariant as Record<string, any>,
24
+ ourVariant as Record<string, any>,
25
+ level + 1
26
+ )
37
27
  } else {
38
- variants[key][subKey] = {
39
- // keep order
40
- ...parentVal,
41
- ...val,
28
+ variants[key] = {
29
+ ...parentVariant,
30
+ ...ourVariant,
42
31
  }
43
32
  }
44
33
  }
45
-
46
- // merge parent variant keys that are superset
47
- if (parentVariant) {
48
- variants[key] = {
49
- ...parentVariant,
50
- ...variants[key],
51
- }
52
- }
53
34
  }
54
35
 
55
36
  return {
@@ -1,14 +1,10 @@
1
- import { isWeb } from '@tamagui/constants'
2
1
  import { normalizeCSSColor, rgba } from '@tamagui/normalize-css-color'
3
2
 
4
3
  export { rgba } from '@tamagui/normalize-css-color'
5
4
 
6
5
  export const normalizeColor = (color?: string | null, opacity?: number) => {
7
6
  if (!color) return
8
- if (color[0] === '$' || (color[0] === 'v' && color.startsWith('var('))) {
9
- return color
10
- }
11
- if (isWeb && opacity === 1) {
7
+ if (color[0] === '$' || color.startsWith('var(')) {
12
8
  return color
13
9
  }
14
10
  const colorProcessed = normalizeCSSColor(color)
@@ -19,6 +19,8 @@ import { isObj } from './isObj'
19
19
  import { pseudoDescriptors } from './pseudoDescriptors'
20
20
 
21
21
  export const propMapper: PropMapper = (key, value, styleStateIn, subPropsIn) => {
22
+ lastFontFamilyToken = null
23
+
22
24
  if (!(process.env.TAMAGUI_TARGET === 'native' && isAndroid)) {
23
25
  // this shouldnt be necessary and handled in the outer loop
24
26
  if (key === 'elevationAndroid') return
@@ -99,7 +101,7 @@ export const propMapper: PropMapper = (key, value, styleStateIn, subPropsIn) =>
99
101
  [key, value],
100
102
  ]
101
103
 
102
- if (key === 'fontFamily') {
104
+ if (key === 'fontFamily' && lastFontFamilyToken) {
103
105
  fontFamilyCache.set(result, lastFontFamilyToken)
104
106
  }
105
107
 
@@ -1,8 +1,7 @@
1
- import { getToken, getTokenObject, getTokens } from '../config'
2
- import { GetThemeUnwrapped } from '../hooks/getThemeUnwrapped'
1
+ import { getTokenObject } from '../config'
3
2
  import { DedupedThemes, ThemeParsed } from '../types'
4
3
 
5
- export const themesRaw: Record<string, ThemeParsed> = {}
4
+ const themesRaw: Record<string, ThemeParsed> = {}
6
5
 
7
6
  // this seems expensive but its necessary to do two loops unless we want to refactor a variety of things again
8
7
  // not *too* much work but not a big cost doing the two loops
@@ -50,9 +49,8 @@ export function proxyThemeToParents(themeName: string, theme: ThemeParsed) {
50
49
  // proxy fallback values to parent theme values
51
50
  return new Proxy(theme, {
52
51
  get(target, key) {
53
- if (key === GetThemeUnwrapped) return theme
54
52
  if (
55
- key == null ||
53
+ !key ||
56
54
  // dont ask me, idk why but on hermes you can see that useTheme()[undefined] passes in STRING undefined to proxy
57
55
  // if someone is crazy enough to use "undefined" as a theme key then this not working is on them
58
56
  key == 'undefined' ||
@@ -63,12 +61,11 @@ export function proxyThemeToParents(themeName: string, theme: ThemeParsed) {
63
61
  // check parents
64
62
  for (let i = numParents - 1; i >= 0; i--) {
65
63
  const parent = themesRaw[parents[i]]
66
- if (!parent) continue
67
- if (Reflect.has(parent, key)) {
64
+ if (parent && Reflect.has(parent, key)) {
68
65
  return Reflect.get(parent, key)
69
66
  }
70
67
  }
71
- return getTokenObject(key as any) ?? Reflect.get(target, key)
68
+ return getTokenObject(key as any)
72
69
  },
73
70
  })
74
71
  }
@@ -1,7 +1,5 @@
1
- import { createProxy } from './createProxy'
2
-
3
1
  export function proxyThemeVariables<A extends Object>(obj: A): A {
4
- return createProxy<A>(obj || {}, {
2
+ return new Proxy<A>(obj || {}, {
5
3
  has(target, key) {
6
4
  return Reflect.has(target, removeStarting$(key))
7
5
  },
@@ -1,4 +1,4 @@
1
- import React, { forwardRef } from 'react'
1
+ import { forwardRef } from 'react'
2
2
 
3
3
  import { StaticConfig, ThemeableProps } from '../types'
4
4
  import { Theme } from '../views/Theme'
@@ -10,8 +10,10 @@ export function themeable<ComponentType extends (props: any) => any>(
10
10
  const withThemeComponent = forwardRef(function WithTheme(props: ThemeableProps, ref) {
11
11
  const { themeInverse, theme, componentName, themeReset, ...rest } = props
12
12
 
13
- // @ts-expect-error its ok
14
- const element = <Component ref={ref} {...rest} data-disable-theme />
13
+ const element = (
14
+ // @ts-expect-error its ok
15
+ <Component ref={ref} {...rest} data-disable-theme />
16
+ )
15
17
 
16
18
  let contents = (
17
19
  <Theme