@tamagui/theme 2.0.0-rc.35 → 2.0.0-rc.36-1775243248161
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/_mutateTheme.cjs +91 -58
- package/dist/cjs/_mutateTheme.native.js +128 -89
- package/dist/cjs/_mutateTheme.native.js.map +1 -1
- package/dist/cjs/addTheme.cjs +13 -11
- package/dist/cjs/addTheme.native.js +13 -11
- package/dist/cjs/addTheme.native.js.map +1 -1
- package/dist/cjs/index.cjs +13 -11
- package/dist/cjs/index.native.js +13 -11
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/replaceTheme.cjs +15 -12
- package/dist/cjs/replaceTheme.native.js +21 -19
- package/dist/cjs/replaceTheme.native.js.map +1 -1
- package/dist/cjs/updateTheme.cjs +13 -11
- package/dist/cjs/updateTheme.native.js +13 -11
- package/dist/cjs/updateTheme.native.js.map +1 -1
- package/dist/esm/_mutateTheme.mjs +76 -45
- package/dist/esm/_mutateTheme.mjs.map +1 -1
- package/dist/esm/_mutateTheme.native.js +113 -76
- package/dist/esm/_mutateTheme.native.js.map +1 -1
- package/dist/esm/addTheme.mjs +1 -1
- package/dist/esm/addTheme.native.js +1 -1
- package/dist/esm/replaceTheme.mjs +3 -2
- package/dist/esm/replaceTheme.mjs.map +1 -1
- package/dist/esm/replaceTheme.native.js +9 -9
- package/dist/esm/replaceTheme.native.js.map +1 -1
- package/dist/esm/updateTheme.mjs +1 -1
- package/dist/esm/updateTheme.native.js +1 -1
- package/package.json +5 -5
|
@@ -3,20 +3,22 @@ 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
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
14
|
get: () => from[key],
|
|
14
15
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
18
20
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value:
|
|
21
|
+
value: true
|
|
20
22
|
}), mod);
|
|
21
23
|
var mutateTheme_exports = {};
|
|
22
24
|
__export(mutateTheme_exports, {
|
|
@@ -24,17 +26,17 @@ __export(mutateTheme_exports, {
|
|
|
24
26
|
mutateThemes: () => mutateThemes
|
|
25
27
|
});
|
|
26
28
|
module.exports = __toCommonJS(mutateTheme_exports);
|
|
27
|
-
var import_constants = require("@tamagui/constants")
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
var import_constants = require("@tamagui/constants");
|
|
30
|
+
var import_start_transition = require("@tamagui/start-transition");
|
|
31
|
+
var import_web = require("@tamagui/web");
|
|
30
32
|
function mutateThemes({
|
|
31
33
|
themes,
|
|
32
34
|
batch,
|
|
33
|
-
insertCSS =
|
|
35
|
+
insertCSS = true,
|
|
34
36
|
...props
|
|
35
37
|
}) {
|
|
36
|
-
const allThemesProxied = {}
|
|
37
|
-
|
|
38
|
+
const allThemesProxied = {};
|
|
39
|
+
const allThemesRaw = {};
|
|
38
40
|
for (const {
|
|
39
41
|
name,
|
|
40
42
|
theme
|
|
@@ -44,20 +46,24 @@ function mutateThemes({
|
|
|
44
46
|
name,
|
|
45
47
|
theme,
|
|
46
48
|
// we'll do one update at the end
|
|
47
|
-
avoidUpdate:
|
|
49
|
+
avoidUpdate: true,
|
|
48
50
|
// always add which also replaces but doesnt fail first time
|
|
49
51
|
mutationType: "add"
|
|
50
52
|
});
|
|
51
|
-
|
|
53
|
+
if (res) {
|
|
54
|
+
allThemesProxied[name] = res.theme;
|
|
55
|
+
allThemesRaw[name] = res.themeRaw;
|
|
56
|
+
}
|
|
52
57
|
}
|
|
53
58
|
const cssRules = insertCSS ? insertThemeCSS(allThemesRaw, batch) : [];
|
|
54
|
-
|
|
59
|
+
(0, import_start_transition.startTransition)(() => {
|
|
55
60
|
for (const themeName in allThemesProxied) {
|
|
56
61
|
const theme = allThemesProxied[themeName];
|
|
57
62
|
updateThemeConfig(themeName, theme);
|
|
58
63
|
}
|
|
59
64
|
updateThemeStates();
|
|
60
|
-
})
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
61
67
|
themes: allThemesProxied,
|
|
62
68
|
themesRaw: allThemesRaw,
|
|
63
69
|
cssRules
|
|
@@ -65,62 +71,85 @@ function mutateThemes({
|
|
|
65
71
|
}
|
|
66
72
|
function _mutateTheme(props) {
|
|
67
73
|
if (import_constants.isServer) {
|
|
68
|
-
process.env.NODE_ENV === "development"
|
|
74
|
+
if (process.env.NODE_ENV === "development") {
|
|
75
|
+
console.warn("Theme mutation is not supported on server side");
|
|
76
|
+
}
|
|
69
77
|
return;
|
|
70
78
|
}
|
|
71
|
-
const config = (0, import_web.getConfig)()
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
const config = (0, import_web.getConfig)();
|
|
80
|
+
const {
|
|
81
|
+
name: themeName,
|
|
82
|
+
theme: themeIn,
|
|
83
|
+
insertCSS,
|
|
84
|
+
mutationType
|
|
85
|
+
} = props;
|
|
78
86
|
if (process.env.NODE_ENV === "development") {
|
|
79
|
-
if (!config)
|
|
87
|
+
if (!config) {
|
|
88
|
+
throw new Error("No config");
|
|
89
|
+
}
|
|
80
90
|
const theme2 = config.themes[props.name];
|
|
81
|
-
if (mutationType !== "add" && !theme2)
|
|
91
|
+
if (mutationType !== "add" && !theme2) {
|
|
92
|
+
throw new Error(`${mutationType === "replace" ? "Replace" : "Update"} theme failed! Theme ${props.name} does not exist`);
|
|
93
|
+
}
|
|
82
94
|
}
|
|
83
95
|
const theme = {
|
|
84
96
|
...(mutationType === "update" ? config.themes[themeName] ?? {} : {}),
|
|
85
97
|
...themeIn
|
|
86
98
|
};
|
|
87
|
-
for (const key in theme)
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
99
|
+
for (const key in theme) {
|
|
100
|
+
(0, import_web.ensureThemeVariable)(theme, key);
|
|
101
|
+
}
|
|
102
|
+
const themeProxied = (0, import_web.proxyThemeToParents)(themeName, theme);
|
|
103
|
+
const response = {
|
|
104
|
+
themeRaw: theme,
|
|
105
|
+
theme: themeProxied,
|
|
106
|
+
cssRules: []
|
|
107
|
+
};
|
|
108
|
+
if (props.avoidUpdate) {
|
|
109
|
+
return response;
|
|
110
|
+
}
|
|
111
|
+
if (insertCSS) {
|
|
112
|
+
response.cssRules = insertThemeCSS({
|
|
113
|
+
[themeName]: theme
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
updateThemeConfig(themeName, themeProxied);
|
|
117
|
+
updateThemeStates();
|
|
118
|
+
return response;
|
|
97
119
|
}
|
|
98
120
|
function updateThemeConfig(themeName, theme) {
|
|
99
121
|
const config = (0, import_web.getConfig)();
|
|
100
|
-
config.themes[themeName] = theme
|
|
122
|
+
config.themes[themeName] = theme;
|
|
123
|
+
(0, import_web.updateConfig)("themes", config.themes);
|
|
101
124
|
}
|
|
102
125
|
function updateThemeStates() {
|
|
103
126
|
(0, import_web.forceUpdateThemes)();
|
|
104
127
|
}
|
|
105
|
-
function insertThemeCSS(themes, batch =
|
|
128
|
+
function insertThemeCSS(themes, batch = false) {
|
|
129
|
+
if (false) {
|
|
130
|
+
return [];
|
|
131
|
+
}
|
|
106
132
|
const config = (0, import_web.getConfig)();
|
|
107
133
|
let cssRules = [];
|
|
108
134
|
for (const themeName in themes) {
|
|
109
|
-
const theme = themes[themeName]
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
cssRules = [...cssRules, ...rules]
|
|
135
|
+
const theme = themes[themeName];
|
|
136
|
+
const rules = (0, import_web.getThemeCSSRules)({
|
|
137
|
+
config,
|
|
138
|
+
themeName,
|
|
139
|
+
names: [themeName],
|
|
140
|
+
hasDarkLight: true,
|
|
141
|
+
theme,
|
|
142
|
+
// Use mutated variable creator which starts from high index to avoid conflicts
|
|
143
|
+
useMutatedVariables: true
|
|
144
|
+
});
|
|
145
|
+
cssRules = [...cssRules, ...rules];
|
|
146
|
+
if (!batch) {
|
|
147
|
+
updateStyle(`t_theme_style_${themeName}`, rules);
|
|
148
|
+
}
|
|
120
149
|
}
|
|
121
150
|
if (import_web.mutatedAutoVariables.length > 0) {
|
|
122
151
|
const autoVarCSS = `:root{${import_web.mutatedAutoVariables.map(v => `--${v.name}:${v.val}`).join(";")}}`;
|
|
123
|
-
updateStyle(
|
|
152
|
+
updateStyle(`t_mutate_vars`, [autoVarCSS]);
|
|
124
153
|
}
|
|
125
154
|
if (batch) {
|
|
126
155
|
const id = typeof batch == "string" ? batch : (0, import_web.simpleHash)(Object.keys(themes).join(""));
|
|
@@ -129,8 +158,12 @@ function insertThemeCSS(themes, batch = !1) {
|
|
|
129
158
|
return cssRules;
|
|
130
159
|
}
|
|
131
160
|
function updateStyle(id, rules) {
|
|
132
|
-
const existing = document.querySelector(`#${id}`)
|
|
133
|
-
|
|
134
|
-
style.id = id
|
|
135
|
-
|
|
161
|
+
const existing = document.querySelector(`#${id}`);
|
|
162
|
+
const style = document.createElement("style");
|
|
163
|
+
style.id = id;
|
|
164
|
+
style.appendChild(document.createTextNode(rules.join("\n")));
|
|
165
|
+
document.head.appendChild(style);
|
|
166
|
+
if (existing) {
|
|
167
|
+
existing.parentElement?.removeChild(existing);
|
|
168
|
+
}
|
|
136
169
|
}
|
|
@@ -5,20 +5,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value:
|
|
23
|
+
value: true
|
|
22
24
|
}), mod);
|
|
23
25
|
var mutateTheme_exports = {};
|
|
24
26
|
__export(mutateTheme_exports, {
|
|
@@ -26,55 +28,64 @@ __export(mutateTheme_exports, {
|
|
|
26
28
|
mutateThemes: () => mutateThemes
|
|
27
29
|
});
|
|
28
30
|
module.exports = __toCommonJS(mutateTheme_exports);
|
|
29
|
-
var import_constants = require("@tamagui/constants")
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
var import_constants = require("@tamagui/constants");
|
|
32
|
+
var import_start_transition = require("@tamagui/start-transition");
|
|
33
|
+
var import_web = require("@tamagui/web");
|
|
32
34
|
function mutateThemes(param) {
|
|
33
35
|
var {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
_didIteratorError =
|
|
36
|
+
themes,
|
|
37
|
+
batch,
|
|
38
|
+
insertCSS = true,
|
|
39
|
+
...props
|
|
40
|
+
} = param;
|
|
41
|
+
var allThemesProxied = {};
|
|
42
|
+
var allThemesRaw = {};
|
|
43
|
+
var _iteratorNormalCompletion = true,
|
|
44
|
+
_didIteratorError = false,
|
|
43
45
|
_iteratorError = void 0;
|
|
44
46
|
try {
|
|
45
|
-
for (var _iterator = themes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion =
|
|
47
|
+
for (var _iterator = themes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
46
48
|
var {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
49
|
+
name,
|
|
50
|
+
theme
|
|
51
|
+
} = _step.value;
|
|
52
|
+
var res = _mutateTheme({
|
|
53
|
+
...props,
|
|
54
|
+
name,
|
|
55
|
+
theme,
|
|
56
|
+
// we'll do one update at the end
|
|
57
|
+
avoidUpdate: true,
|
|
58
|
+
// always add which also replaces but doesnt fail first time
|
|
59
|
+
mutationType: "add"
|
|
60
|
+
});
|
|
61
|
+
if (res) {
|
|
62
|
+
allThemesProxied[name] = res.theme;
|
|
63
|
+
allThemesRaw[name] = res.themeRaw;
|
|
64
|
+
}
|
|
60
65
|
}
|
|
61
66
|
} catch (err) {
|
|
62
|
-
_didIteratorError =
|
|
67
|
+
_didIteratorError = true;
|
|
68
|
+
_iteratorError = err;
|
|
63
69
|
} finally {
|
|
64
70
|
try {
|
|
65
|
-
!_iteratorNormalCompletion && _iterator.return != null
|
|
71
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
72
|
+
_iterator.return();
|
|
73
|
+
}
|
|
66
74
|
} finally {
|
|
67
|
-
if (_didIteratorError)
|
|
75
|
+
if (_didIteratorError) {
|
|
76
|
+
throw _iteratorError;
|
|
77
|
+
}
|
|
68
78
|
}
|
|
69
79
|
}
|
|
70
80
|
var cssRules = insertCSS ? insertThemeCSS(allThemesRaw, batch) : [];
|
|
71
|
-
|
|
81
|
+
(0, import_start_transition.startTransition)(function () {
|
|
72
82
|
for (var themeName in allThemesProxied) {
|
|
73
83
|
var theme2 = allThemesProxied[themeName];
|
|
74
84
|
updateThemeConfig(themeName, theme2);
|
|
75
85
|
}
|
|
76
86
|
updateThemeStates();
|
|
77
|
-
})
|
|
87
|
+
});
|
|
88
|
+
return {
|
|
78
89
|
themes: allThemesProxied,
|
|
79
90
|
themesRaw: allThemesRaw,
|
|
80
91
|
cssRules
|
|
@@ -82,77 +93,105 @@ function mutateThemes(param) {
|
|
|
82
93
|
}
|
|
83
94
|
function _mutateTheme(props) {
|
|
84
95
|
if (import_constants.isServer) {
|
|
85
|
-
process.env.NODE_ENV === "development"
|
|
96
|
+
if (process.env.NODE_ENV === "development") {
|
|
97
|
+
console.warn("Theme mutation is not supported on server side");
|
|
98
|
+
}
|
|
86
99
|
return;
|
|
87
100
|
}
|
|
88
|
-
var config = (0, import_web.getConfig)()
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
101
|
+
var config = (0, import_web.getConfig)();
|
|
102
|
+
var {
|
|
103
|
+
name: themeName,
|
|
104
|
+
theme: themeIn,
|
|
105
|
+
insertCSS,
|
|
106
|
+
mutationType
|
|
107
|
+
} = props;
|
|
95
108
|
if (process.env.NODE_ENV === "development") {
|
|
96
|
-
if (!config)
|
|
109
|
+
if (!config) {
|
|
110
|
+
throw new Error("No config");
|
|
111
|
+
}
|
|
97
112
|
var theme = config.themes[props.name];
|
|
98
|
-
if (mutationType !== "add" && !theme)
|
|
113
|
+
if (mutationType !== "add" && !theme) {
|
|
114
|
+
throw new Error(`${mutationType === "replace" ? "Replace" : "Update"} theme failed! Theme ${props.name} does not exist`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
var _config_themes_themeName;
|
|
118
|
+
var theme1 = {
|
|
119
|
+
...(mutationType === "update" ? (_config_themes_themeName = config.themes[themeName]) !== null && _config_themes_themeName !== void 0 ? _config_themes_themeName : {} : {}),
|
|
120
|
+
...themeIn
|
|
121
|
+
};
|
|
122
|
+
for (var key in theme1) {
|
|
123
|
+
(0, import_web.ensureThemeVariable)(theme1, key);
|
|
124
|
+
}
|
|
125
|
+
var themeProxied = (0, import_web.proxyThemeToParents)(themeName, theme1);
|
|
126
|
+
var response = {
|
|
127
|
+
themeRaw: theme1,
|
|
128
|
+
theme: themeProxied,
|
|
129
|
+
cssRules: []
|
|
130
|
+
};
|
|
131
|
+
if (props.avoidUpdate) {
|
|
132
|
+
return response;
|
|
99
133
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
themeRaw: theme1,
|
|
109
|
-
theme: themeProxied,
|
|
110
|
-
cssRules: []
|
|
111
|
-
};
|
|
112
|
-
return props.avoidUpdate || (insertCSS && (response.cssRules = insertThemeCSS({
|
|
113
|
-
[themeName]: theme1
|
|
114
|
-
})), updateThemeConfig(themeName, themeProxied), updateThemeStates()), response;
|
|
134
|
+
if (insertCSS) {
|
|
135
|
+
response.cssRules = insertThemeCSS({
|
|
136
|
+
[themeName]: theme1
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
updateThemeConfig(themeName, themeProxied);
|
|
140
|
+
updateThemeStates();
|
|
141
|
+
return response;
|
|
115
142
|
}
|
|
116
143
|
function updateThemeConfig(themeName, theme) {
|
|
117
144
|
var config = (0, import_web.getConfig)();
|
|
118
|
-
config.themes[themeName] = theme
|
|
145
|
+
config.themes[themeName] = theme;
|
|
146
|
+
(0, import_web.updateConfig)("themes", config.themes);
|
|
119
147
|
}
|
|
120
148
|
function updateThemeStates() {
|
|
121
149
|
(0, import_web.forceUpdateThemes)();
|
|
122
150
|
}
|
|
123
151
|
function insertThemeCSS(themes) {
|
|
124
|
-
var batch = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] :
|
|
125
|
-
|
|
126
|
-
|
|
152
|
+
var batch = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
153
|
+
if (true) {
|
|
154
|
+
return [];
|
|
155
|
+
}
|
|
156
|
+
var config = (0, import_web.getConfig)();
|
|
157
|
+
var cssRules = [];
|
|
127
158
|
for (var themeName in themes) {
|
|
128
|
-
var theme = themes[themeName]
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
cssRules = [...cssRules, ...rules]
|
|
159
|
+
var theme = themes[themeName];
|
|
160
|
+
var rules = (0, import_web.getThemeCSSRules)({
|
|
161
|
+
config,
|
|
162
|
+
themeName,
|
|
163
|
+
names: [themeName],
|
|
164
|
+
hasDarkLight: true,
|
|
165
|
+
theme,
|
|
166
|
+
// Use mutated variable creator which starts from high index to avoid conflicts
|
|
167
|
+
useMutatedVariables: true
|
|
168
|
+
});
|
|
169
|
+
cssRules = [...cssRules, ...rules];
|
|
170
|
+
if (!batch) {
|
|
171
|
+
updateStyle(`t_theme_style_${themeName}`, rules);
|
|
172
|
+
}
|
|
139
173
|
}
|
|
140
174
|
if (import_web.mutatedAutoVariables.length > 0) {
|
|
141
|
-
var autoVarCSS
|
|
142
|
-
|
|
175
|
+
var autoVarCSS = `:root{${import_web.mutatedAutoVariables.map(function (v) {
|
|
176
|
+
return `--${v.name}:${v.val}`;
|
|
177
|
+
}).join(";")}}`;
|
|
178
|
+
updateStyle(`t_mutate_vars`, [autoVarCSS]);
|
|
143
179
|
}
|
|
144
180
|
if (batch) {
|
|
145
|
-
var id;
|
|
181
|
+
var id = typeof batch == "string" ? batch : (0, import_web.simpleHash)(Object.keys(themes).join(""));
|
|
146
182
|
updateStyle(`t_theme_style_${id}`, cssRules);
|
|
147
183
|
}
|
|
184
|
+
return cssRules;
|
|
148
185
|
}
|
|
149
186
|
function updateStyle(id, rules) {
|
|
150
|
-
var existing = document.querySelector(`#${id}`)
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
187
|
+
var existing = document.querySelector(`#${id}`);
|
|
188
|
+
var style = document.createElement("style");
|
|
189
|
+
style.id = id;
|
|
190
|
+
style.appendChild(document.createTextNode(rules.join("\n")));
|
|
191
|
+
document.head.appendChild(style);
|
|
192
|
+
if (existing) {
|
|
154
193
|
var _existing_parentElement;
|
|
155
|
-
(_existing_parentElement = existing.parentElement) === null || _existing_parentElement === void 0
|
|
194
|
+
(_existing_parentElement = existing.parentElement) === null || _existing_parentElement === void 0 ? void 0 : _existing_parentElement.removeChild(existing);
|
|
156
195
|
}
|
|
157
196
|
}
|
|
158
197
|
//# sourceMappingURL=_mutateTheme.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","mutateTheme_exports","__export","_mutateTheme","mutateThemes","module","exports","import_constants","require","import_start_transition","import_web","param","themes","batch","insertCSS","props","allThemesProxied","allThemesRaw","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","Symbol","iterator","_step","next","done","name","theme","res","avoidUpdate","mutationType","themeRaw","err","return","cssRules","insertThemeCSS","startTransition","themeName","theme2","updateThemeConfig","updateThemeStates","themesRaw","isServer","process","env","NODE_ENV","console","warn","config","getConfig","themeIn","Error","_config_themes_themeName","theme1","key","ensureThemeVariable","themeProxied","proxyThemeToParents","response","updateConfig","forceUpdateThemes","arguments","length","rules","getThemeCSSRules","names","hasDarkLight","useMutatedVariables","updateStyle","mutatedAutoVariables"
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","mutateTheme_exports","__export","_mutateTheme","mutateThemes","module","exports","import_constants","require","import_start_transition","import_web","param","themes","batch","insertCSS","props","allThemesProxied","allThemesRaw","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","Symbol","iterator","_step","next","done","name","theme","res","avoidUpdate","mutationType","themeRaw","err","return","cssRules","insertThemeCSS","startTransition","themeName","theme2","updateThemeConfig","updateThemeStates","themesRaw","isServer","process","env","NODE_ENV","console","warn","config","getConfig","themeIn","Error","_config_themes_themeName","theme1","key","ensureThemeVariable","themeProxied","proxyThemeToParents","response","updateConfig","forceUpdateThemes","arguments","length","rules","getThemeCSSRules","names","hasDarkLight","useMutatedVariables","updateStyle","mutatedAutoVariables"],"sources":["../../src/_mutateTheme.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,mBAAA;AAAAC,QAAA,CAAAD,mBAAA;EAAAE,YAAA,EAAAA,CAAA,KAAAA,YAAA;EAAAC,YAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAV,YAAyB,CAAAK,mBAAA;AACzB,IAAAM,gBAAA,GAAAC,OAAgC;AAEhC,IAAAC,uBASO,GAAAD,OAAA;AAmBA,IAAAE,UAAS,GAAAF,OAAa;AAAA,SAC3BJ,aAAAO,KAAA;EACA;IAAAC,MAAA;IAAAC,KAAA;IAAAC,SAAA;IAAA,GAAAC;EAAA,IAAAJ,KAAA;EACA,IAAAK,gBAAY;EACZ,IAAGC,YAAA;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GAAW,IAAAvC,UAAa,CAAAwC,SAAQ;EAC9BD,MAAA,CAAArC,MAAM,CAAA0B,SAAe,IAAAV,KAAS;EAE9B,IAAAlB,UAAM,CAAAkD,YAAQ,YAAAX,MAAA,CAAArC,MAAiB;AAAA;AAC7B,SACA6B,kBAAA;EAAA,IACA/B,UAAQ,CAAAmD,iBAAS;AAAA;AACH,SACdzB,eAAAxB,MAAA;EAAA,IAAAC,KAAA,GAAAiD,SAAA,CAAAC,MAAA,QAAAD,SAAA,iBAAAA,SAAA;EAAA,IAEA;IACF,OAAC;EAED;EAEA,IAAAb,MAAK,IAAO,GAAAvC,UAAA,CAAAwC,SAAA;EACV,IAAAf,QAAA,KAAY;EAAmC,KACjD,IAAAG,SAAA,IAAA1B,MAAA;IACF,IAAAgB,KAAA,GAAAhB,MAAA,CAAA0B,SAAA;IAGA,IAAI0B,KAAA,OAAAtD,UAAA,CAAAuD,gBAA8B;MAChChB,MAAM;MACNX,SAAA;MACF4B,KAAA,GAEI5B,SAAO,CACT;MACA6B,YAAY;MACdvC,KAAA;MAEA;MACFwC,mBAAA;IAEA;IACEjC,QAAM,IACN,GAAMA,QAAQ,EACd,GAAM6B,KAAK,CACX;IACA,KAAAnD,KAAS,EAAK;MACVwD,WAAU,kBAAA/B,SAAA,IAAA0B,KAAA;IACZ;EACF;EACF,IAAAtD,UAAA,CAAA4D,oBAAA,CAAAP,MAAA","ignoreList":[]}
|
package/dist/cjs/addTheme.cjs
CHANGED
|
@@ -3,20 +3,22 @@ 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
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
14
|
get: () => from[key],
|
|
14
15
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
18
20
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value:
|
|
21
|
+
value: true
|
|
20
22
|
}), mod);
|
|
21
23
|
var addTheme_exports = {};
|
|
22
24
|
__export(addTheme_exports, {
|
|
@@ -27,7 +29,7 @@ var import_mutateTheme = require("./_mutateTheme.cjs");
|
|
|
27
29
|
function addTheme(props) {
|
|
28
30
|
return (0, import_mutateTheme._mutateTheme)({
|
|
29
31
|
...props,
|
|
30
|
-
insertCSS:
|
|
32
|
+
insertCSS: true,
|
|
31
33
|
mutationType: "add"
|
|
32
34
|
});
|
|
33
35
|
}
|
|
@@ -5,20 +5,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value:
|
|
23
|
+
value: true
|
|
22
24
|
}), mod);
|
|
23
25
|
var addTheme_exports = {};
|
|
24
26
|
__export(addTheme_exports, {
|
|
@@ -29,7 +31,7 @@ var import_mutateTheme = require("./_mutateTheme.native.js");
|
|
|
29
31
|
function addTheme(props) {
|
|
30
32
|
return (0, import_mutateTheme._mutateTheme)({
|
|
31
33
|
...props,
|
|
32
|
-
insertCSS:
|
|
34
|
+
insertCSS: true,
|
|
33
35
|
mutationType: "add"
|
|
34
36
|
});
|
|
35
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","addTheme_exports","__export","addTheme","module","exports","import_mutateTheme","require","props","_mutateTheme"],"sources":["../../src/addTheme.ts"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","addTheme_exports","__export","addTheme","module","exports","import_mutateTheme","require","props","_mutateTheme"],"sources":["../../src/addTheme.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,gBAAA;AAAAC,QAAA,CAAAD,gBAAA;EAAAE,QAAA,EAAAA,CAAA,KAAAA;AAAA;AAEAC,MAAA,CAAAC,OAAA,GAAAT,YAA6B,CAAAK,gBAAA;AAEtB,IAAAK,kBAAkB,GAItBC,OAAA;AACD,SAAAJ,QAAOA,CAAAK,KAAA;EACT,WAAAF,kBAAA,CAAAG,YAAA","ignoreList":[]}
|