@tamagui/web 1.82.1 → 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.
- package/dist/cjs/createComponent.js +2 -2
- package/dist/cjs/createComponent.js.map +1 -1
- package/dist/cjs/createComponent.native.js +2 -2
- package/dist/cjs/createComponent.native.js.map +1 -1
- package/dist/cjs/helpers/ThemeManager.js +12 -8
- package/dist/cjs/helpers/ThemeManager.js.map +1 -1
- package/dist/cjs/helpers/ThemeManager.native.js +12 -8
- package/dist/cjs/helpers/ThemeManager.native.js.map +1 -1
- package/dist/cjs/helpers/getSplitStyles.js +1 -1
- package/dist/cjs/helpers/getSplitStyles.js.map +1 -1
- package/dist/cjs/helpers/getSplitStyles.native.js +1 -1
- package/dist/cjs/helpers/getSplitStyles.native.js.map +1 -1
- package/dist/cjs/helpers/themeable.js +4 -1
- package/dist/cjs/helpers/themeable.js.map +1 -1
- package/dist/cjs/helpers/themeable.native.js +4 -1
- package/dist/cjs/helpers/themeable.native.js.map +1 -1
- package/dist/cjs/hooks/useTheme.js +1 -1
- package/dist/cjs/hooks/useTheme.js.map +1 -1
- package/dist/cjs/hooks/useTheme.native.js +1 -1
- package/dist/cjs/hooks/useTheme.native.js.map +1 -1
- package/dist/cjs/views/Theme.js +28 -27
- package/dist/cjs/views/Theme.js.map +2 -2
- package/dist/cjs/views/Theme.native.js +28 -27
- package/dist/cjs/views/Theme.native.js.map +2 -2
- package/dist/cjs/views/ThemeDebug.js +3 -5
- package/dist/cjs/views/ThemeDebug.js.map +1 -1
- package/dist/esm/createComponent.js +3 -3
- package/dist/esm/createComponent.js.map +1 -1
- package/dist/esm/createComponent.native.js +3 -3
- package/dist/esm/createComponent.native.js.map +1 -1
- package/dist/esm/helpers/ThemeManager.js +12 -8
- package/dist/esm/helpers/ThemeManager.js.map +1 -1
- package/dist/esm/helpers/ThemeManager.native.js +12 -8
- package/dist/esm/helpers/ThemeManager.native.js.map +1 -1
- package/dist/esm/helpers/getSplitStyles.js +1 -1
- package/dist/esm/helpers/getSplitStyles.js.map +1 -1
- package/dist/esm/helpers/getSplitStyles.native.js +1 -1
- package/dist/esm/helpers/getSplitStyles.native.js.map +1 -1
- package/dist/esm/helpers/themeable.js +4 -1
- package/dist/esm/helpers/themeable.js.map +1 -1
- package/dist/esm/helpers/themeable.native.js +4 -1
- package/dist/esm/helpers/themeable.native.js.map +1 -1
- package/dist/esm/hooks/useTheme.js +1 -1
- package/dist/esm/hooks/useTheme.js.map +1 -1
- package/dist/esm/hooks/useTheme.native.js +1 -1
- package/dist/esm/hooks/useTheme.native.js.map +1 -1
- package/dist/esm/views/Theme.js +28 -34
- package/dist/esm/views/Theme.js.map +2 -2
- package/dist/esm/views/Theme.native.js +28 -34
- package/dist/esm/views/Theme.native.js.map +2 -2
- package/dist/esm/views/ThemeDebug.js +3 -4
- package/dist/esm/views/ThemeDebug.js.map +1 -1
- package/package.json +10 -10
- package/src/createComponent.tsx +3 -3
- package/src/helpers/ThemeManager.tsx +12 -8
- package/src/helpers/getSplitStyles.tsx +1 -1
- package/src/helpers/themeable.tsx +4 -2
- package/src/hooks/useTheme.tsx +1 -1
- package/src/views/Theme.tsx +44 -52
- package/src/views/ThemeDebug.tsx +7 -5
- package/types/helpers/ThemeManager.d.ts +1 -1
- package/types/helpers/ThemeManager.d.ts.map +1 -1
- package/types/helpers/themeable.d.ts.map +1 -1
- package/types/views/Theme.d.ts +1 -1
- package/types/views/Theme.d.ts.map +1 -1
- package/types/views/ThemeDebug.d.ts.map +1 -1
package/dist/esm/views/Theme.js
CHANGED
|
@@ -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
|
|
18
|
-
const isRoot = !!props._isRoot,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
|
35
|
-
const { themeManager, isNewTheme } = themeState
|
|
36
|
-
if (
|
|
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 &&
|
|
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 =
|
|
45
|
-
return forceClassName === !1 ? elementsWithContext : isWeb
|
|
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
|
-
|
|
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
|
|
5
|
-
"names": [
|
|
4
|
+
"mappings": "AAAA,SAAS,aAAa;AACtB,OAAO,SAAS,UAAU,cAAc,YAAY,gBAAgB,cAAc;AAElF,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AACpC,SAA+B,4BAA4B;AAE3D,SAAS,kBAAkB;AA8BnB;AA5BD,MAAM,QAAQ,WAAW,SAAe,EAAE,UAAU,GAAG,MAAM,GAAe,KAAK;AAEtF,MAAI,MAAM;AACR,WAAO;AAGT,QAAM,SAAS,CAAC,CAAC,MAAM,SACjB,aAAa,qBAAqB,OAAO,MAAM;AAGrD,MAAI,gBAF4B,MAAM,qBAAqB,IAGvD,SAAS;AAAA,IAAI;AAAA,IAAU,CAAC,UACtB,aAAa,OAAO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E,WAAW,MAAM,IAAI,0BAA0B,YAAY,MAAM;AAEzE,MAAI,iBACF,oBAAC,UAAK,WAAW,GAAG,SAAS,2BAA2B,OACrD,UACH;AAIF,MAAI,sBAAsB;AACxB,UAAM,OAAO,WAAW,OAAO,QAAQ,IACjC,mBAAmB,KAAK,WAAW,OAAO,IAC5C,wBACA,KAAK,WAAW,MAAM,IACtB,uBACA;AACJ,qBACE,oBAAC,UAAK,WAAW,GAAG,UAAU,mBAAmB,EAAE,kBAChD,0BACH;AAAA,EAEJ;AAEA,SAAO;AACT;AAEA,MAAM,WAAW,CAAC;AAElB,SAAS,0BAA0B,YAAkC,SAAS,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
|
|
18
|
-
const isRoot = !!props._isRoot,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
|
35
|
-
const { themeManager, isNewTheme } = themeState
|
|
36
|
-
if (
|
|
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 &&
|
|
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 =
|
|
45
|
-
return forceClassName === !1 ? elementsWithContext : isWeb
|
|
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
|
-
|
|
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
|
|
5
|
-
"names": [
|
|
4
|
+
"mappings": "AAAA,SAAS,aAAa;AACtB,OAAO,SAAS,UAAU,cAAc,YAAY,gBAAgB,cAAc;AAElF,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AACpC,SAA+B,4BAA4B;AAE3D,SAAS,kBAAkB;AA8BnB;AA5BD,MAAM,QAAQ,WAAW,SAAe,EAAE,UAAU,GAAG,MAAM,GAAe,KAAK;AAEtF,MAAI,MAAM;AACR,WAAO;AAGT,QAAM,SAAS,CAAC,CAAC,MAAM,SACjB,aAAa,qBAAqB,OAAO,MAAM;AAGrD,MAAI,gBAF4B,MAAM,qBAAqB,IAGvD,SAAS;AAAA,IAAI;AAAA,IAAU,CAAC,UACtB,aAAa,OAAO,EAAG,sBAAuB,GAAK,CAAC;AAAA,EACtD,IACA;AAEJ,MAAI;AACF,QAAI;AACF,YAAM,SAAS,KAAK,aAAa,GACjC,gBAAgB,aAAa,eAAe,EAAE,IAAI,CAAC;AAAA,IACrD,QAAQ;AAAA,IAER;AAGF,SAAI,QAAQ,IAAI,aAAa,iBACvB,M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A,KAAK,WAAW,MAAM,IACtB,uBACA;AACJ,qBACE,oBAAC,UAAK,WAAW,GAAG,UAAU,mBAAmB,EAAE,kBAChD,0BACH;AAAA,EAEJ;AAEA,SAAO;AACT;AAEA,MAAM,WAAW,CAAC;AAElB,SAAS,0BAA0B,YAAkC,SAAS,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,3 +1,4 @@
|
|
|
1
|
+
import { useDidFinishSSR } 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": "
|
|
4
|
+
"mappings": "AACA,SAAS,uBAAuB;AAChC,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,GAIG;AACD,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,UAAM,aAAa,gBAAgB,GAC7B,CAAC,eAAe,gBAAgB,IAAI,SAAS,CAAC,GAC9C,WAAW,eAAe,GAC1B,KAAK,MAAM;AAoCjB,WAlCI,QAAQ,IAAI,aAAa,iBAAiB,OAAO,WAAa,QAC3D,SACH,OAAO,SAAS,cAAc,KAAK,GACnC,KAAK,MAAM,SAAS,SACpB,KAAK,MAAM,YAAY,UACvB,KAAK,MAAM,WAAW,SACtB,KAAK,MAAM,SAAS,KACpB,KAAK,MAAM,SAAS,QACpB,KAAK,MAAM,OAAO,QACl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A,oBAAC,SAAI,OAAO,EAAE,OAAO,MAAM,GAAI,cAAG;AAAA,MAEjC;AAAA,OACH;AAAA,EAEJ;AACA,SAAO;AACT;AAEA,WAAW,cAAiB;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/web",
|
|
3
|
-
"version": "1.82.
|
|
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.
|
|
31
|
-
"@tamagui/constants": "1.82.
|
|
32
|
-
"@tamagui/helpers": "1.82.
|
|
33
|
-
"@tamagui/normalize-css-color": "1.82.
|
|
34
|
-
"@tamagui/timer": "1.82.
|
|
35
|
-
"@tamagui/use-did-finish-ssr": "1.82.
|
|
36
|
-
"@tamagui/use-event": "1.82.
|
|
37
|
-
"@tamagui/use-force-update": "1.82.
|
|
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.
|
|
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",
|
package/src/createComponent.tsx
CHANGED
|
@@ -65,7 +65,7 @@ import {
|
|
|
65
65
|
WebOnlyPressEvents,
|
|
66
66
|
} from './types'
|
|
67
67
|
import { Slot } from './views/Slot'
|
|
68
|
-
import {
|
|
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 =
|
|
1208
|
+
content = disableTheme
|
|
1209
1209
|
? content
|
|
1210
|
-
:
|
|
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
|
-
|
|
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 =
|
|
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
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
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,
|
|
@@ -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
|
|
@@ -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
|
-
|
|
14
|
-
|
|
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
|
package/src/hooks/useTheme.tsx
CHANGED
|
@@ -493,7 +493,7 @@ export const useChangeThemeEffect = (
|
|
|
493
493
|
|
|
494
494
|
const wasInversed = prev?.inversed
|
|
495
495
|
const nextInversed = isNewTheme && state.scheme !== parentManager?.state.scheme
|
|
496
|
-
const inversed = nextInversed ? true : wasInversed ? false : null
|
|
496
|
+
const inversed = nextInversed ? true : wasInversed != null ? false : null
|
|
497
497
|
|
|
498
498
|
const response: ChangedThemeResponse = {
|
|
499
499
|
themeManager,
|
package/src/views/Theme.tsx
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
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
|
|
|
11
4
|
import { variableToString } from '../createVariable'
|
|
12
5
|
import { ThemeManagerContext } from '../helpers/ThemeManagerContext'
|
|
@@ -14,66 +7,65 @@ import { ChangedThemeResponse, useChangeThemeEffect } from '../hooks/useTheme'
|
|
|
14
7
|
import type { ThemeProps } from '../types'
|
|
15
8
|
import { ThemeDebug } from './ThemeDebug'
|
|
16
9
|
|
|
17
|
-
export const Theme = forwardRef(function Theme(props: ThemeProps, ref) {
|
|
10
|
+
export const Theme = forwardRef(function Theme({ children, ...props }: ThemeProps, ref) {
|
|
18
11
|
// @ts-expect-error only for internal views
|
|
19
12
|
if (props.disable) {
|
|
20
|
-
return
|
|
13
|
+
return children
|
|
21
14
|
}
|
|
22
15
|
|
|
23
16
|
const isRoot = !!props['_isRoot']
|
|
24
|
-
const disableDirectChildTheme = props['disable-child-theme']
|
|
25
17
|
const themeState = useChangeThemeEffect(props, isRoot)
|
|
18
|
+
const disableDirectChildTheme = props['disable-child-theme']
|
|
26
19
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
//ok
|
|
40
|
-
}
|
|
20
|
+
let finalChildren = disableDirectChildTheme
|
|
21
|
+
? Children.map(children, (child) =>
|
|
22
|
+
cloneElement(child, { ['data-disable-theme']: true })
|
|
23
|
+
)
|
|
24
|
+
: children
|
|
25
|
+
|
|
26
|
+
if (ref) {
|
|
27
|
+
try {
|
|
28
|
+
React.Children.only(finalChildren)
|
|
29
|
+
finalChildren = cloneElement(finalChildren, { ref })
|
|
30
|
+
} catch {
|
|
31
|
+
//ok
|
|
41
32
|
}
|
|
33
|
+
}
|
|
42
34
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
35
|
+
if (process.env.NODE_ENV === 'development') {
|
|
36
|
+
if (props.debug === 'visualize') {
|
|
37
|
+
finalChildren = (
|
|
38
|
+
<ThemeDebug themeState={themeState} themeProps={props}>
|
|
39
|
+
{finalChildren}
|
|
40
|
+
</ThemeDebug>
|
|
41
|
+
)
|
|
51
42
|
}
|
|
43
|
+
}
|
|
52
44
|
|
|
53
|
-
|
|
54
|
-
}, [props.children, disableDirectChildTheme])
|
|
55
|
-
|
|
56
|
-
return useThemedChildren(themeState, children, props, isRoot)
|
|
45
|
+
return getThemedChildren(themeState, finalChildren, props, isRoot)
|
|
57
46
|
})
|
|
58
47
|
Theme['displayName'] = 'Theme'
|
|
59
48
|
Theme['avoidForwardRef'] = true
|
|
60
49
|
|
|
61
|
-
export function
|
|
50
|
+
export function getThemedChildren(
|
|
62
51
|
themeState: ChangedThemeResponse,
|
|
63
52
|
children: any,
|
|
64
53
|
props: ThemeProps,
|
|
65
|
-
isRoot = false
|
|
66
|
-
avoidWrap = false
|
|
54
|
+
isRoot = false
|
|
67
55
|
) {
|
|
68
56
|
const { themeManager, isNewTheme } = themeState
|
|
57
|
+
|
|
58
|
+
// its always there.. should fix type
|
|
59
|
+
if (!themeManager) throw `❌`
|
|
60
|
+
|
|
69
61
|
const { shallow, forceClassName } = props
|
|
70
62
|
const hasEverThemed = useRef(false)
|
|
71
|
-
if (isNewTheme) {
|
|
72
|
-
hasEverThemed.current = true
|
|
73
|
-
}
|
|
74
63
|
|
|
75
64
|
const shouldRenderChildrenWithTheme =
|
|
76
65
|
isNewTheme || props.inverse || hasEverThemed.current || forceClassName || isRoot
|
|
66
|
+
if (shouldRenderChildrenWithTheme) {
|
|
67
|
+
hasEverThemed.current = true
|
|
68
|
+
}
|
|
77
69
|
|
|
78
70
|
if (!shouldRenderChildrenWithTheme) {
|
|
79
71
|
return children
|
|
@@ -82,7 +74,7 @@ export function useThemedChildren(
|
|
|
82
74
|
let next = children
|
|
83
75
|
|
|
84
76
|
// each children of these children wont get the theme
|
|
85
|
-
if (shallow
|
|
77
|
+
if (shallow) {
|
|
86
78
|
next = Children.toArray(children).map((child) => {
|
|
87
79
|
return isValidElement(child)
|
|
88
80
|
? cloneElement(
|
|
@@ -96,19 +88,17 @@ export function useThemedChildren(
|
|
|
96
88
|
})
|
|
97
89
|
}
|
|
98
90
|
|
|
99
|
-
const elementsWithContext =
|
|
91
|
+
const elementsWithContext = (
|
|
100
92
|
<ThemeManagerContext.Provider value={themeManager}>
|
|
101
93
|
{next}
|
|
102
94
|
</ThemeManagerContext.Provider>
|
|
103
|
-
) : (
|
|
104
|
-
next
|
|
105
95
|
)
|
|
106
96
|
|
|
107
97
|
if (forceClassName === false) {
|
|
108
98
|
return elementsWithContext
|
|
109
99
|
}
|
|
110
100
|
|
|
111
|
-
if (isWeb
|
|
101
|
+
if (isWeb) {
|
|
112
102
|
return wrapThemeElements({
|
|
113
103
|
children: elementsWithContext,
|
|
114
104
|
themeState,
|
|
@@ -138,10 +128,6 @@ function wrapThemeElements({
|
|
|
138
128
|
const inverse = themeState.inversed
|
|
139
129
|
const requiresExtraWrapper = inverse != null || forceClassName
|
|
140
130
|
|
|
141
|
-
if (!themeState.isNewTheme && !requiresExtraWrapper) {
|
|
142
|
-
return <span className="_dsp_contents is_Theme">{children}</span>
|
|
143
|
-
}
|
|
144
|
-
|
|
145
131
|
const { className, style } = getThemeClassNameAndStyle(themeState, isRoot)
|
|
146
132
|
|
|
147
133
|
let themedChildren = (
|
|
@@ -168,7 +154,13 @@ function wrapThemeElements({
|
|
|
168
154
|
return themedChildren
|
|
169
155
|
}
|
|
170
156
|
|
|
157
|
+
const emptyObj = {}
|
|
158
|
+
|
|
171
159
|
function getThemeClassNameAndStyle(themeState: ChangedThemeResponse, isRoot = false) {
|
|
160
|
+
if (!themeState.isNewTheme) {
|
|
161
|
+
return { className: '', style: emptyObj }
|
|
162
|
+
}
|
|
163
|
+
|
|
172
164
|
// in order to provide currentColor, set color by default
|
|
173
165
|
const themeColor =
|
|
174
166
|
themeState.state?.theme && themeState.isNewTheme
|
package/src/views/ThemeDebug.tsx
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { isServer } from '@tamagui/constants'
|
|
2
|
+
import { useDidFinishSSR } from '@tamagui/use-did-finish-ssr'
|
|
1
3
|
import { useForceUpdate } from '@tamagui/use-force-update'
|
|
2
4
|
import { useEffect, useId, useState } from 'react'
|
|
3
5
|
import { createPortal } from 'react-dom'
|
|
@@ -16,12 +18,8 @@ export function ThemeDebug({
|
|
|
16
18
|
themeProps: ThemeProps
|
|
17
19
|
children: any
|
|
18
20
|
}) {
|
|
19
|
-
// disabled
|
|
20
|
-
if (themeProps['disable-child-theme']) {
|
|
21
|
-
return children
|
|
22
|
-
}
|
|
23
|
-
|
|
24
21
|
if (process.env.NODE_ENV === 'development') {
|
|
22
|
+
const isHydrated = useDidFinishSSR()
|
|
25
23
|
const [onChangeCount, setOnChangeCount] = useState(0)
|
|
26
24
|
const rerender = useForceUpdate()
|
|
27
25
|
const id = useId()
|
|
@@ -60,6 +58,10 @@ export function ThemeDebug({
|
|
|
60
58
|
return () => clearTimeout(tm as any)
|
|
61
59
|
}, [])
|
|
62
60
|
|
|
61
|
+
if (themeProps['disable-child-theme'] || !isHydrated) {
|
|
62
|
+
return children
|
|
63
|
+
}
|
|
64
|
+
|
|
63
65
|
return (
|
|
64
66
|
<>
|
|
65
67
|
{createPortal(
|
|
@@ -15,7 +15,7 @@ export type ThemeManagerState = {
|
|
|
15
15
|
className?: string;
|
|
16
16
|
scheme?: ColorScheme;
|
|
17
17
|
};
|
|
18
|
-
export declare function getHasThemeUpdatingProps(props: ThemeProps):
|
|
18
|
+
export declare function getHasThemeUpdatingProps(props: ThemeProps): boolean;
|
|
19
19
|
export declare class ThemeManager {
|
|
20
20
|
props: ThemeProps;
|
|
21
21
|
id: number;
|