@tamagui/theme 1.74.8 → 1.74.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/theme",
3
- "version": "1.74.8",
3
+ "version": "1.74.9",
4
4
  "sideEffects": false,
5
5
  "source": "src/index.ts",
6
6
  "types": "./types/index.d.ts",
@@ -21,14 +21,14 @@
21
21
  "clean:build": "tamagui-build clean:build"
22
22
  },
23
23
  "dependencies": {
24
- "@tamagui/constants": "1.74.8",
25
- "@tamagui/web": "1.74.8"
24
+ "@tamagui/constants": "1.74.9",
25
+ "@tamagui/web": "1.74.9"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "react": "*"
29
29
  },
30
30
  "devDependencies": {
31
- "@tamagui/build": "1.74.8",
31
+ "@tamagui/build": "1.74.9",
32
32
  "react": "^18.2.0"
33
33
  },
34
34
  "publishConfig": {
@@ -1,116 +0,0 @@
1
- import { isServer } from "@tamagui/constants";
2
- import {
3
- activeThemeManagers,
4
- ensureThemeVariable,
5
- getConfig,
6
- getThemeCSSRules,
7
- proxyThemeToParents,
8
- simpleHash,
9
- updateConfig
10
- } from "@tamagui/web";
11
- import { startTransition } from "react";
12
- function mutateThemes({
13
- themes,
14
- batch,
15
- insertCSS = !0,
16
- ...props
17
- }) {
18
- const allThemesProxied = {}, allThemesRaw = {};
19
- for (const { name, theme } of themes) {
20
- const res = _mutateTheme({
21
- ...props,
22
- name,
23
- theme,
24
- // we'll do one update at the end
25
- avoidUpdate: !0,
26
- // always add which also replaces but doesnt fail first time
27
- mutationType: "add"
28
- });
29
- res && (allThemesProxied[name] = res.theme, allThemesRaw[name] = res.themeRaw);
30
- }
31
- const cssRules = insertCSS ? insertThemeCSS(allThemesRaw, batch) : [];
32
- return startTransition(() => {
33
- for (const themeName in allThemesProxied) {
34
- const theme = allThemesProxied[themeName];
35
- updateThemeConfig(themeName, theme), notifyThemeManagersOfUpdate(themeName, theme);
36
- }
37
- }), {
38
- themes: allThemesProxied,
39
- themesRaw: allThemesRaw,
40
- cssRules
41
- };
42
- }
43
- function _mutateTheme(props) {
44
- if (isServer) {
45
- process.env.NODE_ENV === "development" && console.warn("Theme mutation is not supported on server side");
46
- return;
47
- }
48
- const config = getConfig(), { name: themeName, theme: themeIn, insertCSS, mutationType } = props;
49
- if (process.env.NODE_ENV === "development") {
50
- if (!config)
51
- throw new Error("No config");
52
- const theme2 = config.themes[props.name];
53
- if (mutationType !== "add" && !theme2)
54
- throw new Error(
55
- `${mutationType === "replace" ? "Replace" : "Update"} theme failed! Theme ${props.name} does not exist`
56
- );
57
- }
58
- const theme = {
59
- ...mutationType === "update" ? config.themes[themeName] ?? {} : {},
60
- ...themeIn
61
- };
62
- for (const key in theme)
63
- ensureThemeVariable(theme, key);
64
- const themeProxied = proxyThemeToParents(themeName, theme), response = {
65
- themeRaw: theme,
66
- theme: themeProxied,
67
- cssRules: []
68
- };
69
- return props.avoidUpdate || (insertCSS && (response.cssRules = insertThemeCSS({
70
- [themeName]: theme
71
- })), updateThemeConfig(themeName, themeProxied), notifyThemeManagersOfUpdate(themeName, themeProxied)), response;
72
- }
73
- function updateThemeConfig(themeName, theme) {
74
- const config = getConfig();
75
- config.themes[themeName] = theme, updateConfig("themes", config.themes);
76
- }
77
- function notifyThemeManagersOfUpdate(themeName, theme) {
78
- activeThemeManagers.forEach((manager) => {
79
- manager.state.name === themeName && manager.updateStateFromProps(
80
- {
81
- name: themeName,
82
- forceTheme: theme
83
- },
84
- !0
85
- );
86
- });
87
- }
88
- function insertThemeCSS(themes, batch = !1) {
89
- const config = getConfig();
90
- let cssRules = [];
91
- for (const themeName in themes) {
92
- const theme = themes[themeName], rules = getThemeCSSRules({
93
- // @ts-ignore this works but should be fixed types
94
- config,
95
- themeName,
96
- names: [themeName],
97
- theme
98
- });
99
- cssRules = [...cssRules, ...rules], batch || updateStyle(`t_theme_style_${themeName}`, rules);
100
- }
101
- if (batch) {
102
- const id = 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.mjs.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/_mutateTheme.ts"],
4
- "mappings": "AAAA,SAAS,gBAAgB;AAEzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB;AAgBzB,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ,GAAG;AACL,GAMG;AACD,QAAM,mBAAgD,CAAC,GACjD,eAA4C,CAAC;AAEnD,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,yBAAgB,MAAM;AACpB,eAAW,aAAa,kBAAkB;AACxC,YAAM,QAAQ,iBAAiB,SAAS;AACxC,wBAAkB,WAAW,KAAK,GAClC,4BAA4B,WAAW,KAAK;AAAA,IAC9C;AAAA,EACF,CAAC,GAEM;AAAA,IACL,QAAQ;AAAA,IACR,WAAW;AAAA,IACX;AAAA,EACF;AACF;AAEO,SAAS,aA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J,CAAC;AACH;AAEA,SAAS,eAAe,QAAsC,QAAQ,IAAO;AAK3E,QAAM,SAAS,UAAU;AACzB,MAAI,WAAqB,CAAC;AAE1B,aAAW,aAAa,QAAQ;AAC9B,UAAM,QAAQ,OAAO,SAAS,GAExB,QAAQ,iBAAiB;AAAA;AAAA,MAE7B;AAAA,MACA;AAAA,MACA,OAAO,CAAC,SAAS;AAAA,MACjB;AAAA,IACF,CAAC;AAED,eAAW,CAAC,GAAG,UAAU,GAAG,KAAK,GAE5B,SACH,YAAY,iBAAiB,SAAS,IAAI,KAAK;AAAA,EAEnD;AAEA,MAAI,OAAO;AACT,UAAM,KAAK,WAAW,OAAO,KAAK,MAAM,EAAE,KAAK,GAAG,CAAC;AACnD,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
- }
@@ -1,8 +0,0 @@
1
- import { _mutateTheme } from "./_mutateTheme";
2
- function addTheme(props) {
3
- return _mutateTheme({ ...props, insertCSS: !0, mutationType: "add" });
4
- }
5
- export {
6
- addTheme
7
- };
8
- //# sourceMappingURL=addTheme.mjs.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/addTheme.ts"],
4
- "mappings": "AAEA,SAAS,oBAAoB;AAEtB,SAAS,SAAS,OAItB;AACD,SAAO,aAAa,EAAE,GAAG,OAAO,WAAW,IAAM,cAAc,MAAM,CAAC;AACxE;",
5
- "names": []
6
- }
@@ -1,8 +0,0 @@
1
- export * from "./addTheme";
2
- export * from "./updateTheme";
3
- export * from "./replaceTheme";
4
- import { mutateThemes } from "./_mutateTheme";
5
- export {
6
- mutateThemes
7
- };
8
- //# sourceMappingURL=index.mjs.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/index.ts"],
4
- "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,oBAAoB;",
5
- "names": []
6
- }
@@ -1,11 +0,0 @@
1
- import { _mutateTheme } from "./_mutateTheme";
2
- function replaceTheme({
3
- name,
4
- theme
5
- }) {
6
- return _mutateTheme({ name, theme, insertCSS: !0, mutationType: "replace" });
7
- }
8
- export {
9
- replaceTheme
10
- };
11
- //# sourceMappingURL=replaceTheme.mjs.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/replaceTheme.ts"],
4
- "mappings": "AAEA,SAAS,oBAAoB;AAEtB,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA;AACF,GAGG;AAED,SADa,aAAa,EAAE,MAAM,OAAO,WAAW,IAAM,cAAc,UAAU,CAAC;AAErF;",
5
- "names": []
6
- }
@@ -1,11 +0,0 @@
1
- import { _mutateTheme } from "./_mutateTheme";
2
- function updateTheme({
3
- name,
4
- theme
5
- }) {
6
- return _mutateTheme({ name, theme, insertCSS: !0, mutationType: "update" });
7
- }
8
- export {
9
- updateTheme
10
- };
11
- //# sourceMappingURL=updateTheme.mjs.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/updateTheme.ts"],
4
- "mappings": "AAEA,SAAS,oBAAoB;AAEtB,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AACF,GAGG;AACD,SAAO,aAAa,EAAE,MAAM,OAAO,WAAW,IAAM,cAAc,SAAS,CAAC;AAC9E;",
5
- "names": []
6
- }
@@ -1,83 +0,0 @@
1
- import { isServer } from "@tamagui/constants";
2
- import {
3
- activeThemeManagers,
4
- ensureThemeVariable,
5
- getConfig,
6
- getThemeCSSRules,
7
- proxyThemeToParents,
8
- updateConfig
9
- } from "@tamagui/web";
10
- function _mutateTheme(props) {
11
- if (isServer) {
12
- if (process.env.NODE_ENV === "development") {
13
- console.warn("Theme mutation is not supported on server side");
14
- }
15
- return;
16
- }
17
- const config = getConfig();
18
- const { name: themeName, theme: themeIn, insertCSS, mutationType } = props;
19
- if (process.env.NODE_ENV === "development") {
20
- if (!config) {
21
- throw new Error("No config");
22
- }
23
- const theme2 = config.themes[props.name];
24
- if (mutationType && !theme2) {
25
- throw new Error(
26
- `${mutationType === "replace" ? "Replace" : "Update"} theme failed! Theme ${props.name} does not exist`
27
- );
28
- }
29
- if (!props.mutationType && theme2) {
30
- return { theme: theme2 };
31
- }
32
- }
33
- const theme = {
34
- ...mutationType === "update" ? config.themes[themeName] ?? {} : {},
35
- ...themeIn
36
- };
37
- for (const key in theme) {
38
- ensureThemeVariable(theme, key);
39
- }
40
- const themeProxied = proxyThemeToParents(themeName, theme, config.themes);
41
- config.themes[themeName] = themeProxied;
42
- let cssRules = [];
43
- updateConfig("themes", { ...config.themes, [themeName]: themeProxied });
44
- if (process.env.TAMAGUI_TARGET === "web") {
45
- if (insertCSS) {
46
- cssRules = getThemeCSSRules({
47
- // @ts-ignore this works but should be fixed types
48
- config,
49
- themeName,
50
- names: [themeName],
51
- theme
52
- });
53
- const id = `t_theme_style_${themeName}`;
54
- const existing = document.querySelector(`#${id}`);
55
- const style = document.createElement("style");
56
- style.id = id;
57
- style.appendChild(document.createTextNode(cssRules.join("\n")));
58
- document.head.appendChild(style);
59
- if (existing) {
60
- existing.parentElement?.removeChild(existing);
61
- }
62
- }
63
- }
64
- activeThemeManagers.forEach((manager) => {
65
- if (manager.state.name === props.name) {
66
- manager.updateState(
67
- {
68
- name: props.name,
69
- forceTheme: themeProxied
70
- },
71
- true
72
- );
73
- }
74
- });
75
- return {
76
- theme: themeProxied,
77
- cssRules
78
- };
79
- }
80
- export {
81
- _mutateTheme
82
- };
83
- //# sourceMappingUR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AiB;AAAA;AAAA,QAE1B;AAAA,QACA;AAAA,QACA,OAAO,CAAC,SAAS;AAAA,QACjB;AAAA,MACF,CAAC;AACD,YAAM,KAAK,iBAAiB;AAC5B,YAAM,WAAW,SAAS,cAAc,IAAI,IAAI;AAChD,YAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,YAAM,KAAK;AACX,YAAM,YAAY,SAAS,eAAe,SAAS,KAAK,IAAI,CAAC,CAAC;AAC9D,eAAS,KAAK,YAAY,KAAK;AAC/B,UAAI,UAAU;AACZ,iBAAS,eAAe,YAAY,QAAQ;AAAA,MAC9C;AAAA,IACF;AAAA,EACF;AAEA,sBAAoB,QAAQ,CAAC,YAAY;AACvC,QAAI,QAAQ,MAAM,SAAS,MAAM,MAAM;AACrC,cAAQ;AAAA,QACN;AAAA,UACE,MAAM,MAAM;AAAA,UACZ,YAAY;AAAA,QACd;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AAGD,SAAO;AAAA,IACL,OAAO;AAAA,IACP;AAAA,EACF;AACF;",
5
- "names": ["theme"]
6
- }
@@ -1,8 +0,0 @@
1
- import { _mutateTheme } from "./_mutateTheme";
2
- function addTheme(props) {
3
- return _mutateTheme({ ...props });
4
- }
5
- export {
6
- addTheme
7
- };
8
- //# sourceMappingURL=addTheme.mjs.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/addTheme.ts"],
4
- "mappings": "AAEA,SAAS,oBAAoB;AAEtB,SAAS,SAAS,OAItB;AACD,SAAO,aAAa,EAAE,GAAG,MAAM,CAAC;AAClC;",
5
- "names": []
6
- }
@@ -1,4 +0,0 @@
1
- export * from "./addTheme";
2
- export * from "./updateTheme";
3
- export * from "./replaceTheme";
4
- //# sourceMappingURL=index.mjs.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/index.ts"],
4
- "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;",
5
- "names": []
6
- }
@@ -1,12 +0,0 @@
1
- import { _mutateTheme } from "./_mutateTheme";
2
- function replaceTheme({
3
- name,
4
- theme
5
- }) {
6
- const next = _mutateTheme({ name, theme, insertCSS: true, mutationType: "replace" });
7
- return next;
8
- }
9
- export {
10
- replaceTheme
11
- };
12
- //# sourceMappingURL=replaceTheme.mjs.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/replaceTheme.ts"],
4
- "mappings": "AAEA,SAAS,oBAAoB;AAEtB,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA;AACF,GAGG;AACD,QAAM,OAAO,aAAa,EAAE,MAAM,OAAO,WAAW,MAAM,cAAc,UAAU,CAAC;AACnF,SAAO;AACT;",
5
- "names": []
6
- }
@@ -1,12 +0,0 @@
1
- import { _mutateTheme } from "./_mutateTheme";
2
- function updateTheme({
3
- name,
4
- theme
5
- }) {
6
- return _mutateTheme({ name, theme, insertCSS: true, mutationType: "update" });
7
- }
8
- globalThis["updateTheme"] = updateTheme;
9
- export {
10
- updateTheme
11
- };
12
- //# sourceMappingURL=updateTheme.mjs.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/updateTheme.ts"],
4
- "mappings": "AAEA,SAAS,oBAAoB;AAEtB,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AACF,GAGG;AACD,SAAO,aAAa,EAAE,MAAM,OAAO,WAAW,MAAM,cAAc,SAAS,CAAC;AAC9E;AAEA,WAAW,aAAa,IAAI;",
5
- "names": []
6
- }