@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
|
@@ -26,34 +26,30 @@ var createComponent_exports = {};
|
|
|
26
26
|
__export(createComponent_exports, {
|
|
27
27
|
Spacer: () => Spacer,
|
|
28
28
|
Unspaced: () => Unspaced,
|
|
29
|
-
accessibilityRoleToWebRole: () => accessibilityRoleToWebRole,
|
|
30
29
|
createComponent: () => createComponent,
|
|
31
30
|
mouseUps: () => mouseUps,
|
|
32
|
-
processIDRefList: () => processIDRefList,
|
|
33
31
|
spacedChildren: () => spacedChildren
|
|
34
32
|
});
|
|
35
33
|
module.exports = __toCommonJS(createComponent_exports);
|
|
36
34
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
+
var import_compose_refs = require("@tamagui/compose-refs");
|
|
37
36
|
var import_constants = require("@tamagui/constants");
|
|
38
37
|
var import_helpers = require("@tamagui/helpers");
|
|
39
|
-
var
|
|
38
|
+
var import_react_native_use_responder_events = require("@tamagui/react-native-use-responder-events");
|
|
40
39
|
var import_use_force_update = require("@tamagui/use-force-update");
|
|
41
40
|
var import_react = __toESM(require("react"));
|
|
42
|
-
var import_react_native = require("react-native");
|
|
43
41
|
var import_config = require("./config");
|
|
44
42
|
var import_constants2 = require("./constants/constants");
|
|
45
43
|
var import_FontLanguageContext = require("./contexts/FontLanguageContext");
|
|
46
44
|
var import_TextAncestorContext = require("./contexts/TextAncestorContext");
|
|
47
|
-
var import_assignNativePropsToWeb = require("./helpers/assignNativePropsToWeb");
|
|
48
|
-
var import_createPropMapper = require("./helpers/createPropMapper");
|
|
49
45
|
var import_extendStaticConfig = require("./helpers/extendStaticConfig");
|
|
50
46
|
var import_getSplitStyles = require("./helpers/getSplitStyles");
|
|
51
47
|
var import_insertStyleRule = require("./helpers/insertStyleRule");
|
|
52
48
|
var import_mergeProps = require("./helpers/mergeProps");
|
|
53
49
|
var import_proxyThemeVariables = require("./helpers/proxyThemeVariables");
|
|
54
50
|
var import_useShallowSetState = require("./helpers/useShallowSetState");
|
|
51
|
+
var import_useElementLayout = require("./hooks/useElementLayout");
|
|
55
52
|
var import_useMedia = require("./hooks/useMedia");
|
|
56
|
-
var import_usePressable = require("./hooks/usePressable");
|
|
57
53
|
var import_useServerHooks = require("./hooks/useServerHooks");
|
|
58
54
|
var import_useTheme = require("./hooks/useTheme");
|
|
59
55
|
var import_Pressability = require("./vendor/Pressability");
|
|
@@ -61,6 +57,11 @@ var import_Slot = require("./views/Slot");
|
|
|
61
57
|
var import_Theme = require("./views/Theme");
|
|
62
58
|
import_react.default["keep"];
|
|
63
59
|
let defaultComponentState = null;
|
|
60
|
+
let defaultComponentStateMounted = null;
|
|
61
|
+
let tamaguiConfig;
|
|
62
|
+
let AnimatedText;
|
|
63
|
+
let AnimatedView;
|
|
64
|
+
let initialTheme;
|
|
64
65
|
const mouseUps = /* @__PURE__ */ new Set();
|
|
65
66
|
if (typeof document !== "undefined") {
|
|
66
67
|
const cancelTouches = () => {
|
|
@@ -76,8 +77,13 @@ function mergeShorthands({ defaultProps }, { shorthands }) {
|
|
|
76
77
|
defaultProps[shorthands[key] || key] = defaultProps[key];
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
|
-
let
|
|
80
|
-
let
|
|
80
|
+
let BaseText;
|
|
81
|
+
let BaseView;
|
|
82
|
+
if (process.env.TAMAGUI_TARGET === "native") {
|
|
83
|
+
const native = require("react-native");
|
|
84
|
+
BaseText = native.Text || native.default.Text;
|
|
85
|
+
BaseView = native.View || native.default.View;
|
|
86
|
+
}
|
|
81
87
|
function createComponent(configIn, ParentComponent) {
|
|
82
88
|
const staticConfig = (() => {
|
|
83
89
|
const next = (0, import_extendStaticConfig.extendStaticConfig)(configIn, ParentComponent);
|
|
@@ -88,10 +94,7 @@ function createComponent(configIn, ParentComponent) {
|
|
|
88
94
|
}
|
|
89
95
|
})();
|
|
90
96
|
const defaultComponentClassName = `is_${staticConfig.componentName}`;
|
|
91
|
-
|
|
92
|
-
let AnimatedText;
|
|
93
|
-
let AnimatedView;
|
|
94
|
-
let avoidClassesWhileAnimating = true;
|
|
97
|
+
const avoidClassesWhileAnimating = true;
|
|
95
98
|
let defaultNativeStyle;
|
|
96
99
|
let tamaguiDefaultProps;
|
|
97
100
|
let initialSplitStyles;
|
|
@@ -108,10 +111,26 @@ function createComponent(configIn, ParentComponent) {
|
|
|
108
111
|
const componentName = props.componentName || staticConfig.componentName;
|
|
109
112
|
const componentClassName = props.asChild ? "" : props.componentName ? `is_${props.componentName}` : defaultComponentClassName;
|
|
110
113
|
const forceUpdate = (0, import_use_force_update.useForceUpdate)();
|
|
111
|
-
config = config || (0, import_config.getConfig)();
|
|
112
114
|
const theme = (0, import_useTheme.useTheme)(props.theme, componentName, props, forceUpdate);
|
|
113
|
-
const
|
|
115
|
+
const hasEnterStyle = !!props.enterStyle;
|
|
116
|
+
const needsMount = Boolean((import_constants.isWeb ? import_constants.isClient : true) && (hasEnterStyle || props.animation));
|
|
117
|
+
const states = (0, import_useServerHooks.useServerState)(
|
|
118
|
+
needsMount ? defaultComponentState : defaultComponentStateMounted
|
|
119
|
+
);
|
|
114
120
|
const state = propsIn.forceStyle ? { ...states[0], [propsIn.forceStyle]: true } : states[0];
|
|
121
|
+
const setState = states[1];
|
|
122
|
+
const setStateShallow = (0, import_useShallowSetState.useShallowSetState)(setState);
|
|
123
|
+
const shouldSetMounted = needsMount && !state.mounted;
|
|
124
|
+
const setMounted = shouldSetMounted ? () => {
|
|
125
|
+
setTimeout(
|
|
126
|
+
() => {
|
|
127
|
+
setStateShallow({
|
|
128
|
+
mounted: true
|
|
129
|
+
});
|
|
130
|
+
},
|
|
131
|
+
import_constants.isWeb ? 10 : 0
|
|
132
|
+
);
|
|
133
|
+
} : void 0;
|
|
115
134
|
const shouldAvoidClasses = !!(props.animation && avoidClassesWhileAnimating) || !staticConfig.acceptsClassName;
|
|
116
135
|
const shouldForcePseudo = !!propsIn.forceStyle;
|
|
117
136
|
const hasTextAncestor = !!(import_constants.isWeb && isText ? (0, import_react.useContext)(import_TextAncestorContext.TextAncestorContext) : false);
|
|
@@ -127,25 +146,41 @@ function createComponent(configIn, ParentComponent) {
|
|
|
127
146
|
resolveVariablesAs: "value"
|
|
128
147
|
};
|
|
129
148
|
const languageContext = import_constants.isRSC ? null : (0, import_react.useContext)(import_FontLanguageContext.FontLanguageContext);
|
|
149
|
+
const useAnimations = (_a = tamaguiConfig.animations) == null ? void 0 : _a.useAnimations;
|
|
150
|
+
const nextIsAnimated = !!(useAnimations && props.animation);
|
|
151
|
+
const isAnimated = nextIsAnimated || state.hasAnimation;
|
|
152
|
+
if (nextIsAnimated && !state.hasAnimation) {
|
|
153
|
+
setStateShallow({ hasAnimation: true });
|
|
154
|
+
}
|
|
155
|
+
const isTaggable = !Component || typeof Component === "string";
|
|
156
|
+
const element = import_constants.isWeb ? isTaggable ? props.tag || Component : Component : Component;
|
|
157
|
+
const BaseTextComponent = BaseText || element || "span";
|
|
158
|
+
const BaseViewComponent = BaseView || element || (hasTextAncestor ? "span" : "div");
|
|
159
|
+
let elementType = isText ? (isAnimated ? AnimatedText : null) || BaseTextComponent : (isAnimated ? AnimatedView : null) || BaseViewComponent;
|
|
160
|
+
elementType = Component || elementType;
|
|
161
|
+
const isStringElement = typeof elementType === "string";
|
|
130
162
|
const splitStyles = (0, import_getSplitStyles.useSplitStyles)(
|
|
131
163
|
props,
|
|
132
164
|
staticConfig,
|
|
133
165
|
theme,
|
|
134
166
|
splitStyleState,
|
|
135
|
-
props.asChild ? null : initialSplitStyles
|
|
167
|
+
props.asChild ? null : initialSplitStyles,
|
|
136
168
|
languageContext || void 0,
|
|
169
|
+
elementType,
|
|
137
170
|
debugProp
|
|
138
171
|
);
|
|
139
172
|
const hostRef = (0, import_useServerHooks.useServerRef)(null);
|
|
140
|
-
const
|
|
141
|
-
|
|
173
|
+
const isReactNativeWeb = Boolean(
|
|
174
|
+
staticConfig.isReactNativeWeb || isAnimated && tamaguiConfig.animations.isReactNativeWeb
|
|
175
|
+
);
|
|
176
|
+
const isAnimatedReactNativeWeb = isAnimated && avoidClassesWhileAnimating;
|
|
142
177
|
if (process.env.NODE_ENV === "development") {
|
|
143
178
|
if (!process.env.TAMAGUI_TARGET) {
|
|
144
179
|
console.error(`No process.env.TAMAGUI_TARGET set, please set it to "native" or "web".`);
|
|
145
180
|
}
|
|
146
181
|
if (debugProp) {
|
|
147
182
|
const name = `${componentName || (Component == null ? void 0 : Component.displayName) || (Component == null ? void 0 : Component.name) || "[Unnamed Component]"}`;
|
|
148
|
-
const type =
|
|
183
|
+
const type = isReactNativeWeb ? "rnw" : "tamagui";
|
|
149
184
|
const banner = `${name} ${propsIn["data-is"] || ""} ${type}`;
|
|
150
185
|
console.group(`%c \u{1F41B} ${banner}`, "background: yellow;");
|
|
151
186
|
console.groupCollapsed("initial props/state");
|
|
@@ -169,42 +204,11 @@ function createComponent(configIn, ParentComponent) {
|
|
|
169
204
|
classNames,
|
|
170
205
|
mediaKeys
|
|
171
206
|
} = splitStyles;
|
|
172
|
-
(0, import_constants.useIsomorphicLayoutEffect)(() => {
|
|
173
|
-
if (!mediaKeys.length) {
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
const disposers = [];
|
|
177
|
-
for (const key of mediaKeys) {
|
|
178
|
-
disposers.push(
|
|
179
|
-
(0, import_useMedia.addMediaQueryListener)(key, (next) => {
|
|
180
|
-
setState((prev) => {
|
|
181
|
-
if (prev.mediaState[key] !== next) {
|
|
182
|
-
return {
|
|
183
|
-
...prev,
|
|
184
|
-
mediaState: {
|
|
185
|
-
...prev.mediaState,
|
|
186
|
-
[key]: next
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
return prev;
|
|
191
|
-
});
|
|
192
|
-
})
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
return () => {
|
|
196
|
-
};
|
|
197
|
-
}, [mediaKeys.join(",")]);
|
|
198
|
-
const useAnimations = (_a = tamaguiConfig == null ? void 0 : tamaguiConfig.animations) == null ? void 0 : _a.useAnimations;
|
|
199
|
-
const nextIsAnimated = !!(useAnimations && props.animation);
|
|
200
|
-
const isAnimated = nextIsAnimated || state.hasAnimation;
|
|
201
|
-
if (nextIsAnimated && !state.hasAnimation) {
|
|
202
|
-
setStateShallow({ hasAnimation: true });
|
|
203
|
-
}
|
|
204
207
|
const animationFeatureStylesIn = props.animation ? { ...defaultNativeStyle, ...splitStylesStyle } : null;
|
|
205
208
|
const propsWithAnimation = props;
|
|
209
|
+
let animationStyles;
|
|
206
210
|
if (!import_constants.isRSC && isAnimated && useAnimations) {
|
|
207
|
-
const
|
|
211
|
+
const animations = useAnimations(propsWithAnimation, {
|
|
208
212
|
state,
|
|
209
213
|
pseudos,
|
|
210
214
|
onDidAnimate: props.onDidAnimate,
|
|
@@ -235,7 +239,6 @@ function createComponent(configIn, ParentComponent) {
|
|
|
235
239
|
style,
|
|
236
240
|
pseudos.hoverStyle,
|
|
237
241
|
pseudos.focusStyle,
|
|
238
|
-
pseudos.pressStyle,
|
|
239
242
|
pseudos.pressStyle
|
|
240
243
|
);
|
|
241
244
|
enterStyle && isEntering && merge(style, enterStyle);
|
|
@@ -244,21 +247,46 @@ function createComponent(configIn, ParentComponent) {
|
|
|
244
247
|
state.press && pseudos.pressStyle && merge(style, pseudos.pressStyle);
|
|
245
248
|
exitStyle && isExiting && merge(style, exitStyle);
|
|
246
249
|
if (process.env.NODE_ENV === "development") {
|
|
247
|
-
if (debugProp) {
|
|
250
|
+
if (debugProp === "verbose") {
|
|
248
251
|
console.log("animation style", style);
|
|
249
252
|
}
|
|
250
253
|
}
|
|
251
254
|
return style;
|
|
252
255
|
}
|
|
253
256
|
});
|
|
254
|
-
if (
|
|
255
|
-
|
|
256
|
-
animation: animationState
|
|
257
|
-
});
|
|
257
|
+
if (animations) {
|
|
258
|
+
animationStyles = animations.style;
|
|
258
259
|
}
|
|
259
260
|
}
|
|
261
|
+
(0, import_constants.useIsomorphicLayoutEffect)(() => {
|
|
262
|
+
if (!mediaKeys.length)
|
|
263
|
+
return;
|
|
264
|
+
const disposers = [];
|
|
265
|
+
for (const key of mediaKeys) {
|
|
266
|
+
disposers.push(
|
|
267
|
+
(0, import_useMedia.addMediaQueryListener)(key, (next) => {
|
|
268
|
+
setState((prev) => {
|
|
269
|
+
if (prev.mediaState[key] !== next) {
|
|
270
|
+
return {
|
|
271
|
+
...prev,
|
|
272
|
+
mediaState: {
|
|
273
|
+
...prev.mediaState,
|
|
274
|
+
[key]: next
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
return prev;
|
|
279
|
+
});
|
|
280
|
+
})
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
return () => {
|
|
284
|
+
for (const disposer of disposers) {
|
|
285
|
+
disposer();
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
}, [mediaKeys.join(",")]);
|
|
260
289
|
const {
|
|
261
|
-
tag,
|
|
262
290
|
hitSlop,
|
|
263
291
|
asChild,
|
|
264
292
|
children,
|
|
@@ -283,30 +311,9 @@ function createComponent(configIn, ParentComponent) {
|
|
|
283
311
|
defaultVariants,
|
|
284
312
|
...nonTamaguiProps
|
|
285
313
|
} = viewPropsIn;
|
|
286
|
-
const isTaggable = !Component || typeof Component === "string";
|
|
287
|
-
const element = import_constants.isWeb ? isTaggable ? tag || Component : Component : Component;
|
|
288
|
-
const BaseTextComponent = !import_constants.isWeb ? import_react_native.Text : element || "span";
|
|
289
|
-
const BaseViewComponent = !import_constants.isWeb ? import_react_native.View : element || (hasTextAncestor ? "span" : "div");
|
|
290
|
-
let elementType = isText ? (isAnimated ? AnimatedText || import_react_native.Text : null) || BaseTextComponent : (isAnimated ? AnimatedView || import_react_native.View : null) || BaseViewComponent;
|
|
291
|
-
elementType = Component || elementType;
|
|
292
|
-
const isStringElement = typeof elementType === "string";
|
|
293
314
|
const disabled = props.accessibilityState != null && props.accessibilityState.disabled === true || props.accessibilityDisabled;
|
|
294
315
|
let viewProps;
|
|
295
|
-
|
|
296
|
-
const shouldSetMounted = Boolean(
|
|
297
|
-
(import_constants.isWeb ? import_constants.isClient : true) && (hasEnterStyle || props.animation) && !state.mounted
|
|
298
|
-
);
|
|
299
|
-
const setMounted = shouldSetMounted ? () => {
|
|
300
|
-
setTimeout(
|
|
301
|
-
() => {
|
|
302
|
-
setStateShallow({
|
|
303
|
-
mounted: true
|
|
304
|
-
});
|
|
305
|
-
},
|
|
306
|
-
import_constants.isWeb ? 10 : 0
|
|
307
|
-
);
|
|
308
|
-
} : void 0;
|
|
309
|
-
if (process.env.TAMAGUI_TARGET === "web" && !staticConfig.isReactNativeWeb) {
|
|
316
|
+
if (process.env.TAMAGUI_TARGET === "web" && !isReactNativeWeb) {
|
|
310
317
|
const {
|
|
311
318
|
onMoveShouldSetResponder,
|
|
312
319
|
onMoveShouldSetResponderCapture,
|
|
@@ -324,66 +331,18 @@ function createComponent(configIn, ParentComponent) {
|
|
|
324
331
|
onSelectionChangeShouldSetResponderCapture,
|
|
325
332
|
onStartShouldSetResponder,
|
|
326
333
|
onStartShouldSetResponderCapture,
|
|
327
|
-
nativeID,
|
|
328
|
-
accessibilityActiveDescendant,
|
|
329
|
-
accessibilityAtomic,
|
|
330
|
-
accessibilityAutoComplete,
|
|
331
|
-
accessibilityBusy,
|
|
332
|
-
accessibilityChecked,
|
|
333
|
-
accessibilityColumnCount,
|
|
334
|
-
accessibilityColumnIndex,
|
|
335
|
-
accessibilityColumnSpan,
|
|
336
|
-
accessibilityControls,
|
|
337
|
-
accessibilityCurrent,
|
|
338
|
-
accessibilityDescribedBy,
|
|
339
|
-
accessibilityDetails,
|
|
340
|
-
accessibilityDisabled,
|
|
341
|
-
accessibilityErrorMessage,
|
|
342
|
-
accessibilityExpanded,
|
|
343
|
-
accessibilityFlowTo,
|
|
344
|
-
accessibilityHasPopup,
|
|
345
|
-
accessibilityHidden,
|
|
346
|
-
accessibilityInvalid,
|
|
347
|
-
accessibilityKeyShortcuts,
|
|
348
|
-
accessibilityLabel,
|
|
349
|
-
accessibilityLabelledBy,
|
|
350
|
-
accessibilityLevel,
|
|
351
|
-
accessibilityLiveRegion,
|
|
352
|
-
accessibilityModal,
|
|
353
|
-
accessibilityMultiline,
|
|
354
|
-
accessibilityMultiSelectable,
|
|
355
|
-
accessibilityOrientation,
|
|
356
|
-
accessibilityOwns,
|
|
357
|
-
accessibilityPlaceholder,
|
|
358
|
-
accessibilityPosInSet,
|
|
359
|
-
accessibilityPressed,
|
|
360
|
-
accessibilityReadOnly,
|
|
361
|
-
accessibilityRequired,
|
|
362
|
-
accessibilityRole,
|
|
363
|
-
accessibilityRoleDescription,
|
|
364
|
-
accessibilityRowCount,
|
|
365
|
-
accessibilityRowIndex,
|
|
366
|
-
accessibilityRowSpan,
|
|
367
|
-
accessibilitySelected,
|
|
368
|
-
accessibilitySetSize,
|
|
369
|
-
accessibilitySort,
|
|
370
|
-
accessibilityValueMax,
|
|
371
|
-
accessibilityValueMin,
|
|
372
|
-
accessibilityValueNow,
|
|
373
|
-
accessibilityValueText,
|
|
374
|
-
accessible,
|
|
375
|
-
accessibilityState,
|
|
376
|
-
accessibilityValue,
|
|
377
334
|
collapsable,
|
|
378
335
|
focusable,
|
|
336
|
+
accessible,
|
|
337
|
+
accessibilityDisabled,
|
|
379
338
|
onLayout,
|
|
380
339
|
...webProps
|
|
381
340
|
} = nonTamaguiProps;
|
|
382
341
|
viewProps = webProps;
|
|
383
|
-
(0, import_assignNativePropsToWeb.assignNativePropsToWeb)(elementType, viewProps, nonTamaguiProps);
|
|
384
342
|
if (!import_constants.isRSC) {
|
|
385
|
-
(
|
|
386
|
-
(0,
|
|
343
|
+
usePlatformMethods(hostRef);
|
|
344
|
+
(0, import_useElementLayout.useElementLayout)(hostRef, onLayout);
|
|
345
|
+
(0, import_react_native_use_responder_events.useResponderEvents)(hostRef, {
|
|
387
346
|
onMoveShouldSetResponder,
|
|
388
347
|
onMoveShouldSetResponderCapture,
|
|
389
348
|
onResponderEnd,
|
|
@@ -401,9 +360,6 @@ function createComponent(configIn, ParentComponent) {
|
|
|
401
360
|
onStartShouldSetResponder,
|
|
402
361
|
onStartShouldSetResponderCapture
|
|
403
362
|
});
|
|
404
|
-
const platformMethodsRef = (0, import_rnw.usePlatformMethods)(viewProps);
|
|
405
|
-
const setRef = (0, import_rnw.useMergeRefs)(hostRef, platformMethodsRef, forwardedRef, setMounted);
|
|
406
|
-
viewProps.ref = setRef;
|
|
407
363
|
}
|
|
408
364
|
if (props.href != void 0 && hrefAttrs != void 0) {
|
|
409
365
|
const { download, rel, target } = hrefAttrs;
|
|
@@ -436,10 +392,8 @@ function createComponent(configIn, ParentComponent) {
|
|
|
436
392
|
}
|
|
437
393
|
} else {
|
|
438
394
|
viewProps = nonTamaguiProps;
|
|
439
|
-
if (forwardedRef) {
|
|
440
|
-
viewProps.ref = forwardedRef;
|
|
441
|
-
}
|
|
442
395
|
}
|
|
396
|
+
viewProps.ref = (0, import_compose_refs.useComposedRefs)(hostRef, forwardedRef, setMounted);
|
|
443
397
|
if (process.env.NODE_ENV === "development" && !isText && import_constants.isWeb && !staticConfig.isHOC) {
|
|
444
398
|
import_react.Children.toArray(props.children).forEach((item) => {
|
|
445
399
|
if (typeof item === "string") {
|
|
@@ -461,7 +415,6 @@ function createComponent(configIn, ParentComponent) {
|
|
|
461
415
|
}, [unPress]);
|
|
462
416
|
}
|
|
463
417
|
let styles;
|
|
464
|
-
const animationStyles = state.animation ? state.animation.style : null;
|
|
465
418
|
if (isStringElement && shouldAvoidClasses && !shouldForcePseudo) {
|
|
466
419
|
styles = {
|
|
467
420
|
...defaultNativeStyle,
|
|
@@ -487,41 +440,23 @@ function createComponent(configIn, ParentComponent) {
|
|
|
487
440
|
Object.assign(splitStyles.style, next);
|
|
488
441
|
}
|
|
489
442
|
}
|
|
443
|
+
let fontFamily = isText ? splitStyles.fontFamily || staticConfig.defaultProps.fontFamily : null;
|
|
444
|
+
if (fontFamily && fontFamily[0] === "$") {
|
|
445
|
+
fontFamily = fontFamily.slice(1);
|
|
446
|
+
}
|
|
447
|
+
const fontFamilyClassName = fontFamily ? `font_${fontFamily}` : "";
|
|
490
448
|
if (process.env.TAMAGUI_TARGET === "web") {
|
|
491
|
-
let fontFamily = isText ? splitStyles.fontFamily || staticConfig.defaultProps.fontFamily : null;
|
|
492
|
-
if (fontFamily && fontFamily[0] === "$") {
|
|
493
|
-
fontFamily = fontFamily.slice(1);
|
|
494
|
-
}
|
|
495
|
-
if (process.env.NODE_ENV === "development") {
|
|
496
|
-
if (fontFamily == null ? void 0 : fontFamily.startsWith(`var(`)) {
|
|
497
|
-
console.warn(
|
|
498
|
-
`Received variable instead of resolved name of font, this is a bug. Please report on Github.`,
|
|
499
|
-
{
|
|
500
|
-
fontFamily,
|
|
501
|
-
props,
|
|
502
|
-
splitStyles,
|
|
503
|
-
staticConfig
|
|
504
|
-
}
|
|
505
|
-
);
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
449
|
const classList = [
|
|
509
450
|
componentName ? componentClassName : "",
|
|
510
|
-
|
|
451
|
+
fontFamilyClassName,
|
|
511
452
|
theme.className,
|
|
512
453
|
classNames ? Object.values(classNames).join(" ") : ""
|
|
513
454
|
];
|
|
514
455
|
const className = classList.join(" ");
|
|
515
456
|
const style = animationStyles ?? splitStyles.style;
|
|
516
|
-
const isAnimatedReactNativeWeb = props.animation && avoidClassesWhileAnimating;
|
|
517
457
|
if (isAnimatedReactNativeWeb) {
|
|
518
458
|
viewProps.style = style;
|
|
519
|
-
|
|
520
|
-
...viewProps.dataSet,
|
|
521
|
-
className,
|
|
522
|
-
id: props.id
|
|
523
|
-
};
|
|
524
|
-
} else if (staticConfig.isReactNativeWeb) {
|
|
459
|
+
} else if (isReactNativeWeb) {
|
|
525
460
|
const rnwStyle = { $$css: true };
|
|
526
461
|
for (const name of className.split(" ")) {
|
|
527
462
|
rnwStyle[name] = name;
|
|
@@ -542,10 +477,8 @@ function createComponent(configIn, ParentComponent) {
|
|
|
542
477
|
}
|
|
543
478
|
}
|
|
544
479
|
if (process.env.TAMAGUI_TARGET === "native") {
|
|
545
|
-
const mergedRef = (0, import_rnw.useMergeRefs)(forwardedRef, hostRef, setMounted);
|
|
546
|
-
viewProps.ref = mergedRef;
|
|
547
480
|
if (splitStyles.fontFamily) {
|
|
548
|
-
const faceInfo = (_b =
|
|
481
|
+
const faceInfo = (_b = tamaguiConfig.fontsParsed[splitStyles.fontFamily]) == null ? void 0 : _b.face;
|
|
549
482
|
if (faceInfo) {
|
|
550
483
|
const [weight, style] = (() => {
|
|
551
484
|
var _a2, _b2;
|
|
@@ -573,13 +506,10 @@ function createComponent(configIn, ParentComponent) {
|
|
|
573
506
|
const attachPress = !!((pseudos == null ? void 0 : pseudos.pressStyle) || (initialPseudos == null ? void 0 : initialPseudos.pressStyle) || onPress || onPressOut || onPressIn || onClick);
|
|
574
507
|
const isHoverable = import_constants.isWeb;
|
|
575
508
|
const attachHover = isHoverable && !!(pseudos && pseudos.hoverStyle || onHoverIn || onHoverOut || onMouseEnter || onMouseLeave);
|
|
576
|
-
const handlesPressEvents = !
|
|
577
|
-
const pressKey = handlesPressEvents ? "onPress" : "onClick";
|
|
578
|
-
const pressInKey = handlesPressEvents ? "onPressIn" : "onMouseDown";
|
|
579
|
-
const pressOutKey = handlesPressEvents ? "onPressOut" : "onMouseUp";
|
|
509
|
+
const handlesPressEvents = !import_constants.isWeb && !asChild;
|
|
580
510
|
const shouldAttach = !asChild && (attachPress || attachHover || "pressStyle" in props || "onPress" in props || "onPressIn" in props || "onPressOut" in props || import_constants.isWeb && ("hoverStyle" in props || "onHoverIn" in props || "onHoverOut" in props || "onMouseEnter" in props || "onMouseLeave" in props));
|
|
581
511
|
const events = shouldAttach && !import_constants.isRSC ? {
|
|
582
|
-
|
|
512
|
+
onPressOut: attachPress ? (e) => {
|
|
583
513
|
unPress();
|
|
584
514
|
onPressOut == null ? void 0 : onPressOut(e);
|
|
585
515
|
onMouseUp == null ? void 0 : onMouseUp(e);
|
|
@@ -593,7 +523,7 @@ function createComponent(configIn, ParentComponent) {
|
|
|
593
523
|
if (state.pressIn) {
|
|
594
524
|
next.press = true;
|
|
595
525
|
}
|
|
596
|
-
if (
|
|
526
|
+
if (attachHover || state.pressIn) {
|
|
597
527
|
setStateShallow(next);
|
|
598
528
|
}
|
|
599
529
|
onHoverIn == null ? void 0 : onHoverIn(e);
|
|
@@ -616,7 +546,7 @@ function createComponent(configIn, ParentComponent) {
|
|
|
616
546
|
onMouseLeave == null ? void 0 : onMouseLeave(e);
|
|
617
547
|
} : void 0
|
|
618
548
|
},
|
|
619
|
-
|
|
549
|
+
onPressIn: attachPress ? (e) => {
|
|
620
550
|
setStateShallow({
|
|
621
551
|
press: true,
|
|
622
552
|
pressIn: true,
|
|
@@ -627,12 +557,12 @@ function createComponent(configIn, ParentComponent) {
|
|
|
627
557
|
if (import_constants.isWeb) {
|
|
628
558
|
mouseUps.add(unPress);
|
|
629
559
|
}
|
|
630
|
-
} :
|
|
631
|
-
|
|
560
|
+
} : void 0,
|
|
561
|
+
onPress: attachPress ? (e) => {
|
|
632
562
|
unPress();
|
|
633
563
|
onClick == null ? void 0 : onClick(e);
|
|
634
564
|
onPress == null ? void 0 : onPress(e);
|
|
635
|
-
} :
|
|
565
|
+
} : void 0,
|
|
636
566
|
...!import_constants.isWeb && {
|
|
637
567
|
cancelable: !props.rejectResponderTermination,
|
|
638
568
|
disabled: props.disabled !== null ? props.disabled : (_e = props.accessibilityState) == null ? void 0 : _e.disabled,
|
|
@@ -680,28 +610,6 @@ function createComponent(configIn, ParentComponent) {
|
|
|
680
610
|
onPressOut
|
|
681
611
|
};
|
|
682
612
|
}
|
|
683
|
-
if (!import_constants.isRSC && import_constants.isWeb) {
|
|
684
|
-
const [pressableProps] = (0, import_usePressable.usePressable)(
|
|
685
|
-
events ? {
|
|
686
|
-
disabled,
|
|
687
|
-
...hitSlop && {
|
|
688
|
-
hitSlop
|
|
689
|
-
},
|
|
690
|
-
onPressOut: events[pressOutKey],
|
|
691
|
-
onPressIn: events[pressInKey],
|
|
692
|
-
onPress: events[pressKey]
|
|
693
|
-
} : {
|
|
694
|
-
disabled: true
|
|
695
|
-
}
|
|
696
|
-
);
|
|
697
|
-
if (events) {
|
|
698
|
-
if (handlesPressEvents) {
|
|
699
|
-
Object.assign(viewProps, pressableProps);
|
|
700
|
-
} else {
|
|
701
|
-
Object.assign(viewProps, events);
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
613
|
if (process.env.TAMAGUI_TARGET === "native") {
|
|
706
614
|
const attachFocus = !!(pseudos && pseudos.focusStyle || initialPseudos && initialPseudos.focusStyle);
|
|
707
615
|
if (attachFocus) {
|
|
@@ -714,9 +622,6 @@ function createComponent(configIn, ParentComponent) {
|
|
|
714
622
|
}
|
|
715
623
|
const pressability = (0, import_Pressability.usePressability)(events);
|
|
716
624
|
if (attachPress && events) {
|
|
717
|
-
const dontComposePressabilityKeys = {
|
|
718
|
-
onClick: true
|
|
719
|
-
};
|
|
720
625
|
if (hitSlop) {
|
|
721
626
|
viewProps.hitSlop = hitSlop;
|
|
722
627
|
}
|
|
@@ -729,21 +634,23 @@ function createComponent(configIn, ParentComponent) {
|
|
|
729
634
|
}
|
|
730
635
|
content = (0, import_react.createElement)(elementType, viewProps, childEls);
|
|
731
636
|
if (process.env.TAMAGUI_TARGET === "web") {
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
637
|
+
if (events) {
|
|
638
|
+
content = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
639
|
+
style: styleDisplayContents,
|
|
640
|
+
onMouseEnter: events.onMouseEnter,
|
|
641
|
+
onMouseLeave: events.onMouseLeave,
|
|
642
|
+
onClick: events.onPress,
|
|
643
|
+
onMouseDown: events.onPressIn,
|
|
644
|
+
onMouseUp: events.onPressOut,
|
|
645
|
+
onTouchStart: events.onPressIn,
|
|
646
|
+
onTouchEnd: events.onPressOut,
|
|
647
|
+
children: content
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
if (isText && isAnimatedReactNativeWeb) {
|
|
738
651
|
content = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
739
|
-
className:
|
|
740
|
-
style:
|
|
741
|
-
display: "contents"
|
|
742
|
-
},
|
|
743
|
-
...events && shouldWrapWithHover && {
|
|
744
|
-
onMouseEnter: events.onMouseEnter,
|
|
745
|
-
onMouseLeave: events.onMouseLeave
|
|
746
|
-
},
|
|
652
|
+
className: fontFamilyClassName,
|
|
653
|
+
style: styleDisplayContents,
|
|
747
654
|
children: content
|
|
748
655
|
});
|
|
749
656
|
}
|
|
@@ -769,52 +676,50 @@ function createComponent(configIn, ParentComponent) {
|
|
|
769
676
|
component.displayName = staticConfig.componentName;
|
|
770
677
|
}
|
|
771
678
|
(0, import_config.onConfiguredOnce)((conf) => {
|
|
772
|
-
if (!
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
679
|
+
if (!tamaguiConfig) {
|
|
680
|
+
tamaguiConfig = conf;
|
|
681
|
+
if (!defaultComponentState) {
|
|
682
|
+
defaultComponentState = {
|
|
683
|
+
hover: false,
|
|
684
|
+
press: false,
|
|
685
|
+
pressIn: false,
|
|
686
|
+
focus: false,
|
|
687
|
+
mounted: false,
|
|
688
|
+
mediaState: (0, import_useMedia.getInitialMediaState)()
|
|
689
|
+
};
|
|
690
|
+
defaultComponentStateMounted = {
|
|
691
|
+
...defaultComponentState,
|
|
692
|
+
mounted: true
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
if (tamaguiConfig.animations) {
|
|
696
|
+
AnimatedText = tamaguiConfig.animations.Text;
|
|
697
|
+
AnimatedView = tamaguiConfig.animations.View;
|
|
698
|
+
}
|
|
699
|
+
if (!initialTheme) {
|
|
700
|
+
const next = conf.themes[conf.defaultTheme || Object.keys(conf.themes)[0]];
|
|
701
|
+
initialTheme = (0, import_proxyThemeVariables.proxyThemeVariables)(next);
|
|
702
|
+
if (!initialTheme && process.env.NODE_ENV === "development") {
|
|
703
|
+
console.log(`Warning: Missing theme`);
|
|
704
|
+
}
|
|
797
705
|
}
|
|
798
706
|
}
|
|
799
|
-
|
|
707
|
+
mergeShorthands(staticConfig, tamaguiConfig);
|
|
800
708
|
let defaultPropsIn = staticConfig.defaultProps || {};
|
|
801
709
|
const parentNames = [...staticConfig.parentNames || [], staticConfig.componentName];
|
|
802
|
-
if (
|
|
710
|
+
if (tamaguiConfig.defaultProps && parentNames && staticConfig.componentName) {
|
|
803
711
|
defaultPropsIn = mergeConfigDefaultProps(
|
|
804
712
|
staticConfig.componentName,
|
|
805
713
|
defaultPropsIn,
|
|
806
|
-
|
|
714
|
+
tamaguiConfig.defaultProps,
|
|
807
715
|
parentNames,
|
|
808
|
-
|
|
716
|
+
tamaguiConfig
|
|
809
717
|
);
|
|
810
718
|
}
|
|
811
719
|
const debug = defaultPropsIn["debug"];
|
|
812
|
-
|
|
813
|
-
debugger;
|
|
814
|
-
}
|
|
815
|
-
const [parentProps, parentClassNames] = (0, import_mergeProps.mergeProps)(defaultPropsIn, {}, true);
|
|
720
|
+
const [ourProps, ourClassNames] = (0, import_mergeProps.mergeProps)(defaultPropsIn, {}, true);
|
|
816
721
|
initialSplitStyles = (0, import_getSplitStyles.insertSplitStyles)(
|
|
817
|
-
|
|
722
|
+
ourProps,
|
|
818
723
|
staticConfig,
|
|
819
724
|
initialTheme,
|
|
820
725
|
{
|
|
@@ -837,9 +742,9 @@ function createComponent(configIn, ParentComponent) {
|
|
|
837
742
|
true
|
|
838
743
|
);
|
|
839
744
|
initialSplitStyles.classNames = {
|
|
840
|
-
...parentClassNames,
|
|
841
745
|
...defaultsClassnames,
|
|
842
|
-
...initialSplitStyles.classNames
|
|
746
|
+
...initialSplitStyles.classNames,
|
|
747
|
+
...ourClassNames
|
|
843
748
|
};
|
|
844
749
|
defaultNativeStyle = {};
|
|
845
750
|
const validStyles2 = staticConfig.validStyles || import_helpers.stylePropsView;
|
|
@@ -866,7 +771,12 @@ function createComponent(configIn, ParentComponent) {
|
|
|
866
771
|
tamaguiDefaultProps,
|
|
867
772
|
defaultNativeStyle,
|
|
868
773
|
defaults: defaults2,
|
|
869
|
-
defaultPropsIn
|
|
774
|
+
defaultPropsIn,
|
|
775
|
+
defaultPropsKeyOrder: Object.keys(staticConfig.defaultProps),
|
|
776
|
+
defaultPropsInKeyOrder: Object.keys(defaultPropsIn).map((k) => [k, defaultPropsIn[k]]),
|
|
777
|
+
ourProps,
|
|
778
|
+
ourClassNames,
|
|
779
|
+
defaultsClassnames
|
|
870
780
|
});
|
|
871
781
|
}
|
|
872
782
|
}
|
|
@@ -939,9 +849,6 @@ const Spacer = createComponent({
|
|
|
939
849
|
},
|
|
940
850
|
both: {}
|
|
941
851
|
}
|
|
942
|
-
},
|
|
943
|
-
defaultVariants: {
|
|
944
|
-
direction: "both"
|
|
945
852
|
}
|
|
946
853
|
});
|
|
947
854
|
function spacedChildren({
|
|
@@ -987,7 +894,7 @@ function spacedChildren({
|
|
|
987
894
|
if (hasSpace) {
|
|
988
895
|
final.push(
|
|
989
896
|
createSpacer({
|
|
990
|
-
key: `_${index}
|
|
897
|
+
key: `_${index}_00tmgui`,
|
|
991
898
|
direction,
|
|
992
899
|
space,
|
|
993
900
|
spaceFlex
|
|
@@ -1000,7 +907,7 @@ function spacedChildren({
|
|
|
1000
907
|
if (hasSpace) {
|
|
1001
908
|
final.push(
|
|
1002
909
|
createSpacer({
|
|
1003
|
-
key: `_${index}
|
|
910
|
+
key: `_${index}01tmgui`,
|
|
1004
911
|
direction,
|
|
1005
912
|
space,
|
|
1006
913
|
spaceFlex
|
|
@@ -1010,7 +917,7 @@ function spacedChildren({
|
|
|
1010
917
|
} else {
|
|
1011
918
|
final.push(
|
|
1012
919
|
createSpacer({
|
|
1013
|
-
key: `_${index}
|
|
920
|
+
key: `_${index}02tmgui`,
|
|
1014
921
|
direction,
|
|
1015
922
|
space,
|
|
1016
923
|
spaceFlex
|
|
@@ -1034,37 +941,6 @@ function isUnspaced(child) {
|
|
|
1034
941
|
var _a, _b;
|
|
1035
942
|
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"]);
|
|
1036
943
|
}
|
|
1037
|
-
function AbsoluteFill(props) {
|
|
1038
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.View, {
|
|
1039
|
-
pointerEvents: "box-none",
|
|
1040
|
-
style: absoluteFill,
|
|
1041
|
-
children: props.children
|
|
1042
|
-
});
|
|
1043
|
-
}
|
|
1044
|
-
const absoluteFill = {
|
|
1045
|
-
position: "absolute",
|
|
1046
|
-
top: 0,
|
|
1047
|
-
left: 0,
|
|
1048
|
-
right: 0,
|
|
1049
|
-
bottom: 0
|
|
1050
|
-
};
|
|
1051
|
-
function processIDRefList(idRefList) {
|
|
1052
|
-
return Array.isArray(idRefList) ? idRefList.join(" ") : idRefList;
|
|
1053
|
-
}
|
|
1054
|
-
const accessibilityRoleToWebRole = {
|
|
1055
|
-
adjustable: "slider",
|
|
1056
|
-
button: "button",
|
|
1057
|
-
header: "heading",
|
|
1058
|
-
image: "img",
|
|
1059
|
-
imagebutton: null,
|
|
1060
|
-
keyboardkey: null,
|
|
1061
|
-
label: null,
|
|
1062
|
-
link: "link",
|
|
1063
|
-
none: "presentation",
|
|
1064
|
-
search: "search",
|
|
1065
|
-
summary: "region",
|
|
1066
|
-
text: null
|
|
1067
|
-
};
|
|
1068
944
|
function addPseudoToStyles(styles, initialPseudos, pseudos, name, force = false) {
|
|
1069
945
|
const pseudoStyle = pseudos[name];
|
|
1070
946
|
const shouldNestObject = import_constants.isWeb && name !== "enterStyle" && name !== "exitStyle";
|
|
@@ -1165,14 +1041,48 @@ function merge(base, next) {
|
|
|
1165
1041
|
}
|
|
1166
1042
|
}
|
|
1167
1043
|
}
|
|
1044
|
+
function usePlatformMethods(hostRef) {
|
|
1045
|
+
(0, import_constants.useIsomorphicLayoutEffect)(() => {
|
|
1046
|
+
const node = hostRef.current;
|
|
1047
|
+
if (!node)
|
|
1048
|
+
return;
|
|
1049
|
+
node.measure = (callback) => (0, import_useElementLayout.measureLayout)(node, null, callback);
|
|
1050
|
+
node.measureLayout = (relativeToNode, success) => (0, import_useElementLayout.measureLayout)(node, relativeToNode, success);
|
|
1051
|
+
node.measureInWindow = (callback) => {
|
|
1052
|
+
if (!node)
|
|
1053
|
+
return;
|
|
1054
|
+
setTimeout(() => {
|
|
1055
|
+
const { height, left, top, width } = (0, import_useElementLayout.getRect)(node);
|
|
1056
|
+
callback(left, top, width, height);
|
|
1057
|
+
}, 0);
|
|
1058
|
+
};
|
|
1059
|
+
}, [hostRef]);
|
|
1060
|
+
}
|
|
1061
|
+
const AbsoluteFill = createComponent({
|
|
1062
|
+
componentName: "AbsoluteFill",
|
|
1063
|
+
defaultProps: {
|
|
1064
|
+
...import_constants2.stackDefaultStyles,
|
|
1065
|
+
flexDirection: "column",
|
|
1066
|
+
position: "absolute",
|
|
1067
|
+
top: 0,
|
|
1068
|
+
right: 0,
|
|
1069
|
+
bottom: 0,
|
|
1070
|
+
left: 0,
|
|
1071
|
+
pointerEvents: "box-none"
|
|
1072
|
+
}
|
|
1073
|
+
});
|
|
1074
|
+
const styleDisplayContents = {
|
|
1075
|
+
display: "contents"
|
|
1076
|
+
};
|
|
1077
|
+
const dontComposePressabilityKeys = {
|
|
1078
|
+
onClick: true
|
|
1079
|
+
};
|
|
1168
1080
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1169
1081
|
0 && (module.exports = {
|
|
1170
1082
|
Spacer,
|
|
1171
1083
|
Unspaced,
|
|
1172
|
-
accessibilityRoleToWebRole,
|
|
1173
1084
|
createComponent,
|
|
1174
1085
|
mouseUps,
|
|
1175
|
-
processIDRefList,
|
|
1176
1086
|
spacedChildren
|
|
1177
1087
|
});
|
|
1178
1088
|
//# sourceMappingURL=createComponent.js.map
|