@tamagui/core 1.0.0-alpha.11 → 1.0.0-alpha.12
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/types.js.map +1 -1
- package/dist/esm/constants/constants.js +14 -0
- package/dist/esm/constants/constants.js.map +7 -0
- package/dist/esm/constants/platform.js +19 -0
- package/dist/esm/constants/platform.js.map +7 -0
- package/dist/esm/constants/pseudos.js +18 -0
- package/dist/esm/constants/pseudos.js.map +7 -0
- package/dist/esm/constants/rnw.js +22 -0
- package/dist/esm/constants/rnw.js.map +7 -0
- package/dist/esm/createComponent.js +464 -0
- package/dist/esm/createComponent.js.map +7 -0
- package/dist/esm/createFont.js +28 -0
- package/dist/esm/createFont.js.map +7 -0
- package/dist/esm/createShorthands.js +10 -0
- package/dist/esm/createShorthands.js.map +7 -0
- package/dist/esm/createTamagui.js +168 -0
- package/dist/esm/createTamagui.js.map +7 -0
- package/dist/esm/createTheme.js +20 -0
- package/dist/esm/createTheme.js.map +7 -0
- package/dist/esm/createTokens.js +33 -0
- package/dist/esm/createTokens.js.map +7 -0
- package/dist/esm/createVariable.js +25 -0
- package/dist/esm/createVariable.js.map +7 -0
- package/dist/esm/helpers/addStylesUsingClassname.js +57 -0
- package/dist/esm/helpers/addStylesUsingClassname.js.map +7 -0
- package/dist/esm/helpers/createMediaStyle.js +34 -0
- package/dist/esm/helpers/createMediaStyle.js.map +7 -0
- package/dist/esm/helpers/createPropMapper.js +160 -0
- package/dist/esm/helpers/createPropMapper.js.map +7 -0
- package/dist/esm/helpers/createTamaguiProvider.js +25 -0
- package/dist/esm/helpers/createTamaguiProvider.js.map +7 -0
- package/dist/esm/helpers/extendStaticConfig.js +59 -0
- package/dist/esm/helpers/extendStaticConfig.js.map +7 -0
- package/dist/esm/helpers/fixNativeShadow.js +8 -0
- package/dist/esm/helpers/fixNativeShadow.js.map +7 -0
- package/dist/esm/helpers/fixNativeShadow.native.js +30 -0
- package/dist/esm/helpers/fixNativeShadow.native.js.map +7 -0
- package/dist/esm/helpers/getSplitStyles.js +150 -0
- package/dist/esm/helpers/getSplitStyles.js.map +7 -0
- package/dist/esm/helpers/getStylesAtomic.js +83 -0
- package/dist/esm/helpers/getStylesAtomic.js.map +7 -0
- package/dist/esm/helpers/getStylesAtomic.native.js +10 -0
- package/dist/esm/helpers/getStylesAtomic.native.js.map +7 -0
- package/dist/esm/helpers/insertStyleRule.js +24 -0
- package/dist/esm/helpers/insertStyleRule.js.map +7 -0
- package/dist/esm/helpers/isObj.js +7 -0
- package/dist/esm/helpers/isObj.js.map +7 -0
- package/dist/esm/helpers/isTamaguiElement.js +10 -0
- package/dist/esm/helpers/isTamaguiElement.js.map +7 -0
- package/dist/esm/helpers/matchMedia.js +18 -0
- package/dist/esm/helpers/matchMedia.js.map +7 -0
- package/dist/esm/helpers/matchMedia.native.js +9 -0
- package/dist/esm/helpers/matchMedia.native.js.map +7 -0
- package/dist/esm/helpers/themeable.js +26 -0
- package/dist/esm/helpers/themeable.js.map +7 -0
- package/dist/esm/helpers/validate.js +60 -0
- package/dist/esm/helpers/validate.js.map +7 -0
- package/dist/esm/hooks/useConstant.js +15 -0
- package/dist/esm/hooks/useConstant.js.map +7 -0
- package/dist/esm/hooks/useFeatures.js +63 -0
- package/dist/esm/hooks/useFeatures.js.map +7 -0
- package/dist/esm/hooks/useMedia.js +173 -0
- package/dist/esm/hooks/useMedia.js.map +7 -0
- package/dist/esm/hooks/usePressable.js +13 -0
- package/dist/esm/hooks/usePressable.js.map +7 -0
- package/dist/esm/hooks/useTheme.js +89 -0
- package/dist/esm/hooks/useTheme.js.map +7 -0
- package/dist/esm/index.js +32 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/static/postProcessStyles.js +18 -0
- package/dist/esm/static/postProcessStyles.js.map +7 -0
- package/dist/esm/static.js +15 -0
- package/dist/esm/static.js.map +7 -0
- package/dist/esm/styled.js +21 -0
- package/dist/esm/styled.js.map +7 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/types.js.map +7 -0
- package/dist/esm/views/Animated.js +79 -0
- package/dist/esm/views/Animated.js.map +7 -0
- package/dist/esm/views/Stack.js +12 -0
- package/dist/esm/views/Stack.js.map +7 -0
- package/dist/esm/views/Text.js +60 -0
- package/dist/esm/views/Text.js.map +7 -0
- package/dist/esm/views/TextAncestorContext.js +18 -0
- package/dist/esm/views/TextAncestorContext.js.map +7 -0
- package/dist/esm/views/Theme.js +68 -0
- package/dist/esm/views/Theme.js.map +7 -0
- package/dist/esm/views/ThemeContext.js +6 -0
- package/dist/esm/views/ThemeContext.js.map +7 -0
- package/dist/esm/views/ThemeInverse.js +26 -0
- package/dist/esm/views/ThemeInverse.js.map +7 -0
- package/dist/esm/views/ThemeManagerContext.js +61 -0
- package/dist/esm/views/ThemeManagerContext.js.map +7 -0
- package/dist/esm/views/ThemeProvider.js +45 -0
- package/dist/esm/views/ThemeProvider.js.map +7 -0
- package/dist/jsx/constants/constants.js +13 -0
- package/dist/jsx/constants/platform.js +18 -0
- package/dist/jsx/constants/pseudos.js +17 -0
- package/dist/jsx/constants/rnw.js +21 -0
- package/dist/jsx/createComponent.js +458 -0
- package/dist/jsx/createFont.js +27 -0
- package/dist/jsx/createShorthands.js +9 -0
- package/dist/jsx/createTamagui.js +167 -0
- package/dist/jsx/createTheme.js +19 -0
- package/dist/jsx/createTokens.js +32 -0
- package/dist/jsx/createVariable.js +24 -0
- package/dist/jsx/helpers/addStylesUsingClassname.js +56 -0
- package/dist/jsx/helpers/createMediaStyle.js +33 -0
- package/dist/jsx/helpers/createPropMapper.js +159 -0
- package/dist/jsx/helpers/createTamaguiProvider.js +19 -0
- package/dist/jsx/helpers/extendStaticConfig.js +58 -0
- package/dist/jsx/helpers/fixNativeShadow.js +7 -0
- package/dist/jsx/helpers/fixNativeShadow.native.js +29 -0
- package/dist/jsx/helpers/getSplitStyles.js +149 -0
- package/dist/jsx/helpers/getStylesAtomic.js +82 -0
- package/dist/jsx/helpers/getStylesAtomic.native.js +9 -0
- package/dist/jsx/helpers/insertStyleRule.js +23 -0
- package/dist/jsx/helpers/isObj.js +6 -0
- package/dist/jsx/helpers/isTamaguiElement.js +9 -0
- package/dist/jsx/helpers/matchMedia.js +17 -0
- package/dist/jsx/helpers/matchMedia.native.js +8 -0
- package/dist/jsx/helpers/themeable.js +23 -0
- package/dist/jsx/helpers/validate.js +59 -0
- package/dist/jsx/hooks/useConstant.js +14 -0
- package/dist/jsx/hooks/useFeatures.js +57 -0
- package/dist/jsx/hooks/useMedia.js +172 -0
- package/dist/jsx/hooks/usePressable.js +12 -0
- package/dist/jsx/hooks/useTheme.js +88 -0
- package/dist/jsx/index.js +31 -0
- package/dist/jsx/static/postProcessStyles.js +17 -0
- package/dist/jsx/static.js +14 -0
- package/dist/jsx/styled.js +20 -0
- package/dist/jsx/types.js +0 -0
- package/dist/jsx/views/Animated.js +74 -0
- package/dist/jsx/views/Stack.js +11 -0
- package/dist/jsx/views/Text.js +59 -0
- package/dist/jsx/views/TextAncestorContext.js +14 -0
- package/dist/jsx/views/Theme.js +62 -0
- package/dist/jsx/views/ThemeContext.js +5 -0
- package/dist/jsx/views/ThemeInverse.js +22 -0
- package/dist/jsx/views/ThemeManagerContext.js +60 -0
- package/dist/jsx/views/ThemeProvider.js +39 -0
- package/package.json +10 -11
- package/src/createComponent.tsx +1 -1
- package/src/types.tsx +6 -6
- package/src/views/Text.tsx +2 -1
- package/types/constants/constants.d.ts +8 -0
- package/types/constants/constants.d.ts.map +1 -0
- package/types/constants/platform.d.ts +9 -0
- package/types/constants/platform.d.ts.map +1 -0
- package/types/constants/pseudos.d.ts +15 -0
- package/types/constants/pseudos.d.ts.map +1 -0
- package/types/constants/rnw.d.ts +2 -0
- package/types/constants/rnw.d.ts.map +1 -0
- package/types/createComponent.d.ts +17 -0
- package/types/createComponent.d.ts.map +1 -0
- package/types/createFont.d.ts +3 -0
- package/types/createFont.d.ts.map +1 -0
- package/types/createShorthands.d.ts +2 -0
- package/types/createShorthands.d.ts.map +1 -0
- package/types/createTamagui.d.ts +38 -0
- package/types/createTamagui.d.ts.map +1 -0
- package/types/createTheme.d.ts +5 -0
- package/types/createTheme.d.ts.map +1 -0
- package/types/createTokens.d.ts +55 -0
- package/types/createTokens.d.ts.map +1 -0
- package/types/createVariable.d.ts +15 -0
- package/types/createVariable.d.ts.map +1 -0
- package/types/helpers/addStylesUsingClassname.d.ts +3 -0
- package/types/helpers/addStylesUsingClassname.d.ts.map +1 -0
- package/types/helpers/createMediaStyle.d.ts +8 -0
- package/types/helpers/createMediaStyle.d.ts.map +1 -0
- package/types/helpers/createPropMapper.d.ts +3 -0
- package/types/helpers/createPropMapper.d.ts.map +1 -0
- package/types/helpers/createTamaguiProvider.d.ts +5 -0
- package/types/helpers/createTamaguiProvider.d.ts.map +1 -0
- package/types/helpers/extendStaticConfig.d.ts +5 -0
- package/types/helpers/extendStaticConfig.d.ts.map +1 -0
- package/types/helpers/fixNativeShadow.d.ts +2 -0
- package/types/helpers/fixNativeShadow.d.ts.map +1 -0
- package/types/helpers/fixNativeShadow.native.d.ts +2 -0
- package/types/helpers/fixNativeShadow.native.d.ts.map +1 -0
- package/types/helpers/getSplitStyles.d.ts +15 -0
- package/types/helpers/getSplitStyles.d.ts.map +1 -0
- package/types/helpers/getStylesAtomic.d.ts +3 -0
- package/types/helpers/getStylesAtomic.d.ts.map +1 -0
- package/types/helpers/getStylesAtomic.native.d.ts +2 -0
- package/types/helpers/getStylesAtomic.native.d.ts.map +1 -0
- package/types/helpers/insertStyleRule.d.ts +2 -0
- package/types/helpers/insertStyleRule.d.ts.map +1 -0
- package/types/helpers/isObj.d.ts +2 -0
- package/types/helpers/isObj.d.ts.map +1 -0
- package/types/helpers/isTamaguiElement.d.ts +3 -0
- package/types/helpers/isTamaguiElement.d.ts.map +1 -0
- package/types/helpers/matchMedia.d.ts +2 -0
- package/types/helpers/matchMedia.d.ts.map +1 -0
- package/types/helpers/matchMedia.native.d.ts +3 -0
- package/types/helpers/matchMedia.native.d.ts.map +1 -0
- package/types/helpers/themeable.d.ts +10 -0
- package/types/helpers/themeable.d.ts.map +1 -0
- package/types/helpers/validate.d.ts +4 -0
- package/types/helpers/validate.d.ts.map +1 -0
- package/types/hooks/useConstant.d.ts +2 -0
- package/types/hooks/useConstant.d.ts.map +1 -0
- package/types/hooks/useFeatures.d.ts +5 -0
- package/types/hooks/useFeatures.d.ts.map +1 -0
- package/types/hooks/useMedia.d.ts +16 -0
- package/types/hooks/useMedia.d.ts.map +1 -0
- package/types/hooks/usePressable.d.ts +3 -0
- package/types/hooks/usePressable.d.ts.map +1 -0
- package/types/hooks/useTheme.d.ts +20 -0
- package/types/hooks/useTheme.d.ts.map +1 -0
- package/types/index.d.ts +29 -0
- package/types/index.d.ts.map +1 -0
- package/types/static/postProcessStyles.d.ts +7 -0
- package/types/static/postProcessStyles.d.ts.map +1 -0
- package/types/static.d.ts +15 -0
- package/types/static.d.ts.map +1 -0
- package/types/styled.d.ts +21 -0
- package/types/styled.d.ts.map +1 -0
- package/types/types.d.ts +306 -0
- package/types/types.d.ts.map +1 -0
- package/types/views/Animated.d.ts +15 -0
- package/types/views/Animated.d.ts.map +1 -0
- package/types/views/Stack.d.ts +3 -0
- package/types/views/Stack.d.ts.map +1 -0
- package/types/views/Text.d.ts +3 -0
- package/types/views/Text.d.ts.map +1 -0
- package/types/views/TextAncestorContext.d.ts +3 -0
- package/types/views/TextAncestorContext.d.ts.map +1 -0
- package/types/views/Theme.d.ts +8 -0
- package/types/views/Theme.d.ts.map +1 -0
- package/types/views/ThemeContext.d.ts +18 -0
- package/types/views/ThemeContext.d.ts.map +1 -0
- package/types/views/ThemeInverse.d.ts +10 -0
- package/types/views/ThemeInverse.d.ts.map +1 -0
- package/types/views/ThemeManagerContext.d.ts +22 -0
- package/types/views/ThemeManagerContext.d.ts.map +1 -0
- package/types/views/ThemeProvider.d.ts +10 -0
- package/types/views/ThemeProvider.d.ts.map +1 -0
- package/types.d.ts +0 -559
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { getStyleRules } from "@tamagui/helpers";
|
|
4
|
+
import { Variable, createVariable, isVariable } from "./createVariable";
|
|
5
|
+
import { createTamaguiProvider } from "./helpers/createTamaguiProvider";
|
|
6
|
+
import { validateConfig } from "./helpers/validate";
|
|
7
|
+
import { configureMedia } from "./hooks/useMedia";
|
|
8
|
+
let conf;
|
|
9
|
+
const getHasConfigured = /* @__PURE__ */ __name(() => !!conf, "getHasConfigured");
|
|
10
|
+
const getTamagui = /* @__PURE__ */ __name(() => conf, "getTamagui");
|
|
11
|
+
const getTokens = /* @__PURE__ */ __name(() => conf.tokensParsed, "getTokens");
|
|
12
|
+
const configListeners = new Set();
|
|
13
|
+
const onConfiguredOnce = /* @__PURE__ */ __name((cb) => {
|
|
14
|
+
if (conf) {
|
|
15
|
+
cb(conf);
|
|
16
|
+
} else {
|
|
17
|
+
configListeners.add(cb);
|
|
18
|
+
}
|
|
19
|
+
}, "onConfiguredOnce");
|
|
20
|
+
const PREFIX = `theme--`;
|
|
21
|
+
function createTamagui(config) {
|
|
22
|
+
if (process.env.NODE_ENV === "development") {
|
|
23
|
+
if (!config["parsed"]) {
|
|
24
|
+
validateConfig(config);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (conf) {
|
|
28
|
+
console.warn("Called createTamagui twice! Should never do so");
|
|
29
|
+
}
|
|
30
|
+
configureMedia({
|
|
31
|
+
queries: config.media,
|
|
32
|
+
defaultActive: config.mediaQueryDefaultActive
|
|
33
|
+
});
|
|
34
|
+
const themeConfig = (() => {
|
|
35
|
+
let cssRules = [];
|
|
36
|
+
let tokenRule = `:root {`;
|
|
37
|
+
const varsByValue = new Map();
|
|
38
|
+
const addVar = /* @__PURE__ */ __name((v) => {
|
|
39
|
+
varsByValue[v.val] = v;
|
|
40
|
+
const rule = `--${v.name}:${typeof v.val === "number" ? `${v.val}px` : v.val};`;
|
|
41
|
+
tokenRule += rule;
|
|
42
|
+
}, "addVar");
|
|
43
|
+
for (const key in config.tokens) {
|
|
44
|
+
for (const skey in config.tokens[key]) {
|
|
45
|
+
const val = config.tokens[key][skey];
|
|
46
|
+
if (key === "font") {
|
|
47
|
+
for (const fkey in val) {
|
|
48
|
+
if (fkey === "family") {
|
|
49
|
+
addVar(val[fkey]);
|
|
50
|
+
} else {
|
|
51
|
+
for (const fskey in val[fkey]) {
|
|
52
|
+
addVar(val[fkey][fskey]);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
addVar(val);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
cssRules.push(`${tokenRule}
|
|
62
|
+
}`);
|
|
63
|
+
for (const themeName in config.themes) {
|
|
64
|
+
config.themes[themeName] = { ...config.themes[themeName] };
|
|
65
|
+
const theme = config.themes[themeName];
|
|
66
|
+
let vars = "";
|
|
67
|
+
for (const themeKey in theme) {
|
|
68
|
+
const val = theme[themeKey];
|
|
69
|
+
const getVariableCSS = /* @__PURE__ */ __name((inv) => {
|
|
70
|
+
const v = varsByValue[inv] ?? inv;
|
|
71
|
+
return isVariable(v) ? `--${themeKey}:var(--${v.name});` : `--${themeKey}:${v};`;
|
|
72
|
+
}, "getVariableCSS");
|
|
73
|
+
vars += getVariableCSS(val);
|
|
74
|
+
if (!isVariable(val)) {
|
|
75
|
+
theme[themeKey] = createVariable({
|
|
76
|
+
name: themeKey,
|
|
77
|
+
val
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const [themeClassName, parentName] = themeName.includes("-") ? themeName.split("-") : [themeName, ""];
|
|
82
|
+
const oppositeName = parentName === "dark" ? "light" : "dark";
|
|
83
|
+
const cssParentSel = parentName ? `.${PREFIX}${parentName}` : "";
|
|
84
|
+
const cssChildSel = `.${PREFIX}${themeClassName}`;
|
|
85
|
+
const cssSel = `${cssParentSel} ${cssChildSel}`;
|
|
86
|
+
const cssRule = `${cssSel}, .${PREFIX}${oppositeName} ${cssSel} {
|
|
87
|
+
${vars}
|
|
88
|
+
}`;
|
|
89
|
+
cssRules.push(cssRule);
|
|
90
|
+
}
|
|
91
|
+
Object.freeze(cssRules);
|
|
92
|
+
return {
|
|
93
|
+
cssRules,
|
|
94
|
+
css: cssRules.join("\n")
|
|
95
|
+
};
|
|
96
|
+
})();
|
|
97
|
+
const tokensParsed = parseTokens(config.tokens);
|
|
98
|
+
const themeParsed = {};
|
|
99
|
+
const firstKey = Object.keys(config.themes)[0];
|
|
100
|
+
for (const key in config.themes[firstKey]) {
|
|
101
|
+
const val = config.themes[firstKey][key].val;
|
|
102
|
+
themeParsed[`$${key}`] = new Variable({ val, name: key });
|
|
103
|
+
}
|
|
104
|
+
const next = {
|
|
105
|
+
shorthands: {},
|
|
106
|
+
...config,
|
|
107
|
+
Provider: createTamaguiProvider({
|
|
108
|
+
defaultTheme: "light",
|
|
109
|
+
...config
|
|
110
|
+
}),
|
|
111
|
+
themeConfig,
|
|
112
|
+
themeParsed,
|
|
113
|
+
tokensParsed,
|
|
114
|
+
parsed: true,
|
|
115
|
+
getCSS() {
|
|
116
|
+
return `${themeConfig.css}
|
|
117
|
+
${[...getStyleRules()].join("\n")}`;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
conf = next;
|
|
121
|
+
if (configListeners.size) {
|
|
122
|
+
configListeners.forEach((cb) => cb(next));
|
|
123
|
+
configListeners.clear();
|
|
124
|
+
}
|
|
125
|
+
return next;
|
|
126
|
+
}
|
|
127
|
+
__name(createTamagui, "createTamagui");
|
|
128
|
+
function getThemeParentClassName(themeName) {
|
|
129
|
+
return `theme-parent ${themeName ? `${PREFIX}${themeName}` : ""}`;
|
|
130
|
+
}
|
|
131
|
+
__name(getThemeParentClassName, "getThemeParentClassName");
|
|
132
|
+
const parseTokens = /* @__PURE__ */ __name((tokens) => {
|
|
133
|
+
const res = {};
|
|
134
|
+
for (const key in tokens) {
|
|
135
|
+
res[key] = {};
|
|
136
|
+
if (key === "font") {
|
|
137
|
+
for (const family in tokens.font) {
|
|
138
|
+
const obj = {};
|
|
139
|
+
res.font[`$${family}`] = obj;
|
|
140
|
+
for (const attrKey in tokens.font[family]) {
|
|
141
|
+
const attr = tokens.font[family][attrKey];
|
|
142
|
+
if (attrKey === "family") {
|
|
143
|
+
obj[attrKey] = attr;
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
obj[attrKey] = Object.keys(attr).reduce((acc, cur) => {
|
|
147
|
+
acc[`$${cur}`] = attr[cur];
|
|
148
|
+
return acc;
|
|
149
|
+
}, {});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
for (const skey in tokens[key]) {
|
|
155
|
+
res[key][`$${skey}`] = tokens[key][skey];
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return res;
|
|
159
|
+
}, "parseTokens");
|
|
160
|
+
export {
|
|
161
|
+
createTamagui,
|
|
162
|
+
getHasConfigured,
|
|
163
|
+
getTamagui,
|
|
164
|
+
getThemeParentClassName,
|
|
165
|
+
getTokens,
|
|
166
|
+
onConfiguredOnce
|
|
167
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { Variable, createVariable } from "./createVariable";
|
|
4
|
+
const createTheme = /* @__PURE__ */ __name((theme) => {
|
|
5
|
+
const res = {};
|
|
6
|
+
for (const key in theme) {
|
|
7
|
+
const val = theme[key];
|
|
8
|
+
if (!(val instanceof Variable)) {
|
|
9
|
+
res[key] = createVariable({
|
|
10
|
+
name: key,
|
|
11
|
+
val
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return res;
|
|
16
|
+
}, "createTheme");
|
|
17
|
+
export {
|
|
18
|
+
createTheme
|
|
19
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { createVariable } from "./createVariable";
|
|
4
|
+
import { validateTokens } from "./helpers/validate";
|
|
5
|
+
function createTokens(tokens) {
|
|
6
|
+
if (process.env.NODE_ENV === "development") {
|
|
7
|
+
validateTokens(tokens);
|
|
8
|
+
}
|
|
9
|
+
return setupTokens(tokens);
|
|
10
|
+
}
|
|
11
|
+
__name(createTokens, "createTokens");
|
|
12
|
+
function setupTokens(tokens) {
|
|
13
|
+
return mapTokensToVariables(tokens);
|
|
14
|
+
}
|
|
15
|
+
__name(setupTokens, "setupTokens");
|
|
16
|
+
const mapTokensToVariables = /* @__PURE__ */ __name((tokens, parentPath = "") => {
|
|
17
|
+
const res = {};
|
|
18
|
+
for (const key in tokens) {
|
|
19
|
+
const val = tokens[key];
|
|
20
|
+
const name = parentPath ? `${parentPath}-${key}` : key;
|
|
21
|
+
if (val && typeof val === "object") {
|
|
22
|
+
res[key] = mapTokensToVariables(tokens[key], name);
|
|
23
|
+
} else {
|
|
24
|
+
res[key] = createVariable({ val, name });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return res;
|
|
28
|
+
}, "mapTokensToVariables");
|
|
29
|
+
export {
|
|
30
|
+
createTokens,
|
|
31
|
+
mapTokensToVariables
|
|
32
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { isWeb } from "./constants/platform";
|
|
4
|
+
class Variable {
|
|
5
|
+
constructor({ val, name }) {
|
|
6
|
+
this.val = val;
|
|
7
|
+
this.name = name;
|
|
8
|
+
this.variable = isWeb ? `var(--${name})` : this.val;
|
|
9
|
+
}
|
|
10
|
+
toString() {
|
|
11
|
+
return isWeb ? this.variable : this.val;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
__name(Variable, "Variable");
|
|
15
|
+
const createVariable = /* @__PURE__ */ __name((props) => new Variable(props), "createVariable");
|
|
16
|
+
function isVariable(v) {
|
|
17
|
+
return v instanceof Variable;
|
|
18
|
+
}
|
|
19
|
+
__name(isVariable, "isVariable");
|
|
20
|
+
export {
|
|
21
|
+
Variable,
|
|
22
|
+
createVariable,
|
|
23
|
+
isVariable
|
|
24
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { useInsertionEffect } from "react";
|
|
4
|
+
import { getStylesAtomic } from "./getStylesAtomic";
|
|
5
|
+
import { insertStyleRule } from "./insertStyleRule";
|
|
6
|
+
let added = new Set();
|
|
7
|
+
function useStylesAsClassname(styles) {
|
|
8
|
+
if (!useInsertionEffect) {
|
|
9
|
+
return addStylesUsingClassname(styles);
|
|
10
|
+
} else {
|
|
11
|
+
const insertions = [];
|
|
12
|
+
const className = addStylesUsingClassname(styles, (_, rules) => {
|
|
13
|
+
for (const rule of rules) {
|
|
14
|
+
insertions.push(rule);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
useInsertionEffect(() => {
|
|
18
|
+
for (const ruleset of insertions) {
|
|
19
|
+
insertStyleRule(ruleset);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
return className;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
__name(useStylesAsClassname, "useStylesAsClassname");
|
|
26
|
+
function addStylesUsingClassname(styles, onAdd) {
|
|
27
|
+
let className = "";
|
|
28
|
+
for (const style of styles) {
|
|
29
|
+
if (!style)
|
|
30
|
+
continue;
|
|
31
|
+
if (Array.isArray(style)) {
|
|
32
|
+
className += " " + addStylesUsingClassname(style);
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
for (const { identifier, rules } of getStylesAtomic(style)) {
|
|
36
|
+
className += ` ${identifier}`;
|
|
37
|
+
if (added.has(identifier)) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
added.add(identifier);
|
|
41
|
+
if (onAdd) {
|
|
42
|
+
onAdd(identifier, rules);
|
|
43
|
+
} else {
|
|
44
|
+
for (const rule of rules) {
|
|
45
|
+
insertStyleRule(rule);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return className;
|
|
51
|
+
}
|
|
52
|
+
__name(addStylesUsingClassname, "addStylesUsingClassname");
|
|
53
|
+
export {
|
|
54
|
+
addStylesUsingClassname,
|
|
55
|
+
useStylesAsClassname
|
|
56
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { mediaObjectToString } from "../hooks/useMedia";
|
|
4
|
+
const MEDIA_SEP = "_";
|
|
5
|
+
const createMediaStyle = /* @__PURE__ */ __name(({ identifier, rules }, mediaKey, mediaQueries, negate, importance = 0) => {
|
|
6
|
+
const mediaKeys = Object.keys(mediaQueries);
|
|
7
|
+
const mediaKeyPrecendence = mediaKeys.reduce((acc, cur, i) => {
|
|
8
|
+
acc[cur] = new Array(importance + 1).fill(":root").join("");
|
|
9
|
+
return acc;
|
|
10
|
+
}, {});
|
|
11
|
+
const negKey = negate ? "0" : "";
|
|
12
|
+
const ogPrefix = identifier.slice(0, identifier.indexOf("-") + 1);
|
|
13
|
+
const nextIdentifier = `${identifier.replace(ogPrefix, `${ogPrefix}${MEDIA_SEP}${mediaKey}${negKey}${MEDIA_SEP}`)}`;
|
|
14
|
+
const screenStr = negate ? "not all" : "screen";
|
|
15
|
+
const mediaSelector = mediaObjectToString(mediaQueries[mediaKey]);
|
|
16
|
+
const mediaQuery = `${screenStr} and ${mediaSelector}`;
|
|
17
|
+
const precendencePrefix = mediaKeyPrecendence[mediaKey];
|
|
18
|
+
const styleInner = rules[0].replace(identifier, nextIdentifier);
|
|
19
|
+
let styleRule = "";
|
|
20
|
+
if (styleInner.includes("@media")) {
|
|
21
|
+
styleRule = styleInner.replace("{", ` and ${mediaQuery} {`);
|
|
22
|
+
} else {
|
|
23
|
+
styleRule = `@media ${mediaQuery} { ${precendencePrefix} ${styleInner} }`;
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
styleRule,
|
|
27
|
+
identifier: nextIdentifier
|
|
28
|
+
};
|
|
29
|
+
}, "createMediaStyle");
|
|
30
|
+
export {
|
|
31
|
+
MEDIA_SEP,
|
|
32
|
+
createMediaStyle
|
|
33
|
+
};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { isWeb } from "../constants/platform";
|
|
4
|
+
import { getTamagui } from "../createTamagui";
|
|
5
|
+
import { Variable } from "../createVariable";
|
|
6
|
+
import { isObj } from "./isObj";
|
|
7
|
+
const createPropMapper = /* @__PURE__ */ __name((c) => {
|
|
8
|
+
const variants = c.variants;
|
|
9
|
+
let variantsParsed;
|
|
10
|
+
const defaultProps = c.defaultProps || {};
|
|
11
|
+
return (key, value, theme, props) => {
|
|
12
|
+
const conf = getTamagui();
|
|
13
|
+
if (!conf) {
|
|
14
|
+
console.trace("no conf! err");
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (variants && !variantsParsed) {
|
|
18
|
+
variantsParsed = parseVariants(variants, conf);
|
|
19
|
+
}
|
|
20
|
+
let fontFamily = props.fontFamily || defaultProps.fontFamily || "$body";
|
|
21
|
+
const variant = variantsParsed?.[key];
|
|
22
|
+
if (variant && typeof value !== "undefined") {
|
|
23
|
+
const val = value === true ? variant["$true"] || variant["true"] : variant[value] ?? variant["..."] ?? value;
|
|
24
|
+
const res = typeof val === "function" ? val(value, { tokens: conf.tokensParsed, theme, props }) : isObj(val) ? { ...val } : val;
|
|
25
|
+
if (isObj(res)) {
|
|
26
|
+
resolveTokens(res, conf, theme, fontFamily);
|
|
27
|
+
}
|
|
28
|
+
return res;
|
|
29
|
+
}
|
|
30
|
+
let shouldReturn = false;
|
|
31
|
+
if (conf.shorthands[key]) {
|
|
32
|
+
shouldReturn = true;
|
|
33
|
+
key = conf.shorthands[key];
|
|
34
|
+
}
|
|
35
|
+
if (value && value[0] === "$") {
|
|
36
|
+
shouldReturn = true;
|
|
37
|
+
value = getToken(key, value, conf, theme, fontFamily);
|
|
38
|
+
}
|
|
39
|
+
if (value instanceof Variable) {
|
|
40
|
+
shouldReturn = true;
|
|
41
|
+
value = value.variable;
|
|
42
|
+
}
|
|
43
|
+
if (shouldReturn) {
|
|
44
|
+
return {
|
|
45
|
+
[key]: value
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}, "createPropMapper");
|
|
50
|
+
const resolveTokens = /* @__PURE__ */ __name((res, conf, theme, fontFamily) => {
|
|
51
|
+
for (const rKey in res) {
|
|
52
|
+
const fKey = conf.shorthands[rKey] || rKey;
|
|
53
|
+
const val = res[rKey];
|
|
54
|
+
if (val instanceof Variable) {
|
|
55
|
+
res[fKey] = val.variable;
|
|
56
|
+
} else if (typeof val === "string") {
|
|
57
|
+
const fVal = val[0] === "$" ? getToken(fKey, val, conf, theme, fontFamily) : val;
|
|
58
|
+
res[fKey] = fVal;
|
|
59
|
+
} else {
|
|
60
|
+
if (isObj(val)) {
|
|
61
|
+
resolveTokens(val, conf, theme, fontFamily);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}, "resolveTokens");
|
|
66
|
+
const getToken = /* @__PURE__ */ __name((key, value, { tokensParsed, themeParsed }, theme, fontFamily = "$body") => {
|
|
67
|
+
if (themeParsed[value]) {
|
|
68
|
+
if (isWeb && themeParsed[value].variable) {
|
|
69
|
+
return themeParsed[value].variable;
|
|
70
|
+
} else {
|
|
71
|
+
if (value && value[0] === "$") {
|
|
72
|
+
return theme[`${value.slice(1)}`]?.val || themeParsed[value]?.val;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
let valOrVar;
|
|
77
|
+
if (key === "fontFamily") {
|
|
78
|
+
valOrVar = tokensParsed.font[value]?.family || value;
|
|
79
|
+
}
|
|
80
|
+
if (key === "fontSize") {
|
|
81
|
+
valOrVar = tokensParsed.font[fontFamily]?.size[value] || value;
|
|
82
|
+
}
|
|
83
|
+
if (key === "lineHeight") {
|
|
84
|
+
valOrVar = tokensParsed.font[fontFamily]?.lineHeight[value] || value;
|
|
85
|
+
}
|
|
86
|
+
if (key === "letterSpacing") {
|
|
87
|
+
valOrVar = tokensParsed.font[fontFamily]?.letterSpacing[value] || value;
|
|
88
|
+
}
|
|
89
|
+
if (key === "fontWeight") {
|
|
90
|
+
valOrVar = tokensParsed.font[fontFamily]?.weight[value] || value;
|
|
91
|
+
}
|
|
92
|
+
if (typeof valOrVar !== "undefined") {
|
|
93
|
+
if (valOrVar instanceof Variable) {
|
|
94
|
+
return valOrVar.variable;
|
|
95
|
+
} else {
|
|
96
|
+
return valOrVar;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
for (const cat in tokenCategories) {
|
|
100
|
+
if (tokenCategories[cat][key]) {
|
|
101
|
+
const res = tokensParsed[cat][value];
|
|
102
|
+
if (res) {
|
|
103
|
+
return res.variable;
|
|
104
|
+
} else {
|
|
105
|
+
const themeVar = themeParsed[value];
|
|
106
|
+
if (themeVar) {
|
|
107
|
+
return themeVar.variable;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const spaceVar = tokensParsed.space[value];
|
|
113
|
+
if (spaceVar) {
|
|
114
|
+
return spaceVar.variable;
|
|
115
|
+
}
|
|
116
|
+
return value;
|
|
117
|
+
}, "getToken");
|
|
118
|
+
const tokenCategories = {
|
|
119
|
+
size: {
|
|
120
|
+
width: true,
|
|
121
|
+
height: true,
|
|
122
|
+
minWidth: true,
|
|
123
|
+
minHeight: true,
|
|
124
|
+
maxWidth: true,
|
|
125
|
+
maxHeight: true
|
|
126
|
+
},
|
|
127
|
+
color: {
|
|
128
|
+
color: true,
|
|
129
|
+
backgroundColor: true,
|
|
130
|
+
borderColor: true,
|
|
131
|
+
borderBottomColor: true,
|
|
132
|
+
borderTopColor: true,
|
|
133
|
+
borderLeftColor: true,
|
|
134
|
+
borderRightColor: true
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
function parseVariants(variants, conf) {
|
|
138
|
+
return Object.keys(variants).reduce((acc, key) => {
|
|
139
|
+
acc[key] = Object.keys(variants[key]).reduce((vacc, vkey) => {
|
|
140
|
+
const variantVal = variants[key][vkey];
|
|
141
|
+
if (vkey.startsWith("...")) {
|
|
142
|
+
vacc["..."] = variantVal;
|
|
143
|
+
const tokenKey = vkey.slice(3);
|
|
144
|
+
const tokens = conf.tokens[tokenKey];
|
|
145
|
+
for (const tkey in tokens) {
|
|
146
|
+
vacc[`$${tkey}`] = variantVal;
|
|
147
|
+
}
|
|
148
|
+
} else {
|
|
149
|
+
vacc[vkey] = variantVal;
|
|
150
|
+
}
|
|
151
|
+
return vacc;
|
|
152
|
+
}, {});
|
|
153
|
+
return acc;
|
|
154
|
+
}, {});
|
|
155
|
+
}
|
|
156
|
+
__name(parseVariants, "parseVariants");
|
|
157
|
+
export {
|
|
158
|
+
createPropMapper
|
|
159
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { TextAncestorProvider } from "../views/TextAncestorContext";
|
|
5
|
+
import { ThemeProvider } from "../views/ThemeProvider";
|
|
6
|
+
function createTamaguiProvider(themeProps) {
|
|
7
|
+
return /* @__PURE__ */ __name(function TamaguiProvider({
|
|
8
|
+
initialWindowMetrics,
|
|
9
|
+
fallback,
|
|
10
|
+
children,
|
|
11
|
+
...themePropsProvider
|
|
12
|
+
}) {
|
|
13
|
+
return <TextAncestorProvider><ThemeProvider {...themeProps} {...themePropsProvider}><React.Suspense fallback={fallback || null}>{children}</React.Suspense></ThemeProvider></TextAncestorProvider>;
|
|
14
|
+
}, "TamaguiProvider");
|
|
15
|
+
}
|
|
16
|
+
__name(createTamaguiProvider, "createTamaguiProvider");
|
|
17
|
+
export {
|
|
18
|
+
createTamaguiProvider
|
|
19
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { createPropMapper } from "./createPropMapper";
|
|
4
|
+
function extendStaticConfig(Component, config = {}) {
|
|
5
|
+
const parent = Component || {};
|
|
6
|
+
if (!parent.staticConfig) {
|
|
7
|
+
parent.staticConfig = {
|
|
8
|
+
Component
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
const variants = {
|
|
12
|
+
...parent.staticConfig.variants
|
|
13
|
+
};
|
|
14
|
+
if (config.variants) {
|
|
15
|
+
for (const key in config.variants) {
|
|
16
|
+
if (variants[key]) {
|
|
17
|
+
variants[key] = {
|
|
18
|
+
...variants[key],
|
|
19
|
+
...config.variants[key]
|
|
20
|
+
};
|
|
21
|
+
} else {
|
|
22
|
+
variants[key] = config.variants[key];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return parseStaticConfig({
|
|
27
|
+
...parent.staticConfig,
|
|
28
|
+
isZStack: config.isZStack || parent.staticConfig.isZStack,
|
|
29
|
+
variants,
|
|
30
|
+
isText: config.isText || parent.staticConfig.isText || false,
|
|
31
|
+
neverFlatten: config.neverFlatten ?? parent.staticConfig.neverFlatten,
|
|
32
|
+
ensureOverriddenProp: config.ensureOverriddenProp ?? parent.staticConfig.ensureOverriddenProp,
|
|
33
|
+
validStyles: config.validStyles ? {
|
|
34
|
+
...parent.staticConfig.validStyles,
|
|
35
|
+
...config.validStyles
|
|
36
|
+
} : parent.staticConfig.validStyles,
|
|
37
|
+
validPropsExtra: {
|
|
38
|
+
...parent.staticConfig.validPropsExtra,
|
|
39
|
+
...config.validPropsExtra
|
|
40
|
+
},
|
|
41
|
+
defaultProps: {
|
|
42
|
+
...parent.staticConfig.defaultProps,
|
|
43
|
+
...config.defaultProps
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
__name(extendStaticConfig, "extendStaticConfig");
|
|
48
|
+
const parseStaticConfig = /* @__PURE__ */ __name((config) => {
|
|
49
|
+
return {
|
|
50
|
+
...config,
|
|
51
|
+
parsed: true,
|
|
52
|
+
propMapper: createPropMapper(config)
|
|
53
|
+
};
|
|
54
|
+
}, "parseStaticConfig");
|
|
55
|
+
export {
|
|
56
|
+
extendStaticConfig,
|
|
57
|
+
parseStaticConfig
|
|
58
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
const matchRgba = /rgba\(\s*([\d\.]{1,})\s*,\s*([\d\.]{1,})\s*,\s*([\d\.]{1,})\s*,\s*([\d\.]{1,})\s*\)$/;
|
|
4
|
+
function fixNativeShadow(props) {
|
|
5
|
+
if (props.shadowColor) {
|
|
6
|
+
if (!!!("shadowOffset" in props)) {
|
|
7
|
+
props.shadowOffset = {
|
|
8
|
+
width: 0,
|
|
9
|
+
height: 0
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
if (!!!("shadowOpacity" in props)) {
|
|
13
|
+
const c = `${props.shadowColor}`;
|
|
14
|
+
if (c[0] === "r" && c[3] === "a") {
|
|
15
|
+
const [_, r, g, b, a] = c.match(matchRgba) || [];
|
|
16
|
+
if (typeof a !== "string") {
|
|
17
|
+
console.warn("non valid rgba", c);
|
|
18
|
+
return props;
|
|
19
|
+
}
|
|
20
|
+
props.shadowColor = `rgb(${r},${g},${b})`;
|
|
21
|
+
props.shadowOpacity = +a;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
__name(fixNativeShadow, "fixNativeShadow");
|
|
27
|
+
export {
|
|
28
|
+
fixNativeShadow
|
|
29
|
+
};
|