@tamagui/core 1.0.0-beta.149 → 1.0.0-beta.15
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/README.md +1 -0
- package/dist/cjs/Tamagui.js +13 -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 +175 -96
- 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 +48 -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/helpers/RNComponents.js +4 -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 -2
- package/dist/cjs/helpers/createMediaStyle.js.map +2 -2
- package/dist/cjs/helpers/createPropMapper.js +53 -22
- package/dist/cjs/helpers/createPropMapper.js.map +2 -2
- package/dist/cjs/helpers/createShallowUpdate.js +4 -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 +10 -9
- package/dist/cjs/helpers/fixNativeShadow.native.js.map +2 -2
- package/dist/cjs/helpers/getButtonSize.js +45 -0
- package/dist/cjs/helpers/getButtonSize.js.map +7 -0
- 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 +137 -55
- package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
- package/dist/cjs/helpers/getStylesAtomic.js +20 -3
- package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
- package/dist/cjs/helpers/getStylesAtomic.native.js +4 -0
- package/dist/cjs/helpers/getTextSize.js +56 -0
- package/dist/cjs/helpers/getTextSize.js.map +7 -0
- package/dist/cjs/helpers/insertStyleRule.js +42 -27
- 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 +4 -0
- package/dist/cjs/hooks/useId.js +59 -0
- package/dist/cjs/hooks/useId.js.map +7 -0
- package/dist/cjs/hooks/useIsMounted.js +4 -0
- package/dist/cjs/hooks/useIsTouchDevice.js +8 -4
- package/dist/cjs/hooks/useIsTouchDevice.js.map +2 -2
- package/dist/cjs/hooks/useMedia.js +14 -0
- package/dist/cjs/hooks/useMedia.js.map +2 -2
- package/dist/cjs/hooks/usePressable.js +4 -0
- package/dist/cjs/hooks/usePrevious.js +1 -0
- package/dist/cjs/{createShallowUpdate.js.map → hooks/usePrevious.js.map} +0 -0
- package/dist/cjs/hooks/useTheme.js +30 -16
- package/dist/cjs/hooks/useTheme.js.map +2 -2
- package/dist/cjs/hooks/useUnmountEffect.js +4 -0
- package/dist/cjs/index.js +24 -6
- 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 +11 -5
- package/dist/cjs/styled.js.map +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/views/Slot.js +134 -0
- package/dist/cjs/views/Slot.js.map +7 -0
- package/dist/cjs/views/Stack.js +4 -0
- package/dist/cjs/views/Text.js +13 -14
- package/dist/cjs/views/Text.js.map +2 -2
- package/dist/cjs/views/TextAncestorContext.js +6 -0
- package/dist/cjs/views/Theme.js +7 -3
- package/dist/cjs/views/Theme.js.map +2 -2
- package/dist/cjs/views/ThemeInverse.js +10 -1
- package/dist/cjs/views/ThemeInverse.js.map +2 -2
- 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 +8 -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 +170 -104
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/createTamagui.js +45 -28
- 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/helpers/addStylesUsingClassname.js +4 -1
- package/dist/esm/helpers/addStylesUsingClassname.js.map +2 -2
- package/dist/esm/helpers/createMediaStyle.js +0 -2
- package/dist/esm/helpers/createMediaStyle.js.map +2 -2
- package/dist/esm/helpers/createPropMapper.js +50 -22
- package/dist/esm/helpers/createPropMapper.js.map +2 -2
- package/dist/esm/helpers/extendStaticConfig.js +9 -6
- package/dist/esm/helpers/extendStaticConfig.js.map +2 -2
- package/dist/esm/helpers/fixNativeShadow.native.js +7 -9
- package/dist/esm/helpers/fixNativeShadow.native.js.map +2 -2
- package/dist/esm/helpers/getButtonSize.js +24 -0
- package/dist/esm/helpers/getButtonSize.js.map +7 -0
- package/dist/esm/helpers/getSize.js +13 -0
- package/dist/esm/helpers/getSize.js.map +7 -0
- package/dist/esm/helpers/getSplitStyles.js +136 -57
- package/dist/esm/helpers/getSplitStyles.js.map +2 -2
- package/dist/esm/helpers/getStylesAtomic.js +15 -3
- package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
- package/dist/esm/helpers/getTextSize.js +34 -0
- package/dist/esm/helpers/getTextSize.js.map +7 -0
- package/dist/esm/helpers/insertStyleRule.js +32 -27
- 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/useId.js +35 -0
- package/dist/esm/hooks/useId.js.map +7 -0
- package/dist/esm/hooks/useIsTouchDevice.js +6 -6
- package/dist/esm/hooks/useIsTouchDevice.js.map +2 -2
- package/dist/esm/hooks/useMedia.js +3 -0
- package/dist/esm/hooks/useMedia.js.map +2 -2
- package/dist/esm/hooks/usePrevious.js +1 -0
- package/dist/esm/{createShallowUpdate.js.map → hooks/usePrevious.js.map} +0 -0
- package/dist/esm/hooks/useTheme.js +22 -16
- package/dist/esm/hooks/useTheme.js.map +2 -2
- package/dist/esm/index.js +13 -6
- 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 +7 -5
- package/dist/esm/styled.js.map +2 -2
- package/dist/esm/views/Slot.js +82 -0
- package/dist/esm/views/Slot.js.map +7 -0
- package/dist/esm/views/Text.js +9 -14
- package/dist/esm/views/Text.js.map +2 -2
- package/dist/esm/views/Theme.js +3 -3
- package/dist/esm/views/Theme.js.map +2 -2
- package/dist/esm/views/ThemeInverse.js +6 -2
- package/dist/esm/views/ThemeInverse.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 +8 -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 +161 -100
- package/dist/jsx/createTamagui.js +45 -28
- package/dist/jsx/createTokens.js +2 -6
- package/dist/jsx/createVariable.js +8 -2
- package/dist/jsx/helpers/addStylesUsingClassname.js +4 -1
- package/dist/jsx/helpers/createMediaStyle.js +0 -2
- package/dist/jsx/helpers/createPropMapper.js +50 -22
- package/dist/jsx/helpers/extendStaticConfig.js +9 -6
- package/dist/jsx/helpers/fixNativeShadow.native.js +7 -9
- package/dist/jsx/helpers/getButtonSize.js +23 -0
- package/dist/jsx/helpers/getSize.js +12 -0
- package/dist/jsx/helpers/getSplitStyles.js +136 -57
- package/dist/jsx/helpers/getStylesAtomic.js +15 -3
- package/dist/jsx/helpers/getTextSize.js +33 -0
- package/dist/jsx/helpers/insertStyleRule.js +32 -27
- 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/useId.js +34 -0
- package/dist/jsx/hooks/useIsTouchDevice.js +6 -6
- package/dist/jsx/hooks/useMedia.js +3 -0
- package/dist/jsx/{createShallowUpdate.js → hooks/usePrevious.js} +0 -0
- package/dist/jsx/hooks/useTheme.js +22 -16
- package/dist/jsx/index.js +13 -6
- package/dist/jsx/static.js +3 -0
- package/dist/jsx/styled.js +7 -5
- package/dist/jsx/views/Slot.js +75 -0
- package/dist/jsx/views/Text.js +9 -14
- package/dist/jsx/views/Theme.js +4 -4
- package/dist/jsx/views/ThemeInverse.js +6 -1
- package/dist/jsx/views/ThemeProvider.js +2 -2
- package/package.json +8 -6
- package/types/Tamagui.d.ts +16 -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/createTamagui.d.ts +3 -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/fixNativeShadow.native.d.ts +2 -1
- package/types/helpers/fixNativeShadow.native.d.ts.map +1 -1
- package/types/helpers/getButtonSize.d.ts +8 -0
- package/types/helpers/getButtonSize.d.ts.map +1 -0
- package/types/helpers/getSize.d.ts +3 -0
- package/types/helpers/getSize.d.ts.map +1 -0
- package/types/helpers/getSplitStyles.d.ts +14 -6
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/helpers/getStylesAtomic.d.ts.map +1 -1
- package/types/helpers/getTextSize.d.ts +3 -0
- package/types/helpers/getTextSize.d.ts.map +1 -0
- 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/useId.d.ts +9 -0
- package/types/hooks/useId.d.ts.map +1 -0
- package/types/hooks/useMedia.d.ts +2 -6
- package/types/hooks/useMedia.d.ts.map +1 -1
- package/types/hooks/usePrevious.d.ts +1 -0
- package/types/hooks/usePrevious.d.ts.map +1 -0
- package/types/hooks/useTheme.d.ts +1 -1
- package/types/hooks/useTheme.d.ts.map +1 -1
- package/types/index.d.ts +11 -6
- 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 +86 -46
- package/types/types.d.ts.map +1 -1
- package/types/views/Slot.d.ts +9 -0
- package/types/views/Slot.d.ts.map +1 -0
- package/types/views/Text.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/ThemeInverse.d.ts.map +1 -1
- package/types/views/ThemeProvider.d.ts +1 -0
- package/types/views/ThemeProvider.d.ts.map +1 -1
- package/LICENSE +0 -21
- package/dist/cjs/constants/pseudos.js.map +0 -7
- package/dist/cjs/createShallowUpdate.js +0 -1
- 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/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/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
|
@@ -13,20 +13,23 @@ import React, {
|
|
|
13
13
|
useRef,
|
|
14
14
|
useState
|
|
15
15
|
} from "react";
|
|
16
|
-
import { StyleSheet, Text, View } from "react-native";
|
|
16
|
+
import { Pressable, StyleSheet, Text, View } from "react-native";
|
|
17
|
+
import { BaseButton } from "react-native-gesture-handler";
|
|
17
18
|
import { onConfiguredOnce } from "./conf";
|
|
18
19
|
import { stackDefaultStyles } from "./constants/constants";
|
|
19
|
-
import { isAndroid,
|
|
20
|
+
import { isAndroid, isWeb, useIsomorphicLayoutEffect } from "./constants/platform";
|
|
20
21
|
import { rnw } from "./constants/rnw";
|
|
21
|
-
import { isVariable } from "./createVariable";
|
|
22
22
|
import { createShallowUpdate } from "./helpers/createShallowUpdate";
|
|
23
23
|
import { extendStaticConfig, parseStaticConfig } from "./helpers/extendStaticConfig";
|
|
24
|
-
import {
|
|
24
|
+
import { insertSplitStyles, useSplitStyles } from "./helpers/getSplitStyles";
|
|
25
25
|
import { getAllSelectors } from "./helpers/insertStyleRule";
|
|
26
|
+
import { proxyThemeVariables } from "./helpers/proxyThemeVariables";
|
|
26
27
|
import { wrapThemeManagerContext } from "./helpers/wrapThemeManagerContext";
|
|
27
28
|
import { useFeatures } from "./hooks/useFeatures";
|
|
29
|
+
import { useIsTouchDevice } from "./hooks/useIsTouchDevice";
|
|
28
30
|
import { usePressable } from "./hooks/usePressable";
|
|
29
31
|
import { getThemeManagerIfChanged, useTheme } from "./hooks/useTheme";
|
|
32
|
+
import { Slot } from "./views/Slot";
|
|
30
33
|
import { TextAncestorContext } from "./views/TextAncestorContext";
|
|
31
34
|
React["keep"];
|
|
32
35
|
const defaultComponentState = {
|
|
@@ -43,55 +46,70 @@ if (typeof document !== "undefined") {
|
|
|
43
46
|
mouseUps.forEach((x) => x());
|
|
44
47
|
mouseUps.clear();
|
|
45
48
|
});
|
|
49
|
+
document.addEventListener("touchend", () => {
|
|
50
|
+
mouseUps.forEach((x) => x());
|
|
51
|
+
mouseUps.clear();
|
|
52
|
+
});
|
|
53
|
+
document.addEventListener("touchcancel", () => {
|
|
54
|
+
mouseUps.forEach((x) => x());
|
|
55
|
+
mouseUps.clear();
|
|
56
|
+
});
|
|
46
57
|
}
|
|
47
|
-
function
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
staticConfig = configIn;
|
|
51
|
-
} else {
|
|
52
|
-
staticConfig = parseStaticConfig(configIn);
|
|
58
|
+
function mergeShorthands({ defaultProps }, { shorthands }) {
|
|
59
|
+
for (const key in defaultProps) {
|
|
60
|
+
defaultProps[shorthands[key] || key] = defaultProps[key];
|
|
53
61
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
}
|
|
63
|
+
__name(mergeShorthands, "mergeShorthands");
|
|
64
|
+
let initialTheme;
|
|
65
|
+
function createComponent(configIn, ParentComponent) {
|
|
66
|
+
const staticConfig = (() => {
|
|
67
|
+
const config = extendStaticConfig(configIn, ParentComponent);
|
|
68
|
+
if ("parsed" in config) {
|
|
69
|
+
return config;
|
|
70
|
+
} else {
|
|
71
|
+
return parseStaticConfig(config);
|
|
72
|
+
}
|
|
73
|
+
})();
|
|
74
|
+
const componentClassName = `is_${staticConfig.componentName}`;
|
|
57
75
|
let tamaguiConfig;
|
|
58
76
|
let AnimatedText;
|
|
59
77
|
let AnimatedView;
|
|
60
78
|
let avoidClasses = true;
|
|
61
|
-
let defaultPseudos = {};
|
|
62
79
|
let defaultNativeStyle;
|
|
63
|
-
let defaultNativeStyleSheet
|
|
64
|
-
let
|
|
65
|
-
let
|
|
66
|
-
let defaultSplitStyleResult = null;
|
|
80
|
+
let defaultNativeStyleSheet;
|
|
81
|
+
let tamaguiDefaultProps;
|
|
82
|
+
let initialSplitStyles;
|
|
67
83
|
function addPseudoToStyles(styles, name, pseudos) {
|
|
68
84
|
const pseudoStyle = pseudos[name];
|
|
69
85
|
const shouldNestObject = isWeb && name !== "enterStyle" && name !== "exitStyle";
|
|
70
|
-
|
|
71
|
-
styles.push(shouldNestObject ? { [name]: pseudoStyle } : pseudoStyle);
|
|
72
|
-
}
|
|
73
|
-
const defaultPseudoStyle = defaultPseudos[name];
|
|
86
|
+
const defaultPseudoStyle = initialSplitStyles.pseudos[name];
|
|
74
87
|
if (defaultPseudoStyle) {
|
|
75
88
|
styles.push(shouldNestObject ? { [name]: defaultPseudoStyle } : defaultPseudoStyle);
|
|
76
89
|
}
|
|
90
|
+
if (pseudoStyle) {
|
|
91
|
+
styles.push(shouldNestObject ? { [name]: pseudoStyle } : pseudoStyle);
|
|
92
|
+
}
|
|
77
93
|
}
|
|
78
94
|
__name(addPseudoToStyles, "addPseudoToStyles");
|
|
79
95
|
const component = forwardRef((props, forwardedRef) => {
|
|
80
96
|
var _a, _b, _c, _d;
|
|
97
|
+
props = tamaguiDefaultProps && !props.asChild ? { ...tamaguiDefaultProps, ...props } : props;
|
|
98
|
+
const { Component, componentName, isText, isZStack } = staticConfig;
|
|
81
99
|
if (process.env.NODE_ENV === "development") {
|
|
82
100
|
if (props["debug"]) {
|
|
83
|
-
console.
|
|
84
|
-
console.log("props in:", props);
|
|
101
|
+
console.log("\u26A0\uFE0F", staticConfig.componentName || (Component == null ? void 0 : Component.displayName) || (Component == null ? void 0 : Component.name) || "[Unnamed Component]", "debug on");
|
|
102
|
+
console.log("props in:", props, Object.keys(props));
|
|
85
103
|
if (props["debug"] === "break")
|
|
86
104
|
debugger;
|
|
87
105
|
}
|
|
88
106
|
}
|
|
89
107
|
const forceUpdate = useForceUpdate();
|
|
90
|
-
const theme = useTheme(props.theme, componentName, props, forceUpdate);
|
|
108
|
+
const theme = useTheme(props.theme, staticConfig.componentName, props, forceUpdate);
|
|
91
109
|
const [state, set_] = useState(defaultComponentState);
|
|
92
110
|
const setStateShallow = createShallowUpdate(set_);
|
|
93
111
|
const shouldAvoidClasses = !!(props.animation && avoidClasses);
|
|
94
|
-
const splitStyles =
|
|
112
|
+
const splitStyles = useSplitStyles(props, staticConfig, theme, shouldAvoidClasses ? { ...state, noClassNames: true, resolveVariablesAs: "value" } : state, shouldAvoidClasses || props.asChild ? null : initialSplitStyles.classNames);
|
|
95
113
|
const { viewProps: viewPropsIn, pseudos, medias, style, classNames } = splitStyles;
|
|
96
114
|
const useAnimations = (_a = tamaguiConfig.animations) == null ? void 0 : _a.useAnimations;
|
|
97
115
|
const isAnimated = !!(useAnimations && props.animation);
|
|
@@ -110,6 +128,7 @@ function createComponent(configIn) {
|
|
|
110
128
|
const {
|
|
111
129
|
tag,
|
|
112
130
|
hitSlop,
|
|
131
|
+
asChild,
|
|
113
132
|
children,
|
|
114
133
|
pointerEvents,
|
|
115
134
|
onPress,
|
|
@@ -144,6 +163,7 @@ function createComponent(configIn) {
|
|
|
144
163
|
accessibilityRole,
|
|
145
164
|
collapsable,
|
|
146
165
|
focusable,
|
|
166
|
+
onClick,
|
|
147
167
|
theme: _themeProp,
|
|
148
168
|
defaultVariants,
|
|
149
169
|
onLayout,
|
|
@@ -166,7 +186,7 @@ function createComponent(configIn) {
|
|
|
166
186
|
};
|
|
167
187
|
}
|
|
168
188
|
useIsomorphicLayoutEffect(() => {
|
|
169
|
-
if (typeof window !== "undefined") {
|
|
189
|
+
if (typeof window !== "undefined" && (hasEnterStyle || props.animation)) {
|
|
170
190
|
setStateShallow({
|
|
171
191
|
mounted: true
|
|
172
192
|
});
|
|
@@ -176,7 +196,7 @@ function createComponent(configIn) {
|
|
|
176
196
|
mouseUps.delete(unPress);
|
|
177
197
|
internal.current.isMounted = false;
|
|
178
198
|
};
|
|
179
|
-
}, [hasEnterStyle]);
|
|
199
|
+
}, [hasEnterStyle, props.animation]);
|
|
180
200
|
if (nativeID) {
|
|
181
201
|
viewProps.id = nativeID;
|
|
182
202
|
}
|
|
@@ -192,7 +212,7 @@ function createComponent(configIn) {
|
|
|
192
212
|
if (accessibilityRole)
|
|
193
213
|
viewProps.accessibilityRole = accessibilityRole;
|
|
194
214
|
}
|
|
195
|
-
if (isWeb) {
|
|
215
|
+
if (isWeb && !asChild) {
|
|
196
216
|
rnw.useResponderEvents(hostRef, {
|
|
197
217
|
onMoveShouldSetResponder,
|
|
198
218
|
onMoveShouldSetResponderCapture,
|
|
@@ -253,7 +273,7 @@ function createComponent(configIn) {
|
|
|
253
273
|
const className = classList.join(" ");
|
|
254
274
|
if (process.env.NODE_ENV === "development") {
|
|
255
275
|
if (props["debug"]) {
|
|
256
|
-
console.log(" \xBB className", { isStringElement, pseudos, state,
|
|
276
|
+
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]])) });
|
|
257
277
|
}
|
|
258
278
|
}
|
|
259
279
|
viewProps.className = className;
|
|
@@ -294,11 +314,16 @@ function createComponent(configIn) {
|
|
|
294
314
|
viewProps.ref = forwardedRef;
|
|
295
315
|
}
|
|
296
316
|
}
|
|
297
|
-
const
|
|
298
|
-
const
|
|
317
|
+
const initialPseudos = initialSplitStyles.pseudos;
|
|
318
|
+
const attachPress = !!(pseudos && pseudos.pressStyle || initialPseudos && initialPseudos.pressStyle || onPress || onPressOut || onPressIn || onClick);
|
|
319
|
+
const isTouch = useIsTouchDevice();
|
|
320
|
+
const isHoverable = isWeb && !isTouch;
|
|
299
321
|
const attachHover = isHoverable && !!(pseudos && pseudos.hoverStyle || onHoverIn || onHoverOut || onMouseEnter || onMouseLeave);
|
|
300
|
-
const
|
|
301
|
-
const
|
|
322
|
+
const handlesPressEvents = !isStringElement && !asChild;
|
|
323
|
+
const pressKey = handlesPressEvents ? "onPress" : "onClick";
|
|
324
|
+
const pressInKey = handlesPressEvents ? "onPressIn" : "onMouseDown";
|
|
325
|
+
const pressOutKey = handlesPressEvents ? "onPressOut" : "onMouseUp";
|
|
326
|
+
const shouldAttach = !asChild && (attachPress || attachHover || "pressStyle" in props || "onPress" in props || "onPressIn" in props || "onPressOut" in props || isWeb && ("hoverStyle" in props || "onHoverIn" in props || "onHoverOut" in props || "onMouseEnter" in props || "onMouseLeave" in props));
|
|
302
327
|
const unPress = useCallback(() => {
|
|
303
328
|
if (!internal.current.isMounted)
|
|
304
329
|
return;
|
|
@@ -308,12 +333,10 @@ function createComponent(configIn) {
|
|
|
308
333
|
});
|
|
309
334
|
}, []);
|
|
310
335
|
const events = shouldAttach ? {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
}
|
|
316
|
-
},
|
|
336
|
+
[pressOutKey]: attachPress ? (e) => {
|
|
337
|
+
unPress();
|
|
338
|
+
onPressOut == null ? void 0 : onPressOut(e);
|
|
339
|
+
} : void 0,
|
|
317
340
|
...isHoverable && {
|
|
318
341
|
onMouseEnter: attachHover ? (e) => {
|
|
319
342
|
let next = {};
|
|
@@ -346,37 +369,29 @@ function createComponent(configIn) {
|
|
|
346
369
|
onMouseLeave == null ? void 0 : onMouseLeave(e);
|
|
347
370
|
} : void 0
|
|
348
371
|
},
|
|
349
|
-
|
|
372
|
+
[pressInKey]: attachPress ? (e) => {
|
|
350
373
|
setStateShallow({
|
|
351
374
|
press: true,
|
|
352
375
|
pressIn: true
|
|
353
376
|
});
|
|
354
377
|
onPressIn == null ? void 0 : onPressIn(e);
|
|
355
378
|
onMouseDown == null ? void 0 : onMouseDown(e);
|
|
379
|
+
if (isWeb) {
|
|
380
|
+
mouseUps.add(unPress);
|
|
381
|
+
}
|
|
356
382
|
} : null,
|
|
357
|
-
[
|
|
358
|
-
onPress == null ? void 0 : onPress(e);
|
|
383
|
+
[pressKey]: attachPress ? (e) => {
|
|
359
384
|
unPress();
|
|
360
|
-
|
|
385
|
+
onClick == null ? void 0 : onClick(e);
|
|
386
|
+
onPress == null ? void 0 : onPress(e);
|
|
361
387
|
} : null
|
|
362
388
|
} : null;
|
|
363
|
-
|
|
389
|
+
const childEls = !children || asChild ? children : wrapThemeManagerContext(spacedChildren({
|
|
364
390
|
children,
|
|
365
391
|
space,
|
|
366
392
|
flexDirection: props.flexDirection || ((_b = staticConfig.defaultProps) == null ? void 0 : _b.flexDirection),
|
|
367
393
|
isZStack
|
|
368
394
|
}), getThemeManagerIfChanged(theme));
|
|
369
|
-
const [pressProps] = usePressable(events ? {
|
|
370
|
-
disabled,
|
|
371
|
-
...hitSlop && {
|
|
372
|
-
hitSlop
|
|
373
|
-
},
|
|
374
|
-
onPressIn: events.onMouseDown,
|
|
375
|
-
onPressOut: events.onPressOut,
|
|
376
|
-
onPress: events[pressEventKey]
|
|
377
|
-
} : {
|
|
378
|
-
disabled: true
|
|
379
|
-
});
|
|
380
395
|
let content;
|
|
381
396
|
if (isWeb) {
|
|
382
397
|
if (staticConfig.isReactNativeWeb) {
|
|
@@ -393,14 +408,46 @@ function createComponent(configIn) {
|
|
|
393
408
|
}
|
|
394
409
|
}
|
|
395
410
|
}
|
|
396
|
-
if (
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
411
|
+
if (asChild) {
|
|
412
|
+
ViewComponent = Slot;
|
|
413
|
+
const onlyChild = React.Children.only(children);
|
|
414
|
+
Object.assign(viewProps, onlyChild.props);
|
|
415
|
+
}
|
|
416
|
+
if (isWeb) {
|
|
417
|
+
const [pressableProps] = usePressable(events ? {
|
|
418
|
+
disabled,
|
|
419
|
+
...hitSlop && {
|
|
420
|
+
hitSlop
|
|
421
|
+
},
|
|
422
|
+
onPressOut: events[pressOutKey],
|
|
423
|
+
onPressIn: events[pressInKey],
|
|
424
|
+
onPress: events[pressKey]
|
|
425
|
+
} : {
|
|
426
|
+
disabled: true
|
|
427
|
+
});
|
|
428
|
+
if (events) {
|
|
429
|
+
if (handlesPressEvents) {
|
|
430
|
+
Object.assign(viewProps, pressableProps);
|
|
431
|
+
} else {
|
|
432
|
+
Object.assign(viewProps, events);
|
|
433
|
+
}
|
|
401
434
|
}
|
|
402
435
|
}
|
|
403
436
|
content = createElement(ViewComponent, viewProps, childEls);
|
|
437
|
+
if (!isWeb) {
|
|
438
|
+
if (attachPress && events) {
|
|
439
|
+
content = /* @__PURE__ */ React.createElement(Pressable, {
|
|
440
|
+
onPressIn: events[pressInKey],
|
|
441
|
+
onPress: events[pressKey]
|
|
442
|
+
}, /* @__PURE__ */ React.createElement(BaseButton, {
|
|
443
|
+
onActiveStateChange: (isActive) => {
|
|
444
|
+
if (!isActive) {
|
|
445
|
+
unPress();
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}, content));
|
|
449
|
+
}
|
|
450
|
+
}
|
|
404
451
|
if (isWeb && events && attachHover) {
|
|
405
452
|
content = /* @__PURE__ */ React.createElement("span", {
|
|
406
453
|
className: "tui_Hoverable",
|
|
@@ -413,8 +460,7 @@ function createComponent(configIn) {
|
|
|
413
460
|
}
|
|
414
461
|
if (process.env.NODE_ENV === "development") {
|
|
415
462
|
if (props["debug"]) {
|
|
416
|
-
viewProps
|
|
417
|
-
console.log(" \xBB ", { propsIn: { ...props }, propsOut: { ...viewProps }, state, splitStyles, defaultsClassName, 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, defaultSplitStyleResult, ...typeof window !== "undefined" ? { theme, themeState: theme.__state, themeClassName: theme.className, staticConfig, tamaguiConfig } : null });
|
|
463
|
+
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(" "), 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 });
|
|
418
464
|
}
|
|
419
465
|
}
|
|
420
466
|
if (features.length) {
|
|
@@ -422,66 +468,81 @@ function createComponent(configIn) {
|
|
|
422
468
|
}
|
|
423
469
|
return content;
|
|
424
470
|
});
|
|
471
|
+
component.displayName = staticConfig.componentName;
|
|
425
472
|
onConfiguredOnce((conf) => {
|
|
426
473
|
var _a, _b, _c, _d;
|
|
427
474
|
if (process.env.IS_STATIC === "is_static") {
|
|
428
475
|
return;
|
|
429
476
|
}
|
|
430
|
-
const shouldDebug = (_a = staticConfig.defaultProps) == null ? void 0 : _a.debug;
|
|
431
477
|
tamaguiConfig = conf;
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
478
|
+
mergeShorthands(staticConfig, tamaguiConfig);
|
|
479
|
+
avoidClasses = !!((_a = tamaguiConfig.animations) == null ? void 0 : _a.avoidClasses);
|
|
480
|
+
AnimatedText = (_b = tamaguiConfig.animations) == null ? void 0 : _b.Text;
|
|
481
|
+
AnimatedView = (_c = tamaguiConfig == null ? void 0 : tamaguiConfig.animations) == null ? void 0 : _c.View;
|
|
482
|
+
initialTheme = initialTheme || proxyThemeVariables(conf.themes[conf.defaultTheme || Object.keys(conf.themes)[0]]);
|
|
483
|
+
initialSplitStyles = insertSplitStyles(staticConfig.defaultProps, staticConfig, initialTheme, {
|
|
437
484
|
mounted: true,
|
|
438
485
|
hover: false,
|
|
439
486
|
press: false,
|
|
440
487
|
pressIn: false,
|
|
441
488
|
focus: false,
|
|
442
|
-
resolveVariablesAs: "both"
|
|
489
|
+
resolveVariablesAs: "both",
|
|
490
|
+
keepVariantsAsProps: true
|
|
443
491
|
});
|
|
444
|
-
const
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
}
|
|
448
|
-
defaultPseudos = pseudos;
|
|
492
|
+
const defaults = {
|
|
493
|
+
...component.defaultProps,
|
|
494
|
+
...initialSplitStyles.viewProps
|
|
495
|
+
};
|
|
449
496
|
defaultNativeStyle = {};
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
497
|
+
const validStyles = staticConfig.validStyles || stylePropsView;
|
|
498
|
+
for (const key in staticConfig.defaultProps) {
|
|
499
|
+
const val = staticConfig.defaultProps[key];
|
|
500
|
+
if (typeof val === "string" && val[0] === "$" || !validStyles[key]) {
|
|
501
|
+
defaults[key] = val;
|
|
502
|
+
} else {
|
|
503
|
+
defaultNativeStyle[key] = val;
|
|
504
|
+
}
|
|
453
505
|
}
|
|
454
506
|
defaultNativeStyleSheet = StyleSheet.create({
|
|
455
507
|
base: defaultNativeStyle
|
|
456
508
|
});
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
509
|
+
if (Object.keys(defaults).length) {
|
|
510
|
+
tamaguiDefaultProps = defaults;
|
|
511
|
+
}
|
|
512
|
+
if (process.env.NODE_ENV === "development" && ((_d = staticConfig.defaultProps) == null ? void 0 : _d.debug)) {
|
|
513
|
+
if (process.env.IS_STATIC !== "is_static") {
|
|
514
|
+
console.log(`\u{1F41B} [${staticConfig.componentName || "Component"}]`, {
|
|
515
|
+
staticConfig,
|
|
516
|
+
initialSplitStyles,
|
|
517
|
+
tamaguiDefaultProps,
|
|
518
|
+
defaultNativeStyle,
|
|
519
|
+
defaults
|
|
520
|
+
});
|
|
521
|
+
}
|
|
464
522
|
}
|
|
465
523
|
});
|
|
466
524
|
let res = component;
|
|
467
525
|
if (configIn.memo) {
|
|
468
526
|
res = memo(res);
|
|
469
527
|
}
|
|
470
|
-
res["whyDidYouRender"] = true;
|
|
471
528
|
res["staticConfig"] = {
|
|
472
|
-
validStyles:
|
|
529
|
+
validStyles: staticConfig.validStyles || stylePropsView,
|
|
473
530
|
...staticConfig
|
|
474
531
|
};
|
|
475
|
-
|
|
476
|
-
|
|
532
|
+
if (process.env.NODE_ENV === "development") {
|
|
533
|
+
res["whyDidYouRender"] = true;
|
|
534
|
+
}
|
|
535
|
+
res["extractable"] = (Component, conf) => {
|
|
536
|
+
Component["staticConfig"] = extendStaticConfig({
|
|
537
|
+
Component,
|
|
477
538
|
...conf,
|
|
478
539
|
neverFlatten: true,
|
|
479
540
|
defaultProps: {
|
|
480
|
-
...
|
|
541
|
+
...Component.defaultProps,
|
|
481
542
|
...conf == null ? void 0 : conf.defaultProps
|
|
482
543
|
}
|
|
483
|
-
});
|
|
484
|
-
return
|
|
544
|
+
}, res);
|
|
545
|
+
return Component;
|
|
485
546
|
};
|
|
486
547
|
return res;
|
|
487
548
|
}
|
|
@@ -522,6 +583,9 @@ const Spacer = createComponent({
|
|
|
522
583
|
minWidth: 0
|
|
523
584
|
}
|
|
524
585
|
}
|
|
586
|
+
},
|
|
587
|
+
defaultVariants: {
|
|
588
|
+
direction: "horizontal"
|
|
525
589
|
}
|
|
526
590
|
});
|
|
527
591
|
function spacedChildren({
|
|
@@ -568,22 +632,24 @@ function spacedChildren({
|
|
|
568
632
|
return next;
|
|
569
633
|
}
|
|
570
634
|
__name(spacedChildren, "spacedChildren");
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
|
|
635
|
+
function AbsoluteFill(props) {
|
|
636
|
+
return isWeb ? /* @__PURE__ */ React.createElement("div", {
|
|
637
|
+
style: {
|
|
638
|
+
position: "absolute",
|
|
639
|
+
top: 0,
|
|
640
|
+
left: 0,
|
|
641
|
+
right: 0,
|
|
642
|
+
bottom: 0
|
|
643
|
+
}
|
|
644
|
+
}, props.children) : /* @__PURE__ */ React.createElement(View, {
|
|
645
|
+
style: StyleSheet.absoluteFill
|
|
646
|
+
}, props.child);
|
|
647
|
+
}
|
|
648
|
+
__name(AbsoluteFill, "AbsoluteFill");
|
|
582
649
|
export {
|
|
583
650
|
AbsoluteFill,
|
|
584
651
|
Spacer,
|
|
585
652
|
createComponent,
|
|
586
|
-
defaultComponentState,
|
|
587
653
|
mouseUps,
|
|
588
654
|
spacedChildren
|
|
589
655
|
};
|