@tamagui/theme 2.0.0-rc.3 → 2.0.0-rc.30
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/index.js +20 -14
- package/dist/esm/index.js +5 -7
- package/dist/esm/index.js.map +1 -6
- package/package.json +8 -11
- package/dist/cjs/_mutateTheme.js +0 -121
- package/dist/cjs/_mutateTheme.js.map +0 -6
- package/dist/cjs/addTheme.js +0 -24
- package/dist/cjs/addTheme.js.map +0 -6
- package/dist/cjs/replaceTheme.js +0 -27
- package/dist/cjs/replaceTheme.js.map +0 -6
- package/dist/cjs/updateTheme.js +0 -27
- package/dist/cjs/updateTheme.js.map +0 -6
- package/dist/esm/_mutateTheme.js +0 -116
- package/dist/esm/_mutateTheme.js.map +0 -6
- package/dist/esm/addTheme.js +0 -8
- package/dist/esm/addTheme.js.map +0 -6
- package/dist/esm/replaceTheme.js +0 -11
- package/dist/esm/replaceTheme.js.map +0 -6
- package/dist/esm/updateTheme.js +0 -11
- package/dist/esm/updateTheme.js.map +0 -6
package/dist/cjs/index.js
CHANGED
|
@@ -3,22 +3,28 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: !0
|
|
9
|
+
});
|
|
10
|
+
},
|
|
11
|
+
__copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
13
|
+
get: () => from[key],
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
},
|
|
18
|
+
__reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
20
|
+
value: !0
|
|
21
|
+
}), mod);
|
|
15
22
|
var index_exports = {};
|
|
16
23
|
__export(index_exports, {
|
|
17
24
|
mutateThemes: () => import_mutateTheme.mutateThemes
|
|
18
25
|
});
|
|
19
26
|
module.exports = __toCommonJS(index_exports);
|
|
20
|
-
__reExport(index_exports, require("./addTheme"), module.exports);
|
|
21
|
-
__reExport(index_exports, require("./updateTheme"), module.exports);
|
|
22
|
-
__reExport(index_exports, require("./replaceTheme"), module.exports);
|
|
23
|
-
var import_mutateTheme = require("./_mutateTheme");
|
|
24
|
-
//# sourceMappingURL=index.js.map
|
|
27
|
+
__reExport(index_exports, require("./addTheme.cjs"), module.exports);
|
|
28
|
+
__reExport(index_exports, require("./updateTheme.cjs"), module.exports);
|
|
29
|
+
__reExport(index_exports, require("./replaceTheme.cjs"), module.exports);
|
|
30
|
+
var import_mutateTheme = require("./_mutateTheme.cjs");
|
package/dist/esm/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
export * from "./addTheme";
|
|
2
|
-
export * from "./updateTheme";
|
|
3
|
-
export * from "./replaceTheme";
|
|
4
|
-
import { mutateThemes } from "./_mutateTheme";
|
|
5
|
-
export {
|
|
6
|
-
mutateThemes
|
|
7
|
-
};
|
|
1
|
+
export * from "./addTheme.mjs";
|
|
2
|
+
export * from "./updateTheme.mjs";
|
|
3
|
+
export * from "./replaceTheme.mjs";
|
|
4
|
+
import { mutateThemes } from "./_mutateTheme.mjs";
|
|
5
|
+
export { mutateThemes };
|
|
8
6
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/index.ts"],
|
|
4
|
-
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,oBAAoB;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
|
1
|
+
{"version":3,"names":["mutateThemes"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAASA,YAAA,QAAoB","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/theme",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.30",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -16,15 +16,12 @@
|
|
|
16
16
|
"./package.json": "./package.json",
|
|
17
17
|
".": {
|
|
18
18
|
"types": "./types/index.d.ts",
|
|
19
|
-
"react-native":
|
|
20
|
-
|
|
21
|
-
"import": "./dist/esm/index.native.js",
|
|
22
|
-
"require": "./dist/cjs/index.native.js"
|
|
23
|
-
},
|
|
19
|
+
"react-native": "./dist/esm/index.native.js",
|
|
20
|
+
"browser": "./dist/esm/index.mjs",
|
|
24
21
|
"module": "./dist/esm/index.mjs",
|
|
25
22
|
"import": "./dist/esm/index.mjs",
|
|
26
23
|
"require": "./dist/cjs/index.cjs",
|
|
27
|
-
"default": "./dist/
|
|
24
|
+
"default": "./dist/esm/index.mjs"
|
|
28
25
|
}
|
|
29
26
|
},
|
|
30
27
|
"publishConfig": {
|
|
@@ -37,12 +34,12 @@
|
|
|
37
34
|
"clean:build": "tamagui-build clean:build"
|
|
38
35
|
},
|
|
39
36
|
"dependencies": {
|
|
40
|
-
"@tamagui/constants": "2.0.0-rc.
|
|
41
|
-
"@tamagui/start-transition": "2.0.0-rc.
|
|
42
|
-
"@tamagui/web": "2.0.0-rc.
|
|
37
|
+
"@tamagui/constants": "2.0.0-rc.30",
|
|
38
|
+
"@tamagui/start-transition": "2.0.0-rc.30",
|
|
39
|
+
"@tamagui/web": "2.0.0-rc.30"
|
|
43
40
|
},
|
|
44
41
|
"devDependencies": {
|
|
45
|
-
"@tamagui/build": "2.0.0-rc.
|
|
42
|
+
"@tamagui/build": "2.0.0-rc.30",
|
|
46
43
|
"react": ">=19"
|
|
47
44
|
},
|
|
48
45
|
"peerDependencies": {
|
package/dist/cjs/_mutateTheme.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
-
var mutateTheme_exports = {};
|
|
16
|
-
__export(mutateTheme_exports, {
|
|
17
|
-
_mutateTheme: () => _mutateTheme,
|
|
18
|
-
mutateThemes: () => mutateThemes
|
|
19
|
-
});
|
|
20
|
-
module.exports = __toCommonJS(mutateTheme_exports);
|
|
21
|
-
var import_constants = require("@tamagui/constants"), import_start_transition = require("@tamagui/start-transition"), import_web = require("@tamagui/web");
|
|
22
|
-
function mutateThemes({
|
|
23
|
-
themes,
|
|
24
|
-
batch,
|
|
25
|
-
insertCSS = !0,
|
|
26
|
-
...props
|
|
27
|
-
}) {
|
|
28
|
-
const allThemesProxied = {}, allThemesRaw = {};
|
|
29
|
-
for (const { name, theme } of themes) {
|
|
30
|
-
const res = _mutateTheme({
|
|
31
|
-
...props,
|
|
32
|
-
name,
|
|
33
|
-
theme,
|
|
34
|
-
// we'll do one update at the end
|
|
35
|
-
avoidUpdate: !0,
|
|
36
|
-
// always add which also replaces but doesnt fail first time
|
|
37
|
-
mutationType: "add"
|
|
38
|
-
});
|
|
39
|
-
res && (allThemesProxied[name] = res.theme, allThemesRaw[name] = res.themeRaw);
|
|
40
|
-
}
|
|
41
|
-
const cssRules = insertCSS ? insertThemeCSS(allThemesRaw, batch) : [];
|
|
42
|
-
return (0, import_start_transition.startTransition)(() => {
|
|
43
|
-
for (const themeName in allThemesProxied) {
|
|
44
|
-
const theme = allThemesProxied[themeName];
|
|
45
|
-
updateThemeConfig(themeName, theme);
|
|
46
|
-
}
|
|
47
|
-
updateThemeStates();
|
|
48
|
-
}), {
|
|
49
|
-
themes: allThemesProxied,
|
|
50
|
-
themesRaw: allThemesRaw,
|
|
51
|
-
cssRules
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
function _mutateTheme(props) {
|
|
55
|
-
if (import_constants.isServer) {
|
|
56
|
-
process.env.NODE_ENV === "development" && console.warn("Theme mutation is not supported on server side");
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const config = (0, import_web.getConfig)(), { name: themeName, theme: themeIn, insertCSS, mutationType } = props;
|
|
60
|
-
if (process.env.NODE_ENV === "development") {
|
|
61
|
-
if (!config)
|
|
62
|
-
throw new Error("No config");
|
|
63
|
-
const theme2 = config.themes[props.name];
|
|
64
|
-
if (mutationType !== "add" && !theme2)
|
|
65
|
-
throw new Error(
|
|
66
|
-
`${mutationType === "replace" ? "Replace" : "Update"} theme failed! Theme ${props.name} does not exist`
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
const theme = {
|
|
70
|
-
...mutationType === "update" ? config.themes[themeName] ?? {} : {},
|
|
71
|
-
...themeIn
|
|
72
|
-
};
|
|
73
|
-
for (const key in theme)
|
|
74
|
-
(0, import_web.ensureThemeVariable)(theme, key);
|
|
75
|
-
const themeProxied = (0, import_web.proxyThemeToParents)(themeName, theme), response = {
|
|
76
|
-
themeRaw: theme,
|
|
77
|
-
theme: themeProxied,
|
|
78
|
-
cssRules: []
|
|
79
|
-
};
|
|
80
|
-
return props.avoidUpdate || (insertCSS && (response.cssRules = insertThemeCSS({
|
|
81
|
-
[themeName]: theme
|
|
82
|
-
})), updateThemeConfig(themeName, themeProxied), updateThemeStates()), response;
|
|
83
|
-
}
|
|
84
|
-
function updateThemeConfig(themeName, theme) {
|
|
85
|
-
const config = (0, import_web.getConfig)();
|
|
86
|
-
config.themes[themeName] = theme, (0, import_web.updateConfig)("themes", config.themes);
|
|
87
|
-
}
|
|
88
|
-
function updateThemeStates() {
|
|
89
|
-
(0, import_web.forceUpdateThemes)();
|
|
90
|
-
}
|
|
91
|
-
function insertThemeCSS(themes, batch = !1) {
|
|
92
|
-
const config = (0, import_web.getConfig)();
|
|
93
|
-
let cssRules = [];
|
|
94
|
-
for (const themeName in themes) {
|
|
95
|
-
const theme = themes[themeName], rules = (0, import_web.getThemeCSSRules)({
|
|
96
|
-
config,
|
|
97
|
-
themeName,
|
|
98
|
-
names: [themeName],
|
|
99
|
-
hasDarkLight: !0,
|
|
100
|
-
theme,
|
|
101
|
-
// Use mutated variable creator which starts from high index to avoid conflicts
|
|
102
|
-
useMutatedVariables: !0
|
|
103
|
-
});
|
|
104
|
-
cssRules = [...cssRules, ...rules], batch || updateStyle(`t_theme_style_${themeName}`, rules);
|
|
105
|
-
}
|
|
106
|
-
if (import_web.mutatedAutoVariables.length > 0) {
|
|
107
|
-
const autoVarCSS = `:root{${import_web.mutatedAutoVariables.map((v) => `--${v.name}:${v.val}`).join(";")}}`;
|
|
108
|
-
updateStyle("t_mutate_vars", [autoVarCSS]);
|
|
109
|
-
}
|
|
110
|
-
if (batch) {
|
|
111
|
-
const id = typeof batch == "string" ? batch : (0, import_web.simpleHash)(Object.keys(themes).join(""));
|
|
112
|
-
updateStyle(`t_theme_style_${id}`, cssRules);
|
|
113
|
-
}
|
|
114
|
-
return cssRules;
|
|
115
|
-
}
|
|
116
|
-
function updateStyle(id, rules) {
|
|
117
|
-
const existing = document.querySelector(`#${id}`), style = document.createElement("style");
|
|
118
|
-
style.id = id, style.appendChild(document.createTextNode(rules.join(`
|
|
119
|
-
`))), document.head.appendChild(style), existing && existing.parentElement?.removeChild(existing);
|
|
120
|
-
}
|
|
121
|
-
//# sourceMappingURL=_mutateTheme.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/_mutateTheme.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAyB,+BACzB,0BAAgC,sCAEhC,aASO;AAmBA,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ,GAAG;AACL,GAKG;AACD,QAAM,mBAAgD,CAAC,GACjD,eAA4C,CAAC;AACnD,aAAW,EAAE,MAAM,MAAM,KAAK,QAAQ;AACpC,UAAM,MAAM,aAAa;AAAA,MACvB,GAAG;AAAA,MACH;AAAA,MACA;AAAA;AAAA,MAEA,aAAa;AAAA;AAAA,MAEb,cAAc;AAAA,IAChB,CAAC;AACD,IAAI,QACF,iBAAiB,IAAI,IAAI,IAAI,OAC7B,aAAa,IAAI,IAAI,IAAI;AAAA,EAE7B;AAEA,QAAM,WAAW,YAAY,eAAe,cAAc,KAAK,IAAI,CAAC;AAEpE,sDAAgB,MAAM;AACpB,eAAW,aAAa,kBAAkB;AACxC,YAAM,QAAQ,iBAAiB,SAAS;AACxC,wBAAkB,WAAW,KAAK;AAAA,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AM,aAAS,sBAAU;AACzB,MAAI,WAAqB,CAAC;AAE1B,aAAW,aAAa,QAAQ;AAC9B,UAAM,QAAQ,OAAO,SAAS,GAExB,YAAQ,6BAAiB;AAAA,MAC7B;AAAA,MACA;AAAA,MACA,OAAO,CAAC,SAAS;AAAA,MACjB,cAAc;AAAA,MACd;AAAA;AAAA,MAEA,qBAAqB;AAAA,IACvB,CAAC;AAED,eAAW,CAAC,GAAG,UAAU,GAAG,KAAK,GAE5B,SACH,YAAY,iBAAiB,SAAS,IAAI,KAAK;AAAA,EAEnD;AAGA,MAAI,gCAAqB,SAAS,GAAG;AACnC,UAAM,aAAa,SAAS,gCAAqB,IAAI,CAAC,MAAM,KAAK,EAAE,IAAI,IAAI,EAAE,GAAG,EAAE,EAAE,KAAK,GAAG,CAAC;AAC7F,gBAAY,iBAAiB,CAAC,UAAU,CAAC;AAAA,EAC3C;AAEA,MAAI,OAAO;AACT,UAAM,KAAK,OAAO,SAAS,WAAW,YAAQ,uBAAW,OAAO,KAAK,MAAM,EAAE,KAAK,EAAE,CAAC;AACrF,gBAAY,iBAAiB,EAAE,IAAI,QAAQ;AAAA,EAC7C;AAEA,SAAO;AACT;AAEA,SAAS,YAAY,IAAY,OAAiB;AAChD,QAAM,WAAW,SAAS,cAAc,IAAI,EAAE,EAAE,GAC1C,QAAQ,SAAS,cAAc,OAAO;AAC5C,QAAM,KAAK,IACX,MAAM,YAAY,SAAS,eAAe,MAAM,KAAK;AAAA,CAAI,CAAC,CAAC,GAC3D,SAAS,KAAK,YAAY,KAAK,GAC3B,YACF,SAAS,eAAe,YAAY,QAAQ;AAEhD;",
|
|
5
|
-
"names": ["theme"]
|
|
6
|
-
}
|
package/dist/cjs/addTheme.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
-
var addTheme_exports = {};
|
|
16
|
-
__export(addTheme_exports, {
|
|
17
|
-
addTheme: () => addTheme
|
|
18
|
-
});
|
|
19
|
-
module.exports = __toCommonJS(addTheme_exports);
|
|
20
|
-
var import_mutateTheme = require("./_mutateTheme");
|
|
21
|
-
function addTheme(props) {
|
|
22
|
-
return (0, import_mutateTheme._mutateTheme)({ ...props, insertCSS: !0, mutationType: "add" });
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=addTheme.js.map
|
package/dist/cjs/addTheme.js.map
DELETED
package/dist/cjs/replaceTheme.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
-
var replaceTheme_exports = {};
|
|
16
|
-
__export(replaceTheme_exports, {
|
|
17
|
-
replaceTheme: () => replaceTheme
|
|
18
|
-
});
|
|
19
|
-
module.exports = __toCommonJS(replaceTheme_exports);
|
|
20
|
-
var import_mutateTheme = require("./_mutateTheme");
|
|
21
|
-
function replaceTheme({
|
|
22
|
-
name,
|
|
23
|
-
theme
|
|
24
|
-
}) {
|
|
25
|
-
return (0, import_mutateTheme._mutateTheme)({ name, theme, insertCSS: !0, mutationType: "replace" });
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=replaceTheme.js.map
|
package/dist/cjs/updateTheme.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
-
var updateTheme_exports = {};
|
|
16
|
-
__export(updateTheme_exports, {
|
|
17
|
-
updateTheme: () => updateTheme
|
|
18
|
-
});
|
|
19
|
-
module.exports = __toCommonJS(updateTheme_exports);
|
|
20
|
-
var import_mutateTheme = require("./_mutateTheme");
|
|
21
|
-
function updateTheme({
|
|
22
|
-
name,
|
|
23
|
-
theme
|
|
24
|
-
}) {
|
|
25
|
-
return (0, import_mutateTheme._mutateTheme)({ name, theme, insertCSS: !0, mutationType: "update" });
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=updateTheme.js.map
|
package/dist/esm/_mutateTheme.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { isServer } from "@tamagui/constants";
|
|
2
|
-
import { startTransition } from "@tamagui/start-transition";
|
|
3
|
-
import {
|
|
4
|
-
ensureThemeVariable,
|
|
5
|
-
forceUpdateThemes,
|
|
6
|
-
getConfig,
|
|
7
|
-
getThemeCSSRules,
|
|
8
|
-
mutatedAutoVariables,
|
|
9
|
-
proxyThemeToParents,
|
|
10
|
-
simpleHash,
|
|
11
|
-
updateConfig
|
|
12
|
-
} from "@tamagui/web";
|
|
13
|
-
function mutateThemes({
|
|
14
|
-
themes,
|
|
15
|
-
batch,
|
|
16
|
-
insertCSS = !0,
|
|
17
|
-
...props
|
|
18
|
-
}) {
|
|
19
|
-
const allThemesProxied = {}, allThemesRaw = {};
|
|
20
|
-
for (const { name, theme } of themes) {
|
|
21
|
-
const res = _mutateTheme({
|
|
22
|
-
...props,
|
|
23
|
-
name,
|
|
24
|
-
theme,
|
|
25
|
-
// we'll do one update at the end
|
|
26
|
-
avoidUpdate: !0,
|
|
27
|
-
// always add which also replaces but doesnt fail first time
|
|
28
|
-
mutationType: "add"
|
|
29
|
-
});
|
|
30
|
-
res && (allThemesProxied[name] = res.theme, allThemesRaw[name] = res.themeRaw);
|
|
31
|
-
}
|
|
32
|
-
const cssRules = insertCSS ? insertThemeCSS(allThemesRaw, batch) : [];
|
|
33
|
-
return startTransition(() => {
|
|
34
|
-
for (const themeName in allThemesProxied) {
|
|
35
|
-
const theme = allThemesProxied[themeName];
|
|
36
|
-
updateThemeConfig(themeName, theme);
|
|
37
|
-
}
|
|
38
|
-
updateThemeStates();
|
|
39
|
-
}), {
|
|
40
|
-
themes: allThemesProxied,
|
|
41
|
-
themesRaw: allThemesRaw,
|
|
42
|
-
cssRules
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
function _mutateTheme(props) {
|
|
46
|
-
if (isServer) {
|
|
47
|
-
process.env.NODE_ENV === "development" && console.warn("Theme mutation is not supported on server side");
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
const config = getConfig(), { name: themeName, theme: themeIn, insertCSS, mutationType } = props;
|
|
51
|
-
if (process.env.NODE_ENV === "development") {
|
|
52
|
-
if (!config)
|
|
53
|
-
throw new Error("No config");
|
|
54
|
-
const theme2 = config.themes[props.name];
|
|
55
|
-
if (mutationType !== "add" && !theme2)
|
|
56
|
-
throw new Error(
|
|
57
|
-
`${mutationType === "replace" ? "Replace" : "Update"} theme failed! Theme ${props.name} does not exist`
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
const theme = {
|
|
61
|
-
...mutationType === "update" ? config.themes[themeName] ?? {} : {},
|
|
62
|
-
...themeIn
|
|
63
|
-
};
|
|
64
|
-
for (const key in theme)
|
|
65
|
-
ensureThemeVariable(theme, key);
|
|
66
|
-
const themeProxied = proxyThemeToParents(themeName, theme), response = {
|
|
67
|
-
themeRaw: theme,
|
|
68
|
-
theme: themeProxied,
|
|
69
|
-
cssRules: []
|
|
70
|
-
};
|
|
71
|
-
return props.avoidUpdate || (insertCSS && (response.cssRules = insertThemeCSS({
|
|
72
|
-
[themeName]: theme
|
|
73
|
-
})), updateThemeConfig(themeName, themeProxied), updateThemeStates()), response;
|
|
74
|
-
}
|
|
75
|
-
function updateThemeConfig(themeName, theme) {
|
|
76
|
-
const config = getConfig();
|
|
77
|
-
config.themes[themeName] = theme, updateConfig("themes", config.themes);
|
|
78
|
-
}
|
|
79
|
-
function updateThemeStates() {
|
|
80
|
-
forceUpdateThemes();
|
|
81
|
-
}
|
|
82
|
-
function insertThemeCSS(themes, batch = !1) {
|
|
83
|
-
const config = getConfig();
|
|
84
|
-
let cssRules = [];
|
|
85
|
-
for (const themeName in themes) {
|
|
86
|
-
const theme = themes[themeName], rules = getThemeCSSRules({
|
|
87
|
-
config,
|
|
88
|
-
themeName,
|
|
89
|
-
names: [themeName],
|
|
90
|
-
hasDarkLight: !0,
|
|
91
|
-
theme,
|
|
92
|
-
// Use mutated variable creator which starts from high index to avoid conflicts
|
|
93
|
-
useMutatedVariables: !0
|
|
94
|
-
});
|
|
95
|
-
cssRules = [...cssRules, ...rules], batch || updateStyle(`t_theme_style_${themeName}`, rules);
|
|
96
|
-
}
|
|
97
|
-
if (mutatedAutoVariables.length > 0) {
|
|
98
|
-
const autoVarCSS = `:root{${mutatedAutoVariables.map((v) => `--${v.name}:${v.val}`).join(";")}}`;
|
|
99
|
-
updateStyle("t_mutate_vars", [autoVarCSS]);
|
|
100
|
-
}
|
|
101
|
-
if (batch) {
|
|
102
|
-
const id = typeof batch == "string" ? batch : simpleHash(Object.keys(themes).join(""));
|
|
103
|
-
updateStyle(`t_theme_style_${id}`, cssRules);
|
|
104
|
-
}
|
|
105
|
-
return cssRules;
|
|
106
|
-
}
|
|
107
|
-
function updateStyle(id, rules) {
|
|
108
|
-
const existing = document.querySelector(`#${id}`), style = document.createElement("style");
|
|
109
|
-
style.id = id, style.appendChild(document.createTextNode(rules.join(`
|
|
110
|
-
`))), document.head.appendChild(style), existing && existing.parentElement?.removeChild(existing);
|
|
111
|
-
}
|
|
112
|
-
export {
|
|
113
|
-
_mutateTheme,
|
|
114
|
-
mutateThemes
|
|
115
|
-
};
|
|
116
|
-
//# sourceMappingURL=_mutateTheme.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/_mutateTheme.ts"],
|
|
4
|
-
"mappings": "AAAA,SAAS,gBA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