@tamagui/core 1.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.ultra.cache.json +1 -0
- package/_/constants/constants.js +14 -0
- package/_/constants/constants.js.map +7 -0
- package/_/constants/platform.js +20 -0
- package/_/constants/platform.js.map +7 -0
- package/_/constants/pseudos.js +18 -0
- package/_/constants/pseudos.js.map +7 -0
- package/_/constants/rnw.js +22 -0
- package/_/constants/rnw.js.map +7 -0
- package/_/createComponent.js +427 -0
- package/_/createComponent.js.map +7 -0
- package/_/createShorthands.js +10 -0
- package/_/createShorthands.js.map +7 -0
- package/_/createTamagui.js +122 -0
- package/_/createTamagui.js.map +7 -0
- package/_/createTheme.js +20 -0
- package/_/createTheme.js.map +7 -0
- package/_/createTokens.js +29 -0
- package/_/createTokens.js.map +7 -0
- package/_/createVariable.js +22 -0
- package/_/createVariable.js.map +7 -0
- package/_/helpers/addStylesUsingClassname.js +32 -0
- package/_/helpers/addStylesUsingClassname.js.map +7 -0
- package/_/helpers/createMediaStyle.js +34 -0
- package/_/helpers/createMediaStyle.js.map +7 -0
- package/_/helpers/createTamaguiProvider.js +42 -0
- package/_/helpers/createTamaguiProvider.js.map +7 -0
- package/_/helpers/extendStaticConfig.js +176 -0
- package/_/helpers/extendStaticConfig.js.map +7 -0
- package/_/helpers/fixNativeShadow.js +8 -0
- package/_/helpers/fixNativeShadow.js.map +7 -0
- package/_/helpers/fixNativeShadow.native.js +30 -0
- package/_/helpers/fixNativeShadow.native.js.map +7 -0
- package/_/helpers/getSplitStyles.js +160 -0
- package/_/helpers/getSplitStyles.js.map +7 -0
- package/_/helpers/getStylesAtomic.js +84 -0
- package/_/helpers/getStylesAtomic.js.map +7 -0
- package/_/helpers/getStylesAtomic.native.js +10 -0
- package/_/helpers/getStylesAtomic.native.js.map +7 -0
- package/_/helpers/insertStyleRule.js +24 -0
- package/_/helpers/insertStyleRule.js.map +7 -0
- package/_/helpers/matchMedia.js +15 -0
- package/_/helpers/matchMedia.js.map +7 -0
- package/_/helpers/matchMedia.native.js +8 -0
- package/_/helpers/matchMedia.native.js.map +7 -0
- package/_/helpers/themeable.js +26 -0
- package/_/helpers/themeable.js.map +7 -0
- package/_/hooks/useConstant.js +15 -0
- package/_/hooks/useConstant.js.map +7 -0
- package/_/hooks/useFeatures.js +75 -0
- package/_/hooks/useFeatures.js.map +7 -0
- package/_/hooks/useForceUpdate.js +28 -0
- package/_/hooks/useForceUpdate.js.map +7 -0
- package/_/hooks/useMedia.js +173 -0
- package/_/hooks/useMedia.js.map +7 -0
- package/_/hooks/usePressable.js +14 -0
- package/_/hooks/usePressable.js.map +7 -0
- package/_/hooks/useTheme.js +94 -0
- package/_/hooks/useTheme.js.map +7 -0
- package/_/index.js +30 -0
- package/_/index.js.map +7 -0
- package/_/static/postProcessStyles.js +18 -0
- package/_/static/postProcessStyles.js.map +7 -0
- package/_/static.js +12 -0
- package/_/static.js.map +7 -0
- package/_/styled.js +21 -0
- package/_/styled.js.map +7 -0
- package/_/types.js +1 -0
- package/_/types.js.map +7 -0
- package/_/views/Animated.js +79 -0
- package/_/views/Animated.js.map +7 -0
- package/_/views/Stack.js +12 -0
- package/_/views/Stack.js.map +7 -0
- package/_/views/Text.js +60 -0
- package/_/views/Text.js.map +7 -0
- package/_/views/TextAncestorContext.js +19 -0
- package/_/views/TextAncestorContext.js.map +7 -0
- package/_/views/Theme.js +57 -0
- package/_/views/Theme.js.map +7 -0
- package/_/views/ThemeContext.js +6 -0
- package/_/views/ThemeContext.js.map +7 -0
- package/_/views/ThemeInverse.js +27 -0
- package/_/views/ThemeInverse.js.map +7 -0
- package/_/views/ThemeManagerContext.js +56 -0
- package/_/views/ThemeManagerContext.js.map +7 -0
- package/_/views/ThemeProvider.js +45 -0
- package/_/views/ThemeProvider.js.map +7 -0
- package/dist/constants/constants.js +14 -0
- package/dist/constants/constants.js.map +7 -0
- package/dist/constants/platform.js +19 -0
- package/dist/constants/platform.js.map +7 -0
- package/dist/constants/pseudos.js +18 -0
- package/dist/constants/pseudos.js.map +7 -0
- package/dist/constants/rnw.js +22 -0
- package/dist/constants/rnw.js.map +7 -0
- package/dist/constants/styleConstants.js +46 -0
- package/dist/constants/styleConstants.js.map +7 -0
- package/dist/createComponent.js +445 -0
- package/dist/createComponent.js.map +7 -0
- package/dist/createFont.js +24 -0
- package/dist/createFont.js.map +7 -0
- package/dist/createShorthands.js +10 -0
- package/dist/createShorthands.js.map +7 -0
- package/dist/createTamagui.js +159 -0
- package/dist/createTamagui.js.map +7 -0
- package/dist/createTheme.js +20 -0
- package/dist/createTheme.js.map +7 -0
- package/dist/createTokens.js +29 -0
- package/dist/createTokens.js.map +7 -0
- package/dist/createVariable.js +22 -0
- package/dist/createVariable.js.map +7 -0
- package/dist/helpers/addStylesUsingClassname.js +57 -0
- package/dist/helpers/addStylesUsingClassname.js.map +7 -0
- package/dist/helpers/createMediaStyle.js +34 -0
- package/dist/helpers/createMediaStyle.js.map +7 -0
- package/dist/helpers/createPropMapper.js +153 -0
- package/dist/helpers/createPropMapper.js.map +7 -0
- package/dist/helpers/createTamaguiProvider.js +25 -0
- package/dist/helpers/createTamaguiProvider.js.map +7 -0
- package/dist/helpers/extendStaticConfig.js +59 -0
- package/dist/helpers/extendStaticConfig.js.map +7 -0
- package/dist/helpers/fixNativeShadow.js +8 -0
- package/dist/helpers/fixNativeShadow.js.map +7 -0
- package/dist/helpers/fixNativeShadow.native.js +30 -0
- package/dist/helpers/fixNativeShadow.native.js.map +7 -0
- package/dist/helpers/getSplitStyles.js +160 -0
- package/dist/helpers/getSplitStyles.js.map +7 -0
- package/dist/helpers/getStylesAtomic.js +83 -0
- package/dist/helpers/getStylesAtomic.js.map +7 -0
- package/dist/helpers/getStylesAtomic.native.js +10 -0
- package/dist/helpers/getStylesAtomic.native.js.map +7 -0
- package/dist/helpers/insertStyleRule.js +24 -0
- package/dist/helpers/insertStyleRule.js.map +7 -0
- package/dist/helpers/isObj.js +7 -0
- package/dist/helpers/isObj.js.map +7 -0
- package/dist/helpers/matchMedia.js +15 -0
- package/dist/helpers/matchMedia.js.map +7 -0
- package/dist/helpers/matchMedia.native.js +8 -0
- package/dist/helpers/matchMedia.native.js.map +7 -0
- package/dist/helpers/pseudos.js +1 -0
- package/dist/helpers/pseudos.js.map +7 -0
- package/dist/helpers/themeable.js +26 -0
- package/dist/helpers/themeable.js.map +7 -0
- package/dist/hooks/useConstant.js +15 -0
- package/dist/hooks/useConstant.js.map +7 -0
- package/dist/hooks/useFeatures.js +75 -0
- package/dist/hooks/useFeatures.js.map +7 -0
- package/dist/hooks/useForceUpdate.js +28 -0
- package/dist/hooks/useForceUpdate.js.map +7 -0
- package/dist/hooks/useMedia.js +171 -0
- package/dist/hooks/useMedia.js.map +7 -0
- package/dist/hooks/usePressable.js +13 -0
- package/dist/hooks/usePressable.js.map +7 -0
- package/dist/hooks/useTheme.js +93 -0
- package/dist/hooks/useTheme.js.map +7 -0
- package/dist/index.cjs +2125 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +7 -0
- package/dist/packages/core/src/constants/constants.d.ts +8 -0
- package/dist/packages/core/src/constants/constants.d.ts.map +1 -0
- package/dist/packages/core/src/constants/platform.d.ts +9 -0
- package/dist/packages/core/src/constants/platform.d.ts.map +1 -0
- package/dist/packages/core/src/constants/pseudos.d.ts +15 -0
- package/dist/packages/core/src/constants/pseudos.d.ts.map +1 -0
- package/dist/packages/core/src/constants/rnw.d.ts +2 -0
- package/dist/packages/core/src/constants/rnw.d.ts.map +1 -0
- package/dist/packages/core/src/createComponent.d.ts +16 -0
- package/dist/packages/core/src/createComponent.d.ts.map +1 -0
- package/dist/packages/core/src/createShorthands.d.ts +2 -0
- package/dist/packages/core/src/createShorthands.d.ts.map +1 -0
- package/dist/packages/core/src/createTamagui.d.ts +37 -0
- package/dist/packages/core/src/createTamagui.d.ts.map +1 -0
- package/dist/packages/core/src/createTheme.d.ts +5 -0
- package/dist/packages/core/src/createTheme.d.ts.map +1 -0
- package/dist/packages/core/src/createTokens.d.ts +45 -0
- package/dist/packages/core/src/createTokens.d.ts.map +1 -0
- package/dist/packages/core/src/createVariable.d.ts +14 -0
- package/dist/packages/core/src/createVariable.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/addStylesUsingClassname.d.ts +2 -0
- package/dist/packages/core/src/helpers/addStylesUsingClassname.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/createMediaStyle.d.ts +8 -0
- package/dist/packages/core/src/helpers/createMediaStyle.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/createTamaguiProvider.d.ts +5 -0
- package/dist/packages/core/src/helpers/createTamaguiProvider.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/extendStaticConfig.d.ts +5 -0
- package/dist/packages/core/src/helpers/extendStaticConfig.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/fixNativeShadow.d.ts +2 -0
- package/dist/packages/core/src/helpers/fixNativeShadow.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/fixNativeShadow.native.d.ts +2 -0
- package/dist/packages/core/src/helpers/fixNativeShadow.native.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/getSplitStyles.d.ts +15 -0
- package/dist/packages/core/src/helpers/getSplitStyles.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/getStylesAtomic.d.ts +3 -0
- package/dist/packages/core/src/helpers/getStylesAtomic.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/getStylesAtomic.native.d.ts +2 -0
- package/dist/packages/core/src/helpers/getStylesAtomic.native.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/insertStyleRule.d.ts +2 -0
- package/dist/packages/core/src/helpers/insertStyleRule.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/matchMedia.d.ts +2 -0
- package/dist/packages/core/src/helpers/matchMedia.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/matchMedia.native.d.ts +3 -0
- package/dist/packages/core/src/helpers/matchMedia.native.d.ts.map +1 -0
- package/dist/packages/core/src/helpers/themeable.d.ts +10 -0
- package/dist/packages/core/src/helpers/themeable.d.ts.map +1 -0
- package/dist/packages/core/src/hooks/useConstant.d.ts +2 -0
- package/dist/packages/core/src/hooks/useConstant.d.ts.map +1 -0
- package/dist/packages/core/src/hooks/useFeatures.d.ts +5 -0
- package/dist/packages/core/src/hooks/useFeatures.d.ts.map +1 -0
- package/dist/packages/core/src/hooks/useForceUpdate.d.ts +2 -0
- package/dist/packages/core/src/hooks/useForceUpdate.d.ts.map +1 -0
- package/dist/packages/core/src/hooks/useMedia.d.ts +16 -0
- package/dist/packages/core/src/hooks/useMedia.d.ts.map +1 -0
- package/dist/packages/core/src/hooks/usePressable.d.ts +3 -0
- package/dist/packages/core/src/hooks/usePressable.d.ts.map +1 -0
- package/dist/packages/core/src/hooks/useTheme.d.ts +18 -0
- package/dist/packages/core/src/hooks/useTheme.d.ts.map +1 -0
- package/dist/packages/core/src/index.d.ts +27 -0
- package/dist/packages/core/src/index.d.ts.map +1 -0
- package/dist/packages/core/src/static/postProcessStyles.d.ts +7 -0
- package/dist/packages/core/src/static/postProcessStyles.d.ts.map +1 -0
- package/dist/packages/core/src/static.d.ts +12 -0
- package/dist/packages/core/src/static.d.ts.map +1 -0
- package/dist/packages/core/src/styled.d.ts +16 -0
- package/dist/packages/core/src/styled.d.ts.map +1 -0
- package/dist/packages/core/src/types.d.ts +305 -0
- package/dist/packages/core/src/types.d.ts.map +1 -0
- package/dist/packages/core/src/views/Animated.d.ts +15 -0
- package/dist/packages/core/src/views/Animated.d.ts.map +1 -0
- package/dist/packages/core/src/views/Stack.d.ts +3 -0
- package/dist/packages/core/src/views/Stack.d.ts.map +1 -0
- package/dist/packages/core/src/views/Text.d.ts +3 -0
- package/dist/packages/core/src/views/Text.d.ts.map +1 -0
- package/dist/packages/core/src/views/TextAncestorContext.d.ts +3 -0
- package/dist/packages/core/src/views/TextAncestorContext.d.ts.map +1 -0
- package/dist/packages/core/src/views/Theme.d.ts +8 -0
- package/dist/packages/core/src/views/Theme.d.ts.map +1 -0
- package/dist/packages/core/src/views/ThemeContext.d.ts +18 -0
- package/dist/packages/core/src/views/ThemeContext.d.ts.map +1 -0
- package/dist/packages/core/src/views/ThemeInverse.d.ts +10 -0
- package/dist/packages/core/src/views/ThemeInverse.d.ts.map +1 -0
- package/dist/packages/core/src/views/ThemeManagerContext.d.ts +15 -0
- package/dist/packages/core/src/views/ThemeManagerContext.d.ts.map +1 -0
- package/dist/packages/core/src/views/ThemeProvider.d.ts +10 -0
- package/dist/packages/core/src/views/ThemeProvider.d.ts.map +1 -0
- package/dist/packages/helpers/src/AllRules.d.ts +3 -0
- package/dist/packages/helpers/src/AllRules.d.ts.map +1 -0
- package/dist/packages/helpers/src/concatClassName.d.ts +2 -0
- package/dist/packages/helpers/src/concatClassName.d.ts.map +1 -0
- package/dist/packages/helpers/src/index.d.ts +5 -0
- package/dist/packages/helpers/src/index.d.ts.map +1 -0
- package/dist/packages/helpers/src/types.d.ts +8 -0
- package/dist/packages/helpers/src/types.d.ts.map +1 -0
- package/dist/packages/helpers/src/validStyleProps.d.ts +475 -0
- package/dist/packages/helpers/src/validStyleProps.d.ts.map +1 -0
- package/dist/static/postProcessStyles.js +18 -0
- package/dist/static/postProcessStyles.js.map +7 -0
- package/dist/static.js +15 -0
- package/dist/static.js.map +7 -0
- package/dist/styled.js +21 -0
- package/dist/styled.js.map +7 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +7 -0
- package/dist/views/Animated.js +79 -0
- package/dist/views/Animated.js.map +7 -0
- package/dist/views/SafeAreaProvider.js +30 -0
- package/dist/views/SafeAreaProvider.js.map +7 -0
- package/dist/views/Stack.js +12 -0
- package/dist/views/Stack.js.map +7 -0
- package/dist/views/Text.js +60 -0
- package/dist/views/Text.js.map +7 -0
- package/dist/views/TextAncestorContext.js +18 -0
- package/dist/views/TextAncestorContext.js.map +7 -0
- package/dist/views/Theme.js +56 -0
- package/dist/views/Theme.js.map +7 -0
- package/dist/views/ThemeContext.js +6 -0
- package/dist/views/ThemeContext.js.map +7 -0
- package/dist/views/ThemeInverse.js +27 -0
- package/dist/views/ThemeInverse.js.map +7 -0
- package/dist/views/ThemeManagerContext.js +55 -0
- package/dist/views/ThemeManagerContext.js.map +7 -0
- package/dist/views/ThemeProvider.js +45 -0
- package/dist/views/ThemeProvider.js.map +7 -0
- package/package.json +33 -0
- package/src/constants/constants.ts +12 -0
- package/src/constants/platform.ts +15 -0
- package/src/constants/pseudos.ts +14 -0
- package/src/constants/rnw.tsx +20 -0
- package/src/createComponent.tsx +596 -0
- package/src/createFont.ts +26 -0
- package/src/createShorthands.ts +5 -0
- package/src/createTamagui.ts +207 -0
- package/src/createTheme.ts +19 -0
- package/src/createTokens.ts +83 -0
- package/src/createVariable.ts +22 -0
- package/src/helpers/addStylesUsingClassname.tsx +60 -0
- package/src/helpers/createMediaStyle.ts +46 -0
- package/src/helpers/createPropMapper.ts +184 -0
- package/src/helpers/createTamaguiProvider.tsx +22 -0
- package/src/helpers/extendStaticConfig.ts +68 -0
- package/src/helpers/fixNativeShadow.native.tsx +27 -0
- package/src/helpers/fixNativeShadow.tsx +2 -0
- package/src/helpers/getSplitStyles.tsx +210 -0
- package/src/helpers/getStylesAtomic.native.ts +3 -0
- package/src/helpers/getStylesAtomic.ts +103 -0
- package/src/helpers/insertStyleRule.tsx +18 -0
- package/src/helpers/isObj.ts +1 -0
- package/src/helpers/matchMedia.native.ts +3 -0
- package/src/helpers/matchMedia.ts +9 -0
- package/src/helpers/themeable.tsx +42 -0
- package/src/hooks/useConstant.tsx +10 -0
- package/src/hooks/useFeatures.tsx +78 -0
- package/src/hooks/useForceUpdate.tsx +26 -0
- package/src/hooks/useMedia.tsx +194 -0
- package/src/hooks/usePressable.tsx +9 -0
- package/src/hooks/useTheme.tsx +107 -0
- package/src/index.ts +33 -0
- package/src/static/postProcessStyles.tsx +20 -0
- package/src/static.ts +22 -0
- package/src/styled.ts +82 -0
- package/src/types.tsx +561 -0
- package/src/views/Animated.tsx +121 -0
- package/src/views/SafeAreaProvider.tsx +33 -0
- package/src/views/Stack.tsx +21 -0
- package/src/views/Text.tsx +66 -0
- package/src/views/TextAncestorContext.tsx +12 -0
- package/src/views/Theme.tsx +73 -0
- package/src/views/ThemeContext.tsx +5 -0
- package/src/views/ThemeInverse.tsx +23 -0
- package/src/views/ThemeManagerContext.tsx +50 -0
- package/src/views/ThemeProvider.tsx +52 -0
- package/tsconfig.json +8 -0
- package/types.d.ts +558 -0
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { concatClassName, stylePropsView } from "@tamagui/helpers";
|
|
4
|
+
import React, {
|
|
5
|
+
Children,
|
|
6
|
+
Fragment,
|
|
7
|
+
createElement,
|
|
8
|
+
forwardRef,
|
|
9
|
+
useCallback,
|
|
10
|
+
useContext,
|
|
11
|
+
useEffect,
|
|
12
|
+
useRef,
|
|
13
|
+
useState
|
|
14
|
+
} from "react";
|
|
15
|
+
import { StyleSheet, Text, View } from "react-native";
|
|
16
|
+
import { stackDefaultStyles } from "./constants/constants";
|
|
17
|
+
import { isTouchDevice, isWeb } from "./constants/platform";
|
|
18
|
+
import { rnw } from "./constants/rnw";
|
|
19
|
+
import { onConfiguredOnce } from "./createTamagui";
|
|
20
|
+
import { addStylesUsingClassname, useStylesAsClassname } from "./helpers/addStylesUsingClassname";
|
|
21
|
+
import { extendStaticConfig, parseStaticConfig } from "./helpers/extendStaticConfig";
|
|
22
|
+
import { getSplitStyles } from "./helpers/getSplitStyles";
|
|
23
|
+
import { useFeatures } from "./hooks/useFeatures";
|
|
24
|
+
import { useForceUpdate } from "./hooks/useForceUpdate";
|
|
25
|
+
import { usePressable } from "./hooks/usePressable";
|
|
26
|
+
import { TextAncestorContext } from "./views/TextAncestorContext";
|
|
27
|
+
import { ThemeManagerContext } from "./views/ThemeManagerContext";
|
|
28
|
+
const mouseUps = new Set();
|
|
29
|
+
if (typeof document !== "undefined") {
|
|
30
|
+
document.addEventListener("mouseup", () => {
|
|
31
|
+
mouseUps.forEach((x) => x());
|
|
32
|
+
mouseUps.clear();
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function createComponent(configIn) {
|
|
36
|
+
let staticConfig;
|
|
37
|
+
if ("parsed" in configIn) {
|
|
38
|
+
staticConfig = configIn;
|
|
39
|
+
} else {
|
|
40
|
+
staticConfig = parseStaticConfig(configIn);
|
|
41
|
+
}
|
|
42
|
+
const { Component, validStyles, isText, isZStack } = staticConfig;
|
|
43
|
+
const validStyleProps = validStyles ?? stylePropsView;
|
|
44
|
+
let defaultProps = null;
|
|
45
|
+
let tamaguiConfig;
|
|
46
|
+
let defaultsStyle;
|
|
47
|
+
let defaultsClassName = "";
|
|
48
|
+
let initialTheme;
|
|
49
|
+
const component = forwardRef((props, forwardedRef) => {
|
|
50
|
+
const {
|
|
51
|
+
tag,
|
|
52
|
+
hitSlop,
|
|
53
|
+
children,
|
|
54
|
+
pointerEvents,
|
|
55
|
+
onPress,
|
|
56
|
+
onPressIn,
|
|
57
|
+
onPressOut,
|
|
58
|
+
onHoverIn,
|
|
59
|
+
onHoverOut,
|
|
60
|
+
space,
|
|
61
|
+
disabled,
|
|
62
|
+
onMouseEnter,
|
|
63
|
+
onMouseLeave,
|
|
64
|
+
hrefAttrs,
|
|
65
|
+
onMoveShouldSetResponder,
|
|
66
|
+
onMoveShouldSetResponderCapture,
|
|
67
|
+
onResponderEnd,
|
|
68
|
+
onResponderGrant,
|
|
69
|
+
onResponderMove,
|
|
70
|
+
onResponderReject,
|
|
71
|
+
onResponderRelease,
|
|
72
|
+
onResponderStart,
|
|
73
|
+
onResponderTerminate,
|
|
74
|
+
onResponderTerminationRequest,
|
|
75
|
+
onScrollShouldSetResponder,
|
|
76
|
+
onScrollShouldSetResponderCapture,
|
|
77
|
+
onSelectionChangeShouldSetResponder,
|
|
78
|
+
onSelectionChangeShouldSetResponderCapture,
|
|
79
|
+
onStartShouldSetResponder,
|
|
80
|
+
onStartShouldSetResponderCapture,
|
|
81
|
+
onMouseDown,
|
|
82
|
+
onClick,
|
|
83
|
+
onLayout
|
|
84
|
+
} = props;
|
|
85
|
+
const forceUpdate = useForceUpdate();
|
|
86
|
+
const features = useFeatures(props, { forceUpdate });
|
|
87
|
+
const manager = useContext(ThemeManagerContext);
|
|
88
|
+
const [state, set_] = useState(() => ({
|
|
89
|
+
hover: false,
|
|
90
|
+
press: false,
|
|
91
|
+
pressIn: false,
|
|
92
|
+
theme: manager.name
|
|
93
|
+
}));
|
|
94
|
+
const set = /* @__PURE__ */ __name((next) => set_((prev) => {
|
|
95
|
+
for (const key in next) {
|
|
96
|
+
if (prev[key] !== next[key]) {
|
|
97
|
+
return { ...prev, ...next };
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return prev;
|
|
101
|
+
}), "set");
|
|
102
|
+
if (process.env.NODE_ENV === "development" && !isText && isWeb) {
|
|
103
|
+
Children.toArray(props.children).forEach((item) => {
|
|
104
|
+
if (typeof item === "string") {
|
|
105
|
+
console.error(`Unexpected text node: ${item}. A text node cannot be a child of a <View>.`);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
const hasTextAncestor = isWeb ? useContext(TextAncestorContext) : false;
|
|
110
|
+
const hostRef = useRef(null);
|
|
111
|
+
if (isWeb) {
|
|
112
|
+
rnw.useResponderEvents(hostRef, {
|
|
113
|
+
onMoveShouldSetResponder,
|
|
114
|
+
onMoveShouldSetResponderCapture,
|
|
115
|
+
onResponderEnd,
|
|
116
|
+
onResponderGrant,
|
|
117
|
+
onResponderMove,
|
|
118
|
+
onResponderReject,
|
|
119
|
+
onResponderRelease,
|
|
120
|
+
onResponderStart,
|
|
121
|
+
onResponderTerminate,
|
|
122
|
+
onResponderTerminationRequest,
|
|
123
|
+
onScrollShouldSetResponder,
|
|
124
|
+
onScrollShouldSetResponderCapture,
|
|
125
|
+
onSelectionChangeShouldSetResponder,
|
|
126
|
+
onSelectionChangeShouldSetResponderCapture,
|
|
127
|
+
onStartShouldSetResponder,
|
|
128
|
+
onStartShouldSetResponderCapture
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
const isTracking = useRef(false);
|
|
132
|
+
const { viewProps, pseudos, style, classNames } = getSplitStyles(props, staticConfig, manager.theme || initialTheme);
|
|
133
|
+
const internal = useRef();
|
|
134
|
+
if (!internal.current) {
|
|
135
|
+
internal.current = {
|
|
136
|
+
isMounted: true
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
internal.current.isMounted = true;
|
|
141
|
+
const dispose = manager?.onChangeTheme((name) => {
|
|
142
|
+
if (isTracking.current) {
|
|
143
|
+
set({ theme: name });
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
return () => {
|
|
147
|
+
dispose();
|
|
148
|
+
mouseUps.delete(unPress);
|
|
149
|
+
isTracking.current = false;
|
|
150
|
+
internal.current.isMounted = false;
|
|
151
|
+
};
|
|
152
|
+
}, [manager]);
|
|
153
|
+
const element = isWeb ? !Component || typeof Component === "string" ? tag || Component : Component : Component;
|
|
154
|
+
const ReactView = !isWeb ? View : element || (hasTextAncestor ? "span" : "div");
|
|
155
|
+
const ReactText = !isWeb ? Text : element || "span";
|
|
156
|
+
const ViewComponent = isText ? ReactText : ReactView;
|
|
157
|
+
const isHovering = !isTouchDevice && !disabled && pseudos && state.hover;
|
|
158
|
+
const isPressing = !disabled && pseudos && state.press;
|
|
159
|
+
const styles = [
|
|
160
|
+
style,
|
|
161
|
+
isHovering ? pseudos.hoverStyle || null : null,
|
|
162
|
+
isPressing ? pseudos.pressStyle || null : null
|
|
163
|
+
];
|
|
164
|
+
if (isWeb) {
|
|
165
|
+
const stylesClassNames = useStylesAsClassname(styles);
|
|
166
|
+
const classList = isText ? [
|
|
167
|
+
defaultsClassName,
|
|
168
|
+
classNames,
|
|
169
|
+
stylesClassNames,
|
|
170
|
+
props.className
|
|
171
|
+
] : [defaultsClassName, props.className, classNames, stylesClassNames];
|
|
172
|
+
const className = concatClassName(...classList);
|
|
173
|
+
if (process.env.NODE_ENV === "development") {
|
|
174
|
+
if (props["debug"]) {
|
|
175
|
+
console.log("\u{1F95A} className", { style, styles, classList, stylesClassNames, className });
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
viewProps.className = className;
|
|
179
|
+
} else {
|
|
180
|
+
viewProps.style = styles;
|
|
181
|
+
}
|
|
182
|
+
if (pointerEvents) {
|
|
183
|
+
viewProps.pointerEvents = pointerEvents;
|
|
184
|
+
}
|
|
185
|
+
if (isWeb) {
|
|
186
|
+
const platformMethodsRef = rnw.usePlatformMethods(viewProps);
|
|
187
|
+
const setRef = rnw.useMergeRefs(hostRef, platformMethodsRef, forwardedRef);
|
|
188
|
+
viewProps.ref = setRef;
|
|
189
|
+
if (props.href != null && hrefAttrs != null) {
|
|
190
|
+
const { download, rel, target } = hrefAttrs;
|
|
191
|
+
if (download != null) {
|
|
192
|
+
viewProps.download = download;
|
|
193
|
+
}
|
|
194
|
+
if (rel != null) {
|
|
195
|
+
viewProps.rel = rel;
|
|
196
|
+
}
|
|
197
|
+
if (typeof target === "string") {
|
|
198
|
+
viewProps.target = target.charAt(0) !== "_" ? "_" + target : target;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
} else {
|
|
202
|
+
if (forwardedRef) {
|
|
203
|
+
viewProps.ref = forwardedRef;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
const attachPress = !!(pseudos && pseudos.pressStyle || onPress || onPressOut || onPressIn || onClick);
|
|
207
|
+
const attachHover = isWeb && !isTouchDevice && !!(pseudos && pseudos.hoverStyle || onHoverIn || onHoverOut || onMouseEnter || onMouseLeave);
|
|
208
|
+
const shouldAttach = internal.current.hasEverHadEvents || attachPress || attachHover || "pressStyle" in props || "onPress" in props || "onPressIn" in props || "onPressOut" in props || isWeb && ("hoverStyle" in props || "onClick" in props || "onHoverIn" in props || "onHoverOut" in props || "onMouseEnter" in props || "onMouseLeave" in props);
|
|
209
|
+
if (shouldAttach) {
|
|
210
|
+
internal.current.hasEverHadEvents = true;
|
|
211
|
+
}
|
|
212
|
+
const unPress = useCallback(() => {
|
|
213
|
+
if (!internal.current.isMounted)
|
|
214
|
+
return;
|
|
215
|
+
set({
|
|
216
|
+
press: false,
|
|
217
|
+
pressIn: false
|
|
218
|
+
});
|
|
219
|
+
}, []);
|
|
220
|
+
const events = shouldAttach ? {
|
|
221
|
+
...!isWeb && {
|
|
222
|
+
onPressOut: (e) => {
|
|
223
|
+
unPress();
|
|
224
|
+
onPressOut?.(e);
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
...isWeb && !isTouchDevice && {
|
|
228
|
+
onMouseEnter: attachHover || attachPress ? (e) => {
|
|
229
|
+
let next = {};
|
|
230
|
+
if (attachHover) {
|
|
231
|
+
next.hover = true;
|
|
232
|
+
}
|
|
233
|
+
if (state.pressIn) {
|
|
234
|
+
next.press = true;
|
|
235
|
+
}
|
|
236
|
+
if (Object.keys(next).length) {
|
|
237
|
+
set(next);
|
|
238
|
+
}
|
|
239
|
+
onHoverIn?.(e);
|
|
240
|
+
onMouseEnter?.(e);
|
|
241
|
+
} : void 0,
|
|
242
|
+
onMouseLeave: attachHover || attachPress ? (e) => {
|
|
243
|
+
let next = {};
|
|
244
|
+
mouseUps.add(unPress);
|
|
245
|
+
if (attachHover) {
|
|
246
|
+
next.hover = false;
|
|
247
|
+
}
|
|
248
|
+
if (state.pressIn) {
|
|
249
|
+
next.press = false;
|
|
250
|
+
next.pressIn = false;
|
|
251
|
+
}
|
|
252
|
+
if (Object.keys(next).length) {
|
|
253
|
+
set(next);
|
|
254
|
+
}
|
|
255
|
+
onHoverOut?.(e);
|
|
256
|
+
onMouseLeave?.(e);
|
|
257
|
+
} : void 0
|
|
258
|
+
},
|
|
259
|
+
onMouseDown: attachPress ? (e) => {
|
|
260
|
+
set({
|
|
261
|
+
press: true,
|
|
262
|
+
pressIn: true
|
|
263
|
+
});
|
|
264
|
+
onPressIn?.(e);
|
|
265
|
+
onMouseDown?.(e);
|
|
266
|
+
} : onPressIn,
|
|
267
|
+
onClick: attachPress ? (e) => {
|
|
268
|
+
onPress?.(e);
|
|
269
|
+
onClick?.(e);
|
|
270
|
+
unPress();
|
|
271
|
+
onPressOut?.(e);
|
|
272
|
+
} : onPressOut
|
|
273
|
+
} : null;
|
|
274
|
+
if (events) {
|
|
275
|
+
if (typeof ViewComponent !== "string") {
|
|
276
|
+
const [pressProps] = usePressable({
|
|
277
|
+
disabled,
|
|
278
|
+
hitSlop,
|
|
279
|
+
onPressIn: events.onMouseDown,
|
|
280
|
+
onPressOut: events.onPressOut,
|
|
281
|
+
onPress: events.onClick
|
|
282
|
+
});
|
|
283
|
+
Object.assign(viewProps, pressProps);
|
|
284
|
+
} else {
|
|
285
|
+
Object.assign(viewProps, events);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
const childEls = spacedChildren({
|
|
289
|
+
children,
|
|
290
|
+
space,
|
|
291
|
+
flexDirection: props.flexDirection || defaultProps?.flexDirection,
|
|
292
|
+
isZStack
|
|
293
|
+
});
|
|
294
|
+
let content;
|
|
295
|
+
if (isWeb && rnw) {
|
|
296
|
+
const domProps = rnw.createDOMProps(viewProps);
|
|
297
|
+
const className = domProps.className && domProps.className !== viewProps.className ? `${domProps.className} ${viewProps.className}` : viewProps.className;
|
|
298
|
+
Object.assign(viewProps, domProps);
|
|
299
|
+
viewProps.className = className;
|
|
300
|
+
content = createElement(ViewComponent, viewProps, childEls);
|
|
301
|
+
} else {
|
|
302
|
+
content = createElement(ViewComponent, viewProps, childEls);
|
|
303
|
+
}
|
|
304
|
+
const shouldWrapTextAncestor = isWeb && isText && !hasTextAncestor;
|
|
305
|
+
if (shouldWrapTextAncestor) {
|
|
306
|
+
content = createElement(TextAncestorContext.Provider, { value: true }, content);
|
|
307
|
+
}
|
|
308
|
+
if (process.env.NODE_ENV === "development") {
|
|
309
|
+
if (props["debug"]) {
|
|
310
|
+
viewProps["debug"] = true;
|
|
311
|
+
console.log("\u{1F95A} props in:", props);
|
|
312
|
+
console.log("\u{1F95A} props out:", viewProps);
|
|
313
|
+
console.log(props.onClick?.toString());
|
|
314
|
+
console.log("\u{1F95A} etc:", { shouldAttach, ViewComponent, viewProps, styles, pseudos, content, childEls });
|
|
315
|
+
if (isWeb) {
|
|
316
|
+
console.log("\u{1F95A} component info", { staticConfig, tamaguiConfig });
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, features, content);
|
|
321
|
+
});
|
|
322
|
+
onConfiguredOnce((conf) => {
|
|
323
|
+
tamaguiConfig = conf;
|
|
324
|
+
initialTheme = conf.themes[conf.defaultTheme || Object.keys(conf.themes)[0]];
|
|
325
|
+
const next = getSplitStyles(staticConfig.defaultProps, staticConfig, initialTheme, true);
|
|
326
|
+
if (isWeb) {
|
|
327
|
+
if (next.classNames) {
|
|
328
|
+
defaultsClassName += next.classNames + " ";
|
|
329
|
+
}
|
|
330
|
+
defaultsClassName += addStylesUsingClassname([next.style, next.pseudos]);
|
|
331
|
+
} else {
|
|
332
|
+
if (!hasWarnedOnce) {
|
|
333
|
+
hasWarnedOnce = true;
|
|
334
|
+
console.log("\u26A0\uFE0F we need to account for default styles for media queries");
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
component.defaultProps = {
|
|
338
|
+
...next.viewProps,
|
|
339
|
+
...component.defaultProps
|
|
340
|
+
};
|
|
341
|
+
if (process.env.NODE_ENV === "development") {
|
|
342
|
+
if (staticConfig.defaultProps?.debug) {
|
|
343
|
+
console.log("tamagui debug component:", next, defaultsClassName, component.defaultProps);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
component["staticConfig"] = {
|
|
348
|
+
validStyles: validStyleProps,
|
|
349
|
+
...staticConfig
|
|
350
|
+
};
|
|
351
|
+
const res = component;
|
|
352
|
+
res["extractable"] = (Component2) => {
|
|
353
|
+
Component2["staticConfig"] = extendStaticConfig(res, {
|
|
354
|
+
neverFlatten: true,
|
|
355
|
+
defaultProps: Component2.defaultProps
|
|
356
|
+
});
|
|
357
|
+
return Component2;
|
|
358
|
+
};
|
|
359
|
+
return res;
|
|
360
|
+
}
|
|
361
|
+
__name(createComponent, "createComponent");
|
|
362
|
+
let hasWarnedOnce = false;
|
|
363
|
+
const Spacer = createComponent({
|
|
364
|
+
defaultProps: {
|
|
365
|
+
...stackDefaultStyles,
|
|
366
|
+
size: true
|
|
367
|
+
},
|
|
368
|
+
variants: {
|
|
369
|
+
size: {
|
|
370
|
+
"...size": (size, { tokens }) => {
|
|
371
|
+
size = size == true ? "$true" : size;
|
|
372
|
+
return {
|
|
373
|
+
width: tokens.size[size] ?? size,
|
|
374
|
+
height: tokens.size[size] ?? size
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
direction: {
|
|
379
|
+
horizontal: {
|
|
380
|
+
height: 0
|
|
381
|
+
},
|
|
382
|
+
vertical: {
|
|
383
|
+
width: 0
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
function spacedChildren({
|
|
389
|
+
isZStack,
|
|
390
|
+
children,
|
|
391
|
+
space,
|
|
392
|
+
flexDirection
|
|
393
|
+
}) {
|
|
394
|
+
if (!space && !isZStack) {
|
|
395
|
+
return children;
|
|
396
|
+
}
|
|
397
|
+
const childrenList = Children.toArray(children);
|
|
398
|
+
const len = childrenList.length;
|
|
399
|
+
if (len === 1) {
|
|
400
|
+
return children;
|
|
401
|
+
}
|
|
402
|
+
const next = [];
|
|
403
|
+
for (const [index, child] of childrenList.entries()) {
|
|
404
|
+
if (child === null || child === void 0) {
|
|
405
|
+
continue;
|
|
406
|
+
}
|
|
407
|
+
const key = `${child?.["key"] ?? index}`;
|
|
408
|
+
next.push(/* @__PURE__ */ React.createElement(Fragment, {
|
|
409
|
+
key
|
|
410
|
+
}, isZStack ? /* @__PURE__ */ React.createElement(Absolute, null, child) : child));
|
|
411
|
+
if (child?.["type"]?.["isVisuallyHidden"]) {
|
|
412
|
+
continue;
|
|
413
|
+
}
|
|
414
|
+
if (index !== len - 1) {
|
|
415
|
+
if (space) {
|
|
416
|
+
next.push(/* @__PURE__ */ React.createElement(Spacer, {
|
|
417
|
+
key: `${key}_spacer`,
|
|
418
|
+
direction: flexDirection === "row" || flexDirection === "row-reverse" ? "horizontal" : "vertical",
|
|
419
|
+
size: space
|
|
420
|
+
}));
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
return next;
|
|
425
|
+
}
|
|
426
|
+
__name(spacedChildren, "spacedChildren");
|
|
427
|
+
const Absolute = /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ React.createElement(View, {
|
|
428
|
+
style: sheet.fullscreen
|
|
429
|
+
}, children), "Absolute");
|
|
430
|
+
const sheet = StyleSheet.create({
|
|
431
|
+
fullscreen: {
|
|
432
|
+
position: "absolute",
|
|
433
|
+
top: 0,
|
|
434
|
+
left: 0,
|
|
435
|
+
right: 0,
|
|
436
|
+
bottom: 0
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
export {
|
|
440
|
+
Spacer,
|
|
441
|
+
createComponent,
|
|
442
|
+
mouseUps,
|
|
443
|
+
spacedChildren
|
|
444
|
+
};
|
|
445
|
+
//# sourceMappingURL=createComponent.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/createComponent.tsx"],
|
|
4
|
+
"sourcesContent": ["import { concatClassName, stylePropsView } from '@tamagui/helpers'\nimport React, {\n Children,\n Fragment,\n createElement,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from 'react'\nimport { StyleSheet, Text, View, ViewStyle } from 'react-native'\n\nimport { stackDefaultStyles } from './constants/constants'\nimport { isTouchDevice, isWeb } from './constants/platform'\nimport { rnw } from './constants/rnw'\nimport { onConfiguredOnce } from './createTamagui'\nimport { addStylesUsingClassname, useStylesAsClassname } from './helpers/addStylesUsingClassname'\nimport { extendStaticConfig, parseStaticConfig } from './helpers/extendStaticConfig'\nimport { getSplitStyles } from './helpers/getSplitStyles'\nimport { useFeatures } from './hooks/useFeatures'\nimport { useForceUpdate } from './hooks/useForceUpdate'\nimport { usePressable } from './hooks/usePressable'\nimport {\n SpaceTokens,\n StaticComponent,\n StaticConfig,\n StaticConfigParsed,\n TamaguiInternalConfig,\n} from './types'\nimport { TextAncestorContext } from './views/TextAncestorContext'\nimport { ThemeManagerContext } from './views/ThemeManagerContext'\n\nexport const mouseUps = new Set<Function>()\n\nif (typeof document !== 'undefined') {\n document.addEventListener('mouseup', () => {\n mouseUps.forEach((x) => x())\n mouseUps.clear()\n })\n}\n\ntype DefaultProps = {}\n\nexport function createComponent<A extends Object = DefaultProps>(\n configIn: Partial<StaticConfig> | StaticConfigParsed\n) {\n let staticConfig: StaticConfigParsed\n if ('parsed' in configIn) {\n staticConfig = configIn\n } else {\n staticConfig = parseStaticConfig(configIn)\n }\n\n const { Component, validStyles, isText, isZStack } = staticConfig\n const validStyleProps = validStyles ?? stylePropsView\n\n // split out default styles vs props so we can assign it to component.defaultProps\n let defaultProps = null as any\n let tamaguiConfig: TamaguiInternalConfig\n\n // web uses className, native uses style\n let defaultsStyle: any\n let defaultsClassName = ''\n let initialTheme: any\n\n // see onConfiguredOnce below which attaches a name then to this component\n\n const component = forwardRef<View, A>((props: any, forwardedRef) => {\n const {\n tag,\n hitSlop,\n children,\n pointerEvents,\n onPress,\n onPressIn,\n onPressOut,\n onHoverIn,\n onHoverOut,\n space,\n disabled,\n onMouseEnter,\n onMouseLeave,\n hrefAttrs,\n onMoveShouldSetResponder,\n onMoveShouldSetResponderCapture,\n onResponderEnd,\n onResponderGrant,\n onResponderMove,\n onResponderReject,\n onResponderRelease,\n onResponderStart,\n onResponderTerminate,\n onResponderTerminationRequest,\n onScrollShouldSetResponder,\n onScrollShouldSetResponderCapture,\n onSelectionChangeShouldSetResponder,\n onSelectionChangeShouldSetResponderCapture,\n onStartShouldSetResponder,\n onStartShouldSetResponderCapture,\n onMouseDown,\n onClick,\n // TODO feature load layou hook\n onLayout,\n } = props\n\n const forceUpdate = useForceUpdate()\n const features = useFeatures(props, { forceUpdate })\n const manager = useContext(ThemeManagerContext)\n const [state, set_] = useState(() => ({\n hover: false,\n press: false,\n pressIn: false,\n theme: manager.name,\n }))\n const set = (next: Partial<typeof state>) =>\n set_((prev) => {\n for (const key in next) {\n if (prev[key] !== next[key]) {\n return { ...prev, ...next }\n }\n }\n return prev\n })\n\n // from react-native-web\n if (process.env.NODE_ENV === 'development' && !isText && isWeb) {\n Children.toArray(props.children).forEach((item) => {\n if (typeof item === 'string') {\n console.error(`Unexpected text node: ${item}. A text node cannot be a child of a <View>.`)\n }\n })\n }\n\n const hasTextAncestor = isWeb ? useContext(TextAncestorContext) : false\n const hostRef = useRef(null)\n\n if (isWeb) {\n // from react-native-web\n rnw.useResponderEvents(hostRef, {\n onMoveShouldSetResponder,\n onMoveShouldSetResponderCapture,\n onResponderEnd,\n onResponderGrant,\n onResponderMove,\n onResponderReject,\n onResponderRelease,\n onResponderStart,\n onResponderTerminate,\n onResponderTerminationRequest,\n onScrollShouldSetResponder,\n onScrollShouldSetResponderCapture,\n onSelectionChangeShouldSetResponder,\n onSelectionChangeShouldSetResponderCapture,\n onStartShouldSetResponder,\n onStartShouldSetResponderCapture,\n })\n }\n\n const isTracking = useRef(false)\n\n const { viewProps, pseudos, style, classNames } = getSplitStyles(\n props,\n staticConfig,\n (manager.theme as any) || initialTheme\n )\n\n // hasEverHadEvents prevents repareting if you remove onPress or similar...\n const internal = useRef<{ isMounted: boolean; hasEverHadEvents?: boolean }>()\n if (!internal.current) {\n internal.current = {\n isMounted: true,\n }\n }\n\n useEffect(() => {\n internal.current!.isMounted = true\n const dispose = manager?.onChangeTheme((name) => {\n if (isTracking.current) {\n set({ theme: name })\n }\n })\n return () => {\n dispose()\n mouseUps.delete(unPress)\n isTracking.current = false\n internal.current!.isMounted = false\n }\n }, [manager])\n\n // element\n const element = isWeb\n ? !Component || typeof Component === 'string'\n ? // default to tag, fallback to component (when both strings)\n tag || Component\n : Component\n : Component\n const ReactView = !isWeb ? View : element || (hasTextAncestor ? 'span' : 'div')\n const ReactText = !isWeb ? Text : element || 'span'\n const ViewComponent = isText ? ReactText : ReactView\n\n // styles\n const isHovering = !isTouchDevice && !disabled && pseudos && state.hover\n const isPressing = !disabled && pseudos && state.press\n\n const styles = [\n // parity w react-native-web, only for text in text\n // TODO this should be able to be done w css to replicate after extraction:\n // (.text .text { display: inline-flex; }) (but if they set display we'd need stronger precendence)\n // isText && hasTextAncestor && isWeb ? { display: 'inline-flex' } : null,\n style,\n isHovering ? pseudos.hoverStyle || null : null,\n isPressing ? pseudos.pressStyle || null : null,\n ]\n\n if (isWeb) {\n const stylesClassNames = useStylesAsClassname(styles)\n const classList = isText\n ? [\n defaultsClassName,\n // hasTextAncestor === true && cssText.textHasAncestor,\n // TODO MOVE TO VARIANTS [number] [any]\n // numberOfLines != null && numberOfLines > 1 && cssText.textMultiLine,\n classNames,\n stylesClassNames,\n props.className,\n ]\n : [defaultsClassName, props.className, classNames, stylesClassNames]\n\n const className = concatClassName(...classList)\n if (process.env.NODE_ENV === 'development') {\n if (props['debug']) {\n // prettier-ignore\n console.log('\uD83E\uDD5A className', { style, styles, classList, stylesClassNames, className })\n }\n }\n viewProps.className = className\n } else {\n viewProps.style = styles\n }\n\n if (pointerEvents) {\n viewProps.pointerEvents = pointerEvents\n }\n\n if (isWeb) {\n // from react-native-web\n const platformMethodsRef = rnw.usePlatformMethods(viewProps)\n const setRef = rnw.useMergeRefs(hostRef, platformMethodsRef, forwardedRef)\n viewProps.ref = setRef\n if (props.href != null && hrefAttrs != null) {\n const { download, rel, target } = hrefAttrs\n if (download != null) {\n viewProps.download = download\n }\n if (rel != null) {\n viewProps.rel = rel\n }\n if (typeof target === 'string') {\n viewProps.target = target.charAt(0) !== '_' ? '_' + target : target\n }\n }\n } else {\n if (forwardedRef) {\n viewProps.ref = forwardedRef\n }\n }\n\n const attachPress = !!(\n (pseudos && pseudos.pressStyle) ||\n onPress ||\n onPressOut ||\n onPressIn ||\n onClick\n )\n const attachHover =\n isWeb &&\n !isTouchDevice &&\n !!((pseudos && pseudos.hoverStyle) || onHoverIn || onHoverOut || onMouseEnter || onMouseLeave)\n\n // check presence to prevent reparenting bugs, allows for onPress={x ? function : undefined} usage\n // while avoiding reparenting...\n // once proper reparenting is supported, we can remove this and use that...\n const shouldAttach =\n internal.current.hasEverHadEvents ||\n attachPress ||\n attachHover ||\n 'pressStyle' in props ||\n 'onPress' in props ||\n 'onPressIn' in props ||\n 'onPressOut' in props ||\n (isWeb &&\n ('hoverStyle' in props ||\n 'onClick' in props ||\n 'onHoverIn' in props ||\n 'onHoverOut' in props ||\n 'onMouseEnter' in props ||\n 'onMouseLeave' in props))\n\n // never remove events as we wrap in a div (for now, may be able to remove..)\n if (shouldAttach) {\n internal.current.hasEverHadEvents = true\n }\n\n const unPress = useCallback(() => {\n if (!internal.current!.isMounted) return\n set({\n press: false,\n pressIn: false,\n })\n }, [])\n\n const events = shouldAttach\n ? {\n ...(!isWeb && {\n // non web\n onPressOut: (e) => {\n unPress()\n onPressOut?.(e)\n },\n }),\n ...(isWeb &&\n !isTouchDevice && {\n onMouseEnter:\n attachHover || attachPress\n ? (e) => {\n let next: Partial<typeof state> = {}\n if (attachHover) {\n next.hover = true\n }\n if (state.pressIn) {\n next.press = true\n }\n if (Object.keys(next).length) {\n set(next)\n }\n onHoverIn?.(e)\n onMouseEnter?.(e)\n }\n : undefined,\n onMouseLeave:\n attachHover || attachPress\n ? (e) => {\n let next: Partial<typeof state> = {}\n mouseUps.add(unPress)\n if (attachHover) {\n next.hover = false\n }\n if (state.pressIn) {\n next.press = false\n next.pressIn = false\n }\n if (Object.keys(next).length) {\n set(next)\n }\n onHoverOut?.(e)\n onMouseLeave?.(e)\n }\n : undefined,\n }),\n onMouseDown: attachPress\n ? (e) => {\n set({\n press: true,\n pressIn: true,\n })\n onPressIn?.(e)\n onMouseDown?.(e)\n }\n : (onPressIn as any),\n onClick: attachPress\n ? (e) => {\n // this caused issue with next.js passing href\n // e.preventDefault()\n onPress?.(e)\n onClick?.(e)\n unPress()\n onPressOut?.(e)\n }\n : (onPressOut as any),\n }\n : null\n\n if (events) {\n if (typeof ViewComponent !== 'string') {\n // TODO once we do the above we can then rely entirely on pressStyle returned here isntead of above pressStyle logic\n const [pressProps] = usePressable({\n disabled,\n hitSlop,\n onPressIn: events.onMouseDown,\n onPressOut: events.onPressOut,\n onPress: events.onClick,\n })\n Object.assign(viewProps, pressProps)\n } else {\n Object.assign(viewProps, events)\n }\n }\n\n const childEls = spacedChildren({\n children,\n space,\n flexDirection: props.flexDirection || defaultProps?.flexDirection,\n isZStack: isZStack,\n })\n\n let content: any\n\n // replicate react-native-web's `createElement`\n if (isWeb && rnw) {\n const domProps = rnw.createDOMProps(viewProps)\n const className =\n domProps.className && domProps.className !== viewProps.className\n ? `${domProps.className} ${viewProps.className}`\n : viewProps.className\n Object.assign(viewProps, domProps)\n viewProps.className = className\n content = createElement(ViewComponent, viewProps, childEls)\n } else {\n content = createElement(ViewComponent, viewProps, childEls)\n }\n\n const shouldWrapTextAncestor = isWeb && isText && !hasTextAncestor\n if (shouldWrapTextAncestor) {\n // from react-native-web\n // @ts-ignore\n content = createElement(TextAncestorContext.Provider, { value: true }, content)\n }\n\n if (process.env.NODE_ENV === 'development') {\n if (props['debug']) {\n viewProps['debug'] = true\n console.log('\uD83E\uDD5A props in:', props)\n console.log('\uD83E\uDD5A props out:', viewProps)\n console.log(props.onClick?.toString())\n // prettier-ignore\n console.log('\uD83E\uDD5A etc:', { shouldAttach, ViewComponent, viewProps, styles, pseudos, content, childEls })\n // only on browser because node expands it huge\n if (isWeb) {\n console.log('\uD83E\uDD5A component info', { staticConfig, tamaguiConfig })\n }\n }\n }\n\n return (\n <>\n {features}\n {content}\n </>\n )\n })\n\n // Once configuration is run and all components are registered\n // get default props + className and analyze styles\n onConfiguredOnce((conf) => {\n tamaguiConfig = conf\n initialTheme = conf.themes[conf.defaultTheme || Object.keys(conf.themes)[0]]\n const next = getSplitStyles(staticConfig.defaultProps, staticConfig, initialTheme, true)\n if (isWeb) {\n if (next.classNames) {\n defaultsClassName += next.classNames + ' '\n }\n defaultsClassName += addStylesUsingClassname([next.style, next.pseudos])\n } else {\n if (!hasWarnedOnce) {\n hasWarnedOnce = true\n console.log('\u26A0\uFE0F we need to account for default styles for media queries')\n }\n }\n // @ts-ignore\n component.defaultProps = {\n ...next.viewProps,\n ...component.defaultProps,\n }\n if (process.env.NODE_ENV === 'development') {\n if (staticConfig.defaultProps?.debug) {\n console.log('tamagui debug component:', next, defaultsClassName, component.defaultProps)\n }\n }\n })\n\n component['staticConfig'] = {\n validStyles: validStyleProps,\n ...staticConfig,\n }\n\n const res = component as any as StaticComponent<A, void>\n\n // add extractable HoC\n res['extractable'] = (Component: any) => {\n Component['staticConfig'] = extendStaticConfig(res, {\n neverFlatten: true,\n defaultProps: Component.defaultProps,\n })\n return Component\n }\n\n return res\n}\n\nlet hasWarnedOnce = false\n\n// dont used styled() here to avoid circular deps\n// keep inline to avoid circular deps\n\nexport const Spacer = createComponent<{ size?: number | SpaceTokens; flex?: boolean | number }>({\n defaultProps: {\n ...stackDefaultStyles,\n size: true,\n },\n variants: {\n size: {\n '...size': (size, { tokens }) => {\n size = size == true ? '$true' : size\n return {\n width: tokens.size[size] ?? size,\n height: tokens.size[size] ?? size,\n }\n },\n },\n\n direction: {\n horizontal: {\n height: 0,\n },\n vertical: {\n width: 0,\n },\n },\n },\n})\n\nexport function spacedChildren({\n isZStack,\n children,\n space,\n flexDirection,\n}: {\n isZStack?: boolean\n children: any\n space?: any\n flexDirection?: ViewStyle['flexDirection']\n}) {\n if (!space && !isZStack) {\n return children\n }\n const childrenList = Children.toArray(children)\n const len = childrenList.length\n if (len === 1) {\n return children\n }\n const next: any[] = []\n for (const [index, child] of childrenList.entries()) {\n if (child === null || child === undefined) {\n continue\n }\n\n const key = `${child?.['key'] ?? index}`\n\n next.push(<Fragment key={key}>{isZStack ? <Absolute>{child}</Absolute> : child}</Fragment>)\n\n // allows for custom visually hidden components that dont insert spacing\n if (child?.['type']?.['isVisuallyHidden']) {\n continue\n }\n\n if (index !== len - 1) {\n if (space) {\n next.push(\n <Spacer\n key={`${key}_spacer`}\n // @ts-ignore TODO\n direction={\n flexDirection === 'row' || flexDirection === 'row-reverse' ? 'horizontal' : 'vertical'\n }\n size={space}\n />\n )\n }\n }\n }\n return next\n}\n\n// for now not so \"tamagui-y\"\nconst Absolute = ({ children }) => <View style={sheet.fullscreen}>{children}</View>\nconst sheet = StyleSheet.create({\n fullscreen: {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n },\n})\n"],
|
|
5
|
+
"mappings": ";;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAQA;AACA;AAEO,MAAM,WAAW,IAAI;AAE5B,IAAI,OAAO,aAAa,aAAa;AACnC,WAAS,iBAAiB,WAAW,MAAM;AACzC,aAAS,QAAQ,CAAC,MAAM;AACxB,aAAS;AAAA;AAAA;AAMN,yBACL,UACA;AACA,MAAI;AACJ,MAAI,YAAY,UAAU;AACxB,mBAAe;AAAA,SACV;AACL,mBAAe,kBAAkB;AAAA;AAGnC,QAAM,EAAE,WAAW,aAAa,QAAQ,aAAa;AACrD,QAAM,kBAAkB,eAAe;AAGvC,MAAI,eAAe;AACnB,MAAI;AAGJ,MAAI;AACJ,MAAI,oBAAoB;AACxB,MAAI;AAIJ,QAAM,YAAY,WAAoB,CAAC,OAAY,i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,kBAAkB,SAAS,kBAAkB,gBAAgB,eAAe;AAAA,UAE9E,MAAM;AAAA;AAAA;AAAA;AAAA;AAMhB,SAAO;AAAA;AAjDO;AAqDhB,MAAM,WAAW,wBAAC,EAAE,eAAe,oCAAC,MAAD;AAAA,EAAM,OAAO,MAAM;AAAA,GAAa,WAAlD;AACjB,MAAM,QAAQ,WAAW,OAAO;AAAA,EAC9B,YAAY;AAAA,IACV,UAAU;AAAA,IACV,KAAK;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,IACP,QAAQ;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
const createFont = /* @__PURE__ */ __name((font) => {
|
|
4
|
+
const sizeKeys = Object.keys(font.size);
|
|
5
|
+
for (const key in font) {
|
|
6
|
+
if (key === "size" || key === "family")
|
|
7
|
+
continue;
|
|
8
|
+
const section = font[key];
|
|
9
|
+
const keys = Object.keys(section);
|
|
10
|
+
let fillVal = section[keys[0]];
|
|
11
|
+
for (const sKey of sizeKeys) {
|
|
12
|
+
if (!(sKey in section)) {
|
|
13
|
+
section[sKey] = fillVal;
|
|
14
|
+
} else {
|
|
15
|
+
fillVal = section[sKey];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return Object.freeze(font);
|
|
20
|
+
}, "createFont");
|
|
21
|
+
export {
|
|
22
|
+
createFont
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=createFont.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/createFont.ts"],
|
|
4
|
+
"sourcesContent": ["import { GenericFont } from './types'\n\nexport const createFont = <A extends GenericFont>(font: A): A => {\n // fills in any missing values based on size keys being standard\n const sizeKeys = Object.keys(font.size)\n\n for (const key in font) {\n if (key === 'size' || key === 'family') continue\n const section = font[key]\n const keys = Object.keys(section)\n\n // fill with first filled in value to start\n let fillVal = section[keys[0]]\n\n for (const sKey of sizeKeys) {\n if (!(sKey in section)) {\n section[sKey] = fillVal\n } else {\n // if exists, set as the fillVal\n fillVal = section[sKey]\n }\n }\n }\n\n return Object.freeze(font)\n}\n"],
|
|
5
|
+
"mappings": ";;AAEO,MAAM,aAAa,wBAAwB,SAAe;AAE/D,QAAM,WAAW,OAAO,KAAK,KAAK;AAElC,aAAW,OAAO,MAAM;AACtB,QAAI,QAAQ,UAAU,QAAQ;AAAU;AACxC,UAAM,UAAU,KAAK;AACrB,UAAM,OAAO,OAAO,KAAK;AAGzB,QAAI,UAAU,QAAQ,KAAK;AAE3B,eAAW,QAAQ,UAAU;AAC3B,UAAI,CAAE,SAAQ,UAAU;AACtB,gBAAQ,QAAQ;AAAA,aACX;AAEL,kBAAU,QAAQ;AAAA;AAAA;AAAA;AAKxB,SAAO,OAAO,OAAO;AAAA,GAtBG;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
function createShorthands(shorthands) {
|
|
4
|
+
return Object.freeze(shorthands);
|
|
5
|
+
}
|
|
6
|
+
__name(createShorthands, "createShorthands");
|
|
7
|
+
export {
|
|
8
|
+
createShorthands
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=createShorthands.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/createShorthands.ts"],
|
|
4
|
+
"sourcesContent": ["// type helper\n\nexport function createShorthands<A extends Record<string, string>>(shorthands: A): A {\n return Object.freeze(shorthands) as any\n}\n"],
|
|
5
|
+
"mappings": ";;AAEO,0BAA4D,YAAkB;AACnF,SAAO,OAAO,OAAO;AAAA;AADP;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|