@tamagui/core 1.0.1-beta.136 → 1.0.1-beta.137
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/addTheme.js +74 -0
- package/dist/cjs/addTheme.js.map +7 -0
- package/dist/cjs/contexts/TextAncestorContext.js +44 -0
- package/dist/cjs/contexts/TextAncestorContext.js.map +7 -0
- package/dist/cjs/contexts/ThemeContext.js +30 -0
- package/dist/cjs/contexts/ThemeContext.js.map +7 -0
- package/dist/cjs/createComponent.js +2 -2
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/createTamagui.js +18 -118
- package/dist/cjs/createTamagui.js.map +2 -2
- package/dist/cjs/createTheme.js +2 -5
- package/dist/cjs/createTheme.js.map +2 -2
- package/dist/cjs/ensureThemeVariable.js +152 -0
- package/dist/cjs/ensureThemeVariable.js.map +7 -0
- package/dist/cjs/helpers/ThemeManager.js +212 -0
- package/dist/cjs/helpers/ThemeManager.js.map +7 -0
- package/dist/cjs/helpers/createTamaguiProvider.js +1 -1
- package/dist/cjs/helpers/createTamaguiProvider.js.map +2 -2
- package/dist/cjs/helpers/ensureThemeVariable.js +152 -0
- package/dist/cjs/helpers/ensureThemeVariable.js.map +7 -0
- package/dist/cjs/helpers/getThemeCSSRules.js +98 -0
- package/dist/cjs/helpers/getThemeCSSRules.js.map +7 -0
- package/dist/cjs/helpers/getThemeCSSRules.native.js +31 -0
- package/dist/cjs/helpers/getThemeCSSRules.native.js.map +7 -0
- package/dist/cjs/helpers/themes.js +79 -0
- package/dist/cjs/helpers/themes.js.map +7 -0
- package/dist/cjs/hooks/useTheme.js +20 -11
- package/dist/cjs/hooks/useTheme.js.map +2 -2
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/loadTheme.js +64 -0
- package/dist/cjs/loadTheme.js.map +7 -0
- package/dist/cjs/updateTheme.js +44 -0
- package/dist/cjs/updateTheme.js.map +7 -0
- package/dist/cjs/vendor/Pressability.js +32 -0
- package/dist/cjs/vendor/Pressability.js.map +7 -0
- package/dist/cjs/vendor/Pressability.native.js +32 -0
- package/dist/cjs/vendor/Pressability.native.js.map +7 -0
- package/dist/cjs/views/Theme.js +1 -1
- package/dist/cjs/views/Theme.js.map +2 -2
- package/dist/cjs/views/ThemeProvider.js +1 -1
- package/dist/cjs/views/ThemeProvider.js.map +1 -1
- package/dist/cjs/views/ThemeReset.js +1 -1
- package/dist/cjs/views/ThemeReset.js.map +1 -1
- package/dist/esm/addTheme.js +50 -0
- package/dist/esm/addTheme.js.map +7 -0
- package/dist/esm/contexts/TextAncestorContext.js +15 -0
- package/dist/esm/contexts/TextAncestorContext.js.map +7 -0
- package/dist/esm/contexts/ThemeContext.js +6 -0
- package/dist/esm/contexts/ThemeContext.js.map +7 -0
- package/dist/esm/createComponent.js +2 -2
- package/dist/esm/createComponent.js.map +1 -1
- package/dist/esm/createTamagui.js +17 -117
- package/dist/esm/createTamagui.js.map +2 -2
- package/dist/esm/createTheme.js +1 -3
- package/dist/esm/createTheme.js.map +2 -2
- package/dist/esm/ensureThemeVariable.js +125 -0
- package/dist/esm/ensureThemeVariable.js.map +7 -0
- package/dist/esm/helpers/ThemeManager.js +186 -0
- package/dist/esm/helpers/ThemeManager.js.map +7 -0
- package/dist/esm/helpers/createTamaguiProvider.js +1 -1
- package/dist/esm/helpers/createTamaguiProvider.js.map +2 -2
- package/dist/esm/helpers/ensureThemeVariable.js +125 -0
- package/dist/esm/helpers/ensureThemeVariable.js.map +7 -0
- package/dist/esm/helpers/getThemeCSSRules.js +74 -0
- package/dist/esm/helpers/getThemeCSSRules.js.map +7 -0
- package/dist/esm/helpers/getThemeCSSRules.native.js +7 -0
- package/dist/esm/helpers/getThemeCSSRules.native.js.map +7 -0
- package/dist/esm/helpers/themes.js +54 -0
- package/dist/esm/helpers/themes.js.map +7 -0
- package/dist/esm/hooks/useTheme.js +23 -11
- package/dist/esm/hooks/useTheme.js.map +2 -2
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/loadTheme.js +40 -0
- package/dist/esm/loadTheme.js.map +7 -0
- package/dist/esm/updateTheme.js +20 -0
- package/dist/esm/updateTheme.js.map +7 -0
- package/dist/esm/vendor/Pressability.js +7 -0
- package/dist/esm/vendor/Pressability.js.map +7 -0
- package/dist/esm/vendor/Pressability.native.js +7 -0
- package/dist/esm/vendor/Pressability.native.js.map +7 -0
- package/dist/esm/views/Theme.js +1 -1
- package/dist/esm/views/Theme.js.map +1 -1
- package/dist/esm/views/ThemeProvider.js +1 -1
- package/dist/esm/views/ThemeProvider.js.map +1 -1
- package/dist/esm/views/ThemeReset.js +1 -1
- package/dist/esm/views/ThemeReset.js.map +1 -1
- package/package.json +8 -8
- package/types/addTheme.d.ts +11 -0
- package/types/{views → contexts}/TextAncestorContext.d.ts +0 -0
- package/types/{ThemeContext.d.ts → contexts/ThemeContext.d.ts} +1 -1
- package/types/createTheme.d.ts +0 -1
- package/types/{ThemeManager.d.ts → helpers/ThemeManager.d.ts} +5 -5
- package/types/helpers/getThemeCSSRules.d.ts +8 -0
- package/types/helpers/getThemeCSSRules.native.d.ts +2 -0
- package/types/helpers/themes.d.ts +4 -0
- package/types/hooks/useTheme.d.ts +2 -1
- package/types/index.d.ts +3 -1
- package/types/updateTheme.d.ts +9 -0
- package/types/{Pressability.d.ts → vendor/Pressability.d.ts} +0 -0
- package/types/{Pressability.native.d.ts → vendor/Pressability.native.d.ts} +0 -0
- package/types/views/Theme.d.ts +1 -1
- package/types/defaultComponentState.d.ts +0 -1
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var themes_exports = {};
|
|
20
|
+
__export(themes_exports, {
|
|
21
|
+
ensureThemeVariable: () => ensureThemeVariable,
|
|
22
|
+
proxyThemeToParents: () => proxyThemeToParents
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(themes_exports);
|
|
25
|
+
var import_createVariable = require("../createVariable");
|
|
26
|
+
var import_getThemeUnwrapped = require("../hooks/getThemeUnwrapped");
|
|
27
|
+
function ensureThemeVariable(theme, key) {
|
|
28
|
+
const val = theme[key];
|
|
29
|
+
const themeKey = key;
|
|
30
|
+
if (!(0, import_createVariable.isVariable)(val)) {
|
|
31
|
+
theme[key] = (0, import_createVariable.createVariable)({
|
|
32
|
+
key: themeKey,
|
|
33
|
+
name: themeKey,
|
|
34
|
+
val
|
|
35
|
+
});
|
|
36
|
+
} else {
|
|
37
|
+
if (val.name !== themeKey) {
|
|
38
|
+
theme[key] = (0, import_createVariable.createVariable)({
|
|
39
|
+
key: val.name,
|
|
40
|
+
name: themeKey,
|
|
41
|
+
val: val.val
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function proxyThemeToParents(themeName, theme, themes) {
|
|
47
|
+
const cur = [];
|
|
48
|
+
const parents = themeName.split("_").slice(0, -1).map((part) => {
|
|
49
|
+
cur.push(part);
|
|
50
|
+
return cur.join("_");
|
|
51
|
+
});
|
|
52
|
+
const hasParents = parents.length;
|
|
53
|
+
return new Proxy(theme, {
|
|
54
|
+
get(target, key) {
|
|
55
|
+
if (key === import_getThemeUnwrapped.GetThemeUnwrapped) {
|
|
56
|
+
return theme;
|
|
57
|
+
}
|
|
58
|
+
if (!hasParents || Reflect.has(target, key)) {
|
|
59
|
+
return Reflect.get(target, key);
|
|
60
|
+
}
|
|
61
|
+
for (let i = parents.length - 1; i >= 0; i--) {
|
|
62
|
+
const parent = themes[parents[i]];
|
|
63
|
+
if (!parent) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (Reflect.has(parent, key)) {
|
|
67
|
+
return Reflect.get(parent, key);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return Reflect.get(target, key);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
75
|
+
0 && (module.exports = {
|
|
76
|
+
ensureThemeVariable,
|
|
77
|
+
proxyThemeToParents
|
|
78
|
+
});
|
|
79
|
+
//# sourceMappingURL=themes.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/helpers/themes.ts"],
|
|
4
|
+
"sourcesContent": ["import { createVariable, isVariable } from '../createVariable'\nimport { GetThemeUnwrapped } from '../hooks/getThemeUnwrapped'\nimport { CreateTamaguiProps } from '../types'\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 hasParents = parents.length\n\n // proxy fallback values to parent theme values\n return new Proxy(theme, {\n get(target, key) {\n if (key === GetThemeUnwrapped) {\n return theme\n }\n if (!hasParents || Reflect.has(target, key)) {\n return Reflect.get(target, key)\n }\n // check parents\n for (let i = parents.length - 1; i >= 0; i--) {\n const parent = themes[parents[i]]\n if (!parent) {\n continue\n }\n if (Reflect.has(parent, key)) {\n return Reflect.get(parent, key)\n }\n }\n return Reflect.get(target, key)\n },\n })\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAA2C;AAC3C,+BAAkC;AAK3B,6BAA6B,OAAY,KAAa;AAC3D,QAAM,MAAM,MAAM;AAClB,QAAM,WAAW;AACjB,MAAI,CAAC,sCAAW,GAAG,GAAG;AACpB,UAAM,OAAO,0CAAe;AAAA,MAC1B,KAAK;AAAA,MACL,MAAM;AAAA,MACN;AAAA,IACF,CAAC;AAAA,EACH,OAAO;AACL,QAAI,IAAI,SAAS,UAAU;AAEzB,YAAM,OAAO,0CAAe;AAAA,QAC1B,KAAK,IAAI;AAAA,QACT,MAAM;AAAA,QACN,KAAK,IAAI;AAAA,MACX,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,6BACL,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,4CAAmB;AAC7B,eAAO;AAAA,MACT;AACA,UAAI,CAAC,cAAc,QAAQ,IAAI,QAAQ,GAAG,GAAG;AAC3C,eAAO,QAAQ,IAAI,QAAQ,GAAG;AAAA,MAChC;AAEA,eAAS,IAAI,QAAQ,SAAS,GAAG,KAAK,GAAG,KAAK;AAC5C,cAAM,SAAS,OAAO,QAAQ;AAC9B,YAAI,CAAC,QAAQ;AACX;AAAA,QACF;AACA,YAAI,QAAQ,IAAI,QAAQ,GAAG,GAAG;AAC5B,iBAAO,QAAQ,IAAI,QAAQ,GAAG;AAAA,QAChC;AAAA,MACF;AACA,aAAO,QAAQ,IAAI,QAAQ,GAAG;AAAA,IAChC;AAAA,EACF,CAAC;AACH;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var useTheme_exports = {};
|
|
20
20
|
__export(useTheme_exports, {
|
|
21
|
+
activeThemeManagers: () => activeThemeManagers,
|
|
21
22
|
getThemeManager: () => getThemeManager,
|
|
22
23
|
useChangeThemeEffect: () => useChangeThemeEffect,
|
|
23
24
|
useDefaultThemeName: () => useDefaultThemeName,
|
|
@@ -29,9 +30,9 @@ var import_use_force_update = require("@tamagui/use-force-update");
|
|
|
29
30
|
var import_react = require("react");
|
|
30
31
|
var import_conf = require("../conf");
|
|
31
32
|
var import_platform = require("../constants/platform");
|
|
33
|
+
var import_ThemeContext = require("../contexts/ThemeContext");
|
|
32
34
|
var import_areEqualSets = require("../helpers/areEqualSets");
|
|
33
|
-
var
|
|
34
|
-
var import_ThemeManager = require("../ThemeManager");
|
|
35
|
+
var import_ThemeManager = require("../helpers/ThemeManager");
|
|
35
36
|
var import_getThemeUnwrapped = require("./getThemeUnwrapped");
|
|
36
37
|
var import_useConstant = require("./useConstant");
|
|
37
38
|
const useTheme = (themeName, componentName, props, forceUpdate) => {
|
|
@@ -58,13 +59,14 @@ const useTheme = (themeName, componentName, props, forceUpdate) => {
|
|
|
58
59
|
themeManager == null ? void 0 : themeManager.track(st.uuid, st.keys);
|
|
59
60
|
}
|
|
60
61
|
});
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
return themes[(0, import_conf.getConfig)().defaultTheme || "light"];
|
|
62
|
+
const debugProp = props && props["debug"];
|
|
63
|
+
if (!theme) {
|
|
64
|
+
if (process.env.NODE_ENV === "development") {
|
|
65
|
+
console.warn("No theme", { themeName, theme, componentName, className });
|
|
67
66
|
}
|
|
67
|
+
return themes[(0, import_conf.getConfig)().defaultTheme || Object.keys(themes)[0]];
|
|
68
|
+
}
|
|
69
|
+
return (0, import_react.useMemo)(() => {
|
|
68
70
|
return new Proxy(theme, {
|
|
69
71
|
has(_, key) {
|
|
70
72
|
if (typeof key === "string") {
|
|
@@ -99,14 +101,14 @@ const useTheme = (themeName, componentName, props, forceUpdate) => {
|
|
|
99
101
|
}
|
|
100
102
|
if (state.current.isRendering && !state.current.keys.has(key)) {
|
|
101
103
|
state.current.keys.add(key);
|
|
102
|
-
if (process.env.NODE_ENV === "development" &&
|
|
104
|
+
if (process.env.NODE_ENV === "development" && debugProp === "verbose") {
|
|
103
105
|
console.log(" \u{1F538} tracking theme", key);
|
|
104
106
|
}
|
|
105
107
|
}
|
|
106
108
|
return themeManager.getValue(key);
|
|
107
109
|
}
|
|
108
110
|
});
|
|
109
|
-
}, [name, theme, className]);
|
|
111
|
+
}, [name, theme, componentName, className, debugProp]);
|
|
110
112
|
};
|
|
111
113
|
const GetThemeManager = Symbol();
|
|
112
114
|
const getThemeManager = (theme) => {
|
|
@@ -133,6 +135,7 @@ const useDefaultThemeName = () => {
|
|
|
133
135
|
var _a;
|
|
134
136
|
return (_a = (0, import_react.useContext)(import_ThemeContext.ThemeContext)) == null ? void 0 : _a.defaultTheme;
|
|
135
137
|
};
|
|
138
|
+
const activeThemeManagers = /* @__PURE__ */ new Set();
|
|
136
139
|
const useChangeThemeEffect = (name, componentName, props, forceUpdateProp) => {
|
|
137
140
|
const debug = props && props["debug"];
|
|
138
141
|
const parentManager = (0, import_react.useContext)(import_ThemeManager.ThemeManagerContext) || import_ThemeManager.emptyManager;
|
|
@@ -150,10 +153,11 @@ const useChangeThemeEffect = (name, componentName, props, forceUpdateProp) => {
|
|
|
150
153
|
(0, import_react.useLayoutEffect)(() => {
|
|
151
154
|
if (!themeManager)
|
|
152
155
|
return;
|
|
156
|
+
activeThemeManagers.add(themeManager);
|
|
153
157
|
if (next == null ? void 0 : next.name) {
|
|
154
158
|
themeManager.update(next);
|
|
155
159
|
}
|
|
156
|
-
|
|
160
|
+
const disposeParentOnChange = parentManager.onChangeTheme(() => {
|
|
157
161
|
const next2 = parentManager.getNextTheme(getThemeProps, debug);
|
|
158
162
|
if (!next2)
|
|
159
163
|
return;
|
|
@@ -161,6 +165,10 @@ const useChangeThemeEffect = (name, componentName, props, forceUpdateProp) => {
|
|
|
161
165
|
forceUpdate();
|
|
162
166
|
}
|
|
163
167
|
});
|
|
168
|
+
return () => {
|
|
169
|
+
activeThemeManagers.delete(themeManager);
|
|
170
|
+
disposeParentOnChange();
|
|
171
|
+
};
|
|
164
172
|
}, [themes, name, componentName, debug, next == null ? void 0 : next.name]);
|
|
165
173
|
}
|
|
166
174
|
return {
|
|
@@ -175,6 +183,7 @@ const useChangeThemeEffect = (name, componentName, props, forceUpdateProp) => {
|
|
|
175
183
|
};
|
|
176
184
|
// Annotate the CommonJS export names for ESM import in node:
|
|
177
185
|
0 && (module.exports = {
|
|
186
|
+
activeThemeManagers,
|
|
178
187
|
getThemeManager,
|
|
179
188
|
useChangeThemeEffect,
|
|
180
189
|
useDefaultThemeName,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useTheme.tsx"],
|
|
4
|
-
"sourcesContent": ["import { useForceUpdate } from '@tamagui/use-force-update'\nimport React, { useContext, useLayoutEffect, useMemo, useRef, useState } from 'react'\n\nimport { getConfig } from '../conf'\nimport { isWeb, useIsomorphicLayoutEffect } from '../constants/platform'\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAA+B;AAC/B,mBAA8E;AAE9E,kBAA0B;AAC1B,sBAAiD;AACjD,0BAA6B;AAC7B,0BAA6B;AAC7B,
|
|
4
|
+
"sourcesContent": ["import { useForceUpdate } from '@tamagui/use-force-update'\nimport React, { useContext, useLayoutEffect, useMemo, useRef, useState } from 'react'\n\nimport { getConfig } from '../conf'\nimport { isWeb, useIsomorphicLayoutEffect } from '../constants/platform'\nimport { ThemeContext } from '../contexts/ThemeContext'\nimport { areEqualSets } from '../helpers/areEqualSets'\nimport {\n GetNextThemeProps,\n ThemeManager,\n ThemeManagerContext,\n emptyManager,\n} from '../helpers/ThemeManager'\nimport { ThemeName, ThemeObject } from '../types'\nimport { GetThemeUnwrapped } from './getThemeUnwrapped'\nimport { useConstant } from './useConstant'\n\nexport type ThemeProps = {\n className?: string\n disableThemeClass?: boolean\n name: Exclude<ThemeName, number> | null\n componentName?: string\n children?: any\n reset?: boolean\n debug?: boolean | 'verbose'\n}\n\ntype UseThemeState = {\n uuid: Object\n keys: Set<string>\n isRendering: boolean\n}\n\nexport const useTheme = (\n themeName?: string | null,\n componentName?: string,\n props?: ThemeProps,\n forceUpdate?: any\n): ThemeObject => {\n const { name, theme, themes, themeManager, className } = useChangeThemeEffect(\n themeName,\n componentName,\n props,\n forceUpdate\n )\n\n if (process.env.NODE_ENV === 'development') {\n if (props?.debug === 'verbose') {\n console.log(' \uD83D\uDD39 useTheme', { themeName, componentName, name, className })\n }\n }\n\n const state = useRef() as React.MutableRefObject<UseThemeState>\n if (!state.current) {\n state.current = {\n uuid: {},\n keys: new Set(),\n isRendering: true,\n }\n }\n state.current.isRendering = true\n\n // track usage\n useIsomorphicLayoutEffect(() => {\n const st = state.current\n st.isRendering = false\n const cur = themeManager?.keys.get(st.uuid)\n if (!cur || !areEqualSets(st.keys, cur)) {\n themeManager?.track(st.uuid, st.keys)\n }\n })\n\n const debugProp = props && props['debug']\n\n if (!theme) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('No theme', { themeName, theme, componentName, className })\n }\n return themes[getConfig().defaultTheme || Object.keys(themes)[0]]\n }\n\n return useMemo(() => {\n return new Proxy(theme, {\n has(_, key) {\n if (typeof key === 'string') {\n if (key[0] === '$') {\n key = key.slice(1)\n }\n }\n return Reflect.has(theme, key)\n },\n get(_, key) {\n if (key === GetThemeUnwrapped) {\n return theme\n }\n if (key === GetThemeManager) {\n return themeManager\n }\n if (key === 'name') {\n return name\n }\n if (key === 'className') {\n return className\n }\n if (!name || key === '__proto__' || typeof key === 'symbol' || key === '$typeof') {\n return Reflect.get(_, key)\n }\n if (!themeManager) {\n console.error('No themeManager')\n return\n }\n // auto convert variables to plain\n if (key[0] === '$') {\n key = key.slice(1)\n }\n if (state.current.isRendering && !state.current.keys.has(key)) {\n state.current.keys.add(key)\n if (process.env.NODE_ENV === 'development' && debugProp === 'verbose') {\n console.log(' \uD83D\uDD38 tracking theme', key)\n }\n }\n return themeManager.getValue(key)\n },\n })\n }, [name, theme, componentName, className, debugProp])\n}\n\nconst GetThemeManager = Symbol()\n\nexport const getThemeManager = (theme: any): ThemeManager | undefined => {\n if (!theme) return\n return theme[GetThemeManager]\n}\n\nexport const useThemeName = (opts?: { parent?: true }) => {\n const parent = useContext(ThemeManagerContext)\n const [name, setName] = useState(parent?.name || '')\n\n useIsomorphicLayoutEffect(() => {\n if (!parent) return\n return parent.onChangeTheme((next, manager) => {\n const name = opts?.parent ? manager.parentName || next : next\n if (!name) return\n setName(name)\n })\n }, [parent])\n\n return name\n}\n\nexport const useDefaultThemeName = () => {\n return useContext(ThemeContext)?.defaultTheme\n}\n\nexport const activeThemeManagers = new Set<ThemeManager>()\n\nexport const useChangeThemeEffect = (\n name?: string | null,\n componentName?: string,\n props?: ThemeProps,\n forceUpdateProp?: any\n) => {\n const debug = props && props['debug']\n const parentManager = useContext(ThemeManagerContext) || emptyManager\n const { themes } = useContext(ThemeContext)!\n const reset = props?.reset || false\n const getThemeProps: GetNextThemeProps = { name, componentName, themes, reset }\n const next = parentManager.getNextTheme(getThemeProps, debug)\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const forceUpdate = forceUpdateProp || useForceUpdate()\n\n const themeManager = useConstant<ThemeManager | null>(() => {\n if (!next) return null\n return new ThemeManager(next.name, next.theme, parentManager, reset)\n })\n\n // if not SSR\n if (!isWeb || typeof document !== 'undefined') {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useLayoutEffect(() => {\n if (!themeManager) return\n\n activeThemeManagers.add(themeManager)\n\n if (next?.name) {\n themeManager.update(next)\n }\n\n const disposeParentOnChange = parentManager.onChangeTheme(() => {\n const next = parentManager.getNextTheme(getThemeProps, debug)\n if (!next) return\n if (themeManager.update(next)) {\n forceUpdate()\n }\n })\n\n return () => {\n activeThemeManagers.delete(themeManager)\n disposeParentOnChange()\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [themes, name, componentName, debug, next?.name])\n }\n\n return {\n ...(parentManager && {\n name: parentManager.name,\n theme: parentManager.theme,\n }),\n ...next,\n themes,\n themeManager,\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAA+B;AAC/B,mBAA8E;AAE9E,kBAA0B;AAC1B,sBAAiD;AACjD,0BAA6B;AAC7B,0BAA6B;AAC7B,0BAKO;AAEP,+BAAkC;AAClC,yBAA4B;AAkBrB,MAAM,WAAW,CACtB,WACA,eACA,OACA,gBACgB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A,IACH;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -39,6 +39,8 @@ __reExport(src_exports, require("./createTokens"), module.exports);
|
|
|
39
39
|
__reExport(src_exports, require("./createVariable"), module.exports);
|
|
40
40
|
__reExport(src_exports, require("./createVariables"), module.exports);
|
|
41
41
|
__reExport(src_exports, require("./insertFont"), module.exports);
|
|
42
|
+
__reExport(src_exports, require("./addTheme"), module.exports);
|
|
43
|
+
__reExport(src_exports, require("./updateTheme"), module.exports);
|
|
42
44
|
__reExport(src_exports, require("./styled"), module.exports);
|
|
43
45
|
__reExport(src_exports, require("./types"), module.exports);
|
|
44
46
|
var import_conf = require("./conf");
|
|
@@ -77,7 +79,7 @@ __reExport(src_exports, require("./hooks/useUnmountEffect"), module.exports);
|
|
|
77
79
|
__reExport(src_exports, require("./views/Slot"), module.exports);
|
|
78
80
|
__reExport(src_exports, require("./views/Stack"), module.exports);
|
|
79
81
|
__reExport(src_exports, require("./views/Text"), module.exports);
|
|
80
|
-
var import_TextAncestorContext = require("./
|
|
82
|
+
var import_TextAncestorContext = require("./contexts/TextAncestorContext");
|
|
81
83
|
__reExport(src_exports, require("./views/Theme"), module.exports);
|
|
82
84
|
__reExport(src_exports, require("./views/ThemeInverse"), module.exports);
|
|
83
85
|
__reExport(src_exports, require("./views/ThemeProvider"), module.exports);
|
package/dist/cjs/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'\nexport * from './createComponent'\nexport * from './createShorthands'\nexport * from './createTheme'\nexport * from './createTamagui'\nexport * from './createFont'\nexport * from './createTokens'\nexport * from './createVariable'\nexport * from './createVariables'\nexport * from './insertFont'\nexport * from './styled'\nexport * from './types'\n// for type portability\nexport type { RNWTextProps, RNWViewProps } from './types-rnw'\nexport { getHasConfigured, getConfig, getThemes, getTokens, onConfiguredOnce } from './conf'\n\nexport * from './constants/constants'\nexport * from './constants/platform'\nexport { createDOMProps } from '@tamagui/rnw'\n\nexport * from './helpers/calc'\nexport * from './helpers/createShallowUpdate'\nexport * from './helpers/getStackSize'\nexport * from './helpers/getVariantExtras'\nexport * from './helpers/getExpandedShorthands'\nexport * from './helpers/getSize'\nexport * from './helpers/getSplitStyles'\nexport * from './helpers/getStylesAtomic'\nexport * from './helpers/pseudoDescriptors'\nexport * from './helpers/mergeProps'\nexport * from './helpers/expandStyles'\nexport * from './helpers/getFont'\nexport * from './helpers/isObj'\nexport * from './helpers/isTamaguiElement'\nexport * from './helpers/isTamaguiComponent'\nexport * from './helpers/matchMedia'\nexport * from './helpers/startTransition'\nexport * from './helpers/themeable'\nexport * from './helpers/withStaticProperties'\n\nexport * from './contexts/ButtonInsideButtonContext'\n\nexport * from './hooks/useConstant'\nexport * from './hooks/useId'\nexport * from './hooks/useIsMounted'\nexport * from './hooks/useIsTouchDevice'\nexport * from './hooks/useMedia'\nexport * from './hooks/usePressable'\nexport * from './hooks/useTheme'\nexport * from './hooks/useIsSSR'\nexport * from './hooks/useUnmountEffect'\n\nexport * from './views/Slot'\nexport * from './views/Stack'\nexport * from './views/Text'\nexport { TextAncestorProvider, TextAncestorContext } from './
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAc,sBAAd;AACA,wBAAc,8BADd;AAEA,wBAAc,+BAFd;AAGA,wBAAc,0BAHd;AAIA,wBAAc,4BAJd;AAKA,wBAAc,yBALd;AAMA,wBAAc,2BANd;AAOA,wBAAc,6BAPd;AAQA,wBAAc,8BARd;AASA,wBAAc,yBATd;AAUA,wBAAc,
|
|
4
|
+
"sourcesContent": ["export * from './Tamagui'\nexport * from './createComponent'\nexport * from './createShorthands'\nexport * from './createTheme'\nexport * from './createTamagui'\nexport * from './createFont'\nexport * from './createTokens'\nexport * from './createVariable'\nexport * from './createVariables'\nexport * from './insertFont'\nexport * from './addTheme'\nexport * from './updateTheme'\nexport * from './styled'\nexport * from './types'\n\n// for type portability\nexport type { RNWTextProps, RNWViewProps } from './types-rnw'\nexport { getHasConfigured, getConfig, getThemes, getTokens, onConfiguredOnce } from './conf'\n\nexport * from './constants/constants'\nexport * from './constants/platform'\nexport { createDOMProps } from '@tamagui/rnw'\n\nexport * from './helpers/calc'\nexport * from './helpers/createShallowUpdate'\nexport * from './helpers/getStackSize'\nexport * from './helpers/getVariantExtras'\nexport * from './helpers/getExpandedShorthands'\nexport * from './helpers/getSize'\nexport * from './helpers/getSplitStyles'\nexport * from './helpers/getStylesAtomic'\nexport * from './helpers/pseudoDescriptors'\nexport * from './helpers/mergeProps'\nexport * from './helpers/expandStyles'\nexport * from './helpers/getFont'\nexport * from './helpers/isObj'\nexport * from './helpers/isTamaguiElement'\nexport * from './helpers/isTamaguiComponent'\nexport * from './helpers/matchMedia'\nexport * from './helpers/startTransition'\nexport * from './helpers/themeable'\nexport * from './helpers/withStaticProperties'\n\nexport * from './contexts/ButtonInsideButtonContext'\n\nexport * from './hooks/useConstant'\nexport * from './hooks/useId'\nexport * from './hooks/useIsMounted'\nexport * from './hooks/useIsTouchDevice'\nexport * from './hooks/useMedia'\nexport * from './hooks/usePressable'\nexport * from './hooks/useTheme'\nexport * from './hooks/useIsSSR'\nexport * from './hooks/useUnmountEffect'\n\nexport * from './views/Slot'\nexport * from './views/Stack'\nexport * from './views/Text'\nexport { TextAncestorProvider, TextAncestorContext } from './contexts/TextAncestorContext'\nexport * from './views/Theme'\nexport * from './views/ThemeInverse'\nexport * from './views/ThemeProvider'\nexport * from './views/ThemeReset'\nexport * from './views/FontLanguage'\n\nexport * from '@tamagui/use-force-update'\nexport * from '@tamagui/use-event'\nexport * from '@tamagui/helpers'\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;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DA,wBAAc,kCA7Dd;AA8DA,wBAAc,+BA9Dd;AA+DA,wBAAc,iCA/Dd;AAiEA,wBAAc,sCAjEd;AAkEA,wBAAc,+BAlEd;AAmEA,wBAAc,6BAnEd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var loadTheme_exports = {};
|
|
20
|
+
__export(loadTheme_exports, {
|
|
21
|
+
loadTheme: () => loadTheme
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(loadTheme_exports);
|
|
24
|
+
var import_conf = require("./conf");
|
|
25
|
+
var import_themes = require("./helpers/themes");
|
|
26
|
+
const loadTheme = ({
|
|
27
|
+
name: themeName,
|
|
28
|
+
theme: themeIn,
|
|
29
|
+
insertCSS
|
|
30
|
+
}) => {
|
|
31
|
+
const config = (0, import_conf.getConfig)();
|
|
32
|
+
if (!config) {
|
|
33
|
+
throw new Error(`Must run createTamagui once before loading theme`);
|
|
34
|
+
}
|
|
35
|
+
if (config.themes[themeName]) {
|
|
36
|
+
throw new Error(`Already defined theme "${themeName}", use updateTheme to change values`);
|
|
37
|
+
}
|
|
38
|
+
const theme = { ...themeIn };
|
|
39
|
+
for (const key in theme) {
|
|
40
|
+
(0, import_themes.ensureThemeVariable)(theme, key);
|
|
41
|
+
}
|
|
42
|
+
const cssRules = (0, import_themes.getThemeCSSRules)({
|
|
43
|
+
config,
|
|
44
|
+
themeName,
|
|
45
|
+
names: [themeName],
|
|
46
|
+
theme
|
|
47
|
+
});
|
|
48
|
+
const themeProxied = (0, import_themes.proxyThemeToParents)(themeName, theme, config.themes);
|
|
49
|
+
config.themes[themeName] = themeProxied;
|
|
50
|
+
if (insertCSS && typeof document !== "undefined") {
|
|
51
|
+
const style = document.createElement("style");
|
|
52
|
+
style.appendChild(document.createTextNode(cssRules.join("\n")));
|
|
53
|
+
document.head.appendChild(style);
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
theme: themeProxied,
|
|
57
|
+
cssRules
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
+
0 && (module.exports = {
|
|
62
|
+
loadTheme
|
|
63
|
+
});
|
|
64
|
+
//# sourceMappingURL=loadTheme.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/loadTheme.ts"],
|
|
4
|
+
"sourcesContent": ["import { getConfig } from './conf'\nimport { ensureThemeVariable, getThemeCSSRules, proxyThemeToParents } from './helpers/themes'\nimport { ThemeObject } from './types'\n\nexport const loadTheme = ({\n name: themeName,\n theme: themeIn,\n insertCSS,\n}: {\n name: string\n theme: ThemeObject\n insertCSS?: boolean\n}) => {\n const config = getConfig()\n if (!config) {\n throw new Error(`Must run createTamagui once before loading theme`)\n }\n if (config.themes[themeName]) {\n throw new Error(`Already defined theme \"${themeName}\", use updateTheme to change values`)\n }\n const theme = { ...themeIn }\n for (const key in theme) {\n ensureThemeVariable(theme, key)\n }\n const cssRules = getThemeCSSRules({\n config,\n themeName,\n names: [themeName],\n theme,\n })\n const themeProxied = proxyThemeToParents(themeName, theme, config.themes)\n config.themes[themeName] = themeProxied\n\n if (insertCSS && typeof document !== 'undefined') {\n const style = document.createElement('style')\n style.appendChild(document.createTextNode(cssRules.join('\\n')))\n document.head.appendChild(style)\n }\n\n return {\n theme: themeProxied,\n cssRules,\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA0B;AAC1B,oBAA2E;AAGpE,MAAM,YAAY,CAAC;AAAA,EACxB,MAAM;AAAA,EACN,OAAO;AAAA,EACP;AAAA,MAKI;AACJ,QAAM,SAAS,2BAAU;AACzB,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,kDAAkD;AAAA,EACpE;AACA,MAAI,OAAO,OAAO,YAAY;AAC5B,UAAM,IAAI,MAAM,0BAA0B,8CAA8C;AAAA,EAC1F;AACA,QAAM,QAAQ,EAAE,GAAG,QAAQ;AAC3B,aAAW,OAAO,OAAO;AACvB,2CAAoB,OAAO,GAAG;AAAA,EAChC;AACA,QAAM,WAAW,oCAAiB;AAAA,IAChC;AAAA,IACA;AAAA,IACA,OAAO,CAAC,SAAS;AAAA,IACjB;AAAA,EACF,CAAC;AACD,QAAM,eAAe,uCAAoB,WAAW,OAAO,OAAO,MAAM;AACxE,SAAO,OAAO,aAAa;AAE3B,MAAI,aAAa,OAAO,aAAa,aAAa;AAChD,UAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,UAAM,YAAY,SAAS,eAAe,SAAS,KAAK,IAAI,CAAC,CAAC;AAC9D,aAAS,KAAK,YAAY,KAAK;AAAA,EACjC;AAEA,SAAO;AAAA,IACL,OAAO;AAAA,IACP;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var updateTheme_exports = {};
|
|
20
|
+
__export(updateTheme_exports, {
|
|
21
|
+
updateTheme: () => updateTheme
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(updateTheme_exports);
|
|
24
|
+
var import_addTheme = require("./addTheme");
|
|
25
|
+
var import_useTheme = require("./hooks/useTheme");
|
|
26
|
+
function updateTheme({ name, theme }) {
|
|
27
|
+
const next = (0, import_addTheme.addTheme)({ name, theme, insertCSS: true, update: true });
|
|
28
|
+
if (process.env.TAMAGUI_TARGET === "native") {
|
|
29
|
+
import_useTheme.activeThemeManagers.forEach((manager) => {
|
|
30
|
+
if (manager.name === name) {
|
|
31
|
+
manager.update({
|
|
32
|
+
name,
|
|
33
|
+
theme: next.theme
|
|
34
|
+
}, true);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return next;
|
|
39
|
+
}
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
updateTheme
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=updateTheme.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/updateTheme.ts"],
|
|
4
|
+
"sourcesContent": ["import { addTheme } from './addTheme'\nimport { activeThemeManagers } from './hooks/useTheme'\nimport { ThemeObject } from './types'\n\nexport function updateTheme({ name, theme }: { name: string; theme: ThemeObject }) {\n const next = addTheme({ name, theme, insertCSS: true, update: true })\n\n if (process.env.TAMAGUI_TARGET === 'native') {\n activeThemeManagers.forEach((manager) => {\n if (manager.name === name) {\n manager.update(\n {\n name,\n theme: next.theme,\n },\n true\n )\n }\n })\n }\n\n return next\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAyB;AACzB,sBAAoC;AAG7B,qBAAqB,EAAE,MAAM,SAA+C;AACjF,QAAM,OAAO,8BAAS,EAAE,MAAM,OAAO,WAAW,MAAM,QAAQ,KAAK,CAAC;AAEpE,MAAI,QAAQ,IAAI,mBAAmB,UAAU;AAC3C,wCAAoB,QAAQ,CAAC,YAAY;AACvC,UAAI,QAAQ,SAAS,MAAM;AACzB,gBAAQ,OACN;AAAA,UACE;AAAA,UACA,OAAO,KAAK;AAAA,QACd,GACA,IACF;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var Pressability_exports = {};
|
|
20
|
+
__export(Pressability_exports, {
|
|
21
|
+
Pressability: () => Pressability,
|
|
22
|
+
usePressability: () => usePressability
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(Pressability_exports);
|
|
25
|
+
const Pressability = {};
|
|
26
|
+
const usePressability = {};
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
Pressability,
|
|
30
|
+
usePressability
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=Pressability.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/vendor/Pressability.tsx"],
|
|
4
|
+
"sourcesContent": ["export const Pressability = {} as any\nexport const usePressability = {} as Function\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,eAAe,CAAC;AACtB,MAAM,kBAAkB,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var Pressability_native_exports = {};
|
|
20
|
+
__export(Pressability_native_exports, {
|
|
21
|
+
Pressability: () => Pressability,
|
|
22
|
+
usePressability: () => usePressability
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(Pressability_native_exports);
|
|
25
|
+
const Pressability = require("react-native/Libraries/Pressability/Pressability").default;
|
|
26
|
+
const usePressability = require("react-native/Libraries/Pressability/usePressability").default;
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
Pressability,
|
|
30
|
+
usePressability
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=Pressability.native.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/vendor/Pressability.native.tsx"],
|
|
4
|
+
"sourcesContent": ["export const Pressability = require('react-native/Libraries/Pressability/Pressability').default\nexport const usePressability =\n require('react-native/Libraries/Pressability/usePressability').default\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,eAAe,QAAQ,kDAAkD,EAAE;AACjF,MAAM,kBACX,QAAQ,qDAAqD,EAAE;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/cjs/views/Theme.js
CHANGED
|
@@ -27,8 +27,8 @@ __export(Theme_exports, {
|
|
|
27
27
|
module.exports = __toCommonJS(Theme_exports);
|
|
28
28
|
var import_react = __toESM(require("react"));
|
|
29
29
|
var import_platform = require("../constants/platform");
|
|
30
|
+
var import_ThemeManager = require("../helpers/ThemeManager");
|
|
30
31
|
var import_useTheme = require("../hooks/useTheme");
|
|
31
|
-
var import_ThemeManager = require("../ThemeManager");
|
|
32
32
|
import_react.default["createElement"];
|
|
33
33
|
const Theme = (0, import_react.memo)(function Theme2(props) {
|
|
34
34
|
var _a, _b;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/Theme.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { memo, useMemo } from 'react'\n\nimport { isWeb } from '../constants/platform'\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAqC;AAErC,sBAAsB;AACtB,
|
|
4
|
+
"sourcesContent": ["import React, { memo, useMemo } from 'react'\n\nimport { isWeb } from '../constants/platform'\nimport { ThemeManager, ThemeManagerContext } from '../helpers/ThemeManager'\nimport { ThemeProps, useChangeThemeEffect } from '../hooks/useTheme'\n\n// bugfix esbuild strips react jsx: 'preserve'\nReact['createElement']\n\nexport const Theme = memo(function Theme(props: ThemeProps) {\n const { name, theme, themeManager, themes, className } = useChangeThemeEffect(\n props.name,\n props.componentName,\n props\n )\n\n const missingTheme = !themes || !name || !theme\n\n // memo here, changing theme without re-rendering all children is a critical optimization\n // may require some effort of end user to memoize but without this memo they'd have no option\n const contents = useMemo(\n () => (missingTheme ? null : wrapThemeManagerContext(props.children, themeManager)),\n [props.children, themeManager]\n )\n\n if (missingTheme) {\n if (name && !theme && process.env.NODE_ENV === 'development') {\n console.warn(`No theme found by name ${name}`)\n }\n return props.children\n }\n\n if (isWeb) {\n return (\n <span\n className={(!props.disableThemeClass\n ? [props.className, className].filter(Boolean)\n : []\n ).join(' ')}\n style={{\n display: 'contents',\n // in order to provide currentColor, set color by default\n color: themes[name]?.color?.toString(),\n }}\n >\n {contents}\n </span>\n )\n }\n\n return contents\n})\n\nexport function wrapThemeManagerContext(\n children: any,\n themeManager?: ThemeManager | null,\n shouldSetChildrenThemeToParent?: boolean\n) {\n return themeManager ? (\n <ThemeManagerContext.Provider value={themeManager}>\n {shouldSetChildrenThemeToParent ? (\n <Theme name={themeManager.parentName}>{children}</Theme>\n ) : (\n children\n )}\n </ThemeManagerContext.Provider>\n ) : (\n children\n )\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAqC;AAErC,sBAAsB;AACtB,0BAAkD;AAClD,sBAAiD;AAGjD,qBAAM;AAEC,MAAM,QAAQ,uBAAK,gBAAe,OAAmB;AAT5D;AAUE,QAAM,EAAE,MAAM,OAAO,cAAc,QAAQ,cAAc,0CACvD,MAAM,MACN,MAAM,eACN,KACF;AAEA,QAAM,eAAe,CAAC,UAAU,CAAC,QAAQ,CAAC;AAI1C,QAAM,WAAW,0BACf,MAAO,eAAe,OAAO,wBAAwB,MAAM,UAAU,YAAY,GACjF,CAAC,MAAM,UAAU,YAAY,CAC/B;AAEA,MAAI,cAAc;AAChB,QAAI,QAAQ,CAAC,SAAS,QAAQ,IAAI,aAAa,eAAe;AAC5D,cAAQ,KAAK,0BAA0B,MAAM;AAAA,IAC/C;AACA,WAAO,MAAM;AAAA,EACf;AAEA,MAAI,uBAAO;AACT,WACE,mDAAC;AAAA,MACC,WAAY,EAAC,MAAM,oBACf,CAAC,MAAM,WAAW,SAAS,EAAE,OAAO,OAAO,IAC3C,CAAC,GACH,KAAK,GAAG;AAAA,MACV,OAAO;AAAA,QACL,SAAS;AAAA,QAET,OAAO,mBAAO,UAAP,mBAAc,UAAd,mBAAqB;AAAA,MAC9B;AAAA,OAEC,QACH;AAAA,EAEJ;AAEA,SAAO;AACT,CAAC;AAEM,iCACL,UACA,cACA,gCACA;AACA,SAAO,eACL,mDAAC,wCAAoB,UAApB;AAAA,IAA6B,OAAO;AAAA,KAClC,iCACC,mDAAC;AAAA,IAAM,MAAM,aAAa;AAAA,KAAa,QAAS,IAEhD,QAEJ,IAEA;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -27,7 +27,7 @@ module.exports = __toCommonJS(ThemeProvider_exports);
|
|
|
27
27
|
var import_react = __toESM(require("react"));
|
|
28
28
|
var import_conf = require("../conf");
|
|
29
29
|
var import_constants = require("../constants/constants");
|
|
30
|
-
var import_ThemeContext = require("../ThemeContext");
|
|
30
|
+
var import_ThemeContext = require("../contexts/ThemeContext");
|
|
31
31
|
var import_Theme = require("./Theme");
|
|
32
32
|
import_react.default["createElement"];
|
|
33
33
|
const ThemeProvider = (props) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/ThemeProvider.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { useLayoutEffect, useMemo } from 'react'\n\nimport { getHasConfigured } from '../conf'\nimport { THEME_CLASSNAME_PREFIX } from '../constants/constants'\nimport { ThemeContext } from '../ThemeContext'\nimport { Theme } from './Theme'\n\n// bugfix esbuild strips react jsx: 'preserve'\nReact['createElement']\n\nexport type ThemeProviderProps = {\n className?: string\n themes: any\n defaultTheme: string\n disableRootThemeClass?: boolean\n themeClassNameOnRoot?: boolean\n children?: any\n reset?: boolean\n}\n\nexport const ThemeProvider = (props: ThemeProviderProps) => {\n if (!getHasConfigured()) {\n throw new Error(`Missing configureThemes() call, add to your root file`)\n }\n\n // ensure theme is attached to root body node as well to work with modals by default\n if (typeof document !== 'undefined') {\n useLayoutEffect(() => {\n if (props.disableRootThemeClass) {\n return\n }\n const cn = `${THEME_CLASSNAME_PREFIX}${props.defaultTheme}`\n const target = props.themeClassNameOnRoot ? document.documentElement : document.body\n target.classList.add(cn)\n return () => {\n target.classList.remove(cn)\n }\n }, [props.defaultTheme, props.disableRootThemeClass])\n }\n\n const themeContext = useMemo(() => {\n return {\n themes: props.themes,\n defaultTheme: props.defaultTheme,\n }\n }, [props.themes])\n\n return (\n <ThemeContext.Provider value={themeContext}>\n <Theme\n className={props.className}\n name={props.defaultTheme}\n disableThemeClass={props.disableRootThemeClass}\n >\n {props.children}\n </Theme>\n </ThemeContext.Provider>\n )\n}\n"],
|
|
4
|
+
"sourcesContent": ["import React, { useLayoutEffect, useMemo } from 'react'\n\nimport { getHasConfigured } from '../conf'\nimport { THEME_CLASSNAME_PREFIX } from '../constants/constants'\nimport { ThemeContext } from '../contexts/ThemeContext'\nimport { Theme } from './Theme'\n\n// bugfix esbuild strips react jsx: 'preserve'\nReact['createElement']\n\nexport type ThemeProviderProps = {\n className?: string\n themes: any\n defaultTheme: string\n disableRootThemeClass?: boolean\n themeClassNameOnRoot?: boolean\n children?: any\n reset?: boolean\n}\n\nexport const ThemeProvider = (props: ThemeProviderProps) => {\n if (!getHasConfigured()) {\n throw new Error(`Missing configureThemes() call, add to your root file`)\n }\n\n // ensure theme is attached to root body node as well to work with modals by default\n if (typeof document !== 'undefined') {\n useLayoutEffect(() => {\n if (props.disableRootThemeClass) {\n return\n }\n const cn = `${THEME_CLASSNAME_PREFIX}${props.defaultTheme}`\n const target = props.themeClassNameOnRoot ? document.documentElement : document.body\n target.classList.add(cn)\n return () => {\n target.classList.remove(cn)\n }\n }, [props.defaultTheme, props.disableRootThemeClass])\n }\n\n const themeContext = useMemo(() => {\n return {\n themes: props.themes,\n defaultTheme: props.defaultTheme,\n }\n }, [props.themes])\n\n return (\n <ThemeContext.Provider value={themeContext}>\n <Theme\n className={props.className}\n name={props.defaultTheme}\n disableThemeClass={props.disableRootThemeClass}\n >\n {props.children}\n </Theme>\n </ThemeContext.Provider>\n )\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAgD;AAEhD,kBAAiC;AACjC,uBAAuC;AACvC,0BAA6B;AAC7B,mBAAsB;AAGtB,qBAAM;AAYC,MAAM,gBAAgB,CAAC,UAA8B;AAC1D,MAAI,CAAC,kCAAiB,GAAG;AACvB,UAAM,IAAI,MAAM,uDAAuD;AAAA,EACzE;AAGA,MAAI,OAAO,aAAa,aAAa;AACnC,sCAAgB,MAAM;AACpB,UAAI,MAAM,uBAAuB;AAC/B;AAAA,MACF;AACA,YAAM,KAAK,GAAG,0CAAyB,MAAM;AAC7C,YAAM,SAAS,MAAM,uBAAuB,SAAS,kBAAkB,SAAS;AAChF,aAAO,UAAU,IAAI,EAAE;AACvB,aAAO,MAAM;AACX,eAAO,UAAU,OAAO,EAAE;AAAA,MAC5B;AAAA,IACF,GAAG,CAAC,MAAM,cAAc,MAAM,qBAAqB,CAAC;AAAA,EACtD;AAEA,QAAM,eAAe,0BAAQ,MAAM;AACjC,WAAO;AAAA,MACL,QAAQ,MAAM;AAAA,MACd,cAAc,MAAM;AAAA,IACtB;AAAA,EACF,GAAG,CAAC,MAAM,MAAM,CAAC;AAEjB,SACE,mDAAC,iCAAa,UAAb;AAAA,IAAsB,OAAO;AAAA,KAC5B,mDAAC;AAAA,IACC,WAAW,MAAM;AAAA,IACjB,MAAM,MAAM;AAAA,IACZ,mBAAmB,MAAM;AAAA,KAExB,MAAM,QACT,CACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -26,7 +26,7 @@ __export(ThemeReset_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(ThemeReset_exports);
|
|
27
27
|
var import_react = __toESM(require("react"));
|
|
28
28
|
var import_platform = require("../constants/platform");
|
|
29
|
-
var import_ThemeManager = require("../ThemeManager");
|
|
29
|
+
var import_ThemeManager = require("../helpers/ThemeManager");
|
|
30
30
|
var import_Theme = require("./Theme");
|
|
31
31
|
import_react.default["createElement"];
|
|
32
32
|
const ThemeReset = (props) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/ThemeReset.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { useContext, useLayoutEffect, useState } from 'react'\n\nimport { isWeb } from '../constants/platform'\nimport { ThemeManagerContext } from '../ThemeManager'\nimport { Theme } from './Theme'\n\n// bugfix esbuild strips react jsx: 'preserve'\nReact['createElement']\n\n// resets the theme to the parent theme\nexport const ThemeReset = (props: { children?: any }) => {\n const themeManager = useContext(ThemeManagerContext)\n const [name, setName] = useState<string | null>(null)\n\n // this component doesn't work with SSR, so must run only client side\n // we could at least prevent more flickering by having the ssr head script\n // that changes to dark initially also go through and change all of these\n if (!isWeb || typeof document !== 'undefined') {\n useLayoutEffect(() => {\n if (!themeManager) return\n if (name !== themeManager.parentName) {\n setName(themeManager.parentName)\n }\n }, [themeManager?.parentName])\n\n useLayoutEffect(() => {\n if (!themeManager) return\n return themeManager.onChangeTheme(() => {\n setName(themeManager.parentName)\n })\n }, [])\n }\n\n if (!themeManager || !props.children) {\n return props.children || null\n }\n\n return (\n <Theme className=\"tui-theme-reset\" reset name={name}>\n {props.children}\n </Theme>\n )\n}\n"],
|
|
4
|
+
"sourcesContent": ["import React, { useContext, useLayoutEffect, useState } from 'react'\n\nimport { isWeb } from '../constants/platform'\nimport { ThemeManagerContext } from '../helpers/ThemeManager'\nimport { Theme } from './Theme'\n\n// bugfix esbuild strips react jsx: 'preserve'\nReact['createElement']\n\n// resets the theme to the parent theme\nexport const ThemeReset = (props: { children?: any }) => {\n const themeManager = useContext(ThemeManagerContext)\n const [name, setName] = useState<string | null>(null)\n\n // this component doesn't work with SSR, so must run only client side\n // we could at least prevent more flickering by having the ssr head script\n // that changes to dark initially also go through and change all of these\n if (!isWeb || typeof document !== 'undefined') {\n useLayoutEffect(() => {\n if (!themeManager) return\n if (name !== themeManager.parentName) {\n setName(themeManager.parentName)\n }\n }, [themeManager?.parentName])\n\n useLayoutEffect(() => {\n if (!themeManager) return\n return themeManager.onChangeTheme(() => {\n setName(themeManager.parentName)\n })\n }, [])\n }\n\n if (!themeManager || !props.children) {\n return props.children || null\n }\n\n return (\n <Theme className=\"tui-theme-reset\" reset name={name}>\n {props.children}\n </Theme>\n )\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA6D;AAE7D,sBAAsB;AACtB,0BAAoC;AACpC,mBAAsB;AAGtB,qBAAM;AAGC,MAAM,aAAa,CAAC,UAA8B;AACvD,QAAM,eAAe,6BAAW,uCAAmB;AACnD,QAAM,CAAC,MAAM,WAAW,2BAAwB,IAAI;AAKpD,MAAI,CAAC,yBAAS,OAAO,aAAa,aAAa;AAC7C,sCAAgB,MAAM;AACpB,UAAI,CAAC;AAAc;AACnB,UAAI,SAAS,aAAa,YAAY;AACpC,gBAAQ,aAAa,UAAU;AAAA,MACjC;AAAA,IACF,GAAG,CAAC,6CAAc,UAAU,CAAC;AAE7B,sCAAgB,MAAM;AACpB,UAAI,CAAC;AAAc;AACnB,aAAO,aAAa,cAAc,MAAM;AACtC,gBAAQ,aAAa,UAAU;AAAA,MACjC,CAAC;AAAA,IACH,GAAG,CAAC,CAAC;AAAA,EACP;AAEA,MAAI,CAAC,gBAAgB,CAAC,MAAM,UAAU;AACpC,WAAO,MAAM,YAAY;AAAA,EAC3B;AAEA,SACE,mDAAC;AAAA,IAAM,WAAU;AAAA,IAAkB,OAAK;AAAA,IAAC;AAAA,KACtC,MAAM,QACT;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|