@tamagui/web 1.5.8 → 1.5.10
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/helpers/ThemeManager.js +4 -3
- package/dist/cjs/helpers/ThemeManager.js.map +2 -2
- package/dist/cjs/helpers/getThemeCSSRules.js +57 -40
- package/dist/cjs/helpers/getThemeCSSRules.js.map +2 -2
- package/dist/cjs/helpers/themes.js +10 -12
- package/dist/cjs/helpers/themes.js.map +2 -2
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +2 -2
- package/dist/esm/helpers/ThemeManager.js +4 -3
- package/dist/esm/helpers/ThemeManager.js.map +2 -2
- package/dist/esm/helpers/ThemeManager.mjs +4 -3
- package/dist/esm/helpers/ThemeManager.mjs.map +2 -2
- package/dist/esm/helpers/getThemeCSSRules.js +57 -40
- package/dist/esm/helpers/getThemeCSSRules.js.map +2 -2
- package/dist/esm/helpers/getThemeCSSRules.mjs +57 -40
- package/dist/esm/helpers/getThemeCSSRules.mjs.map +2 -2
- package/dist/esm/helpers/themes.js +10 -12
- package/dist/esm/helpers/themes.js.map +2 -2
- package/dist/esm/helpers/themes.mjs +10 -12
- package/dist/esm/helpers/themes.mjs.map +2 -2
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/index.mjs.map +2 -2
- package/package.json +9 -9
- package/src/helpers/ThemeManager.tsx +4 -4
- package/src/helpers/getThemeCSSRules.ts +82 -50
- package/src/helpers/themes.ts +10 -13
- package/src/index.ts +1 -0
- package/types/helpers/getThemeCSSRules.d.ts.map +1 -1
- package/types/helpers/themes.d.ts.map +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
|
@@ -23,63 +23,80 @@ function getThemeCSSRules({
|
|
|
23
23
|
vars += `--${simpleHash(themeKey, 40)}:${value};`;
|
|
24
24
|
}
|
|
25
25
|
const isDarkOrLightBase = themeName === "dark" || themeName === "light";
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
const selectorsSet = new Set(
|
|
27
|
+
names.map((name) => {
|
|
28
|
+
return `${CNP}${name}`;
|
|
29
|
+
})
|
|
30
|
+
);
|
|
29
31
|
if (hasDarkLight) {
|
|
30
32
|
for (const subName of names) {
|
|
31
|
-
const isDark =
|
|
32
|
-
const
|
|
33
|
+
const isDark = themeName === "dark" || subName.startsWith("dark_");
|
|
34
|
+
const maxDepth = config.maxDarkLightNesting ?? 3;
|
|
33
35
|
if (!(isDark || subName.startsWith("light_"))) {
|
|
34
|
-
|
|
36
|
+
selectorsSet.add(`:root:root ${CNP}${subName}`);
|
|
35
37
|
continue;
|
|
36
38
|
}
|
|
37
39
|
const childSelector = `${CNP}${subName.replace(isDark ? "dark_" : "light_", "")}`;
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const [
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
|
|
40
|
+
const [altLightDark, altSubTheme] = [
|
|
41
|
+
isDark ? ["dark", "light"] : ["light", "dark"],
|
|
42
|
+
isDark ? ["dark", "sub_theme"] : ["light", "sub_theme"]
|
|
43
|
+
];
|
|
44
|
+
for (const order of [altLightDark, altSubTheme]) {
|
|
45
|
+
if (isDarkOrLightBase) {
|
|
46
|
+
order.reverse();
|
|
47
|
+
}
|
|
48
|
+
const [stronger, weaker] = order;
|
|
49
|
+
const numSelectors = Math.round(maxDepth * 1.5);
|
|
50
|
+
for (let depth = 0; depth < numSelectors; depth++) {
|
|
51
|
+
const isOdd = depth % 2 === 1;
|
|
52
|
+
if (isOdd && depth < 3) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const parents = new Array(depth + 1).fill(0).map((_, psi) => {
|
|
56
|
+
return `${CNP}${psi % 2 === 0 ? stronger : weaker}`;
|
|
57
|
+
});
|
|
58
|
+
let parentSelectors = parents.length > 1 ? parents.slice(1) : parents;
|
|
59
|
+
if (isOdd) {
|
|
60
|
+
const [_first, second, ...rest] = parentSelectors;
|
|
61
|
+
parentSelectors = [second, ...rest, second];
|
|
62
|
+
}
|
|
63
|
+
const lastParentSelector = parentSelectors[parentSelectors.length - 1];
|
|
64
|
+
const nextChildSelector = childSelector === lastParentSelector ? "" : childSelector;
|
|
65
|
+
selectorsSet.add(`${parentSelectors.join(" ")} ${nextChildSelector}`.trim());
|
|
55
66
|
}
|
|
56
|
-
const lastParentSelector = parentSelectors[parentSelectors.length - 1];
|
|
57
|
-
selectors.push(
|
|
58
|
-
`${parentSelectors.join(" ")} ${childSelector === lastParentSelector ? "" : childSelector}`
|
|
59
|
-
);
|
|
60
67
|
}
|
|
61
68
|
}
|
|
62
69
|
}
|
|
70
|
+
const selectors = [...selectorsSet];
|
|
63
71
|
const selectorsString = selectors.map((x) => {
|
|
64
|
-
const
|
|
65
|
-
const rootSep = isBaseTheme && config.themeClassNameOnRoot ? "" : " ";
|
|
72
|
+
const rootSep = isBaseTheme(x) && config.themeClassNameOnRoot ? "" : " ";
|
|
66
73
|
return `:root${rootSep}${x}`;
|
|
67
|
-
});
|
|
68
|
-
const css = `${selectorsString
|
|
74
|
+
}).join(", ");
|
|
75
|
+
const css = `${selectorsString} {${vars}}`;
|
|
69
76
|
cssRuleSets.push(css);
|
|
70
|
-
if (config.shouldAddPrefersColorThemes
|
|
77
|
+
if (config.shouldAddPrefersColorThemes) {
|
|
78
|
+
const bgString = variableToString(theme.background);
|
|
79
|
+
const fgString = variableToString(theme.color);
|
|
80
|
+
const bodyRules = `body{background:${bgString};color:${fgString};}`;
|
|
71
81
|
const isDark = themeName.startsWith("dark");
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
)
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
)
|
|
82
|
+
const baseName = isDark ? "dark" : "light";
|
|
83
|
+
const lessSpecificSelectors = selectors.map((x) => {
|
|
84
|
+
if (x == darkSelector || x === lightSelector)
|
|
85
|
+
return `:root`;
|
|
86
|
+
return x.replace(/^\.t_(dark|light) /, "").trim();
|
|
87
|
+
}).filter(Boolean).join(", ");
|
|
88
|
+
const themeRules = `${lessSpecificSelectors} {${vars}}`;
|
|
89
|
+
const prefersMediaSelectors = `@media(prefers-color-scheme:${baseName}){
|
|
90
|
+
${bodyRules}
|
|
91
|
+
${themeRules}
|
|
92
|
+
}`;
|
|
93
|
+
cssRuleSets.push(prefersMediaSelectors);
|
|
80
94
|
}
|
|
81
95
|
return cssRuleSets;
|
|
82
96
|
}
|
|
97
|
+
const darkSelector = ".t_dark";
|
|
98
|
+
const lightSelector = ".t_light";
|
|
99
|
+
const isBaseTheme = (x) => x === darkSelector || x === lightSelector || x.startsWith(".t_dark ") || x.startsWith(".t_light ");
|
|
83
100
|
export {
|
|
84
101
|
getThemeCSSRules
|
|
85
102
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/getThemeCSSRules.ts"],
|
|
4
|
-
"sourcesContent": ["import { simpleHash } from '@tamagui/helpers'\n\nimport { THEME_CLASSNAME_PREFIX } from '../constants/constants.js'\nimport { Variable, variableToString } from '../createVariable.js'\nimport type { CreateTamaguiProps, ThemeParsed } from '../types.js'\nimport { tokensValueToVariable } from './registerCSSVariable.js'\n\nexport function getThemeCSSRules({\n config,\n themeName,\n theme,\n names,\n}: {\n config: CreateTamaguiProps\n themeName: string\n theme: ThemeParsed\n names: string[]\n}) {\n const cssRuleSets: string[] = []\n\n // special case for SSR\n const hasDarkLight = 'light' in config.themes && 'dark' in config.themes\n const CNP = `.${THEME_CLASSNAME_PREFIX}`\n let vars = ''\n\n // themeToVariableToValueMap.set(theme, {})\n // const varToValMap = themeToVariableToValueMap.get(theme)\n for (const themeKey in theme) {\n const variable = theme[themeKey] as Variable\n let value: any = null\n // if (varToValMap) {\n // varToValMap[variable.variable] = variable.val\n // }\n if (!tokensValueToVariable.has(variable.val)) {\n value = variable.val\n } else {\n value = tokensValueToVariable.get(variable.val)!.variable\n }\n // Hash themeKey in case it has invalid chars too\n vars += `--${simpleHash(themeKey, 40)}:${value};`\n }\n\n const isDarkOrLightBase = themeName === 'dark' || themeName === 'light'\n const
|
|
5
|
-
"mappings": "AAAA,SAAS,kBAAkB;AAE3B,SAAS,8BAA8B;AACvC,SAAmB,wBAAwB;AAE3C,SAAS,6BAA6B;AAE/B,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAKG;AACD,QAAM,cAAwB,CAAC;AAG/B,QAAM,eAAe,WAAW,OAAO,UAAU,UAAU,OAAO;AAClE,QAAM,MAAM,IAAI;AAChB,MAAI,OAAO;AAIX,aAAW,YAAY,OAAO;AAC5B,UAAM,WAAW,MAAM,QAAQ;AAC/B,QAAI,QAAa;AAIjB,QAAI,CAAC,sBAAsB,IAAI,SAAS,GAAG,GAAG;AAC5C,cAAQ,SAAS;AAAA,IACnB,OAAO;AACL,cAAQ,sBAAsB,IAAI,SAAS,GAAG,EAAG;AAAA,IACnD;AAEA,YAAQ,KAAK,WAAW,UAAU,EAAE,KAAK;AAAA,EAC3C;AAEA,QAAM,oBAAoB,cAAc,UAAU,cAAc;AAChE,QAAM,
|
|
4
|
+
"sourcesContent": ["import { simpleHash } from '@tamagui/helpers'\n\nimport { THEME_CLASSNAME_PREFIX } from '../constants/constants.js'\nimport { Variable, variableToString } from '../createVariable.js'\nimport type { CreateTamaguiProps, ThemeParsed } from '../types.js'\nimport { tokensValueToVariable } from './registerCSSVariable.js'\n\nexport function getThemeCSSRules({\n config,\n themeName,\n theme,\n names,\n}: {\n config: CreateTamaguiProps\n themeName: string\n theme: ThemeParsed\n names: string[]\n}) {\n const cssRuleSets: string[] = []\n\n // special case for SSR\n const hasDarkLight = 'light' in config.themes && 'dark' in config.themes\n const CNP = `.${THEME_CLASSNAME_PREFIX}`\n let vars = ''\n\n // themeToVariableToValueMap.set(theme, {})\n // const varToValMap = themeToVariableToValueMap.get(theme)\n for (const themeKey in theme) {\n const variable = theme[themeKey] as Variable\n let value: any = null\n // if (varToValMap) {\n // varToValMap[variable.variable] = variable.val\n // }\n if (!tokensValueToVariable.has(variable.val)) {\n value = variable.val\n } else {\n value = tokensValueToVariable.get(variable.val)!.variable\n }\n // Hash themeKey in case it has invalid chars too\n vars += `--${simpleHash(themeKey, 40)}:${value};`\n }\n\n const isDarkOrLightBase = themeName === 'dark' || themeName === 'light'\n const selectorsSet = new Set(\n names.map((name) => {\n return `${CNP}${name}`\n })\n )\n\n // since we dont specify dark/light in classnames we have to do an awkward specificity war\n // use config.maxDarkLightNesting to determine how deep you can nest until it breaks\n if (hasDarkLight) {\n for (const subName of names) {\n const isDark = themeName === 'dark' || subName.startsWith('dark_')\n const maxDepth = config.maxDarkLightNesting ?? 3\n\n if (!(isDark || subName.startsWith('light_'))) {\n // neither light nor dark subtheme, just generate one selector with :root:root which\n // will override all :root light/dark selectors generated below\n selectorsSet.add(`:root:root ${CNP}${subName}`)\n continue\n }\n\n const childSelector = `${CNP}${subName.replace(isDark ? 'dark_' : 'light_', '')}`\n\n const [altLightDark, altSubTheme] = [\n isDark ? ['dark', 'light'] : ['light', 'dark'],\n isDark ? ['dark', 'sub_theme'] : ['light', 'sub_theme'],\n ]\n\n for (const order of [altLightDark, altSubTheme]) {\n if (isDarkOrLightBase) {\n order.reverse()\n }\n const [stronger, weaker] = order\n const numSelectors = Math.round(maxDepth * 1.5)\n\n for (let depth = 0; depth < numSelectors; depth++) {\n const isOdd = depth % 2 === 1\n\n // wtf is this continue:\n if (isOdd && depth < 3) {\n continue\n }\n\n const parents = new Array(depth + 1).fill(0).map((_, psi) => {\n return `${CNP}${psi % 2 === 0 ? stronger : weaker}`\n })\n\n let parentSelectors = parents.length > 1 ? parents.slice(1) : parents\n\n if (isOdd) {\n const [_first, second, ...rest] = parentSelectors\n parentSelectors = [second, ...rest, second]\n }\n\n const lastParentSelector = parentSelectors[parentSelectors.length - 1]\n const nextChildSelector =\n childSelector === lastParentSelector ? '' : childSelector\n\n // for light/dark/light:\n selectorsSet.add(`${parentSelectors.join(' ')} ${nextChildSelector}`.trim())\n }\n }\n }\n }\n\n const selectors = [...selectorsSet]\n\n // only do our :root attach if it's not light/dark - not support sub themes on root saves a lot of effort/size\n // this isBaseTheme logic could probably be done more efficiently above\n const selectorsString = selectors\n .map((x) => {\n const rootSep = isBaseTheme(x) && config.themeClassNameOnRoot ? '' : ' '\n return `:root${rootSep}${x}`\n })\n .join(', ')\n\n const css = `${selectorsString} {${vars}}`\n cssRuleSets.push(css)\n\n if (config.shouldAddPrefersColorThemes) {\n const bgString = variableToString(theme.background)\n const fgString = variableToString(theme.color)\n const bodyRules = `body{background:${bgString};color:${fgString};}`\n const isDark = themeName.startsWith('dark')\n const baseName = isDark ? 'dark' : 'light'\n const lessSpecificSelectors = selectors\n .map((x) => {\n if (x == darkSelector || x === lightSelector) return `:root`\n return x.replace(/^\\.t_(dark|light) /, '').trim()\n })\n .filter(Boolean)\n .join(', ')\n const themeRules = `${lessSpecificSelectors} {${vars}}`\n const prefersMediaSelectors = `@media(prefers-color-scheme:${baseName}){\n ${bodyRules}\n ${themeRules}\n}`\n cssRuleSets.push(prefersMediaSelectors)\n }\n\n return cssRuleSets\n}\n\nconst darkSelector = '.t_dark'\nconst lightSelector = '.t_light'\nconst isBaseTheme = (x: string) =>\n x === darkSelector ||\n x === lightSelector ||\n x.startsWith('.t_dark ') ||\n x.startsWith('.t_light ')\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -23,63 +23,80 @@ function getThemeCSSRules({
|
|
|
23
23
|
vars += `--${simpleHash(themeKey, 40)}:${value};`;
|
|
24
24
|
}
|
|
25
25
|
const isDarkOrLightBase = themeName === "dark" || themeName === "light";
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
const selectorsSet = new Set(
|
|
27
|
+
names.map((name) => {
|
|
28
|
+
return `${CNP}${name}`;
|
|
29
|
+
})
|
|
30
|
+
);
|
|
29
31
|
if (hasDarkLight) {
|
|
30
32
|
for (const subName of names) {
|
|
31
|
-
const isDark =
|
|
32
|
-
const
|
|
33
|
+
const isDark = themeName === "dark" || subName.startsWith("dark_");
|
|
34
|
+
const maxDepth = config.maxDarkLightNesting ?? 3;
|
|
33
35
|
if (!(isDark || subName.startsWith("light_"))) {
|
|
34
|
-
|
|
36
|
+
selectorsSet.add(`:root:root ${CNP}${subName}`);
|
|
35
37
|
continue;
|
|
36
38
|
}
|
|
37
39
|
const childSelector = `${CNP}${subName.replace(isDark ? "dark_" : "light_", "")}`;
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const [
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
|
|
40
|
+
const [altLightDark, altSubTheme] = [
|
|
41
|
+
isDark ? ["dark", "light"] : ["light", "dark"],
|
|
42
|
+
isDark ? ["dark", "sub_theme"] : ["light", "sub_theme"]
|
|
43
|
+
];
|
|
44
|
+
for (const order of [altLightDark, altSubTheme]) {
|
|
45
|
+
if (isDarkOrLightBase) {
|
|
46
|
+
order.reverse();
|
|
47
|
+
}
|
|
48
|
+
const [stronger, weaker] = order;
|
|
49
|
+
const numSelectors = Math.round(maxDepth * 1.5);
|
|
50
|
+
for (let depth = 0; depth < numSelectors; depth++) {
|
|
51
|
+
const isOdd = depth % 2 === 1;
|
|
52
|
+
if (isOdd && depth < 3) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const parents = new Array(depth + 1).fill(0).map((_, psi) => {
|
|
56
|
+
return `${CNP}${psi % 2 === 0 ? stronger : weaker}`;
|
|
57
|
+
});
|
|
58
|
+
let parentSelectors = parents.length > 1 ? parents.slice(1) : parents;
|
|
59
|
+
if (isOdd) {
|
|
60
|
+
const [_first, second, ...rest] = parentSelectors;
|
|
61
|
+
parentSelectors = [second, ...rest, second];
|
|
62
|
+
}
|
|
63
|
+
const lastParentSelector = parentSelectors[parentSelectors.length - 1];
|
|
64
|
+
const nextChildSelector = childSelector === lastParentSelector ? "" : childSelector;
|
|
65
|
+
selectorsSet.add(`${parentSelectors.join(" ")} ${nextChildSelector}`.trim());
|
|
55
66
|
}
|
|
56
|
-
const lastParentSelector = parentSelectors[parentSelectors.length - 1];
|
|
57
|
-
selectors.push(
|
|
58
|
-
`${parentSelectors.join(" ")} ${childSelector === lastParentSelector ? "" : childSelector}`
|
|
59
|
-
);
|
|
60
67
|
}
|
|
61
68
|
}
|
|
62
69
|
}
|
|
70
|
+
const selectors = [...selectorsSet];
|
|
63
71
|
const selectorsString = selectors.map((x) => {
|
|
64
|
-
const
|
|
65
|
-
const rootSep = isBaseTheme && config.themeClassNameOnRoot ? "" : " ";
|
|
72
|
+
const rootSep = isBaseTheme(x) && config.themeClassNameOnRoot ? "" : " ";
|
|
66
73
|
return `:root${rootSep}${x}`;
|
|
67
|
-
});
|
|
68
|
-
const css = `${selectorsString
|
|
74
|
+
}).join(", ");
|
|
75
|
+
const css = `${selectorsString} {${vars}}`;
|
|
69
76
|
cssRuleSets.push(css);
|
|
70
|
-
if (config.shouldAddPrefersColorThemes
|
|
77
|
+
if (config.shouldAddPrefersColorThemes) {
|
|
78
|
+
const bgString = variableToString(theme.background);
|
|
79
|
+
const fgString = variableToString(theme.color);
|
|
80
|
+
const bodyRules = `body{background:${bgString};color:${fgString};}`;
|
|
71
81
|
const isDark = themeName.startsWith("dark");
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
)
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
)
|
|
82
|
+
const baseName = isDark ? "dark" : "light";
|
|
83
|
+
const lessSpecificSelectors = selectors.map((x) => {
|
|
84
|
+
if (x == darkSelector || x === lightSelector)
|
|
85
|
+
return `:root`;
|
|
86
|
+
return x.replace(/^\.t_(dark|light) /, "").trim();
|
|
87
|
+
}).filter(Boolean).join(", ");
|
|
88
|
+
const themeRules = `${lessSpecificSelectors} {${vars}}`;
|
|
89
|
+
const prefersMediaSelectors = `@media(prefers-color-scheme:${baseName}){
|
|
90
|
+
${bodyRules}
|
|
91
|
+
${themeRules}
|
|
92
|
+
}`;
|
|
93
|
+
cssRuleSets.push(prefersMediaSelectors);
|
|
80
94
|
}
|
|
81
95
|
return cssRuleSets;
|
|
82
96
|
}
|
|
97
|
+
const darkSelector = ".t_dark";
|
|
98
|
+
const lightSelector = ".t_light";
|
|
99
|
+
const isBaseTheme = (x) => x === darkSelector || x === lightSelector || x.startsWith(".t_dark ") || x.startsWith(".t_light ");
|
|
83
100
|
export {
|
|
84
101
|
getThemeCSSRules
|
|
85
102
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/getThemeCSSRules.ts"],
|
|
4
|
-
"sourcesContent": ["import { simpleHash } from '@tamagui/helpers'\n\nimport { THEME_CLASSNAME_PREFIX } from '../constants/constants.js'\nimport { Variable, variableToString } from '../createVariable.js'\nimport type { CreateTamaguiProps, ThemeParsed } from '../types.js'\nimport { tokensValueToVariable } from './registerCSSVariable.js'\n\nexport function getThemeCSSRules({\n config,\n themeName,\n theme,\n names,\n}: {\n config: CreateTamaguiProps\n themeName: string\n theme: ThemeParsed\n names: string[]\n}) {\n const cssRuleSets: string[] = []\n\n // special case for SSR\n const hasDarkLight = 'light' in config.themes && 'dark' in config.themes\n const CNP = `.${THEME_CLASSNAME_PREFIX}`\n let vars = ''\n\n // themeToVariableToValueMap.set(theme, {})\n // const varToValMap = themeToVariableToValueMap.get(theme)\n for (const themeKey in theme) {\n const variable = theme[themeKey] as Variable\n let value: any = null\n // if (varToValMap) {\n // varToValMap[variable.variable] = variable.val\n // }\n if (!tokensValueToVariable.has(variable.val)) {\n value = variable.val\n } else {\n value = tokensValueToVariable.get(variable.val)!.variable\n }\n // Hash themeKey in case it has invalid chars too\n vars += `--${simpleHash(themeKey, 40)}:${value};`\n }\n\n const isDarkOrLightBase = themeName === 'dark' || themeName === 'light'\n const
|
|
5
|
-
"mappings": "AAAA,SAAS,kBAAkB;AAE3B,SAAS,8BAA8B;AACvC,SAAmB,wBAAwB;AAE3C,SAAS,6BAA6B;AAE/B,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAKG;AACD,QAAM,cAAwB,CAAC;AAG/B,QAAM,eAAe,WAAW,OAAO,UAAU,UAAU,OAAO;AAClE,QAAM,MAAM,IAAI;AAChB,MAAI,OAAO;AAIX,aAAW,YAAY,OAAO;AAC5B,UAAM,WAAW,MAAM,QAAQ;AAC/B,QAAI,QAAa;AAIjB,QAAI,CAAC,sBAAsB,IAAI,SAAS,GAAG,GAAG;AAC5C,cAAQ,SAAS;AAAA,IACnB,OAAO;AACL,cAAQ,sBAAsB,IAAI,SAAS,GAAG,EAAG;AAAA,IACnD;AAEA,YAAQ,KAAK,WAAW,UAAU,EAAE,KAAK;AAAA,EAC3C;AAEA,QAAM,oBAAoB,cAAc,UAAU,cAAc;AAChE,QAAM,
|
|
4
|
+
"sourcesContent": ["import { simpleHash } from '@tamagui/helpers'\n\nimport { THEME_CLASSNAME_PREFIX } from '../constants/constants.js'\nimport { Variable, variableToString } from '../createVariable.js'\nimport type { CreateTamaguiProps, ThemeParsed } from '../types.js'\nimport { tokensValueToVariable } from './registerCSSVariable.js'\n\nexport function getThemeCSSRules({\n config,\n themeName,\n theme,\n names,\n}: {\n config: CreateTamaguiProps\n themeName: string\n theme: ThemeParsed\n names: string[]\n}) {\n const cssRuleSets: string[] = []\n\n // special case for SSR\n const hasDarkLight = 'light' in config.themes && 'dark' in config.themes\n const CNP = `.${THEME_CLASSNAME_PREFIX}`\n let vars = ''\n\n // themeToVariableToValueMap.set(theme, {})\n // const varToValMap = themeToVariableToValueMap.get(theme)\n for (const themeKey in theme) {\n const variable = theme[themeKey] as Variable\n let value: any = null\n // if (varToValMap) {\n // varToValMap[variable.variable] = variable.val\n // }\n if (!tokensValueToVariable.has(variable.val)) {\n value = variable.val\n } else {\n value = tokensValueToVariable.get(variable.val)!.variable\n }\n // Hash themeKey in case it has invalid chars too\n vars += `--${simpleHash(themeKey, 40)}:${value};`\n }\n\n const isDarkOrLightBase = themeName === 'dark' || themeName === 'light'\n const selectorsSet = new Set(\n names.map((name) => {\n return `${CNP}${name}`\n })\n )\n\n // since we dont specify dark/light in classnames we have to do an awkward specificity war\n // use config.maxDarkLightNesting to determine how deep you can nest until it breaks\n if (hasDarkLight) {\n for (const subName of names) {\n const isDark = themeName === 'dark' || subName.startsWith('dark_')\n const maxDepth = config.maxDarkLightNesting ?? 3\n\n if (!(isDark || subName.startsWith('light_'))) {\n // neither light nor dark subtheme, just generate one selector with :root:root which\n // will override all :root light/dark selectors generated below\n selectorsSet.add(`:root:root ${CNP}${subName}`)\n continue\n }\n\n const childSelector = `${CNP}${subName.replace(isDark ? 'dark_' : 'light_', '')}`\n\n const [altLightDark, altSubTheme] = [\n isDark ? ['dark', 'light'] : ['light', 'dark'],\n isDark ? ['dark', 'sub_theme'] : ['light', 'sub_theme'],\n ]\n\n for (const order of [altLightDark, altSubTheme]) {\n if (isDarkOrLightBase) {\n order.reverse()\n }\n const [stronger, weaker] = order\n const numSelectors = Math.round(maxDepth * 1.5)\n\n for (let depth = 0; depth < numSelectors; depth++) {\n const isOdd = depth % 2 === 1\n\n // wtf is this continue:\n if (isOdd && depth < 3) {\n continue\n }\n\n const parents = new Array(depth + 1).fill(0).map((_, psi) => {\n return `${CNP}${psi % 2 === 0 ? stronger : weaker}`\n })\n\n let parentSelectors = parents.length > 1 ? parents.slice(1) : parents\n\n if (isOdd) {\n const [_first, second, ...rest] = parentSelectors\n parentSelectors = [second, ...rest, second]\n }\n\n const lastParentSelector = parentSelectors[parentSelectors.length - 1]\n const nextChildSelector =\n childSelector === lastParentSelector ? '' : childSelector\n\n // for light/dark/light:\n selectorsSet.add(`${parentSelectors.join(' ')} ${nextChildSelector}`.trim())\n }\n }\n }\n }\n\n const selectors = [...selectorsSet]\n\n // only do our :root attach if it's not light/dark - not support sub themes on root saves a lot of effort/size\n // this isBaseTheme logic could probably be done more efficiently above\n const selectorsString = selectors\n .map((x) => {\n const rootSep = isBaseTheme(x) && config.themeClassNameOnRoot ? '' : ' '\n return `:root${rootSep}${x}`\n })\n .join(', ')\n\n const css = `${selectorsString} {${vars}}`\n cssRuleSets.push(css)\n\n if (config.shouldAddPrefersColorThemes) {\n const bgString = variableToString(theme.background)\n const fgString = variableToString(theme.color)\n const bodyRules = `body{background:${bgString};color:${fgString};}`\n const isDark = themeName.startsWith('dark')\n const baseName = isDark ? 'dark' : 'light'\n const lessSpecificSelectors = selectors\n .map((x) => {\n if (x == darkSelector || x === lightSelector) return `:root`\n return x.replace(/^\\.t_(dark|light) /, '').trim()\n })\n .filter(Boolean)\n .join(', ')\n const themeRules = `${lessSpecificSelectors} {${vars}}`\n const prefersMediaSelectors = `@media(prefers-color-scheme:${baseName}){\n ${bodyRules}\n ${themeRules}\n}`\n cssRuleSets.push(prefersMediaSelectors)\n }\n\n return cssRuleSets\n}\n\nconst darkSelector = '.t_dark'\nconst lightSelector = '.t_light'\nconst isBaseTheme = (x: string) =>\n x === darkSelector ||\n x === lightSelector ||\n x.startsWith('.t_dark ') ||\n x.startsWith('.t_light ')\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -25,21 +25,19 @@ function proxyThemeToParents(themeName, theme, themes) {
|
|
|
25
25
|
cur.push(part);
|
|
26
26
|
return cur.join("_");
|
|
27
27
|
});
|
|
28
|
-
const
|
|
28
|
+
const numParents = parents.length;
|
|
29
29
|
return new Proxy(theme, {
|
|
30
30
|
get(target, key) {
|
|
31
|
-
if (key === GetThemeUnwrapped)
|
|
31
|
+
if (key === GetThemeUnwrapped)
|
|
32
32
|
return theme;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (Reflect.has(parent, key)) {
|
|
42
|
-
return Reflect.get(parent, key);
|
|
33
|
+
if (numParents && !Reflect.has(target, key)) {
|
|
34
|
+
for (let i = numParents - 1; i >= 0; i--) {
|
|
35
|
+
const parent = themes[parents[i]];
|
|
36
|
+
if (!parent)
|
|
37
|
+
continue;
|
|
38
|
+
if (Reflect.has(parent, key)) {
|
|
39
|
+
return Reflect.get(parent, key);
|
|
40
|
+
}
|
|
43
41
|
}
|
|
44
42
|
}
|
|
45
43
|
return Reflect.get(target, key);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/themes.ts"],
|
|
4
|
-
"sourcesContent": ["import { createVariable, isVariable } from '../createVariable.js'\nimport { GetThemeUnwrapped } from '../hooks/getThemeUnwrapped.js'\nimport { CreateTamaguiProps } from '../types.js'\n\n// mutates, freeze after\n// shared by createTamagui so extracted here\nexport function ensureThemeVariable(theme: any, key: string) {\n const val = theme[key]\n const themeKey = key\n if (!isVariable(val)) {\n theme[key] = createVariable({\n key: themeKey,\n name: themeKey,\n val,\n })\n } else {\n if (val.name !== themeKey) {\n // rename to theme name\n theme[key] = createVariable({\n key: val.name,\n name: themeKey,\n val: val.val,\n })\n }\n }\n}\n\nexport function proxyThemeToParents(\n themeName: string,\n theme: any,\n themes: CreateTamaguiProps['themes']\n) {\n // we could test if this is better as just a straight object spread or fancier proxy\n const cur: string[] = []\n // if theme is dark_blue_alt1_Button\n // this will be the parent names in order: ['dark', 'dark_blue', 'dark_blue_alt1\"]\n const parents = themeName\n .split('_')\n .slice(0, -1)\n .map((part) => {\n cur.push(part)\n return cur.join('_')\n })\n\n const
|
|
5
|
-
"mappings": "AAAA,SAAS,gBAAgB,kBAAkB;AAC3C,SAAS,yBAAyB;AAK3B,SAAS,oBAAoB,OAAY,KAAa;AAC3D,QAAM,MAAM,MAAM,GAAG;AACrB,QAAM,WAAW;AACjB,MAAI,CAAC,WAAW,GAAG,GAAG;AACpB,UAAM,GAAG,IAAI,eAAe;AAAA,MAC1B,KAAK;AAAA,MACL,MAAM;AAAA,MACN;AAAA,IACF,CAAC;AAAA,EACH,OAAO;AACL,QAAI,IAAI,SAAS,UAAU;AAEzB,YAAM,GAAG,IAAI,eAAe;AAAA,QAC1B,KAAK,IAAI;AAAA,QACT,MAAM;AAAA,QACN,KAAK,IAAI;AAAA,MACX,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,SAAS,oBACd,WACA,OACA,QACA;AAEA,QAAM,MAAgB,CAAC;AAGvB,QAAM,UAAU,UACb,MAAM,GAAG,EACT,MAAM,GAAG,EAAE,EACX,IAAI,CAAC,SAAS;AACb,QAAI,KAAK,IAAI;AACb,WAAO,IAAI,KAAK,GAAG;AAAA,EACrB,CAAC;AAEH,QAAM,
|
|
4
|
+
"sourcesContent": ["import { createVariable, isVariable } from '../createVariable.js'\nimport { GetThemeUnwrapped } from '../hooks/getThemeUnwrapped.js'\nimport { CreateTamaguiProps } from '../types.js'\n\n// mutates, freeze after\n// shared by createTamagui so extracted here\nexport function ensureThemeVariable(theme: any, key: string) {\n const val = theme[key]\n const themeKey = key\n if (!isVariable(val)) {\n theme[key] = createVariable({\n key: themeKey,\n name: themeKey,\n val,\n })\n } else {\n if (val.name !== themeKey) {\n // rename to theme name\n theme[key] = createVariable({\n key: val.name,\n name: themeKey,\n val: val.val,\n })\n }\n }\n}\n\nexport function proxyThemeToParents(\n themeName: string,\n theme: any,\n themes: CreateTamaguiProps['themes']\n) {\n // we could test if this is better as just a straight object spread or fancier proxy\n const cur: string[] = []\n // if theme is dark_blue_alt1_Button\n // this will be the parent names in order: ['dark', 'dark_blue', 'dark_blue_alt1\"]\n const parents = themeName\n .split('_')\n .slice(0, -1)\n .map((part) => {\n cur.push(part)\n return cur.join('_')\n })\n\n const numParents = parents.length\n\n // proxy fallback values to parent theme values\n return new Proxy(theme, {\n get(target, key) {\n if (key === GetThemeUnwrapped) return theme\n if (numParents && !Reflect.has(target, key)) {\n // check parents\n for (let i = numParents - 1; i >= 0; i--) {\n const parent = themes[parents[i]]\n if (!parent) continue\n if (Reflect.has(parent, key)) {\n return Reflect.get(parent, key)\n }\n }\n }\n return Reflect.get(target, key)\n },\n })\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,gBAAgB,kBAAkB;AAC3C,SAAS,yBAAyB;AAK3B,SAAS,oBAAoB,OAAY,KAAa;AAC3D,QAAM,MAAM,MAAM,GAAG;AACrB,QAAM,WAAW;AACjB,MAAI,CAAC,WAAW,GAAG,GAAG;AACpB,UAAM,GAAG,IAAI,eAAe;AAAA,MAC1B,KAAK;AAAA,MACL,MAAM;AAAA,MACN;AAAA,IACF,CAAC;AAAA,EACH,OAAO;AACL,QAAI,IAAI,SAAS,UAAU;AAEzB,YAAM,GAAG,IAAI,eAAe;AAAA,QAC1B,KAAK,IAAI;AAAA,QACT,MAAM;AAAA,QACN,KAAK,IAAI;AAAA,MACX,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,SAAS,oBACd,WACA,OACA,QACA;AAEA,QAAM,MAAgB,CAAC;AAGvB,QAAM,UAAU,UACb,MAAM,GAAG,EACT,MAAM,GAAG,EAAE,EACX,IAAI,CAAC,SAAS;AACb,QAAI,KAAK,IAAI;AACb,WAAO,IAAI,KAAK,GAAG;AAAA,EACrB,CAAC;AAEH,QAAM,aAAa,QAAQ;AAG3B,SAAO,IAAI,MAAM,OAAO;AAAA,IACtB,IAAI,QAAQ,KAAK;AACf,UAAI,QAAQ;AAAmB,eAAO;AACtC,UAAI,cAAc,CAAC,QAAQ,IAAI,QAAQ,GAAG,GAAG;AAE3C,iBAAS,IAAI,aAAa,GAAG,KAAK,GAAG,KAAK;AACxC,gBAAM,SAAS,OAAO,QAAQ,CAAC,CAAC;AAChC,cAAI,CAAC;AAAQ;AACb,cAAI,QAAQ,IAAI,QAAQ,GAAG,GAAG;AAC5B,mBAAO,QAAQ,IAAI,QAAQ,GAAG;AAAA,UAChC;AAAA,QACF;AAAA,MACF;AACA,aAAO,QAAQ,IAAI,QAAQ,GAAG;AAAA,IAChC;AAAA,EACF,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -25,21 +25,19 @@ function proxyThemeToParents(themeName, theme, themes) {
|
|
|
25
25
|
cur.push(part);
|
|
26
26
|
return cur.join("_");
|
|
27
27
|
});
|
|
28
|
-
const
|
|
28
|
+
const numParents = parents.length;
|
|
29
29
|
return new Proxy(theme, {
|
|
30
30
|
get(target, key) {
|
|
31
|
-
if (key === GetThemeUnwrapped)
|
|
31
|
+
if (key === GetThemeUnwrapped)
|
|
32
32
|
return theme;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (Reflect.has(parent, key)) {
|
|
42
|
-
return Reflect.get(parent, key);
|
|
33
|
+
if (numParents && !Reflect.has(target, key)) {
|
|
34
|
+
for (let i = numParents - 1; i >= 0; i--) {
|
|
35
|
+
const parent = themes[parents[i]];
|
|
36
|
+
if (!parent)
|
|
37
|
+
continue;
|
|
38
|
+
if (Reflect.has(parent, key)) {
|
|
39
|
+
return Reflect.get(parent, key);
|
|
40
|
+
}
|
|
43
41
|
}
|
|
44
42
|
}
|
|
45
43
|
return Reflect.get(target, key);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/themes.ts"],
|
|
4
|
-
"sourcesContent": ["import { createVariable, isVariable } from '../createVariable.js'\nimport { GetThemeUnwrapped } from '../hooks/getThemeUnwrapped.js'\nimport { CreateTamaguiProps } from '../types.js'\n\n// mutates, freeze after\n// shared by createTamagui so extracted here\nexport function ensureThemeVariable(theme: any, key: string) {\n const val = theme[key]\n const themeKey = key\n if (!isVariable(val)) {\n theme[key] = createVariable({\n key: themeKey,\n name: themeKey,\n val,\n })\n } else {\n if (val.name !== themeKey) {\n // rename to theme name\n theme[key] = createVariable({\n key: val.name,\n name: themeKey,\n val: val.val,\n })\n }\n }\n}\n\nexport function proxyThemeToParents(\n themeName: string,\n theme: any,\n themes: CreateTamaguiProps['themes']\n) {\n // we could test if this is better as just a straight object spread or fancier proxy\n const cur: string[] = []\n // if theme is dark_blue_alt1_Button\n // this will be the parent names in order: ['dark', 'dark_blue', 'dark_blue_alt1\"]\n const parents = themeName\n .split('_')\n .slice(0, -1)\n .map((part) => {\n cur.push(part)\n return cur.join('_')\n })\n\n const
|
|
5
|
-
"mappings": "AAAA,SAAS,gBAAgB,kBAAkB;AAC3C,SAAS,yBAAyB;AAK3B,SAAS,oBAAoB,OAAY,KAAa;AAC3D,QAAM,MAAM,MAAM,GAAG;AACrB,QAAM,WAAW;AACjB,MAAI,CAAC,WAAW,GAAG,GAAG;AACpB,UAAM,GAAG,IAAI,eAAe;AAAA,MAC1B,KAAK;AAAA,MACL,MAAM;AAAA,MACN;AAAA,IACF,CAAC;AAAA,EACH,OAAO;AACL,QAAI,IAAI,SAAS,UAAU;AAEzB,YAAM,GAAG,IAAI,eAAe;AAAA,QAC1B,KAAK,IAAI;AAAA,QACT,MAAM;AAAA,QACN,KAAK,IAAI;AAAA,MACX,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,SAAS,oBACd,WACA,OACA,QACA;AAEA,QAAM,MAAgB,CAAC;AAGvB,QAAM,UAAU,UACb,MAAM,GAAG,EACT,MAAM,GAAG,EAAE,EACX,IAAI,CAAC,SAAS;AACb,QAAI,KAAK,IAAI;AACb,WAAO,IAAI,KAAK,GAAG;AAAA,EACrB,CAAC;AAEH,QAAM,
|
|
4
|
+
"sourcesContent": ["import { createVariable, isVariable } from '../createVariable.js'\nimport { GetThemeUnwrapped } from '../hooks/getThemeUnwrapped.js'\nimport { CreateTamaguiProps } from '../types.js'\n\n// mutates, freeze after\n// shared by createTamagui so extracted here\nexport function ensureThemeVariable(theme: any, key: string) {\n const val = theme[key]\n const themeKey = key\n if (!isVariable(val)) {\n theme[key] = createVariable({\n key: themeKey,\n name: themeKey,\n val,\n })\n } else {\n if (val.name !== themeKey) {\n // rename to theme name\n theme[key] = createVariable({\n key: val.name,\n name: themeKey,\n val: val.val,\n })\n }\n }\n}\n\nexport function proxyThemeToParents(\n themeName: string,\n theme: any,\n themes: CreateTamaguiProps['themes']\n) {\n // we could test if this is better as just a straight object spread or fancier proxy\n const cur: string[] = []\n // if theme is dark_blue_alt1_Button\n // this will be the parent names in order: ['dark', 'dark_blue', 'dark_blue_alt1\"]\n const parents = themeName\n .split('_')\n .slice(0, -1)\n .map((part) => {\n cur.push(part)\n return cur.join('_')\n })\n\n const numParents = parents.length\n\n // proxy fallback values to parent theme values\n return new Proxy(theme, {\n get(target, key) {\n if (key === GetThemeUnwrapped) return theme\n if (numParents && !Reflect.has(target, key)) {\n // check parents\n for (let i = numParents - 1; i >= 0; i--) {\n const parent = themes[parents[i]]\n if (!parent) continue\n if (Reflect.has(parent, key)) {\n return Reflect.get(parent, key)\n }\n }\n }\n return Reflect.get(target, key)\n },\n })\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,gBAAgB,kBAAkB;AAC3C,SAAS,yBAAyB;AAK3B,SAAS,oBAAoB,OAAY,KAAa;AAC3D,QAAM,MAAM,MAAM,GAAG;AACrB,QAAM,WAAW;AACjB,MAAI,CAAC,WAAW,GAAG,GAAG;AACpB,UAAM,GAAG,IAAI,eAAe;AAAA,MAC1B,KAAK;AAAA,MACL,MAAM;AAAA,MACN;AAAA,IACF,CAAC;AAAA,EACH,OAAO;AACL,QAAI,IAAI,SAAS,UAAU;AAEzB,YAAM,GAAG,IAAI,eAAe;AAAA,QAC1B,KAAK,IAAI;AAAA,QACT,MAAM;AAAA,QACN,KAAK,IAAI;AAAA,MACX,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,SAAS,oBACd,WACA,OACA,QACA;AAEA,QAAM,MAAgB,CAAC;AAGvB,QAAM,UAAU,UACb,MAAM,GAAG,EACT,MAAM,GAAG,EAAE,EACX,IAAI,CAAC,SAAS;AACb,QAAI,KAAK,IAAI;AACb,WAAO,IAAI,KAAK,GAAG;AAAA,EACrB,CAAC;AAEH,QAAM,aAAa,QAAQ;AAG3B,SAAO,IAAI,MAAM,OAAO;AAAA,IACtB,IAAI,QAAQ,KAAK;AACf,UAAI,QAAQ;AAAmB,eAAO;AACtC,UAAI,cAAc,CAAC,QAAQ,IAAI,QAAQ,GAAG,GAAG;AAE3C,iBAAS,IAAI,aAAa,GAAG,KAAK,GAAG,KAAK;AACxC,gBAAM,SAAS,OAAO,QAAQ,CAAC,CAAC;AAChC,cAAI,CAAC;AAAQ;AACb,cAAI,QAAQ,IAAI,QAAQ,GAAG,GAAG;AAC5B,mBAAO,QAAQ,IAAI,QAAQ,GAAG;AAAA,UAChC;AAAA,QACF;AAAA,MACF;AACA,aAAO,QAAQ,IAAI,QAAQ,GAAG;AAAA,IAChC;AAAA,EACF,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -30,6 +30,7 @@ export * from "./helpers/matchMedia.js";
|
|
|
30
30
|
export * from "./helpers/proxyThemeVariables.js";
|
|
31
31
|
export * from "./helpers/themeable.js";
|
|
32
32
|
export * from "./helpers/withStaticProperties.js";
|
|
33
|
+
export * from "./helpers/normalizeColor.js";
|
|
33
34
|
export * from "./contexts/ButtonNestingContext.js";
|
|
34
35
|
export * from "./hooks/useId.js";
|
|
35
36
|
export * from "./hooks/useIsTouchDevice.js";
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './Tamagui.js'\nexport * from './createComponent.js'\nexport * from './createShorthands.js'\nexport * from './createTheme.js'\nexport * from './createTamagui.js'\nexport * from './createFont.js'\nexport * from './createTokens.js'\nexport * from './createVariable.js'\nexport * from './createVariables.js'\nexport * from './insertFont.js'\nexport * from './addTheme.js'\nexport * from './updateTheme.js'\nexport * from './styled.js'\nexport * from './types.js'\nexport * from './setupReactNative.js'\n\nexport { getConfig, getThemes, getTokens, onConfiguredOnce } from './config.js'\n\nexport * from './constants/constants.js'\n\nexport * from './helpers/useShallowSetState.js'\nexport * from './helpers/getVariantExtras.js'\nexport * from './helpers/getAnimationDriver.js'\nexport * from './helpers/getExpandedShorthands.js'\nexport * from './helpers/getSplitStyles.js'\nexport * from './helpers/getStylesAtomic.js'\nexport * from './helpers/pseudoDescriptors.js'\nexport * from './helpers/mergeProps.js'\nexport * from './helpers/expandStyles.js'\nexport * from './helpers/isTamaguiElement.js'\nexport * from './helpers/isTamaguiComponent.js'\nexport * from './helpers/matchMedia.js'\nexport * from './helpers/proxyThemeVariables.js'\nexport * from './helpers/themeable.js'\nexport * from './helpers/withStaticProperties.js'\n\nexport * from './contexts/ButtonNestingContext.js'\n\nexport * from './hooks/useId.js'\nexport * from './hooks/useIsTouchDevice.js'\n\nexport {\n configureMedia,\n getMedia,\n mediaState,\n useMedia,\n useMediaPropsActive,\n mediaObjectToString,\n mediaQueryConfig,\n} from './hooks/useMedia.js'\nexport * from './hooks/useTheme.js'\nexport * from './hooks/useThemeName.js'\nexport * from './hooks/useSafeRef.js'\nexport * from './hooks/useStyle.js'\n\nexport * from './views/Slot.js'\nexport * from './views/Stack.js'\nexport * from './views/Text.js'\nexport * from './contexts/TextAncestorContext.js'\nexport * from './views/Theme.js'\nexport * from './views/ThemeProvider.js'\nexport * from './views/FontLanguage.js'\nexport * from './views/TamaguiProvider.js'\n\nexport * from '@tamagui/use-force-update'\nexport * from '@tamagui/use-did-finish-ssr'\nexport * from '@tamagui/use-event'\nexport * from '@tamagui/compose-refs'\nexport * from '@tamagui/helpers'\nexport * from '@tamagui/constants'\n\nexport * from './setupHooks.js'\n"],
|
|
5
|
-
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,SAAS,WAAW,WAAW,WAAW,wBAAwB;AAElE,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AAEd,cAAc;AACd,cAAc;AAEd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;",
|
|
4
|
+
"sourcesContent": ["export * from './Tamagui.js'\nexport * from './createComponent.js'\nexport * from './createShorthands.js'\nexport * from './createTheme.js'\nexport * from './createTamagui.js'\nexport * from './createFont.js'\nexport * from './createTokens.js'\nexport * from './createVariable.js'\nexport * from './createVariables.js'\nexport * from './insertFont.js'\nexport * from './addTheme.js'\nexport * from './updateTheme.js'\nexport * from './styled.js'\nexport * from './types.js'\nexport * from './setupReactNative.js'\n\nexport { getConfig, getThemes, getTokens, onConfiguredOnce } from './config.js'\n\nexport * from './constants/constants.js'\n\nexport * from './helpers/useShallowSetState.js'\nexport * from './helpers/getVariantExtras.js'\nexport * from './helpers/getAnimationDriver.js'\nexport * from './helpers/getExpandedShorthands.js'\nexport * from './helpers/getSplitStyles.js'\nexport * from './helpers/getStylesAtomic.js'\nexport * from './helpers/pseudoDescriptors.js'\nexport * from './helpers/mergeProps.js'\nexport * from './helpers/expandStyles.js'\nexport * from './helpers/isTamaguiElement.js'\nexport * from './helpers/isTamaguiComponent.js'\nexport * from './helpers/matchMedia.js'\nexport * from './helpers/proxyThemeVariables.js'\nexport * from './helpers/themeable.js'\nexport * from './helpers/withStaticProperties.js'\nexport * from './helpers/normalizeColor.js'\n\nexport * from './contexts/ButtonNestingContext.js'\n\nexport * from './hooks/useId.js'\nexport * from './hooks/useIsTouchDevice.js'\n\nexport {\n configureMedia,\n getMedia,\n mediaState,\n useMedia,\n useMediaPropsActive,\n mediaObjectToString,\n mediaQueryConfig,\n} from './hooks/useMedia.js'\nexport * from './hooks/useTheme.js'\nexport * from './hooks/useThemeName.js'\nexport * from './hooks/useSafeRef.js'\nexport * from './hooks/useStyle.js'\n\nexport * from './views/Slot.js'\nexport * from './views/Stack.js'\nexport * from './views/Text.js'\nexport * from './contexts/TextAncestorContext.js'\nexport * from './views/Theme.js'\nexport * from './views/ThemeProvider.js'\nexport * from './views/FontLanguage.js'\nexport * from './views/TamaguiProvider.js'\n\nexport * from '@tamagui/use-force-update'\nexport * from '@tamagui/use-did-finish-ssr'\nexport * from '@tamagui/use-event'\nexport * from '@tamagui/compose-refs'\nexport * from '@tamagui/helpers'\nexport * from '@tamagui/constants'\n\nexport * from './setupHooks.js'\n"],
|
|
5
|
+
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,SAAS,WAAW,WAAW,WAAW,wBAAwB;AAElE,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AAEd,cAAc;AACd,cAAc;AAEd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -30,6 +30,7 @@ export * from "./helpers/matchMedia.js";
|
|
|
30
30
|
export * from "./helpers/proxyThemeVariables.js";
|
|
31
31
|
export * from "./helpers/themeable.js";
|
|
32
32
|
export * from "./helpers/withStaticProperties.js";
|
|
33
|
+
export * from "./helpers/normalizeColor.js";
|
|
33
34
|
export * from "./contexts/ButtonNestingContext.js";
|
|
34
35
|
export * from "./hooks/useId.js";
|
|
35
36
|
export * from "./hooks/useIsTouchDevice.js";
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './Tamagui.js'\nexport * from './createComponent.js'\nexport * from './createShorthands.js'\nexport * from './createTheme.js'\nexport * from './createTamagui.js'\nexport * from './createFont.js'\nexport * from './createTokens.js'\nexport * from './createVariable.js'\nexport * from './createVariables.js'\nexport * from './insertFont.js'\nexport * from './addTheme.js'\nexport * from './updateTheme.js'\nexport * from './styled.js'\nexport * from './types.js'\nexport * from './setupReactNative.js'\n\nexport { getConfig, getThemes, getTokens, onConfiguredOnce } from './config.js'\n\nexport * from './constants/constants.js'\n\nexport * from './helpers/useShallowSetState.js'\nexport * from './helpers/getVariantExtras.js'\nexport * from './helpers/getAnimationDriver.js'\nexport * from './helpers/getExpandedShorthands.js'\nexport * from './helpers/getSplitStyles.js'\nexport * from './helpers/getStylesAtomic.js'\nexport * from './helpers/pseudoDescriptors.js'\nexport * from './helpers/mergeProps.js'\nexport * from './helpers/expandStyles.js'\nexport * from './helpers/isTamaguiElement.js'\nexport * from './helpers/isTamaguiComponent.js'\nexport * from './helpers/matchMedia.js'\nexport * from './helpers/proxyThemeVariables.js'\nexport * from './helpers/themeable.js'\nexport * from './helpers/withStaticProperties.js'\n\nexport * from './contexts/ButtonNestingContext.js'\n\nexport * from './hooks/useId.js'\nexport * from './hooks/useIsTouchDevice.js'\n\nexport {\n configureMedia,\n getMedia,\n mediaState,\n useMedia,\n useMediaPropsActive,\n mediaObjectToString,\n mediaQueryConfig,\n} from './hooks/useMedia.js'\nexport * from './hooks/useTheme.js'\nexport * from './hooks/useThemeName.js'\nexport * from './hooks/useSafeRef.js'\nexport * from './hooks/useStyle.js'\n\nexport * from './views/Slot.js'\nexport * from './views/Stack.js'\nexport * from './views/Text.js'\nexport * from './contexts/TextAncestorContext.js'\nexport * from './views/Theme.js'\nexport * from './views/ThemeProvider.js'\nexport * from './views/FontLanguage.js'\nexport * from './views/TamaguiProvider.js'\n\nexport * from '@tamagui/use-force-update'\nexport * from '@tamagui/use-did-finish-ssr'\nexport * from '@tamagui/use-event'\nexport * from '@tamagui/compose-refs'\nexport * from '@tamagui/helpers'\nexport * from '@tamagui/constants'\n\nexport * from './setupHooks.js'\n"],
|
|
5
|
-
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,SAAS,WAAW,WAAW,WAAW,wBAAwB;AAElE,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AAEd,cAAc;AACd,cAAc;AAEd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;",
|
|
4
|
+
"sourcesContent": ["export * from './Tamagui.js'\nexport * from './createComponent.js'\nexport * from './createShorthands.js'\nexport * from './createTheme.js'\nexport * from './createTamagui.js'\nexport * from './createFont.js'\nexport * from './createTokens.js'\nexport * from './createVariable.js'\nexport * from './createVariables.js'\nexport * from './insertFont.js'\nexport * from './addTheme.js'\nexport * from './updateTheme.js'\nexport * from './styled.js'\nexport * from './types.js'\nexport * from './setupReactNative.js'\n\nexport { getConfig, getThemes, getTokens, onConfiguredOnce } from './config.js'\n\nexport * from './constants/constants.js'\n\nexport * from './helpers/useShallowSetState.js'\nexport * from './helpers/getVariantExtras.js'\nexport * from './helpers/getAnimationDriver.js'\nexport * from './helpers/getExpandedShorthands.js'\nexport * from './helpers/getSplitStyles.js'\nexport * from './helpers/getStylesAtomic.js'\nexport * from './helpers/pseudoDescriptors.js'\nexport * from './helpers/mergeProps.js'\nexport * from './helpers/expandStyles.js'\nexport * from './helpers/isTamaguiElement.js'\nexport * from './helpers/isTamaguiComponent.js'\nexport * from './helpers/matchMedia.js'\nexport * from './helpers/proxyThemeVariables.js'\nexport * from './helpers/themeable.js'\nexport * from './helpers/withStaticProperties.js'\nexport * from './helpers/normalizeColor.js'\n\nexport * from './contexts/ButtonNestingContext.js'\n\nexport * from './hooks/useId.js'\nexport * from './hooks/useIsTouchDevice.js'\n\nexport {\n configureMedia,\n getMedia,\n mediaState,\n useMedia,\n useMediaPropsActive,\n mediaObjectToString,\n mediaQueryConfig,\n} from './hooks/useMedia.js'\nexport * from './hooks/useTheme.js'\nexport * from './hooks/useThemeName.js'\nexport * from './hooks/useSafeRef.js'\nexport * from './hooks/useStyle.js'\n\nexport * from './views/Slot.js'\nexport * from './views/Stack.js'\nexport * from './views/Text.js'\nexport * from './contexts/TextAncestorContext.js'\nexport * from './views/Theme.js'\nexport * from './views/ThemeProvider.js'\nexport * from './views/FontLanguage.js'\nexport * from './views/TamaguiProvider.js'\n\nexport * from '@tamagui/use-force-update'\nexport * from '@tamagui/use-did-finish-ssr'\nexport * from '@tamagui/use-event'\nexport * from '@tamagui/compose-refs'\nexport * from '@tamagui/helpers'\nexport * from '@tamagui/constants'\n\nexport * from './setupHooks.js'\n"],
|
|
5
|
+
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,SAAS,WAAW,WAAW,WAAW,wBAAwB;AAElE,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AAEd,cAAc;AACd,cAAc;AAEd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/web",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.10",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -27,20 +27,20 @@
|
|
|
27
27
|
"reset.css"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@tamagui/compose-refs": "^1.5.
|
|
31
|
-
"@tamagui/constants": "^1.5.
|
|
32
|
-
"@tamagui/helpers": "^1.5.
|
|
33
|
-
"@tamagui/normalize-css-color": "^1.5.
|
|
34
|
-
"@tamagui/use-did-finish-ssr": "^1.5.
|
|
35
|
-
"@tamagui/use-event": "^1.5.
|
|
36
|
-
"@tamagui/use-force-update": "^1.5.
|
|
30
|
+
"@tamagui/compose-refs": "^1.5.10",
|
|
31
|
+
"@tamagui/constants": "^1.5.10",
|
|
32
|
+
"@tamagui/helpers": "^1.5.10",
|
|
33
|
+
"@tamagui/normalize-css-color": "^1.5.10",
|
|
34
|
+
"@tamagui/use-did-finish-ssr": "^1.5.10",
|
|
35
|
+
"@tamagui/use-event": "^1.5.10",
|
|
36
|
+
"@tamagui/use-force-update": "^1.5.10"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"react": "*",
|
|
40
40
|
"react-dom": "*"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@tamagui/build": "^1.5.
|
|
43
|
+
"@tamagui/build": "^1.5.10",
|
|
44
44
|
"@testing-library/react": "^13.4.0",
|
|
45
45
|
"csstype": "^3.0.10",
|
|
46
46
|
"react": "^18.2.0",
|
|
@@ -160,14 +160,13 @@ export class ThemeManager {
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
function getNextThemeClassName(name: string, isInverting = false) {
|
|
163
|
-
const next =
|
|
163
|
+
const next = `t_sub_theme ${THEME_CLASSNAME_PREFIX}${name}`
|
|
164
164
|
if (isInverting) {
|
|
165
165
|
return (
|
|
166
166
|
next +
|
|
167
167
|
// ensure you invert to base dark as well as specific dark
|
|
168
168
|
// ... logic should likely be elsewhere
|
|
169
|
-
(next.includes('dark_') ? ` t_dark` : '')
|
|
170
|
-
(next.includes('light_') ? ` t_light` : '')
|
|
169
|
+
(next.includes('dark_') ? ` t_dark` : next.includes('light_') ? ` t_light` : '')
|
|
171
170
|
)
|
|
172
171
|
}
|
|
173
172
|
return next.replace('light_', '').replace('dark_', '')
|
|
@@ -190,7 +189,8 @@ function getState(
|
|
|
190
189
|
throw new Error('Cannot reset + set new name')
|
|
191
190
|
}
|
|
192
191
|
if (props.reset && !parentManager?.parentManager) {
|
|
193
|
-
|
|
192
|
+
console.warn('Cannot reset no grandparent exists')
|
|
193
|
+
return null
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
let result: ThemeManagerState | null = null
|