@tamagui/core 1.0.0-beta.152 → 1.0.0-beta.17
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 +191 -113
- 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/helpers/getSize.js +35 -0
- 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/{constants/pseudos.js → helpers/nativeGestureHandler.js} +11 -19
- package/dist/cjs/helpers/nativeGestureHandler.js.map +7 -0
- package/dist/cjs/helpers/nativeGestureHandler.native.js +18 -0
- package/dist/cjs/helpers/nativeGestureHandler.native.js.map +7 -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/nativeGestureHandler.native.js +18 -0
- package/dist/cjs/nativeGestureHandler.native.js.map +7 -0
- 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 +187 -122
- 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/nativeGestureHandler.js +7 -0
- package/dist/esm/helpers/nativeGestureHandler.js.map +7 -0
- package/dist/esm/helpers/nativeGestureHandler.native.js +2 -0
- package/dist/esm/helpers/nativeGestureHandler.native.js.map +7 -0
- 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/nativeGestureHandler.native.js +2 -0
- package/dist/esm/nativeGestureHandler.native.js.map +7 -0
- 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 +173 -113
- 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/nativeGestureHandler.js +6 -0
- package/dist/jsx/helpers/nativeGestureHandler.native.js +1 -0
- 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/nativeGestureHandler.native.js +1 -0
- 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/nativeGestureHandler.d.ts +2 -0
- package/types/helpers/nativeGestureHandler.d.ts.map +1 -0
- package/types/helpers/nativeGestureHandler.native.d.ts +2 -0
- package/types/helpers/nativeGestureHandler.native.d.ts.map +1 -0
- 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/nativeGestureHandler.native.d.ts +2 -0
- package/types/nativeGestureHandler.native.d.ts.map +1 -0
- 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
17
|
import { onConfiguredOnce } from "./conf";
|
|
18
18
|
import { stackDefaultStyles } from "./constants/constants";
|
|
19
|
-
import { isAndroid,
|
|
19
|
+
import { isAndroid, isWeb, useIsomorphicLayoutEffect } from "./constants/platform";
|
|
20
20
|
import { rnw } from "./constants/rnw";
|
|
21
|
-
import { isVariable } from "./createVariable";
|
|
22
21
|
import { createShallowUpdate } from "./helpers/createShallowUpdate";
|
|
23
22
|
import { extendStaticConfig, parseStaticConfig } from "./helpers/extendStaticConfig";
|
|
24
|
-
import {
|
|
23
|
+
import { insertSplitStyles, useSplitStyles } from "./helpers/getSplitStyles";
|
|
25
24
|
import { getAllSelectors } from "./helpers/insertStyleRule";
|
|
25
|
+
import { BaseButton } from "./helpers/nativeGestureHandler";
|
|
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,41 @@ 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 = <Pressable onPressIn={events[pressInKey]} onPress={events[pressKey]}><BaseButton onActiveStateChange={(isActive) => {
|
|
440
|
+
if (!isActive) {
|
|
441
|
+
unPress();
|
|
442
|
+
}
|
|
443
|
+
}}>{content}</BaseButton></Pressable>;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
404
446
|
if (isWeb && events && attachHover) {
|
|
405
447
|
content = <span className="tui_Hoverable" style={{
|
|
406
448
|
display: "contents"
|
|
@@ -408,8 +450,7 @@ function createComponent(configIn) {
|
|
|
408
450
|
}
|
|
409
451
|
if (process.env.NODE_ENV === "development") {
|
|
410
452
|
if (props["debug"]) {
|
|
411
|
-
viewProps
|
|
412
|
-
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 });
|
|
453
|
+
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 });
|
|
413
454
|
}
|
|
414
455
|
}
|
|
415
456
|
if (features.length) {
|
|
@@ -420,66 +461,81 @@ function createComponent(configIn) {
|
|
|
420
461
|
}
|
|
421
462
|
return content;
|
|
422
463
|
});
|
|
464
|
+
component.displayName = staticConfig.componentName;
|
|
423
465
|
onConfiguredOnce((conf) => {
|
|
424
466
|
var _a, _b, _c, _d;
|
|
425
467
|
if (process.env.IS_STATIC === "is_static") {
|
|
426
468
|
return;
|
|
427
469
|
}
|
|
428
|
-
const shouldDebug = (_a = staticConfig.defaultProps) == null ? void 0 : _a.debug;
|
|
429
470
|
tamaguiConfig = conf;
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
471
|
+
mergeShorthands(staticConfig, tamaguiConfig);
|
|
472
|
+
avoidClasses = !!((_a = tamaguiConfig.animations) == null ? void 0 : _a.avoidClasses);
|
|
473
|
+
AnimatedText = (_b = tamaguiConfig.animations) == null ? void 0 : _b.Text;
|
|
474
|
+
AnimatedView = (_c = tamaguiConfig == null ? void 0 : tamaguiConfig.animations) == null ? void 0 : _c.View;
|
|
475
|
+
initialTheme = initialTheme || proxyThemeVariables(conf.themes[conf.defaultTheme || Object.keys(conf.themes)[0]]);
|
|
476
|
+
initialSplitStyles = insertSplitStyles(staticConfig.defaultProps, staticConfig, initialTheme, {
|
|
435
477
|
mounted: true,
|
|
436
478
|
hover: false,
|
|
437
479
|
press: false,
|
|
438
480
|
pressIn: false,
|
|
439
481
|
focus: false,
|
|
440
|
-
resolveVariablesAs: "both"
|
|
482
|
+
resolveVariablesAs: "both",
|
|
483
|
+
keepVariantsAsProps: true
|
|
441
484
|
});
|
|
442
|
-
const
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
}
|
|
446
|
-
defaultPseudos = pseudos;
|
|
485
|
+
const defaults = {
|
|
486
|
+
...component.defaultProps,
|
|
487
|
+
...initialSplitStyles.viewProps
|
|
488
|
+
};
|
|
447
489
|
defaultNativeStyle = {};
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
490
|
+
const validStyles = staticConfig.validStyles || stylePropsView;
|
|
491
|
+
for (const key in staticConfig.defaultProps) {
|
|
492
|
+
const val = staticConfig.defaultProps[key];
|
|
493
|
+
if (typeof val === "string" && val[0] === "$" || !validStyles[key]) {
|
|
494
|
+
defaults[key] = val;
|
|
495
|
+
} else {
|
|
496
|
+
defaultNativeStyle[key] = val;
|
|
497
|
+
}
|
|
451
498
|
}
|
|
452
499
|
defaultNativeStyleSheet = StyleSheet.create({
|
|
453
500
|
base: defaultNativeStyle
|
|
454
501
|
});
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
502
|
+
if (Object.keys(defaults).length) {
|
|
503
|
+
tamaguiDefaultProps = defaults;
|
|
504
|
+
}
|
|
505
|
+
if (process.env.NODE_ENV === "development" && ((_d = staticConfig.defaultProps) == null ? void 0 : _d.debug)) {
|
|
506
|
+
if (process.env.IS_STATIC !== "is_static") {
|
|
507
|
+
console.log(`\u{1F41B} [${staticConfig.componentName || "Component"}]`, {
|
|
508
|
+
staticConfig,
|
|
509
|
+
initialSplitStyles,
|
|
510
|
+
tamaguiDefaultProps,
|
|
511
|
+
defaultNativeStyle,
|
|
512
|
+
defaults
|
|
513
|
+
});
|
|
514
|
+
}
|
|
462
515
|
}
|
|
463
516
|
});
|
|
464
517
|
let res = component;
|
|
465
518
|
if (configIn.memo) {
|
|
466
519
|
res = memo(res);
|
|
467
520
|
}
|
|
468
|
-
res["whyDidYouRender"] = true;
|
|
469
521
|
res["staticConfig"] = {
|
|
470
|
-
validStyles:
|
|
522
|
+
validStyles: staticConfig.validStyles || stylePropsView,
|
|
471
523
|
...staticConfig
|
|
472
524
|
};
|
|
473
|
-
|
|
474
|
-
|
|
525
|
+
if (process.env.NODE_ENV === "development") {
|
|
526
|
+
res["whyDidYouRender"] = true;
|
|
527
|
+
}
|
|
528
|
+
res["extractable"] = (Component, conf) => {
|
|
529
|
+
Component["staticConfig"] = extendStaticConfig({
|
|
530
|
+
Component,
|
|
475
531
|
...conf,
|
|
476
532
|
neverFlatten: true,
|
|
477
533
|
defaultProps: {
|
|
478
|
-
...
|
|
534
|
+
...Component.defaultProps,
|
|
479
535
|
...conf == null ? void 0 : conf.defaultProps
|
|
480
536
|
}
|
|
481
|
-
});
|
|
482
|
-
return
|
|
537
|
+
}, res);
|
|
538
|
+
return Component;
|
|
483
539
|
};
|
|
484
540
|
return res;
|
|
485
541
|
}
|
|
@@ -520,6 +576,9 @@ const Spacer = createComponent({
|
|
|
520
576
|
minWidth: 0
|
|
521
577
|
}
|
|
522
578
|
}
|
|
579
|
+
},
|
|
580
|
+
defaultVariants: {
|
|
581
|
+
direction: "horizontal"
|
|
523
582
|
}
|
|
524
583
|
});
|
|
525
584
|
function spacedChildren({
|
|
@@ -530,47 +589,48 @@ function spacedChildren({
|
|
|
530
589
|
spaceFlex
|
|
531
590
|
}) {
|
|
532
591
|
var _a;
|
|
533
|
-
const childrenList = Children.toArray(children);
|
|
592
|
+
const childrenList = Array.isArray(children) ? children : Children.toArray(children);
|
|
534
593
|
const len = childrenList.length;
|
|
535
|
-
if (len
|
|
594
|
+
if (len <= 1) {
|
|
536
595
|
return childrenList;
|
|
537
596
|
}
|
|
538
|
-
const
|
|
597
|
+
const final = [];
|
|
539
598
|
for (const [index, child] of childrenList.entries()) {
|
|
540
|
-
if (child === null || child === void 0) {
|
|
599
|
+
if (child === null || child === void 0 || child === false || Array.isArray(child) && child.length === 0) {
|
|
541
600
|
continue;
|
|
542
601
|
}
|
|
543
602
|
if (!child || child["key"] && !isZStack) {
|
|
544
|
-
|
|
603
|
+
final.push(child);
|
|
545
604
|
} else {
|
|
546
|
-
|
|
605
|
+
final.push(<Fragment key={index}>{isZStack ? <AbsoluteFill>{child}</AbsoluteFill> : child}</Fragment>);
|
|
547
606
|
}
|
|
548
607
|
if ((_a = child["type"]) == null ? void 0 : _a["isVisuallyHidden"]) {
|
|
549
608
|
continue;
|
|
550
609
|
}
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
}
|
|
610
|
+
const next = childrenList[index + 1];
|
|
611
|
+
if (next && space) {
|
|
612
|
+
final.push(<Spacer key={`_${index}_spacer`} direction={flexDirection === "row" || flexDirection === "row-reverse" ? "horizontal" : "vertical"} size={space} {...spaceFlex && {
|
|
613
|
+
flex: spaceFlex
|
|
614
|
+
}} />);
|
|
557
615
|
}
|
|
558
616
|
}
|
|
559
|
-
return
|
|
617
|
+
return final;
|
|
560
618
|
}
|
|
561
619
|
__name(spacedChildren, "spacedChildren");
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
620
|
+
function AbsoluteFill(props) {
|
|
621
|
+
return isWeb ? <div style={{
|
|
622
|
+
position: "absolute",
|
|
623
|
+
top: 0,
|
|
624
|
+
left: 0,
|
|
625
|
+
right: 0,
|
|
626
|
+
bottom: 0
|
|
627
|
+
}}>{props.children}</div> : <View style={StyleSheet.absoluteFill}>{props.child}</View>;
|
|
628
|
+
}
|
|
629
|
+
__name(AbsoluteFill, "AbsoluteFill");
|
|
569
630
|
export {
|
|
570
631
|
AbsoluteFill,
|
|
571
632
|
Spacer,
|
|
572
633
|
createComponent,
|
|
573
|
-
defaultComponentState,
|
|
574
634
|
mouseUps,
|
|
575
635
|
spacedChildren
|
|
576
636
|
};
|
|
@@ -28,7 +28,7 @@ function createTamagui(config) {
|
|
|
28
28
|
defaultActive: config.mediaQueryDefaultActive
|
|
29
29
|
});
|
|
30
30
|
const themeConfig = (() => {
|
|
31
|
-
var _a, _b;
|
|
31
|
+
var _a, _b, _c;
|
|
32
32
|
let cssRules = [];
|
|
33
33
|
const varsByValue = /* @__PURE__ */ new Map();
|
|
34
34
|
if (isWeb) {
|
|
@@ -75,13 +75,16 @@ function createTamagui(config) {
|
|
|
75
75
|
}
|
|
76
76
|
if (isWeb) {
|
|
77
77
|
const isDarkOrLightBase = themeName === "dark" || themeName === "light";
|
|
78
|
-
const isDark = themeName.
|
|
78
|
+
const isDark = themeName.startsWith("dark");
|
|
79
79
|
const selector = `${CNP}${themeName}`;
|
|
80
|
-
const addDarkLightSels = hasDarkLight && !isDarkOrLightBase;
|
|
81
80
|
const selectors = [selector];
|
|
82
|
-
if (
|
|
81
|
+
if (hasDarkLight) {
|
|
83
82
|
const childSelector = `${CNP}${themeName.replace("dark_", "").replace("light_", "")}`;
|
|
84
|
-
const
|
|
83
|
+
const order = isDark ? ["dark", "light"] : ["light", "dark"];
|
|
84
|
+
if (isDarkOrLightBase) {
|
|
85
|
+
order.reverse();
|
|
86
|
+
}
|
|
87
|
+
const [stronger, weaker] = order;
|
|
85
88
|
const max = (_b = config.maxDarkLightNesting) != null ? _b : 3;
|
|
86
89
|
new Array(max * 2).fill(void 0).forEach((_, pi) => {
|
|
87
90
|
if (pi % 2 === 1)
|
|
@@ -92,25 +95,56 @@ function createTamagui(config) {
|
|
|
92
95
|
selectors.push(`${(parents.length > 1 ? parents.slice(1) : parents).join(" ")} ${childSelector}`);
|
|
93
96
|
});
|
|
94
97
|
}
|
|
95
|
-
const
|
|
96
|
-
${vars}
|
|
97
|
-
|
|
98
|
-
|
|
98
|
+
const rootSep = config.themeClassNameOnRoot ? "" : " ";
|
|
99
|
+
cssRules.push(`${selectors.map((x) => `:root${rootSep}${x}`).join(", ")} {${vars}}`);
|
|
100
|
+
if ((_c = config.shouldAddPrefersColorThemes) != null ? _c : true) {
|
|
101
|
+
if (isDarkOrLightBase) {
|
|
102
|
+
cssRules.push(`@media(prefers-color-scheme: ${isDark ? "dark" : "light"}) {
|
|
103
|
+
body { background:${theme.background}; color: ${theme.color} }
|
|
104
|
+
:root {${vars} }
|
|
105
|
+
}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
99
108
|
}
|
|
100
109
|
}
|
|
101
110
|
varsByValue.clear();
|
|
102
111
|
Object.freeze(cssRules);
|
|
112
|
+
const css = cssRules.join("\n");
|
|
103
113
|
return {
|
|
104
114
|
cssRules,
|
|
105
|
-
css
|
|
115
|
+
css
|
|
106
116
|
};
|
|
107
117
|
})();
|
|
108
118
|
const tokensParsed = parseTokens(config.tokens);
|
|
119
|
+
const fontsParsed = (() => {
|
|
120
|
+
if (!config.fonts) {
|
|
121
|
+
throw new Error(`No fonts defined!`);
|
|
122
|
+
}
|
|
123
|
+
const res = {};
|
|
124
|
+
for (const familyName in config.fonts) {
|
|
125
|
+
const family = config.fonts[familyName];
|
|
126
|
+
const parsed = {};
|
|
127
|
+
for (const attrKey in family) {
|
|
128
|
+
const attr = family[attrKey];
|
|
129
|
+
if (attrKey === "family") {
|
|
130
|
+
parsed[attrKey] = attr;
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
parsed[attrKey] = Object.keys(attr).reduce((acc, cur) => {
|
|
134
|
+
acc[`$${cur}`] = attr[cur];
|
|
135
|
+
return acc;
|
|
136
|
+
}, {});
|
|
137
|
+
}
|
|
138
|
+
res[`$${familyName}`] = parsed;
|
|
139
|
+
}
|
|
140
|
+
return res;
|
|
141
|
+
})();
|
|
109
142
|
const getCSS = /* @__PURE__ */ __name(() => {
|
|
110
143
|
return `${themeConfig.css}
|
|
111
144
|
${getInsertedRules().join("\n")}`;
|
|
112
145
|
}, "getCSS");
|
|
113
146
|
const next = {
|
|
147
|
+
fonts: {},
|
|
114
148
|
animations: {},
|
|
115
149
|
shorthands: {},
|
|
116
150
|
media: {},
|
|
@@ -120,6 +154,7 @@ ${getInsertedRules().join("\n")}`;
|
|
|
120
154
|
defaultTheme: "light",
|
|
121
155
|
...config
|
|
122
156
|
}),
|
|
157
|
+
fontsParsed,
|
|
123
158
|
themeConfig,
|
|
124
159
|
tokensParsed,
|
|
125
160
|
parsed: true,
|
|
@@ -138,24 +173,6 @@ const parseTokens = /* @__PURE__ */ __name((tokens) => {
|
|
|
138
173
|
const res = {};
|
|
139
174
|
for (const key in tokens) {
|
|
140
175
|
res[key] = {};
|
|
141
|
-
if (key === "font") {
|
|
142
|
-
for (const family in tokens.font) {
|
|
143
|
-
const obj = {};
|
|
144
|
-
res.font[`$${family}`] = obj;
|
|
145
|
-
for (const attrKey in tokens.font[family]) {
|
|
146
|
-
const attr = tokens.font[family][attrKey];
|
|
147
|
-
if (attrKey === "family") {
|
|
148
|
-
obj[attrKey] = attr;
|
|
149
|
-
continue;
|
|
150
|
-
}
|
|
151
|
-
obj[attrKey] = Object.keys(attr).reduce((acc, cur) => {
|
|
152
|
-
acc[`$${cur}`] = attr[cur];
|
|
153
|
-
return acc;
|
|
154
|
-
}, {});
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
continue;
|
|
158
|
-
}
|
|
159
176
|
for (const skey in tokens[key]) {
|
|
160
177
|
res[key][`$${skey}`] = tokens[key][skey];
|
|
161
178
|
}
|
package/dist/jsx/createTokens.js
CHANGED
|
@@ -6,17 +6,13 @@ function createTokens(tokens) {
|
|
|
6
6
|
if (process.env.NODE_ENV === "development") {
|
|
7
7
|
validateTokens(tokens);
|
|
8
8
|
}
|
|
9
|
-
return setupTokens(tokens);
|
|
10
|
-
}
|
|
11
|
-
__name(createTokens, "createTokens");
|
|
12
|
-
function setupTokens(tokens) {
|
|
13
9
|
return mapTokensToVariables(tokens);
|
|
14
10
|
}
|
|
15
|
-
__name(
|
|
11
|
+
__name(createTokens, "createTokens");
|
|
16
12
|
const mapTokensToVariables = /* @__PURE__ */ __name((tokens, parentPath = "") => {
|
|
17
13
|
const res = {};
|
|
18
14
|
for (const key in tokens) {
|
|
19
|
-
|
|
15
|
+
let val = tokens[key];
|
|
20
16
|
const name = parentPath ? `${parentPath}-${key}` : key;
|
|
21
17
|
if (val && typeof val === "object") {
|
|
22
18
|
res[key] = mapTokensToVariables(tokens[key], name);
|
|
@@ -22,12 +22,17 @@ function isVariable(v) {
|
|
|
22
22
|
}
|
|
23
23
|
__name(isVariable, "isVariable");
|
|
24
24
|
function getVariableValue(v) {
|
|
25
|
-
if (isVariable(v))
|
|
25
|
+
if (isVariable(v))
|
|
26
26
|
return v.val;
|
|
27
|
-
}
|
|
28
27
|
return v;
|
|
29
28
|
}
|
|
30
29
|
__name(getVariableValue, "getVariableValue");
|
|
30
|
+
function getVariableName(v) {
|
|
31
|
+
if (isVariable(v))
|
|
32
|
+
return v.name;
|
|
33
|
+
return v;
|
|
34
|
+
}
|
|
35
|
+
__name(getVariableName, "getVariableName");
|
|
31
36
|
const createCSSVariable = /* @__PURE__ */ __name((val, includeVar = true) => {
|
|
32
37
|
const name = val.replace(/[^a-z0-9\_\-]+/i, "_");
|
|
33
38
|
return includeVar ? `var(--${name})` : name;
|
|
@@ -37,6 +42,7 @@ export {
|
|
|
37
42
|
Variable,
|
|
38
43
|
createCSSVariable,
|
|
39
44
|
createVariable,
|
|
45
|
+
getVariableName,
|
|
40
46
|
getVariableValue,
|
|
41
47
|
isVariable
|
|
42
48
|
};
|