@tamagui/web
Advanced tools
Comparing version 1.30.24 to 1.30.25
@@ -59,10 +59,7 @@ "use strict"; | ||
} | ||
const parentManager = getNonComponentParentManager(parentManagerIn); | ||
if (parentManager) { | ||
this.parentManager = parentManager; | ||
} | ||
this.parentManager = parentManagerIn; | ||
if (this.updateState(props, false)) { | ||
return; | ||
} | ||
return parentManager || this; | ||
return parentManagerIn || this; | ||
} | ||
@@ -162,4 +159,8 @@ updateState(props = this.props || {}, shouldNotify = true) { | ||
function getState(props, parentManager) { | ||
var _a, _b, _c; | ||
var _a, _b, _c, _d, _e, _f; | ||
const validManagerAndAllComponentThemes = getNonComponentParentManager(parentManager); | ||
parentManager = validManagerAndAllComponentThemes[0]; | ||
const allComponentThemes = validManagerAndAllComponentThemes[1]; | ||
const themes = (0, import_config.getThemes)(); | ||
const isDirectParentAComponentTheme = allComponentThemes.length > 0; | ||
if (props.name && props.reset) { | ||
@@ -171,3 +172,3 @@ throw new Error("Cannot reset + set new name"); | ||
} | ||
if (props.reset && !(parentManager == null ? void 0 : parentManager.parentManager)) { | ||
if (props.reset && !isDirectParentAComponentTheme && !(parentManager == null ? void 0 : parentManager.parentManager)) { | ||
if (process.env.NODE_ENV === "development") { | ||
@@ -179,5 +180,11 @@ console.warn("Cannot reset no grandparent exists"); | ||
let result = null; | ||
const nextName = props.reset ? ((_b = (_a = parentManager == null ? void 0 : parentManager.parentManager) == null ? void 0 : _a.state) == null ? void 0 : _b.name) || "" : props.name || ""; | ||
const nextName = props.reset ? isDirectParentAComponentTheme ? ((_a = parentManager == null ? void 0 : parentManager.state) == null ? void 0 : _a.name) || "" : ((_c = (_b = parentManager == null ? void 0 : parentManager.parentManager) == null ? void 0 : _b.state) == null ? void 0 : _c.name) || "" : props.name || ""; | ||
const { componentName } = props; | ||
const parentName = ((_c = parentManager == null ? void 0 : parentManager.state) == null ? void 0 : _c.name) || ""; | ||
const parentName = props.reset ? isDirectParentAComponentTheme ? ( | ||
// here because parentManager already skipped componentTheme so we have to only go up once | ||
((_d = parentManager == null ? void 0 : parentManager.parentManager) == null ? void 0 : _d.state.name) || "" | ||
) : ((_f = (_e = parentManager == null ? void 0 : parentManager.parentManager) == null ? void 0 : _e.parentManager) == null ? void 0 : _f.state.name) || "" : isDirectParentAComponentTheme ? allComponentThemes[0] || "" : (parentManager == null ? void 0 : parentManager.state.name) || ""; | ||
if (props.reset && isDirectParentAComponentTheme) { | ||
allComponentThemes.shift(); | ||
} | ||
const base = parentName.split(import_constants.THEME_NAME_SEPARATOR); | ||
@@ -238,3 +245,3 @@ const lastSegment = base[base.length - 1]; | ||
} | ||
potentials = [...componentPotentials, ...potentials]; | ||
potentials = [...componentPotentials, ...potentials, ...allComponentThemes]; | ||
} | ||
@@ -268,5 +275,8 @@ const found = potentials.find((t) => t in themes); | ||
function getNonComponentParentManager(themeManager) { | ||
var _a; | ||
let res = themeManager; | ||
let componentThemeNames = []; | ||
while (res) { | ||
if (res == null ? void 0 : res.isComponent) { | ||
componentThemeNames.push((_a = res == null ? void 0 : res.state) == null ? void 0 : _a.name); | ||
res = res.parentManager; | ||
@@ -277,3 +287,3 @@ } else { | ||
} | ||
return res || null; | ||
return [res || null, componentThemeNames]; | ||
} | ||
@@ -280,0 +290,0 @@ // Annotate the CommonJS export names for ESM import in node: |
@@ -138,12 +138,11 @@ "use strict"; | ||
} = props; | ||
const ogParentManager = (0, import_react.useContext)(import_ThemeManagerContext.ThemeManagerContext); | ||
const parentManager = (0, import_react.useContext)(import_ThemeManagerContext.ThemeManagerContext); | ||
const hasThemeUpdatingProps = (0, import_ThemeManager.getHasThemeUpdatingProps)(props); | ||
const parentManager = disable || !hasThemeUpdatingProps ? ogParentManager : (0, import_ThemeManager.getNonComponentParentManager)(ogParentManager); | ||
if (disable) { | ||
if (!ogParentManager) | ||
if (!parentManager) | ||
throw `\u274C`; | ||
return { | ||
isNewTheme: false, | ||
...ogParentManager.state, | ||
themeManager: ogParentManager | ||
...parentManager.state, | ||
themeManager: parentManager | ||
}; | ||
@@ -285,4 +284,4 @@ } | ||
} else { | ||
state2 = ogParentManager.state; | ||
themeManager2 = ogParentManager; | ||
state2 = parentManager.state; | ||
themeManager2 = parentManager; | ||
} | ||
@@ -289,0 +288,0 @@ } |
@@ -34,10 +34,7 @@ import { getThemes, getTokens } from "../config"; | ||
} | ||
const parentManager = getNonComponentParentManager(parentManagerIn); | ||
if (parentManager) { | ||
this.parentManager = parentManager; | ||
} | ||
this.parentManager = parentManagerIn; | ||
if (this.updateState(props, false)) { | ||
return; | ||
} | ||
return parentManager || this; | ||
return parentManagerIn || this; | ||
} | ||
@@ -137,4 +134,8 @@ updateState(props = this.props || {}, shouldNotify = true) { | ||
function getState(props, parentManager) { | ||
var _a, _b, _c; | ||
var _a, _b, _c, _d, _e, _f; | ||
const validManagerAndAllComponentThemes = getNonComponentParentManager(parentManager); | ||
parentManager = validManagerAndAllComponentThemes[0]; | ||
const allComponentThemes = validManagerAndAllComponentThemes[1]; | ||
const themes = getThemes(); | ||
const isDirectParentAComponentTheme = allComponentThemes.length > 0; | ||
if (props.name && props.reset) { | ||
@@ -146,3 +147,3 @@ throw new Error("Cannot reset + set new name"); | ||
} | ||
if (props.reset && !(parentManager == null ? void 0 : parentManager.parentManager)) { | ||
if (props.reset && !isDirectParentAComponentTheme && !(parentManager == null ? void 0 : parentManager.parentManager)) { | ||
if (process.env.NODE_ENV === "development") { | ||
@@ -154,5 +155,11 @@ console.warn("Cannot reset no grandparent exists"); | ||
let result = null; | ||
const nextName = props.reset ? ((_b = (_a = parentManager == null ? void 0 : parentManager.parentManager) == null ? void 0 : _a.state) == null ? void 0 : _b.name) || "" : props.name || ""; | ||
const nextName = props.reset ? isDirectParentAComponentTheme ? ((_a = parentManager == null ? void 0 : parentManager.state) == null ? void 0 : _a.name) || "" : ((_c = (_b = parentManager == null ? void 0 : parentManager.parentManager) == null ? void 0 : _b.state) == null ? void 0 : _c.name) || "" : props.name || ""; | ||
const { componentName } = props; | ||
const parentName = ((_c = parentManager == null ? void 0 : parentManager.state) == null ? void 0 : _c.name) || ""; | ||
const parentName = props.reset ? isDirectParentAComponentTheme ? ( | ||
// here because parentManager already skipped componentTheme so we have to only go up once | ||
((_d = parentManager == null ? void 0 : parentManager.parentManager) == null ? void 0 : _d.state.name) || "" | ||
) : ((_f = (_e = parentManager == null ? void 0 : parentManager.parentManager) == null ? void 0 : _e.parentManager) == null ? void 0 : _f.state.name) || "" : isDirectParentAComponentTheme ? allComponentThemes[0] || "" : (parentManager == null ? void 0 : parentManager.state.name) || ""; | ||
if (props.reset && isDirectParentAComponentTheme) { | ||
allComponentThemes.shift(); | ||
} | ||
const base = parentName.split(THEME_NAME_SEPARATOR); | ||
@@ -213,3 +220,3 @@ const lastSegment = base[base.length - 1]; | ||
} | ||
potentials = [...componentPotentials, ...potentials]; | ||
potentials = [...componentPotentials, ...potentials, ...allComponentThemes]; | ||
} | ||
@@ -243,5 +250,8 @@ const found = potentials.find((t) => t in themes); | ||
function getNonComponentParentManager(themeManager) { | ||
var _a; | ||
let res = themeManager; | ||
let componentThemeNames = []; | ||
while (res) { | ||
if (res == null ? void 0 : res.isComponent) { | ||
componentThemeNames.push((_a = res == null ? void 0 : res.state) == null ? void 0 : _a.name); | ||
res = res.parentManager; | ||
@@ -252,3 +262,3 @@ } else { | ||
} | ||
return res || null; | ||
return [res || null, componentThemeNames]; | ||
} | ||
@@ -255,0 +265,0 @@ export { |
@@ -8,4 +8,3 @@ import { isClient, isRSC, isServer, isWeb } from "@tamagui/constants"; | ||
ThemeManager, | ||
getHasThemeUpdatingProps, | ||
getNonComponentParentManager | ||
getHasThemeUpdatingProps | ||
} from "../helpers/ThemeManager"; | ||
@@ -116,12 +115,11 @@ import { ThemeManagerContext } from "../helpers/ThemeManagerContext"; | ||
} = props; | ||
const ogParentManager = useContext(ThemeManagerContext); | ||
const parentManager = useContext(ThemeManagerContext); | ||
const hasThemeUpdatingProps = getHasThemeUpdatingProps(props); | ||
const parentManager = disable || !hasThemeUpdatingProps ? ogParentManager : getNonComponentParentManager(ogParentManager); | ||
if (disable) { | ||
if (!ogParentManager) | ||
if (!parentManager) | ||
throw `\u274C`; | ||
return { | ||
isNewTheme: false, | ||
...ogParentManager.state, | ||
themeManager: ogParentManager | ||
...parentManager.state, | ||
themeManager: parentManager | ||
}; | ||
@@ -263,4 +261,4 @@ } | ||
} else { | ||
state2 = ogParentManager.state; | ||
themeManager2 = ogParentManager; | ||
state2 = parentManager.state; | ||
themeManager2 = parentManager; | ||
} | ||
@@ -267,0 +265,0 @@ } |
{ | ||
"name": "@tamagui/web", | ||
"version": "1.30.24", | ||
"version": "1.30.25", | ||
"source": "src/index.ts", | ||
@@ -30,9 +30,9 @@ "main": "dist/cjs", | ||
"dependencies": { | ||
"@tamagui/compose-refs": "1.30.24", | ||
"@tamagui/constants": "1.30.24", | ||
"@tamagui/helpers": "1.30.24", | ||
"@tamagui/normalize-css-color": "1.30.24", | ||
"@tamagui/use-did-finish-ssr": "1.30.24", | ||
"@tamagui/use-event": "1.30.24", | ||
"@tamagui/use-force-update": "1.30.24" | ||
"@tamagui/compose-refs": "1.30.25", | ||
"@tamagui/constants": "1.30.25", | ||
"@tamagui/helpers": "1.30.25", | ||
"@tamagui/normalize-css-color": "1.30.25", | ||
"@tamagui/use-did-finish-ssr": "1.30.25", | ||
"@tamagui/use-event": "1.30.25", | ||
"@tamagui/use-force-update": "1.30.25" | ||
}, | ||
@@ -43,3 +43,3 @@ "peerDependencies": { | ||
"devDependencies": { | ||
"@tamagui/build": "1.30.24", | ||
"@tamagui/build": "1.30.25", | ||
"@testing-library/react": "^13.4.0", | ||
@@ -46,0 +46,0 @@ "csstype": "^3.0.10", |
@@ -38,4 +38,4 @@ import { ThemeParsed, ThemeProps } from '../types'; | ||
} | ||
export declare function getNonComponentParentManager(themeManager?: ThemeManager | null): ThemeManager | null; | ||
export declare function getNonComponentParentManager(themeManager?: ThemeManager | null): readonly [ThemeManager | null, string[]]; | ||
export {}; | ||
//# sourceMappingURL=ThemeManager.d.ts.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1180280
24905
+ Added@tamagui/compose-refs@1.30.25(transitive)
+ Added@tamagui/constants@1.30.25(transitive)
+ Added@tamagui/helpers@1.30.25(transitive)
+ Added@tamagui/normalize-css-color@1.30.25(transitive)
+ Added@tamagui/simple-hash@1.30.25(transitive)
+ Added@tamagui/use-did-finish-ssr@1.30.25(transitive)
+ Added@tamagui/use-event@1.30.25(transitive)
+ Added@tamagui/use-force-update@1.30.25(transitive)
- Removed@tamagui/compose-refs@1.30.24(transitive)
- Removed@tamagui/constants@1.30.24(transitive)
- Removed@tamagui/helpers@1.30.24(transitive)
- Removed@tamagui/normalize-css-color@1.30.24(transitive)
- Removed@tamagui/simple-hash@1.30.24(transitive)
- Removed@tamagui/use-did-finish-ssr@1.30.24(transitive)
- Removed@tamagui/use-event@1.30.24(transitive)
- Removed@tamagui/use-force-update@1.30.24(transitive)
Updated@tamagui/constants@1.30.25
Updated@tamagui/helpers@1.30.25
Updated@tamagui/use-event@1.30.25