@tamagui/web 1.74.16 → 1.74.17
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.map +1 -1
- package/dist/cjs/createComponent.native.js.map +1 -1
- package/dist/cjs/helpers/ThemeManager.js +18 -16
- package/dist/cjs/helpers/ThemeManager.js.map +1 -1
- package/dist/cjs/helpers/ThemeManager.native.js +18 -16
- package/dist/cjs/helpers/ThemeManager.native.js.map +1 -1
- package/dist/cjs/helpers/createShallowSetState.js +7 -2
- package/dist/cjs/helpers/createShallowSetState.js.map +1 -1
- package/dist/cjs/helpers/createShallowSetState.native.js +7 -2
- package/dist/cjs/helpers/createShallowSetState.native.js.map +1 -1
- package/dist/cjs/helpers/themeable.js +1 -1
- package/dist/cjs/helpers/themeable.js.map +1 -1
- package/dist/cjs/helpers/themeable.native.js +1 -1
- package/dist/cjs/helpers/themeable.native.js.map +1 -1
- package/dist/cjs/hooks/useTheme.js +18 -11
- package/dist/cjs/hooks/useTheme.js.map +2 -2
- package/dist/cjs/hooks/useTheme.native.js +21 -12
- package/dist/cjs/hooks/useTheme.native.js.map +2 -2
- package/dist/cjs/views/Theme.js +17 -29
- package/dist/cjs/views/Theme.js.map +1 -1
- package/dist/cjs/views/Theme.native.js +17 -29
- package/dist/cjs/views/Theme.native.js.map +1 -1
- package/dist/esm/createComponent.js.map +1 -1
- package/dist/esm/createComponent.native.js.map +1 -1
- package/dist/esm/helpers/ThemeManager.js +17 -16
- package/dist/esm/helpers/ThemeManager.js.map +1 -1
- package/dist/esm/helpers/ThemeManager.native.js +17 -16
- package/dist/esm/helpers/ThemeManager.native.js.map +1 -1
- package/dist/esm/helpers/createShallowSetState.js +6 -2
- package/dist/esm/helpers/createShallowSetState.js.map +1 -1
- package/dist/esm/helpers/createShallowSetState.native.js +6 -2
- package/dist/esm/helpers/createShallowSetState.native.js.map +1 -1
- package/dist/esm/helpers/themeable.js +1 -1
- package/dist/esm/helpers/themeable.js.map +1 -1
- package/dist/esm/helpers/themeable.native.js +1 -1
- package/dist/esm/helpers/themeable.native.js.map +1 -1
- package/dist/esm/hooks/useTheme.js +26 -10
- package/dist/esm/hooks/useTheme.js.map +2 -2
- package/dist/esm/hooks/useTheme.native.js +29 -11
- package/dist/esm/hooks/useTheme.native.js.map +2 -2
- package/dist/esm/views/Theme.js +14 -24
- package/dist/esm/views/Theme.js.map +1 -1
- package/dist/esm/views/Theme.native.js +14 -24
- package/dist/esm/views/Theme.native.js.map +1 -1
- package/package.json +9 -9
- package/src/createComponent.tsx +1 -2
- package/src/helpers/ThemeManager.tsx +22 -22
- package/src/helpers/createShallowSetState.tsx +7 -5
- package/src/helpers/themeable.tsx +1 -1
- package/src/hooks/useTheme.tsx +47 -10
- package/src/views/Theme.tsx +33 -29
- package/types/createComponent.d.ts.map +1 -1
- package/types/helpers/ThemeManager.d.ts +0 -1
- package/types/helpers/ThemeManager.d.ts.map +1 -1
- package/types/helpers/createShallowSetState.d.ts +1 -0
- package/types/helpers/createShallowSetState.d.ts.map +1 -1
- package/types/hooks/useTheme.d.ts +1 -0
- package/types/hooks/useTheme.d.ts.map +1 -1
- package/types/views/Theme.d.ts +0 -12
- package/types/views/Theme.d.ts.map +1 -1
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { isClient, isIos, isServer } from "@tamagui/constants";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
useContext,
|
|
4
|
+
useEffect,
|
|
5
|
+
useLayoutEffect,
|
|
6
|
+
useMemo,
|
|
7
|
+
useRef,
|
|
8
|
+
useState
|
|
9
|
+
} from "react";
|
|
3
10
|
import { getConfig } from "../config";
|
|
4
11
|
import { getVariable } from "../createVariable";
|
|
5
12
|
import { createProxy } from "../helpers/createProxy";
|
|
13
|
+
import { isEqualShallow } from "../helpers/createShallowSetState";
|
|
6
14
|
import {
|
|
7
15
|
ThemeManager,
|
|
8
16
|
getHasThemeUpdatingProps
|
|
@@ -103,8 +111,10 @@ function someParentIsInversed(manager) {
|
|
|
103
111
|
{
|
|
104
112
|
let cur = manager;
|
|
105
113
|
for (; cur; ) {
|
|
106
|
-
if (cur.
|
|
114
|
+
if (!cur.parentManager)
|
|
107
115
|
return !0;
|
|
116
|
+
if (cur.parentManager.state.scheme !== cur.state.scheme)
|
|
117
|
+
return !1;
|
|
108
118
|
cur = cur.parentManager;
|
|
109
119
|
}
|
|
110
120
|
}
|
|
@@ -118,7 +128,7 @@ const activeThemeManagers = /* @__PURE__ */ new Set(), useChangeThemeEffect = (p
|
|
|
118
128
|
state: parentManager?.state,
|
|
119
129
|
themeManager: parentManager
|
|
120
130
|
};
|
|
121
|
-
const [themeState, setThemeState] = useState(createState), { state, mounted, isNewTheme, themeManager } = themeState, isInversingOnMount = !!(!themeState.mounted && props.inverse);
|
|
131
|
+
const [themeState, setThemeState] = useState(createState), { state, mounted, isNewTheme, themeManager, inversed } = themeState, isInversingOnMount = !!(!themeState.mounted && props.inverse);
|
|
122
132
|
function getShouldUpdateTheme(manager = themeManager, nextState, prevState = state, forceShouldChange = !1) {
|
|
123
133
|
const forceUpdate = shouldUpdate?.();
|
|
124
134
|
if (!manager || !forceShouldChange && forceUpdate === !1)
|
|
@@ -133,7 +143,10 @@ const activeThemeManagers = /* @__PURE__ */ new Set(), useChangeThemeEffect = (p
|
|
|
133
143
|
if (!themeManager)
|
|
134
144
|
return;
|
|
135
145
|
if (props.inverse && !mounted) {
|
|
136
|
-
setThemeState(
|
|
146
|
+
setThemeState((prev) => createState({
|
|
147
|
+
...prev,
|
|
148
|
+
mounted: !0
|
|
149
|
+
}));
|
|
137
150
|
return;
|
|
138
151
|
}
|
|
139
152
|
isNewTheme && themeManager && activeThemeManagers.add(themeManager), (isNewTheme || getShouldUpdateTheme(themeManager)) && setThemeState(createState);
|
|
@@ -167,6 +180,7 @@ const activeThemeManagers = /* @__PURE__ */ new Set(), useChangeThemeEffect = (p
|
|
|
167
180
|
}), [themeManager])), isInversingOnMount)
|
|
168
181
|
return {
|
|
169
182
|
isNewTheme: !1,
|
|
183
|
+
inversed: !1,
|
|
170
184
|
themeManager: parentManager,
|
|
171
185
|
state: {
|
|
172
186
|
name: "",
|
|
@@ -177,6 +191,7 @@ const activeThemeManagers = /* @__PURE__ */ new Set(), useChangeThemeEffect = (p
|
|
|
177
191
|
return {
|
|
178
192
|
state,
|
|
179
193
|
isNewTheme,
|
|
194
|
+
inversed,
|
|
180
195
|
themeManager
|
|
181
196
|
};
|
|
182
197
|
function createState(prev, force = !1) {
|
|
@@ -198,15 +213,18 @@ const activeThemeManagers = /* @__PURE__ */ new Set(), useChangeThemeEffect = (p
|
|
|
198
213
|
themeManager2 = getNewThemeManager(), state2 = { ...themeManager2.state };
|
|
199
214
|
}
|
|
200
215
|
const isNewTheme2 = !!(themeManager2 !== parentManager || props.inverse), mounted2 = props.inverse ? isRoot || prev?.mounted : !0;
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
const response = {
|
|
204
|
-
state: state2,
|
|
216
|
+
state2 || (isNewTheme2 ? state2 = themeManager2.state : (state2 = parentManager.state, themeManager2 = parentManager));
|
|
217
|
+
const wasInversed = prev?.inversed, inversed2 = isNewTheme2 && state2.scheme !== parentManager?.state.scheme ? !0 : wasInversed ? !1 : null, response = {
|
|
205
218
|
themeManager: themeManager2,
|
|
206
219
|
isNewTheme: isNewTheme2,
|
|
207
|
-
mounted: mounted2
|
|
208
|
-
|
|
209
|
-
|
|
220
|
+
mounted: mounted2,
|
|
221
|
+
inversed: inversed2
|
|
222
|
+
}, shouldReturnPrev = !force && prev && // isEqualShallow uses the second arg as the keys so this should compare without state first...
|
|
223
|
+
isEqualShallow(prev, response) && // ... and then compare just the state, because we make a new state obj but is likely the same
|
|
224
|
+
isEqualShallow(prev.state, state2);
|
|
225
|
+
if (prev && shouldReturnPrev)
|
|
226
|
+
return prev;
|
|
227
|
+
if (response.state = state2, process.env.NODE_ENV === "development" && props.debug && isClient) {
|
|
210
228
|
console.groupCollapsed(` \u{1F537} ${themeManager2.id} useChangeThemeEffect createState`);
|
|
211
229
|
const parentState = { ...parentManager?.state }, parentId = parentManager?.id, themeManagerState = { ...themeManager2.state };
|
|
212
230
|
console.info({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useTheme.tsx"],
|
|
4
|
-
"mappings": "AAAA,SAAS,UAAU,OAAO,gBAAgB;AAC1C,
|
|
5
|
-
"names": ["_", "themeManager", "state", "isNewTheme", "mounted"]
|
|
4
|
+
"mappings": "AAAA,SAAS,UAAU,OAAO,gBAAgB;AAC1C;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,iBAAiB;AAC1B,SAAmB,mBAAmB;AACtC,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,EAEA;AAAA,OACK;AACP,SAAS,2BAA2B;AASpC,SAAS,yBAAyB;AAYlC,MAAM,aAAa,EAAE,MAAM,KAAK;AAEhC,IAAI;AACJ,SAAS,yBAAyB;AAChC,MAAI;AAAQ,WAAO;AACnB,QAAM,SAAS,UAAU,GACnB,OAAO,OAAO,OAAO,QAAQ,UAAU,OAAO,KAAK,OAAO,MAAM,EAAE,CAAC,GACnE,eAAe,OAAO,OAAO,IAAI;AACvC,kBAAS,gBAAgB,EAAE,OAAO,cAAc,KAAK,CAAC,GAC/C;AACT;AA8BO,MAAM,WAAW,CAAC,QAAoB,eAAe;AAC1D,QAAM,CAAC,GAAG,KAAK,IAAI,kBAAkB,KAAK;AAE1C,SADY,SAAS,uBAAuB;AAE9C,GAEa,oBAAoB,CAC/B,UACwC;AACxC,QAAM,OAAO,OAAiB,CAAC,CAAC,GAE1B,oBAAoB;AAAA,IACxB;AAAA,IACA;AAAA,IACA,KAAK;AAAA,IACJ,WAiBG,SAhBA,MAAM;AACJ,YAAM,OACJ,MAAM,eAAe,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C1B,oBAAoB,EAAE,GAAGA,cAAa,MAAM;AAClD,cAAQ,KAAK;AAAA,QACX;AAAA,QACA;AAAA,QACA;AAAA,QACA,cAAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC,GACD,QAAQ,SAAS;AAAA,IACnB;AAEA,WAAO;AAAA,EACT;AACF;",
|
|
5
|
+
"names": ["_", "themeManager", "state", "isNewTheme", "mounted", "inversed"]
|
|
6
6
|
}
|
package/dist/esm/views/Theme.js
CHANGED
|
@@ -48,15 +48,6 @@ function useThemedChildren(themeState, children, props, isRoot = !1, avoidWrap =
|
|
|
48
48
|
isRoot
|
|
49
49
|
}) : elementsWithContext;
|
|
50
50
|
}
|
|
51
|
-
function getThemeCNStyle(themeState, isRoot = !1) {
|
|
52
|
-
if (!themeState.isNewTheme)
|
|
53
|
-
return;
|
|
54
|
-
const themeColor = themeState.state?.theme && themeState.isNewTheme ? variableToString(themeState.state.theme.color) : "", style = themeColor ? {
|
|
55
|
-
color: themeColor
|
|
56
|
-
} : void 0;
|
|
57
|
-
let className = themeState.state?.className || "";
|
|
58
|
-
return isRoot && (className = className.replace("t_sub_theme", "")), { style, className };
|
|
59
|
-
}
|
|
60
51
|
function wrapThemeElements({
|
|
61
52
|
children,
|
|
62
53
|
themeState,
|
|
@@ -65,27 +56,26 @@ function wrapThemeElements({
|
|
|
65
56
|
}) {
|
|
66
57
|
if (isRoot && forceClassName === !1)
|
|
67
58
|
return children;
|
|
68
|
-
const inverse = themeState.
|
|
69
|
-
if (!themeState.isNewTheme && !
|
|
59
|
+
const inverse = themeState.inversed, requiresExtraWrapper = inverse != null || forceClassName;
|
|
60
|
+
if (!themeState.isNewTheme && !requiresExtraWrapper)
|
|
70
61
|
return /* @__PURE__ */ jsx("span", { className: "_dsp_contents is_Theme", children });
|
|
71
|
-
const { className, style } =
|
|
62
|
+
const { className, style } = getThemeClassNameAndStyle(themeState, isRoot);
|
|
72
63
|
let themedChildren = /* @__PURE__ */ jsx("span", { className: `${className} _dsp_contents is_Theme`, style, children });
|
|
73
|
-
if (
|
|
74
|
-
const name = themeState.state?.name || "";
|
|
75
|
-
themedChildren = /* @__PURE__ */ jsx(
|
|
76
|
-
"span",
|
|
77
|
-
{
|
|
78
|
-
className: `${name.startsWith("light") ? "t_light" : name.startsWith("dark") ? "t_dark" : ""} _dsp_contents ${inverse ? "is_inversed" : ""}`,
|
|
79
|
-
children: themedChildren
|
|
80
|
-
}
|
|
81
|
-
);
|
|
64
|
+
if (requiresExtraWrapper) {
|
|
65
|
+
const name = themeState.state?.name || "", inverseClassName = name.startsWith("light") ? "t_light is_inversed" : name.startsWith("dark") ? "t_dark is_inversed" : "";
|
|
66
|
+
themedChildren = /* @__PURE__ */ jsx("span", { className: `${inverse ? inverseClassName : ""} _dsp_contents`, children: themedChildren });
|
|
82
67
|
}
|
|
83
68
|
return themedChildren;
|
|
84
69
|
}
|
|
70
|
+
function getThemeClassNameAndStyle(themeState, isRoot = !1) {
|
|
71
|
+
const themeColor = themeState.state?.theme && themeState.isNewTheme ? variableToString(themeState.state.theme.color) : "", style = themeColor ? {
|
|
72
|
+
color: themeColor
|
|
73
|
+
} : void 0;
|
|
74
|
+
let className = themeState.state?.className || "";
|
|
75
|
+
return isRoot && (className = className.replace("t_sub_theme", "")), { style, className };
|
|
76
|
+
}
|
|
85
77
|
export {
|
|
86
78
|
Theme,
|
|
87
|
-
|
|
88
|
-
useThemedChildren,
|
|
89
|
-
wrapThemeElements
|
|
79
|
+
useThemedChildren
|
|
90
80
|
};
|
|
91
81
|
//# 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,EAEA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,wBAAwB;A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SAAO;AACT;AAEA,SAAS,0BAA0B,YAAkC,SAAS,IAAO;AAEnF,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
5
|
"names": ["children"]
|
|
6
6
|
}
|
|
@@ -48,15 +48,6 @@ function useThemedChildren(themeState, children, props, isRoot = !1, avoidWrap =
|
|
|
48
48
|
isRoot
|
|
49
49
|
}) : elementsWithContext;
|
|
50
50
|
}
|
|
51
|
-
function getThemeCNStyle(themeState, isRoot = !1) {
|
|
52
|
-
if (!themeState.isNewTheme)
|
|
53
|
-
return;
|
|
54
|
-
const themeColor = themeState.state?.theme && themeState.isNewTheme ? variableToString(themeState.state.theme.color) : "", style = themeColor ? {
|
|
55
|
-
color: themeColor
|
|
56
|
-
} : void 0;
|
|
57
|
-
let className = themeState.state?.className || "";
|
|
58
|
-
return isRoot && (className = className.replace("t_sub_theme", "")), { style, className };
|
|
59
|
-
}
|
|
60
51
|
function wrapThemeElements({
|
|
61
52
|
children,
|
|
62
53
|
themeState,
|
|
@@ -65,27 +56,26 @@ function wrapThemeElements({
|
|
|
65
56
|
}) {
|
|
66
57
|
if (isRoot && forceClassName === !1)
|
|
67
58
|
return children;
|
|
68
|
-
const inverse = themeState.
|
|
69
|
-
if (!themeState.isNewTheme && !
|
|
59
|
+
const inverse = themeState.inversed, requiresExtraWrapper = inverse != null || forceClassName;
|
|
60
|
+
if (!themeState.isNewTheme && !requiresExtraWrapper)
|
|
70
61
|
return /* @__PURE__ */ jsx("span", { className: "_dsp_contents is_Theme", children });
|
|
71
|
-
const { className, style } =
|
|
62
|
+
const { className, style } = getThemeClassNameAndStyle(themeState, isRoot);
|
|
72
63
|
let themedChildren = /* @__PURE__ */ jsx("span", { className: `${className} _dsp_contents is_Theme`, style, children });
|
|
73
|
-
if (
|
|
74
|
-
const name = themeState.state?.name || "";
|
|
75
|
-
themedChildren = /* @__PURE__ */ jsx(
|
|
76
|
-
"span",
|
|
77
|
-
{
|
|
78
|
-
className: `${name.startsWith("light") ? "t_light" : name.startsWith("dark") ? "t_dark" : ""} _dsp_contents ${inverse ? "is_inversed" : ""}`,
|
|
79
|
-
children: themedChildren
|
|
80
|
-
}
|
|
81
|
-
);
|
|
64
|
+
if (requiresExtraWrapper) {
|
|
65
|
+
const name = themeState.state?.name || "", inverseClassName = name.startsWith("light") ? "t_light is_inversed" : name.startsWith("dark") ? "t_dark is_inversed" : "";
|
|
66
|
+
themedChildren = /* @__PURE__ */ jsx("span", { className: `${inverse ? inverseClassName : ""} _dsp_contents`, children: themedChildren });
|
|
82
67
|
}
|
|
83
68
|
return themedChildren;
|
|
84
69
|
}
|
|
70
|
+
function getThemeClassNameAndStyle(themeState, isRoot = !1) {
|
|
71
|
+
const themeColor = themeState.state?.theme && themeState.isNewTheme ? variableToString(themeState.state.theme.color) : "", style = themeColor ? {
|
|
72
|
+
color: themeColor
|
|
73
|
+
} : void 0;
|
|
74
|
+
let className = themeState.state?.className || "";
|
|
75
|
+
return isRoot && (className = className.replace("t_sub_theme", "")), { style, className };
|
|
76
|
+
}
|
|
85
77
|
export {
|
|
86
78
|
Theme,
|
|
87
|
-
|
|
88
|
-
useThemedChildren,
|
|
89
|
-
wrapThemeElements
|
|
79
|
+
useThemedChildren
|
|
90
80
|
};
|
|
91
81
|
//# 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,EAEA;AAAA,EAC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E,kBAChD,0BACH;AAAA,EAEJ;AAEA,SAAO;AACT;AAEA,SAAS,0BAA0B,YAAkC,SAAS,IAAO;AAEnF,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
5
|
"names": ["children"]
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/web",
|
|
3
|
-
"version": "1.74.
|
|
3
|
+
"version": "1.74.17",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -27,19 +27,19 @@
|
|
|
27
27
|
"reset.css"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@tamagui/compose-refs": "1.74.
|
|
31
|
-
"@tamagui/constants": "1.74.
|
|
32
|
-
"@tamagui/helpers": "1.74.
|
|
33
|
-
"@tamagui/normalize-css-color": "1.74.
|
|
34
|
-
"@tamagui/timer": "1.74.
|
|
35
|
-
"@tamagui/use-did-finish-ssr": "1.74.
|
|
36
|
-
"@tamagui/use-force-update": "1.74.
|
|
30
|
+
"@tamagui/compose-refs": "1.74.17",
|
|
31
|
+
"@tamagui/constants": "1.74.17",
|
|
32
|
+
"@tamagui/helpers": "1.74.17",
|
|
33
|
+
"@tamagui/normalize-css-color": "1.74.17",
|
|
34
|
+
"@tamagui/timer": "1.74.17",
|
|
35
|
+
"@tamagui/use-did-finish-ssr": "1.74.17",
|
|
36
|
+
"@tamagui/use-force-update": "1.74.17"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"react": "*"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@tamagui/build": "1.74.
|
|
42
|
+
"@tamagui/build": "1.74.17",
|
|
43
43
|
"@testing-library/react": "^14.0.0",
|
|
44
44
|
"csstype": "^3.0.10",
|
|
45
45
|
"react": "^18.2.0",
|
package/src/createComponent.tsx
CHANGED
|
@@ -56,14 +56,13 @@ import {
|
|
|
56
56
|
TamaguiElement,
|
|
57
57
|
TamaguiInternalConfig,
|
|
58
58
|
TextProps,
|
|
59
|
-
ThemeProps,
|
|
60
59
|
UseAnimationHook,
|
|
61
60
|
UseAnimationProps,
|
|
62
61
|
UseThemeWithStateProps,
|
|
63
62
|
WebOnlyPressEvents,
|
|
64
63
|
} from './types'
|
|
65
64
|
import { Slot } from './views/Slot'
|
|
66
|
-
import {
|
|
65
|
+
import { useThemedChildren } from './views/Theme'
|
|
67
66
|
import { ThemeDebug } from './views/ThemeDebug'
|
|
68
67
|
|
|
69
68
|
// this appears to fix expo / babel not picking this up sometimes? really odd
|
|
@@ -24,7 +24,6 @@ export type ThemeManagerState = {
|
|
|
24
24
|
theme?: ThemeParsed | null
|
|
25
25
|
isComponent?: boolean
|
|
26
26
|
className?: string
|
|
27
|
-
inverse?: boolean
|
|
28
27
|
scheme?: ColorScheme
|
|
29
28
|
}
|
|
30
29
|
|
|
@@ -91,7 +90,7 @@ export class ThemeManager {
|
|
|
91
90
|
updateState(nextState: ThemeManagerState, shouldNotify = true) {
|
|
92
91
|
this.state = nextState
|
|
93
92
|
this._allKeys = null
|
|
94
|
-
if (process.env.NODE_ENV
|
|
93
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
95
94
|
this['_numChangeEventsSent'] ??= 0
|
|
96
95
|
this['_numChangeEventsSent']++
|
|
97
96
|
}
|
|
@@ -149,7 +148,7 @@ export class ThemeManager {
|
|
|
149
148
|
}
|
|
150
149
|
|
|
151
150
|
onChangeTheme(cb: ThemeListener, debugId?: number) {
|
|
152
|
-
if (process.env.NODE_ENV
|
|
151
|
+
if (process.env.NODE_ENV !== 'production' && debugId) {
|
|
153
152
|
// @ts-ignore
|
|
154
153
|
this._listeningIds ??= new Set()
|
|
155
154
|
// @ts-ignore
|
|
@@ -183,10 +182,7 @@ function getState(
|
|
|
183
182
|
const [allManagers, componentManagers] = getManagers(manager)
|
|
184
183
|
|
|
185
184
|
const isDirectParentAComponentTheme = !!manager?.state.isComponent
|
|
186
|
-
const startIndex =
|
|
187
|
-
allManagers.findIndex((x) => !x?.state.isComponent) +
|
|
188
|
-
(props.reset && !isDirectParentAComponentTheme ? 1 : 0)
|
|
189
|
-
|
|
185
|
+
const startIndex = props.reset && !isDirectParentAComponentTheme ? 1 : 0
|
|
190
186
|
let baseManager = allManagers[startIndex]
|
|
191
187
|
let parentManager = allManagers[startIndex + 1]
|
|
192
188
|
|
|
@@ -197,13 +193,20 @@ function getState(
|
|
|
197
193
|
return null
|
|
198
194
|
}
|
|
199
195
|
|
|
196
|
+
const { componentName } = props
|
|
200
197
|
let result: ThemeManagerState | null = null
|
|
201
198
|
|
|
202
|
-
|
|
199
|
+
let baseName = baseManager?.state.name || ''
|
|
200
|
+
|
|
201
|
+
if (baseManager?.state.isComponent) {
|
|
202
|
+
// remove component name
|
|
203
|
+
baseName = baseName.replace(/_[A-Z][a-z]+/, '')
|
|
204
|
+
}
|
|
205
|
+
|
|
203
206
|
const nextName = props.reset ? baseName : props.name || ''
|
|
204
207
|
|
|
205
208
|
const allComponentThemes = componentManagers.map((x) => x?.state.name || '')
|
|
206
|
-
if (
|
|
209
|
+
if (isDirectParentAComponentTheme) {
|
|
207
210
|
allComponentThemes.shift()
|
|
208
211
|
}
|
|
209
212
|
|
|
@@ -215,7 +218,7 @@ function getState(
|
|
|
215
218
|
? max // component name only don't search upwards
|
|
216
219
|
: 0
|
|
217
220
|
|
|
218
|
-
if (process.env.NODE_ENV
|
|
221
|
+
if (process.env.NODE_ENV !== 'production' && typeof props.debug === 'string') {
|
|
219
222
|
console.groupCollapsed('ThemeManager.getState()')
|
|
220
223
|
console.info({ props, baseName, base, min, max })
|
|
221
224
|
}
|
|
@@ -241,22 +244,22 @@ function getState(
|
|
|
241
244
|
}
|
|
242
245
|
}
|
|
243
246
|
|
|
244
|
-
if (props.
|
|
247
|
+
if (componentName && !props.reset) {
|
|
245
248
|
let componentPotentials: string[] = []
|
|
246
249
|
// components only look for component themes
|
|
247
250
|
if (nextName) {
|
|
248
251
|
const beforeSeparator = prefix.slice(0, prefix.indexOf(THEME_NAME_SEPARATOR))
|
|
249
|
-
componentPotentials.push(`${beforeSeparator}_${nextName}_${
|
|
252
|
+
componentPotentials.push(`${beforeSeparator}_${nextName}_${componentName}`)
|
|
250
253
|
}
|
|
251
|
-
componentPotentials.push(`${prefix}_${
|
|
254
|
+
componentPotentials.push(`${prefix}_${componentName}`)
|
|
252
255
|
if (nextName) {
|
|
253
256
|
// do this one and one level up
|
|
254
257
|
const prefixLessOne = base.slice(0, i - 1).join(THEME_NAME_SEPARATOR)
|
|
255
258
|
if (prefixLessOne) {
|
|
256
|
-
const lessSpecific = `${prefixLessOne}_${nextName}_${
|
|
259
|
+
const lessSpecific = `${prefixLessOne}_${nextName}_${componentName}`
|
|
257
260
|
componentPotentials.unshift(lessSpecific)
|
|
258
261
|
}
|
|
259
|
-
const moreSpecific = `${prefix}_${nextName}_${
|
|
262
|
+
const moreSpecific = `${prefix}_${nextName}_${componentName}`
|
|
260
263
|
componentPotentials.unshift(moreSpecific)
|
|
261
264
|
}
|
|
262
265
|
potentials = [...componentPotentials, ...potentials, ...allComponentThemes]
|
|
@@ -264,8 +267,8 @@ function getState(
|
|
|
264
267
|
|
|
265
268
|
const found = potentials.find((t) => t in themes)
|
|
266
269
|
|
|
267
|
-
if (process.env.NODE_ENV
|
|
268
|
-
console.info(' - ', { found, potentials, baseManager })
|
|
270
|
+
if (process.env.NODE_ENV !== 'production' && typeof props.debug === 'string') {
|
|
271
|
+
console.info(' - ', { found, potentials, baseManager, nextName, baseName, prefix })
|
|
269
272
|
}
|
|
270
273
|
|
|
271
274
|
if (found) {
|
|
@@ -283,17 +286,14 @@ function getState(
|
|
|
283
286
|
}`
|
|
284
287
|
|
|
285
288
|
// because its a new theme the baseManager is now the parent
|
|
286
|
-
const parentState = baseManager?.state
|
|
287
|
-
const parentScheme = parentState?.scheme
|
|
289
|
+
const parentState = (baseManager || parentManager)?.state
|
|
288
290
|
const parentName = parentState?.name
|
|
289
|
-
const inverse = parentScheme && scheme !== parentScheme
|
|
290
291
|
|
|
291
292
|
result = {
|
|
292
293
|
name: found,
|
|
293
294
|
parentName,
|
|
294
295
|
theme: themes[found],
|
|
295
296
|
className,
|
|
296
|
-
inverse,
|
|
297
297
|
isComponent,
|
|
298
298
|
scheme,
|
|
299
299
|
}
|
|
@@ -303,7 +303,7 @@ function getState(
|
|
|
303
303
|
}
|
|
304
304
|
|
|
305
305
|
if (
|
|
306
|
-
process.env.NODE_ENV
|
|
306
|
+
process.env.NODE_ENV !== 'production' &&
|
|
307
307
|
typeof props.debug === 'string' &&
|
|
308
308
|
typeof window !== 'undefined'
|
|
309
309
|
) {
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
|
|
3
|
-
import { TamaguiComponentState } from '../types'
|
|
4
|
-
|
|
5
3
|
export function createShallowSetState<State extends Object>(
|
|
6
4
|
setter: React.Dispatch<React.SetStateAction<State>>
|
|
7
5
|
) {
|
|
8
6
|
return (next: Partial<State>) => setter((prev) => mergeIfNotShallowEqual(prev, next))
|
|
9
7
|
}
|
|
10
8
|
|
|
11
|
-
export function mergeIfNotShallowEqual(prev, next) {
|
|
9
|
+
export function mergeIfNotShallowEqual(prev: any, next: any) {
|
|
10
|
+
return isEqualShallow(prev, next) ? prev : { ...prev, ...next }
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function isEqualShallow(prev, next) {
|
|
12
14
|
for (const key in next) {
|
|
13
15
|
if (prev[key] !== next[key]) {
|
|
14
|
-
return
|
|
16
|
+
return false
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
|
-
return
|
|
19
|
+
return true
|
|
18
20
|
}
|
|
@@ -16,7 +16,7 @@ export function themeable<ComponentType extends (props: any) => any>(
|
|
|
16
16
|
let contents = (
|
|
17
17
|
<Theme
|
|
18
18
|
componentName={componentName || staticConfig?.componentName}
|
|
19
|
-
name={theme
|
|
19
|
+
name={theme}
|
|
20
20
|
disable-child-theme
|
|
21
21
|
debug={props.debug}
|
|
22
22
|
inverse={themeInverse}
|
package/src/hooks/useTheme.tsx
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import { isClient, isIos, isServer } from '@tamagui/constants'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
useContext,
|
|
4
|
+
useEffect,
|
|
5
|
+
useId,
|
|
6
|
+
useLayoutEffect,
|
|
7
|
+
useMemo,
|
|
8
|
+
useRef,
|
|
9
|
+
useState,
|
|
10
|
+
} from 'react'
|
|
3
11
|
|
|
4
12
|
import { getConfig } from '../config'
|
|
5
13
|
import { Variable, getVariable } from '../createVariable'
|
|
6
14
|
import { createProxy } from '../helpers/createProxy'
|
|
15
|
+
import { isEqualShallow } from '../helpers/createShallowSetState'
|
|
7
16
|
import {
|
|
8
17
|
ThemeManager,
|
|
9
18
|
ThemeManagerState,
|
|
@@ -24,6 +33,9 @@ export type ChangedThemeResponse = {
|
|
|
24
33
|
state?: ThemeManagerState
|
|
25
34
|
themeManager?: ThemeManager | null
|
|
26
35
|
isNewTheme: boolean
|
|
36
|
+
// null = never been inversed
|
|
37
|
+
// false = was inversed, now not
|
|
38
|
+
inversed?: null | boolean
|
|
27
39
|
mounted?: boolean
|
|
28
40
|
}
|
|
29
41
|
|
|
@@ -244,7 +256,8 @@ function someParentIsInversed(manager?: ThemeManager) {
|
|
|
244
256
|
if (process.env.TAMAGUI_TARGET === 'native') {
|
|
245
257
|
let cur: ThemeManager | null | undefined = manager
|
|
246
258
|
while (cur) {
|
|
247
|
-
if (cur.
|
|
259
|
+
if (!cur.parentManager) return true
|
|
260
|
+
if (cur.parentManager.state.scheme !== cur.state.scheme) return false
|
|
248
261
|
cur = cur.parentManager
|
|
249
262
|
}
|
|
250
263
|
}
|
|
@@ -285,7 +298,8 @@ export const useChangeThemeEffect = (
|
|
|
285
298
|
// }
|
|
286
299
|
|
|
287
300
|
const [themeState, setThemeState] = useState<ChangedThemeResponse>(createState)
|
|
288
|
-
|
|
301
|
+
|
|
302
|
+
const { state, mounted, isNewTheme, themeManager, inversed } = themeState
|
|
289
303
|
const isInversingOnMount = Boolean(!themeState.mounted && props.inverse)
|
|
290
304
|
|
|
291
305
|
function getShouldUpdateTheme(
|
|
@@ -302,6 +316,7 @@ export const useChangeThemeEffect = (
|
|
|
302
316
|
if (forceUpdate !== true && !manager.getStateShouldChange(next, prevState)) {
|
|
303
317
|
return
|
|
304
318
|
}
|
|
319
|
+
|
|
305
320
|
return next
|
|
306
321
|
}
|
|
307
322
|
|
|
@@ -314,7 +329,12 @@ export const useChangeThemeEffect = (
|
|
|
314
329
|
// could be done through fancy selectors like how we do prefers-media
|
|
315
330
|
// but may be a bit of explosion of selectors
|
|
316
331
|
if (props.inverse && !mounted) {
|
|
317
|
-
setThemeState(
|
|
332
|
+
setThemeState((prev) => {
|
|
333
|
+
return createState({
|
|
334
|
+
...prev,
|
|
335
|
+
mounted: true,
|
|
336
|
+
})
|
|
337
|
+
})
|
|
318
338
|
return
|
|
319
339
|
}
|
|
320
340
|
|
|
@@ -390,6 +410,7 @@ export const useChangeThemeEffect = (
|
|
|
390
410
|
if (isInversingOnMount) {
|
|
391
411
|
return {
|
|
392
412
|
isNewTheme: false,
|
|
413
|
+
inversed: false,
|
|
393
414
|
themeManager: parentManager,
|
|
394
415
|
state: {
|
|
395
416
|
name: '',
|
|
@@ -402,6 +423,7 @@ export const useChangeThemeEffect = (
|
|
|
402
423
|
return {
|
|
403
424
|
state,
|
|
404
425
|
isNewTheme,
|
|
426
|
+
inversed,
|
|
405
427
|
themeManager,
|
|
406
428
|
}
|
|
407
429
|
|
|
@@ -474,16 +496,31 @@ export const useChangeThemeEffect = (
|
|
|
474
496
|
}
|
|
475
497
|
}
|
|
476
498
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
499
|
+
const wasInversed = prev?.inversed
|
|
500
|
+
const nextInversed = isNewTheme && state.scheme !== parentManager?.state.scheme
|
|
501
|
+
const inversed = nextInversed ? true : wasInversed ? false : null
|
|
480
502
|
|
|
481
|
-
const response = {
|
|
482
|
-
state,
|
|
503
|
+
const response: ChangedThemeResponse = {
|
|
483
504
|
themeManager,
|
|
484
505
|
isNewTheme,
|
|
485
506
|
mounted,
|
|
486
|
-
|
|
507
|
+
inversed,
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
const shouldReturnPrev =
|
|
511
|
+
!force &&
|
|
512
|
+
prev &&
|
|
513
|
+
// isEqualShallow uses the second arg as the keys so this should compare without state first...
|
|
514
|
+
isEqualShallow(prev, response) &&
|
|
515
|
+
// ... and then compare just the state, because we make a new state obj but is likely the same
|
|
516
|
+
isEqualShallow(prev.state, state)
|
|
517
|
+
|
|
518
|
+
if (prev && shouldReturnPrev) {
|
|
519
|
+
return prev
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// after we compare equal we set the state
|
|
523
|
+
response.state = state
|
|
487
524
|
|
|
488
525
|
if (process.env.NODE_ENV === 'development' && props['debug'] && isClient) {
|
|
489
526
|
console.groupCollapsed(` 🔷 ${themeManager.id} useChangeThemeEffect createState`)
|