@tamagui/web 1.26.0 → 1.27.0
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/helpers/createPropMapper.js +1 -11
- package/dist/cjs/helpers/createPropMapper.js.map +1 -1
- package/dist/cjs/helpers/createVariantContext.js +41 -0
- package/dist/cjs/helpers/createVariantContext.js.map +6 -0
- package/dist/cjs/helpers/getThemeCSSRules.js +3 -3
- package/dist/cjs/helpers/getThemeCSSRules.js.map +1 -1
- package/dist/esm/helpers/createPropMapper.js +1 -11
- package/dist/esm/helpers/createPropMapper.js.map +1 -1
- package/dist/esm/helpers/createVariantContext.js +17 -0
- package/dist/esm/helpers/createVariantContext.js.map +6 -0
- package/dist/esm/helpers/getThemeCSSRules.js +3 -3
- package/dist/esm/helpers/getThemeCSSRules.js.map +1 -1
- package/package.json +9 -9
- package/src/helpers/createPropMapper.ts +2 -12
- package/src/helpers/getThemeCSSRules.ts +6 -3
- package/src/types.tsx +5 -0
- package/types/helpers/createVariantContext.d.ts.map +1 -0
- package/types/helpers/getThemeCSSRules.d.ts.map +1 -1
- package/types/types.d.ts +1 -0
- package/types/types.d.ts.map +1 -1
- package/dist/cjs/helpers/accessibilityDirectMap.js +0 -76
- package/dist/cjs/helpers/accessibilityDirectMap.js.map +0 -6
- package/dist/cjs/helpers/memoizeArgumentsWeak.js +0 -57
- package/dist/cjs/helpers/memoizeArgumentsWeak.js.map +0 -6
- package/dist/cjs/helpers/memoizeFunctionByArgumentsReference.js +0 -31
- package/dist/cjs/helpers/memoizeFunctionByArgumentsReference.js.map +0 -6
- package/dist/esm/Tamagui.mjs +0 -45
- package/dist/esm/Tamagui.mjs.map +0 -6
- package/dist/esm/config.mjs +0 -90
- package/dist/esm/config.mjs.map +0 -6
- package/dist/esm/constants/accessibilityDirectMap.mjs +0 -52
- package/dist/esm/constants/accessibilityDirectMap.mjs.map +0 -6
- package/dist/esm/constants/constants.mjs +0 -22
- package/dist/esm/constants/constants.mjs.map +0 -6
- package/dist/esm/constants/isDevTools.mjs +0 -13
- package/dist/esm/constants/isDevTools.mjs.map +0 -6
- package/dist/esm/contexts/AnimationDriverContext.mjs +0 -6
- package/dist/esm/contexts/AnimationDriverContext.mjs.map +0 -6
- package/dist/esm/contexts/ButtonNestingContext.mjs +0 -6
- package/dist/esm/contexts/ButtonNestingContext.mjs.map +0 -6
- package/dist/esm/contexts/FontLanguageContext.mjs +0 -6
- package/dist/esm/contexts/FontLanguageContext.mjs.map +0 -6
- package/dist/esm/contexts/TextAncestorContext.mjs +0 -6
- package/dist/esm/contexts/TextAncestorContext.mjs.map +0 -6
- package/dist/esm/createComponent.mjs +0 -880
- package/dist/esm/createComponent.mjs.map +0 -6
- package/dist/esm/createFont.mjs +0 -45
- package/dist/esm/createFont.mjs.map +0 -6
- package/dist/esm/createShorthands.mjs +0 -7
- package/dist/esm/createShorthands.mjs.map +0 -6
- package/dist/esm/createTamagui.mjs +0 -203
- package/dist/esm/createTamagui.mjs.map +0 -6
- package/dist/esm/createTheme.mjs +0 -7
- package/dist/esm/createTheme.mjs.map +0 -6
- package/dist/esm/createTokens.mjs +0 -15
- package/dist/esm/createTokens.mjs.map +0 -6
- package/dist/esm/createVariable.mjs +0 -78
- package/dist/esm/createVariable.mjs.map +0 -6
- package/dist/esm/createVariables.mjs +0 -35
- package/dist/esm/createVariables.mjs.map +0 -6
- package/dist/esm/helpers/ThemeManager.mjs +0 -256
- package/dist/esm/helpers/ThemeManager.mjs.map +0 -6
- package/dist/esm/helpers/ThemeManagerContext.mjs +0 -6
- package/dist/esm/helpers/ThemeManagerContext.mjs.map +0 -6
- package/dist/esm/helpers/accessibilityDirectMap.js +0 -52
- package/dist/esm/helpers/accessibilityDirectMap.js.map +0 -6
- package/dist/esm/helpers/accessibilityDirectMap.mjs +0 -52
- package/dist/esm/helpers/accessibilityDirectMap.mjs.map +0 -6
- package/dist/esm/helpers/createChainedWeakCache.mjs +0 -39
- package/dist/esm/helpers/createChainedWeakCache.mjs.map +0 -6
- package/dist/esm/helpers/createMediaStyle.mjs +0 -42
- package/dist/esm/helpers/createMediaStyle.mjs.map +0 -6
- package/dist/esm/helpers/createPropMapper.mjs +0 -414
- package/dist/esm/helpers/createPropMapper.mjs.map +0 -6
- package/dist/esm/helpers/createProxy.mjs +0 -19
- package/dist/esm/helpers/createProxy.mjs.map +0 -6
- package/dist/esm/helpers/defaultOffset.mjs +0 -5
- package/dist/esm/helpers/defaultOffset.mjs.map +0 -6
- package/dist/esm/helpers/expandStyle.mjs +0 -65
- package/dist/esm/helpers/expandStyle.mjs.map +0 -6
- package/dist/esm/helpers/expandStyles.mjs +0 -52
- package/dist/esm/helpers/expandStyles.mjs.map +0 -6
- package/dist/esm/helpers/extendStaticConfig.mjs +0 -67
- package/dist/esm/helpers/extendStaticConfig.mjs.map +0 -6
- package/dist/esm/helpers/getAnimationDriver.mjs +0 -8
- package/dist/esm/helpers/getAnimationDriver.mjs.map +0 -6
- package/dist/esm/helpers/getExpandedShorthands.mjs +0 -15
- package/dist/esm/helpers/getExpandedShorthands.mjs.map +0 -6
- package/dist/esm/helpers/getFontLanguage.mjs +0 -5
- package/dist/esm/helpers/getFontLanguage.mjs.map +0 -6
- package/dist/esm/helpers/getSplitStyles.mjs +0 -879
- package/dist/esm/helpers/getSplitStyles.mjs.map +0 -6
- package/dist/esm/helpers/getStylesAtomic.mjs +0 -193
- package/dist/esm/helpers/getStylesAtomic.mjs.map +0 -6
- package/dist/esm/helpers/getStylesAtomic.native.mjs +0 -12
- package/dist/esm/helpers/getStylesAtomic.native.mjs.map +0 -6
- package/dist/esm/helpers/getThemeCSSRules.mjs +0 -113
- package/dist/esm/helpers/getThemeCSSRules.mjs.map +0 -6
- package/dist/esm/helpers/getThemeCSSRules.native.mjs +0 -7
- package/dist/esm/helpers/getThemeCSSRules.native.mjs.map +0 -6
- package/dist/esm/helpers/getVariantExtras.mjs +0 -67
- package/dist/esm/helpers/getVariantExtras.mjs.map +0 -6
- package/dist/esm/helpers/insertStyleRule.mjs +0 -191
- package/dist/esm/helpers/insertStyleRule.mjs.map +0 -6
- package/dist/esm/helpers/isObj.mjs +0 -5
- package/dist/esm/helpers/isObj.mjs.map +0 -6
- package/dist/esm/helpers/isTamaguiComponent.mjs +0 -8
- package/dist/esm/helpers/isTamaguiComponent.mjs.map +0 -6
- package/dist/esm/helpers/isTamaguiElement.mjs +0 -9
- package/dist/esm/helpers/isTamaguiElement.mjs.map +0 -6
- package/dist/esm/helpers/matchMedia.mjs +0 -17
- package/dist/esm/helpers/matchMedia.mjs.map +0 -6
- package/dist/esm/helpers/matchMedia.native.mjs +0 -23
- package/dist/esm/helpers/matchMedia.native.mjs.map +0 -6
- package/dist/esm/helpers/memoizeArgumentsWeak.js +0 -33
- package/dist/esm/helpers/memoizeArgumentsWeak.js.map +0 -6
- package/dist/esm/helpers/memoizeArgumentsWeak.mjs +0 -33
- package/dist/esm/helpers/memoizeArgumentsWeak.mjs.map +0 -6
- package/dist/esm/helpers/memoizeFunctionByArgumentsReference.js +0 -30
- package/dist/esm/helpers/memoizeFunctionByArgumentsReference.js.map +0 -6
- package/dist/esm/helpers/memoizeFunctionByArgumentsReference.mjs +0 -30
- package/dist/esm/helpers/memoizeFunctionByArgumentsReference.mjs.map +0 -6
- package/dist/esm/helpers/mergeProps.mjs +0 -40
- package/dist/esm/helpers/mergeProps.mjs.map +0 -6
- package/dist/esm/helpers/normalizeColor.mjs +0 -31
- package/dist/esm/helpers/normalizeColor.mjs.map +0 -6
- package/dist/esm/helpers/normalizeShadow.mjs +0 -23
- package/dist/esm/helpers/normalizeShadow.mjs.map +0 -6
- package/dist/esm/helpers/normalizeShadow.native.mjs +0 -31
- package/dist/esm/helpers/normalizeShadow.native.mjs.map +0 -6
- package/dist/esm/helpers/normalizeStylePropKeys.mjs +0 -5
- package/dist/esm/helpers/normalizeStylePropKeys.mjs.map +0 -6
- package/dist/esm/helpers/normalizeStylePropKeys.native.mjs +0 -16
- package/dist/esm/helpers/normalizeStylePropKeys.native.mjs.map +0 -6
- package/dist/esm/helpers/normalizeValueWithProperty.mjs +0 -110
- package/dist/esm/helpers/normalizeValueWithProperty.mjs.map +0 -6
- package/dist/esm/helpers/proxyThemeVariables.mjs +0 -16
- package/dist/esm/helpers/proxyThemeVariables.mjs.map +0 -6
- package/dist/esm/helpers/pseudoDescriptors.mjs +0 -29
- package/dist/esm/helpers/pseudoDescriptors.mjs.map +0 -6
- package/dist/esm/helpers/registerCSSVariable.mjs +0 -14
- package/dist/esm/helpers/registerCSSVariable.mjs.map +0 -6
- package/dist/esm/helpers/themeable.mjs +0 -28
- package/dist/esm/helpers/themeable.mjs.map +0 -6
- package/dist/esm/helpers/themes.mjs +0 -51
- package/dist/esm/helpers/themes.mjs.map +0 -6
- package/dist/esm/helpers/timer.mjs +0 -11
- package/dist/esm/helpers/timer.mjs.map +0 -6
- package/dist/esm/helpers/useShallowSetState.mjs +0 -23
- package/dist/esm/helpers/useShallowSetState.mjs.map +0 -6
- package/dist/esm/helpers/warnOnce.mjs +0 -14
- package/dist/esm/helpers/warnOnce.mjs.map +0 -6
- package/dist/esm/helpers/withStaticProperties.mjs +0 -9
- package/dist/esm/helpers/withStaticProperties.mjs.map +0 -6
- package/dist/esm/hooks/getThemeUnwrapped.mjs +0 -9
- package/dist/esm/hooks/getThemeUnwrapped.mjs.map +0 -6
- package/dist/esm/hooks/useAnimationDriver.mjs +0 -13
- package/dist/esm/hooks/useAnimationDriver.mjs.map +0 -6
- package/dist/esm/hooks/useId.mjs +0 -5
- package/dist/esm/hooks/useId.mjs.map +0 -6
- package/dist/esm/hooks/useIsTouchDevice.mjs +0 -9
- package/dist/esm/hooks/useIsTouchDevice.mjs.map +0 -6
- package/dist/esm/hooks/useMedia.mjs +0 -233
- package/dist/esm/hooks/useMedia.mjs.map +0 -6
- package/dist/esm/hooks/useProps.mjs +0 -10
- package/dist/esm/hooks/useProps.mjs.map +0 -6
- package/dist/esm/hooks/useSafeRef.mjs +0 -35
- package/dist/esm/hooks/useSafeRef.mjs.map +0 -6
- package/dist/esm/hooks/useServerHooks.mjs +0 -11
- package/dist/esm/hooks/useServerHooks.mjs.map +0 -6
- package/dist/esm/hooks/useStyle.mjs +0 -37
- package/dist/esm/hooks/useStyle.mjs.map +0 -6
- package/dist/esm/hooks/useTheme.mjs +0 -282
- package/dist/esm/hooks/useTheme.mjs.map +0 -6
- package/dist/esm/hooks/useThemeName.mjs +0 -28
- package/dist/esm/hooks/useThemeName.mjs.map +0 -6
- package/dist/esm/index.mjs +0 -87
- package/dist/esm/index.mjs.map +0 -6
- package/dist/esm/inject-styles.mjs +0 -16
- package/dist/esm/inject-styles.mjs.map +0 -6
- package/dist/esm/insertFont.mjs +0 -67
- package/dist/esm/insertFont.mjs.map +0 -6
- package/dist/esm/setupHooks.mjs +0 -9
- package/dist/esm/setupHooks.mjs.map +0 -6
- package/dist/esm/setupReactNative.mjs +0 -25
- package/dist/esm/setupReactNative.mjs.map +0 -6
- package/dist/esm/styled.mjs +0 -89
- package/dist/esm/styled.mjs.map +0 -6
- package/dist/esm/types.mjs +0 -1
- package/dist/esm/types.mjs.map +0 -6
- package/dist/esm/views/AnimationDriverProvider.mjs +0 -9
- package/dist/esm/views/AnimationDriverProvider.mjs.map +0 -6
- package/dist/esm/views/FontLanguage.mjs +0 -17
- package/dist/esm/views/FontLanguage.mjs.map +0 -6
- package/dist/esm/views/FontLanguage.native.mjs +0 -11
- package/dist/esm/views/FontLanguage.native.mjs.map +0 -6
- package/dist/esm/views/FontLanguage.types.mjs +0 -1
- package/dist/esm/views/FontLanguage.types.mjs.map +0 -6
- package/dist/esm/views/Slot.mjs +0 -66
- package/dist/esm/views/Slot.mjs.map +0 -6
- package/dist/esm/views/Stack.mjs +0 -13
- package/dist/esm/views/Stack.mjs.map +0 -6
- package/dist/esm/views/TamaguiProvider.mjs +0 -57
- package/dist/esm/views/TamaguiProvider.mjs.map +0 -6
- package/dist/esm/views/Text.mjs +0 -71
- package/dist/esm/views/Text.mjs.map +0 -6
- package/dist/esm/views/Theme.mjs +0 -75
- package/dist/esm/views/Theme.mjs.map +0 -6
- package/dist/esm/views/ThemeDebug.mjs +0 -96
- package/dist/esm/views/ThemeDebug.mjs.map +0 -6
- package/dist/esm/views/ThemeDebug.native.mjs +0 -11
- package/dist/esm/views/ThemeDebug.native.mjs.map +0 -6
- package/dist/esm/views/ThemeProvider.mjs +0 -45
- package/dist/esm/views/ThemeProvider.mjs.map +0 -6
- package/types/helpers/accessibilityDirectMap.d.ts +0 -2
- package/types/helpers/accessibilityDirectMap.d.ts.map +0 -1
- package/types/helpers/memoizeArgumentsWeak.d.ts +0 -5
- package/types/helpers/memoizeArgumentsWeak.d.ts.map +0 -1
- package/types/helpers/memoizeFunctionByArgumentsReference.d.ts +0 -11
- package/types/helpers/memoizeFunctionByArgumentsReference.d.ts.map +0 -1
|
@@ -1,880 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useComposedRefs } from "@tamagui/compose-refs";
|
|
3
|
-
import {
|
|
4
|
-
isClient,
|
|
5
|
-
isRSC,
|
|
6
|
-
isServer,
|
|
7
|
-
isWeb,
|
|
8
|
-
useIsomorphicLayoutEffect
|
|
9
|
-
} from "@tamagui/constants";
|
|
10
|
-
import { stylePropsView, validStyles } from "@tamagui/helpers";
|
|
11
|
-
import React, {
|
|
12
|
-
Children,
|
|
13
|
-
Fragment,
|
|
14
|
-
createElement,
|
|
15
|
-
forwardRef,
|
|
16
|
-
memo,
|
|
17
|
-
useCallback,
|
|
18
|
-
useContext,
|
|
19
|
-
useId,
|
|
20
|
-
useRef
|
|
21
|
-
} from "react";
|
|
22
|
-
import { onConfiguredOnce } from "./config";
|
|
23
|
-
import { stackDefaultStyles } from "./constants/constants";
|
|
24
|
-
import { FontLanguageContext } from "./contexts/FontLanguageContext";
|
|
25
|
-
import { TextAncestorContext } from "./contexts/TextAncestorContext";
|
|
26
|
-
import { didGetVariableValue, setDidGetVariableValue } from "./createVariable";
|
|
27
|
-
import { extendStaticConfig, parseStaticConfig } from "./helpers/extendStaticConfig";
|
|
28
|
-
import { useSplitStyles } from "./helpers/getSplitStyles";
|
|
29
|
-
import { mergeProps } from "./helpers/mergeProps";
|
|
30
|
-
import { proxyThemeVariables } from "./helpers/proxyThemeVariables";
|
|
31
|
-
import { themeable } from "./helpers/themeable";
|
|
32
|
-
import { useShallowSetState } from "./helpers/useShallowSetState";
|
|
33
|
-
import { useAnimationDriver } from "./hooks/useAnimationDriver";
|
|
34
|
-
import { setMediaShouldUpdate, useMedia } from "./hooks/useMedia";
|
|
35
|
-
import { useServerRef, useServerState } from "./hooks/useServerHooks";
|
|
36
|
-
import { useThemeWithState } from "./hooks/useTheme";
|
|
37
|
-
import { hooks } from "./setupHooks";
|
|
38
|
-
import { Slot } from "./views/Slot";
|
|
39
|
-
import { useThemedChildren } from "./views/Theme";
|
|
40
|
-
import { ThemeDebug } from "./views/ThemeDebug";
|
|
41
|
-
process.env.TAMAGUI_TARGET;
|
|
42
|
-
const defaultComponentState = {
|
|
43
|
-
hover: false,
|
|
44
|
-
press: false,
|
|
45
|
-
pressIn: false,
|
|
46
|
-
focus: false,
|
|
47
|
-
unmounted: true
|
|
48
|
-
};
|
|
49
|
-
const defaultComponentStateMounted = {
|
|
50
|
-
...defaultComponentState,
|
|
51
|
-
unmounted: false
|
|
52
|
-
};
|
|
53
|
-
const HYDRATION_CUTOFF = process.env.TAMAGUI_ANIMATED_PRESENCE_HYDRATION_CUTOFF ? +process.env.TAMAGUI_ANIMATED_PRESENCE_HYDRATION_CUTOFF : 5;
|
|
54
|
-
let tamaguiConfig;
|
|
55
|
-
let AnimatedText;
|
|
56
|
-
let AnimatedView;
|
|
57
|
-
let initialTheme;
|
|
58
|
-
const mouseUps = /* @__PURE__ */ new Set();
|
|
59
|
-
if (typeof document !== "undefined") {
|
|
60
|
-
const cancelTouches = () => {
|
|
61
|
-
mouseUps.forEach((x) => x());
|
|
62
|
-
mouseUps.clear();
|
|
63
|
-
};
|
|
64
|
-
addEventListener("mouseup", cancelTouches);
|
|
65
|
-
addEventListener("touchend", cancelTouches);
|
|
66
|
-
addEventListener("touchcancel", cancelTouches);
|
|
67
|
-
}
|
|
68
|
-
let BaseText;
|
|
69
|
-
let BaseView;
|
|
70
|
-
let hasSetupBaseViews = false;
|
|
71
|
-
const numRenderedOfType = {};
|
|
72
|
-
function createComponent(configIn, ParentComponent) {
|
|
73
|
-
const staticConfig = (() => {
|
|
74
|
-
const next = extendStaticConfig(configIn, ParentComponent);
|
|
75
|
-
if ("parsed" in next) {
|
|
76
|
-
return next;
|
|
77
|
-
} else {
|
|
78
|
-
return parseStaticConfig(next);
|
|
79
|
-
}
|
|
80
|
-
})();
|
|
81
|
-
const { isHOC } = staticConfig;
|
|
82
|
-
const defaultComponentClassName = `is_${staticConfig.componentName}`;
|
|
83
|
-
let defaultProps;
|
|
84
|
-
let defaultTag;
|
|
85
|
-
const component = forwardRef((propsIn, forwardedRef) => {
|
|
86
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
87
|
-
if (process.env.TAMAGUI_TARGET === "native") {
|
|
88
|
-
if (!hasSetupBaseViews) {
|
|
89
|
-
hasSetupBaseViews = true;
|
|
90
|
-
const baseViews = (_b = (_a = hooks).getBaseViews) == null ? void 0 : _b.call(_a);
|
|
91
|
-
if (baseViews) {
|
|
92
|
-
BaseText = baseViews.Text;
|
|
93
|
-
BaseView = baseViews.View;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
if (process.env.NODE_ENV === "test") {
|
|
98
|
-
if (propsIn["data-test-renders"]) {
|
|
99
|
-
propsIn["data-test-renders"]["current"] ??= 0;
|
|
100
|
-
propsIn["data-test-renders"]["current"] += 1;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
let props;
|
|
104
|
-
if (defaultProps && !propsIn.asChild) {
|
|
105
|
-
props = mergeProps(defaultProps, propsIn)[0];
|
|
106
|
-
} else {
|
|
107
|
-
props = propsIn;
|
|
108
|
-
}
|
|
109
|
-
const debugProp = props["debug"];
|
|
110
|
-
const { Component, isText, isZStack } = staticConfig;
|
|
111
|
-
const componentName = props.componentName || staticConfig.componentName;
|
|
112
|
-
const stateRef = useRef(
|
|
113
|
-
void 0
|
|
114
|
-
);
|
|
115
|
-
stateRef.current ||= {};
|
|
116
|
-
const hostRef = useServerRef(null);
|
|
117
|
-
const animationsConfig = useAnimationDriver();
|
|
118
|
-
const useAnimations = animationsConfig == null ? void 0 : animationsConfig.useAnimations;
|
|
119
|
-
const hasAnimationProp = props.animation || props.style && hasAnimatedStyleValue(props.style);
|
|
120
|
-
const willBeAnimated = (() => {
|
|
121
|
-
if (isServer)
|
|
122
|
-
return false;
|
|
123
|
-
const next = !!(hasAnimationProp && !isHOC && useAnimations);
|
|
124
|
-
if (next && !stateRef.current.hasAnimated) {
|
|
125
|
-
stateRef.current.hasAnimated = true;
|
|
126
|
-
}
|
|
127
|
-
return next || stateRef.current.hasAnimated;
|
|
128
|
-
})();
|
|
129
|
-
const usePresence = animationsConfig == null ? void 0 : animationsConfig.usePresence;
|
|
130
|
-
const presence = !isRSC && willBeAnimated && usePresence ? usePresence() : null;
|
|
131
|
-
const hasEnterStyle = !!props.enterStyle;
|
|
132
|
-
const needsMount = Boolean((isWeb ? isClient : true) && willBeAnimated);
|
|
133
|
-
const states = useServerState(
|
|
134
|
-
needsMount ? defaultComponentState : defaultComponentStateMounted
|
|
135
|
-
);
|
|
136
|
-
const state = propsIn.forceStyle ? { ...states[0], [propsIn.forceStyle]: true } : states[0];
|
|
137
|
-
const setState = states[1];
|
|
138
|
-
const setStateShallow = useShallowSetState(setState, debugProp, componentName);
|
|
139
|
-
let hasHydrated = false;
|
|
140
|
-
numRenderedOfType[componentName] ??= 0;
|
|
141
|
-
if (willBeAnimated) {
|
|
142
|
-
if (++numRenderedOfType[componentName] > HYDRATION_CUTOFF) {
|
|
143
|
-
hasHydrated = true;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
let isAnimated = willBeAnimated;
|
|
147
|
-
if (presence && hasHydrated) {
|
|
148
|
-
} else {
|
|
149
|
-
if (isAnimated && (isServer || state.unmounted === true)) {
|
|
150
|
-
isAnimated = false;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
const componentClassName = props.asChild ? "" : props.componentName ? `is_${props.componentName}` : defaultComponentClassName;
|
|
154
|
-
const hasTextAncestor = !!(isWeb && isText ? useContext(TextAncestorContext) : false);
|
|
155
|
-
const languageContext = isRSC ? null : useContext(FontLanguageContext);
|
|
156
|
-
const isDisabled = props.disabled ?? ((_c = props.accessibilityState) == null ? void 0 : _c.disabled);
|
|
157
|
-
const isTaggable = !Component || typeof Component === "string";
|
|
158
|
-
const element = isWeb ? isTaggable ? props.tag || defaultTag || Component : Component : Component;
|
|
159
|
-
const BaseTextComponent = BaseText || element || "span";
|
|
160
|
-
const BaseViewComponent = BaseView || element || (hasTextAncestor ? "span" : "div");
|
|
161
|
-
AnimatedText = animationsConfig ? animationsConfig.Text : BaseTextComponent;
|
|
162
|
-
AnimatedView = animationsConfig ? animationsConfig.View : BaseViewComponent;
|
|
163
|
-
let elementType = isText ? (isAnimated ? AnimatedText : null) || BaseTextComponent : (isAnimated ? AnimatedView : null) || BaseViewComponent;
|
|
164
|
-
const avoidClassesWhileAnimating = animationsConfig == null ? void 0 : animationsConfig.isReactNative;
|
|
165
|
-
if (isAnimated && presence) {
|
|
166
|
-
const presenceState = presence[2];
|
|
167
|
-
if (presenceState) {
|
|
168
|
-
if (state.unmounted && presenceState.enterVariant) {
|
|
169
|
-
props[presenceState.enterVariant] = true;
|
|
170
|
-
}
|
|
171
|
-
if (!presenceState.isPresent && presenceState.exitVariant) {
|
|
172
|
-
props[presenceState.exitVariant] = true;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
const isAnimatedReactNative = isAnimated && (animationsConfig == null ? void 0 : animationsConfig.isReactNative);
|
|
177
|
-
const isReactNative = Boolean(staticConfig.isReactNative || isAnimatedReactNative);
|
|
178
|
-
const shouldAvoidClasses = !isWeb || !!(isAnimated && avoidClassesWhileAnimating) || !staticConfig.acceptsClassName;
|
|
179
|
-
const shouldForcePseudo = !!propsIn.forceStyle;
|
|
180
|
-
const noClassNames = shouldAvoidClasses || shouldForcePseudo;
|
|
181
|
-
const disableThemeProp = props["data-disable-theme"];
|
|
182
|
-
const disableTheme = disableThemeProp && !willBeAnimated || isHOC;
|
|
183
|
-
const themeStateProps = {
|
|
184
|
-
name: props.theme,
|
|
185
|
-
componentName,
|
|
186
|
-
reset: props.reset,
|
|
187
|
-
inverse: props.themeInverse,
|
|
188
|
-
// @ts-ignore this is internal use only
|
|
189
|
-
disable: disableTheme,
|
|
190
|
-
shouldUpdate: () => !!stateRef.current.didAccessThemeVariableValue
|
|
191
|
-
};
|
|
192
|
-
if (process.env.NODE_ENV === "development") {
|
|
193
|
-
themeStateProps.debug = props.debug;
|
|
194
|
-
}
|
|
195
|
-
const themeState = useThemeWithState(themeStateProps);
|
|
196
|
-
elementType = Component || elementType;
|
|
197
|
-
const isStringElement = typeof elementType === "string";
|
|
198
|
-
const isExiting = (presence == null ? void 0 : presence[0]) === false;
|
|
199
|
-
const mediaState = useMedia(
|
|
200
|
-
// @ts-ignore, we just pass a stable object so we can get it later with
|
|
201
|
-
// should match to the one used in `setMediaShouldUpdate` below
|
|
202
|
-
stateRef,
|
|
203
|
-
debugProp ? { props, staticConfig } : null
|
|
204
|
-
);
|
|
205
|
-
setDidGetVariableValue(false);
|
|
206
|
-
if (process.env.NODE_ENV === "development") {
|
|
207
|
-
const id = useId();
|
|
208
|
-
if (debugProp) {
|
|
209
|
-
const name = `${componentName || (Component == null ? void 0 : Component.displayName) || (Component == null ? void 0 : Component.name) || "[Unnamed Component]"}`;
|
|
210
|
-
const type = isAnimatedReactNative ? "(animated)" : isReactNative ? "(rnw)" : "";
|
|
211
|
-
const dataIs = propsIn["data-is"] || "";
|
|
212
|
-
const banner = `${name}${dataIs ? ` ${dataIs}` : ""} ${type} id ${id}`;
|
|
213
|
-
const parentsLog = (conf) => {
|
|
214
|
-
var _a2;
|
|
215
|
-
return conf.parentNames ? ` (${(_a2 = conf.parentNames) == null ? void 0 : _a2.join(" > ")})` : "";
|
|
216
|
-
};
|
|
217
|
-
console.group(
|
|
218
|
-
`%c ${banner}${parentsLog(staticConfig)} (unmounted: ${state.unmounted})`,
|
|
219
|
-
"background: yellow;"
|
|
220
|
-
);
|
|
221
|
-
if (!isServer) {
|
|
222
|
-
console.groupCollapsed(
|
|
223
|
-
`Info (collapsed): ${state.press || state.pressIn ? "PRESSED " : ""}${state.hover ? "HOVERED " : ""}${state.focus ? "FOCUSED" : " "}`
|
|
224
|
-
);
|
|
225
|
-
console.log({
|
|
226
|
-
props,
|
|
227
|
-
state,
|
|
228
|
-
staticConfig,
|
|
229
|
-
elementType,
|
|
230
|
-
themeStateProps,
|
|
231
|
-
themeState
|
|
232
|
-
});
|
|
233
|
-
console.groupEnd();
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
const resolveVariablesAs = (
|
|
238
|
-
// if HOC + mounted + has animation prop, resolve as value so it passes non-variable to child
|
|
239
|
-
isAnimated || isHOC && state.unmounted == false && hasAnimationProp ? "value" : "auto"
|
|
240
|
-
);
|
|
241
|
-
const splitStyles = useSplitStyles(
|
|
242
|
-
props,
|
|
243
|
-
staticConfig,
|
|
244
|
-
themeState.theme,
|
|
245
|
-
{
|
|
246
|
-
...state,
|
|
247
|
-
mediaState,
|
|
248
|
-
noClassNames,
|
|
249
|
-
hasTextAncestor,
|
|
250
|
-
resolveVariablesAs,
|
|
251
|
-
isExiting
|
|
252
|
-
},
|
|
253
|
-
null,
|
|
254
|
-
languageContext || void 0,
|
|
255
|
-
elementType,
|
|
256
|
-
debugProp
|
|
257
|
-
);
|
|
258
|
-
const isMediaSpaced = Array.isArray(splitStyles.hasMedia);
|
|
259
|
-
const shouldListenForMedia = didGetVariableValue() || isMediaSpaced || noClassNames && splitStyles.hasMedia === true;
|
|
260
|
-
setMediaShouldUpdate(stateRef, {
|
|
261
|
-
enabled: shouldListenForMedia,
|
|
262
|
-
keys: noClassNames && isMediaSpaced ? splitStyles.hasMedia : null
|
|
263
|
-
});
|
|
264
|
-
const isAnimatedReactNativeWeb = isAnimated && avoidClassesWhileAnimating;
|
|
265
|
-
if (process.env.NODE_ENV === "development") {
|
|
266
|
-
if (!process.env.TAMAGUI_TARGET) {
|
|
267
|
-
console.error(
|
|
268
|
-
`No process.env.TAMAGUI_TARGET set, please set it to "native" or "web".`
|
|
269
|
-
);
|
|
270
|
-
}
|
|
271
|
-
if (debugProp) {
|
|
272
|
-
console.groupCollapsed("props");
|
|
273
|
-
console.log("props in", propsIn, "mapped to", props, "in order", Object.keys(props));
|
|
274
|
-
console.log("splitStyles", splitStyles);
|
|
275
|
-
console.log("shouldListenForMedia", shouldListenForMedia);
|
|
276
|
-
console.log("className", Object.values(splitStyles.classNames));
|
|
277
|
-
if (isClient) {
|
|
278
|
-
console.log("ref", hostRef, "(click to view)");
|
|
279
|
-
}
|
|
280
|
-
console.groupEnd();
|
|
281
|
-
if (debugProp === "break") {
|
|
282
|
-
debugger;
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
const {
|
|
287
|
-
viewProps: viewPropsIn,
|
|
288
|
-
pseudos,
|
|
289
|
-
style: splitStylesStyle,
|
|
290
|
-
classNames,
|
|
291
|
-
space
|
|
292
|
-
} = splitStyles;
|
|
293
|
-
const propsWithAnimation = props;
|
|
294
|
-
let animationStyles;
|
|
295
|
-
if (!isRSC && willBeAnimated && useAnimations && !isHOC) {
|
|
296
|
-
const animations = useAnimations({
|
|
297
|
-
props: propsWithAnimation,
|
|
298
|
-
style: splitStylesStyle,
|
|
299
|
-
presence,
|
|
300
|
-
state,
|
|
301
|
-
theme: themeState.theme,
|
|
302
|
-
pseudos: pseudos || null,
|
|
303
|
-
onDidAnimate: props.onDidAnimate,
|
|
304
|
-
hostRef,
|
|
305
|
-
staticConfig
|
|
306
|
-
});
|
|
307
|
-
if (isAnimated) {
|
|
308
|
-
if (animations) {
|
|
309
|
-
animationStyles = animations.style;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
const {
|
|
314
|
-
asChild,
|
|
315
|
-
children,
|
|
316
|
-
onPress,
|
|
317
|
-
onPressIn,
|
|
318
|
-
onPressOut,
|
|
319
|
-
onHoverIn,
|
|
320
|
-
onHoverOut,
|
|
321
|
-
themeShallow,
|
|
322
|
-
spaceDirection: _spaceDirection,
|
|
323
|
-
disabled: disabledProp,
|
|
324
|
-
onMouseUp,
|
|
325
|
-
onMouseDown,
|
|
326
|
-
onMouseEnter,
|
|
327
|
-
onMouseLeave,
|
|
328
|
-
separator,
|
|
329
|
-
// ignore from here on out
|
|
330
|
-
forceStyle: _forceStyle,
|
|
331
|
-
// @ts-ignore for next/link compat etc
|
|
332
|
-
onClick,
|
|
333
|
-
theme: _themeProp,
|
|
334
|
-
// @ts-ignore
|
|
335
|
-
defaultVariants,
|
|
336
|
-
...nonTamaguiProps
|
|
337
|
-
} = viewPropsIn;
|
|
338
|
-
const disabled = ((_d = props.accessibilityState) == null ? void 0 : _d.disabled) || props.accessibilityDisabled;
|
|
339
|
-
let viewProps = nonTamaguiProps;
|
|
340
|
-
if (isHOC && _themeProp) {
|
|
341
|
-
viewProps.theme = _themeProp;
|
|
342
|
-
}
|
|
343
|
-
if (process.env.TAMAGUI_TARGET === "web" && !isReactNative && !willBeAnimated && !asChild) {
|
|
344
|
-
viewProps = (_f = (_e = hooks).usePropsTransform) == null ? void 0 : _f.call(_e, elementType, nonTamaguiProps, hostRef);
|
|
345
|
-
} else {
|
|
346
|
-
viewProps = nonTamaguiProps;
|
|
347
|
-
}
|
|
348
|
-
viewProps.ref = useComposedRefs(hostRef, forwardedRef);
|
|
349
|
-
if (process.env.NODE_ENV === "development") {
|
|
350
|
-
if (!isText && isWeb && !isHOC) {
|
|
351
|
-
Children.toArray(props.children).forEach((item) => {
|
|
352
|
-
if (typeof item === "string" && item !== "\n") {
|
|
353
|
-
console.error(
|
|
354
|
-
`Unexpected text node: ${item}. A text node cannot be a child of a <View>.`
|
|
355
|
-
);
|
|
356
|
-
}
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
const unPress = useCallback(() => {
|
|
361
|
-
setStateShallow({
|
|
362
|
-
press: false,
|
|
363
|
-
pressIn: false
|
|
364
|
-
});
|
|
365
|
-
}, [setStateShallow]);
|
|
366
|
-
const shouldSetMounted = needsMount && state.unmounted;
|
|
367
|
-
useIsomorphicLayoutEffect(() => {
|
|
368
|
-
if (!shouldSetMounted) {
|
|
369
|
-
return () => {
|
|
370
|
-
mouseUps.delete(unPress);
|
|
371
|
-
};
|
|
372
|
-
}
|
|
373
|
-
const unmounted = state.unmounted === true && hasEnterStyle ? "should-enter" : false;
|
|
374
|
-
setStateShallow({
|
|
375
|
-
unmounted
|
|
376
|
-
});
|
|
377
|
-
}, [shouldSetMounted, state.unmounted]);
|
|
378
|
-
let styles;
|
|
379
|
-
if (isStringElement && shouldAvoidClasses && !shouldForcePseudo) {
|
|
380
|
-
styles = {
|
|
381
|
-
...animationStyles ?? splitStylesStyle
|
|
382
|
-
};
|
|
383
|
-
} else {
|
|
384
|
-
styles = [animationStyles ?? splitStylesStyle];
|
|
385
|
-
if (shouldForcePseudo) {
|
|
386
|
-
const next = {};
|
|
387
|
-
styles.forEach((style) => Object.assign(next, style));
|
|
388
|
-
Object.assign(splitStyles.style, next);
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
let fontFamily = isText ? splitStyles.fontFamily || staticConfig.defaultProps.fontFamily : null;
|
|
392
|
-
if (fontFamily && fontFamily[0] === "$") {
|
|
393
|
-
fontFamily = fontFamily.slice(1);
|
|
394
|
-
}
|
|
395
|
-
const fontFamilyClassName = fontFamily ? `font_${fontFamily}` : "";
|
|
396
|
-
const classList = [
|
|
397
|
-
hasEnterStyle && (state.unmounted && needsMount || !isClient) ? "t_will-mount" : "",
|
|
398
|
-
componentName ? componentClassName : "",
|
|
399
|
-
fontFamilyClassName,
|
|
400
|
-
classNames ? Object.values(classNames).join(" ") : ""
|
|
401
|
-
];
|
|
402
|
-
const className = classList.join(" ");
|
|
403
|
-
if (process.env.TAMAGUI_TARGET === "web") {
|
|
404
|
-
const style = animationStyles ?? splitStyles.style;
|
|
405
|
-
if (isAnimatedReactNativeWeb) {
|
|
406
|
-
viewProps.style = style;
|
|
407
|
-
} else if (isReactNative) {
|
|
408
|
-
const cnStyles = { $$css: true };
|
|
409
|
-
for (const name of className.split(" ")) {
|
|
410
|
-
cnStyles[name] = name;
|
|
411
|
-
}
|
|
412
|
-
viewProps.style = [...Array.isArray(style) ? style : [style], cnStyles];
|
|
413
|
-
if (process.env.NODE_ENV === "development") {
|
|
414
|
-
Object.keys(viewProps).forEach((key) => {
|
|
415
|
-
if (key.startsWith("data-")) {
|
|
416
|
-
viewProps.dataSet ??= {};
|
|
417
|
-
viewProps.dataSet[key.replace("data-", "")] = viewProps[key];
|
|
418
|
-
delete viewProps[key];
|
|
419
|
-
}
|
|
420
|
-
});
|
|
421
|
-
}
|
|
422
|
-
} else {
|
|
423
|
-
viewProps.className = className;
|
|
424
|
-
viewProps.style = style;
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
if (process.env.TAMAGUI_TARGET === "native") {
|
|
428
|
-
if (splitStyles.fontFamily) {
|
|
429
|
-
const faceInfo = (_g = tamaguiConfig.fontsParsed[splitStyles.fontFamily]) == null ? void 0 : _g.face;
|
|
430
|
-
if (faceInfo) {
|
|
431
|
-
const [weight, style] = (() => {
|
|
432
|
-
var _a2, _b2;
|
|
433
|
-
let weight2;
|
|
434
|
-
let style2;
|
|
435
|
-
for (let i = styles.length; i >= 0; i--) {
|
|
436
|
-
weight2 ??= (_a2 = styles[i]) == null ? void 0 : _a2.fontWeight;
|
|
437
|
-
style2 ??= (_b2 = styles[i]) == null ? void 0 : _b2.fontStyle;
|
|
438
|
-
}
|
|
439
|
-
return [weight2 || "400", style2 || "normal"];
|
|
440
|
-
})();
|
|
441
|
-
const overrideFace = (_i = (_h = faceInfo[weight]) == null ? void 0 : _h[style]) == null ? void 0 : _i.val;
|
|
442
|
-
if (overrideFace) {
|
|
443
|
-
for (const style2 of styles) {
|
|
444
|
-
if (style2 == null ? void 0 : style2.fontFamily) {
|
|
445
|
-
style2.fontFamily = overrideFace;
|
|
446
|
-
style2.fontWeight = void 0;
|
|
447
|
-
style2.fontStyle = void 0;
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
viewProps.style = styles;
|
|
454
|
-
}
|
|
455
|
-
const runtimePressStyle = !disabled && noClassNames && (pseudos == null ? void 0 : pseudos.pressStyle);
|
|
456
|
-
const attachPress = Boolean(
|
|
457
|
-
runtimePressStyle || onPress || onPressOut || onPressIn || onClick
|
|
458
|
-
);
|
|
459
|
-
const runtimeHoverStyle = !disabled && noClassNames && (pseudos == null ? void 0 : pseudos.hoverStyle);
|
|
460
|
-
const isHoverable = isWeb && !!(runtimeHoverStyle || onHoverIn || onHoverOut || onMouseEnter || onMouseLeave);
|
|
461
|
-
const handlesPressEvents = !(isWeb || asChild);
|
|
462
|
-
const shouldAttach = Boolean(
|
|
463
|
-
attachPress || isHoverable || noClassNames && "pressStyle" in props || isWeb && noClassNames && "hoverStyle" in props
|
|
464
|
-
);
|
|
465
|
-
const events = shouldAttach && !isRSC && !isDisabled && !asChild ? {
|
|
466
|
-
onPressOut: attachPress ? (e) => {
|
|
467
|
-
unPress();
|
|
468
|
-
onPressOut == null ? void 0 : onPressOut(e);
|
|
469
|
-
onMouseUp == null ? void 0 : onMouseUp(e);
|
|
470
|
-
} : void 0,
|
|
471
|
-
...isHoverable && {
|
|
472
|
-
onMouseEnter: isHoverable ? (e) => {
|
|
473
|
-
const next = {};
|
|
474
|
-
if (isHoverable) {
|
|
475
|
-
next.hover = true;
|
|
476
|
-
}
|
|
477
|
-
if (state.pressIn) {
|
|
478
|
-
next.press = true;
|
|
479
|
-
}
|
|
480
|
-
setStateShallow(next);
|
|
481
|
-
onHoverIn == null ? void 0 : onHoverIn(e);
|
|
482
|
-
onMouseEnter == null ? void 0 : onMouseEnter(e);
|
|
483
|
-
} : void 0,
|
|
484
|
-
onMouseLeave: isHoverable ? (e) => {
|
|
485
|
-
const next = {};
|
|
486
|
-
mouseUps.add(unPress);
|
|
487
|
-
if (isHoverable) {
|
|
488
|
-
next.hover = false;
|
|
489
|
-
}
|
|
490
|
-
if (state.pressIn) {
|
|
491
|
-
next.press = false;
|
|
492
|
-
next.pressIn = false;
|
|
493
|
-
}
|
|
494
|
-
setStateShallow(next);
|
|
495
|
-
onHoverOut == null ? void 0 : onHoverOut(e);
|
|
496
|
-
onMouseLeave == null ? void 0 : onMouseLeave(e);
|
|
497
|
-
} : void 0
|
|
498
|
-
},
|
|
499
|
-
onPressIn: attachPress ? (e) => {
|
|
500
|
-
setStateShallow({
|
|
501
|
-
press: true,
|
|
502
|
-
pressIn: true,
|
|
503
|
-
hover: false
|
|
504
|
-
});
|
|
505
|
-
onPressIn == null ? void 0 : onPressIn(e);
|
|
506
|
-
onMouseDown == null ? void 0 : onMouseDown(e);
|
|
507
|
-
if (isWeb) {
|
|
508
|
-
mouseUps.add(unPress);
|
|
509
|
-
}
|
|
510
|
-
} : void 0,
|
|
511
|
-
onPress: attachPress ? (e) => {
|
|
512
|
-
unPress();
|
|
513
|
-
isWeb && (onClick == null ? void 0 : onClick(e));
|
|
514
|
-
onPress == null ? void 0 : onPress(e);
|
|
515
|
-
} : void 0
|
|
516
|
-
} : null;
|
|
517
|
-
if (process.env.TAMAGUI_TARGET === "native") {
|
|
518
|
-
if (events) {
|
|
519
|
-
Object.assign(events, {
|
|
520
|
-
cancelable: !props.rejectResponderTermination,
|
|
521
|
-
disabled: isDisabled,
|
|
522
|
-
hitSlop: props.hitSlop,
|
|
523
|
-
delayLongPress: props.delayLongPress,
|
|
524
|
-
delayPressIn: props.delayPressIn,
|
|
525
|
-
delayPressOut: props.delayPressOut,
|
|
526
|
-
focusable: viewProps.focusable ?? true,
|
|
527
|
-
minPressDuration: 0
|
|
528
|
-
});
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
(_k = (_j = hooks).useEvents) == null ? void 0 : _k.call(_j, viewProps, events, splitStyles, setStateShallow);
|
|
532
|
-
const shouldReset = !!(themeShallow && themeState.isNewTheme);
|
|
533
|
-
if (shouldReset) {
|
|
534
|
-
stateRef.current.themeShallow = true;
|
|
535
|
-
}
|
|
536
|
-
let content = !children || asChild ? children : spacedChildren({
|
|
537
|
-
separator,
|
|
538
|
-
children,
|
|
539
|
-
space,
|
|
540
|
-
direction: props.spaceDirection || "both",
|
|
541
|
-
isZStack,
|
|
542
|
-
debug: debugProp
|
|
543
|
-
});
|
|
544
|
-
if (asChild) {
|
|
545
|
-
elementType = Slot;
|
|
546
|
-
viewProps = {
|
|
547
|
-
...viewProps,
|
|
548
|
-
onPress,
|
|
549
|
-
onPressIn,
|
|
550
|
-
onPressOut
|
|
551
|
-
};
|
|
552
|
-
}
|
|
553
|
-
content = createElement(elementType, viewProps, content);
|
|
554
|
-
content = disableThemeProp ? content : useThemedChildren(themeState, content, {
|
|
555
|
-
shallow: stateRef.current.themeShallow
|
|
556
|
-
// passPropsToChildren: true,
|
|
557
|
-
});
|
|
558
|
-
if (process.env.NODE_ENV === "development") {
|
|
559
|
-
if (props["debug"] === "visualize") {
|
|
560
|
-
content = /* @__PURE__ */ jsx(ThemeDebug, { themeState, themeProps: props, children: content });
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
if (process.env.TAMAGUI_TARGET === "web") {
|
|
564
|
-
if (events || isAnimatedReactNativeWeb) {
|
|
565
|
-
content = /* @__PURE__ */ jsx(
|
|
566
|
-
"span",
|
|
567
|
-
{
|
|
568
|
-
className: `${isAnimatedReactNativeWeb ? className : ""} _dsp_contents`,
|
|
569
|
-
...events && {
|
|
570
|
-
onMouseEnter: events.onMouseEnter,
|
|
571
|
-
onMouseLeave: events.onMouseLeave,
|
|
572
|
-
onClick: events.onPress,
|
|
573
|
-
onMouseDown: events.onPressIn,
|
|
574
|
-
onMouseUp: events.onPressOut,
|
|
575
|
-
onTouchStart: events.onPressIn,
|
|
576
|
-
onTouchEnd: events.onPressOut
|
|
577
|
-
},
|
|
578
|
-
children: content
|
|
579
|
-
}
|
|
580
|
-
);
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
if (process.env.NODE_ENV === "development") {
|
|
584
|
-
if (debugProp) {
|
|
585
|
-
const element2 = typeof elementType === "string" ? elementType : "Component";
|
|
586
|
-
console.groupCollapsed(`render <${element2} /> with props`, viewProps);
|
|
587
|
-
for (const key in viewProps) {
|
|
588
|
-
console.log(key, viewProps[key]);
|
|
589
|
-
}
|
|
590
|
-
console.log("children", content);
|
|
591
|
-
if (typeof window !== "undefined") {
|
|
592
|
-
console.log({ state, themeState, isAnimated, isAnimatedReactNativeWeb, defaultProps, viewProps, splitStyles, animationStyles, handlesPressEvents, isStringElement, classNamesIn: (_l = props.className) == null ? void 0 : _l.split(" "), classNamesOut: (_m = viewProps.className) == null ? void 0 : _m.split(" "), events, shouldAttach, styles, pseudos, content, shouldAvoidClasses, avoidClasses: avoidClassesWhileAnimating, animation: props.animation, style: splitStylesStyle, staticConfig, tamaguiConfig, shouldForcePseudo });
|
|
593
|
-
}
|
|
594
|
-
console.groupEnd();
|
|
595
|
-
console.groupEnd();
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
return content;
|
|
599
|
-
});
|
|
600
|
-
if (staticConfig.componentName) {
|
|
601
|
-
component.displayName = staticConfig.componentName;
|
|
602
|
-
}
|
|
603
|
-
onConfiguredOnce((conf) => {
|
|
604
|
-
if (!tamaguiConfig) {
|
|
605
|
-
tamaguiConfig = conf;
|
|
606
|
-
if (!initialTheme) {
|
|
607
|
-
const next = conf.themes[Object.keys(conf.themes)[0]];
|
|
608
|
-
initialTheme = proxyThemeVariables(next);
|
|
609
|
-
if (process.env.NODE_ENV === "development") {
|
|
610
|
-
if (!initialTheme) {
|
|
611
|
-
console.log("Warning: Missing theme");
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
let defaultPropsIn = staticConfig.defaultProps || {};
|
|
617
|
-
const parentNames = [...staticConfig.parentNames || [], staticConfig.componentName];
|
|
618
|
-
if (tamaguiConfig.defaultProps && parentNames && staticConfig.componentName) {
|
|
619
|
-
defaultPropsIn = mergeConfigDefaultProps(
|
|
620
|
-
staticConfig.componentName,
|
|
621
|
-
defaultPropsIn,
|
|
622
|
-
tamaguiConfig.defaultProps,
|
|
623
|
-
parentNames,
|
|
624
|
-
tamaguiConfig
|
|
625
|
-
);
|
|
626
|
-
}
|
|
627
|
-
const debug = defaultPropsIn["debug"];
|
|
628
|
-
if (defaultPropsIn.tag) {
|
|
629
|
-
defaultTag = defaultPropsIn.tag;
|
|
630
|
-
}
|
|
631
|
-
const noClassNames = !staticConfig.acceptsClassName;
|
|
632
|
-
const { name, variants, defaultVariants, ...restProps } = defaultPropsIn;
|
|
633
|
-
defaultProps = restProps;
|
|
634
|
-
if (process.env.NODE_ENV === "development" && debug) {
|
|
635
|
-
if (process.env.IS_STATIC !== "is_static") {
|
|
636
|
-
console.log(`\u{1F41B} [${staticConfig.componentName || "Component"}]`, {
|
|
637
|
-
staticConfig,
|
|
638
|
-
defaultPropsIn,
|
|
639
|
-
defaultProps,
|
|
640
|
-
defaultPropsKeyOrder: Object.keys(defaultProps),
|
|
641
|
-
defaultTag,
|
|
642
|
-
noClassNames
|
|
643
|
-
});
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
});
|
|
647
|
-
let res = component;
|
|
648
|
-
if (configIn.memo) {
|
|
649
|
-
res = memo(res);
|
|
650
|
-
}
|
|
651
|
-
res.staticConfig = {
|
|
652
|
-
validStyles: staticConfig.validStyles || stylePropsView,
|
|
653
|
-
...staticConfig
|
|
654
|
-
};
|
|
655
|
-
function extendStyledConfig() {
|
|
656
|
-
return extendStaticConfig(
|
|
657
|
-
{
|
|
658
|
-
...staticConfig,
|
|
659
|
-
neverFlatten: true,
|
|
660
|
-
isHOC: true
|
|
661
|
-
},
|
|
662
|
-
res
|
|
663
|
-
);
|
|
664
|
-
}
|
|
665
|
-
function extractable(Component) {
|
|
666
|
-
Component.staticConfig = extendStyledConfig();
|
|
667
|
-
Component.styleable = styleable;
|
|
668
|
-
return Component;
|
|
669
|
-
}
|
|
670
|
-
function styleable(Component) {
|
|
671
|
-
var _a;
|
|
672
|
-
const isForwardedRefAlready = ((_a = Component.render) == null ? void 0 : _a.length) === 2;
|
|
673
|
-
const ComponentForwardedRef = isForwardedRefAlready ? Component : forwardRef(Component);
|
|
674
|
-
const extendedConfig = extendStyledConfig();
|
|
675
|
-
const out = themeable(ComponentForwardedRef, extendedConfig);
|
|
676
|
-
out.staticConfig = extendedConfig;
|
|
677
|
-
out.styleable = styleable;
|
|
678
|
-
return out;
|
|
679
|
-
}
|
|
680
|
-
res.extractable = extractable;
|
|
681
|
-
res.styleable = styleable;
|
|
682
|
-
return res;
|
|
683
|
-
}
|
|
684
|
-
const Unspaced = (props) => props.children;
|
|
685
|
-
Unspaced["isUnspaced"] = true;
|
|
686
|
-
const Spacer = createComponent({
|
|
687
|
-
acceptsClassName: true,
|
|
688
|
-
memo: true,
|
|
689
|
-
componentName: "Spacer",
|
|
690
|
-
validStyles,
|
|
691
|
-
defaultProps: {
|
|
692
|
-
...stackDefaultStyles,
|
|
693
|
-
// avoid nesting issues
|
|
694
|
-
tag: "span",
|
|
695
|
-
size: true,
|
|
696
|
-
pointerEvents: "none"
|
|
697
|
-
},
|
|
698
|
-
variants: {
|
|
699
|
-
size: {
|
|
700
|
-
"...size": (size, { tokens }) => {
|
|
701
|
-
size = size === true ? "$true" : size;
|
|
702
|
-
const sizePx = tokens.space[size] ?? size;
|
|
703
|
-
return {
|
|
704
|
-
width: sizePx,
|
|
705
|
-
height: sizePx,
|
|
706
|
-
minWidth: sizePx,
|
|
707
|
-
minHeight: sizePx
|
|
708
|
-
};
|
|
709
|
-
}
|
|
710
|
-
},
|
|
711
|
-
flex: {
|
|
712
|
-
true: {
|
|
713
|
-
flexGrow: 1
|
|
714
|
-
}
|
|
715
|
-
},
|
|
716
|
-
direction: {
|
|
717
|
-
horizontal: {
|
|
718
|
-
height: 0,
|
|
719
|
-
minHeight: 0
|
|
720
|
-
},
|
|
721
|
-
vertical: {
|
|
722
|
-
width: 0,
|
|
723
|
-
minWidth: 0
|
|
724
|
-
},
|
|
725
|
-
both: {}
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
});
|
|
729
|
-
function spacedChildren(props) {
|
|
730
|
-
var _a, _b, _c;
|
|
731
|
-
const { isZStack, children, space, direction, spaceFlex, separator } = props;
|
|
732
|
-
const hasSpace = !!(space || spaceFlex);
|
|
733
|
-
const hasSeparator = !(separator === void 0 || separator === null);
|
|
734
|
-
if (!(hasSpace || hasSeparator || isZStack)) {
|
|
735
|
-
return children;
|
|
736
|
-
}
|
|
737
|
-
const childrenList = Children.toArray(children);
|
|
738
|
-
const len = childrenList.length;
|
|
739
|
-
if (len <= 1 && !isZStack && !((_b = (_a = childrenList[0]) == null ? void 0 : _a["type"]) == null ? void 0 : _b["shouldForwardSpace"])) {
|
|
740
|
-
return childrenList;
|
|
741
|
-
}
|
|
742
|
-
const final = [];
|
|
743
|
-
for (let [index, child] of childrenList.entries()) {
|
|
744
|
-
const isEmpty = child === null || child === void 0 || Array.isArray(child) && child.length === 0;
|
|
745
|
-
if (!isEmpty && React.isValidElement(child) && ((_c = child.type) == null ? void 0 : _c["shouldForwardSpace"])) {
|
|
746
|
-
child = React.cloneElement(child, {
|
|
747
|
-
space,
|
|
748
|
-
spaceFlex,
|
|
749
|
-
separator,
|
|
750
|
-
key: child.key
|
|
751
|
-
});
|
|
752
|
-
}
|
|
753
|
-
if (isEmpty || !child || child["key"] && !isZStack) {
|
|
754
|
-
final.push(child);
|
|
755
|
-
} else {
|
|
756
|
-
final.push(
|
|
757
|
-
/* @__PURE__ */ jsx(Fragment, { children: isZStack ? /* @__PURE__ */ jsx(AbsoluteFill, { children: child }) : child }, index)
|
|
758
|
-
);
|
|
759
|
-
}
|
|
760
|
-
if (isUnspaced(child) && index === 0)
|
|
761
|
-
continue;
|
|
762
|
-
if (isZStack)
|
|
763
|
-
continue;
|
|
764
|
-
const next = childrenList[index + 1];
|
|
765
|
-
if (next && !isUnspaced(next)) {
|
|
766
|
-
if (separator) {
|
|
767
|
-
if (hasSpace) {
|
|
768
|
-
final.push(
|
|
769
|
-
createSpacer({
|
|
770
|
-
key: `_${index}_00tmgui`,
|
|
771
|
-
direction,
|
|
772
|
-
space,
|
|
773
|
-
spaceFlex
|
|
774
|
-
})
|
|
775
|
-
);
|
|
776
|
-
}
|
|
777
|
-
final.push(
|
|
778
|
-
React.isValidElement(separator) ? React.cloneElement(separator, { key: `sep_${index}` }) : separator
|
|
779
|
-
);
|
|
780
|
-
if (hasSpace) {
|
|
781
|
-
final.push(
|
|
782
|
-
createSpacer({
|
|
783
|
-
key: `_${index}01tmgui`,
|
|
784
|
-
direction,
|
|
785
|
-
space,
|
|
786
|
-
spaceFlex
|
|
787
|
-
})
|
|
788
|
-
);
|
|
789
|
-
}
|
|
790
|
-
} else {
|
|
791
|
-
final.push(
|
|
792
|
-
createSpacer({
|
|
793
|
-
key: `_${index}02tmgui`,
|
|
794
|
-
direction,
|
|
795
|
-
space,
|
|
796
|
-
spaceFlex
|
|
797
|
-
})
|
|
798
|
-
);
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
if (process.env.NODE_ENV === "development") {
|
|
803
|
-
if (props.debug) {
|
|
804
|
-
console.log(` Spaced children`, final, props);
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
return final;
|
|
808
|
-
}
|
|
809
|
-
function createSpacer({ key, direction, space, spaceFlex }) {
|
|
810
|
-
return /* @__PURE__ */ jsx(
|
|
811
|
-
Spacer,
|
|
812
|
-
{
|
|
813
|
-
size: space,
|
|
814
|
-
direction,
|
|
815
|
-
...typeof spaceFlex !== "undefined" && {
|
|
816
|
-
flex: spaceFlex === true ? 1 : spaceFlex === false ? 0 : spaceFlex
|
|
817
|
-
}
|
|
818
|
-
},
|
|
819
|
-
key
|
|
820
|
-
);
|
|
821
|
-
}
|
|
822
|
-
function isUnspaced(child) {
|
|
823
|
-
const t = child == null ? void 0 : child["type"];
|
|
824
|
-
return (t == null ? void 0 : t["isVisuallyHidden"]) || (t == null ? void 0 : t["isUnspaced"]);
|
|
825
|
-
}
|
|
826
|
-
const DefaultProps = /* @__PURE__ */ new Map();
|
|
827
|
-
function mergeConfigDefaultProps(name, props, configDefaults, parentNames, conf) {
|
|
828
|
-
const len = parentNames.length;
|
|
829
|
-
let prev;
|
|
830
|
-
for (let i = 0; i < len; i++) {
|
|
831
|
-
const n = parentNames[i];
|
|
832
|
-
if (!n)
|
|
833
|
-
continue;
|
|
834
|
-
if (DefaultProps.has(n)) {
|
|
835
|
-
prev = DefaultProps.get(n);
|
|
836
|
-
continue;
|
|
837
|
-
}
|
|
838
|
-
const props2 = configDefaults[n];
|
|
839
|
-
if (!props2) {
|
|
840
|
-
if (prev) {
|
|
841
|
-
DefaultProps.set(n, prev);
|
|
842
|
-
}
|
|
843
|
-
continue;
|
|
844
|
-
}
|
|
845
|
-
prev = mergeProps(prev || {}, props2, false, conf.inverseShorthands)[0];
|
|
846
|
-
DefaultProps.set(n, prev);
|
|
847
|
-
}
|
|
848
|
-
const ourDefaultsMerged = DefaultProps.get(name);
|
|
849
|
-
if (ourDefaultsMerged) {
|
|
850
|
-
return mergeProps(props, ourDefaultsMerged, false, conf.inverseShorthands)[0];
|
|
851
|
-
}
|
|
852
|
-
return props;
|
|
853
|
-
}
|
|
854
|
-
const AbsoluteFill = createComponent({
|
|
855
|
-
defaultProps: {
|
|
856
|
-
...stackDefaultStyles,
|
|
857
|
-
flexDirection: "column",
|
|
858
|
-
position: "absolute",
|
|
859
|
-
top: 0,
|
|
860
|
-
right: 0,
|
|
861
|
-
bottom: 0,
|
|
862
|
-
left: 0,
|
|
863
|
-
pointerEvents: "box-none"
|
|
864
|
-
}
|
|
865
|
-
});
|
|
866
|
-
function hasAnimatedStyleValue(style) {
|
|
867
|
-
return Object.keys(style).some((k) => {
|
|
868
|
-
const val = style[k];
|
|
869
|
-
return val && typeof val === "object" && "_animation" in val;
|
|
870
|
-
});
|
|
871
|
-
}
|
|
872
|
-
export {
|
|
873
|
-
Spacer,
|
|
874
|
-
Unspaced,
|
|
875
|
-
createComponent,
|
|
876
|
-
defaultComponentState,
|
|
877
|
-
mouseUps,
|
|
878
|
-
spacedChildren
|
|
879
|
-
};
|
|
880
|
-
//# sourceMappingURL=createComponent.mjs.map
|