@tamagui/core 1.0.1-beta.226 → 1.0.1-beta.228
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/constants/platform.js +65 -0
- package/dist/cjs/constants/platform.js.map +7 -0
- package/dist/cjs/constants/platform.native.js +62 -0
- package/dist/cjs/constants/platform.native.js.map +7 -0
- package/dist/cjs/createComponent.js +22 -38
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/createVariable.js +1 -1
- package/dist/cjs/createVariable.js.map +2 -2
- package/dist/cjs/helpers/ThemeManager.js +19 -12
- package/dist/cjs/helpers/ThemeManager.js.map +3 -3
- package/dist/cjs/helpers/ThemeManager.test.js +16 -0
- package/dist/cjs/helpers/ThemeManager.test.js.map +2 -2
- package/dist/cjs/helpers/assignNativePropsToWeb.js +188 -0
- package/dist/cjs/helpers/assignNativePropsToWeb.js.map +7 -0
- package/dist/cjs/helpers/assignNativePropsToWeb.native.js +30 -0
- package/dist/cjs/helpers/assignNativePropsToWeb.native.js.map +7 -0
- package/dist/cjs/helpers/calc.js +71 -0
- package/dist/cjs/helpers/calc.js.map +7 -0
- package/dist/cjs/helpers/createPropMapper.js +3 -5
- package/dist/cjs/helpers/createPropMapper.js.map +2 -2
- package/dist/cjs/helpers/createShallowUpdate.js +44 -0
- package/dist/cjs/helpers/createShallowUpdate.js.map +7 -0
- package/dist/cjs/helpers/getFont.js +66 -0
- package/dist/cjs/helpers/getFont.js.map +7 -0
- package/dist/cjs/helpers/getSplitStyles.js +85 -67
- package/dist/cjs/helpers/getSplitStyles.js.map +3 -3
- package/dist/cjs/helpers/getStackSize.js +46 -0
- package/dist/cjs/helpers/getStackSize.js.map +7 -0
- package/dist/cjs/helpers/normalizeColor.js +2 -2
- package/dist/cjs/helpers/normalizeColor.js.map +2 -2
- package/dist/cjs/helpers/startTransition.js +36 -0
- package/dist/cjs/helpers/startTransition.js.map +7 -0
- package/dist/cjs/helpers/timer.js +35 -0
- package/dist/cjs/helpers/timer.js.map +7 -0
- package/dist/cjs/helpers/validate.js +2 -0
- package/dist/cjs/helpers/validate.js.map +7 -0
- package/dist/cjs/hooks/useConstant.js +39 -0
- package/dist/cjs/hooks/useConstant.js.map +7 -0
- package/dist/cjs/hooks/useIsMounted.js +40 -0
- package/dist/cjs/hooks/useIsMounted.js.map +7 -0
- package/dist/cjs/hooks/useIsSSR.js +46 -0
- package/dist/cjs/hooks/useIsSSR.js.map +7 -0
- package/dist/cjs/hooks/usePressable.js +36 -0
- package/dist/cjs/hooks/usePressable.js.map +7 -0
- package/dist/cjs/hooks/useTheme.js +24 -20
- package/dist/cjs/hooks/useTheme.js.map +3 -3
- package/dist/cjs/hooks/useUnmountEffect.js +32 -0
- package/dist/cjs/hooks/useUnmountEffect.js.map +7 -0
- package/dist/cjs/injectStyles.js +40 -0
- package/dist/cjs/injectStyles.js.map +7 -0
- package/dist/cjs/styled.js +0 -10
- package/dist/cjs/styled.js.map +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/views/Theme.js +5 -9
- package/dist/cjs/views/Theme.js.map +2 -2
- package/dist/cjs/views/ThemeInverse.js +18 -25
- package/dist/cjs/views/ThemeInverse.js.map +2 -2
- package/dist/cjs/views/ThemeReset.js +12 -12
- package/dist/cjs/views/ThemeReset.js.map +2 -2
- package/dist/esm/constants/platform.js +30 -0
- package/dist/esm/constants/platform.js.map +7 -0
- package/dist/esm/constants/platform.native.js +28 -0
- package/dist/esm/constants/platform.native.js.map +7 -0
- package/dist/esm/createComponent.js +22 -38
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/createVariable.js +1 -1
- package/dist/esm/createVariable.js.map +2 -2
- package/dist/esm/helpers/ThemeManager.js +14 -7
- package/dist/esm/helpers/ThemeManager.js.map +2 -2
- package/dist/esm/helpers/ThemeManager.test.js +16 -0
- package/dist/esm/helpers/ThemeManager.test.js.map +2 -2
- package/dist/esm/helpers/assignNativePropsToWeb.js +164 -0
- package/dist/esm/helpers/assignNativePropsToWeb.js.map +7 -0
- package/dist/esm/helpers/assignNativePropsToWeb.native.js +6 -0
- package/dist/esm/helpers/assignNativePropsToWeb.native.js.map +7 -0
- package/dist/esm/helpers/calc.js +47 -0
- package/dist/esm/helpers/calc.js.map +7 -0
- package/dist/esm/helpers/createPropMapper.js +3 -5
- package/dist/esm/helpers/createPropMapper.js.map +2 -2
- package/dist/esm/helpers/createShallowUpdate.js +20 -0
- package/dist/esm/helpers/createShallowUpdate.js.map +7 -0
- package/dist/esm/helpers/getFont.js +42 -0
- package/dist/esm/helpers/getFont.js.map +7 -0
- package/dist/esm/helpers/getSplitStyles.js +85 -67
- package/dist/esm/helpers/getSplitStyles.js.map +3 -3
- package/dist/esm/helpers/getStackSize.js +22 -0
- package/dist/esm/helpers/getStackSize.js.map +7 -0
- package/dist/esm/helpers/normalizeColor.js +1 -1
- package/dist/esm/helpers/normalizeColor.js.map +1 -1
- package/dist/esm/helpers/startTransition.js +6 -0
- package/dist/esm/helpers/startTransition.js.map +7 -0
- package/dist/esm/helpers/timer.js +11 -0
- package/dist/esm/helpers/timer.js.map +7 -0
- package/dist/esm/helpers/validate.js +1 -0
- package/dist/esm/helpers/validate.js.map +7 -0
- package/dist/esm/hooks/useConstant.js +15 -0
- package/dist/esm/hooks/useConstant.js.map +7 -0
- package/dist/esm/hooks/useIsMounted.js +16 -0
- package/dist/esm/hooks/useIsMounted.js.map +7 -0
- package/dist/esm/hooks/useIsSSR.js +22 -0
- package/dist/esm/hooks/useIsSSR.js.map +7 -0
- package/dist/esm/hooks/usePressable.js +12 -0
- package/dist/esm/hooks/usePressable.js.map +7 -0
- package/dist/esm/hooks/useTheme.js +24 -20
- package/dist/esm/hooks/useTheme.js.map +3 -3
- package/dist/esm/hooks/useUnmountEffect.js +8 -0
- package/dist/esm/hooks/useUnmountEffect.js.map +7 -0
- package/dist/esm/injectStyles.js +16 -0
- package/dist/esm/injectStyles.js.map +7 -0
- package/dist/esm/styled.js +0 -10
- package/dist/esm/styled.js.map +2 -2
- package/dist/esm/views/Theme.js +5 -9
- package/dist/esm/views/Theme.js.map +2 -2
- package/dist/esm/views/ThemeInverse.js +17 -23
- package/dist/esm/views/ThemeInverse.js.map +2 -2
- package/dist/esm/views/ThemeReset.js +12 -12
- package/dist/esm/views/ThemeReset.js.map +2 -2
- package/package.json +13 -13
- package/src/createComponent.tsx +22 -81
- package/src/createVariable.ts +1 -1
- package/src/helpers/ThemeManager.test.tsx +17 -0
- package/src/helpers/ThemeManager.tsx +29 -14
- package/src/helpers/createPropMapper.ts +4 -5
- package/src/helpers/getSplitStyles.tsx +130 -91
- package/src/helpers/normalizeColor.ts +1 -1
- package/src/helpers/timer.ts +9 -0
- package/src/hooks/useTheme.tsx +29 -22
- package/src/styled.tsx +0 -12
- package/src/types.tsx +2 -5
- package/src/views/Theme.tsx +5 -9
- package/types/helpers/ThemeManager.d.ts +2 -2
- package/types/helpers/getSplitStyles.d.ts +22 -6
- package/types/helpers/timer.d.ts +2 -0
- package/types/hooks/useTheme.d.ts +0 -1
- package/types/types.d.ts +1 -5
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useMemo, useRef } from "react";
|
|
2
|
+
function useConstant(fn) {
|
|
3
|
+
if (typeof document === "undefined") {
|
|
4
|
+
return useMemo(() => fn(), []);
|
|
5
|
+
}
|
|
6
|
+
const ref = useRef();
|
|
7
|
+
if (!ref.current) {
|
|
8
|
+
ref.current = { v: fn() };
|
|
9
|
+
}
|
|
10
|
+
return ref.current.v;
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
useConstant
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=useConstant.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hooks/useConstant.tsx"],
|
|
4
|
+
"sourcesContent": ["import { useMemo, useRef } from 'react'\n\ntype ResultBox<T> = { v: T }\n\nexport function useConstant<T>(fn: () => T): T {\n // RSC compat\n if (typeof document === 'undefined') {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useMemo(() => fn(), [])\n }\n\n const ref = useRef<ResultBox<T>>()\n\n if (!ref.current) {\n ref.current = { v: fn() }\n }\n\n return ref.current.v\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,SAAS,cAAc;AAIzB,SAAS,YAAe,IAAgB;AAE7C,MAAI,OAAO,aAAa,aAAa;AAEnC,WAAO,QAAQ,MAAM,GAAG,GAAG,CAAC,CAAC;AAAA,EAC/B;AAEA,QAAM,MAAM,OAAqB;AAEjC,MAAI,CAAC,IAAI,SAAS;AAChB,QAAI,UAAU,EAAE,GAAG,GAAG,EAAE;AAAA,EAC1B;AAEA,SAAO,IAAI,QAAQ;AACrB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useRef } from "react";
|
|
2
|
+
import { useIsomorphicLayoutEffect } from "../constants/platform";
|
|
3
|
+
function useIsMounted() {
|
|
4
|
+
const isMounted = useRef(false);
|
|
5
|
+
useIsomorphicLayoutEffect(() => {
|
|
6
|
+
isMounted.current = true;
|
|
7
|
+
return () => {
|
|
8
|
+
isMounted.current = false;
|
|
9
|
+
};
|
|
10
|
+
}, []);
|
|
11
|
+
return isMounted;
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
useIsMounted
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=useIsMounted.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hooks/useIsMounted.ts"],
|
|
4
|
+
"sourcesContent": ["import { useRef } from 'react'\n\nimport { useIsomorphicLayoutEffect } from '../constants/platform'\n\nexport function useIsMounted() {\n const isMounted = useRef(false)\n\n useIsomorphicLayoutEffect(() => {\n isMounted.current = true\n\n return () => {\n isMounted.current = false\n }\n }, [])\n\n return isMounted\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,cAAc;AAEvB,SAAS,iCAAiC;AAEnC,SAAS,eAAe;AAC7B,QAAM,YAAY,OAAO,KAAK;AAE9B,4BAA0B,MAAM;AAC9B,cAAU,UAAU;AAEpB,WAAO,MAAM;AACX,gBAAU,UAAU;AAAA,IACtB;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { isServer, isWeb, useIsomorphicLayoutEffect } from "../constants/platform";
|
|
3
|
+
import { startTransition } from "../helpers/startTransition";
|
|
4
|
+
const useIsSSR = (props) => {
|
|
5
|
+
const [val, setVal] = useState(true);
|
|
6
|
+
useIsomorphicLayoutEffect(() => {
|
|
7
|
+
if (isWeb && !isServer) {
|
|
8
|
+
if (props == null ? void 0 : props.immediate) {
|
|
9
|
+
setVal(false);
|
|
10
|
+
} else {
|
|
11
|
+
startTransition(() => {
|
|
12
|
+
setVal(false);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}, []);
|
|
17
|
+
return val;
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
useIsSSR
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=useIsSSR.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hooks/useIsSSR.tsx"],
|
|
4
|
+
"sourcesContent": ["import { useState } from 'react'\n\nimport { isServer, isWeb, useIsomorphicLayoutEffect } from '../constants/platform'\nimport { startTransition } from '../helpers/startTransition'\n\n// because any change before first useEffect causes hydration / mismatch issues\n\nexport const useIsSSR = (props?: { immediate?: boolean }) => {\n const [val, setVal] = useState(true)\n\n useIsomorphicLayoutEffect(() => {\n if (isWeb && !isServer) {\n // could also have a global tamagui `config.immediateSSRTransition`\n if (props?.immediate) {\n setVal(false)\n } else {\n startTransition(() => {\n setVal(false)\n })\n }\n }\n }, [])\n\n return val\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,gBAAgB;AAEzB,SAAS,UAAU,OAAO,iCAAiC;AAC3D,SAAS,uBAAuB;AAIzB,MAAM,WAAW,CAAC,UAAoC;AAC3D,QAAM,CAAC,KAAK,MAAM,IAAI,SAAS,IAAI;AAEnC,4BAA0B,MAAM;AAC9B,QAAI,SAAS,CAAC,UAAU;AAEtB,UAAI,+BAAO,WAAW;AACpB,eAAO,KAAK;AAAA,MACd,OAAO;AACL,wBAAgB,MAAM;AACpB,iBAAO,KAAK;AAAA,QACd,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var _a, _b;
|
|
2
|
+
import { Pressable } from "react-native";
|
|
3
|
+
const getPressable = (_b = (_a = Pressable) == null ? void 0 : _a["type"]) == null ? void 0 : _b["render"];
|
|
4
|
+
const usePressable = (props) => {
|
|
5
|
+
const out = getPressable(props);
|
|
6
|
+
const { children, style, ...pressableProps } = out.props;
|
|
7
|
+
return [pressableProps, style];
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
usePressable
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=usePressable.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hooks/usePressable.tsx"],
|
|
4
|
+
"sourcesContent": ["import { Pressable, PressableProps } from 'react-native'\n\nconst getPressable = Pressable?.['type']?.['render']\n\nexport const usePressable = (props: PressableProps) => {\n const out = getPressable(props)\n const { children, style, ...pressableProps } = out.props\n return [pressableProps, style] as const\n}\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,SAAS,iBAAiC;AAE1C,MAAM,gBAAe,4CAAY,YAAZ,mBAAsB;AAEpC,MAAM,eAAe,CAAC,UAA0B;AACrD,QAAM,MAAM,aAAa,KAAK;AAC9B,QAAM,EAAE,UAAU,UAAU,eAAe,IAAI,IAAI;AACnD,SAAO,CAAC,gBAAgB,KAAK;AAC/B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -7,17 +7,20 @@ import { ThemeManager, hasNoThemeUpdatingProps } from "../helpers/ThemeManager";
|
|
|
7
7
|
import { ThemeManagerContext } from "../helpers/ThemeManagerContext";
|
|
8
8
|
import { GetThemeUnwrapped } from "./getThemeUnwrapped";
|
|
9
9
|
const emptyProps = { name: null };
|
|
10
|
+
function getDefaultThemeProxied() {
|
|
11
|
+
const config = getConfig();
|
|
12
|
+
const name = Object.keys(config.themes)[0];
|
|
13
|
+
return getThemeProxied({
|
|
14
|
+
theme: config.themes[name],
|
|
15
|
+
name
|
|
16
|
+
});
|
|
17
|
+
}
|
|
10
18
|
const useTheme = (props = emptyProps) => {
|
|
11
19
|
var _a;
|
|
12
20
|
if (isRSC) {
|
|
13
|
-
|
|
14
|
-
const name2 = Object.keys(config.themes)[0];
|
|
15
|
-
return getThemeProxied({
|
|
16
|
-
theme: config.themes[name2],
|
|
17
|
-
name: name2
|
|
18
|
-
});
|
|
21
|
+
return getDefaultThemeProxied();
|
|
19
22
|
}
|
|
20
|
-
const { name, theme,
|
|
23
|
+
const { name, theme, themeManager, className, isNewTheme } = useChangeThemeEffect(props);
|
|
21
24
|
if (process.env.NODE_ENV === "development") {
|
|
22
25
|
if (isWeb && isNewTheme && className === ((_a = themeManager == null ? void 0 : themeManager.parentManager) == null ? void 0 : _a.state.className)) {
|
|
23
26
|
console.error(`Should always change, duplicating ThemeMananger bug`, themeManager);
|
|
@@ -36,7 +39,7 @@ const useTheme = (props = emptyProps) => {
|
|
|
36
39
|
if (process.env.NODE_ENV === "development") {
|
|
37
40
|
console.warn("No theme found", name, props, themeManager);
|
|
38
41
|
}
|
|
39
|
-
return
|
|
42
|
+
return getDefaultThemeProxied();
|
|
40
43
|
}
|
|
41
44
|
return useMemo(() => {
|
|
42
45
|
return getThemeProxied({
|
|
@@ -93,25 +96,23 @@ const getThemeManager = (theme) => theme == null ? void 0 : theme[GetThemeManage
|
|
|
93
96
|
const getThemeIsNewTheme = (theme) => theme == null ? void 0 : theme[GetIsNewTheme];
|
|
94
97
|
const activeThemeManagers = /* @__PURE__ */ new Set();
|
|
95
98
|
const useChangeThemeEffect = (props, root = false) => {
|
|
96
|
-
const parentManager = useContext(ThemeManagerContext);
|
|
97
|
-
const config = getConfig();
|
|
98
|
-
const { debug } = props;
|
|
99
|
-
const disable = props.disable;
|
|
100
|
-
const { themes } = config;
|
|
101
99
|
if (isRSC) {
|
|
102
100
|
return {
|
|
103
101
|
...createState().state,
|
|
104
|
-
themes,
|
|
105
102
|
themeManager: null
|
|
106
103
|
};
|
|
107
104
|
}
|
|
105
|
+
const parentManager = useContext(ThemeManagerContext);
|
|
106
|
+
const {
|
|
107
|
+
debug,
|
|
108
|
+
disable
|
|
109
|
+
} = props;
|
|
108
110
|
if (disable) {
|
|
109
111
|
if (!parentManager)
|
|
110
112
|
throw new Error(`Disable topmost`);
|
|
111
113
|
return {
|
|
112
114
|
...parentManager.state,
|
|
113
115
|
isNewTheme: false,
|
|
114
|
-
themes,
|
|
115
116
|
themeManager: parentManager
|
|
116
117
|
};
|
|
117
118
|
}
|
|
@@ -147,22 +148,22 @@ const useChangeThemeEffect = (props, root = false) => {
|
|
|
147
148
|
console.log("useTheme.render isNewTheme", isNewTheme, props, themeManager.state.name, parentManager == null ? void 0 : parentManager.state.name);
|
|
148
149
|
if (hasNoThemeUpdatingProps(props)) {
|
|
149
150
|
if (!parentManager)
|
|
150
|
-
throw
|
|
151
|
+
throw `impossible`;
|
|
152
|
+
if (process.env.NODE_ENV === "development" && props.debug === "verbose")
|
|
153
|
+
console.log("useTheme no updating props", parentManager.state);
|
|
151
154
|
return {
|
|
152
155
|
...parentManager.state,
|
|
153
|
-
themes,
|
|
154
156
|
themeManager: parentManager,
|
|
155
157
|
isNewTheme: false
|
|
156
158
|
};
|
|
157
159
|
}
|
|
158
160
|
updateState();
|
|
159
161
|
if (!mounted && !parentManager) {
|
|
160
|
-
throw
|
|
162
|
+
throw `impossible`;
|
|
161
163
|
}
|
|
162
164
|
return {
|
|
163
165
|
...state,
|
|
164
166
|
isNewTheme,
|
|
165
|
-
themes,
|
|
166
167
|
themeManager,
|
|
167
168
|
...!mounted && parentManager && {
|
|
168
169
|
...parentManager.state,
|
|
@@ -184,8 +185,11 @@ const useChangeThemeEffect = (props, root = false) => {
|
|
|
184
185
|
};
|
|
185
186
|
}
|
|
186
187
|
function updateState() {
|
|
187
|
-
if (themeManager.getStateIfChanged(props, state, parentManager)) {
|
|
188
|
+
if (themeManager.getStateIfChanged(props, isNewTheme ? state : null, parentManager)) {
|
|
188
189
|
setThemeState(createState);
|
|
190
|
+
} else {
|
|
191
|
+
if (process.env.NODE_ENV === "development" && props.debug === "verbose")
|
|
192
|
+
console.log(`useTheme updateState didn't change`);
|
|
189
193
|
}
|
|
190
194
|
}
|
|
191
195
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useTheme.tsx"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable no-console */\nimport { isClient, isRSC, isServer, isWeb } from '@tamagui/constants'\nimport { useContext, useLayoutEffect, useMemo, useState } from 'react'\n\nimport { getConfig } from '../config'\nimport { isDevTools } from '../constants/isDevTools'\nimport { createProxy } from '../helpers/createProxy'\nimport { ThemeManager, ThemeManagerState, hasNoThemeUpdatingProps } from '../helpers/ThemeManager'\nimport { ThemeManagerContext } from '../helpers/ThemeManagerContext'\nimport { ThemeParsed, ThemeProps } from '../types'\nimport { GetThemeUnwrapped } from './getThemeUnwrapped'\n\nexport type ChangedThemeResponse = {\n
|
|
5
|
-
"mappings": "AACA,SAAS,UAAU,OAAO,UAAU,aAAa;AACjD,SAAS,YAAY,iBAAiB,SAAS,gBAAgB;AAE/D,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,cAAiC,+BAA+B;AACzE,SAAS,2BAA2B;AAEpC,SAAS,yBAAyB;
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["/* eslint-disable no-console */\nimport { isClient, isRSC, isServer, isWeb } from '@tamagui/constants'\nimport { useContext, useLayoutEffect, useMemo, useState } from 'react'\n\nimport { getConfig } from '../config'\nimport { isDevTools } from '../constants/isDevTools'\nimport { createProxy } from '../helpers/createProxy'\nimport { ThemeManager, ThemeManagerState, hasNoThemeUpdatingProps } from '../helpers/ThemeManager'\nimport { ThemeManagerContext } from '../helpers/ThemeManagerContext'\nimport { ThemeParsed, ThemeProps } from '../types'\nimport { GetThemeUnwrapped } from './getThemeUnwrapped'\n\nexport type ChangedThemeResponse = {\n themeManager: ThemeManager | null\n name: string\n isNewTheme?: boolean\n theme?: ThemeParsed | null\n className?: string\n}\n\nconst emptyProps = { name: null }\n\nfunction getDefaultThemeProxied() {\n const config = getConfig()\n const name = Object.keys(config.themes)[0]\n return getThemeProxied({\n theme: config.themes[name],\n name,\n })\n}\n\nexport const useTheme = (props: ThemeProps = emptyProps): ThemeParsed => {\n if (isRSC) {\n return getDefaultThemeProxied()\n }\n\n const { name, theme, themeManager, className, isNewTheme } = useChangeThemeEffect(props)\n\n if (process.env.NODE_ENV === 'development') {\n // ensure we aren't creating too many ThemeManagers\n if (isWeb && isNewTheme && className === themeManager?.parentManager?.state.className) {\n console.error(`Should always change, duplicating ThemeMananger bug`, themeManager)\n // eslint-disable-next-line no-debugger\n debugger\n }\n if (props.debug === 'verbose') {\n console.groupCollapsed(' \uD83D\uDD39 useTheme =>', name)\n const logs = { ...props, name, className, ...(isDevTools && { theme }) }\n for (const key in logs) {\n console.log(' ', key, logs[key])\n }\n console.groupEnd()\n }\n }\n\n if (!theme) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('No theme found', name, props, themeManager)\n }\n return getDefaultThemeProxied()\n }\n\n return useMemo(() => {\n return getThemeProxied({\n isNewTheme,\n theme,\n name,\n className,\n themeManager,\n })\n }, [theme, isNewTheme, name, className, themeManager])\n}\n\nfunction getThemeProxied({\n theme,\n name,\n className,\n themeManager,\n isNewTheme,\n}: {\n theme: any\n name: string\n className?: string\n themeManager?: ThemeManager | null\n isNewTheme?: boolean\n}) {\n return createProxy(theme, {\n has(_, key) {\n if (typeof key === 'string') {\n if (key[0] === '$') key = key.slice(1)\n return themeManager?.allKeys.has(key)\n }\n return Reflect.has(theme, key)\n },\n get(_, key) {\n if (key === GetThemeUnwrapped) {\n return theme\n } else if (key === GetThemeManager) {\n return themeManager\n } else if (key === GetIsNewTheme) {\n return isNewTheme\n } else if (key === 'name') {\n return name\n } else if (key === 'className') {\n return className\n } else if (!name || key === '__proto__' || typeof key === 'symbol' || key === '$typeof') {\n return Reflect.get(_, key)\n }\n // auto convert variables to plain\n if (key[0] === '$') key = key.slice(1)\n if (!themeManager) {\n return theme[key]\n }\n return themeManager.getValue(key)\n },\n })\n}\n\nconst GetThemeManager = Symbol()\nconst GetIsNewTheme = Symbol()\n\nexport const getThemeManager = (theme: any): ThemeManager | undefined => theme?.[GetThemeManager]\nexport const getThemeIsNewTheme = (theme: any): ThemeManager | undefined => theme?.[GetIsNewTheme]\n\nexport const activeThemeManagers = new Set<ThemeManager>()\n\nexport const useChangeThemeEffect = (props: ThemeProps, root = false): ChangedThemeResponse => {\n if (isRSC) {\n // we need context working for this to work well\n return {\n ...createState().state,\n themeManager: null,\n }\n }\n const parentManager = useContext(ThemeManagerContext)\n\n const {\n debug,\n // @ts-expect-error internal use only\n disable,\n } = props\n\n if (disable) {\n if (!parentManager) throw new Error(`Disable topmost`)\n return {\n ...parentManager.state,\n isNewTheme: false,\n themeManager: parentManager,\n }\n }\n\n type State = {\n isNewTheme: boolean\n state: ThemeManagerState\n themeManager: ThemeManager\n mounted?: boolean\n }\n\n const [themeState, setThemeState] = useState<State>(createState)\n const { isNewTheme, state, themeManager, mounted } = themeState\n\n if (!isServer) {\n useLayoutEffect(() => {\n if (disable) return\n // SSR safe inverse (because server can't know prefers scheme)\n // could be done through fancy selectors like how we do prefers-media\n // but may be a bit of explosion of selectors\n if (props.inverse && !mounted) {\n setThemeState({ ...themeState, mounted: true })\n return\n }\n activeThemeManagers.add(themeManager)\n const disposeChangeListener = parentManager?.onChangeTheme(() => {\n if (!isNewTheme && !isWeb) {\n setThemeState({\n ...themeState,\n state: { ...themeManager.state },\n isNewTheme: false,\n })\n } else {\n updateState()\n }\n })\n return () => {\n activeThemeManagers.delete(themeManager)\n disposeChangeListener?.()\n }\n }, [disable, state, isNewTheme, debug])\n }\n\n // prettier-ignore\n if (process.env.NODE_ENV === 'development' && debug) console.log('useTheme.render isNewTheme', isNewTheme, props, themeManager.state.name, parentManager?.state.name)\n\n // this seems unnecessary\n if (hasNoThemeUpdatingProps(props)) {\n if (!parentManager) throw `impossible`\n // prettier-ignore\n if (process.env.NODE_ENV === 'development' && props.debug === 'verbose') console.log('useTheme no updating props', parentManager.state)\n return {\n ...parentManager.state,\n themeManager: parentManager,\n isNewTheme: false,\n }\n }\n\n // run inline in render\n updateState()\n\n if (!mounted && !parentManager) {\n throw `impossible`\n }\n\n return {\n ...state,\n isNewTheme,\n themeManager,\n ...(!mounted &&\n parentManager && {\n ...parentManager.state,\n isNewTheme: false,\n themeManager: parentManager,\n }),\n }\n\n function createState(prev?: State) {\n const _ = new ThemeManager(props, root ? 'root' : parentManager)\n const isNewTheme = _ !== parentManager\n // prettier-ignore\n if (process.env.NODE_ENV === 'development' && debug) [console.groupCollapsed('useTheme create() isNewTheme', isNewTheme), console.log('parent.state.name', parentManager?.state.name, '\\n', 'props', props, '\\n', isClient ? parentManager : '', 'getState', isNewTheme && isClient ? _.getState(props) : '', '\\n', 'state', isClient ? { ..._.state } : ''), console.groupEnd()]\n // only inverse relies on this for ssr\n const mounted = !props.inverse ? true : root || prev?.mounted || false\n return {\n // ThemeManager returns parentManager if no change\n isNewTheme,\n state: { ..._.state },\n themeManager: _,\n mounted,\n }\n }\n\n function updateState() {\n if (themeManager.getStateIfChanged(props, isNewTheme ? state : null, parentManager)) {\n setThemeState(createState)\n } else {\n // prettier-ignore\n if (process.env.NODE_ENV === 'development' && props.debug === 'verbose') console.log(`useTheme updateState didn't change`)\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["isNewTheme", "mounted"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hooks/useUnmountEffect.ts"],
|
|
4
|
+
"sourcesContent": ["import { useEffect } from 'react'\n\nexport function useUnmountEffect(callback: () => void) {\n return useEffect(() => () => callback(), [])\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iBAAiB;AAEnB,SAAS,iBAAiB,UAAsB;AACrD,SAAO,UAAU,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC;AAC7C;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const stylesheets = {};
|
|
2
|
+
const injectStyles = ({ filePath, css }) => {
|
|
3
|
+
let stylesheet = stylesheets[filePath];
|
|
4
|
+
if (!stylesheet) {
|
|
5
|
+
const styleEl = document.createElement("style");
|
|
6
|
+
styleEl.setAttribute("data-file", filePath);
|
|
7
|
+
styleEl.setAttribute("type", "text/css");
|
|
8
|
+
stylesheet = stylesheets[filePath] = styleEl;
|
|
9
|
+
document.head.appendChild(styleEl);
|
|
10
|
+
}
|
|
11
|
+
stylesheet.innerHTML = css;
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
injectStyles
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=injectStyles.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/injectStyles.ts"],
|
|
4
|
+
"sourcesContent": ["// for vite dev mode\n\nconst stylesheets: Record<string, HTMLElement> = {}\n\ninterface InjectStylesOptions {\n filePath: string\n css: string\n}\n\nexport const injectStyles = ({ filePath, css }: InjectStylesOptions) => {\n let stylesheet = stylesheets[filePath]\n if (!stylesheet) {\n const styleEl = document.createElement('style')\n styleEl.setAttribute('data-file', filePath)\n styleEl.setAttribute('type', 'text/css')\n stylesheet = stylesheets[filePath] = styleEl\n document.head.appendChild(styleEl)\n }\n stylesheet.innerHTML = css\n}\n"],
|
|
5
|
+
"mappings": "AAEA,MAAM,cAA2C,CAAC;AAO3C,MAAM,eAAe,CAAC,EAAE,UAAU,IAAI,MAA2B;AACtE,MAAI,aAAa,YAAY;AAC7B,MAAI,CAAC,YAAY;AACf,UAAM,UAAU,SAAS,cAAc,OAAO;AAC9C,YAAQ,aAAa,aAAa,QAAQ;AAC1C,YAAQ,aAAa,QAAQ,UAAU;AACvC,iBAAa,YAAY,YAAY;AACrC,aAAS,KAAK,YAAY,OAAO;AAAA,EACnC;AACA,aAAW,YAAY;AACzB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/esm/styled.js
CHANGED
|
@@ -3,16 +3,6 @@ import { ReactNativeStaticConfigs } from "./setupReactNative";
|
|
|
3
3
|
function styled(Component, options, staticExtractionOptions) {
|
|
4
4
|
const staticConfigProps = (() => {
|
|
5
5
|
const parentStaticConfig = "staticConfig" in Component ? Component.staticConfig : null;
|
|
6
|
-
if (process.env.NODE_ENV === "development") {
|
|
7
|
-
if (parentStaticConfig == null ? void 0 : parentStaticConfig.isHOC) {
|
|
8
|
-
console.warn(
|
|
9
|
-
`Warning: Parent component is a functional component, not a Tamagui styled() component. Extending with styled() will break and lead to incorrect styles.`,
|
|
10
|
-
`Given options:`,
|
|
11
|
-
options,
|
|
12
|
-
new Error().stack
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
6
|
if (options) {
|
|
17
7
|
const {
|
|
18
8
|
variants,
|
package/dist/esm/styled.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/styled.tsx"],
|
|
4
|
-
"sourcesContent": ["import { createComponent } from './createComponent'\nimport { ReactNativeStaticConfigs } from './setupReactNative'\nimport {\n GetProps,\n GetVariantValues,\n MediaProps,\n PseudoProps,\n StaticConfig,\n StylableComponent,\n TamaguiComponent,\n TamaguiElement,\n VariantDefinitions,\n VariantSpreadFunction,\n} from './types'\n\n// TODO may be able to use this in the options?: arg below directly\nexport type StyledOptions<ParentComponent extends StylableComponent> = GetProps<ParentComponent> & {\n name?: string\n variants?: VariantDefinitions<ParentComponent> | undefined\n defaultVariants?: { [key: string]: any }\n}\n\n// can't infer from styled(<YStack />) which would be nice\n// * excessively deep type instantiation\n\ntype GetBaseProps<A extends StylableComponent> =\n // A extends TamaguiReactElement\n // ? GetBaseProps<A['type']> :\n A extends TamaguiComponent<any, any, infer P> ? P : GetProps<A>\n\ntype GetVariantProps<A extends StylableComponent> =\n // A extends TamaguiReactElement\n // ? GetVariantProps<A['type']>\n // :\n A extends TamaguiComponent<any, any, any, infer V> ? V : {}\n\nexport function styled<\n ParentComponent extends StylableComponent,\n Variants extends VariantDefinitions<ParentComponent> | void = VariantDefinitions<ParentComponent> | void\n>(\n Component: ParentComponent,\n // this should be Partial<GetProps<ParentComponent>> but causes excessively deep type issues\n options?: GetProps<ParentComponent> & {\n name?: string\n variants?: Variants | undefined\n // thought i had this typed, but can't get it linked\n defaultVariants?: { [key: string]: any }\n acceptsClassName?: boolean\n },\n staticExtractionOptions?: Partial<StaticConfig>\n) {\n // allows passing styled(<H1 bc=\"red\" />)\n // but to get types right would be tricky\n // if (isValidElement(Component) && isTamaguiComponent(Component.type)) {\n // const props = Component.props\n // if (props && typeof props === 'object') {\n // Component = Component.type as any\n // options = options ? ({ ...props, ...options } as any) : props\n // }\n // }\n\n const staticConfigProps = (() => {\n const parentStaticConfig =\n 'staticConfig' in Component ? (Component.staticConfig as StaticConfig) : null\n\n if (
|
|
5
|
-
"mappings": "AAAA,SAAS,uBAAuB;AAChC,SAAS,gCAAgC;AAmClC,SAAS,OAId,WAEA,SAOA,yBACA;AAWA,QAAM,qBAAqB,MAAM;AAC/B,UAAM,qBACJ,kBAAkB,YAAa,UAAU,eAAgC;AAE3E,QAAI,
|
|
4
|
+
"sourcesContent": ["import { createComponent } from './createComponent'\nimport { ReactNativeStaticConfigs } from './setupReactNative'\nimport {\n GetProps,\n GetVariantValues,\n MediaProps,\n PseudoProps,\n StaticConfig,\n StylableComponent,\n TamaguiComponent,\n TamaguiElement,\n VariantDefinitions,\n VariantSpreadFunction,\n} from './types'\n\n// TODO may be able to use this in the options?: arg below directly\nexport type StyledOptions<ParentComponent extends StylableComponent> = GetProps<ParentComponent> & {\n name?: string\n variants?: VariantDefinitions<ParentComponent> | undefined\n defaultVariants?: { [key: string]: any }\n}\n\n// can't infer from styled(<YStack />) which would be nice\n// * excessively deep type instantiation\n\ntype GetBaseProps<A extends StylableComponent> =\n // A extends TamaguiReactElement\n // ? GetBaseProps<A['type']> :\n A extends TamaguiComponent<any, any, infer P> ? P : GetProps<A>\n\ntype GetVariantProps<A extends StylableComponent> =\n // A extends TamaguiReactElement\n // ? GetVariantProps<A['type']>\n // :\n A extends TamaguiComponent<any, any, any, infer V> ? V : {}\n\nexport function styled<\n ParentComponent extends StylableComponent,\n Variants extends VariantDefinitions<ParentComponent> | void = VariantDefinitions<ParentComponent> | void\n>(\n Component: ParentComponent,\n // this should be Partial<GetProps<ParentComponent>> but causes excessively deep type issues\n options?: GetProps<ParentComponent> & {\n name?: string\n variants?: Variants | undefined\n // thought i had this typed, but can't get it linked\n defaultVariants?: { [key: string]: any }\n acceptsClassName?: boolean\n },\n staticExtractionOptions?: Partial<StaticConfig>\n) {\n // allows passing styled(<H1 bc=\"red\" />)\n // but to get types right would be tricky\n // if (isValidElement(Component) && isTamaguiComponent(Component.type)) {\n // const props = Component.props\n // if (props && typeof props === 'object') {\n // Component = Component.type as any\n // options = options ? ({ ...props, ...options } as any) : props\n // }\n // }\n\n const staticConfigProps = (() => {\n const parentStaticConfig =\n 'staticConfig' in Component ? (Component.staticConfig as StaticConfig) : null\n\n if (options) {\n const {\n variants,\n name,\n defaultVariants,\n acceptsClassName: acceptsClassNameProp,\n ...defaultProps\n } = options\n if (defaultVariants) {\n Object.assign(defaultProps, defaultVariants)\n }\n const isReactNative = Boolean(\n ReactNativeStaticConfigs.has(Component) ||\n ReactNativeStaticConfigs.has(parentStaticConfig?.Component) ||\n parentStaticConfig?.isReactNative ||\n staticExtractionOptions?.isReactNative\n )\n const isTamagui = !isReactNative && !!parentStaticConfig\n\n const Comp = isReactNative ? parentStaticConfig?.Component || Component : (Component as any)\n const nativeConf = (isReactNative && ReactNativeStaticConfigs.get(Comp)) || null\n\n const isText = Boolean(staticExtractionOptions?.isText || parentStaticConfig?.isText)\n const acceptsClassName = acceptsClassNameProp ?? (isTamagui || isReactNative)\n\n const conf: Partial<StaticConfig> = {\n ...staticExtractionOptions,\n ...(!isTamagui && {\n Component: Comp,\n }),\n // this type gets messed up by options?: Partial<GetProps<ParentComponent>> above\n // take away the Partial<> and it's fine\n variants,\n defaultProps,\n defaultVariants,\n componentName: name,\n isReactNative,\n isText,\n acceptsClassName,\n ...nativeConf,\n }\n\n // bail on non className views as well\n if (defaultProps.children || !acceptsClassName) {\n conf.neverFlatten = true\n }\n\n return conf\n }\n return {}\n })()\n\n const component = createComponent(staticConfigProps, Component)\n\n // get parent props without pseudos and medias so we can rebuild both with new variants\n // get parent props without pseudos and medias so we can rebuild both with new variants\n type ParentPropsBase = GetBaseProps<ParentComponent>\n type ParentVariants = GetVariantProps<ParentComponent>\n\n type OurVariants = Variants extends void\n ? {}\n : {\n [Key in keyof Variants]?: Variants[Key] extends VariantSpreadFunction<any, infer Val>\n ? Val\n : GetVariantValues<keyof Variants[Key]>\n }\n\n type VariantProps = Omit<ParentVariants, keyof OurVariants> & OurVariants\n type OurPropsBase = ParentPropsBase & VariantProps\n\n type Props = Variants extends void\n ? GetProps<ParentComponent>\n : // start with base props\n OurPropsBase &\n // add in media (+ pseudos nested)\n MediaProps<Partial<OurPropsBase>> &\n // add in pseudos\n PseudoProps<Partial<OurPropsBase>>\n\n type StyledComponent = TamaguiComponent<\n Props,\n TamaguiElement,\n ParentPropsBase,\n ParentVariants & OurVariants\n >\n\n return component as StyledComponent\n}\n\n// import { Stack } from './views/Stack'\n// const X = styled(Stack, {\n// variants: {\n// size: {\n// '...size': (val) => {\n// return {}\n// }\n// },\n// disabled: {\n// true: {\n// opacity: 0.5,\n// pointerEvents: 'none',\n// },\n// },\n// } as const\n// })\n// type variants = GetStyledVariants<typeof X>\n// const y = <X disabled size=\"$10\" />\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,uBAAuB;AAChC,SAAS,gCAAgC;AAmClC,SAAS,OAId,WAEA,SAOA,yBACA;AAWA,QAAM,qBAAqB,MAAM;AAC/B,UAAM,qBACJ,kBAAkB,YAAa,UAAU,eAAgC;AAE3E,QAAI,SAAS;AACX,YAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,QACA,kBAAkB;AAAA,WACf;AAAA,MACL,IAAI;AACJ,UAAI,iBAAiB;AACnB,eAAO,OAAO,cAAc,eAAe;AAAA,MAC7C;AACA,YAAM,gBAAgB;AAAA,QACpB,yBAAyB,IAAI,SAAS,KACpC,yBAAyB,IAAI,yDAAoB,SAAS,MAC1D,yDAAoB,mBACpB,mEAAyB;AAAA,MAC7B;AACA,YAAM,YAAY,CAAC,iBAAiB,CAAC,CAAC;AAEtC,YAAM,OAAO,iBAAgB,yDAAoB,cAAa,YAAa;AAC3E,YAAM,aAAc,iBAAiB,yBAAyB,IAAI,IAAI,KAAM;AAE5E,YAAM,SAAS,SAAQ,mEAAyB,YAAU,yDAAoB,OAAM;AACpF,YAAM,mBAAmB,yBAAyB,aAAa;AAE/D,YAAM,OAA8B;AAAA,QAClC,GAAG;AAAA,QACH,GAAI,CAAC,aAAa;AAAA,UAChB,WAAW;AAAA,QACb;AAAA,QAGA;AAAA,QACA;AAAA,QACA;AAAA,QACA,eAAe;AAAA,QACf;AAAA,QACA;AAAA,QACA;AAAA,QACA,GAAG;AAAA,MACL;AAGA,UAAI,aAAa,YAAY,CAAC,kBAAkB;AAC9C,aAAK,eAAe;AAAA,MACtB;AAEA,aAAO;AAAA,IACT;AACA,WAAO,CAAC;AAAA,EACV,GAAG;AAEH,QAAM,YAAY,gBAAgB,mBAAmB,SAAS;AAkC9D,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/views/Theme.js
CHANGED
|
@@ -9,22 +9,18 @@ function Theme(props) {
|
|
|
9
9
|
return props.children;
|
|
10
10
|
}
|
|
11
11
|
const isRoot = !!props["_isRoot"];
|
|
12
|
-
const { name, theme, themeManager,
|
|
13
|
-
props,
|
|
14
|
-
isRoot
|
|
15
|
-
);
|
|
12
|
+
const { name, theme, themeManager, isNewTheme, className } = useChangeThemeEffect(props, isRoot);
|
|
16
13
|
const disableThemeClass = props.disableThemeClass;
|
|
17
|
-
const missingTheme = !
|
|
18
|
-
const disablePassingTheme = missingTheme || !isNewTheme;
|
|
14
|
+
const missingTheme = !name || !theme;
|
|
19
15
|
let contents = useMemo(() => {
|
|
20
16
|
const next = props["data-themeable"] ? React.cloneElement(props.children, { ["data-themeable"]: true }) : props.children;
|
|
21
|
-
return
|
|
22
|
-
}, [
|
|
17
|
+
return missingTheme ? next : wrapThemeManagerContext(next, themeManager);
|
|
18
|
+
}, [missingTheme, props.children, themeManager]);
|
|
23
19
|
if (process.env.NODE_ENV === "development" && missingTheme) {
|
|
24
20
|
name && !theme && console.warn(`No theme found by name ${name}`);
|
|
25
21
|
return props.children;
|
|
26
22
|
}
|
|
27
|
-
if (disableThemeClass ||
|
|
23
|
+
if (disableThemeClass || missingTheme) {
|
|
28
24
|
return contents;
|
|
29
25
|
}
|
|
30
26
|
if (isWeb) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/Theme.tsx"],
|
|
4
|
-
"sourcesContent": ["import { isWeb } from '@tamagui/constants'\nimport React, { useMemo } from 'react'\n\nimport { variableToString } from '../createVariable'\nimport { ThemeManager } from '../helpers/ThemeManager'\nimport { ThemeManagerContext } from '../helpers/ThemeManagerContext'\nimport { useChangeThemeEffect } from '../hooks/useTheme'\nimport { ThemeProps } from '../types'\n\nexport function Theme(props: ThemeProps) {\n // @ts-expect-error its a permanent prop meant for internal views\n if (props.disable) {\n return props.children\n }\n\n const isRoot = !!props['_isRoot']\n const { name, theme, themeManager,
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { isWeb } from '@tamagui/constants'\nimport React, { useMemo } from 'react'\n\nimport { variableToString } from '../createVariable'\nimport { ThemeManager } from '../helpers/ThemeManager'\nimport { ThemeManagerContext } from '../helpers/ThemeManagerContext'\nimport { useChangeThemeEffect } from '../hooks/useTheme'\nimport { ThemeProps } from '../types'\n\nexport function Theme(props: ThemeProps) {\n // @ts-expect-error its a permanent prop meant for internal views\n if (props.disable) {\n return props.children\n }\n\n const isRoot = !!props['_isRoot']\n const { name, theme, themeManager, isNewTheme, className } = useChangeThemeEffect(props, isRoot)\n\n const disableThemeClass = props.disableThemeClass\n const missingTheme = !name || !theme\n\n // memo here, changing theme without re-rendering all children is a critical optimization\n // may require some effort of end user to memoize but without this memo they'd have no option\n let contents = useMemo(() => {\n const next = props['data-themeable']\n ? React.cloneElement(props.children, { ['data-themeable']: true })\n : props.children\n\n return missingTheme ? next : wrapThemeManagerContext(next, themeManager)\n }, [missingTheme, props.children, themeManager])\n\n if (process.env.NODE_ENV === 'development' && missingTheme) {\n // eslint-disable-next-line no-console\n name && !theme && console.warn(`No theme found by name ${name}`)\n return props.children\n }\n\n if (disableThemeClass || missingTheme) {\n return contents\n }\n\n if (isWeb) {\n const cn = [props.className, className, '_dsp_contents'].filter(Boolean).join(' ')\n contents = (\n <span\n className={cn}\n style={{\n // in order to provide currentColor, set color by default\n color: variableToString(theme?.color),\n }}\n >\n {contents}\n </span>\n )\n }\n\n return contents\n}\n\nexport function wrapThemeManagerContext(\n children: any,\n themeManager?: ThemeManager | null,\n shouldReset?: boolean\n) {\n // be sure to memoize themeManager to avoid reparenting\n if (!themeManager) {\n return children\n }\n // be sure to memoize shouldReset to avoid reparenting\n let next = children\n // TODO likely not necessary if we do reset logic now in useTheme?\n // reset to parent theme\n if (shouldReset && themeManager) {\n next = <Theme name={themeManager.state.parentName}>{next}</Theme>\n }\n return <ThemeManagerContext.Provider value={themeManager}>{next}</ThemeManagerContext.Provider>\n}\n"],
|
|
5
|
+
"mappings": "AA4CM;AA5CN,SAAS,aAAa;AACtB,OAAO,SAAS,eAAe;AAE/B,SAAS,wBAAwB;AAEjC,SAAS,2BAA2B;AACpC,SAAS,4BAA4B;AAG9B,SAAS,MAAM,OAAmB;AAEvC,MAAI,MAAM,SAAS;AACjB,WAAO,MAAM;AAAA,EACf;AAEA,QAAM,SAAS,CAAC,CAAC,MAAM;AACvB,QAAM,EAAE,MAAM,OAAO,cAAc,YAAY,UAAU,IAAI,qBAAqB,OAAO,MAAM;AAE/F,QAAM,oBAAoB,MAAM;AAChC,QAAM,eAAe,CAAC,QAAQ,CAAC;AAI/B,MAAI,WAAW,QAAQ,MAAM;AAC3B,UAAM,OAAO,MAAM,oBACf,MAAM,aAAa,MAAM,UAAU,EAAE,CAAC,mBAAmB,KAAK,CAAC,IAC/D,MAAM;AAEV,WAAO,eAAe,OAAO,wBAAwB,MAAM,YAAY;AAAA,EACzE,GAAG,CAAC,cAAc,MAAM,UAAU,YAAY,CAAC;AAE/C,MAAI,QAAQ,IAAI,aAAa,iBAAiB,cAAc;AAE1D,YAAQ,CAAC,SAAS,QAAQ,KAAK,0BAA0B,MAAM;AAC/D,WAAO,MAAM;AAAA,EACf;AAEA,MAAI,qBAAqB,cAAc;AACrC,WAAO;AAAA,EACT;AAEA,MAAI,OAAO;AACT,UAAM,KAAK,CAAC,MAAM,WAAW,WAAW,eAAe,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AACjF,eACE,oBAAC;AAAA,MACC,WAAW;AAAA,MACX,OAAO;AAAA,QAEL,OAAO,iBAAiB,+BAAO,KAAK;AAAA,MACtC;AAAA,MAEC;AAAA,KACH;AAAA,EAEJ;AAEA,SAAO;AACT;AAEO,SAAS,wBACd,UACA,cACA,aACA;AAEA,MAAI,CAAC,cAAc;AACjB,WAAO;AAAA,EACT;AAEA,MAAI,OAAO;AAGX,MAAI,eAAe,cAAc;AAC/B,WAAO,oBAAC;AAAA,MAAM,MAAM,aAAa,MAAM;AAAA,MAAa;AAAA,KAAK;AAAA,EAC3D;AACA,SAAO,oBAAC,oBAAoB,UAApB;AAAA,IAA6B,OAAO;AAAA,IAAe;AAAA,GAAK;AAClE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,38 +1,32 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { isWeb, useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
3
2
|
import { useState } from "react";
|
|
3
|
+
import { useIsomorphicLayoutEffect } from "../constants/platform";
|
|
4
4
|
import { useDefaultThemeName, useThemeName } from "../hooks/useTheme";
|
|
5
5
|
import { Theme } from "./Theme";
|
|
6
|
-
const toggleTheme = (themeName) => {
|
|
7
|
-
return themeName.startsWith("light") ? "dark" : "light";
|
|
8
|
-
};
|
|
9
|
-
const useThemeInverse = (props = {}) => {
|
|
10
|
-
const themeName = useThemeName();
|
|
11
|
-
const defaultTheme = useDefaultThemeName();
|
|
12
|
-
const [name, setName] = useState(null);
|
|
13
|
-
const curName = themeName || defaultTheme || "";
|
|
14
|
-
if (isWeb) {
|
|
15
|
-
useIsomorphicLayoutEffect(() => {
|
|
16
|
-
setName(toggleTheme(curName));
|
|
17
|
-
}, [defaultTheme, themeName]);
|
|
18
|
-
return props.disable ? null : name;
|
|
19
|
-
}
|
|
20
|
-
return props.disable ? null : toggleTheme(curName);
|
|
21
|
-
};
|
|
22
6
|
const ThemeInverse = ({
|
|
23
7
|
children,
|
|
24
8
|
disable
|
|
25
9
|
}) => {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
10
|
+
const themeName = useThemeName();
|
|
11
|
+
const defaultTheme = useDefaultThemeName();
|
|
12
|
+
const [name, setName] = useState(null);
|
|
13
|
+
useIsomorphicLayoutEffect(() => {
|
|
14
|
+
if (themeName.startsWith("dark")) {
|
|
15
|
+
setName("light");
|
|
16
|
+
}
|
|
17
|
+
if (themeName.startsWith("light")) {
|
|
18
|
+
setName("dark");
|
|
19
|
+
}
|
|
20
|
+
}, [defaultTheme, themeName]);
|
|
21
|
+
if (disable) {
|
|
22
|
+
return children;
|
|
23
|
+
}
|
|
29
24
|
return /* @__PURE__ */ jsx(Theme, {
|
|
30
|
-
name
|
|
25
|
+
name,
|
|
31
26
|
children
|
|
32
27
|
});
|
|
33
28
|
};
|
|
34
29
|
export {
|
|
35
|
-
ThemeInverse
|
|
36
|
-
useThemeInverse
|
|
30
|
+
ThemeInverse
|
|
37
31
|
};
|
|
38
32
|
//# sourceMappingURL=ThemeInverse.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/ThemeInverse.tsx"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import React, { useState } from 'react'\n\nimport { useIsomorphicLayoutEffect } from '../constants/platform'\nimport { useDefaultThemeName, useThemeName } from '../hooks/useTheme'\nimport { Theme } from './Theme'\n\nexport const ThemeInverse = ({\n children,\n disable,\n}: {\n children: React.ReactNode\n disable?: boolean\n}) => {\n const themeName = useThemeName()\n const defaultTheme = useDefaultThemeName()\n const [name, setName] = useState<null | string>(null)\n\n // ssr\n useIsomorphicLayoutEffect(() => {\n if (themeName.startsWith('dark')) {\n setName('light')\n }\n if (themeName.startsWith('light')) {\n setName('dark')\n }\n }, [defaultTheme, themeName])\n\n if (disable) {\n return children as JSX.Element\n }\n\n return <Theme name={name}>{children}</Theme>\n}\n"],
|
|
5
|
+
"mappings": "AA+BS;AA/BT,SAAgB,gBAAgB;AAEhC,SAAS,iCAAiC;AAC1C,SAAS,qBAAqB,oBAAoB;AAClD,SAAS,aAAa;AAEf,MAAM,eAAe,CAAC;AAAA,EAC3B;AAAA,EACA;AACF,MAGM;AACJ,QAAM,YAAY,aAAa;AAC/B,QAAM,eAAe,oBAAoB;AACzC,QAAM,CAAC,MAAM,OAAO,IAAI,SAAwB,IAAI;AAGpD,4BAA0B,MAAM;AAC9B,QAAI,UAAU,WAAW,MAAM,GAAG;AAChC,cAAQ,OAAO;AAAA,IACjB;AACA,QAAI,UAAU,WAAW,OAAO,GAAG;AACjC,cAAQ,MAAM;AAAA,IAChB;AAAA,EACF,GAAG,CAAC,cAAc,SAAS,CAAC;AAE5B,MAAI,SAAS;AACX,WAAO;AAAA,EACT;AAEA,SAAO,oBAAC;AAAA,IAAM;AAAA,IAAa;AAAA,GAAS;AACtC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { isClient } from "@tamagui/constants";
|
|
3
2
|
import React, { useContext, useLayoutEffect, useState } from "react";
|
|
3
|
+
import { isWeb } from "../constants/platform";
|
|
4
4
|
import { ThemeManagerContext } from "../helpers/ThemeManager";
|
|
5
5
|
import { Theme } from "./Theme";
|
|
6
6
|
React["createElement"];
|
|
7
7
|
const ThemeReset = (props) => {
|
|
8
|
-
const
|
|
8
|
+
const themeManager = useContext(ThemeManagerContext);
|
|
9
9
|
const [name, setName] = useState(null);
|
|
10
|
-
if (
|
|
10
|
+
if (!isWeb || typeof document !== "undefined") {
|
|
11
11
|
useLayoutEffect(() => {
|
|
12
|
-
if (!
|
|
12
|
+
if (!themeManager)
|
|
13
13
|
return;
|
|
14
|
-
if (name !==
|
|
15
|
-
setName(
|
|
14
|
+
if (name !== themeManager.parentName) {
|
|
15
|
+
setName(themeManager.parentName);
|
|
16
16
|
}
|
|
17
|
-
}, [
|
|
17
|
+
}, [themeManager == null ? void 0 : themeManager.parentName]);
|
|
18
18
|
useLayoutEffect(() => {
|
|
19
|
-
if (!
|
|
19
|
+
if (!themeManager)
|
|
20
20
|
return;
|
|
21
|
-
return
|
|
22
|
-
setName(
|
|
21
|
+
return themeManager.onChangeTheme(() => {
|
|
22
|
+
setName(themeManager.parentName);
|
|
23
23
|
});
|
|
24
|
-
}, [
|
|
24
|
+
}, []);
|
|
25
25
|
}
|
|
26
|
-
if (!
|
|
26
|
+
if (!themeManager || !props.children) {
|
|
27
27
|
return props.children || null;
|
|
28
28
|
}
|
|
29
29
|
return /* @__PURE__ */ jsx(Theme, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/ThemeReset.tsx"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": "AAsCI;AAtCJ,
|
|
4
|
+
"sourcesContent": ["import React, { useContext, useLayoutEffect, useState } from 'react'\n\nimport { isWeb } from '../constants/platform'\nimport { ThemeManagerContext } from '../helpers/ThemeManager'\nimport { Theme } from './Theme'\n\n// bugfix esbuild strips react jsx: 'preserve'\nReact['createElement']\n\n// resets the theme to the parent theme\nexport const ThemeReset = (props: { children?: any }) => {\n const themeManager = useContext(ThemeManagerContext)\n const [name, setName] = useState<string | null>(null)\n\n // this component doesn't work with SSR, so must run only client side\n // we could at least prevent more flickering by having the ssr head script\n // that changes to dark initially also go through and change all of these\n if (!isWeb || typeof document !== 'undefined') {\n useLayoutEffect(() => {\n if (!themeManager) return\n if (name !== themeManager.parentName) {\n setName(themeManager.parentName)\n }\n }, [themeManager?.parentName])\n\n useLayoutEffect(() => {\n if (!themeManager) return\n return themeManager.onChangeTheme(() => {\n setName(themeManager.parentName)\n })\n }, [])\n }\n\n if (!themeManager || !props.children) {\n return props.children || null\n }\n\n return (\n <Theme className=\"tui-theme-reset\" reset name={name}>\n {props.children}\n </Theme>\n )\n}\n"],
|
|
5
|
+
"mappings": "AAsCI;AAtCJ,OAAO,SAAS,YAAY,iBAAiB,gBAAgB;AAE7D,SAAS,aAAa;AACtB,SAAS,2BAA2B;AACpC,SAAS,aAAa;AAGtB,MAAM;AAGC,MAAM,aAAa,CAAC,UAA8B;AACvD,QAAM,eAAe,WAAW,mBAAmB;AACnD,QAAM,CAAC,MAAM,OAAO,IAAI,SAAwB,IAAI;AAKpD,MAAI,CAAC,SAAS,OAAO,aAAa,aAAa;AAC7C,oBAAgB,MAAM;AACpB,UAAI,CAAC;AAAc;AACnB,UAAI,SAAS,aAAa,YAAY;AACpC,gBAAQ,aAAa,UAAU;AAAA,MACjC;AAAA,IACF,GAAG,CAAC,6CAAc,UAAU,CAAC;AAE7B,oBAAgB,MAAM;AACpB,UAAI,CAAC;AAAc;AACnB,aAAO,aAAa,cAAc,MAAM;AACtC,gBAAQ,aAAa,UAAU;AAAA,MACjC,CAAC;AAAA,IACH,GAAG,CAAC,CAAC;AAAA,EACP;AAEA,MAAI,CAAC,gBAAgB,CAAC,MAAM,UAAU;AACpC,WAAO,MAAM,YAAY;AAAA,EAC3B;AAEA,SACE,oBAAC;AAAA,IAAM,WAAU;AAAA,IAAkB,OAAK;AAAA,IAAC;AAAA,IACtC,gBAAM;AAAA,GACT;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|