@tamagui/core 1.0.1-beta.76 → 1.0.1-beta.79
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/ThemeManager.js +6 -22
- package/dist/cjs/ThemeManager.js.map +2 -2
- package/dist/cjs/constants/rnw.js +5 -7
- package/dist/cjs/constants/rnw.js.map +2 -2
- package/dist/cjs/createComponent.js +4 -3
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/helpers/createPropMapper.js +1 -15
- package/dist/cjs/helpers/createPropMapper.js.map +2 -2
- package/dist/cjs/helpers/getSplitStyles.js +3 -0
- package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
- package/dist/cjs/helpers/validate.js +33 -30
- package/dist/cjs/helpers/validate.js.map +2 -2
- package/dist/cjs/index.js +0 -5
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/insertFont.js +1 -2
- package/dist/cjs/insertFont.js.map +2 -2
- package/dist/esm/ThemeManager.js +4 -4
- package/dist/esm/ThemeManager.js.map +2 -2
- package/dist/esm/constants/rnw.js +2 -7
- package/dist/esm/constants/rnw.js.map +2 -2
- package/dist/esm/createComponent.js +4 -3
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/helpers/createPropMapper.js +1 -17
- package/dist/esm/helpers/createPropMapper.js.map +2 -2
- package/dist/esm/helpers/getSplitStyles.js +3 -0
- package/dist/esm/helpers/getSplitStyles.js.map +2 -2
- package/dist/esm/helpers/validate.js +1 -1
- package/dist/esm/helpers/validate.js.map +2 -2
- package/dist/esm/index.js +0 -3
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/insertFont.js +1 -2
- package/dist/esm/insertFont.js.map +2 -2
- package/package.json +7 -7
- package/types/ThemeManager.d.ts +1 -1
- package/types/ThemeManager.d.ts.map +1 -1
- package/types/constants/rnw.d.ts.map +1 -1
- package/types/createComponent.d.ts.map +1 -1
- package/types/helpers/createTamaguiProvider.d.ts +1 -0
- package/types/helpers/createTamaguiProvider.d.ts.map +1 -1
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/index.d.ts +1 -1
- package/types/index.d.ts.map +1 -1
- package/dist/cjs/helpers/pseudos.js +0 -41
- package/dist/cjs/helpers/pseudos.js.map +0 -7
- package/dist/esm/helpers/pseudos.js +0 -18
- package/dist/esm/helpers/pseudos.js.map +0 -7
- package/dist/jsx/Pressability.js +0 -4
- package/dist/jsx/Pressability.native.js +0 -4
- package/dist/jsx/Tamagui.js +0 -38
- package/dist/jsx/ThemeContext.js +0 -5
- package/dist/jsx/ThemeManager.js +0 -194
- package/dist/jsx/conf.js +0 -38
- package/dist/jsx/constants/constants.js +0 -17
- package/dist/jsx/constants/platform.js +0 -25
- package/dist/jsx/constants/rnw.js +0 -10
- package/dist/jsx/contexts/ButtonInsideButtonContext.js +0 -5
- package/dist/jsx/createComponent.js +0 -1036
- package/dist/jsx/createFont.js +0 -25
- package/dist/jsx/createShorthands.js +0 -6
- package/dist/jsx/createTamagui.js +0 -245
- package/dist/jsx/createTheme.js +0 -6
- package/dist/jsx/createTokens.js +0 -11
- package/dist/jsx/createVariable.js +0 -64
- package/dist/jsx/createVariables.js +0 -31
- package/dist/jsx/defaultComponentState.js +0 -0
- package/dist/jsx/helpers/RNComponents.js +0 -11
- package/dist/jsx/helpers/areEqualSets.js +0 -13
- package/dist/jsx/helpers/calc.js +0 -46
- package/dist/jsx/helpers/createMediaStyle.js +0 -29
- package/dist/jsx/helpers/createPropMapper.js +0 -243
- package/dist/jsx/helpers/createShallowUpdate.js +0 -16
- package/dist/jsx/helpers/createTamaguiProvider.js +0 -28
- package/dist/jsx/helpers/extendStaticConfig.js +0 -62
- package/dist/jsx/helpers/fixNativeShadow.js +0 -5
- package/dist/jsx/helpers/fixNativeShadow.native.js +0 -28
- package/dist/jsx/helpers/generateAtomicStyles.js +0 -410
- package/dist/jsx/helpers/getExpandedShorthands.js +0 -15
- package/dist/jsx/helpers/getSize.js +0 -19
- package/dist/jsx/helpers/getSplitStyles.js +0 -380
- package/dist/jsx/helpers/getStackSize.js +0 -15
- package/dist/jsx/helpers/getStylesAtomic.js +0 -61
- package/dist/jsx/helpers/getStylesAtomic.native.js +0 -6
- package/dist/jsx/helpers/getTextSize.js +0 -31
- package/dist/jsx/helpers/getVariantExtras.js +0 -22
- package/dist/jsx/helpers/insertStyleRule.js +0 -91
- package/dist/jsx/helpers/isObj.js +0 -4
- package/dist/jsx/helpers/isTamaguiComponent.js +0 -12
- package/dist/jsx/helpers/isTamaguiElement.js +0 -8
- package/dist/jsx/helpers/matchMedia.js +0 -15
- package/dist/jsx/helpers/matchMedia.native.js +0 -6
- package/dist/jsx/helpers/mergeProps.js +0 -15
- package/dist/jsx/helpers/mergeTransform.js +0 -16
- package/dist/jsx/helpers/nativeGestureHandler.native.js +0 -1
- package/dist/jsx/helpers/proxyThemeVariables.js +0 -14
- package/dist/jsx/helpers/pseudos.js +0 -17
- package/dist/jsx/helpers/registerCSSVariable.js +0 -14
- package/dist/jsx/helpers/themeable.js +0 -22
- package/dist/jsx/helpers/validate.js +0 -73
- package/dist/jsx/helpers/withStaticProperties.js +0 -7
- package/dist/jsx/helpers/wrapThemeManagerContext.js +0 -7
- package/dist/jsx/hooks/useConstant.js +0 -11
- package/dist/jsx/hooks/useFeatures.js +0 -165
- package/dist/jsx/hooks/useId.js +0 -32
- package/dist/jsx/hooks/useIsMounted.js +0 -15
- package/dist/jsx/hooks/useIsTouchDevice.js +0 -14
- package/dist/jsx/hooks/useMedia.js +0 -153
- package/dist/jsx/hooks/usePressable.js +0 -11
- package/dist/jsx/hooks/usePrevious.js +0 -0
- package/dist/jsx/hooks/useTheme.js +0 -164
- package/dist/jsx/hooks/useUnmountEffect.js +0 -7
- package/dist/jsx/index.js +0 -64
- package/dist/jsx/insertFont.js +0 -64
- package/dist/jsx/static.js +0 -18
- package/dist/jsx/styled.js +0 -49
- package/dist/jsx/types-rnw.js +0 -0
- package/dist/jsx/types.js +0 -0
- package/dist/jsx/views/Slot.js +0 -70
- package/dist/jsx/views/Stack.js +0 -12
- package/dist/jsx/views/Text.js +0 -57
- package/dist/jsx/views/TextAncestorContext.js +0 -13
- package/dist/jsx/views/Theme.js +0 -27
- package/dist/jsx/views/ThemeInverse.js +0 -24
- package/dist/jsx/views/ThemeProvider.js +0 -34
- package/dist/jsx/views/ThemeReset.js +0 -32
- package/types/helpers/pseudos.d.ts +0 -16
- package/types/helpers/pseudos.d.ts.map +0 -1
package/dist/jsx/createFont.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { validateFont } from "./helpers/validate";
|
|
2
|
-
const createFont = (font) => {
|
|
3
|
-
if (process.env.NODE_ENV === "development") {
|
|
4
|
-
validateFont(font);
|
|
5
|
-
}
|
|
6
|
-
const sizeKeys = Object.keys(font.size);
|
|
7
|
-
for (const key in font) {
|
|
8
|
-
if (key === "size" || key === "family")
|
|
9
|
-
continue;
|
|
10
|
-
const section = font[key];
|
|
11
|
-
const keys = Object.keys(section);
|
|
12
|
-
let fillVal = section[keys[0]];
|
|
13
|
-
for (const sKey of sizeKeys) {
|
|
14
|
-
if (!(sKey in section)) {
|
|
15
|
-
section[sKey] = fillVal;
|
|
16
|
-
} else {
|
|
17
|
-
fillVal = section[sKey];
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return Object.freeze(font);
|
|
22
|
-
};
|
|
23
|
-
export {
|
|
24
|
-
createFont
|
|
25
|
-
};
|
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
import { configListeners, getHasConfigured, setConfig } from "./conf";
|
|
2
|
-
import { THEME_CLASSNAME_PREFIX } from "./constants/constants";
|
|
3
|
-
import { isWeb } from "./constants/platform";
|
|
4
|
-
import { createVariable, isVariable } from "./createVariable";
|
|
5
|
-
import { createVariables } from "./createVariables";
|
|
6
|
-
import { createTamaguiProvider } from "./helpers/createTamaguiProvider";
|
|
7
|
-
import { getInsertedRules } from "./helpers/insertStyleRule";
|
|
8
|
-
import {
|
|
9
|
-
registerCSSVariable,
|
|
10
|
-
tokenRules,
|
|
11
|
-
tokensValueToVariable
|
|
12
|
-
} from "./helpers/registerCSSVariable";
|
|
13
|
-
import { configureMedia } from "./hooks/useMedia";
|
|
14
|
-
import { parseFont, registerFontVariables } from "./insertFont";
|
|
15
|
-
import { Tamagui } from "./Tamagui";
|
|
16
|
-
const createdConfigs = /* @__PURE__ */ new WeakMap();
|
|
17
|
-
function createTamagui(config) {
|
|
18
|
-
if (createdConfigs.has(config)) {
|
|
19
|
-
return config;
|
|
20
|
-
}
|
|
21
|
-
if (process.env.NODE_ENV === "development") {
|
|
22
|
-
if (!config.tokens) {
|
|
23
|
-
throw new Error(`No tokens provided to Tamagui config`);
|
|
24
|
-
}
|
|
25
|
-
if (!config.themes) {
|
|
26
|
-
throw new Error(`No themes provided to Tamagui config`);
|
|
27
|
-
}
|
|
28
|
-
if (!config.fonts) {
|
|
29
|
-
throw new Error(`No fonts provided to Tamagui config`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (getHasConfigured()) {
|
|
33
|
-
console.warn(`Warning: createTamagui called twice (maybe HMR)`);
|
|
34
|
-
}
|
|
35
|
-
configureMedia({
|
|
36
|
-
queries: config.media,
|
|
37
|
-
defaultActive: config.mediaQueryDefaultActive
|
|
38
|
-
});
|
|
39
|
-
const fontTokens = createVariables(config.fonts);
|
|
40
|
-
const fontsParsed = (() => {
|
|
41
|
-
const res = {};
|
|
42
|
-
for (const familyName in fontTokens) {
|
|
43
|
-
res[`$${familyName}`] = parseFont(fontTokens[familyName]);
|
|
44
|
-
}
|
|
45
|
-
return res;
|
|
46
|
-
})();
|
|
47
|
-
const themeConfig = (() => {
|
|
48
|
-
var _a;
|
|
49
|
-
const themes = { ...config.themes };
|
|
50
|
-
let cssRules = [];
|
|
51
|
-
if (isWeb) {
|
|
52
|
-
for (const key in config.tokens) {
|
|
53
|
-
for (const skey in config.tokens[key]) {
|
|
54
|
-
const val = config.tokens[key][skey];
|
|
55
|
-
registerCSSVariable(val);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
for (const key in fontsParsed) {
|
|
59
|
-
const fontParsed = fontsParsed[key];
|
|
60
|
-
registerFontVariables(fontParsed);
|
|
61
|
-
}
|
|
62
|
-
const sep = process.env.NODE_ENV === "development" ? config.cssStyleSeparator || " " : "";
|
|
63
|
-
cssRules.push(`:root {${sep}${[...tokenRules].join(`;${sep}`)}${sep}}`);
|
|
64
|
-
}
|
|
65
|
-
const hasDarkLight = "light" in config.themes && "dark" in config.themes;
|
|
66
|
-
const CNP = `.${THEME_CLASSNAME_PREFIX}`;
|
|
67
|
-
const dedupedThemes = {};
|
|
68
|
-
const existing = /* @__PURE__ */ new WeakMap();
|
|
69
|
-
for (const themeName in themes) {
|
|
70
|
-
const rawTheme = themes[themeName];
|
|
71
|
-
if (existing.has(rawTheme)) {
|
|
72
|
-
const e = existing.get(rawTheme);
|
|
73
|
-
themes[themeName] = e.theme;
|
|
74
|
-
e.names.push(themeName);
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
const theme = { ...config.themes[themeName] };
|
|
78
|
-
for (const key in theme) {
|
|
79
|
-
ensureThemeVariable(theme, key);
|
|
80
|
-
}
|
|
81
|
-
themes[themeName] = theme;
|
|
82
|
-
dedupedThemes[themeName] = {
|
|
83
|
-
names: [themeName],
|
|
84
|
-
theme
|
|
85
|
-
};
|
|
86
|
-
existing.set(config.themes[themeName], dedupedThemes[themeName]);
|
|
87
|
-
}
|
|
88
|
-
if (isWeb) {
|
|
89
|
-
for (const themeName in dedupedThemes) {
|
|
90
|
-
const { theme, names } = dedupedThemes[themeName];
|
|
91
|
-
let vars = "";
|
|
92
|
-
for (const themeKey in theme) {
|
|
93
|
-
const variable = theme[themeKey];
|
|
94
|
-
let value = null;
|
|
95
|
-
if (variable.isFloating || !tokensValueToVariable.has(variable.val)) {
|
|
96
|
-
value = variable.val;
|
|
97
|
-
} else {
|
|
98
|
-
value = tokensValueToVariable.get(variable.val).variable;
|
|
99
|
-
}
|
|
100
|
-
vars += `--${themeKey}:${value};`;
|
|
101
|
-
}
|
|
102
|
-
const isDarkOrLightBase = themeName === "dark" || themeName === "light";
|
|
103
|
-
const selectors = names.map((name) => {
|
|
104
|
-
return `${CNP}${name}`;
|
|
105
|
-
});
|
|
106
|
-
if (hasDarkLight) {
|
|
107
|
-
for (const subName of names) {
|
|
108
|
-
const isDark = subName.startsWith("dark");
|
|
109
|
-
const childSelector = `${CNP}${subName.replace("dark_", "").replace("light_", "")}`;
|
|
110
|
-
const order = isDark ? ["dark", "light"] : ["light", "dark"];
|
|
111
|
-
if (isDarkOrLightBase) {
|
|
112
|
-
order.reverse();
|
|
113
|
-
}
|
|
114
|
-
const [stronger, weaker] = order;
|
|
115
|
-
const max = (_a = config.maxDarkLightNesting) != null ? _a : 3;
|
|
116
|
-
new Array(max * 2).fill(void 0).forEach((_, pi) => {
|
|
117
|
-
if (pi % 2 === 1)
|
|
118
|
-
return;
|
|
119
|
-
const parents = new Array(pi + 1).fill(void 0).map((_2, psi) => {
|
|
120
|
-
return `${CNP}${psi % 2 === 0 ? stronger : weaker}`;
|
|
121
|
-
});
|
|
122
|
-
selectors.push(`${(parents.length > 1 ? parents.slice(1) : parents).join(" ")} ${childSelector}`);
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
const rootSep = config.themeClassNameOnRoot ? "" : " ";
|
|
127
|
-
cssRules.push(`${selectors.map((x) => `:root${rootSep}${x}`).join(", ")} {${vars}}`);
|
|
128
|
-
if (config.shouldAddPrefersColorThemes) {
|
|
129
|
-
const isDark = themeName.startsWith("dark");
|
|
130
|
-
if (isDarkOrLightBase) {
|
|
131
|
-
cssRules.push(`@media(prefers-color-scheme: ${isDark ? "dark" : "light"}) {
|
|
132
|
-
body { background:${theme.background}; color: ${theme.color} }
|
|
133
|
-
:root {${vars} }
|
|
134
|
-
}`);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
for (const themeName in themes) {
|
|
140
|
-
const cur = [];
|
|
141
|
-
const parents = themeName.split("_").slice(0, -1).map((part) => {
|
|
142
|
-
cur.push(part);
|
|
143
|
-
return cur.join("_");
|
|
144
|
-
});
|
|
145
|
-
if (!parents.length)
|
|
146
|
-
continue;
|
|
147
|
-
themes[themeName] = new Proxy(themes[themeName], {
|
|
148
|
-
get(target, key) {
|
|
149
|
-
if (Reflect.has(target, key)) {
|
|
150
|
-
return Reflect.get(target, key);
|
|
151
|
-
}
|
|
152
|
-
for (let i = parents.length - 1; i >= 0; i--) {
|
|
153
|
-
const parent = themes[parents[i]];
|
|
154
|
-
if (!parent) {
|
|
155
|
-
continue;
|
|
156
|
-
}
|
|
157
|
-
if (Reflect.has(parent, key)) {
|
|
158
|
-
return Reflect.get(parent, key);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
tokensValueToVariable.clear();
|
|
165
|
-
Object.freeze(cssRules);
|
|
166
|
-
const css = cssRules.join("\n");
|
|
167
|
-
return {
|
|
168
|
-
themes,
|
|
169
|
-
cssRules,
|
|
170
|
-
css
|
|
171
|
-
};
|
|
172
|
-
})();
|
|
173
|
-
const tokensParsed = parseTokens(config.tokens);
|
|
174
|
-
const getCSS = () => {
|
|
175
|
-
return `${themeConfig.css}
|
|
176
|
-
${getInsertedRules().join("\n")}`;
|
|
177
|
-
};
|
|
178
|
-
if (config.shorthands) {
|
|
179
|
-
for (const key in config.shorthands) {
|
|
180
|
-
reversedShorthands[config.shorthands[key]] = key;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
const next = {
|
|
184
|
-
defaultTheme: "light",
|
|
185
|
-
fonts: {},
|
|
186
|
-
animations: {},
|
|
187
|
-
shorthands: {},
|
|
188
|
-
media: {},
|
|
189
|
-
...config,
|
|
190
|
-
themes: themeConfig.themes,
|
|
191
|
-
fontsParsed,
|
|
192
|
-
themeConfig,
|
|
193
|
-
tokensParsed,
|
|
194
|
-
parsed: true,
|
|
195
|
-
getCSS,
|
|
196
|
-
Provider: null
|
|
197
|
-
};
|
|
198
|
-
next.Provider = createTamaguiProvider(next);
|
|
199
|
-
setConfig(next);
|
|
200
|
-
if (configListeners.size) {
|
|
201
|
-
configListeners.forEach((cb) => cb(next));
|
|
202
|
-
configListeners.clear();
|
|
203
|
-
}
|
|
204
|
-
createdConfigs.set(next, true);
|
|
205
|
-
if (process.env.NODE_ENV === "development") {
|
|
206
|
-
if (!globalThis["Tamagui"]) {
|
|
207
|
-
globalThis["Tamagui"] = Tamagui;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
return next;
|
|
211
|
-
}
|
|
212
|
-
const reversedShorthands = {};
|
|
213
|
-
const parseTokens = (tokens) => {
|
|
214
|
-
const res = {};
|
|
215
|
-
for (const key in tokens) {
|
|
216
|
-
res[key] = {};
|
|
217
|
-
for (const skey in tokens[key]) {
|
|
218
|
-
res[key][`$${skey}`] = tokens[key][skey];
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
return res;
|
|
222
|
-
};
|
|
223
|
-
function ensureThemeVariable(theme, key) {
|
|
224
|
-
const val = theme[key];
|
|
225
|
-
const themeKey = key;
|
|
226
|
-
if (!isVariable(val)) {
|
|
227
|
-
theme[key] = createVariable({
|
|
228
|
-
key: themeKey,
|
|
229
|
-
name: themeKey,
|
|
230
|
-
val
|
|
231
|
-
});
|
|
232
|
-
} else {
|
|
233
|
-
if (val.name !== themeKey) {
|
|
234
|
-
theme[key] = createVariable({
|
|
235
|
-
key: val.name,
|
|
236
|
-
name: themeKey,
|
|
237
|
-
val: val.val
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
export {
|
|
243
|
-
createTamagui,
|
|
244
|
-
reversedShorthands
|
|
245
|
-
};
|
package/dist/jsx/createTheme.js
DELETED
package/dist/jsx/createTokens.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { createVariables } from "./createVariables";
|
|
2
|
-
import { validateTokens } from "./helpers/validate";
|
|
3
|
-
function createTokens(tokens) {
|
|
4
|
-
if (process.env.NODE_ENV === "development") {
|
|
5
|
-
validateTokens(tokens);
|
|
6
|
-
}
|
|
7
|
-
return createVariables(tokens);
|
|
8
|
-
}
|
|
9
|
-
export {
|
|
10
|
-
createTokens
|
|
11
|
-
};
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
var _a;
|
|
2
|
-
import { isWeb } from "./constants/platform";
|
|
3
|
-
const IS_VARIABLE_SYMBOL = "__isVariable__";
|
|
4
|
-
class Variable {
|
|
5
|
-
constructor(props) {
|
|
6
|
-
this[_a] = true;
|
|
7
|
-
this.isFloating = false;
|
|
8
|
-
const { val, name, key, isFloating } = props;
|
|
9
|
-
this.val = isVariable(val) ? val.val : val;
|
|
10
|
-
this.name = name;
|
|
11
|
-
this.key = key;
|
|
12
|
-
this.variable = isWeb ? createCSSVariable(name) : "";
|
|
13
|
-
if (isFloating) {
|
|
14
|
-
this.isFloating = true;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
toString() {
|
|
18
|
-
return `${isWeb ? this.variable : this.val}`;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
_a = IS_VARIABLE_SYMBOL;
|
|
22
|
-
const createVariable = (props) => {
|
|
23
|
-
if (isVariable(props)) {
|
|
24
|
-
return props;
|
|
25
|
-
}
|
|
26
|
-
return new Variable(props);
|
|
27
|
-
};
|
|
28
|
-
function isVariable(v) {
|
|
29
|
-
return !!(v instanceof Variable || v && v[IS_VARIABLE_SYMBOL]);
|
|
30
|
-
}
|
|
31
|
-
function getVariableValue(v) {
|
|
32
|
-
if (isVariable(v))
|
|
33
|
-
return v.val;
|
|
34
|
-
return v;
|
|
35
|
-
}
|
|
36
|
-
function getVariableName(v) {
|
|
37
|
-
if (isVariable(v))
|
|
38
|
-
return v.name;
|
|
39
|
-
return v;
|
|
40
|
-
}
|
|
41
|
-
function getVariableVariable(v) {
|
|
42
|
-
if (isVariable(v))
|
|
43
|
-
return v.variable;
|
|
44
|
-
return v;
|
|
45
|
-
}
|
|
46
|
-
const createCSSVariable = (nameProp, includeVar = true) => {
|
|
47
|
-
if (process.env.NODE_ENV === "development") {
|
|
48
|
-
if (!nameProp || typeof nameProp !== "string") {
|
|
49
|
-
console.warn("invalid name", nameProp);
|
|
50
|
-
return ``;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
const name = nameProp.replace(/[^a-z0-9\_\-]+/i, "_");
|
|
54
|
-
return includeVar ? `var(--${name})` : name;
|
|
55
|
-
};
|
|
56
|
-
export {
|
|
57
|
-
Variable,
|
|
58
|
-
createCSSVariable,
|
|
59
|
-
createVariable,
|
|
60
|
-
getVariableName,
|
|
61
|
-
getVariableValue,
|
|
62
|
-
getVariableVariable,
|
|
63
|
-
isVariable
|
|
64
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { createVariable, isVariable } from "./createVariable";
|
|
2
|
-
const createVariables = (tokens, parentPath = "") => {
|
|
3
|
-
const res = {};
|
|
4
|
-
for (const key in tokens) {
|
|
5
|
-
let val = tokens[key];
|
|
6
|
-
const name = parentPath ? `${parentPath}-${key}` : key;
|
|
7
|
-
if (isVariable(val)) {
|
|
8
|
-
res[key] = val;
|
|
9
|
-
} else if (val && typeof val === "object") {
|
|
10
|
-
if (Array.isArray(val)) {
|
|
11
|
-
res[key] = val.map((val2, i) => {
|
|
12
|
-
const skey = `${key}-${i}`;
|
|
13
|
-
const sname = parentPath ? `${name}-${skey}` : skey;
|
|
14
|
-
return isVariable(val2) ? val2 : createVariable({
|
|
15
|
-
val: val2,
|
|
16
|
-
key: skey,
|
|
17
|
-
name: sname
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
} else {
|
|
21
|
-
res[key] = createVariables(tokens[key], name === "color" ? "" : name);
|
|
22
|
-
}
|
|
23
|
-
} else {
|
|
24
|
-
res[key] = isVariable(val) ? val : createVariable({ val, name, key });
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return res;
|
|
28
|
-
};
|
|
29
|
-
export {
|
|
30
|
-
createVariables
|
|
31
|
-
};
|
|
File without changes
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as ReactNative from "react-native";
|
|
2
|
-
const RNComponents = /* @__PURE__ */ new WeakMap();
|
|
3
|
-
for (const key of ["Image", "TextInput", "Text", "View"]) {
|
|
4
|
-
const val = ReactNative[key];
|
|
5
|
-
if (val && typeof val === "object") {
|
|
6
|
-
RNComponents.set(val, true);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
export {
|
|
10
|
-
RNComponents
|
|
11
|
-
};
|
package/dist/jsx/helpers/calc.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { isWeb } from "../constants/platform";
|
|
2
|
-
import { getVariableVariable } from "../createVariable";
|
|
3
|
-
const operators = {
|
|
4
|
-
"+": (a, b) => a + b,
|
|
5
|
-
"-": (a, b) => a - b,
|
|
6
|
-
"/": (a, b) => a / b,
|
|
7
|
-
"*": (a, b) => a * b
|
|
8
|
-
};
|
|
9
|
-
const calc = (...valuesAndOperators) => {
|
|
10
|
-
if (isWeb) {
|
|
11
|
-
let res2 = "calc(";
|
|
12
|
-
for (const cur of valuesAndOperators) {
|
|
13
|
-
if (operators[cur]) {
|
|
14
|
-
res2 += " " + cur + " ";
|
|
15
|
-
} else {
|
|
16
|
-
res2 += convertToVariableOrNumber(cur);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return res2 + ")";
|
|
20
|
-
}
|
|
21
|
-
let res = 0;
|
|
22
|
-
let nextOp = null;
|
|
23
|
-
for (const cur of valuesAndOperators) {
|
|
24
|
-
if (operators[cur]) {
|
|
25
|
-
nextOp = operators[cur];
|
|
26
|
-
} else {
|
|
27
|
-
if (nextOp) {
|
|
28
|
-
res = nextOp(res, cur);
|
|
29
|
-
nextOp = null;
|
|
30
|
-
} else {
|
|
31
|
-
res = +cur;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return res;
|
|
36
|
-
};
|
|
37
|
-
const convertToVariableOrNumber = (v) => {
|
|
38
|
-
const varOrVal = getVariableVariable(v);
|
|
39
|
-
if (typeof varOrVal === "number") {
|
|
40
|
-
return `${varOrVal}px`;
|
|
41
|
-
}
|
|
42
|
-
return varOrVal;
|
|
43
|
-
};
|
|
44
|
-
export {
|
|
45
|
-
calc
|
|
46
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { mediaObjectToString } from "../hooks/useMedia";
|
|
2
|
-
const MEDIA_SEP = "_";
|
|
3
|
-
const createMediaStyle = ({ identifier, rules }, mediaKey, mediaQueries, negate, importance) => {
|
|
4
|
-
const mediaKeys = Object.keys(mediaQueries);
|
|
5
|
-
const importance_ = Math.max(0, importance == void 0 ? mediaKeys.indexOf(mediaKey) : importance || 0);
|
|
6
|
-
const precendencePrefix = new Array(importance_ + 1).fill(":root").join("");
|
|
7
|
-
const negKey = negate ? "0" : "";
|
|
8
|
-
const ogPrefix = identifier.slice(0, identifier.indexOf("-") + 1);
|
|
9
|
-
const nextIdentifier = `${identifier.replace(ogPrefix, `${ogPrefix}${MEDIA_SEP}${mediaKey}${negKey}${MEDIA_SEP}`)}`;
|
|
10
|
-
const screenStr = negate ? "not all" : "screen";
|
|
11
|
-
const mediaSelector = mediaObjectToString(mediaQueries[mediaKey]);
|
|
12
|
-
const mediaQuery = `${screenStr} and ${mediaSelector}`;
|
|
13
|
-
const styleInner = rules.map((rule) => rule.replace(identifier, nextIdentifier)).join(";");
|
|
14
|
-
let styleRule = "";
|
|
15
|
-
if (styleInner.includes("@media")) {
|
|
16
|
-
styleRule = styleInner.replace("{", ` and ${mediaQuery} {`);
|
|
17
|
-
} else {
|
|
18
|
-
styleRule = `@media ${mediaQuery} { ${precendencePrefix} ${styleInner} }`;
|
|
19
|
-
}
|
|
20
|
-
styleRule = styleRule.replace(";}", " !important;}");
|
|
21
|
-
return {
|
|
22
|
-
styleRule,
|
|
23
|
-
identifier: nextIdentifier
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
export {
|
|
27
|
-
MEDIA_SEP,
|
|
28
|
-
createMediaStyle
|
|
29
|
-
};
|