@tamagui/core 1.0.1-beta.192 → 1.0.1-beta.194
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 +4 -2
- package/dist/cjs/Tamagui.js.map +2 -2
- package/dist/cjs/config.js +1 -2
- package/dist/cjs/config.js.map +2 -2
- package/dist/cjs/constants/constants.js +13 -8
- package/dist/cjs/constants/constants.js.map +2 -2
- package/dist/cjs/contexts/TextAncestorContext.js +3 -16
- package/dist/cjs/contexts/TextAncestorContext.js.map +3 -3
- package/dist/cjs/createComponent.js +196 -284
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/createTamagui.js +15 -16
- package/dist/cjs/createTamagui.js.map +3 -3
- package/dist/cjs/createVariable.js +1 -2
- package/dist/cjs/createVariable.js.map +2 -2
- package/dist/cjs/helpers/ThemeManager.js +7 -14
- package/dist/cjs/helpers/ThemeManager.js.map +2 -2
- package/dist/cjs/helpers/{createShallowUpdate.js → cache.js} +20 -21
- package/dist/cjs/helpers/cache.js.map +7 -0
- package/dist/cjs/helpers/createMediaStyle.js +14 -8
- package/dist/cjs/helpers/createMediaStyle.js.map +2 -2
- package/dist/cjs/helpers/extendStaticConfig.js +0 -1
- package/dist/cjs/helpers/extendStaticConfig.js.map +2 -2
- package/dist/cjs/helpers/getSplitStyles.js +214 -94
- package/dist/cjs/helpers/getSplitStyles.js.map +3 -3
- package/dist/cjs/helpers/getStylesAtomic.js +16 -36
- package/dist/cjs/helpers/getStylesAtomic.js.map +3 -3
- package/dist/cjs/helpers/getVariantExtras.js +2 -1
- package/dist/cjs/helpers/getVariantExtras.js.map +2 -2
- package/dist/cjs/helpers/insertStyleRule.js +14 -6
- package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
- package/dist/cjs/helpers/matchMedia.js.map +2 -2
- package/dist/cjs/helpers/mergeTransform.js.map +1 -1
- package/dist/cjs/helpers/normalizeValueWithProperty.js +32 -2
- package/dist/cjs/helpers/normalizeValueWithProperty.js.map +2 -2
- package/dist/cjs/helpers/proxyThemeVariables.js +2 -7
- package/dist/cjs/helpers/proxyThemeVariables.js.map +2 -2
- package/dist/cjs/helpers/useShallowSetState.js.map +2 -2
- package/dist/cjs/hooks/getThemeUnwrapped.js +1 -3
- package/dist/cjs/hooks/getThemeUnwrapped.js.map +2 -2
- package/dist/cjs/hooks/useElementLayout.js +92 -0
- package/dist/cjs/hooks/useElementLayout.js.map +7 -0
- package/dist/cjs/hooks/useIsTouchDevice.js +2 -10
- package/dist/cjs/hooks/useIsTouchDevice.js.map +2 -2
- package/dist/cjs/hooks/useMedia.js +79 -85
- package/dist/cjs/hooks/useMedia.js.map +2 -2
- package/dist/cjs/hooks/useMedia.test.js +2 -0
- package/dist/cjs/{helpers/validate.js.map → hooks/useMedia.test.js.map} +0 -0
- package/dist/cjs/hooks/usePressablePressResponder.js +370 -0
- package/dist/cjs/hooks/usePressablePressResponder.js.map +7 -0
- package/dist/cjs/hooks/useSafeRef.js +13 -15
- package/dist/cjs/hooks/useSafeRef.js.map +2 -2
- package/dist/cjs/hooks/useTheme.js +5 -5
- package/dist/cjs/hooks/useTheme.js.map +2 -2
- package/dist/cjs/index.js +1 -17
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/static.js +0 -20
- package/dist/cjs/static.js.map +2 -2
- package/dist/cjs/styled.js +4 -22
- package/dist/cjs/styled.js.map +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/{hooks/useIsSSR.js → views/AbsoluteFill.js} +18 -23
- package/dist/cjs/views/AbsoluteFill.js.map +7 -0
- package/dist/cjs/views/AbsoluteFill.native.js +45 -0
- package/dist/cjs/views/AbsoluteFill.native.js.map +7 -0
- package/dist/cjs/views/FontLanguage.native.js.map +2 -2
- package/dist/cjs/views/Stack.js.map +1 -1
- package/dist/cjs/views/TamaguiProvider.js +3 -2
- package/dist/cjs/views/TamaguiProvider.js.map +2 -2
- package/dist/cjs/views/Text.js.map +1 -1
- package/dist/cjs/views/ThemeReset.js +10 -10
- package/dist/cjs/views/ThemeReset.js.map +2 -2
- package/dist/esm/Tamagui.js +4 -2
- package/dist/esm/Tamagui.js.map +2 -2
- package/dist/esm/config.js +1 -2
- package/dist/esm/config.js.map +2 -2
- package/dist/esm/constants/constants.js +11 -7
- package/dist/esm/constants/constants.js.map +2 -2
- package/dist/esm/contexts/TextAncestorContext.js +2 -13
- package/dist/esm/contexts/TextAncestorContext.js.map +2 -2
- package/dist/esm/createComponent.js +195 -286
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/createTamagui.js +15 -16
- package/dist/esm/createTamagui.js.map +3 -3
- package/dist/esm/createVariable.js +1 -2
- package/dist/esm/createVariable.js.map +2 -2
- package/dist/esm/helpers/ThemeManager.js +7 -14
- package/dist/esm/helpers/ThemeManager.js.map +2 -2
- package/dist/esm/helpers/cache.js +18 -0
- package/dist/esm/helpers/cache.js.map +7 -0
- package/dist/esm/helpers/createMediaStyle.js +14 -8
- package/dist/esm/helpers/createMediaStyle.js.map +2 -2
- package/dist/esm/helpers/extendStaticConfig.js +0 -1
- package/dist/esm/helpers/extendStaticConfig.js.map +2 -2
- package/dist/esm/helpers/getSplitStyles.js +223 -95
- package/dist/esm/helpers/getSplitStyles.js.map +3 -3
- package/dist/esm/helpers/getStylesAtomic.js +13 -26
- package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
- package/dist/esm/helpers/getVariantExtras.js +2 -1
- package/dist/esm/helpers/getVariantExtras.js.map +2 -2
- package/dist/esm/helpers/insertStyleRule.js +14 -6
- package/dist/esm/helpers/insertStyleRule.js.map +2 -2
- package/dist/esm/helpers/matchMedia.js.map +2 -2
- package/dist/esm/helpers/mergeTransform.js.map +1 -1
- package/dist/esm/helpers/normalizeValueWithProperty.js +30 -1
- package/dist/esm/helpers/normalizeValueWithProperty.js.map +2 -2
- package/dist/esm/helpers/proxyThemeVariables.js +2 -7
- package/dist/esm/helpers/proxyThemeVariables.js.map +2 -2
- package/dist/esm/helpers/useShallowSetState.js.map +2 -2
- package/dist/esm/hooks/getThemeUnwrapped.js +1 -3
- package/dist/esm/hooks/getThemeUnwrapped.js.map +2 -2
- package/dist/esm/hooks/useElementLayout.js +66 -0
- package/dist/esm/hooks/useElementLayout.js.map +7 -0
- package/dist/esm/hooks/useIsTouchDevice.js +3 -11
- package/dist/esm/hooks/useIsTouchDevice.js.map +2 -2
- package/dist/esm/hooks/useMedia.js +76 -84
- package/dist/esm/hooks/useMedia.js.map +2 -2
- package/dist/esm/hooks/useMedia.test.js +1 -0
- package/dist/esm/{helpers/validate.js.map → hooks/useMedia.test.js.map} +0 -0
- package/dist/esm/hooks/usePressablePressResponder.js +346 -0
- package/dist/esm/hooks/usePressablePressResponder.js.map +7 -0
- package/dist/esm/hooks/useSafeRef.js +13 -15
- package/dist/esm/hooks/useSafeRef.js.map +2 -2
- package/dist/esm/hooks/useTheme.js +5 -5
- package/dist/esm/hooks/useTheme.js.map +2 -2
- package/dist/esm/index.js +1 -14
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/static.js +0 -14
- package/dist/esm/static.js.map +2 -2
- package/dist/esm/styled.js +4 -22
- package/dist/esm/styled.js.map +2 -2
- package/dist/esm/views/AbsoluteFill.js +17 -0
- package/dist/esm/views/AbsoluteFill.js.map +7 -0
- package/dist/esm/views/AbsoluteFill.native.js +21 -0
- package/dist/esm/views/AbsoluteFill.native.js.map +7 -0
- package/dist/esm/views/FontLanguage.native.js.map +2 -2
- package/dist/esm/views/Stack.js.map +1 -1
- package/dist/esm/views/TamaguiProvider.js +5 -4
- package/dist/esm/views/TamaguiProvider.js.map +2 -2
- package/dist/esm/views/Text.js.map +1 -1
- package/dist/esm/views/ThemeReset.js +10 -10
- package/dist/esm/views/ThemeReset.js.map +2 -2
- package/package.json +14 -14
- package/src/Tamagui.ts +7 -3
- package/src/config.ts +2 -3
- package/src/constants/constants.ts +10 -6
- package/src/contexts/TextAncestorContext.tsx +1 -8
- package/src/createComponent.tsx +250 -412
- package/src/createTamagui.ts +16 -19
- package/src/createVariable.ts +1 -3
- package/src/helpers/ThemeManager.tsx +7 -15
- package/src/helpers/cache.ts +18 -0
- package/src/helpers/createMediaStyle.ts +16 -9
- package/src/helpers/createProxy.ts +16 -0
- package/src/helpers/extendStaticConfig.ts +0 -1
- package/src/helpers/getSplitStyles.tsx +259 -152
- package/src/helpers/getStylesAtomic.ts +14 -34
- package/src/helpers/getVariantExtras.tsx +2 -1
- package/src/helpers/insertStyleRule.tsx +16 -8
- package/src/helpers/matchMedia.ts +1 -0
- package/src/helpers/mergeTransform.ts +1 -1
- package/src/helpers/normalizeValueWithProperty.ts +30 -0
- package/src/helpers/proxyThemeVariables.tsx +3 -8
- package/src/helpers/useShallowSetState.tsx +0 -1
- package/src/hooks/getThemeUnwrapped.tsx +1 -2
- package/src/hooks/useElementLayout.tsx +90 -0
- package/src/hooks/useIsTouchDevice.tsx +3 -17
- package/src/hooks/useMedia.tsx +82 -88
- package/src/hooks/useSafeRef.ts +17 -18
- package/src/hooks/useTheme.tsx +6 -5
- package/src/index.ts +1 -11
- package/src/static.ts +0 -10
- package/src/styled.tsx +15 -33
- package/src/types.tsx +58 -55
- package/src/views/FontLanguage.native.tsx +1 -0
- package/src/views/Stack.tsx +1 -1
- package/src/views/TamaguiProvider.tsx +5 -5
- package/src/views/Text.tsx +1 -1
- package/src/views/ThemeReset.tsx +11 -11
- package/types/Tamagui.d.ts +6 -4
- package/types/constants/constants.d.ts +14 -3
- package/types/contexts/TextAncestorContext.d.ts +1 -3
- package/types/createComponent.d.ts +0 -15
- package/types/helpers/ThemeManager.d.ts +2 -3
- package/types/helpers/cache.d.ts +12 -0
- package/types/helpers/calc.d.ts +0 -16
- package/types/helpers/createMediaStyle.d.ts +1 -1
- package/types/helpers/createProxy.d.ts +2 -0
- package/types/helpers/getSplitStyles.d.ts +6 -10
- package/types/helpers/getStylesAtomic.d.ts +1 -5
- package/types/helpers/insertStyleRule.d.ts +2 -2
- package/types/helpers/mergeTransform.d.ts +1 -1
- package/types/helpers/normalizeValueWithProperty.d.ts +1 -0
- package/types/hooks/useElementLayout.d.ts +27 -0
- package/types/hooks/useMedia.d.ts +3 -1
- package/types/hooks/useMedia.test.d.ts +1 -0
- package/types/hooks/usePressablePressResponder.d.ts +84 -0
- package/types/index.d.ts +1 -11
- package/types/static.d.ts +0 -1
- package/types/types.d.ts +42 -44
- package/types/views/AbsoluteFill.d.ts +5 -0
- package/types/views/AbsoluteFill.native.d.ts +3 -0
- package/types/views/Stack.d.ts +1 -1
- package/types/views/Text.d.ts +1 -1
- package/dist/cjs/constants/platform.js +0 -74
- package/dist/cjs/constants/platform.js.map +0 -7
- package/dist/cjs/constants/platform.native.js +0 -62
- package/dist/cjs/constants/platform.native.js.map +0 -7
- package/dist/cjs/helpers/createShallowUpdate.js.map +0 -7
- package/dist/cjs/helpers/validate.js +0 -2
- package/dist/cjs/hooks/useDidFinishSSR.js +0 -60
- package/dist/cjs/hooks/useDidFinishSSR.js.map +0 -7
- package/dist/cjs/hooks/useIsSSR.js.map +0 -7
- package/dist/esm/constants/platform.js +0 -39
- package/dist/esm/constants/platform.js.map +0 -7
- package/dist/esm/constants/platform.native.js +0 -28
- package/dist/esm/constants/platform.native.js.map +0 -7
- package/dist/esm/helpers/createShallowUpdate.js +0 -20
- package/dist/esm/helpers/createShallowUpdate.js.map +0 -7
- package/dist/esm/helpers/validate.js +0 -1
- package/dist/esm/hooks/useDidFinishSSR.js +0 -35
- package/dist/esm/hooks/useDidFinishSSR.js.map +0 -7
- package/dist/esm/hooks/useIsSSR.js +0 -22
- package/dist/esm/hooks/useIsSSR.js.map +0 -7
- package/src/helpers/assignNativePropsToWeb.tsx +0 -178
- package/src/helpers/calc.ts +0 -68
- package/src/helpers/getFont.tsx +0 -43
- package/src/helpers/getStackSize.ts +0 -22
- package/src/helpers/startTransition.ts +0 -4
- package/src/hooks/useConstant.tsx +0 -19
- package/src/hooks/useIsMounted.ts +0 -16
- package/src/hooks/usePressable.tsx +0 -9
- package/src/hooks/useUnmountEffect.ts +0 -5
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useComposedRefs } from "@tamagui/compose-refs";
|
|
2
3
|
import { isClient, isRSC, isWeb, useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
3
4
|
import {
|
|
4
5
|
composeEventHandlers,
|
|
@@ -6,12 +7,7 @@ import {
|
|
|
6
7
|
validPseudoKeys,
|
|
7
8
|
validStyles
|
|
8
9
|
} from "@tamagui/helpers";
|
|
9
|
-
import {
|
|
10
|
-
useElementLayout,
|
|
11
|
-
useMergeRefs,
|
|
12
|
-
usePlatformMethods,
|
|
13
|
-
useResponderEvents
|
|
14
|
-
} from "@tamagui/rnw";
|
|
10
|
+
import { useResponderEvents } from "@tamagui/react-native-use-responder-events";
|
|
15
11
|
import { useForceUpdate } from "@tamagui/use-force-update";
|
|
16
12
|
import React, {
|
|
17
13
|
Children,
|
|
@@ -23,13 +19,10 @@ import React, {
|
|
|
23
19
|
useContext,
|
|
24
20
|
useEffect
|
|
25
21
|
} from "react";
|
|
26
|
-
import {
|
|
27
|
-
import { getConfig, onConfiguredOnce } from "./config";
|
|
22
|
+
import { onConfiguredOnce } from "./config";
|
|
28
23
|
import { stackDefaultStyles } from "./constants/constants";
|
|
29
24
|
import { FontLanguageContext } from "./contexts/FontLanguageContext";
|
|
30
25
|
import { TextAncestorContext } from "./contexts/TextAncestorContext";
|
|
31
|
-
import { assignNativePropsToWeb } from "./helpers/assignNativePropsToWeb";
|
|
32
|
-
import { getReturnVariablesAs } from "./helpers/createPropMapper";
|
|
33
26
|
import { extendStaticConfig, parseStaticConfig } from "./helpers/extendStaticConfig";
|
|
34
27
|
import {
|
|
35
28
|
getSubStyle,
|
|
@@ -40,8 +33,8 @@ import { getAllSelectors } from "./helpers/insertStyleRule";
|
|
|
40
33
|
import { mergeProps } from "./helpers/mergeProps";
|
|
41
34
|
import { proxyThemeVariables } from "./helpers/proxyThemeVariables";
|
|
42
35
|
import { useShallowSetState } from "./helpers/useShallowSetState";
|
|
36
|
+
import { getRect, measureLayout, useElementLayout } from "./hooks/useElementLayout";
|
|
43
37
|
import { addMediaQueryListener, getInitialMediaState } from "./hooks/useMedia";
|
|
44
|
-
import { usePressable } from "./hooks/usePressable";
|
|
45
38
|
import { useServerRef, useServerState } from "./hooks/useServerHooks";
|
|
46
39
|
import { getThemeManager, useTheme } from "./hooks/useTheme";
|
|
47
40
|
import { usePressability } from "./vendor/Pressability";
|
|
@@ -49,6 +42,11 @@ import { Slot, mergeEvent } from "./views/Slot";
|
|
|
49
42
|
import { wrapThemeManagerContext } from "./views/Theme";
|
|
50
43
|
React["keep"];
|
|
51
44
|
let defaultComponentState = null;
|
|
45
|
+
let defaultComponentStateMounted = null;
|
|
46
|
+
let tamaguiConfig;
|
|
47
|
+
let AnimatedText;
|
|
48
|
+
let AnimatedView;
|
|
49
|
+
let initialTheme;
|
|
52
50
|
const mouseUps = /* @__PURE__ */ new Set();
|
|
53
51
|
if (typeof document !== "undefined") {
|
|
54
52
|
const cancelTouches = () => {
|
|
@@ -64,8 +62,13 @@ function mergeShorthands({ defaultProps }, { shorthands }) {
|
|
|
64
62
|
defaultProps[shorthands[key] || key] = defaultProps[key];
|
|
65
63
|
}
|
|
66
64
|
}
|
|
67
|
-
let
|
|
68
|
-
let
|
|
65
|
+
let BaseText;
|
|
66
|
+
let BaseView;
|
|
67
|
+
if (process.env.TAMAGUI_TARGET === "native") {
|
|
68
|
+
const native = require("react-native");
|
|
69
|
+
BaseText = native.Text || native.default.Text;
|
|
70
|
+
BaseView = native.View || native.default.View;
|
|
71
|
+
}
|
|
69
72
|
function createComponent(configIn, ParentComponent) {
|
|
70
73
|
const staticConfig = (() => {
|
|
71
74
|
const next = extendStaticConfig(configIn, ParentComponent);
|
|
@@ -76,10 +79,7 @@ function createComponent(configIn, ParentComponent) {
|
|
|
76
79
|
}
|
|
77
80
|
})();
|
|
78
81
|
const defaultComponentClassName = `is_${staticConfig.componentName}`;
|
|
79
|
-
|
|
80
|
-
let AnimatedText;
|
|
81
|
-
let AnimatedView;
|
|
82
|
-
let avoidClassesWhileAnimating = true;
|
|
82
|
+
const avoidClassesWhileAnimating = true;
|
|
83
83
|
let defaultNativeStyle;
|
|
84
84
|
let tamaguiDefaultProps;
|
|
85
85
|
let initialSplitStyles;
|
|
@@ -96,10 +96,26 @@ function createComponent(configIn, ParentComponent) {
|
|
|
96
96
|
const componentName = props.componentName || staticConfig.componentName;
|
|
97
97
|
const componentClassName = props.asChild ? "" : props.componentName ? `is_${props.componentName}` : defaultComponentClassName;
|
|
98
98
|
const forceUpdate = useForceUpdate();
|
|
99
|
-
config = config || getConfig();
|
|
100
99
|
const theme = useTheme(props.theme, componentName, props, forceUpdate);
|
|
101
|
-
const
|
|
100
|
+
const hasEnterStyle = !!props.enterStyle;
|
|
101
|
+
const needsMount = Boolean((isWeb ? isClient : true) && (hasEnterStyle || props.animation));
|
|
102
|
+
const states = useServerState(
|
|
103
|
+
needsMount ? defaultComponentState : defaultComponentStateMounted
|
|
104
|
+
);
|
|
102
105
|
const state = propsIn.forceStyle ? { ...states[0], [propsIn.forceStyle]: true } : states[0];
|
|
106
|
+
const setState = states[1];
|
|
107
|
+
const setStateShallow = useShallowSetState(setState);
|
|
108
|
+
const shouldSetMounted = needsMount && !state.mounted;
|
|
109
|
+
const setMounted = shouldSetMounted ? () => {
|
|
110
|
+
setTimeout(
|
|
111
|
+
() => {
|
|
112
|
+
setStateShallow({
|
|
113
|
+
mounted: true
|
|
114
|
+
});
|
|
115
|
+
},
|
|
116
|
+
isWeb ? 10 : 0
|
|
117
|
+
);
|
|
118
|
+
} : void 0;
|
|
103
119
|
const shouldAvoidClasses = !!(props.animation && avoidClassesWhileAnimating) || !staticConfig.acceptsClassName;
|
|
104
120
|
const shouldForcePseudo = !!propsIn.forceStyle;
|
|
105
121
|
const hasTextAncestor = !!(isWeb && isText ? useContext(TextAncestorContext) : false);
|
|
@@ -115,25 +131,41 @@ function createComponent(configIn, ParentComponent) {
|
|
|
115
131
|
resolveVariablesAs: "value"
|
|
116
132
|
};
|
|
117
133
|
const languageContext = isRSC ? null : useContext(FontLanguageContext);
|
|
134
|
+
const useAnimations = (_a = tamaguiConfig.animations) == null ? void 0 : _a.useAnimations;
|
|
135
|
+
const nextIsAnimated = !!(useAnimations && props.animation);
|
|
136
|
+
const isAnimated = nextIsAnimated || state.hasAnimation;
|
|
137
|
+
if (nextIsAnimated && !state.hasAnimation) {
|
|
138
|
+
setStateShallow({ hasAnimation: true });
|
|
139
|
+
}
|
|
140
|
+
const isTaggable = !Component || typeof Component === "string";
|
|
141
|
+
const element = isWeb ? isTaggable ? props.tag || Component : Component : Component;
|
|
142
|
+
const BaseTextComponent = BaseText || element || "span";
|
|
143
|
+
const BaseViewComponent = BaseView || element || (hasTextAncestor ? "span" : "div");
|
|
144
|
+
let elementType = isText ? (isAnimated ? AnimatedText : null) || BaseTextComponent : (isAnimated ? AnimatedView : null) || BaseViewComponent;
|
|
145
|
+
elementType = Component || elementType;
|
|
146
|
+
const isStringElement = typeof elementType === "string";
|
|
118
147
|
const splitStyles = useSplitStyles(
|
|
119
148
|
props,
|
|
120
149
|
staticConfig,
|
|
121
150
|
theme,
|
|
122
151
|
splitStyleState,
|
|
123
|
-
props.asChild ? null : initialSplitStyles
|
|
152
|
+
props.asChild ? null : initialSplitStyles,
|
|
124
153
|
languageContext || void 0,
|
|
154
|
+
elementType,
|
|
125
155
|
debugProp
|
|
126
156
|
);
|
|
127
157
|
const hostRef = useServerRef(null);
|
|
128
|
-
const
|
|
129
|
-
|
|
158
|
+
const isReactNativeWeb = Boolean(
|
|
159
|
+
staticConfig.isReactNativeWeb || isAnimated && tamaguiConfig.animations.isReactNativeWeb
|
|
160
|
+
);
|
|
161
|
+
const isAnimatedReactNativeWeb = isAnimated && avoidClassesWhileAnimating;
|
|
130
162
|
if (process.env.NODE_ENV === "development") {
|
|
131
163
|
if (!process.env.TAMAGUI_TARGET) {
|
|
132
164
|
console.error(`No process.env.TAMAGUI_TARGET set, please set it to "native" or "web".`);
|
|
133
165
|
}
|
|
134
166
|
if (debugProp) {
|
|
135
167
|
const name = `${componentName || (Component == null ? void 0 : Component.displayName) || (Component == null ? void 0 : Component.name) || "[Unnamed Component]"}`;
|
|
136
|
-
const type =
|
|
168
|
+
const type = isReactNativeWeb ? "rnw" : "tamagui";
|
|
137
169
|
const banner = `${name} ${propsIn["data-is"] || ""} ${type}`;
|
|
138
170
|
console.group(`%c \u{1F41B} ${banner}`, "background: yellow;");
|
|
139
171
|
console.groupCollapsed("initial props/state");
|
|
@@ -157,42 +189,11 @@ function createComponent(configIn, ParentComponent) {
|
|
|
157
189
|
classNames,
|
|
158
190
|
mediaKeys
|
|
159
191
|
} = splitStyles;
|
|
160
|
-
useIsomorphicLayoutEffect(() => {
|
|
161
|
-
if (!mediaKeys.length) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
const disposers = [];
|
|
165
|
-
for (const key of mediaKeys) {
|
|
166
|
-
disposers.push(
|
|
167
|
-
addMediaQueryListener(key, (next) => {
|
|
168
|
-
setState((prev) => {
|
|
169
|
-
if (prev.mediaState[key] !== next) {
|
|
170
|
-
return {
|
|
171
|
-
...prev,
|
|
172
|
-
mediaState: {
|
|
173
|
-
...prev.mediaState,
|
|
174
|
-
[key]: next
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
return prev;
|
|
179
|
-
});
|
|
180
|
-
})
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
return () => {
|
|
184
|
-
};
|
|
185
|
-
}, [mediaKeys.join(",")]);
|
|
186
|
-
const useAnimations = (_a = tamaguiConfig == null ? void 0 : tamaguiConfig.animations) == null ? void 0 : _a.useAnimations;
|
|
187
|
-
const nextIsAnimated = !!(useAnimations && props.animation);
|
|
188
|
-
const isAnimated = nextIsAnimated || state.hasAnimation;
|
|
189
|
-
if (nextIsAnimated && !state.hasAnimation) {
|
|
190
|
-
setStateShallow({ hasAnimation: true });
|
|
191
|
-
}
|
|
192
192
|
const animationFeatureStylesIn = props.animation ? { ...defaultNativeStyle, ...splitStylesStyle } : null;
|
|
193
193
|
const propsWithAnimation = props;
|
|
194
|
+
let animationStyles;
|
|
194
195
|
if (!isRSC && isAnimated && useAnimations) {
|
|
195
|
-
const
|
|
196
|
+
const animations = useAnimations(propsWithAnimation, {
|
|
196
197
|
state,
|
|
197
198
|
pseudos,
|
|
198
199
|
onDidAnimate: props.onDidAnimate,
|
|
@@ -223,7 +224,6 @@ function createComponent(configIn, ParentComponent) {
|
|
|
223
224
|
style,
|
|
224
225
|
pseudos.hoverStyle,
|
|
225
226
|
pseudos.focusStyle,
|
|
226
|
-
pseudos.pressStyle,
|
|
227
227
|
pseudos.pressStyle
|
|
228
228
|
);
|
|
229
229
|
enterStyle && isEntering && merge(style, enterStyle);
|
|
@@ -232,21 +232,46 @@ function createComponent(configIn, ParentComponent) {
|
|
|
232
232
|
state.press && pseudos.pressStyle && merge(style, pseudos.pressStyle);
|
|
233
233
|
exitStyle && isExiting && merge(style, exitStyle);
|
|
234
234
|
if (process.env.NODE_ENV === "development") {
|
|
235
|
-
if (debugProp) {
|
|
235
|
+
if (debugProp === "verbose") {
|
|
236
236
|
console.log("animation style", style);
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
return style;
|
|
240
240
|
}
|
|
241
241
|
});
|
|
242
|
-
if (
|
|
243
|
-
|
|
244
|
-
animation: animationState
|
|
245
|
-
});
|
|
242
|
+
if (animations) {
|
|
243
|
+
animationStyles = animations.style;
|
|
246
244
|
}
|
|
247
245
|
}
|
|
246
|
+
useIsomorphicLayoutEffect(() => {
|
|
247
|
+
if (!mediaKeys.length)
|
|
248
|
+
return;
|
|
249
|
+
const disposers = [];
|
|
250
|
+
for (const key of mediaKeys) {
|
|
251
|
+
disposers.push(
|
|
252
|
+
addMediaQueryListener(key, (next) => {
|
|
253
|
+
setState((prev) => {
|
|
254
|
+
if (prev.mediaState[key] !== next) {
|
|
255
|
+
return {
|
|
256
|
+
...prev,
|
|
257
|
+
mediaState: {
|
|
258
|
+
...prev.mediaState,
|
|
259
|
+
[key]: next
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
return prev;
|
|
264
|
+
});
|
|
265
|
+
})
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
return () => {
|
|
269
|
+
for (const disposer of disposers) {
|
|
270
|
+
disposer();
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
}, [mediaKeys.join(",")]);
|
|
248
274
|
const {
|
|
249
|
-
tag,
|
|
250
275
|
hitSlop,
|
|
251
276
|
asChild,
|
|
252
277
|
children,
|
|
@@ -271,30 +296,9 @@ function createComponent(configIn, ParentComponent) {
|
|
|
271
296
|
defaultVariants,
|
|
272
297
|
...nonTamaguiProps
|
|
273
298
|
} = viewPropsIn;
|
|
274
|
-
const isTaggable = !Component || typeof Component === "string";
|
|
275
|
-
const element = isWeb ? isTaggable ? tag || Component : Component : Component;
|
|
276
|
-
const BaseTextComponent = !isWeb ? Text : element || "span";
|
|
277
|
-
const BaseViewComponent = !isWeb ? View : element || (hasTextAncestor ? "span" : "div");
|
|
278
|
-
let elementType = isText ? (isAnimated ? AnimatedText || Text : null) || BaseTextComponent : (isAnimated ? AnimatedView || View : null) || BaseViewComponent;
|
|
279
|
-
elementType = Component || elementType;
|
|
280
|
-
const isStringElement = typeof elementType === "string";
|
|
281
299
|
const disabled = props.accessibilityState != null && props.accessibilityState.disabled === true || props.accessibilityDisabled;
|
|
282
300
|
let viewProps;
|
|
283
|
-
|
|
284
|
-
const shouldSetMounted = Boolean(
|
|
285
|
-
(isWeb ? isClient : true) && (hasEnterStyle || props.animation) && !state.mounted
|
|
286
|
-
);
|
|
287
|
-
const setMounted = shouldSetMounted ? () => {
|
|
288
|
-
setTimeout(
|
|
289
|
-
() => {
|
|
290
|
-
setStateShallow({
|
|
291
|
-
mounted: true
|
|
292
|
-
});
|
|
293
|
-
},
|
|
294
|
-
isWeb ? 10 : 0
|
|
295
|
-
);
|
|
296
|
-
} : void 0;
|
|
297
|
-
if (process.env.TAMAGUI_TARGET === "web" && !staticConfig.isReactNativeWeb) {
|
|
301
|
+
if (process.env.TAMAGUI_TARGET === "web" && !isReactNativeWeb) {
|
|
298
302
|
const {
|
|
299
303
|
onMoveShouldSetResponder,
|
|
300
304
|
onMoveShouldSetResponderCapture,
|
|
@@ -312,64 +316,16 @@ function createComponent(configIn, ParentComponent) {
|
|
|
312
316
|
onSelectionChangeShouldSetResponderCapture,
|
|
313
317
|
onStartShouldSetResponder,
|
|
314
318
|
onStartShouldSetResponderCapture,
|
|
315
|
-
nativeID,
|
|
316
|
-
accessibilityActiveDescendant,
|
|
317
|
-
accessibilityAtomic,
|
|
318
|
-
accessibilityAutoComplete,
|
|
319
|
-
accessibilityBusy,
|
|
320
|
-
accessibilityChecked,
|
|
321
|
-
accessibilityColumnCount,
|
|
322
|
-
accessibilityColumnIndex,
|
|
323
|
-
accessibilityColumnSpan,
|
|
324
|
-
accessibilityControls,
|
|
325
|
-
accessibilityCurrent,
|
|
326
|
-
accessibilityDescribedBy,
|
|
327
|
-
accessibilityDetails,
|
|
328
|
-
accessibilityDisabled,
|
|
329
|
-
accessibilityErrorMessage,
|
|
330
|
-
accessibilityExpanded,
|
|
331
|
-
accessibilityFlowTo,
|
|
332
|
-
accessibilityHasPopup,
|
|
333
|
-
accessibilityHidden,
|
|
334
|
-
accessibilityInvalid,
|
|
335
|
-
accessibilityKeyShortcuts,
|
|
336
|
-
accessibilityLabel,
|
|
337
|
-
accessibilityLabelledBy,
|
|
338
|
-
accessibilityLevel,
|
|
339
|
-
accessibilityLiveRegion,
|
|
340
|
-
accessibilityModal,
|
|
341
|
-
accessibilityMultiline,
|
|
342
|
-
accessibilityMultiSelectable,
|
|
343
|
-
accessibilityOrientation,
|
|
344
|
-
accessibilityOwns,
|
|
345
|
-
accessibilityPlaceholder,
|
|
346
|
-
accessibilityPosInSet,
|
|
347
|
-
accessibilityPressed,
|
|
348
|
-
accessibilityReadOnly,
|
|
349
|
-
accessibilityRequired,
|
|
350
|
-
accessibilityRole,
|
|
351
|
-
accessibilityRoleDescription,
|
|
352
|
-
accessibilityRowCount,
|
|
353
|
-
accessibilityRowIndex,
|
|
354
|
-
accessibilityRowSpan,
|
|
355
|
-
accessibilitySelected,
|
|
356
|
-
accessibilitySetSize,
|
|
357
|
-
accessibilitySort,
|
|
358
|
-
accessibilityValueMax,
|
|
359
|
-
accessibilityValueMin,
|
|
360
|
-
accessibilityValueNow,
|
|
361
|
-
accessibilityValueText,
|
|
362
|
-
accessible,
|
|
363
|
-
accessibilityState,
|
|
364
|
-
accessibilityValue,
|
|
365
319
|
collapsable,
|
|
366
320
|
focusable,
|
|
321
|
+
accessible,
|
|
322
|
+
accessibilityDisabled,
|
|
367
323
|
onLayout,
|
|
368
324
|
...webProps
|
|
369
325
|
} = nonTamaguiProps;
|
|
370
326
|
viewProps = webProps;
|
|
371
|
-
assignNativePropsToWeb(elementType, viewProps, nonTamaguiProps);
|
|
372
327
|
if (!isRSC) {
|
|
328
|
+
usePlatformMethods(hostRef);
|
|
373
329
|
useElementLayout(hostRef, onLayout);
|
|
374
330
|
useResponderEvents(hostRef, {
|
|
375
331
|
onMoveShouldSetResponder,
|
|
@@ -389,9 +345,6 @@ function createComponent(configIn, ParentComponent) {
|
|
|
389
345
|
onStartShouldSetResponder,
|
|
390
346
|
onStartShouldSetResponderCapture
|
|
391
347
|
});
|
|
392
|
-
const platformMethodsRef = usePlatformMethods(viewProps);
|
|
393
|
-
const setRef = useMergeRefs(hostRef, platformMethodsRef, forwardedRef, setMounted);
|
|
394
|
-
viewProps.ref = setRef;
|
|
395
348
|
}
|
|
396
349
|
if (props.href != void 0 && hrefAttrs != void 0) {
|
|
397
350
|
const { download, rel, target } = hrefAttrs;
|
|
@@ -424,10 +377,8 @@ function createComponent(configIn, ParentComponent) {
|
|
|
424
377
|
}
|
|
425
378
|
} else {
|
|
426
379
|
viewProps = nonTamaguiProps;
|
|
427
|
-
if (forwardedRef) {
|
|
428
|
-
viewProps.ref = forwardedRef;
|
|
429
|
-
}
|
|
430
380
|
}
|
|
381
|
+
viewProps.ref = useComposedRefs(hostRef, forwardedRef, setMounted);
|
|
431
382
|
if (process.env.NODE_ENV === "development" && !isText && isWeb && !staticConfig.isHOC) {
|
|
432
383
|
Children.toArray(props.children).forEach((item) => {
|
|
433
384
|
if (typeof item === "string") {
|
|
@@ -449,7 +400,6 @@ function createComponent(configIn, ParentComponent) {
|
|
|
449
400
|
}, [unPress]);
|
|
450
401
|
}
|
|
451
402
|
let styles;
|
|
452
|
-
const animationStyles = state.animation ? state.animation.style : null;
|
|
453
403
|
if (isStringElement && shouldAvoidClasses && !shouldForcePseudo) {
|
|
454
404
|
styles = {
|
|
455
405
|
...defaultNativeStyle,
|
|
@@ -475,34 +425,23 @@ function createComponent(configIn, ParentComponent) {
|
|
|
475
425
|
Object.assign(splitStyles.style, next);
|
|
476
426
|
}
|
|
477
427
|
}
|
|
428
|
+
let fontFamily = isText ? splitStyles.fontFamily || staticConfig.defaultProps.fontFamily : null;
|
|
429
|
+
if (fontFamily && fontFamily[0] === "$") {
|
|
430
|
+
fontFamily = fontFamily.slice(1);
|
|
431
|
+
}
|
|
432
|
+
const fontFamilyClassName = fontFamily ? `font_${fontFamily}` : "";
|
|
478
433
|
if (process.env.TAMAGUI_TARGET === "web") {
|
|
479
|
-
let fontFamily = isText ? splitStyles.fontFamily || staticConfig.defaultProps.fontFamily : null;
|
|
480
|
-
if (fontFamily && fontFamily[0] === "$") {
|
|
481
|
-
fontFamily = fontFamily.slice(1);
|
|
482
|
-
}
|
|
483
|
-
if (process.env.NODE_ENV === "development") {
|
|
484
|
-
if (fontFamily == null ? void 0 : fontFamily.startsWith(`var(`)) {
|
|
485
|
-
console.warn(
|
|
486
|
-
`Received variable instead of resolved name of font, this is a bug. Please report on Github.`,
|
|
487
|
-
{
|
|
488
|
-
fontFamily,
|
|
489
|
-
props,
|
|
490
|
-
splitStyles,
|
|
491
|
-
staticConfig
|
|
492
|
-
}
|
|
493
|
-
);
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
434
|
const classList = [
|
|
497
435
|
componentName ? componentClassName : "",
|
|
498
|
-
|
|
436
|
+
fontFamilyClassName,
|
|
499
437
|
theme.className,
|
|
500
438
|
classNames ? Object.values(classNames).join(" ") : ""
|
|
501
439
|
];
|
|
502
440
|
const className = classList.join(" ");
|
|
503
441
|
const style = animationStyles ?? splitStyles.style;
|
|
504
|
-
|
|
505
|
-
|
|
442
|
+
if (isAnimatedReactNativeWeb) {
|
|
443
|
+
viewProps.style = style;
|
|
444
|
+
} else if (isReactNativeWeb) {
|
|
506
445
|
const rnwStyle = { $$css: true };
|
|
507
446
|
for (const name of className.split(" ")) {
|
|
508
447
|
rnwStyle[name] = name;
|
|
@@ -523,10 +462,8 @@ function createComponent(configIn, ParentComponent) {
|
|
|
523
462
|
}
|
|
524
463
|
}
|
|
525
464
|
if (process.env.TAMAGUI_TARGET === "native") {
|
|
526
|
-
const mergedRef = useMergeRefs(forwardedRef, hostRef, setMounted);
|
|
527
|
-
viewProps.ref = mergedRef;
|
|
528
465
|
if (splitStyles.fontFamily) {
|
|
529
|
-
const faceInfo = (_b =
|
|
466
|
+
const faceInfo = (_b = tamaguiConfig.fontsParsed[splitStyles.fontFamily]) == null ? void 0 : _b.face;
|
|
530
467
|
if (faceInfo) {
|
|
531
468
|
const [weight, style] = (() => {
|
|
532
469
|
var _a2, _b2;
|
|
@@ -554,13 +491,10 @@ function createComponent(configIn, ParentComponent) {
|
|
|
554
491
|
const attachPress = !!((pseudos == null ? void 0 : pseudos.pressStyle) || (initialPseudos == null ? void 0 : initialPseudos.pressStyle) || onPress || onPressOut || onPressIn || onClick);
|
|
555
492
|
const isHoverable = isWeb;
|
|
556
493
|
const attachHover = isHoverable && !!(pseudos && pseudos.hoverStyle || onHoverIn || onHoverOut || onMouseEnter || onMouseLeave);
|
|
557
|
-
const handlesPressEvents = !
|
|
558
|
-
const pressKey = handlesPressEvents ? "onPress" : "onClick";
|
|
559
|
-
const pressInKey = handlesPressEvents ? "onPressIn" : "onMouseDown";
|
|
560
|
-
const pressOutKey = handlesPressEvents ? "onPressOut" : "onMouseUp";
|
|
494
|
+
const handlesPressEvents = !isWeb && !asChild;
|
|
561
495
|
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));
|
|
562
496
|
const events = shouldAttach && !isRSC ? {
|
|
563
|
-
|
|
497
|
+
onPressOut: attachPress ? (e) => {
|
|
564
498
|
unPress();
|
|
565
499
|
onPressOut == null ? void 0 : onPressOut(e);
|
|
566
500
|
onMouseUp == null ? void 0 : onMouseUp(e);
|
|
@@ -574,7 +508,7 @@ function createComponent(configIn, ParentComponent) {
|
|
|
574
508
|
if (state.pressIn) {
|
|
575
509
|
next.press = true;
|
|
576
510
|
}
|
|
577
|
-
if (
|
|
511
|
+
if (attachHover || state.pressIn) {
|
|
578
512
|
setStateShallow(next);
|
|
579
513
|
}
|
|
580
514
|
onHoverIn == null ? void 0 : onHoverIn(e);
|
|
@@ -597,7 +531,7 @@ function createComponent(configIn, ParentComponent) {
|
|
|
597
531
|
onMouseLeave == null ? void 0 : onMouseLeave(e);
|
|
598
532
|
} : void 0
|
|
599
533
|
},
|
|
600
|
-
|
|
534
|
+
onPressIn: attachPress ? (e) => {
|
|
601
535
|
setStateShallow({
|
|
602
536
|
press: true,
|
|
603
537
|
pressIn: true,
|
|
@@ -608,12 +542,12 @@ function createComponent(configIn, ParentComponent) {
|
|
|
608
542
|
if (isWeb) {
|
|
609
543
|
mouseUps.add(unPress);
|
|
610
544
|
}
|
|
611
|
-
} :
|
|
612
|
-
|
|
545
|
+
} : void 0,
|
|
546
|
+
onPress: attachPress ? (e) => {
|
|
613
547
|
unPress();
|
|
614
548
|
onClick == null ? void 0 : onClick(e);
|
|
615
549
|
onPress == null ? void 0 : onPress(e);
|
|
616
|
-
} :
|
|
550
|
+
} : void 0,
|
|
617
551
|
...!isWeb && {
|
|
618
552
|
cancelable: !props.rejectResponderTermination,
|
|
619
553
|
disabled: props.disabled !== null ? props.disabled : (_e = props.accessibilityState) == null ? void 0 : _e.disabled,
|
|
@@ -661,28 +595,6 @@ function createComponent(configIn, ParentComponent) {
|
|
|
661
595
|
onPressOut
|
|
662
596
|
};
|
|
663
597
|
}
|
|
664
|
-
if (!isRSC && isWeb) {
|
|
665
|
-
const [pressableProps] = usePressable(
|
|
666
|
-
events ? {
|
|
667
|
-
disabled,
|
|
668
|
-
...hitSlop && {
|
|
669
|
-
hitSlop
|
|
670
|
-
},
|
|
671
|
-
onPressOut: events[pressOutKey],
|
|
672
|
-
onPressIn: events[pressInKey],
|
|
673
|
-
onPress: events[pressKey]
|
|
674
|
-
} : {
|
|
675
|
-
disabled: true
|
|
676
|
-
}
|
|
677
|
-
);
|
|
678
|
-
if (events) {
|
|
679
|
-
if (handlesPressEvents) {
|
|
680
|
-
Object.assign(viewProps, pressableProps);
|
|
681
|
-
} else {
|
|
682
|
-
Object.assign(viewProps, events);
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
598
|
if (process.env.TAMAGUI_TARGET === "native") {
|
|
687
599
|
const attachFocus = !!(pseudos && pseudos.focusStyle || initialPseudos && initialPseudos.focusStyle);
|
|
688
600
|
if (attachFocus) {
|
|
@@ -695,9 +607,6 @@ function createComponent(configIn, ParentComponent) {
|
|
|
695
607
|
}
|
|
696
608
|
const pressability = usePressability(events);
|
|
697
609
|
if (attachPress && events) {
|
|
698
|
-
const dontComposePressabilityKeys = {
|
|
699
|
-
onClick: true
|
|
700
|
-
};
|
|
701
610
|
if (hitSlop) {
|
|
702
611
|
viewProps.hitSlop = hitSlop;
|
|
703
612
|
}
|
|
@@ -710,21 +619,23 @@ function createComponent(configIn, ParentComponent) {
|
|
|
710
619
|
}
|
|
711
620
|
content = createElement(elementType, viewProps, childEls);
|
|
712
621
|
if (process.env.TAMAGUI_TARGET === "web") {
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
622
|
+
if (events) {
|
|
623
|
+
content = /* @__PURE__ */ jsx("span", {
|
|
624
|
+
style: styleDisplayContents,
|
|
625
|
+
onMouseEnter: events.onMouseEnter,
|
|
626
|
+
onMouseLeave: events.onMouseLeave,
|
|
627
|
+
onClick: events.onPress,
|
|
628
|
+
onMouseDown: events.onPressIn,
|
|
629
|
+
onMouseUp: events.onPressOut,
|
|
630
|
+
onTouchStart: events.onPressIn,
|
|
631
|
+
onTouchEnd: events.onPressOut,
|
|
632
|
+
children: content
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
if (isText && isAnimatedReactNativeWeb) {
|
|
719
636
|
content = /* @__PURE__ */ jsx("span", {
|
|
720
|
-
className:
|
|
721
|
-
style:
|
|
722
|
-
display: "contents"
|
|
723
|
-
},
|
|
724
|
-
...events && shouldWrapWithHover && {
|
|
725
|
-
onMouseEnter: events.onMouseEnter,
|
|
726
|
-
onMouseLeave: events.onMouseLeave
|
|
727
|
-
},
|
|
637
|
+
className: fontFamilyClassName,
|
|
638
|
+
style: styleDisplayContents,
|
|
728
639
|
children: content
|
|
729
640
|
});
|
|
730
641
|
}
|
|
@@ -750,49 +661,47 @@ function createComponent(configIn, ParentComponent) {
|
|
|
750
661
|
component.displayName = staticConfig.componentName;
|
|
751
662
|
}
|
|
752
663
|
onConfiguredOnce((conf) => {
|
|
753
|
-
if (!
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
664
|
+
if (!tamaguiConfig) {
|
|
665
|
+
tamaguiConfig = conf;
|
|
666
|
+
if (!defaultComponentState) {
|
|
667
|
+
defaultComponentState = {
|
|
668
|
+
hover: false,
|
|
669
|
+
press: false,
|
|
670
|
+
pressIn: false,
|
|
671
|
+
focus: false,
|
|
672
|
+
mounted: false,
|
|
673
|
+
mediaState: getInitialMediaState()
|
|
674
|
+
};
|
|
675
|
+
defaultComponentStateMounted = {
|
|
676
|
+
...defaultComponentState,
|
|
677
|
+
mounted: true
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
if (tamaguiConfig.animations) {
|
|
681
|
+
AnimatedText = tamaguiConfig.animations.Text;
|
|
682
|
+
AnimatedView = tamaguiConfig.animations.View;
|
|
683
|
+
}
|
|
684
|
+
if (!initialTheme) {
|
|
685
|
+
const next = conf.themes[conf.defaultTheme || Object.keys(conf.themes)[0]];
|
|
686
|
+
initialTheme = proxyThemeVariables(next);
|
|
687
|
+
if (!initialTheme && process.env.NODE_ENV === "development") {
|
|
688
|
+
console.log(`Warning: Missing theme`);
|
|
689
|
+
}
|
|
778
690
|
}
|
|
779
691
|
}
|
|
780
|
-
|
|
692
|
+
mergeShorthands(staticConfig, tamaguiConfig);
|
|
781
693
|
let defaultPropsIn = staticConfig.defaultProps || {};
|
|
782
694
|
const parentNames = [...staticConfig.parentNames || [], staticConfig.componentName];
|
|
783
|
-
if (
|
|
695
|
+
if (tamaguiConfig.defaultProps && parentNames && staticConfig.componentName) {
|
|
784
696
|
defaultPropsIn = mergeConfigDefaultProps(
|
|
785
697
|
staticConfig.componentName,
|
|
786
698
|
defaultPropsIn,
|
|
787
|
-
|
|
699
|
+
tamaguiConfig.defaultProps,
|
|
788
700
|
parentNames,
|
|
789
|
-
|
|
701
|
+
tamaguiConfig
|
|
790
702
|
);
|
|
791
703
|
}
|
|
792
704
|
const debug = defaultPropsIn["debug"];
|
|
793
|
-
if (process.env.NODE_ENV === "development" && debug === "break") {
|
|
794
|
-
debugger;
|
|
795
|
-
}
|
|
796
705
|
const [parentProps, parentClassNames] = mergeProps(defaultPropsIn, {}, true);
|
|
797
706
|
initialSplitStyles = insertSplitStyles(
|
|
798
707
|
parentProps,
|
|
@@ -920,9 +829,6 @@ const Spacer = createComponent({
|
|
|
920
829
|
},
|
|
921
830
|
both: {}
|
|
922
831
|
}
|
|
923
|
-
},
|
|
924
|
-
defaultVariants: {
|
|
925
|
-
direction: "both"
|
|
926
832
|
}
|
|
927
833
|
});
|
|
928
834
|
function spacedChildren({
|
|
@@ -968,7 +874,7 @@ function spacedChildren({
|
|
|
968
874
|
if (hasSpace) {
|
|
969
875
|
final.push(
|
|
970
876
|
createSpacer({
|
|
971
|
-
key: `_${index}
|
|
877
|
+
key: `_${index}_00tmgui`,
|
|
972
878
|
direction,
|
|
973
879
|
space,
|
|
974
880
|
spaceFlex
|
|
@@ -981,7 +887,7 @@ function spacedChildren({
|
|
|
981
887
|
if (hasSpace) {
|
|
982
888
|
final.push(
|
|
983
889
|
createSpacer({
|
|
984
|
-
key: `_${index}
|
|
890
|
+
key: `_${index}01tmgui`,
|
|
985
891
|
direction,
|
|
986
892
|
space,
|
|
987
893
|
spaceFlex
|
|
@@ -991,7 +897,7 @@ function spacedChildren({
|
|
|
991
897
|
} else {
|
|
992
898
|
final.push(
|
|
993
899
|
createSpacer({
|
|
994
|
-
key: `_${index}
|
|
900
|
+
key: `_${index}02tmgui`,
|
|
995
901
|
direction,
|
|
996
902
|
space,
|
|
997
903
|
spaceFlex
|
|
@@ -1015,37 +921,6 @@ function isUnspaced(child) {
|
|
|
1015
921
|
var _a, _b;
|
|
1016
922
|
return ((_a = child == null ? void 0 : child["type"]) == null ? void 0 : _a["isVisuallyHidden"]) || ((_b = child == null ? void 0 : child["type"]) == null ? void 0 : _b["isUnspaced"]);
|
|
1017
923
|
}
|
|
1018
|
-
function AbsoluteFill(props) {
|
|
1019
|
-
return /* @__PURE__ */ jsx(View, {
|
|
1020
|
-
pointerEvents: "box-none",
|
|
1021
|
-
style: absoluteFill,
|
|
1022
|
-
children: props.children
|
|
1023
|
-
});
|
|
1024
|
-
}
|
|
1025
|
-
const absoluteFill = {
|
|
1026
|
-
position: "absolute",
|
|
1027
|
-
top: 0,
|
|
1028
|
-
left: 0,
|
|
1029
|
-
right: 0,
|
|
1030
|
-
bottom: 0
|
|
1031
|
-
};
|
|
1032
|
-
function processIDRefList(idRefList) {
|
|
1033
|
-
return Array.isArray(idRefList) ? idRefList.join(" ") : idRefList;
|
|
1034
|
-
}
|
|
1035
|
-
const accessibilityRoleToWebRole = {
|
|
1036
|
-
adjustable: "slider",
|
|
1037
|
-
button: "button",
|
|
1038
|
-
header: "heading",
|
|
1039
|
-
image: "img",
|
|
1040
|
-
imagebutton: null,
|
|
1041
|
-
keyboardkey: null,
|
|
1042
|
-
label: null,
|
|
1043
|
-
link: "link",
|
|
1044
|
-
none: "presentation",
|
|
1045
|
-
search: "search",
|
|
1046
|
-
summary: "region",
|
|
1047
|
-
text: null
|
|
1048
|
-
};
|
|
1049
924
|
function addPseudoToStyles(styles, initialPseudos, pseudos, name, force = false) {
|
|
1050
925
|
const pseudoStyle = pseudos[name];
|
|
1051
926
|
const shouldNestObject = isWeb && name !== "enterStyle" && name !== "exitStyle";
|
|
@@ -1146,13 +1021,47 @@ function merge(base, next) {
|
|
|
1146
1021
|
}
|
|
1147
1022
|
}
|
|
1148
1023
|
}
|
|
1024
|
+
function usePlatformMethods(hostRef) {
|
|
1025
|
+
useIsomorphicLayoutEffect(() => {
|
|
1026
|
+
const node = hostRef.current;
|
|
1027
|
+
if (!node)
|
|
1028
|
+
return;
|
|
1029
|
+
node.measure = (callback) => measureLayout(node, null, callback);
|
|
1030
|
+
node.measureLayout = (relativeToNode, success) => measureLayout(node, relativeToNode, success);
|
|
1031
|
+
node.measureInWindow = (callback) => {
|
|
1032
|
+
if (!node)
|
|
1033
|
+
return;
|
|
1034
|
+
setTimeout(() => {
|
|
1035
|
+
const { height, left, top, width } = getRect(node);
|
|
1036
|
+
callback(left, top, width, height);
|
|
1037
|
+
}, 0);
|
|
1038
|
+
};
|
|
1039
|
+
}, [hostRef]);
|
|
1040
|
+
}
|
|
1041
|
+
const AbsoluteFill = createComponent({
|
|
1042
|
+
componentName: "AbsoluteFill",
|
|
1043
|
+
defaultProps: {
|
|
1044
|
+
...stackDefaultStyles,
|
|
1045
|
+
flexDirection: "column",
|
|
1046
|
+
position: "absolute",
|
|
1047
|
+
top: 0,
|
|
1048
|
+
right: 0,
|
|
1049
|
+
bottom: 0,
|
|
1050
|
+
left: 0,
|
|
1051
|
+
pointerEvents: "box-none"
|
|
1052
|
+
}
|
|
1053
|
+
});
|
|
1054
|
+
const styleDisplayContents = {
|
|
1055
|
+
display: "contents"
|
|
1056
|
+
};
|
|
1057
|
+
const dontComposePressabilityKeys = {
|
|
1058
|
+
onClick: true
|
|
1059
|
+
};
|
|
1149
1060
|
export {
|
|
1150
1061
|
Spacer,
|
|
1151
1062
|
Unspaced,
|
|
1152
|
-
accessibilityRoleToWebRole,
|
|
1153
1063
|
createComponent,
|
|
1154
1064
|
mouseUps,
|
|
1155
|
-
processIDRefList,
|
|
1156
1065
|
spacedChildren
|
|
1157
1066
|
};
|
|
1158
1067
|
//# sourceMappingURL=createComponent.js.map
|