@tamagui/core 1.0.0-beta.202 → 1.0.0-beta.203
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/Tamagui.js +18 -1
- package/dist/cjs/Tamagui.js.map +2 -2
- package/dist/cjs/ThemeContext.js +4 -0
- package/dist/cjs/ThemeManager.js +30 -14
- package/dist/cjs/ThemeManager.js.map +2 -2
- package/dist/cjs/conf.js +10 -1
- package/dist/cjs/conf.js.map +2 -2
- package/dist/cjs/constants/constants.js +6 -0
- package/dist/cjs/constants/platform.js +15 -0
- package/dist/cjs/constants/platform.js.map +2 -2
- package/dist/cjs/constants/rnw.js +4 -0
- package/dist/cjs/contexts/ButtonInsideButtonContext.js +4 -0
- package/dist/cjs/createComponent.js +117 -112
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/createFont.js +4 -0
- package/dist/cjs/createShorthands.js +4 -0
- package/dist/cjs/createTamagui.js +55 -27
- package/dist/cjs/createTamagui.js.map +2 -2
- package/dist/cjs/createTheme.js +4 -0
- package/dist/cjs/createTokens.js +7 -6
- package/dist/cjs/createTokens.js.map +2 -2
- package/dist/cjs/createVariable.js +18 -2
- package/dist/cjs/createVariable.js.map +2 -2
- package/dist/cjs/defaultComponentState.js +0 -30
- package/dist/cjs/defaultComponentState.js.map +3 -3
- package/dist/cjs/helpers/RNComponents.js +4 -0
- package/dist/cjs/helpers/RNComponents.js.map +0 -0
- package/dist/cjs/helpers/addStylesUsingClassname.js +8 -0
- package/dist/cjs/helpers/addStylesUsingClassname.js.map +2 -2
- package/dist/cjs/helpers/areEqualSets.js +4 -0
- package/dist/cjs/helpers/createMediaStyle.js +5 -0
- package/dist/cjs/helpers/createPropMapper.js +63 -61
- package/dist/cjs/helpers/createPropMapper.js.map +2 -2
- package/dist/cjs/helpers/createShallowUpdate.js +4 -0
- package/dist/cjs/helpers/createShallowUpdate.js.map +0 -0
- package/dist/cjs/helpers/createTamaguiProvider.js +4 -0
- package/dist/cjs/helpers/extendStaticConfig.js +9 -6
- package/dist/cjs/helpers/extendStaticConfig.js.map +2 -2
- package/dist/cjs/helpers/fixNativeShadow.js +4 -0
- package/dist/cjs/helpers/fixNativeShadow.native.js +6 -2
- package/dist/cjs/helpers/fixNativeShadow.native.js.map +2 -2
- package/dist/cjs/helpers/getExpandedShorthands.js +4 -0
- package/dist/cjs/{constants/pseudos.js → helpers/getSize.js} +17 -19
- package/dist/cjs/helpers/getSize.js.map +7 -0
- package/dist/cjs/helpers/getSplitStyles.js +114 -59
- package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
- package/dist/cjs/helpers/getStylesAtomic.js +20 -2
- package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
- package/dist/cjs/helpers/getStylesAtomic.native.js +4 -0
- package/dist/cjs/helpers/insertStyleRule.js +46 -26
- package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
- package/dist/cjs/helpers/isObj.js +4 -0
- package/dist/cjs/helpers/isTamaguiElement.js +4 -0
- package/dist/cjs/helpers/matchMedia.js +4 -0
- package/dist/cjs/helpers/matchMedia.native.js +4 -0
- package/dist/cjs/helpers/proxyThemeVariables.js +40 -0
- package/dist/cjs/helpers/proxyThemeVariables.js.map +7 -0
- package/dist/cjs/helpers/themeable.js +7 -2
- package/dist/cjs/helpers/themeable.js.map +2 -2
- package/dist/cjs/helpers/validate.js +53 -11
- package/dist/cjs/helpers/validate.js.map +2 -2
- package/dist/cjs/helpers/withStaticProperties.js +4 -0
- package/dist/cjs/helpers/wrapThemeManagerContext.js +4 -0
- package/dist/cjs/hooks/useConstant.js +4 -0
- package/dist/cjs/hooks/useFeatures.js +101 -13
- package/dist/cjs/hooks/useFeatures.js.map +2 -2
- package/dist/cjs/hooks/useIsMounted.js +4 -0
- package/dist/cjs/hooks/useIsTouchDevice.js +4 -0
- package/dist/cjs/hooks/useMedia.js +31 -12
- package/dist/cjs/hooks/useMedia.js.map +2 -2
- package/dist/cjs/hooks/usePressable.js +4 -0
- package/dist/cjs/hooks/useTheme.js +36 -23
- package/dist/cjs/hooks/useTheme.js.map +2 -2
- package/dist/cjs/hooks/useUnmountEffect.js +4 -0
- package/dist/cjs/index.js +15 -0
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/static.js +3 -0
- package/dist/cjs/static.js.map +2 -2
- package/dist/cjs/styled.js +7 -4
- package/dist/cjs/styled.js.map +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/views/Stack.js +5 -0
- package/dist/cjs/views/Stack.js.map +2 -2
- package/dist/cjs/views/Text.js +5 -0
- package/dist/cjs/views/Text.js.map +2 -2
- package/dist/cjs/views/TextAncestorContext.js +6 -0
- package/dist/cjs/views/Theme.js +11 -4
- package/dist/cjs/views/Theme.js.map +2 -2
- package/dist/cjs/views/ThemeInverse.js +5 -0
- package/dist/cjs/views/ThemeProvider.js +6 -1
- package/dist/cjs/views/ThemeProvider.js.map +2 -2
- package/dist/cjs/views/ThemeReset.js +4 -0
- package/dist/esm/Tamagui.js +10 -2
- package/dist/esm/Tamagui.js.map +2 -2
- package/dist/esm/ThemeManager.js +21 -11
- package/dist/esm/ThemeManager.js.map +2 -2
- package/dist/esm/conf.js +0 -1
- package/dist/esm/conf.js.map +2 -2
- package/dist/esm/constants/platform.js +2 -0
- package/dist/esm/constants/platform.js.map +2 -2
- package/dist/esm/createComponent.js +107 -115
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/createTamagui.js +51 -27
- package/dist/esm/createTamagui.js.map +2 -2
- package/dist/esm/createTokens.js +2 -6
- package/dist/esm/createTokens.js.map +2 -2
- package/dist/esm/createVariable.js +8 -2
- package/dist/esm/createVariable.js.map +2 -2
- package/dist/esm/defaultComponentState.js +0 -11
- package/dist/esm/defaultComponentState.js.map +3 -3
- package/dist/esm/helpers/RNComponents.js +0 -0
- package/dist/esm/helpers/RNComponents.js.map +0 -0
- package/dist/esm/helpers/addStylesUsingClassname.js +4 -1
- package/dist/esm/helpers/addStylesUsingClassname.js.map +2 -2
- package/dist/esm/helpers/createPropMapper.js +59 -61
- package/dist/esm/helpers/createPropMapper.js.map +2 -2
- package/dist/esm/helpers/createShallowUpdate.js +0 -0
- package/dist/esm/helpers/createShallowUpdate.js.map +0 -0
- package/dist/esm/helpers/extendStaticConfig.js +9 -6
- package/dist/esm/helpers/extendStaticConfig.js.map +2 -2
- package/dist/esm/helpers/fixNativeShadow.native.js +2 -2
- package/dist/esm/helpers/fixNativeShadow.native.js.map +2 -2
- package/dist/esm/helpers/getSize.js +13 -0
- package/dist/esm/helpers/getSize.js.map +7 -0
- package/dist/esm/helpers/getSplitStyles.js +110 -61
- package/dist/esm/helpers/getSplitStyles.js.map +2 -2
- package/dist/esm/helpers/getStylesAtomic.js +15 -2
- package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
- package/dist/esm/helpers/insertStyleRule.js +36 -26
- package/dist/esm/helpers/insertStyleRule.js.map +2 -2
- package/dist/esm/helpers/proxyThemeVariables.js +18 -0
- package/dist/esm/helpers/proxyThemeVariables.js.map +7 -0
- package/dist/esm/helpers/themeable.js +3 -2
- package/dist/esm/helpers/themeable.js.map +2 -2
- package/dist/esm/helpers/validate.js +24 -11
- package/dist/esm/helpers/validate.js.map +2 -2
- package/dist/esm/hooks/useFeatures.js +96 -18
- package/dist/esm/hooks/useFeatures.js.map +2 -2
- package/dist/esm/hooks/useMedia.js +20 -12
- package/dist/esm/hooks/useMedia.js.map +2 -2
- package/dist/esm/hooks/useTheme.js +28 -23
- package/dist/esm/hooks/useTheme.js.map +2 -2
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/static.js +3 -0
- package/dist/esm/static.js.map +2 -2
- package/dist/esm/styled.js +3 -4
- package/dist/esm/styled.js.map +2 -2
- package/dist/esm/views/Stack.js +1 -0
- package/dist/esm/views/Stack.js.map +2 -2
- package/dist/esm/views/Text.js +1 -0
- package/dist/esm/views/Text.js.map +2 -2
- package/dist/esm/views/Theme.js +7 -4
- package/dist/esm/views/Theme.js.map +2 -2
- package/dist/esm/views/ThemeProvider.js +2 -1
- package/dist/esm/views/ThemeProvider.js.map +2 -2
- package/dist/jsx/Tamagui.js +10 -2
- package/dist/jsx/ThemeManager.js +21 -11
- package/dist/jsx/conf.js +0 -1
- package/dist/jsx/constants/platform.js +2 -0
- package/dist/jsx/createComponent.js +105 -114
- package/dist/jsx/createTamagui.js +51 -27
- package/dist/jsx/createTokens.js +2 -6
- package/dist/jsx/createVariable.js +8 -2
- package/dist/jsx/defaultComponentState.js +0 -11
- package/dist/jsx/helpers/RNComponents.js +0 -0
- package/dist/jsx/helpers/addStylesUsingClassname.js +4 -1
- package/dist/jsx/helpers/createPropMapper.js +59 -61
- package/dist/jsx/helpers/createShallowUpdate.js +0 -0
- package/dist/jsx/helpers/extendStaticConfig.js +9 -6
- package/dist/jsx/helpers/fixNativeShadow.native.js +2 -2
- package/dist/jsx/helpers/getSize.js +12 -0
- package/dist/jsx/helpers/getSplitStyles.js +110 -61
- package/dist/jsx/helpers/getStylesAtomic.js +15 -2
- package/dist/jsx/helpers/insertStyleRule.js +36 -26
- package/dist/jsx/helpers/proxyThemeVariables.js +17 -0
- package/dist/jsx/helpers/themeable.js +3 -3
- package/dist/jsx/helpers/validate.js +24 -11
- package/dist/jsx/hooks/useFeatures.js +96 -18
- package/dist/jsx/hooks/useMedia.js +20 -12
- package/dist/jsx/hooks/useTheme.js +28 -23
- package/dist/jsx/index.js +4 -0
- package/dist/jsx/static.js +3 -0
- package/dist/jsx/styled.js +3 -4
- package/dist/jsx/views/Stack.js +1 -0
- package/dist/jsx/views/Text.js +1 -0
- package/dist/jsx/views/Theme.js +7 -4
- package/dist/jsx/views/ThemeProvider.js +2 -2
- package/package.json +6 -6
- package/types/Tamagui.d.ts +18 -1
- package/types/Tamagui.d.ts.map +1 -1
- package/types/ThemeManager.d.ts +3 -3
- package/types/ThemeManager.d.ts.map +1 -1
- package/types/conf.d.ts +2 -0
- package/types/conf.d.ts.map +1 -1
- package/types/constants/platform.d.ts +1 -0
- package/types/constants/platform.d.ts.map +1 -1
- package/types/createComponent.d.ts +3 -4
- package/types/createComponent.d.ts.map +1 -1
- package/types/createFont.d.ts +1 -1
- package/types/createFont.d.ts.map +1 -1
- package/types/createTamagui.d.ts +2 -1
- package/types/createTamagui.d.ts.map +1 -1
- package/types/createTokens.d.ts +0 -26
- package/types/createTokens.d.ts.map +1 -1
- package/types/createVariable.d.ts +1 -0
- package/types/createVariable.d.ts.map +1 -1
- package/types/helpers/addStylesUsingClassname.d.ts.map +1 -1
- package/types/helpers/createMediaStyle.d.ts.map +1 -1
- package/types/helpers/createPropMapper.d.ts +1 -1
- package/types/helpers/createPropMapper.d.ts.map +1 -1
- package/types/helpers/extendStaticConfig.d.ts +2 -2
- package/types/helpers/extendStaticConfig.d.ts.map +1 -1
- package/types/helpers/getSize.d.ts +3 -0
- package/types/helpers/getSize.d.ts.map +1 -0
- package/types/helpers/getSplitStyles.d.ts +4 -1
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/helpers/getStylesAtomic.d.ts.map +1 -1
- package/types/helpers/insertStyleRule.d.ts +2 -1
- package/types/helpers/insertStyleRule.d.ts.map +1 -1
- package/types/helpers/proxyThemeVariables.d.ts +2 -0
- package/types/helpers/proxyThemeVariables.d.ts.map +1 -0
- package/types/helpers/themeable.d.ts +3 -1
- package/types/helpers/themeable.d.ts.map +1 -1
- package/types/helpers/validate.d.ts.map +1 -1
- package/types/hooks/useMedia.d.ts +3 -3
- package/types/hooks/useMedia.d.ts.map +1 -1
- package/types/hooks/useTheme.d.ts +1 -1
- package/types/hooks/useTheme.d.ts.map +1 -1
- package/types/index.d.ts +2 -0
- package/types/index.d.ts.map +1 -1
- package/types/static.d.ts +3 -0
- package/types/static.d.ts.map +1 -1
- package/types/styled.d.ts +12 -3
- package/types/styled.d.ts.map +1 -1
- package/types/types.d.ts +73 -45
- package/types/types.d.ts.map +1 -1
- package/types/views/Theme.d.ts +1 -0
- package/types/views/Theme.d.ts.map +1 -1
- package/types/views/ThemeProvider.d.ts +1 -0
- package/types/views/ThemeProvider.d.ts.map +1 -1
- package/dist/cjs/constants/pseudos.js.map +0 -7
- package/dist/cjs/createShallowUpdate.js +0 -1
- package/dist/cjs/createShallowUpdate.js.map +0 -7
- package/dist/cjs/devtools.js +0 -32
- package/dist/cjs/devtools.js.map +0 -7
- package/dist/cjs/spacedChildren.js +0 -86
- package/dist/cjs/spacedChildren.js.map +0 -7
- package/dist/cjs/tamagui-base.css +0 -8
- package/dist/cjs/tamagui-base.css.map +0 -7
- package/dist/esm/constants/pseudos.js +0 -18
- package/dist/esm/constants/pseudos.js.map +0 -7
- package/dist/esm/createShallowUpdate.js +0 -1
- package/dist/esm/createShallowUpdate.js.map +0 -7
- package/dist/esm/devtools.js +0 -14
- package/dist/esm/devtools.js.map +0 -7
- package/dist/esm/spacedChildren.js +0 -52
- package/dist/esm/spacedChildren.js.map +0 -7
- package/dist/esm/tamagui-base.css +0 -8
- package/dist/esm/tamagui-base.css.map +0 -7
- package/dist/jsx/constants/pseudos.js +0 -17
- package/dist/jsx/createShallowUpdate.js +0 -0
- package/dist/jsx/devtools.js +0 -13
- package/dist/jsx/spacedChildren.js +0 -44
- package/dist/jsx/tamagui-base.css +0 -7
- package/types/spacedChildren.d.ts +0 -9
- package/types/spacedChildren.d.ts.map +0 -1
package/dist/esm/ThemeManager.js
CHANGED
|
@@ -16,9 +16,9 @@ var __privateMethod = (obj, member, method) => {
|
|
|
16
16
|
var _getClassName, getClassName_fn;
|
|
17
17
|
import { createContext } from "react";
|
|
18
18
|
import { getThemes } from "./conf";
|
|
19
|
-
import { THEME_CLASSNAME_PREFIX, THEME_NAME_SEPARATOR } from "./
|
|
19
|
+
import { THEME_CLASSNAME_PREFIX, THEME_NAME_SEPARATOR } from "./constants/constants";
|
|
20
20
|
class ThemeManager {
|
|
21
|
-
constructor(name =
|
|
21
|
+
constructor(name = "", theme = null, parentManager = null) {
|
|
22
22
|
this.name = name;
|
|
23
23
|
this.theme = theme;
|
|
24
24
|
this.parentManager = parentManager;
|
|
@@ -76,7 +76,7 @@ class ThemeManager {
|
|
|
76
76
|
return false;
|
|
77
77
|
}
|
|
78
78
|
this.className = className || null;
|
|
79
|
-
this.name = name ||
|
|
79
|
+
this.name = name || "";
|
|
80
80
|
this.theme = theme;
|
|
81
81
|
this.notifyListeners();
|
|
82
82
|
return true;
|
|
@@ -85,10 +85,14 @@ class ThemeManager {
|
|
|
85
85
|
const { themes = getThemes(), name, componentName } = opts;
|
|
86
86
|
if (!name) {
|
|
87
87
|
if (componentName) {
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
const names = [
|
|
89
|
+
`${this.name}_${componentName}`,
|
|
90
|
+
`${withoutComponentName(this.name)}_${componentName}`
|
|
91
|
+
];
|
|
92
|
+
for (const name2 of names) {
|
|
93
|
+
if (name2 in themes) {
|
|
94
|
+
return { name: name2, theme: themes[name2], className: __privateMethod(this, _getClassName, getClassName_fn).call(this, name2) };
|
|
95
|
+
}
|
|
92
96
|
}
|
|
93
97
|
}
|
|
94
98
|
return {
|
|
@@ -113,9 +117,14 @@ class ThemeManager {
|
|
|
113
117
|
parentName = parentName.slice(0, parentName.lastIndexOf(THEME_NAME_SEPARATOR));
|
|
114
118
|
}
|
|
115
119
|
if (componentName) {
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
nextName
|
|
120
|
+
const names = [
|
|
121
|
+
`${nextName}_${componentName}`,
|
|
122
|
+
`${withoutComponentName(nextName)}_${componentName}`
|
|
123
|
+
];
|
|
124
|
+
for (const name2 of names) {
|
|
125
|
+
if (name2 in themes) {
|
|
126
|
+
nextName = name2;
|
|
127
|
+
}
|
|
119
128
|
}
|
|
120
129
|
}
|
|
121
130
|
let theme = themes[nextName];
|
|
@@ -123,7 +132,7 @@ class ThemeManager {
|
|
|
123
132
|
theme = themes[`light_${nextName}`];
|
|
124
133
|
}
|
|
125
134
|
if (process.env.NODE_ENV === "development" && props && props["debug"]) {
|
|
126
|
-
console.log("getNextTheme", { opts, nextName, parentName }
|
|
135
|
+
console.log("getNextTheme", { name: opts.name, nextName, parentName });
|
|
127
136
|
}
|
|
128
137
|
return {
|
|
129
138
|
name: nextName,
|
|
@@ -169,6 +178,7 @@ getClassName_fn = /* @__PURE__ */ __name(function(name) {
|
|
|
169
178
|
}, "#getClassName");
|
|
170
179
|
const ThemeManagerContext = createContext(null);
|
|
171
180
|
const emptyManager = new ThemeManager();
|
|
181
|
+
const withoutComponentName = /* @__PURE__ */ __name((name) => name.replace(/\_[A-Z][a-z]+$/, ""), "withoutComponentName");
|
|
172
182
|
export {
|
|
173
183
|
ThemeManager,
|
|
174
184
|
ThemeManagerContext,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/ThemeManager.tsx"],
|
|
4
|
-
"sourcesContent": ["import { createContext } from 'react'\n\nimport { getThemes } from './conf'\nimport { THEME_CLASSNAME_PREFIX, THEME_NAME_SEPARATOR } from './
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAEA;AACA;AAYO,MAAM,aAAa;AAAA,EAMxB,YACS,
|
|
4
|
+
"sourcesContent": ["import { createContext } from 'react'\n\nimport { getThemes } from './conf'\nimport { THEME_CLASSNAME_PREFIX, THEME_NAME_SEPARATOR } from './constants/constants'\nimport { ThemeObject, Themes } from './types'\n\ntype ThemeListener = (name: string | null, themeManager: ThemeManager) => void\n\nexport type SetActiveThemeProps = {\n className?: string\n parentManager?: ThemeManager | null\n name?: string | null\n theme?: any\n}\n\nexport class ThemeManager {\n keys = new Map<any, Set<string>>()\n listeners = new Map<any, Function>()\n themeListeners = new Set<ThemeListener>()\n className: string | null = null\n\n constructor(\n public name: string = '',\n public theme: ThemeObject | null = null,\n public parentManager: ThemeManager | null = null\n ) {\n // find the nearest different parentManager\n let parent = parentManager\n let tries = 0\n while (true) {\n tries++\n if (tries > 10) {\n throw new Error(`Nested 10 of the same theme in a row, likely error`)\n }\n if (!parent) break\n if (parent.name === name) {\n // go up if same\n parent = parent.parentManager\n } else {\n this.parentManager = parent\n break\n }\n }\n }\n\n get parentName() {\n return this.parentManager?.name || null\n }\n\n get fullName(): string {\n return this.getNextTheme().name || this.name || ''\n // const parentName = this.parentManager?.fullName || ''\n // const name = this.name || ''\n // const parts = [...new Set([...`${parentName}_${name}`.split('_')])].filter(Boolean)\n // return parts.join('_')\n }\n\n // gets value going up to parents\n getValue(key: string) {\n let theme = this.theme\n let manager = this as ThemeManager | null\n while (true) {\n if (!theme) return\n if (key in theme) {\n return theme[key]\n }\n manager = this.parentManager\n if (!manager) {\n return\n }\n if (manager.theme === theme) {\n return\n }\n theme = manager.theme\n }\n }\n\n update({ name, theme, className }: SetActiveThemeProps = {}) {\n // className compare on web, avoids light/dark re-renders\n const sameNameOrClassName = this.className\n ? // == instead of === (sometimes its undefined/null)\n className == this.className\n : name === this.name\n if (sameNameOrClassName) {\n return false\n }\n this.className = className || null\n this.name = name || ''\n this.theme = theme\n this.notifyListeners()\n return true\n }\n\n getNextTheme(\n opts: { themes?: Themes; name?: string | null; componentName?: string | null } = {},\n props?: any\n ) {\n const { themes = getThemes(), name, componentName } = opts\n\n if (!name) {\n if (componentName) {\n // allow for _Card_Button or just _Button\n const names = [\n `${this.name}_${componentName}`,\n `${withoutComponentName(this.name)}_${componentName}`,\n ]\n for (const name of names) {\n if (name in themes) {\n return { name, theme: themes[name], className: this.#getClassName(name) }\n }\n }\n }\n return {\n name: this.name,\n theme: this.theme,\n }\n }\n\n let nextName = name || this.name || ''\n let parentName = this.fullName\n\n while (true) {\n if (nextName in themes) {\n break\n }\n nextName = `${parentName}_${name}`\n if (nextName in themes) {\n break\n }\n if (!parentName.includes(THEME_NAME_SEPARATOR)) {\n // not found!\n console.warn('theme not found', name)\n break\n }\n // go up one\n parentName = parentName.slice(0, parentName.lastIndexOf(THEME_NAME_SEPARATOR))\n }\n\n if (componentName) {\n // allow for _Card_Button or just _Button\n const names = [\n `${nextName}_${componentName}`,\n `${withoutComponentName(nextName)}_${componentName}`,\n ]\n for (const name of names) {\n if (name in themes) {\n nextName = name\n }\n }\n }\n\n let theme = themes[nextName]\n if (!theme) {\n theme = themes[`light_${nextName}`]\n }\n\n if (process.env.NODE_ENV === 'development' && props && props['debug']) {\n console.log('getNextTheme', { name: opts.name, nextName, parentName })\n }\n\n return {\n name: nextName,\n theme,\n className: this.#getClassName(nextName),\n }\n }\n\n #getClassName(name: string) {\n return `${THEME_CLASSNAME_PREFIX}${name} tui_theme`.replace('light_', '').replace('dark_', '')\n }\n\n track(uuid: any, keys: Set<string>) {\n if (!this.name) return\n this.keys.set(uuid, keys)\n }\n\n notifyListeners() {\n if (!this.name) {\n this.keys.clear()\n }\n for (const [uuid, keys] of this.keys.entries()) {\n if (keys.size) {\n this.listeners.get(uuid)?.()\n }\n }\n this.themeListeners.forEach((cb) => cb(this.name, this))\n }\n\n onChangeTheme(cb: ThemeListener) {\n this.themeListeners.add(cb)\n return () => {\n this.themeListeners.delete(cb)\n }\n }\n\n onUpdate(uuid: any, cb: Function) {\n this.listeners.set(uuid, cb)\n return () => {\n this.listeners.delete(uuid)\n this.keys.delete(uuid)\n }\n }\n}\n\nexport const ThemeManagerContext = createContext<ThemeManager | null>(null)\nexport const emptyManager = new ThemeManager()\n\nconst withoutComponentName = (name: string) => name.replace(/\\_[A-Z][a-z]+$/, '')\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/conf.js
CHANGED
package/dist/esm/conf.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/conf.ts"],
|
|
4
|
-
"sourcesContent": ["import { Tamagui } from './Tamagui'\nimport { ConfigListener, TamaguiInternalConfig } from './types'\n\nlet conf: TamaguiInternalConfig | null\n\nexport const setConfig = (next: TamaguiInternalConfig) => {\n conf = next\n if (configListeners.size) {\n configListeners.forEach((cb) => cb(conf!))\n configListeners.clear()\n }\n}\n\nexport const getHasConfigured = () => !!conf\nexport const getConfig = () => conf!\nexport const getTokens = () => conf!.tokensParsed\nexport const getThemes = () => conf!.themes\n\nexport const configListeners = new Set<ConfigListener>()\n\nexport const onConfiguredOnce = (cb: ConfigListener) => {\n if (conf) {\n cb(conf)\n } else {\n configListeners.add(cb)\n }\n\n if (!globalThis['Tamagui']) {\n
|
|
5
|
-
"mappings": ";;AAAA;AAGA,IAAI;AAEG,MAAM,YAAY,wBAAC,SAAgC;AACxD,SAAO;AACP,MAAI,gBAAgB,MAAM;AACxB,oBAAgB,QAAQ,CAAC,OAAO,GAAG,IAAK,CAAC;AACzC,oBAAgB,MAAM;AAAA,EACxB;AACF,GANyB;AAQlB,MAAM,mBAAmB,6BAAM,CAAC,CAAC,MAAR;AACzB,MAAM,YAAY,6BAAM,MAAN;AAClB,MAAM,YAAY,6BAAM,KAAM,cAAZ;AAClB,MAAM,YAAY,6BAAM,KAAM,QAAZ;AAElB,MAAM,kBAAkB,oBAAI,IAAoB;AAEhD,MAAM,mBAAmB,wBAAC,OAAuB;AACtD,MAAI,MAAM;AACR,OAAG,
|
|
4
|
+
"sourcesContent": ["import { Tamagui } from './Tamagui'\nimport { ConfigListener, TamaguiInternalConfig } from './types'\n\nlet conf: TamaguiInternalConfig | null\n\nexport const setConfig = (next: TamaguiInternalConfig) => {\n conf = next\n if (configListeners.size) {\n configListeners.forEach((cb) => cb(conf!))\n configListeners.clear()\n }\n}\n\nexport const getHasConfigured = () => !!conf\nexport const getConfig = () => conf!\nexport const getTokens = () => conf!.tokensParsed\nexport const getThemes = () => conf!.themes\n\nexport const configListeners = new Set<ConfigListener>()\n\nexport const onConfiguredOnce = (cb: ConfigListener) => {\n if (conf) {\n cb(conf!)\n } else {\n configListeners.add(cb)\n }\n\n if (!globalThis['Tamagui']) {\n globalThis['Tamagui'] = Tamagui\n }\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAGA,IAAI;AAEG,MAAM,YAAY,wBAAC,SAAgC;AACxD,SAAO;AACP,MAAI,gBAAgB,MAAM;AACxB,oBAAgB,QAAQ,CAAC,OAAO,GAAG,IAAK,CAAC;AACzC,oBAAgB,MAAM;AAAA,EACxB;AACF,GANyB;AAQlB,MAAM,mBAAmB,6BAAM,CAAC,CAAC,MAAR;AACzB,MAAM,YAAY,6BAAM,MAAN;AAClB,MAAM,YAAY,6BAAM,KAAM,cAAZ;AAClB,MAAM,YAAY,6BAAM,KAAM,QAAZ;AAElB,MAAM,kBAAkB,oBAAI,IAAoB;AAEhD,MAAM,mBAAmB,wBAAC,OAAuB;AACtD,MAAI,MAAM;AACR,OAAG,IAAK;AAAA,EACV,OAAO;AACL,oBAAgB,IAAI,EAAE;AAAA,EACxB;AAEA,MAAI,CAAC,WAAW,YAAY;AAC1B,eAAW,aAAa;AAAA,EAC1B;AACF,GAVgC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -5,6 +5,7 @@ const isAndroid = ((_a = Platform) == null ? void 0 : _a.OS) === "android";
|
|
|
5
5
|
const isIOS = ((_b = Platform) == null ? void 0 : _b.OS) === "ios";
|
|
6
6
|
const isWeb = process.env.TAMAGUI_TARGET !== "native" && (process.env.TAMAGUI_TARGET === "web" || ((_c = Platform) == null ? void 0 : _c.OS) === "web");
|
|
7
7
|
const isSSR = isWeb && typeof window === "undefined";
|
|
8
|
+
const isClient = isWeb && typeof window !== "undefined";
|
|
8
9
|
const useIsomorphicLayoutEffect = isSSR ? useEffect : useLayoutEffect;
|
|
9
10
|
const isChrome = typeof navigator !== "undefined" && /Chrome/.test(navigator.userAgent || "");
|
|
10
11
|
const supportsTouchWeb = typeof window !== "undefined" && "ontouchstart" in window;
|
|
@@ -13,6 +14,7 @@ const isWebIOS = isWeb && typeof navigator !== "undefined" && (/iPad|iPhone|iPod
|
|
|
13
14
|
export {
|
|
14
15
|
isAndroid,
|
|
15
16
|
isChrome,
|
|
17
|
+
isClient,
|
|
16
18
|
isIOS,
|
|
17
19
|
isSSR,
|
|
18
20
|
isTouchDevice,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/constants/platform.ts"],
|
|
4
|
-
"sourcesContent": ["import { useEffect, useLayoutEffect } from 'react'\nimport { Platform } from 'react-native'\n\nexport const isAndroid = Platform?.OS === 'android'\nexport const isIOS = Platform?.OS === 'ios'\n\nexport const isWeb =\n process.env.TAMAGUI_TARGET !== 'native' &&\n (process.env.TAMAGUI_TARGET === 'web' || Platform?.OS === 'web')\n\nexport const isSSR = isWeb && typeof window === 'undefined'\nexport const useIsomorphicLayoutEffect = isSSR ? useEffect : useLayoutEffect\nexport const isChrome = typeof navigator !== 'undefined' && /Chrome/.test(navigator.userAgent || '')\nexport const supportsTouchWeb = typeof window !== 'undefined' && 'ontouchstart' in window\nexport const isTouchDevice = !isWeb || supportsTouchWeb\nexport const isWebIOS =\n isWeb &&\n typeof navigator !== 'undefined' &&\n (/iPad|iPhone|iPod/.test(navigator.platform) ||\n (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) &&\n !window['MSStream']\n"],
|
|
5
|
-
"mappings": "AAAA;AAAA;AACA;AAEO,MAAM,YAAY,uCAAU,QAAO;AACnC,MAAM,QAAQ,uCAAU,QAAO;AAE/B,MAAM,QACX,QAAQ,IAAI,mBAAmB,YAC9B,SAAQ,IAAI,mBAAmB,SAAS,uCAAU,QAAO;AAErD,MAAM,QAAQ,SAAS,OAAO,WAAW;AACzC,MAAM,4BAA4B,QAAQ,YAAY;AACtD,MAAM,WAAW,OAAO,cAAc,eAAe,SAAS,KAAK,UAAU,aAAa,EAAE;AAC5F,MAAM,mBAAmB,OAAO,WAAW,eAAe,kBAAkB;AAC5E,MAAM,gBAAgB,CAAC,SAAS;AAChC,MAAM,WACX,SACA,OAAO,cAAc,eACpB,oBAAmB,KAAK,UAAU,QAAQ,KACxC,UAAU,aAAa,cAAc,UAAU,iBAAiB,MACnE,CAAC,OAAO;",
|
|
4
|
+
"sourcesContent": ["import { useEffect, useLayoutEffect } from 'react'\nimport { Platform } from 'react-native'\n\nexport const isAndroid = Platform?.OS === 'android'\nexport const isIOS = Platform?.OS === 'ios'\n\nexport const isWeb =\n process.env.TAMAGUI_TARGET !== 'native' &&\n (process.env.TAMAGUI_TARGET === 'web' || Platform?.OS === 'web')\n\nexport const isSSR = isWeb && typeof window === 'undefined'\nexport const isClient = isWeb && typeof window !== 'undefined'\nexport const useIsomorphicLayoutEffect = isSSR ? useEffect : useLayoutEffect\nexport const isChrome = typeof navigator !== 'undefined' && /Chrome/.test(navigator.userAgent || '')\nexport const supportsTouchWeb = typeof window !== 'undefined' && 'ontouchstart' in window\nexport const isTouchDevice = !isWeb || supportsTouchWeb\nexport const isWebIOS =\n isWeb &&\n typeof navigator !== 'undefined' &&\n (/iPad|iPhone|iPod/.test(navigator.platform) ||\n (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) &&\n !window['MSStream']\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA;AACA;AAEO,MAAM,YAAY,uCAAU,QAAO;AACnC,MAAM,QAAQ,uCAAU,QAAO;AAE/B,MAAM,QACX,QAAQ,IAAI,mBAAmB,YAC9B,SAAQ,IAAI,mBAAmB,SAAS,uCAAU,QAAO;AAErD,MAAM,QAAQ,SAAS,OAAO,WAAW;AACzC,MAAM,WAAW,SAAS,OAAO,WAAW;AAC5C,MAAM,4BAA4B,QAAQ,YAAY;AACtD,MAAM,WAAW,OAAO,cAAc,eAAe,SAAS,KAAK,UAAU,aAAa,EAAE;AAC5F,MAAM,mBAAmB,OAAO,WAAW,eAAe,kBAAkB;AAC5E,MAAM,gBAAgB,CAAC,SAAS;AAChC,MAAM,WACX,SACA,OAAO,cAAc,eACpB,oBAAmB,KAAK,UAAU,QAAQ,KACxC,UAAU,aAAa,cAAc,UAAU,iBAAiB,MACnE,CAAC,OAAO;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -10,26 +10,34 @@ import React, {
|
|
|
10
10
|
memo,
|
|
11
11
|
useCallback,
|
|
12
12
|
useContext,
|
|
13
|
-
useEffect,
|
|
14
13
|
useRef,
|
|
15
14
|
useState
|
|
16
15
|
} from "react";
|
|
17
16
|
import { StyleSheet, Text, View } from "react-native";
|
|
18
17
|
import { onConfiguredOnce } from "./conf";
|
|
19
18
|
import { stackDefaultStyles } from "./constants/constants";
|
|
20
|
-
import { isAndroid, isTouchDevice, isWeb } from "./constants/platform";
|
|
19
|
+
import { isAndroid, isTouchDevice, isWeb, useIsomorphicLayoutEffect } from "./constants/platform";
|
|
21
20
|
import { rnw } from "./constants/rnw";
|
|
22
21
|
import { isVariable } from "./createVariable";
|
|
23
|
-
import {
|
|
22
|
+
import { createShallowUpdate } from "./helpers/createShallowUpdate";
|
|
24
23
|
import { extendStaticConfig, parseStaticConfig } from "./helpers/extendStaticConfig";
|
|
25
|
-
import {
|
|
26
|
-
|
|
27
|
-
} from "./helpers/
|
|
24
|
+
import { getSplitStyles } from "./helpers/getSplitStyles";
|
|
25
|
+
import { getAllSelectors } from "./helpers/insertStyleRule";
|
|
26
|
+
import { proxyThemeVariables } from "./helpers/proxyThemeVariables";
|
|
28
27
|
import { wrapThemeManagerContext } from "./helpers/wrapThemeManagerContext";
|
|
29
28
|
import { useFeatures } from "./hooks/useFeatures";
|
|
30
29
|
import { usePressable } from "./hooks/usePressable";
|
|
31
30
|
import { getThemeManagerIfChanged, useTheme } from "./hooks/useTheme";
|
|
32
31
|
import { TextAncestorContext } from "./views/TextAncestorContext";
|
|
32
|
+
React["keep"];
|
|
33
|
+
const defaultComponentState = {
|
|
34
|
+
hover: false,
|
|
35
|
+
press: false,
|
|
36
|
+
pressIn: false,
|
|
37
|
+
focus: false,
|
|
38
|
+
mounted: false,
|
|
39
|
+
animation: null
|
|
40
|
+
};
|
|
33
41
|
const mouseUps = /* @__PURE__ */ new Set();
|
|
34
42
|
if (typeof document !== "undefined") {
|
|
35
43
|
document.addEventListener("mouseup", () => {
|
|
@@ -37,77 +45,73 @@ if (typeof document !== "undefined") {
|
|
|
37
45
|
mouseUps.clear();
|
|
38
46
|
});
|
|
39
47
|
}
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
for (const key in next) {
|
|
44
|
-
if (prev[key] !== next[key]) {
|
|
45
|
-
return { ...prev, ...next };
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return prev;
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
__name(createShallowUpdate, "createShallowUpdate");
|
|
53
|
-
function createComponent(configIn) {
|
|
54
|
-
let staticConfig;
|
|
55
|
-
if ("parsed" in configIn) {
|
|
56
|
-
staticConfig = configIn;
|
|
57
|
-
} else {
|
|
58
|
-
staticConfig = parseStaticConfig(configIn);
|
|
48
|
+
function mergeShorthands({ defaultProps }, { shorthands }) {
|
|
49
|
+
for (const key in defaultProps) {
|
|
50
|
+
defaultProps[shorthands[key] || key] = defaultProps[key];
|
|
59
51
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
52
|
+
}
|
|
53
|
+
__name(mergeShorthands, "mergeShorthands");
|
|
54
|
+
let initialTheme;
|
|
55
|
+
function createComponent(configIn, ParentComponent) {
|
|
56
|
+
const staticConfig = (() => {
|
|
57
|
+
const config = extendStaticConfig(configIn, ParentComponent);
|
|
58
|
+
if ("parsed" in config) {
|
|
59
|
+
return config;
|
|
60
|
+
} else {
|
|
61
|
+
return parseStaticConfig(config);
|
|
62
|
+
}
|
|
63
|
+
})();
|
|
64
|
+
const componentClassName = `is_${staticConfig.componentName}`;
|
|
63
65
|
let tamaguiConfig;
|
|
64
66
|
let AnimatedText;
|
|
65
67
|
let AnimatedView;
|
|
66
68
|
let avoidClasses = true;
|
|
67
|
-
let defaultPseudos = {};
|
|
68
69
|
let defaultNativeStyle;
|
|
69
|
-
let defaultNativeStyleSheet
|
|
70
|
-
let
|
|
71
|
-
let initialTheme;
|
|
72
|
-
let splitStyleResult = null;
|
|
70
|
+
let defaultNativeStyleSheet;
|
|
71
|
+
let initialSplitStyles;
|
|
73
72
|
function addPseudoToStyles(styles, name, pseudos) {
|
|
74
73
|
const pseudoStyle = pseudos[name];
|
|
74
|
+
const shouldNestObject = isWeb && name !== "enterStyle" && name !== "exitStyle";
|
|
75
75
|
if (pseudoStyle) {
|
|
76
|
-
styles.push(
|
|
76
|
+
styles.push(shouldNestObject ? { [name]: pseudoStyle } : pseudoStyle);
|
|
77
77
|
}
|
|
78
|
-
const defaultPseudoStyle =
|
|
78
|
+
const defaultPseudoStyle = initialSplitStyles.pseudos[name];
|
|
79
79
|
if (defaultPseudoStyle) {
|
|
80
|
-
styles.push(
|
|
80
|
+
styles.push(shouldNestObject ? { [name]: defaultPseudoStyle } : defaultPseudoStyle);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
__name(addPseudoToStyles, "addPseudoToStyles");
|
|
84
84
|
const component = forwardRef((props, forwardedRef) => {
|
|
85
85
|
var _a, _b, _c, _d;
|
|
86
|
+
const { Component, componentName, isText, isZStack } = staticConfig;
|
|
86
87
|
if (process.env.NODE_ENV === "development") {
|
|
87
88
|
if (props["debug"]) {
|
|
88
|
-
console.warn(componentName || (Component == null ? void 0 : Component.displayName) || (Component == null ? void 0 : Component.name) || "[Unnamed Component]", "
|
|
89
|
+
console.warn(staticConfig.componentName || (Component == null ? void 0 : Component.displayName) || (Component == null ? void 0 : Component.name) || "[Unnamed Component]", "debug on");
|
|
90
|
+
console.log("props in:", props);
|
|
89
91
|
if (props["debug"] === "break")
|
|
90
92
|
debugger;
|
|
91
93
|
}
|
|
92
94
|
}
|
|
93
95
|
const forceUpdate = useForceUpdate();
|
|
94
|
-
const theme = useTheme(props.theme, componentName, props, forceUpdate);
|
|
96
|
+
const theme = useTheme(props.theme, staticConfig.componentName, props, forceUpdate);
|
|
95
97
|
const [state, set_] = useState(defaultComponentState);
|
|
96
98
|
const setStateShallow = createShallowUpdate(set_);
|
|
97
|
-
const shouldAvoidClasses = !!(
|
|
98
|
-
const
|
|
99
|
-
const { viewProps: viewPropsIn, pseudos, medias, style, classNames } =
|
|
99
|
+
const shouldAvoidClasses = !!(props.animation && avoidClasses);
|
|
100
|
+
const splitStyles = getSplitStyles(props, staticConfig, theme, shouldAvoidClasses ? { ...state, noClassNames: true, resolveVariablesAs: "value" } : state, shouldAvoidClasses ? null : initialSplitStyles.classNames);
|
|
101
|
+
const { viewProps: viewPropsIn, pseudos, medias, style, classNames } = splitStyles;
|
|
100
102
|
const useAnimations = (_a = tamaguiConfig.animations) == null ? void 0 : _a.useAnimations;
|
|
101
103
|
const isAnimated = !!(useAnimations && props.animation);
|
|
102
104
|
const hasEnterStyle = !!props.enterStyle;
|
|
103
|
-
const styleWithPseudos = props.animation ? merge({ ...defaultNativeStyle, ...style }, state.hover && pseudos.hoverStyle, state.press && pseudos.pressStyle, state.focus && pseudos.focusStyle, hasEnterStyle && !state.mounted && pseudos.enterStyle, ...Object.values(medias)) : null;
|
|
104
105
|
const features = useFeatures(props, {
|
|
105
106
|
forceUpdate,
|
|
106
107
|
setStateShallow,
|
|
107
108
|
useAnimations,
|
|
108
109
|
state,
|
|
109
|
-
style:
|
|
110
|
-
pseudos
|
|
110
|
+
style: props.animation ? { ...defaultNativeStyle, ...style } : null,
|
|
111
|
+
pseudos,
|
|
112
|
+
staticConfig,
|
|
113
|
+
theme,
|
|
114
|
+
onDidAnimate: props.onDidAnimate
|
|
111
115
|
});
|
|
112
116
|
const {
|
|
113
117
|
tag,
|
|
@@ -146,6 +150,7 @@ function createComponent(configIn) {
|
|
|
146
150
|
accessibilityRole,
|
|
147
151
|
collapsable,
|
|
148
152
|
focusable,
|
|
153
|
+
onClick,
|
|
149
154
|
theme: _themeProp,
|
|
150
155
|
defaultVariants,
|
|
151
156
|
onLayout,
|
|
@@ -167,8 +172,8 @@ function createComponent(configIn) {
|
|
|
167
172
|
isMounted: true
|
|
168
173
|
};
|
|
169
174
|
}
|
|
170
|
-
|
|
171
|
-
if (hasEnterStyle) {
|
|
175
|
+
useIsomorphicLayoutEffect(() => {
|
|
176
|
+
if (typeof window !== "undefined" && (hasEnterStyle || props.animation)) {
|
|
172
177
|
setStateShallow({
|
|
173
178
|
mounted: true
|
|
174
179
|
});
|
|
@@ -178,7 +183,7 @@ function createComponent(configIn) {
|
|
|
178
183
|
mouseUps.delete(unPress);
|
|
179
184
|
internal.current.isMounted = false;
|
|
180
185
|
};
|
|
181
|
-
}, []);
|
|
186
|
+
}, [hasEnterStyle, props.animation]);
|
|
182
187
|
if (nativeID) {
|
|
183
188
|
viewProps.id = nativeID;
|
|
184
189
|
}
|
|
@@ -236,6 +241,7 @@ function createComponent(configIn) {
|
|
|
236
241
|
medias
|
|
237
242
|
];
|
|
238
243
|
if (!animationStyles) {
|
|
244
|
+
!state.mounted && addPseudoToStyles(styles, "enterStyle", pseudos);
|
|
239
245
|
state.hover && addPseudoToStyles(styles, "hoverStyle", pseudos);
|
|
240
246
|
state.focus && addPseudoToStyles(styles, "focusStyle", pseudos);
|
|
241
247
|
state.press && addPseudoToStyles(styles, "pressStyle", pseudos);
|
|
@@ -254,7 +260,7 @@ function createComponent(configIn) {
|
|
|
254
260
|
const className = classList.join(" ");
|
|
255
261
|
if (process.env.NODE_ENV === "development") {
|
|
256
262
|
if (props["debug"]) {
|
|
257
|
-
console.log(" \xBB className", { isStringElement, pseudos, state,
|
|
263
|
+
console.log(" \xBB className", { isStringElement, pseudos, state, classNames, propsClassName: props.className, style, classList, className: className.trim().split(" "), themeClassName: theme.className, values: Object.fromEntries(Object.entries(classNames).map(([k, v]) => [v, getAllSelectors()[v]])) });
|
|
258
264
|
}
|
|
259
265
|
}
|
|
260
266
|
viewProps.className = className;
|
|
@@ -295,7 +301,8 @@ function createComponent(configIn) {
|
|
|
295
301
|
viewProps.ref = forwardedRef;
|
|
296
302
|
}
|
|
297
303
|
}
|
|
298
|
-
const
|
|
304
|
+
const initialPseudos = initialSplitStyles.pseudos;
|
|
305
|
+
const attachPress = !!(pseudos && pseudos.pressStyle || initialPseudos && initialPseudos.pressStyle || onPress || onPressOut || onPressIn || onClick);
|
|
299
306
|
const isHoverable = isWeb && !isTouchDevice;
|
|
300
307
|
const attachHover = isHoverable && !!(pseudos && pseudos.hoverStyle || onHoverIn || onHoverOut || onMouseEnter || onMouseLeave);
|
|
301
308
|
const pressEventKey = isStringElement ? "onClick" : "onPress";
|
|
@@ -308,7 +315,6 @@ function createComponent(configIn) {
|
|
|
308
315
|
pressIn: false
|
|
309
316
|
});
|
|
310
317
|
}, []);
|
|
311
|
-
console.log("attachHover, attachHover", attachHover, pseudos && pseudos.hoverStyle);
|
|
312
318
|
const events = shouldAttach ? {
|
|
313
319
|
...!isWeb && {
|
|
314
320
|
onPressOut: (e) => {
|
|
@@ -360,6 +366,7 @@ function createComponent(configIn) {
|
|
|
360
366
|
onPress == null ? void 0 : onPress(e);
|
|
361
367
|
unPress();
|
|
362
368
|
onPressOut == null ? void 0 : onPressOut(e);
|
|
369
|
+
onClick == null ? void 0 : onClick(e);
|
|
363
370
|
} : null
|
|
364
371
|
} : null;
|
|
365
372
|
let childEls = !children ? children : wrapThemeManagerContext(spacedChildren({
|
|
@@ -403,9 +410,9 @@ function createComponent(configIn) {
|
|
|
403
410
|
}
|
|
404
411
|
}
|
|
405
412
|
content = createElement(ViewComponent, viewProps, childEls);
|
|
406
|
-
console.log("should", attachHover);
|
|
407
413
|
if (isWeb && events && attachHover) {
|
|
408
414
|
content = /* @__PURE__ */ React.createElement("span", {
|
|
415
|
+
className: "tui_Hoverable",
|
|
409
416
|
style: {
|
|
410
417
|
display: "contents"
|
|
411
418
|
},
|
|
@@ -416,7 +423,7 @@ function createComponent(configIn) {
|
|
|
416
423
|
if (process.env.NODE_ENV === "development") {
|
|
417
424
|
if (props["debug"]) {
|
|
418
425
|
viewProps["debug"] = true;
|
|
419
|
-
console.log(" \xBB ", { propsIn: { ...props }, propsOut: { ...viewProps }, animationStyles, isStringElement, classNamesIn: (_c = props.className) == null ? void 0 : _c.split(" "), classNamesOut: (_d = viewProps.className) == null ? void 0 : _d.split(" "), pressProps, events, shouldAttach, ViewComponent, viewProps,
|
|
426
|
+
console.log(" \xBB ", { propsIn: { ...props }, propsOut: { ...viewProps }, state, splitStyles, animationStyles, isStringElement, classNamesIn: (_c = props.className) == null ? void 0 : _c.split(" "), classNamesOut: (_d = viewProps.className) == null ? void 0 : _d.split(" "), pressProps, events, shouldAttach, ViewComponent, viewProps, styles, pseudos, content, childEls, shouldAvoidClasses, avoidClasses, animation: props.animation, style, defaultNativeStyle, initialSplitStyles, ...typeof window !== "undefined" ? { theme, themeState: theme.__state, themeClassName: theme.className, staticConfig, tamaguiConfig } : null });
|
|
420
427
|
}
|
|
421
428
|
}
|
|
422
429
|
if (features.length) {
|
|
@@ -424,23 +431,28 @@ function createComponent(configIn) {
|
|
|
424
431
|
}
|
|
425
432
|
return content;
|
|
426
433
|
});
|
|
434
|
+
component.displayName = staticConfig.componentName;
|
|
427
435
|
onConfiguredOnce((conf) => {
|
|
428
436
|
var _a, _b, _c, _d;
|
|
429
|
-
|
|
437
|
+
if (process.env.IS_STATIC === "is_static") {
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
430
440
|
tamaguiConfig = conf;
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
441
|
+
mergeShorthands(staticConfig, tamaguiConfig);
|
|
442
|
+
avoidClasses = !!((_a = tamaguiConfig.animations) == null ? void 0 : _a.avoidClasses);
|
|
443
|
+
AnimatedText = (_b = tamaguiConfig.animations) == null ? void 0 : _b.Text;
|
|
444
|
+
AnimatedView = (_c = tamaguiConfig == null ? void 0 : tamaguiConfig.animations) == null ? void 0 : _c.View;
|
|
445
|
+
initialTheme = initialTheme || proxyThemeVariables(conf.themes[conf.defaultTheme || Object.keys(conf.themes)[0]]);
|
|
446
|
+
initialSplitStyles = getSplitStyles(staticConfig.defaultProps, staticConfig, initialTheme, {
|
|
436
447
|
mounted: true,
|
|
437
|
-
|
|
448
|
+
hover: false,
|
|
449
|
+
press: false,
|
|
450
|
+
pressIn: false,
|
|
451
|
+
focus: false,
|
|
452
|
+
resolveVariablesAs: "both",
|
|
453
|
+
keepVariantsAsProps: true
|
|
438
454
|
});
|
|
439
|
-
const {
|
|
440
|
-
if (isWeb) {
|
|
441
|
-
defaultsClassName = classNames;
|
|
442
|
-
}
|
|
443
|
-
defaultPseudos = pseudos;
|
|
455
|
+
const { style, viewProps } = initialSplitStyles;
|
|
444
456
|
defaultNativeStyle = {};
|
|
445
457
|
for (const key in style) {
|
|
446
458
|
const v = style[key];
|
|
@@ -449,13 +461,17 @@ function createComponent(configIn) {
|
|
|
449
461
|
defaultNativeStyleSheet = StyleSheet.create({
|
|
450
462
|
base: defaultNativeStyle
|
|
451
463
|
});
|
|
452
|
-
component.displayName = staticConfig.componentName;
|
|
453
464
|
component.defaultProps = {
|
|
454
465
|
...viewProps,
|
|
455
466
|
...component.defaultProps
|
|
456
467
|
};
|
|
457
|
-
if (process.env.NODE_ENV === "development" &&
|
|
458
|
-
|
|
468
|
+
if (process.env.NODE_ENV === "development" && ((_d = staticConfig.defaultProps) == null ? void 0 : _d.debug)) {
|
|
469
|
+
if (process.env.IS_STATIC !== "is_static") {
|
|
470
|
+
console.log(`\u{1F41B} [${staticConfig.componentName || "Component"}]`, {
|
|
471
|
+
staticConfig,
|
|
472
|
+
initialSplitStyles
|
|
473
|
+
});
|
|
474
|
+
}
|
|
459
475
|
}
|
|
460
476
|
});
|
|
461
477
|
let res = component;
|
|
@@ -463,25 +479,30 @@ function createComponent(configIn) {
|
|
|
463
479
|
res = memo(res);
|
|
464
480
|
}
|
|
465
481
|
res["staticConfig"] = {
|
|
466
|
-
validStyles:
|
|
482
|
+
validStyles: staticConfig.validStyles || stylePropsView,
|
|
467
483
|
...staticConfig
|
|
468
484
|
};
|
|
469
|
-
|
|
470
|
-
|
|
485
|
+
if (process.env.NODE_ENV === "development") {
|
|
486
|
+
res["whyDidYouRender"] = true;
|
|
487
|
+
}
|
|
488
|
+
res["extractable"] = (Component, conf) => {
|
|
489
|
+
Component["staticConfig"] = extendStaticConfig({
|
|
490
|
+
Component,
|
|
471
491
|
...conf,
|
|
472
492
|
neverFlatten: true,
|
|
473
493
|
defaultProps: {
|
|
474
|
-
...
|
|
494
|
+
...Component.defaultProps,
|
|
475
495
|
...conf == null ? void 0 : conf.defaultProps
|
|
476
496
|
}
|
|
477
|
-
});
|
|
478
|
-
return
|
|
497
|
+
}, res);
|
|
498
|
+
return Component;
|
|
479
499
|
};
|
|
480
500
|
return res;
|
|
481
501
|
}
|
|
482
502
|
__name(createComponent, "createComponent");
|
|
483
503
|
const Spacer = createComponent({
|
|
484
504
|
memo: true,
|
|
505
|
+
componentName: "Spacer",
|
|
485
506
|
defaultProps: {
|
|
486
507
|
...stackDefaultStyles,
|
|
487
508
|
size: true
|
|
@@ -561,49 +582,20 @@ function spacedChildren({
|
|
|
561
582
|
return next;
|
|
562
583
|
}
|
|
563
584
|
__name(spacedChildren, "spacedChildren");
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
continue;
|
|
573
|
-
for (const key in cur) {
|
|
574
|
-
const val = cur[key];
|
|
575
|
-
if (key !== "transform") {
|
|
576
|
-
if (!(key in res)) {
|
|
577
|
-
res[key] = val;
|
|
578
|
-
}
|
|
579
|
-
continue;
|
|
580
|
-
}
|
|
581
|
-
if (!res.transform) {
|
|
582
|
-
res.transform = val;
|
|
583
|
-
continue;
|
|
584
|
-
}
|
|
585
|
-
for (const t of val) {
|
|
586
|
-
const tkey = Object.keys(t)[0];
|
|
587
|
-
if (res.transform.find((existing) => tkey in existing)) {
|
|
588
|
-
continue;
|
|
589
|
-
}
|
|
590
|
-
res.transform.push(t);
|
|
591
|
-
}
|
|
585
|
+
function AbsoluteFill(props) {
|
|
586
|
+
return isWeb ? /* @__PURE__ */ React.createElement("div", {
|
|
587
|
+
style: {
|
|
588
|
+
position: "absolute",
|
|
589
|
+
top: 0,
|
|
590
|
+
left: 0,
|
|
591
|
+
right: 0,
|
|
592
|
+
bottom: 0
|
|
592
593
|
}
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
},
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
position: "absolute",
|
|
599
|
-
top: 0,
|
|
600
|
-
left: 0,
|
|
601
|
-
right: 0,
|
|
602
|
-
bottom: 0
|
|
603
|
-
}
|
|
604
|
-
}, props.children) : /* @__PURE__ */ React.createElement(View, {
|
|
605
|
-
style: StyleSheet.absoluteFill
|
|
606
|
-
}, props.child), "AbsoluteFill");
|
|
594
|
+
}, props.children) : /* @__PURE__ */ React.createElement(View, {
|
|
595
|
+
style: StyleSheet.absoluteFill
|
|
596
|
+
}, props.child);
|
|
597
|
+
}
|
|
598
|
+
__name(AbsoluteFill, "AbsoluteFill");
|
|
607
599
|
export {
|
|
608
600
|
AbsoluteFill,
|
|
609
601
|
Spacer,
|