@tamagui/core 1.0.0-beta.187 → 1.0.0-beta.2
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 +156 -130
- 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 +56 -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 +38 -0
- package/dist/cjs/helpers/RNComponents.js.map +7 -0
- package/dist/cjs/helpers/addStylesUsingClassname.js +19 -16
- 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 +55 -0
- package/dist/cjs/helpers/createShallowUpdate.js.map +7 -0
- package/dist/cjs/helpers/createTamaguiProvider.js +5 -5
- package/dist/cjs/helpers/createTamaguiProvider.js.map +2 -2
- 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/helpers/getSize.js +35 -0
- package/dist/cjs/helpers/getSize.js.map +7 -0
- package/dist/cjs/helpers/getSplitStyles.js +152 -64
- 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 -12
- package/dist/cjs/hooks/useFeatures.js.map +2 -2
- 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 +30 -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 +8 -15
- package/dist/cjs/styled.js.map +2 -2
- package/dist/cjs/types-rnw.js.map +1 -1
- 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 +146 -133
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/createTamagui.js +53 -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/defaultComponentState.js +0 -11
- package/dist/esm/defaultComponentState.js.map +3 -3
- package/dist/esm/helpers/RNComponents.js +12 -0
- package/dist/esm/helpers/RNComponents.js.map +7 -0
- package/dist/esm/helpers/addStylesUsingClassname.js +16 -18
- 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 +19 -0
- package/dist/esm/helpers/createShallowUpdate.js.map +7 -0
- package/dist/esm/helpers/createTamaguiProvider.js +1 -4
- package/dist/esm/helpers/createTamaguiProvider.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 +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 +152 -67
- 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 -17
- package/dist/esm/hooks/useFeatures.js.map +2 -2
- package/dist/esm/hooks/useIsTouchDevice.js +6 -6
- package/dist/esm/hooks/useIsTouchDevice.js.map +2 -2
- package/dist/esm/hooks/useMedia.js +19 -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 +4 -12
- 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 +139 -127
- package/dist/jsx/createTamagui.js +53 -28
- 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 +11 -0
- package/dist/jsx/helpers/addStylesUsingClassname.js +16 -18
- package/dist/jsx/helpers/createPropMapper.js +59 -61
- package/dist/jsx/helpers/createShallowUpdate.js +18 -0
- package/dist/jsx/helpers/createTamaguiProvider.js +1 -2
- 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 +152 -67
- 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 -17
- package/dist/jsx/hooks/useIsTouchDevice.js +6 -6
- package/dist/jsx/hooks/useMedia.js +19 -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 +4 -12
- 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 +5 -7
- 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 +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/defaultComponentState.d.ts +0 -12
- package/types/defaultComponentState.d.ts.map +1 -1
- package/types/helpers/RNComponents.d.ts +2 -0
- package/types/helpers/RNComponents.d.ts.map +1 -0
- package/types/helpers/addStylesUsingClassname.d.ts.map +1 -1
- package/types/helpers/createPropMapper.d.ts +2 -2
- package/types/helpers/createPropMapper.d.ts.map +1 -1
- package/types/helpers/createShallowUpdate.d.ts +4 -0
- package/types/helpers/createShallowUpdate.d.ts.map +1 -0
- package/types/helpers/createTamaguiProvider.d.ts +1 -1
- package/types/helpers/createTamaguiProvider.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 +15 -18
- 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/useFeatures.d.ts +7 -5
- package/types/hooks/useFeatures.d.ts.map +1 -1
- package/types/hooks/useMedia.d.ts +2 -6
- 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 +13 -8
- package/types/styled.d.ts.map +1 -1
- package/types/types-rnw.d.ts +0 -5
- package/types/types-rnw.d.ts.map +1 -1
- package/types/types.d.ts +147 -106
- package/types/types.d.ts.map +1 -1
- package/types/views/Stack.d.ts +2 -2
- package/types/views/Stack.d.ts.map +1 -1
- package/types/views/Text.d.ts +2 -2
- 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/ThemeProvider.d.ts +1 -0
- package/types/views/ThemeProvider.d.ts.map +1 -1
- package/LICENSE +0 -21
- package/dist/cjs/spacedChildren.js +0 -86
- package/dist/cjs/spacedChildren.js.map +0 -7
- package/dist/esm/spacedChildren.js +0 -52
- package/dist/esm/spacedChildren.js.map +0 -7
- package/dist/jsx/spacedChildren.js +0 -44
- package/types/spacedChildren.d.ts +0 -9
- package/types/spacedChildren.d.ts.map +0 -1
|
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
import { stylePropsView } from "@tamagui/helpers";
|
|
4
4
|
import { useForceUpdate } from "@tamagui/use-force-update";
|
|
5
|
-
import {
|
|
5
|
+
import React, {
|
|
6
6
|
Children,
|
|
7
7
|
Fragment,
|
|
8
8
|
createElement,
|
|
@@ -10,103 +10,119 @@ import {
|
|
|
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,
|
|
19
|
+
import { isAndroid, 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 { insertSplitStyles, useSplitStyles } 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";
|
|
29
|
+
import { useIsTouchDevice } from "./hooks/useIsTouchDevice";
|
|
30
30
|
import { usePressable } from "./hooks/usePressable";
|
|
31
31
|
import { getThemeManagerIfChanged, useTheme } from "./hooks/useTheme";
|
|
32
32
|
import { TextAncestorContext } from "./views/TextAncestorContext";
|
|
33
|
+
React["keep"];
|
|
34
|
+
const defaultComponentState = {
|
|
35
|
+
hover: false,
|
|
36
|
+
press: false,
|
|
37
|
+
pressIn: false,
|
|
38
|
+
focus: false,
|
|
39
|
+
mounted: false,
|
|
40
|
+
animation: null
|
|
41
|
+
};
|
|
33
42
|
const mouseUps = /* @__PURE__ */ new Set();
|
|
34
43
|
if (typeof document !== "undefined") {
|
|
35
44
|
document.addEventListener("mouseup", () => {
|
|
36
45
|
mouseUps.forEach((x) => x());
|
|
37
46
|
mouseUps.clear();
|
|
38
47
|
});
|
|
48
|
+
document.addEventListener("touchend", () => {
|
|
49
|
+
mouseUps.forEach((x) => x());
|
|
50
|
+
mouseUps.clear();
|
|
51
|
+
});
|
|
52
|
+
document.addEventListener("touchcancel", () => {
|
|
53
|
+
mouseUps.forEach((x) => x());
|
|
54
|
+
mouseUps.clear();
|
|
55
|
+
});
|
|
39
56
|
}
|
|
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);
|
|
57
|
+
function mergeShorthands({ defaultProps }, { shorthands }) {
|
|
58
|
+
for (const key in defaultProps) {
|
|
59
|
+
defaultProps[shorthands[key] || key] = defaultProps[key];
|
|
59
60
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
}
|
|
62
|
+
__name(mergeShorthands, "mergeShorthands");
|
|
63
|
+
let initialTheme;
|
|
64
|
+
function createComponent(configIn, ParentComponent) {
|
|
65
|
+
const staticConfig = (() => {
|
|
66
|
+
const config = extendStaticConfig(configIn, ParentComponent);
|
|
67
|
+
if ("parsed" in config) {
|
|
68
|
+
return config;
|
|
69
|
+
} else {
|
|
70
|
+
return parseStaticConfig(config);
|
|
71
|
+
}
|
|
72
|
+
})();
|
|
73
|
+
const componentClassName = `is_${staticConfig.componentName}`;
|
|
63
74
|
let tamaguiConfig;
|
|
64
75
|
let AnimatedText;
|
|
65
76
|
let AnimatedView;
|
|
66
|
-
let avoidClasses =
|
|
67
|
-
let defaultPseudos = {};
|
|
77
|
+
let avoidClasses = true;
|
|
68
78
|
let defaultNativeStyle;
|
|
69
|
-
let defaultNativeStyleSheet
|
|
70
|
-
let
|
|
71
|
-
let
|
|
72
|
-
let splitStyleResult = null;
|
|
79
|
+
let defaultNativeStyleSheet;
|
|
80
|
+
let tamaguiDefaultProps;
|
|
81
|
+
let initialSplitStyles;
|
|
73
82
|
function addPseudoToStyles(styles, name, pseudos) {
|
|
74
83
|
const pseudoStyle = pseudos[name];
|
|
84
|
+
const shouldNestObject = isWeb && name !== "enterStyle" && name !== "exitStyle";
|
|
75
85
|
if (pseudoStyle) {
|
|
76
|
-
styles.push(
|
|
86
|
+
styles.push(shouldNestObject ? { [name]: pseudoStyle } : pseudoStyle);
|
|
77
87
|
}
|
|
78
|
-
const defaultPseudoStyle =
|
|
88
|
+
const defaultPseudoStyle = initialSplitStyles.pseudos[name];
|
|
79
89
|
if (defaultPseudoStyle) {
|
|
80
|
-
styles.push(
|
|
90
|
+
styles.push(shouldNestObject ? { [name]: defaultPseudoStyle } : defaultPseudoStyle);
|
|
81
91
|
}
|
|
82
92
|
}
|
|
83
93
|
__name(addPseudoToStyles, "addPseudoToStyles");
|
|
84
94
|
const component = forwardRef((props, forwardedRef) => {
|
|
85
95
|
var _a, _b, _c, _d;
|
|
96
|
+
props = tamaguiDefaultProps ? { ...tamaguiDefaultProps, ...props } : props;
|
|
97
|
+
const { Component, componentName, isText, isZStack } = staticConfig;
|
|
86
98
|
if (process.env.NODE_ENV === "development") {
|
|
87
99
|
if (props["debug"]) {
|
|
88
|
-
console.warn(componentName || (Component == null ? void 0 : Component.displayName) || (Component == null ? void 0 : Component.name) || "[Unnamed Component]", "
|
|
100
|
+
console.warn(staticConfig.componentName || (Component == null ? void 0 : Component.displayName) || (Component == null ? void 0 : Component.name) || "[Unnamed Component]", "debug on");
|
|
101
|
+
console.log("props in:", props, Object.keys(props));
|
|
89
102
|
if (props["debug"] === "break")
|
|
90
103
|
debugger;
|
|
91
104
|
}
|
|
92
105
|
}
|
|
93
106
|
const forceUpdate = useForceUpdate();
|
|
94
|
-
const theme = useTheme(props.theme, componentName, props, forceUpdate);
|
|
107
|
+
const theme = useTheme(props.theme, staticConfig.componentName, props, forceUpdate);
|
|
95
108
|
const [state, set_] = useState(defaultComponentState);
|
|
96
109
|
const setStateShallow = createShallowUpdate(set_);
|
|
97
|
-
const shouldAvoidClasses = !!(
|
|
98
|
-
const
|
|
99
|
-
const { viewProps: viewPropsIn, pseudos, medias, style, classNames } =
|
|
110
|
+
const shouldAvoidClasses = !!(props.animation && avoidClasses);
|
|
111
|
+
const splitStyles = useSplitStyles(props, staticConfig, theme, shouldAvoidClasses ? { ...state, noClassNames: true, resolveVariablesAs: "value" } : state, shouldAvoidClasses ? null : initialSplitStyles.classNames);
|
|
112
|
+
const { viewProps: viewPropsIn, pseudos, medias, style, classNames } = splitStyles;
|
|
100
113
|
const useAnimations = (_a = tamaguiConfig.animations) == null ? void 0 : _a.useAnimations;
|
|
101
114
|
const isAnimated = !!(useAnimations && props.animation);
|
|
102
|
-
const
|
|
115
|
+
const hasEnterStyle = !!props.enterStyle;
|
|
103
116
|
const features = useFeatures(props, {
|
|
104
117
|
forceUpdate,
|
|
105
118
|
setStateShallow,
|
|
106
119
|
useAnimations,
|
|
107
120
|
state,
|
|
108
|
-
style:
|
|
109
|
-
pseudos
|
|
121
|
+
style: props.animation ? { ...defaultNativeStyle, ...style } : null,
|
|
122
|
+
pseudos,
|
|
123
|
+
staticConfig,
|
|
124
|
+
theme,
|
|
125
|
+
onDidAnimate: props.onDidAnimate
|
|
110
126
|
});
|
|
111
127
|
const {
|
|
112
128
|
tag,
|
|
@@ -145,6 +161,7 @@ function createComponent(configIn) {
|
|
|
145
161
|
accessibilityRole,
|
|
146
162
|
collapsable,
|
|
147
163
|
focusable,
|
|
164
|
+
onClick,
|
|
148
165
|
theme: _themeProp,
|
|
149
166
|
defaultVariants,
|
|
150
167
|
onLayout,
|
|
@@ -160,15 +177,14 @@ function createComponent(configIn) {
|
|
|
160
177
|
}
|
|
161
178
|
const hasTextAncestor = isWeb ? useContext(TextAncestorContext) : false;
|
|
162
179
|
const hostRef = useRef(null);
|
|
163
|
-
const hasEnterStyle = !!props.enterStyle;
|
|
164
180
|
const internal = useRef();
|
|
165
181
|
if (!internal.current) {
|
|
166
182
|
internal.current = {
|
|
167
183
|
isMounted: true
|
|
168
184
|
};
|
|
169
185
|
}
|
|
170
|
-
|
|
171
|
-
if (hasEnterStyle) {
|
|
186
|
+
useIsomorphicLayoutEffect(() => {
|
|
187
|
+
if (typeof window !== "undefined" && (hasEnterStyle || props.animation)) {
|
|
172
188
|
setStateShallow({
|
|
173
189
|
mounted: true
|
|
174
190
|
});
|
|
@@ -178,7 +194,7 @@ function createComponent(configIn) {
|
|
|
178
194
|
mouseUps.delete(unPress);
|
|
179
195
|
internal.current.isMounted = false;
|
|
180
196
|
};
|
|
181
|
-
}, []);
|
|
197
|
+
}, [hasEnterStyle, props.animation]);
|
|
182
198
|
if (nativeID) {
|
|
183
199
|
viewProps.id = nativeID;
|
|
184
200
|
}
|
|
@@ -236,6 +252,7 @@ function createComponent(configIn) {
|
|
|
236
252
|
medias
|
|
237
253
|
];
|
|
238
254
|
if (!animationStyles) {
|
|
255
|
+
!state.mounted && addPseudoToStyles(styles, "enterStyle", pseudos);
|
|
239
256
|
state.hover && addPseudoToStyles(styles, "hoverStyle", pseudos);
|
|
240
257
|
state.focus && addPseudoToStyles(styles, "focusStyle", pseudos);
|
|
241
258
|
state.press && addPseudoToStyles(styles, "pressStyle", pseudos);
|
|
@@ -254,10 +271,11 @@ function createComponent(configIn) {
|
|
|
254
271
|
const className = classList.join(" ");
|
|
255
272
|
if (process.env.NODE_ENV === "development") {
|
|
256
273
|
if (props["debug"]) {
|
|
257
|
-
console.log(" \xBB className", { isStringElement, pseudos, state,
|
|
274
|
+
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
275
|
}
|
|
259
276
|
}
|
|
260
277
|
viewProps.className = className;
|
|
278
|
+
viewProps.style = animationStyles;
|
|
261
279
|
} else {
|
|
262
280
|
viewProps.style = styles;
|
|
263
281
|
}
|
|
@@ -294,8 +312,10 @@ function createComponent(configIn) {
|
|
|
294
312
|
viewProps.ref = forwardedRef;
|
|
295
313
|
}
|
|
296
314
|
}
|
|
297
|
-
const
|
|
298
|
-
const
|
|
315
|
+
const initialPseudos = initialSplitStyles.pseudos;
|
|
316
|
+
const attachPress = !!(pseudos && pseudos.pressStyle || initialPseudos && initialPseudos.pressStyle || onPress || onPressOut || onPressIn || onClick);
|
|
317
|
+
const isTouch = useIsTouchDevice();
|
|
318
|
+
const isHoverable = isWeb && !isTouch;
|
|
299
319
|
const attachHover = isHoverable && !!(pseudos && pseudos.hoverStyle || onHoverIn || onHoverOut || onMouseEnter || onMouseLeave);
|
|
300
320
|
const pressEventKey = isStringElement ? "onClick" : "onPress";
|
|
301
321
|
const shouldAttach = 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);
|
|
@@ -353,8 +373,12 @@ function createComponent(configIn) {
|
|
|
353
373
|
});
|
|
354
374
|
onPressIn == null ? void 0 : onPressIn(e);
|
|
355
375
|
onMouseDown == null ? void 0 : onMouseDown(e);
|
|
376
|
+
if (isWeb) {
|
|
377
|
+
mouseUps.add(unPress);
|
|
378
|
+
}
|
|
356
379
|
} : null,
|
|
357
380
|
[pressEventKey]: attachPress ? (e) => {
|
|
381
|
+
onClick == null ? void 0 : onClick(e);
|
|
358
382
|
onPress == null ? void 0 : onPress(e);
|
|
359
383
|
unPress();
|
|
360
384
|
onPressOut == null ? void 0 : onPressOut(e);
|
|
@@ -377,18 +401,6 @@ function createComponent(configIn) {
|
|
|
377
401
|
} : {
|
|
378
402
|
disabled: true
|
|
379
403
|
});
|
|
380
|
-
if (events) {
|
|
381
|
-
if (!isStringElement) {
|
|
382
|
-
Object.assign(viewProps, pressProps);
|
|
383
|
-
} else {
|
|
384
|
-
Object.assign(viewProps, events);
|
|
385
|
-
}
|
|
386
|
-
if (isWeb && isHoverable) {
|
|
387
|
-
childEls = <span style={{
|
|
388
|
-
display: "contents"
|
|
389
|
-
}} onMouseEnter={events.onMouseEnter} onMouseLeave={events.onMouseLeave}>{children}</span>;
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
404
|
let content;
|
|
393
405
|
if (isWeb) {
|
|
394
406
|
if (staticConfig.isReactNativeWeb) {
|
|
@@ -405,11 +417,23 @@ function createComponent(configIn) {
|
|
|
405
417
|
}
|
|
406
418
|
}
|
|
407
419
|
}
|
|
420
|
+
if (events) {
|
|
421
|
+
if (!isStringElement) {
|
|
422
|
+
Object.assign(viewProps, pressProps);
|
|
423
|
+
} else {
|
|
424
|
+
Object.assign(viewProps, events);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
408
427
|
content = createElement(ViewComponent, viewProps, childEls);
|
|
428
|
+
if (isWeb && events && attachHover) {
|
|
429
|
+
content = <span className="tui_Hoverable" style={{
|
|
430
|
+
display: "contents"
|
|
431
|
+
}} onMouseEnter={events.onMouseEnter} onMouseLeave={events.onMouseLeave}>{content}</span>;
|
|
432
|
+
}
|
|
409
433
|
if (process.env.NODE_ENV === "development") {
|
|
410
434
|
if (props["debug"]) {
|
|
411
435
|
viewProps["debug"] = true;
|
|
412
|
-
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,
|
|
436
|
+
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 });
|
|
413
437
|
}
|
|
414
438
|
}
|
|
415
439
|
if (features.length) {
|
|
@@ -420,23 +444,28 @@ function createComponent(configIn) {
|
|
|
420
444
|
}
|
|
421
445
|
return content;
|
|
422
446
|
});
|
|
447
|
+
component.displayName = staticConfig.componentName;
|
|
423
448
|
onConfiguredOnce((conf) => {
|
|
424
449
|
var _a, _b, _c, _d;
|
|
425
|
-
|
|
450
|
+
if (process.env.IS_STATIC === "is_static") {
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
426
453
|
tamaguiConfig = conf;
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
454
|
+
mergeShorthands(staticConfig, tamaguiConfig);
|
|
455
|
+
avoidClasses = !!((_a = tamaguiConfig.animations) == null ? void 0 : _a.avoidClasses);
|
|
456
|
+
AnimatedText = (_b = tamaguiConfig.animations) == null ? void 0 : _b.Text;
|
|
457
|
+
AnimatedView = (_c = tamaguiConfig == null ? void 0 : tamaguiConfig.animations) == null ? void 0 : _c.View;
|
|
458
|
+
initialTheme = initialTheme || proxyThemeVariables(conf.themes[conf.defaultTheme || Object.keys(conf.themes)[0]]);
|
|
459
|
+
initialSplitStyles = insertSplitStyles(staticConfig.defaultProps, staticConfig, initialTheme, {
|
|
432
460
|
mounted: true,
|
|
433
|
-
|
|
461
|
+
hover: false,
|
|
462
|
+
press: false,
|
|
463
|
+
pressIn: false,
|
|
464
|
+
focus: false,
|
|
465
|
+
resolveVariablesAs: "both",
|
|
466
|
+
keepVariantsAsProps: true
|
|
434
467
|
});
|
|
435
|
-
const {
|
|
436
|
-
if (isWeb) {
|
|
437
|
-
defaultsClassName = classNames;
|
|
438
|
-
}
|
|
439
|
-
defaultPseudos = pseudos;
|
|
468
|
+
const { style, viewProps } = initialSplitStyles;
|
|
440
469
|
defaultNativeStyle = {};
|
|
441
470
|
for (const key in style) {
|
|
442
471
|
const v = style[key];
|
|
@@ -445,13 +474,20 @@ function createComponent(configIn) {
|
|
|
445
474
|
defaultNativeStyleSheet = StyleSheet.create({
|
|
446
475
|
base: defaultNativeStyle
|
|
447
476
|
});
|
|
448
|
-
|
|
449
|
-
component.defaultProps = {
|
|
477
|
+
const defaults = {
|
|
450
478
|
...viewProps,
|
|
451
479
|
...component.defaultProps
|
|
452
480
|
};
|
|
453
|
-
if (
|
|
454
|
-
|
|
481
|
+
if (Object.keys(defaults).length) {
|
|
482
|
+
tamaguiDefaultProps = defaults;
|
|
483
|
+
}
|
|
484
|
+
if (process.env.NODE_ENV === "development" && ((_d = staticConfig.defaultProps) == null ? void 0 : _d.debug)) {
|
|
485
|
+
if (process.env.IS_STATIC !== "is_static") {
|
|
486
|
+
console.log(`\u{1F41B} [${staticConfig.componentName || "Component"}]`, {
|
|
487
|
+
staticConfig,
|
|
488
|
+
initialSplitStyles
|
|
489
|
+
});
|
|
490
|
+
}
|
|
455
491
|
}
|
|
456
492
|
});
|
|
457
493
|
let res = component;
|
|
@@ -459,25 +495,30 @@ function createComponent(configIn) {
|
|
|
459
495
|
res = memo(res);
|
|
460
496
|
}
|
|
461
497
|
res["staticConfig"] = {
|
|
462
|
-
validStyles:
|
|
498
|
+
validStyles: staticConfig.validStyles || stylePropsView,
|
|
463
499
|
...staticConfig
|
|
464
500
|
};
|
|
465
|
-
|
|
466
|
-
|
|
501
|
+
if (process.env.NODE_ENV === "development") {
|
|
502
|
+
res["whyDidYouRender"] = true;
|
|
503
|
+
}
|
|
504
|
+
res["extractable"] = (Component, conf) => {
|
|
505
|
+
Component["staticConfig"] = extendStaticConfig({
|
|
506
|
+
Component,
|
|
467
507
|
...conf,
|
|
468
508
|
neverFlatten: true,
|
|
469
509
|
defaultProps: {
|
|
470
|
-
...
|
|
510
|
+
...Component.defaultProps,
|
|
471
511
|
...conf == null ? void 0 : conf.defaultProps
|
|
472
512
|
}
|
|
473
|
-
});
|
|
474
|
-
return
|
|
513
|
+
}, res);
|
|
514
|
+
return Component;
|
|
475
515
|
};
|
|
476
516
|
return res;
|
|
477
517
|
}
|
|
478
518
|
__name(createComponent, "createComponent");
|
|
479
519
|
const Spacer = createComponent({
|
|
480
520
|
memo: true,
|
|
521
|
+
componentName: "Spacer",
|
|
481
522
|
defaultProps: {
|
|
482
523
|
...stackDefaultStyles,
|
|
483
524
|
size: true
|
|
@@ -550,45 +591,16 @@ function spacedChildren({
|
|
|
550
591
|
return next;
|
|
551
592
|
}
|
|
552
593
|
__name(spacedChildren, "spacedChildren");
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
const val = cur[key];
|
|
564
|
-
if (key !== "transform") {
|
|
565
|
-
if (!(key in res)) {
|
|
566
|
-
res[key] = val;
|
|
567
|
-
}
|
|
568
|
-
continue;
|
|
569
|
-
}
|
|
570
|
-
if (!res.transform) {
|
|
571
|
-
res.transform = val;
|
|
572
|
-
continue;
|
|
573
|
-
}
|
|
574
|
-
for (const t of val) {
|
|
575
|
-
const tkey = Object.keys(t)[0];
|
|
576
|
-
if (res.transform.find((existing) => tkey in existing)) {
|
|
577
|
-
continue;
|
|
578
|
-
}
|
|
579
|
-
res.transform.push(t);
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
return res;
|
|
584
|
-
}, "merge");
|
|
585
|
-
const AbsoluteFill = /* @__PURE__ */ __name((props) => isWeb ? <div style={{
|
|
586
|
-
position: "absolute",
|
|
587
|
-
top: 0,
|
|
588
|
-
left: 0,
|
|
589
|
-
right: 0,
|
|
590
|
-
bottom: 0
|
|
591
|
-
}}>{props.children}</div> : <View style={StyleSheet.absoluteFill}>{props.child}</View>, "AbsoluteFill");
|
|
594
|
+
function AbsoluteFill(props) {
|
|
595
|
+
return isWeb ? <div style={{
|
|
596
|
+
position: "absolute",
|
|
597
|
+
top: 0,
|
|
598
|
+
left: 0,
|
|
599
|
+
right: 0,
|
|
600
|
+
bottom: 0
|
|
601
|
+
}}>{props.children}</div> : <View style={StyleSheet.absoluteFill}>{props.child}</View>;
|
|
602
|
+
}
|
|
603
|
+
__name(AbsoluteFill, "AbsoluteFill");
|
|
592
604
|
export {
|
|
593
605
|
AbsoluteFill,
|
|
594
606
|
Spacer,
|
|
@@ -12,6 +12,14 @@ function createTamagui(config) {
|
|
|
12
12
|
if (createdConfigs.has(config)) {
|
|
13
13
|
return config;
|
|
14
14
|
}
|
|
15
|
+
if (process.env.NODE_ENV === "development") {
|
|
16
|
+
if (!config.tokens) {
|
|
17
|
+
throw new Error(`No tokens provided to Tamagui config`);
|
|
18
|
+
}
|
|
19
|
+
if (!config.themes) {
|
|
20
|
+
throw new Error(`No themes provided to Tamagui config`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
15
23
|
if (getHasConfigured()) {
|
|
16
24
|
console.warn("Called createTamagui twice! Should never do so");
|
|
17
25
|
}
|
|
@@ -20,7 +28,7 @@ function createTamagui(config) {
|
|
|
20
28
|
defaultActive: config.mediaQueryDefaultActive
|
|
21
29
|
});
|
|
22
30
|
const themeConfig = (() => {
|
|
23
|
-
var _a, _b;
|
|
31
|
+
var _a, _b, _c;
|
|
24
32
|
let cssRules = [];
|
|
25
33
|
const varsByValue = /* @__PURE__ */ new Map();
|
|
26
34
|
if (isWeb) {
|
|
@@ -67,13 +75,16 @@ function createTamagui(config) {
|
|
|
67
75
|
}
|
|
68
76
|
if (isWeb) {
|
|
69
77
|
const isDarkOrLightBase = themeName === "dark" || themeName === "light";
|
|
70
|
-
const isDark = themeName.
|
|
78
|
+
const isDark = themeName.startsWith("dark");
|
|
71
79
|
const selector = `${CNP}${themeName}`;
|
|
72
|
-
const addDarkLightSels = hasDarkLight && !isDarkOrLightBase;
|
|
73
80
|
const selectors = [selector];
|
|
74
|
-
if (
|
|
81
|
+
if (hasDarkLight) {
|
|
75
82
|
const childSelector = `${CNP}${themeName.replace("dark_", "").replace("light_", "")}`;
|
|
76
|
-
const
|
|
83
|
+
const order = isDark ? ["dark", "light"] : ["light", "dark"];
|
|
84
|
+
if (isDarkOrLightBase) {
|
|
85
|
+
order.reverse();
|
|
86
|
+
}
|
|
87
|
+
const [stronger, weaker] = order;
|
|
77
88
|
const max = (_b = config.maxDarkLightNesting) != null ? _b : 3;
|
|
78
89
|
new Array(max * 2).fill(void 0).forEach((_, pi) => {
|
|
79
90
|
if (pi % 2 === 1)
|
|
@@ -84,25 +95,56 @@ function createTamagui(config) {
|
|
|
84
95
|
selectors.push(`${(parents.length > 1 ? parents.slice(1) : parents).join(" ")} ${childSelector}`);
|
|
85
96
|
});
|
|
86
97
|
}
|
|
87
|
-
const
|
|
88
|
-
${vars}
|
|
89
|
-
|
|
90
|
-
|
|
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
|
+
}
|
|
91
108
|
}
|
|
92
109
|
}
|
|
93
110
|
varsByValue.clear();
|
|
94
111
|
Object.freeze(cssRules);
|
|
112
|
+
const css = cssRules.join("\n");
|
|
95
113
|
return {
|
|
96
114
|
cssRules,
|
|
97
|
-
css
|
|
115
|
+
css
|
|
98
116
|
};
|
|
99
117
|
})();
|
|
100
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
|
+
})();
|
|
101
142
|
const getCSS = /* @__PURE__ */ __name(() => {
|
|
102
143
|
return `${themeConfig.css}
|
|
103
144
|
${getInsertedRules().join("\n")}`;
|
|
104
145
|
}, "getCSS");
|
|
105
146
|
const next = {
|
|
147
|
+
fonts: {},
|
|
106
148
|
animations: {},
|
|
107
149
|
shorthands: {},
|
|
108
150
|
media: {},
|
|
@@ -112,6 +154,7 @@ ${getInsertedRules().join("\n")}`;
|
|
|
112
154
|
defaultTheme: "light",
|
|
113
155
|
...config
|
|
114
156
|
}),
|
|
157
|
+
fontsParsed,
|
|
115
158
|
themeConfig,
|
|
116
159
|
tokensParsed,
|
|
117
160
|
parsed: true,
|
|
@@ -130,24 +173,6 @@ const parseTokens = /* @__PURE__ */ __name((tokens) => {
|
|
|
130
173
|
const res = {};
|
|
131
174
|
for (const key in tokens) {
|
|
132
175
|
res[key] = {};
|
|
133
|
-
if (key === "font") {
|
|
134
|
-
for (const family in tokens.font) {
|
|
135
|
-
const obj = {};
|
|
136
|
-
res.font[`$${family}`] = obj;
|
|
137
|
-
for (const attrKey in tokens.font[family]) {
|
|
138
|
-
const attr = tokens.font[family][attrKey];
|
|
139
|
-
if (attrKey === "family") {
|
|
140
|
-
obj[attrKey] = attr;
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
obj[attrKey] = Object.keys(attr).reduce((acc, cur) => {
|
|
144
|
-
acc[`$${cur}`] = attr[cur];
|
|
145
|
-
return acc;
|
|
146
|
-
}, {});
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
continue;
|
|
150
|
-
}
|
|
151
176
|
for (const skey in tokens[key]) {
|
|
152
177
|
res[key][`$${skey}`] = tokens[key][skey];
|
|
153
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
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as ReactNative from "react-native";
|
|
2
|
+
const RNComponents = /* @__PURE__ */ new WeakMap();
|
|
3
|
+
for (const key of ["Image", "TextInput", "Text", "View"]) {
|
|
4
|
+
const val = ReactNative[key];
|
|
5
|
+
if (val && typeof val === "object") {
|
|
6
|
+
RNComponents.set(val, true);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
RNComponents
|
|
11
|
+
};
|