@tamagui/core 1.0.1-beta.193 → 1.0.1-beta.195
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 +204 -294
- 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 +212 -93
- 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/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/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 +77 -84
- 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 +3 -4
- 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 +203 -296
- 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 +221 -94
- 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/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/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 +74 -83
- 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 +3 -4
- 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 +256 -421
- 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/extendStaticConfig.ts +0 -1
- package/src/helpers/getSplitStyles.tsx +257 -151
- package/src/helpers/getStylesAtomic.ts +14 -34
- 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/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 +80 -87
- package/src/hooks/useSafeRef.ts +17 -18
- package/src/hooks/useTheme.tsx +4 -4
- 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/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,41 +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
|
-
const isAnimatedReactNativeWeb = props.animation && avoidClassesWhileAnimating;
|
|
505
442
|
if (isAnimatedReactNativeWeb) {
|
|
506
443
|
viewProps.style = style;
|
|
507
|
-
|
|
508
|
-
...viewProps.dataSet,
|
|
509
|
-
className,
|
|
510
|
-
id: props.id
|
|
511
|
-
};
|
|
512
|
-
} else if (staticConfig.isReactNativeWeb) {
|
|
444
|
+
} else if (isReactNativeWeb) {
|
|
513
445
|
const rnwStyle = { $$css: true };
|
|
514
446
|
for (const name of className.split(" ")) {
|
|
515
447
|
rnwStyle[name] = name;
|
|
@@ -530,10 +462,8 @@ function createComponent(configIn, ParentComponent) {
|
|
|
530
462
|
}
|
|
531
463
|
}
|
|
532
464
|
if (process.env.TAMAGUI_TARGET === "native") {
|
|
533
|
-
const mergedRef = useMergeRefs(forwardedRef, hostRef, setMounted);
|
|
534
|
-
viewProps.ref = mergedRef;
|
|
535
465
|
if (splitStyles.fontFamily) {
|
|
536
|
-
const faceInfo = (_b =
|
|
466
|
+
const faceInfo = (_b = tamaguiConfig.fontsParsed[splitStyles.fontFamily]) == null ? void 0 : _b.face;
|
|
537
467
|
if (faceInfo) {
|
|
538
468
|
const [weight, style] = (() => {
|
|
539
469
|
var _a2, _b2;
|
|
@@ -561,13 +491,10 @@ function createComponent(configIn, ParentComponent) {
|
|
|
561
491
|
const attachPress = !!((pseudos == null ? void 0 : pseudos.pressStyle) || (initialPseudos == null ? void 0 : initialPseudos.pressStyle) || onPress || onPressOut || onPressIn || onClick);
|
|
562
492
|
const isHoverable = isWeb;
|
|
563
493
|
const attachHover = isHoverable && !!(pseudos && pseudos.hoverStyle || onHoverIn || onHoverOut || onMouseEnter || onMouseLeave);
|
|
564
|
-
const handlesPressEvents = !
|
|
565
|
-
const pressKey = handlesPressEvents ? "onPress" : "onClick";
|
|
566
|
-
const pressInKey = handlesPressEvents ? "onPressIn" : "onMouseDown";
|
|
567
|
-
const pressOutKey = handlesPressEvents ? "onPressOut" : "onMouseUp";
|
|
494
|
+
const handlesPressEvents = !isWeb && !asChild;
|
|
568
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));
|
|
569
496
|
const events = shouldAttach && !isRSC ? {
|
|
570
|
-
|
|
497
|
+
onPressOut: attachPress ? (e) => {
|
|
571
498
|
unPress();
|
|
572
499
|
onPressOut == null ? void 0 : onPressOut(e);
|
|
573
500
|
onMouseUp == null ? void 0 : onMouseUp(e);
|
|
@@ -581,7 +508,7 @@ function createComponent(configIn, ParentComponent) {
|
|
|
581
508
|
if (state.pressIn) {
|
|
582
509
|
next.press = true;
|
|
583
510
|
}
|
|
584
|
-
if (
|
|
511
|
+
if (attachHover || state.pressIn) {
|
|
585
512
|
setStateShallow(next);
|
|
586
513
|
}
|
|
587
514
|
onHoverIn == null ? void 0 : onHoverIn(e);
|
|
@@ -604,7 +531,7 @@ function createComponent(configIn, ParentComponent) {
|
|
|
604
531
|
onMouseLeave == null ? void 0 : onMouseLeave(e);
|
|
605
532
|
} : void 0
|
|
606
533
|
},
|
|
607
|
-
|
|
534
|
+
onPressIn: attachPress ? (e) => {
|
|
608
535
|
setStateShallow({
|
|
609
536
|
press: true,
|
|
610
537
|
pressIn: true,
|
|
@@ -615,12 +542,12 @@ function createComponent(configIn, ParentComponent) {
|
|
|
615
542
|
if (isWeb) {
|
|
616
543
|
mouseUps.add(unPress);
|
|
617
544
|
}
|
|
618
|
-
} :
|
|
619
|
-
|
|
545
|
+
} : void 0,
|
|
546
|
+
onPress: attachPress ? (e) => {
|
|
620
547
|
unPress();
|
|
621
548
|
onClick == null ? void 0 : onClick(e);
|
|
622
549
|
onPress == null ? void 0 : onPress(e);
|
|
623
|
-
} :
|
|
550
|
+
} : void 0,
|
|
624
551
|
...!isWeb && {
|
|
625
552
|
cancelable: !props.rejectResponderTermination,
|
|
626
553
|
disabled: props.disabled !== null ? props.disabled : (_e = props.accessibilityState) == null ? void 0 : _e.disabled,
|
|
@@ -668,28 +595,6 @@ function createComponent(configIn, ParentComponent) {
|
|
|
668
595
|
onPressOut
|
|
669
596
|
};
|
|
670
597
|
}
|
|
671
|
-
if (!isRSC && isWeb) {
|
|
672
|
-
const [pressableProps] = usePressable(
|
|
673
|
-
events ? {
|
|
674
|
-
disabled,
|
|
675
|
-
...hitSlop && {
|
|
676
|
-
hitSlop
|
|
677
|
-
},
|
|
678
|
-
onPressOut: events[pressOutKey],
|
|
679
|
-
onPressIn: events[pressInKey],
|
|
680
|
-
onPress: events[pressKey]
|
|
681
|
-
} : {
|
|
682
|
-
disabled: true
|
|
683
|
-
}
|
|
684
|
-
);
|
|
685
|
-
if (events) {
|
|
686
|
-
if (handlesPressEvents) {
|
|
687
|
-
Object.assign(viewProps, pressableProps);
|
|
688
|
-
} else {
|
|
689
|
-
Object.assign(viewProps, events);
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
598
|
if (process.env.TAMAGUI_TARGET === "native") {
|
|
694
599
|
const attachFocus = !!(pseudos && pseudos.focusStyle || initialPseudos && initialPseudos.focusStyle);
|
|
695
600
|
if (attachFocus) {
|
|
@@ -702,9 +607,6 @@ function createComponent(configIn, ParentComponent) {
|
|
|
702
607
|
}
|
|
703
608
|
const pressability = usePressability(events);
|
|
704
609
|
if (attachPress && events) {
|
|
705
|
-
const dontComposePressabilityKeys = {
|
|
706
|
-
onClick: true
|
|
707
|
-
};
|
|
708
610
|
if (hitSlop) {
|
|
709
611
|
viewProps.hitSlop = hitSlop;
|
|
710
612
|
}
|
|
@@ -717,21 +619,23 @@ function createComponent(configIn, ParentComponent) {
|
|
|
717
619
|
}
|
|
718
620
|
content = createElement(elementType, viewProps, childEls);
|
|
719
621
|
if (process.env.TAMAGUI_TARGET === "web") {
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
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) {
|
|
726
636
|
content = /* @__PURE__ */ jsx("span", {
|
|
727
|
-
className:
|
|
728
|
-
style:
|
|
729
|
-
display: "contents"
|
|
730
|
-
},
|
|
731
|
-
...events && shouldWrapWithHover && {
|
|
732
|
-
onMouseEnter: events.onMouseEnter,
|
|
733
|
-
onMouseLeave: events.onMouseLeave
|
|
734
|
-
},
|
|
637
|
+
className: fontFamilyClassName,
|
|
638
|
+
style: styleDisplayContents,
|
|
735
639
|
children: content
|
|
736
640
|
});
|
|
737
641
|
}
|
|
@@ -757,52 +661,50 @@ function createComponent(configIn, ParentComponent) {
|
|
|
757
661
|
component.displayName = staticConfig.componentName;
|
|
758
662
|
}
|
|
759
663
|
onConfiguredOnce((conf) => {
|
|
760
|
-
if (!
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
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
|
+
}
|
|
785
690
|
}
|
|
786
691
|
}
|
|
787
|
-
|
|
692
|
+
mergeShorthands(staticConfig, tamaguiConfig);
|
|
788
693
|
let defaultPropsIn = staticConfig.defaultProps || {};
|
|
789
694
|
const parentNames = [...staticConfig.parentNames || [], staticConfig.componentName];
|
|
790
|
-
if (
|
|
695
|
+
if (tamaguiConfig.defaultProps && parentNames && staticConfig.componentName) {
|
|
791
696
|
defaultPropsIn = mergeConfigDefaultProps(
|
|
792
697
|
staticConfig.componentName,
|
|
793
698
|
defaultPropsIn,
|
|
794
|
-
|
|
699
|
+
tamaguiConfig.defaultProps,
|
|
795
700
|
parentNames,
|
|
796
|
-
|
|
701
|
+
tamaguiConfig
|
|
797
702
|
);
|
|
798
703
|
}
|
|
799
704
|
const debug = defaultPropsIn["debug"];
|
|
800
|
-
|
|
801
|
-
debugger;
|
|
802
|
-
}
|
|
803
|
-
const [parentProps, parentClassNames] = mergeProps(defaultPropsIn, {}, true);
|
|
705
|
+
const [ourProps, ourClassNames] = mergeProps(defaultPropsIn, {}, true);
|
|
804
706
|
initialSplitStyles = insertSplitStyles(
|
|
805
|
-
|
|
707
|
+
ourProps,
|
|
806
708
|
staticConfig,
|
|
807
709
|
initialTheme,
|
|
808
710
|
{
|
|
@@ -825,9 +727,9 @@ function createComponent(configIn, ParentComponent) {
|
|
|
825
727
|
true
|
|
826
728
|
);
|
|
827
729
|
initialSplitStyles.classNames = {
|
|
828
|
-
...parentClassNames,
|
|
829
730
|
...defaultsClassnames,
|
|
830
|
-
...initialSplitStyles.classNames
|
|
731
|
+
...initialSplitStyles.classNames,
|
|
732
|
+
...ourClassNames
|
|
831
733
|
};
|
|
832
734
|
defaultNativeStyle = {};
|
|
833
735
|
const validStyles2 = staticConfig.validStyles || stylePropsView;
|
|
@@ -854,7 +756,12 @@ function createComponent(configIn, ParentComponent) {
|
|
|
854
756
|
tamaguiDefaultProps,
|
|
855
757
|
defaultNativeStyle,
|
|
856
758
|
defaults: defaults2,
|
|
857
|
-
defaultPropsIn
|
|
759
|
+
defaultPropsIn,
|
|
760
|
+
defaultPropsKeyOrder: Object.keys(staticConfig.defaultProps),
|
|
761
|
+
defaultPropsInKeyOrder: Object.keys(defaultPropsIn).map((k) => [k, defaultPropsIn[k]]),
|
|
762
|
+
ourProps,
|
|
763
|
+
ourClassNames,
|
|
764
|
+
defaultsClassnames
|
|
858
765
|
});
|
|
859
766
|
}
|
|
860
767
|
}
|
|
@@ -927,9 +834,6 @@ const Spacer = createComponent({
|
|
|
927
834
|
},
|
|
928
835
|
both: {}
|
|
929
836
|
}
|
|
930
|
-
},
|
|
931
|
-
defaultVariants: {
|
|
932
|
-
direction: "both"
|
|
933
837
|
}
|
|
934
838
|
});
|
|
935
839
|
function spacedChildren({
|
|
@@ -975,7 +879,7 @@ function spacedChildren({
|
|
|
975
879
|
if (hasSpace) {
|
|
976
880
|
final.push(
|
|
977
881
|
createSpacer({
|
|
978
|
-
key: `_${index}
|
|
882
|
+
key: `_${index}_00tmgui`,
|
|
979
883
|
direction,
|
|
980
884
|
space,
|
|
981
885
|
spaceFlex
|
|
@@ -988,7 +892,7 @@ function spacedChildren({
|
|
|
988
892
|
if (hasSpace) {
|
|
989
893
|
final.push(
|
|
990
894
|
createSpacer({
|
|
991
|
-
key: `_${index}
|
|
895
|
+
key: `_${index}01tmgui`,
|
|
992
896
|
direction,
|
|
993
897
|
space,
|
|
994
898
|
spaceFlex
|
|
@@ -998,7 +902,7 @@ function spacedChildren({
|
|
|
998
902
|
} else {
|
|
999
903
|
final.push(
|
|
1000
904
|
createSpacer({
|
|
1001
|
-
key: `_${index}
|
|
905
|
+
key: `_${index}02tmgui`,
|
|
1002
906
|
direction,
|
|
1003
907
|
space,
|
|
1004
908
|
spaceFlex
|
|
@@ -1022,37 +926,6 @@ function isUnspaced(child) {
|
|
|
1022
926
|
var _a, _b;
|
|
1023
927
|
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"]);
|
|
1024
928
|
}
|
|
1025
|
-
function AbsoluteFill(props) {
|
|
1026
|
-
return /* @__PURE__ */ jsx(View, {
|
|
1027
|
-
pointerEvents: "box-none",
|
|
1028
|
-
style: absoluteFill,
|
|
1029
|
-
children: props.children
|
|
1030
|
-
});
|
|
1031
|
-
}
|
|
1032
|
-
const absoluteFill = {
|
|
1033
|
-
position: "absolute",
|
|
1034
|
-
top: 0,
|
|
1035
|
-
left: 0,
|
|
1036
|
-
right: 0,
|
|
1037
|
-
bottom: 0
|
|
1038
|
-
};
|
|
1039
|
-
function processIDRefList(idRefList) {
|
|
1040
|
-
return Array.isArray(idRefList) ? idRefList.join(" ") : idRefList;
|
|
1041
|
-
}
|
|
1042
|
-
const accessibilityRoleToWebRole = {
|
|
1043
|
-
adjustable: "slider",
|
|
1044
|
-
button: "button",
|
|
1045
|
-
header: "heading",
|
|
1046
|
-
image: "img",
|
|
1047
|
-
imagebutton: null,
|
|
1048
|
-
keyboardkey: null,
|
|
1049
|
-
label: null,
|
|
1050
|
-
link: "link",
|
|
1051
|
-
none: "presentation",
|
|
1052
|
-
search: "search",
|
|
1053
|
-
summary: "region",
|
|
1054
|
-
text: null
|
|
1055
|
-
};
|
|
1056
929
|
function addPseudoToStyles(styles, initialPseudos, pseudos, name, force = false) {
|
|
1057
930
|
const pseudoStyle = pseudos[name];
|
|
1058
931
|
const shouldNestObject = isWeb && name !== "enterStyle" && name !== "exitStyle";
|
|
@@ -1153,13 +1026,47 @@ function merge(base, next) {
|
|
|
1153
1026
|
}
|
|
1154
1027
|
}
|
|
1155
1028
|
}
|
|
1029
|
+
function usePlatformMethods(hostRef) {
|
|
1030
|
+
useIsomorphicLayoutEffect(() => {
|
|
1031
|
+
const node = hostRef.current;
|
|
1032
|
+
if (!node)
|
|
1033
|
+
return;
|
|
1034
|
+
node.measure = (callback) => measureLayout(node, null, callback);
|
|
1035
|
+
node.measureLayout = (relativeToNode, success) => measureLayout(node, relativeToNode, success);
|
|
1036
|
+
node.measureInWindow = (callback) => {
|
|
1037
|
+
if (!node)
|
|
1038
|
+
return;
|
|
1039
|
+
setTimeout(() => {
|
|
1040
|
+
const { height, left, top, width } = getRect(node);
|
|
1041
|
+
callback(left, top, width, height);
|
|
1042
|
+
}, 0);
|
|
1043
|
+
};
|
|
1044
|
+
}, [hostRef]);
|
|
1045
|
+
}
|
|
1046
|
+
const AbsoluteFill = createComponent({
|
|
1047
|
+
componentName: "AbsoluteFill",
|
|
1048
|
+
defaultProps: {
|
|
1049
|
+
...stackDefaultStyles,
|
|
1050
|
+
flexDirection: "column",
|
|
1051
|
+
position: "absolute",
|
|
1052
|
+
top: 0,
|
|
1053
|
+
right: 0,
|
|
1054
|
+
bottom: 0,
|
|
1055
|
+
left: 0,
|
|
1056
|
+
pointerEvents: "box-none"
|
|
1057
|
+
}
|
|
1058
|
+
});
|
|
1059
|
+
const styleDisplayContents = {
|
|
1060
|
+
display: "contents"
|
|
1061
|
+
};
|
|
1062
|
+
const dontComposePressabilityKeys = {
|
|
1063
|
+
onClick: true
|
|
1064
|
+
};
|
|
1156
1065
|
export {
|
|
1157
1066
|
Spacer,
|
|
1158
1067
|
Unspaced,
|
|
1159
|
-
accessibilityRoleToWebRole,
|
|
1160
1068
|
createComponent,
|
|
1161
1069
|
mouseUps,
|
|
1162
|
-
processIDRefList,
|
|
1163
1070
|
spacedChildren
|
|
1164
1071
|
};
|
|
1165
1072
|
//# sourceMappingURL=createComponent.js.map
|