@tamagui/core 1.2.3 → 1.2.5
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/README.md +4 -0
- package/dist/cjs/hooks/usePlatformMethods.js +48 -0
- package/dist/cjs/hooks/usePlatformMethods.js.map +7 -0
- package/dist/cjs/index.js +152 -75
- package/dist/cjs/index.js.map +3 -3
- package/dist/cjs/{types.js → reactNativeTypes.js} +3 -3
- package/dist/cjs/reactNativeTypes.js.map +7 -0
- package/dist/esm/hooks/usePlatformMethods.js +24 -0
- package/dist/esm/hooks/usePlatformMethods.js.map +7 -0
- package/dist/esm/index.js +157 -71
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/reactNativeTypes.js +1 -0
- package/dist/esm/{types-rnw.js.map → reactNativeTypes.js.map} +0 -0
- package/package.json +5 -11
- package/src/hooks/usePlatformMethods.ts +26 -0
- package/src/index.ts +214 -71
- package/src/reactNativeTypes.ts +104 -0
- package/types/hooks/usePlatformMethods.d.ts +3 -0
- package/types/hooks/usePlatformMethods.d.ts.map +1 -0
- package/types/index.d.ts +6 -54
- package/types/index.d.ts.map +1 -1
- package/types/reactNativeTypes.d.ts +26 -0
- package/types/reactNativeTypes.d.ts.map +1 -0
- package/dist/cjs/Tamagui.js +0 -77
- package/dist/cjs/Tamagui.js.map +0 -7
- package/dist/cjs/addTheme.js +0 -78
- package/dist/cjs/addTheme.js.map +0 -7
- package/dist/cjs/config.js +0 -91
- package/dist/cjs/config.js.map +0 -7
- package/dist/cjs/constants/constants.js +0 -49
- package/dist/cjs/constants/constants.js.map +0 -7
- package/dist/cjs/constants/isDevTools.js +0 -37
- package/dist/cjs/constants/isDevTools.js.map +0 -7
- package/dist/cjs/contexts/ButtonNestingContext.js +0 -30
- package/dist/cjs/contexts/ButtonNestingContext.js.map +0 -7
- package/dist/cjs/contexts/FontLanguageContext.js +0 -30
- package/dist/cjs/contexts/FontLanguageContext.js.map +0 -7
- package/dist/cjs/contexts/TextAncestorContext.js +0 -30
- package/dist/cjs/contexts/TextAncestorContext.js.map +0 -7
- package/dist/cjs/createComponent.js +0 -993
- package/dist/cjs/createComponent.js.map +0 -7
- package/dist/cjs/createFont.js +0 -69
- package/dist/cjs/createFont.js.map +0 -7
- package/dist/cjs/createFont.web.test.js +0 -125
- package/dist/cjs/createFont.web.test.js.map +0 -7
- package/dist/cjs/createShorthands.js +0 -31
- package/dist/cjs/createShorthands.js.map +0 -7
- package/dist/cjs/createTamagui.js +0 -206
- package/dist/cjs/createTamagui.js.map +0 -7
- package/dist/cjs/createTheme.js +0 -31
- package/dist/cjs/createTheme.js.map +0 -7
- package/dist/cjs/createTokens.js +0 -39
- package/dist/cjs/createTokens.js.map +0 -7
- package/dist/cjs/createTokens.web.test.js +0 -28
- package/dist/cjs/createTokens.web.test.js.map +0 -7
- package/dist/cjs/createVariable.js +0 -111
- package/dist/cjs/createVariable.js.map +0 -7
- package/dist/cjs/createVariable.web.test.js +0 -7
- package/dist/cjs/createVariable.web.test.js.map +0 -7
- package/dist/cjs/createVariables.js +0 -60
- package/dist/cjs/createVariables.js.map +0 -7
- package/dist/cjs/helpers/RNComponents.js +0 -40
- package/dist/cjs/helpers/RNComponents.js.map +0 -7
- package/dist/cjs/helpers/ThemeManager.js +0 -234
- package/dist/cjs/helpers/ThemeManager.js.map +0 -7
- package/dist/cjs/helpers/ThemeManager.test.js +0 -465
- package/dist/cjs/helpers/ThemeManager.test.js.map +0 -7
- package/dist/cjs/helpers/ThemeManagerContext.js +0 -30
- package/dist/cjs/helpers/ThemeManagerContext.js.map +0 -7
- package/dist/cjs/helpers/createMediaStyle.js +0 -67
- package/dist/cjs/helpers/createMediaStyle.js.map +0 -7
- package/dist/cjs/helpers/createPropMapper.js +0 -411
- package/dist/cjs/helpers/createPropMapper.js.map +0 -7
- package/dist/cjs/helpers/createProxy.js +0 -43
- package/dist/cjs/helpers/createProxy.js.map +0 -7
- package/dist/cjs/helpers/expandStyle.js +0 -95
- package/dist/cjs/helpers/expandStyle.js.map +0 -7
- package/dist/cjs/helpers/expandStyles.js +0 -116
- package/dist/cjs/helpers/expandStyles.js.map +0 -7
- package/dist/cjs/helpers/extendStaticConfig.js +0 -91
- package/dist/cjs/helpers/extendStaticConfig.js.map +0 -7
- package/dist/cjs/helpers/fixNativeShadow.js +0 -30
- package/dist/cjs/helpers/fixNativeShadow.js.map +0 -7
- package/dist/cjs/helpers/getAnimationDriver.js +0 -32
- package/dist/cjs/helpers/getAnimationDriver.js.map +0 -7
- package/dist/cjs/helpers/getExpandedShorthands.js +0 -40
- package/dist/cjs/helpers/getExpandedShorthands.js.map +0 -7
- package/dist/cjs/helpers/getFontLanguage.js +0 -29
- package/dist/cjs/helpers/getFontLanguage.js.map +0 -7
- package/dist/cjs/helpers/getSplitStyles.js +0 -848
- package/dist/cjs/helpers/getSplitStyles.js.map +0 -7
- package/dist/cjs/helpers/getStylesAtomic.js +0 -226
- package/dist/cjs/helpers/getStylesAtomic.js.map +0 -7
- package/dist/cjs/helpers/getStylesAtomic.native.js +0 -38
- package/dist/cjs/helpers/getStylesAtomic.native.js.map +0 -7
- package/dist/cjs/helpers/getThemeCSSRules.js +0 -110
- package/dist/cjs/helpers/getThemeCSSRules.js.map +0 -7
- package/dist/cjs/helpers/getThemeCSSRules.native.js +0 -31
- package/dist/cjs/helpers/getThemeCSSRules.native.js.map +0 -7
- package/dist/cjs/helpers/getVariantExtras.js +0 -92
- package/dist/cjs/helpers/getVariantExtras.js.map +0 -7
- package/dist/cjs/helpers/insertStyleRule.js +0 -218
- package/dist/cjs/helpers/insertStyleRule.js.map +0 -7
- package/dist/cjs/helpers/isObj.js +0 -29
- package/dist/cjs/helpers/isObj.js.map +0 -7
- package/dist/cjs/helpers/isTamaguiComponent.js +0 -32
- package/dist/cjs/helpers/isTamaguiComponent.js.map +0 -7
- package/dist/cjs/helpers/isTamaguiElement.js +0 -33
- package/dist/cjs/helpers/isTamaguiElement.js.map +0 -7
- package/dist/cjs/helpers/matchMedia.js +0 -42
- package/dist/cjs/helpers/matchMedia.js.map +0 -7
- package/dist/cjs/helpers/matchMedia.native.js +0 -48
- package/dist/cjs/helpers/matchMedia.native.js.map +0 -7
- package/dist/cjs/helpers/mergeProps.js +0 -54
- package/dist/cjs/helpers/mergeProps.js.map +0 -7
- package/dist/cjs/helpers/mergeTransform.js +0 -47
- package/dist/cjs/helpers/mergeTransform.js.map +0 -7
- package/dist/cjs/helpers/normalizeColor.js +0 -71
- package/dist/cjs/helpers/normalizeColor.js.map +0 -7
- package/dist/cjs/helpers/normalizeValueWithProperty.js +0 -138
- package/dist/cjs/helpers/normalizeValueWithProperty.js.map +0 -7
- package/dist/cjs/helpers/proxyThemeVariables.js +0 -40
- package/dist/cjs/helpers/proxyThemeVariables.js.map +0 -7
- package/dist/cjs/helpers/pseudoDescriptors.js +0 -53
- package/dist/cjs/helpers/pseudoDescriptors.js.map +0 -7
- package/dist/cjs/helpers/registerCSSVariable.js +0 -40
- package/dist/cjs/helpers/registerCSSVariable.js.map +0 -7
- package/dist/cjs/helpers/themeable.js +0 -62
- package/dist/cjs/helpers/themeable.js.map +0 -7
- package/dist/cjs/helpers/themes.js +0 -78
- package/dist/cjs/helpers/themes.js.map +0 -7
- package/dist/cjs/helpers/timer.js +0 -35
- package/dist/cjs/helpers/timer.js.map +0 -7
- package/dist/cjs/helpers/useShallowSetState.js +0 -59
- package/dist/cjs/helpers/useShallowSetState.js.map +0 -7
- package/dist/cjs/helpers/warnOnce.js +0 -38
- package/dist/cjs/helpers/warnOnce.js.map +0 -7
- package/dist/cjs/helpers/withStaticProperties.js +0 -32
- package/dist/cjs/helpers/withStaticProperties.js.map +0 -7
- package/dist/cjs/hooks/getThemeUnwrapped.js +0 -34
- package/dist/cjs/hooks/getThemeUnwrapped.js.map +0 -7
- package/dist/cjs/hooks/useId.js +0 -29
- package/dist/cjs/hooks/useId.js.map +0 -7
- package/dist/cjs/hooks/useIsTouchDevice.js +0 -33
- package/dist/cjs/hooks/useIsTouchDevice.js.map +0 -7
- package/dist/cjs/hooks/useMedia.js +0 -263
- package/dist/cjs/hooks/useMedia.js.map +0 -7
- package/dist/cjs/hooks/useSafeRef.js +0 -59
- package/dist/cjs/hooks/useSafeRef.js.map +0 -7
- package/dist/cjs/hooks/useServerHooks.js +0 -36
- package/dist/cjs/hooks/useServerHooks.js.map +0 -7
- package/dist/cjs/hooks/useStyle.js +0 -61
- package/dist/cjs/hooks/useStyle.js.map +0 -7
- package/dist/cjs/hooks/useTheme.js +0 -230
- package/dist/cjs/hooks/useTheme.js.map +0 -7
- package/dist/cjs/hooks/useThemeName.js +0 -52
- package/dist/cjs/hooks/useThemeName.js.map +0 -7
- package/dist/cjs/insertFont.js +0 -93
- package/dist/cjs/insertFont.js.map +0 -7
- package/dist/cjs/setupReactNative.js +0 -51
- package/dist/cjs/setupReactNative.js.map +0 -7
- package/dist/cjs/static.js +0 -20
- package/dist/cjs/static.js.map +0 -7
- package/dist/cjs/styled.js +0 -95
- package/dist/cjs/styled.js.map +0 -7
- package/dist/cjs/types-rnw.js +0 -17
- package/dist/cjs/types-rnw.js.map +0 -7
- package/dist/cjs/types.js.map +0 -7
- package/dist/cjs/updateTheme.js +0 -47
- package/dist/cjs/updateTheme.js.map +0 -7
- package/dist/cjs/views/FontLanguage.js +0 -41
- package/dist/cjs/views/FontLanguage.js.map +0 -7
- package/dist/cjs/views/FontLanguage.native.js +0 -35
- package/dist/cjs/views/FontLanguage.native.js.map +0 -7
- package/dist/cjs/views/FontLanguage.types.js +0 -17
- package/dist/cjs/views/FontLanguage.types.js.map +0 -7
- package/dist/cjs/views/Slot.js +0 -92
- package/dist/cjs/views/Slot.js.map +0 -7
- package/dist/cjs/views/Stack.js +0 -38
- package/dist/cjs/views/Stack.js.map +0 -7
- package/dist/cjs/views/Stack.web.test.js +0 -22
- package/dist/cjs/views/Stack.web.test.js.map +0 -7
- package/dist/cjs/views/TamaguiProvider.js +0 -90
- package/dist/cjs/views/TamaguiProvider.js.map +0 -7
- package/dist/cjs/views/Text.js +0 -94
- package/dist/cjs/views/Text.js.map +0 -7
- package/dist/cjs/views/Theme.js +0 -88
- package/dist/cjs/views/Theme.js.map +0 -7
- package/dist/cjs/views/ThemeProvider.js +0 -70
- package/dist/cjs/views/ThemeProvider.js.map +0 -7
- package/dist/esm/Tamagui.js +0 -41
- package/dist/esm/Tamagui.js.map +0 -7
- package/dist/esm/addTheme.js +0 -54
- package/dist/esm/addTheme.js.map +0 -7
- package/dist/esm/config.js +0 -58
- package/dist/esm/config.js.map +0 -7
- package/dist/esm/constants/constants.js +0 -22
- package/dist/esm/constants/constants.js.map +0 -7
- package/dist/esm/constants/isDevTools.js +0 -13
- package/dist/esm/constants/isDevTools.js.map +0 -7
- package/dist/esm/contexts/ButtonNestingContext.js +0 -6
- package/dist/esm/contexts/ButtonNestingContext.js.map +0 -7
- package/dist/esm/contexts/FontLanguageContext.js +0 -6
- package/dist/esm/contexts/FontLanguageContext.js.map +0 -7
- package/dist/esm/contexts/TextAncestorContext.js +0 -6
- package/dist/esm/contexts/TextAncestorContext.js.map +0 -7
- package/dist/esm/createComponent.js +0 -975
- package/dist/esm/createComponent.js.map +0 -7
- package/dist/esm/createFont.js +0 -45
- package/dist/esm/createFont.js.map +0 -7
- package/dist/esm/createFont.web.test.js +0 -124
- package/dist/esm/createFont.web.test.js.map +0 -7
- package/dist/esm/createShorthands.js +0 -7
- package/dist/esm/createShorthands.js.map +0 -7
- package/dist/esm/createTamagui.js +0 -190
- package/dist/esm/createTamagui.js.map +0 -7
- package/dist/esm/createTheme.js +0 -7
- package/dist/esm/createTheme.js.map +0 -7
- package/dist/esm/createTokens.js +0 -15
- package/dist/esm/createTokens.js.map +0 -7
- package/dist/esm/createTokens.web.test.js +0 -27
- package/dist/esm/createTokens.web.test.js.map +0 -7
- package/dist/esm/createVariable.js +0 -78
- package/dist/esm/createVariable.js.map +0 -7
- package/dist/esm/createVariable.web.test.js +0 -6
- package/dist/esm/createVariable.web.test.js.map +0 -7
- package/dist/esm/createVariables.js +0 -35
- package/dist/esm/createVariables.js.map +0 -7
- package/dist/esm/helpers/RNComponents.js +0 -16
- package/dist/esm/helpers/RNComponents.js.map +0 -7
- package/dist/esm/helpers/ThemeManager.js +0 -209
- package/dist/esm/helpers/ThemeManager.js.map +0 -7
- package/dist/esm/helpers/ThemeManager.test.js +0 -464
- package/dist/esm/helpers/ThemeManager.test.js.map +0 -7
- package/dist/esm/helpers/ThemeManagerContext.js +0 -6
- package/dist/esm/helpers/ThemeManagerContext.js.map +0 -7
- package/dist/esm/helpers/createMediaStyle.js +0 -42
- package/dist/esm/helpers/createMediaStyle.js.map +0 -7
- package/dist/esm/helpers/createPropMapper.js +0 -384
- package/dist/esm/helpers/createPropMapper.js.map +0 -7
- package/dist/esm/helpers/createProxy.js +0 -19
- package/dist/esm/helpers/createProxy.js.map +0 -7
- package/dist/esm/helpers/expandStyle.js +0 -71
- package/dist/esm/helpers/expandStyle.js.map +0 -7
- package/dist/esm/helpers/expandStyles.js +0 -90
- package/dist/esm/helpers/expandStyles.js.map +0 -7
- package/dist/esm/helpers/extendStaticConfig.js +0 -66
- package/dist/esm/helpers/extendStaticConfig.js.map +0 -7
- package/dist/esm/helpers/fixNativeShadow.js +0 -6
- package/dist/esm/helpers/fixNativeShadow.js.map +0 -7
- package/dist/esm/helpers/getAnimationDriver.js +0 -8
- package/dist/esm/helpers/getAnimationDriver.js.map +0 -7
- package/dist/esm/helpers/getExpandedShorthands.js +0 -16
- package/dist/esm/helpers/getExpandedShorthands.js.map +0 -7
- package/dist/esm/helpers/getFontLanguage.js +0 -5
- package/dist/esm/helpers/getFontLanguage.js.map +0 -7
- package/dist/esm/helpers/getSplitStyles.js +0 -847
- package/dist/esm/helpers/getSplitStyles.js.map +0 -7
- package/dist/esm/helpers/getStylesAtomic.js +0 -200
- package/dist/esm/helpers/getStylesAtomic.js.map +0 -7
- package/dist/esm/helpers/getStylesAtomic.native.js +0 -12
- package/dist/esm/helpers/getStylesAtomic.native.js.map +0 -7
- package/dist/esm/helpers/getThemeCSSRules.js +0 -86
- package/dist/esm/helpers/getThemeCSSRules.js.map +0 -7
- package/dist/esm/helpers/getThemeCSSRules.native.js +0 -7
- package/dist/esm/helpers/getThemeCSSRules.native.js.map +0 -7
- package/dist/esm/helpers/getVariantExtras.js +0 -67
- package/dist/esm/helpers/getVariantExtras.js.map +0 -7
- package/dist/esm/helpers/insertStyleRule.js +0 -186
- package/dist/esm/helpers/insertStyleRule.js.map +0 -7
- package/dist/esm/helpers/isObj.js +0 -5
- package/dist/esm/helpers/isObj.js.map +0 -7
- package/dist/esm/helpers/isTamaguiComponent.js +0 -8
- package/dist/esm/helpers/isTamaguiComponent.js.map +0 -7
- package/dist/esm/helpers/isTamaguiElement.js +0 -9
- package/dist/esm/helpers/isTamaguiElement.js.map +0 -7
- package/dist/esm/helpers/matchMedia.js +0 -17
- package/dist/esm/helpers/matchMedia.js.map +0 -7
- package/dist/esm/helpers/matchMedia.native.js +0 -23
- package/dist/esm/helpers/matchMedia.native.js.map +0 -7
- package/dist/esm/helpers/mergeProps.js +0 -30
- package/dist/esm/helpers/mergeProps.js.map +0 -7
- package/dist/esm/helpers/mergeTransform.js +0 -21
- package/dist/esm/helpers/mergeTransform.js.map +0 -7
- package/dist/esm/helpers/normalizeColor.js +0 -36
- package/dist/esm/helpers/normalizeColor.js.map +0 -7
- package/dist/esm/helpers/normalizeValueWithProperty.js +0 -113
- package/dist/esm/helpers/normalizeValueWithProperty.js.map +0 -7
- package/dist/esm/helpers/proxyThemeVariables.js +0 -16
- package/dist/esm/helpers/proxyThemeVariables.js.map +0 -7
- package/dist/esm/helpers/pseudoDescriptors.js +0 -29
- package/dist/esm/helpers/pseudoDescriptors.js.map +0 -7
- package/dist/esm/helpers/registerCSSVariable.js +0 -14
- package/dist/esm/helpers/registerCSSVariable.js.map +0 -7
- package/dist/esm/helpers/themeable.js +0 -28
- package/dist/esm/helpers/themeable.js.map +0 -7
- package/dist/esm/helpers/themes.js +0 -53
- package/dist/esm/helpers/themes.js.map +0 -7
- package/dist/esm/helpers/timer.js +0 -11
- package/dist/esm/helpers/timer.js.map +0 -7
- package/dist/esm/helpers/useShallowSetState.js +0 -35
- package/dist/esm/helpers/useShallowSetState.js.map +0 -7
- package/dist/esm/helpers/warnOnce.js +0 -14
- package/dist/esm/helpers/warnOnce.js.map +0 -7
- package/dist/esm/helpers/withStaticProperties.js +0 -8
- package/dist/esm/helpers/withStaticProperties.js.map +0 -7
- package/dist/esm/hooks/getThemeUnwrapped.js +0 -9
- package/dist/esm/hooks/getThemeUnwrapped.js.map +0 -7
- package/dist/esm/hooks/useId.js +0 -5
- package/dist/esm/hooks/useId.js.map +0 -7
- package/dist/esm/hooks/useIsTouchDevice.js +0 -9
- package/dist/esm/hooks/useIsTouchDevice.js.map +0 -7
- package/dist/esm/hooks/useMedia.js +0 -225
- package/dist/esm/hooks/useMedia.js.map +0 -7
- package/dist/esm/hooks/useSafeRef.js +0 -35
- package/dist/esm/hooks/useSafeRef.js.map +0 -7
- package/dist/esm/hooks/useServerHooks.js +0 -11
- package/dist/esm/hooks/useServerHooks.js.map +0 -7
- package/dist/esm/hooks/useStyle.js +0 -37
- package/dist/esm/hooks/useStyle.js.map +0 -7
- package/dist/esm/hooks/useTheme.js +0 -205
- package/dist/esm/hooks/useTheme.js.map +0 -7
- package/dist/esm/hooks/useThemeName.js +0 -28
- package/dist/esm/hooks/useThemeName.js.map +0 -7
- package/dist/esm/insertFont.js +0 -67
- package/dist/esm/insertFont.js.map +0 -7
- package/dist/esm/setupReactNative.js +0 -25
- package/dist/esm/setupReactNative.js.map +0 -7
- package/dist/esm/static.js +0 -3
- package/dist/esm/static.js.map +0 -7
- package/dist/esm/styled.js +0 -71
- package/dist/esm/styled.js.map +0 -7
- package/dist/esm/types-rnw.js +0 -1
- package/dist/esm/types.js +0 -1
- package/dist/esm/types.js.map +0 -7
- package/dist/esm/updateTheme.js +0 -23
- package/dist/esm/updateTheme.js.map +0 -7
- package/dist/esm/views/FontLanguage.js +0 -17
- package/dist/esm/views/FontLanguage.js.map +0 -7
- package/dist/esm/views/FontLanguage.native.js +0 -11
- package/dist/esm/views/FontLanguage.native.js.map +0 -7
- package/dist/esm/views/FontLanguage.types.js +0 -1
- package/dist/esm/views/FontLanguage.types.js.map +0 -7
- package/dist/esm/views/Slot.js +0 -71
- package/dist/esm/views/Slot.js.map +0 -7
- package/dist/esm/views/Stack.js +0 -14
- package/dist/esm/views/Stack.js.map +0 -7
- package/dist/esm/views/Stack.web.test.js +0 -21
- package/dist/esm/views/Stack.web.test.js.map +0 -7
- package/dist/esm/views/TamaguiProvider.js +0 -56
- package/dist/esm/views/TamaguiProvider.js.map +0 -7
- package/dist/esm/views/Text.js +0 -70
- package/dist/esm/views/Text.js.map +0 -7
- package/dist/esm/views/Theme.js +0 -63
- package/dist/esm/views/Theme.js.map +0 -7
- package/dist/esm/views/ThemeProvider.js +0 -45
- package/dist/esm/views/ThemeProvider.js.map +0 -7
- package/src/Tamagui.ts +0 -48
- package/src/__snapshots__/createTokens.test.ts.snap +0 -772
- package/src/__snapshots__/createTokens.web.test.tsx.snap +0 -772
- package/src/addTheme.ts +0 -65
- package/src/config.ts +0 -62
- package/src/constants/constants.ts +0 -17
- package/src/constants/isDevTools.ts +0 -12
- package/src/contexts/ButtonNestingContext.tsx +0 -3
- package/src/contexts/FontLanguageContext.tsx +0 -5
- package/src/contexts/TextAncestorContext.tsx +0 -3
- package/src/createComponent.tsx +0 -1291
- package/src/createFont.ts +0 -50
- package/src/createShorthands.ts +0 -7
- package/src/createTamagui.ts +0 -253
- package/src/createTheme.ts +0 -13
- package/src/createTokens.ts +0 -46
- package/src/createVariable.ts +0 -93
- package/src/createVariables.ts +0 -55
- package/src/helpers/RNComponents.tsx +0 -14
- package/src/helpers/ThemeManager.tsx +0 -285
- package/src/helpers/ThemeManagerContext.tsx +0 -5
- package/src/helpers/createMediaStyle.ts +0 -56
- package/src/helpers/createPropMapper.ts +0 -544
- package/src/helpers/createProxy.ts +0 -16
- package/src/helpers/expandStyle.ts +0 -82
- package/src/helpers/expandStyles.ts +0 -107
- package/src/helpers/extendStaticConfig.ts +0 -78
- package/src/helpers/fixNativeShadow.tsx +0 -2
- package/src/helpers/getAnimationDriver.tsx +0 -5
- package/src/helpers/getExpandedShorthands.ts +0 -17
- package/src/helpers/getFontLanguage.ts +0 -2
- package/src/helpers/getSplitStyles.tsx +0 -1137
- package/src/helpers/getStylesAtomic.native.ts +0 -8
- package/src/helpers/getStylesAtomic.ts +0 -274
- package/src/helpers/getThemeCSSRules.native.ts +0 -3
- package/src/helpers/getThemeCSSRules.ts +0 -120
- package/src/helpers/getVariantExtras.tsx +0 -85
- package/src/helpers/insertStyleRule.tsx +0 -220
- package/src/helpers/isObj.ts +0 -1
- package/src/helpers/isTamaguiComponent.tsx +0 -11
- package/src/helpers/isTamaguiElement.tsx +0 -15
- package/src/helpers/matchMedia.native.ts +0 -23
- package/src/helpers/matchMedia.ts +0 -16
- package/src/helpers/mergeProps.ts +0 -56
- package/src/helpers/mergeTransform.ts +0 -30
- package/src/helpers/normalizeColor.ts +0 -38
- package/src/helpers/normalizeValueWithProperty.ts +0 -129
- package/src/helpers/proxyThemeVariables.tsx +0 -15
- package/src/helpers/pseudoDescriptors.ts +0 -40
- package/src/helpers/registerCSSVariable.ts +0 -13
- package/src/helpers/themeable.tsx +0 -44
- package/src/helpers/themes.ts +0 -67
- package/src/helpers/timer.ts +0 -9
- package/src/helpers/useShallowSetState.tsx +0 -41
- package/src/helpers/warnOnce.tsx +0 -11
- package/src/helpers/withStaticProperties.tsx +0 -7
- package/src/hooks/getThemeUnwrapped.tsx +0 -5
- package/src/hooks/useId.tsx +0 -1
- package/src/hooks/useIsTouchDevice.tsx +0 -6
- package/src/hooks/useMedia.tsx +0 -298
- package/src/hooks/useSafeRef.ts +0 -45
- package/src/hooks/useServerHooks.tsx +0 -12
- package/src/hooks/useStyle.tsx +0 -49
- package/src/hooks/useTheme.tsx +0 -274
- package/src/hooks/useThemeName.tsx +0 -27
- package/src/insertFont.ts +0 -73
- package/src/setupReactNative.ts +0 -22
- package/src/static.ts +0 -5
- package/src/styled.tsx +0 -195
- package/src/types-rnw.tsx +0 -162
- package/src/types.tsx +0 -1405
- package/src/updateTheme.ts +0 -26
- package/src/views/FontLanguage.native.tsx +0 -12
- package/src/views/FontLanguage.tsx +0 -16
- package/src/views/FontLanguage.types.ts +0 -13
- package/src/views/Slot.tsx +0 -102
- package/src/views/Stack.tsx +0 -25
- package/src/views/TamaguiProvider.tsx +0 -65
- package/src/views/Text.tsx +0 -88
- package/src/views/Theme.tsx +0 -83
- package/src/views/ThemeProvider.tsx +0 -55
- package/types/Tamagui.d.ts +0 -30
- package/types/Tamagui.d.ts.map +0 -1
- package/types/addTheme.d.ts +0 -32
- package/types/addTheme.d.ts.map +0 -1
- package/types/config.d.ts +0 -49
- package/types/config.d.ts.map +0 -1
- package/types/constants/constants.d.ts +0 -21
- package/types/constants/constants.d.ts.map +0 -1
- package/types/constants/isDevTools.d.ts +0 -2
- package/types/constants/isDevTools.d.ts.map +0 -1
- package/types/contexts/ButtonNestingContext.d.ts +0 -3
- package/types/contexts/ButtonNestingContext.d.ts.map +0 -1
- package/types/contexts/FontLanguageContext.d.ts +0 -5
- package/types/contexts/FontLanguageContext.d.ts.map +0 -1
- package/types/contexts/TextAncestorContext.d.ts +0 -3
- package/types/contexts/TextAncestorContext.d.ts.map +0 -1
- package/types/createComponent.d.ts +0 -23
- package/types/createComponent.d.ts.map +0 -1
- package/types/createFont.d.ts +0 -3
- package/types/createFont.d.ts.map +0 -1
- package/types/createFont.web.test.d.ts +0 -2
- package/types/createFont.web.test.d.ts.map +0 -1
- package/types/createShorthands.d.ts +0 -3
- package/types/createShorthands.d.ts.map +0 -1
- package/types/createTamagui.d.ts +0 -3
- package/types/createTamagui.d.ts.map +0 -1
- package/types/createTheme.d.ts +0 -7
- package/types/createTheme.d.ts.map +0 -1
- package/types/createTokens.d.ts +0 -28
- package/types/createTokens.d.ts.map +0 -1
- package/types/createTokens.web.test.d.ts +0 -2
- package/types/createTokens.web.test.d.ts.map +0 -1
- package/types/createVariable.d.ts +0 -26
- package/types/createVariable.d.ts.map +0 -1
- package/types/createVariable.web.test.d.ts +0 -2
- package/types/createVariable.web.test.d.ts.map +0 -1
- package/types/createVariables.d.ts +0 -11
- package/types/createVariables.d.ts.map +0 -1
- package/types/helpers/RNComponents.d.ts +0 -2
- package/types/helpers/RNComponents.d.ts.map +0 -1
- package/types/helpers/ThemeManager.d.ts +0 -36
- package/types/helpers/ThemeManager.d.ts.map +0 -1
- package/types/helpers/ThemeManager.test.d.ts +0 -2
- package/types/helpers/ThemeManager.test.d.ts.map +0 -1
- package/types/helpers/ThemeManagerContext.d.ts +0 -4
- package/types/helpers/ThemeManagerContext.d.ts.map +0 -1
- package/types/helpers/createMediaStyle.d.ts +0 -6
- package/types/helpers/createMediaStyle.d.ts.map +0 -1
- package/types/helpers/createPropMapper.d.ts +0 -7
- package/types/helpers/createPropMapper.d.ts.map +0 -1
- package/types/helpers/createProxy.d.ts +0 -2
- package/types/helpers/createProxy.d.ts.map +0 -1
- package/types/helpers/expandStyle.d.ts +0 -6
- package/types/helpers/expandStyle.d.ts.map +0 -1
- package/types/helpers/expandStyles.d.ts +0 -26
- package/types/helpers/expandStyles.d.ts.map +0 -1
- package/types/helpers/extendStaticConfig.d.ts +0 -4
- package/types/helpers/extendStaticConfig.d.ts.map +0 -1
- package/types/helpers/fixNativeShadow.d.ts +0 -2
- package/types/helpers/fixNativeShadow.d.ts.map +0 -1
- package/types/helpers/getAnimationDriver.d.ts +0 -6
- package/types/helpers/getAnimationDriver.d.ts.map +0 -1
- package/types/helpers/getExpandedShorthands.d.ts +0 -3
- package/types/helpers/getExpandedShorthands.d.ts.map +0 -1
- package/types/helpers/getFontLanguage.d.ts +0 -2
- package/types/helpers/getFontLanguage.d.ts.map +0 -1
- package/types/helpers/getSplitStyles.d.ts +0 -43
- package/types/helpers/getSplitStyles.d.ts.map +0 -1
- package/types/helpers/getStylesAtomic.d.ts +0 -18
- package/types/helpers/getStylesAtomic.d.ts.map +0 -1
- package/types/helpers/getStylesAtomic.native.d.ts +0 -4
- package/types/helpers/getStylesAtomic.native.d.ts.map +0 -1
- package/types/helpers/getThemeCSSRules.d.ts +0 -8
- package/types/helpers/getThemeCSSRules.d.ts.map +0 -1
- package/types/helpers/getThemeCSSRules.native.d.ts +0 -2
- package/types/helpers/getThemeCSSRules.native.d.ts.map +0 -1
- package/types/helpers/getVariantExtras.d.ts +0 -5
- package/types/helpers/getVariantExtras.d.ts.map +0 -1
- package/types/helpers/insertStyleRule.d.ts +0 -13
- package/types/helpers/insertStyleRule.d.ts.map +0 -1
- package/types/helpers/isObj.d.ts +0 -2
- package/types/helpers/isObj.d.ts.map +0 -1
- package/types/helpers/isTamaguiComponent.d.ts +0 -5
- package/types/helpers/isTamaguiComponent.d.ts.map +0 -1
- package/types/helpers/isTamaguiElement.d.ts +0 -7
- package/types/helpers/isTamaguiElement.d.ts.map +0 -1
- package/types/helpers/matchMedia.d.ts +0 -6
- package/types/helpers/matchMedia.d.ts.map +0 -1
- package/types/helpers/matchMedia.native.d.ts +0 -4
- package/types/helpers/matchMedia.native.d.ts.map +0 -1
- package/types/helpers/mergeProps.d.ts +0 -17
- package/types/helpers/mergeProps.d.ts.map +0 -1
- package/types/helpers/mergeTransform.d.ts +0 -9
- package/types/helpers/mergeTransform.d.ts.map +0 -1
- package/types/helpers/normalizeColor.d.ts +0 -4
- package/types/helpers/normalizeColor.d.ts.map +0 -1
- package/types/helpers/normalizeValueWithProperty.d.ts +0 -7
- package/types/helpers/normalizeValueWithProperty.d.ts.map +0 -1
- package/types/helpers/proxyThemeVariables.d.ts +0 -2
- package/types/helpers/proxyThemeVariables.d.ts.map +0 -1
- package/types/helpers/pseudoDescriptors.d.ts +0 -10
- package/types/helpers/pseudoDescriptors.d.ts.map +0 -1
- package/types/helpers/registerCSSVariable.d.ts +0 -5
- package/types/helpers/registerCSSVariable.d.ts.map +0 -1
- package/types/helpers/themeable.d.ts +0 -12
- package/types/helpers/themeable.d.ts.map +0 -1
- package/types/helpers/themes.d.ts +0 -4
- package/types/helpers/themes.d.ts.map +0 -1
- package/types/helpers/timer.d.ts +0 -2
- package/types/helpers/timer.d.ts.map +0 -1
- package/types/helpers/useShallowSetState.d.ts +0 -5
- package/types/helpers/useShallowSetState.d.ts.map +0 -1
- package/types/helpers/warnOnce.d.ts +0 -2
- package/types/helpers/warnOnce.d.ts.map +0 -1
- package/types/helpers/withStaticProperties.d.ts +0 -2
- package/types/helpers/withStaticProperties.d.ts.map +0 -1
- package/types/hooks/getThemeUnwrapped.d.ts +0 -3
- package/types/hooks/getThemeUnwrapped.d.ts.map +0 -1
- package/types/hooks/useId.d.ts +0 -2
- package/types/hooks/useId.d.ts.map +0 -1
- package/types/hooks/useIsTouchDevice.d.ts +0 -2
- package/types/hooks/useIsTouchDevice.d.ts.map +0 -1
- package/types/hooks/useMedia.d.ts +0 -33
- package/types/hooks/useMedia.d.ts.map +0 -1
- package/types/hooks/useSafeRef.d.ts +0 -4
- package/types/hooks/useSafeRef.d.ts.map +0 -1
- package/types/hooks/useServerHooks.d.ts +0 -4
- package/types/hooks/useServerHooks.d.ts.map +0 -1
- package/types/hooks/useStyle.d.ts +0 -8
- package/types/hooks/useStyle.d.ts.map +0 -1
- package/types/hooks/useTheme.d.ts +0 -25
- package/types/hooks/useTheme.d.ts.map +0 -1
- package/types/hooks/useThemeName.d.ts +0 -5
- package/types/hooks/useThemeName.d.ts.map +0 -1
- package/types/insertFont.d.ts +0 -9
- package/types/insertFont.d.ts.map +0 -1
- package/types/setupReactNative.d.ts +0 -5
- package/types/setupReactNative.d.ts.map +0 -1
- package/types/static.d.ts +0 -3
- package/types/static.d.ts.map +0 -1
- package/types/styled.d.ts +0 -20
- package/types/styled.d.ts.map +0 -1
- package/types/types-rnw.d.ts +0 -74
- package/types/types-rnw.d.ts.map +0 -1
- package/types/types.d.ts +0 -673
- package/types/types.d.ts.map +0 -1
- package/types/updateTheme.d.ts +0 -30
- package/types/updateTheme.d.ts.map +0 -1
- package/types/views/FontLanguage.d.ts +0 -4
- package/types/views/FontLanguage.d.ts.map +0 -1
- package/types/views/FontLanguage.native.d.ts +0 -4
- package/types/views/FontLanguage.native.d.ts.map +0 -1
- package/types/views/FontLanguage.types.d.ts +0 -11
- package/types/views/FontLanguage.types.d.ts.map +0 -1
- package/types/views/Slot.d.ts +0 -11
- package/types/views/Slot.d.ts.map +0 -1
- package/types/views/Stack.d.ts +0 -4
- package/types/views/Stack.d.ts.map +0 -1
- package/types/views/Stack.web.test.d.ts +0 -2
- package/types/views/Stack.web.test.d.ts.map +0 -1
- package/types/views/TamaguiProvider.d.ts +0 -4
- package/types/views/TamaguiProvider.d.ts.map +0 -1
- package/types/views/Text.d.ts +0 -4
- package/types/views/Text.d.ts.map +0 -1
- package/types/views/Theme.d.ts +0 -8
- package/types/views/Theme.d.ts.map +0 -1
- package/types/views/ThemeProvider.d.ts +0 -12
- package/types/views/ThemeProvider.d.ts.map +0 -1
package/src/createComponent.tsx
DELETED
|
@@ -1,1291 +0,0 @@
|
|
|
1
|
-
import { useComposedRefs } from '@tamagui/compose-refs'
|
|
2
|
-
import {
|
|
3
|
-
isClient,
|
|
4
|
-
isRSC,
|
|
5
|
-
isServer,
|
|
6
|
-
isWeb,
|
|
7
|
-
useIsomorphicLayoutEffect,
|
|
8
|
-
} from '@tamagui/constants'
|
|
9
|
-
import {
|
|
10
|
-
composeEventHandlers,
|
|
11
|
-
stylePropsView,
|
|
12
|
-
validPseudoKeys,
|
|
13
|
-
validStyles,
|
|
14
|
-
} from '@tamagui/helpers'
|
|
15
|
-
import { useResponderEvents } from '@tamagui/react-native-use-responder-events'
|
|
16
|
-
import React, {
|
|
17
|
-
Children,
|
|
18
|
-
Fragment,
|
|
19
|
-
RefObject,
|
|
20
|
-
createElement,
|
|
21
|
-
forwardRef,
|
|
22
|
-
memo,
|
|
23
|
-
useCallback,
|
|
24
|
-
useContext,
|
|
25
|
-
useEffect,
|
|
26
|
-
useRef,
|
|
27
|
-
} from 'react'
|
|
28
|
-
|
|
29
|
-
import { onConfiguredOnce } from './config'
|
|
30
|
-
import { stackDefaultStyles } from './constants/constants'
|
|
31
|
-
import { FontLanguageContext } from './contexts/FontLanguageContext'
|
|
32
|
-
import { TextAncestorContext } from './contexts/TextAncestorContext'
|
|
33
|
-
import { didGetVariableValue, setDidGetVariableValue } from './createVariable'
|
|
34
|
-
import { extendStaticConfig, parseStaticConfig } from './helpers/extendStaticConfig'
|
|
35
|
-
import { getRect } from './helpers/getRect'
|
|
36
|
-
import { useSplitStyles } from './helpers/getSplitStyles'
|
|
37
|
-
import { getAllSelectors } from './helpers/insertStyleRule'
|
|
38
|
-
import { mergeProps } from './helpers/mergeProps'
|
|
39
|
-
import { proxyThemeVariables } from './helpers/proxyThemeVariables'
|
|
40
|
-
import { useShallowSetState } from './helpers/useShallowSetState'
|
|
41
|
-
import { measureLayout, useElementLayout } from './hooks/useElementLayout'
|
|
42
|
-
import { setMediaShouldUpdate, useMedia } from './hooks/useMedia'
|
|
43
|
-
import { useServerRef, useServerState } from './hooks/useServerHooks'
|
|
44
|
-
import { useThemeWithState } from './hooks/useTheme'
|
|
45
|
-
import {
|
|
46
|
-
DebugProp,
|
|
47
|
-
SpaceDirection,
|
|
48
|
-
SpaceTokens,
|
|
49
|
-
SpacerProps,
|
|
50
|
-
StaticConfig,
|
|
51
|
-
StaticConfigParsed,
|
|
52
|
-
StylableComponent,
|
|
53
|
-
TamaguiComponent,
|
|
54
|
-
TamaguiComponentState,
|
|
55
|
-
TamaguiConfig,
|
|
56
|
-
TamaguiElement,
|
|
57
|
-
TamaguiInternalConfig,
|
|
58
|
-
UseAnimationHook,
|
|
59
|
-
UseAnimationProps,
|
|
60
|
-
} from './types'
|
|
61
|
-
import { usePressability } from './vendor/Pressability'
|
|
62
|
-
import { Slot, mergeEvent } from './views/Slot'
|
|
63
|
-
import { useThemedChildren } from './views/Theme'
|
|
64
|
-
|
|
65
|
-
// let t
|
|
66
|
-
// import { timer } from '@tamagui/timer'
|
|
67
|
-
// if (true || process.env.ANALYZE) {
|
|
68
|
-
// t = require().timer()
|
|
69
|
-
// setTimeout(() => {
|
|
70
|
-
// const out = t.print()
|
|
71
|
-
// if (isClient) {
|
|
72
|
-
// alert(out)
|
|
73
|
-
// }
|
|
74
|
-
// }, 2000)
|
|
75
|
-
// }
|
|
76
|
-
|
|
77
|
-
// this appears to fix expo / babel not picking this up sometimes? really odd
|
|
78
|
-
process.env.TAMAGUI_TARGET
|
|
79
|
-
|
|
80
|
-
export const defaultComponentState: TamaguiComponentState = {
|
|
81
|
-
hover: false,
|
|
82
|
-
press: false,
|
|
83
|
-
pressIn: false,
|
|
84
|
-
focus: false,
|
|
85
|
-
unmounted: true,
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const defaultComponentStateMounted: TamaguiComponentState = {
|
|
89
|
-
...defaultComponentState,
|
|
90
|
-
unmounted: false,
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* All things that need one-time setup after createTamagui is called
|
|
95
|
-
*/
|
|
96
|
-
let tamaguiConfig: TamaguiInternalConfig
|
|
97
|
-
let AnimatedText: any
|
|
98
|
-
let AnimatedView: any
|
|
99
|
-
let initialTheme: any
|
|
100
|
-
|
|
101
|
-
export const mouseUps = new Set<Function>()
|
|
102
|
-
if (typeof document !== 'undefined') {
|
|
103
|
-
const cancelTouches = () => {
|
|
104
|
-
mouseUps.forEach((x) => x())
|
|
105
|
-
mouseUps.clear()
|
|
106
|
-
}
|
|
107
|
-
addEventListener('mouseup', cancelTouches)
|
|
108
|
-
addEventListener('touchend', cancelTouches)
|
|
109
|
-
addEventListener('touchcancel', cancelTouches)
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// mutates
|
|
113
|
-
function mergeShorthands(
|
|
114
|
-
{ defaultProps }: StaticConfigParsed,
|
|
115
|
-
{ shorthands }: TamaguiConfig
|
|
116
|
-
) {
|
|
117
|
-
// they are defined in correct order already { ...parent, ...child }
|
|
118
|
-
for (const key of Object.keys(defaultProps)) {
|
|
119
|
-
defaultProps[shorthands[key] || key] = defaultProps[key]
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Only on native do we need the actual underlying View/Text
|
|
125
|
-
* On the web we avoid react-native altogether in core.
|
|
126
|
-
*/
|
|
127
|
-
let BaseText: any
|
|
128
|
-
let BaseView: any
|
|
129
|
-
if (process.env.TAMAGUI_TARGET === 'native') {
|
|
130
|
-
const native = require('react-native')
|
|
131
|
-
BaseText = native.Text || native.default.Text
|
|
132
|
-
BaseView = native.View || native.default.View
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export function createComponent<
|
|
136
|
-
ComponentPropTypes extends Object = {},
|
|
137
|
-
Ref = TamaguiElement,
|
|
138
|
-
BaseProps = never
|
|
139
|
-
>(
|
|
140
|
-
configIn: Partial<StaticConfig> | StaticConfigParsed,
|
|
141
|
-
ParentComponent?: StylableComponent
|
|
142
|
-
) {
|
|
143
|
-
const staticConfig = (() => {
|
|
144
|
-
const next = extendStaticConfig(configIn, ParentComponent)
|
|
145
|
-
if ('parsed' in next) {
|
|
146
|
-
return next
|
|
147
|
-
} else {
|
|
148
|
-
return parseStaticConfig(next)
|
|
149
|
-
}
|
|
150
|
-
})()
|
|
151
|
-
|
|
152
|
-
const defaultComponentClassName = `is_${staticConfig.componentName}`
|
|
153
|
-
let tamaguiDefaultProps: any
|
|
154
|
-
let defaultTag: string | undefined
|
|
155
|
-
|
|
156
|
-
// see onConfiguredOnce below which attaches a name then to this component
|
|
157
|
-
const component = forwardRef<Ref, ComponentPropTypes>((propsIn: any, forwardedRef) => {
|
|
158
|
-
// test only
|
|
159
|
-
if (process.env.NODE_ENV === 'test') {
|
|
160
|
-
if (propsIn['data-test-renders']) {
|
|
161
|
-
propsIn['data-test-renders']['current'] ??= 0
|
|
162
|
-
propsIn['data-test-renders']['current'] += 1
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
// const time = t.start({ quiet: true })
|
|
166
|
-
|
|
167
|
-
// React inserts default props after your props for some reason...
|
|
168
|
-
// order important so we do loops, you can't just spread because JS does weird things
|
|
169
|
-
let props: any
|
|
170
|
-
if (tamaguiDefaultProps && !propsIn.asChild) {
|
|
171
|
-
props = mergeProps(tamaguiDefaultProps, propsIn)[0]
|
|
172
|
-
} else {
|
|
173
|
-
props = propsIn
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const debugProp = props['debug'] as DebugProp
|
|
177
|
-
const { Component, isText, isZStack } = staticConfig
|
|
178
|
-
const componentName = props.componentName || staticConfig.componentName
|
|
179
|
-
const componentClassName = props.asChild
|
|
180
|
-
? ''
|
|
181
|
-
: props.componentName
|
|
182
|
-
? `is_${props.componentName}`
|
|
183
|
-
: defaultComponentClassName
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Component state for tracking animations, pseudos
|
|
187
|
-
*/
|
|
188
|
-
const animationsConfig = tamaguiConfig.animations
|
|
189
|
-
const useAnimations = animationsConfig?.useAnimations as UseAnimationHook | undefined
|
|
190
|
-
const avoidClassesWhileAnimating = animationsConfig.isReactNative
|
|
191
|
-
const hasEnterStyle = !!props.enterStyle
|
|
192
|
-
const needsMount = Boolean(
|
|
193
|
-
(isWeb ? isClient : true) && (hasEnterStyle || props.animation)
|
|
194
|
-
)
|
|
195
|
-
const states = useServerState<TamaguiComponentState>(
|
|
196
|
-
needsMount ? defaultComponentState! : defaultComponentStateMounted!
|
|
197
|
-
)
|
|
198
|
-
|
|
199
|
-
const state = propsIn.forceStyle
|
|
200
|
-
? { ...states[0], [propsIn.forceStyle]: true }
|
|
201
|
-
: states[0]
|
|
202
|
-
const setState = states[1]
|
|
203
|
-
const setStateShallow = useShallowSetState(setState, debugProp, componentName)
|
|
204
|
-
|
|
205
|
-
// conditional but if ever true stays true
|
|
206
|
-
// [animated, inversed]
|
|
207
|
-
const stateRef = useRef(
|
|
208
|
-
undefined as any as {
|
|
209
|
-
hasAnimated?: boolean
|
|
210
|
-
themeShallow?: boolean
|
|
211
|
-
didAccessThemeVariableValue?: boolean
|
|
212
|
-
}
|
|
213
|
-
)
|
|
214
|
-
stateRef.current ??= {}
|
|
215
|
-
|
|
216
|
-
const isAnimated = (() => {
|
|
217
|
-
const next = !!(useAnimations && props.animation)
|
|
218
|
-
if (next && !stateRef.current.hasAnimated) {
|
|
219
|
-
stateRef.current.hasAnimated = true
|
|
220
|
-
}
|
|
221
|
-
return next || stateRef.current.hasAnimated
|
|
222
|
-
})()
|
|
223
|
-
|
|
224
|
-
const usePresence = tamaguiConfig.animations?.usePresence
|
|
225
|
-
const presence = !isRSC && isAnimated ? usePresence() : null
|
|
226
|
-
|
|
227
|
-
// set enter/exit variants onto our new props object
|
|
228
|
-
if (isAnimated && presence) {
|
|
229
|
-
const presenceState = presence[2]
|
|
230
|
-
if (presenceState) {
|
|
231
|
-
if (state.unmounted && presenceState.enterVariant) {
|
|
232
|
-
props[presenceState.enterVariant] = true
|
|
233
|
-
}
|
|
234
|
-
if (!presenceState.isPresent && presenceState.exitVariant) {
|
|
235
|
-
props[presenceState.exitVariant] = true
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
const isReactNative = Boolean(
|
|
241
|
-
staticConfig.isReactNative || (isAnimated && tamaguiConfig.animations.isReactNative)
|
|
242
|
-
)
|
|
243
|
-
|
|
244
|
-
if (process.env.NODE_ENV === 'development') {
|
|
245
|
-
if (debugProp) {
|
|
246
|
-
// prettier-ignore
|
|
247
|
-
const name = `${componentName || Component?.displayName || Component?.name || '[Unnamed Component]'}`
|
|
248
|
-
const type = isReactNative ? '(rnw)' : ''
|
|
249
|
-
const dataIs = propsIn['data-is'] || ''
|
|
250
|
-
const banner = `${name}${dataIs ? ` ${dataIs}` : ''} ${type}`
|
|
251
|
-
console.group(`%c ${banner}`, 'background: yellow;')
|
|
252
|
-
if (!isServer) {
|
|
253
|
-
console.log('state', state)
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
const shouldAvoidClasses =
|
|
259
|
-
!isWeb ||
|
|
260
|
-
!!(props.animation && avoidClassesWhileAnimating) ||
|
|
261
|
-
!staticConfig.acceptsClassName
|
|
262
|
-
const shouldForcePseudo = !!propsIn.forceStyle
|
|
263
|
-
const noClassNames = shouldAvoidClasses || shouldForcePseudo
|
|
264
|
-
|
|
265
|
-
const themeState = useThemeWithState({
|
|
266
|
-
name: props.theme,
|
|
267
|
-
componentName,
|
|
268
|
-
reset: props.reset,
|
|
269
|
-
inverse: props.themeInverse,
|
|
270
|
-
// @ts-expect-error
|
|
271
|
-
disable: props['data-themeable'],
|
|
272
|
-
debug: props.debug,
|
|
273
|
-
shouldUpdate: () => !!stateRef.current.didAccessThemeVariableValue,
|
|
274
|
-
})!
|
|
275
|
-
|
|
276
|
-
const hasTextAncestor = !!(isWeb && isText ? useContext(TextAncestorContext) : false)
|
|
277
|
-
const languageContext = isRSC ? null : useContext(FontLanguageContext)
|
|
278
|
-
const isDisabled = props.disabled ?? props.accessibilityState?.disabled
|
|
279
|
-
|
|
280
|
-
const isTaggable = !Component || typeof Component === 'string'
|
|
281
|
-
// default to tag, fallback to component (when both strings)
|
|
282
|
-
const element = isWeb
|
|
283
|
-
? isTaggable
|
|
284
|
-
? props.tag || defaultTag || Component
|
|
285
|
-
: Component
|
|
286
|
-
: Component
|
|
287
|
-
|
|
288
|
-
const BaseTextComponent = BaseText || element || 'span'
|
|
289
|
-
const BaseViewComponent = BaseView || element || (hasTextAncestor ? 'span' : 'div')
|
|
290
|
-
let elementType = isText
|
|
291
|
-
? (isAnimated ? AnimatedText : null) || BaseTextComponent
|
|
292
|
-
: (isAnimated ? AnimatedView : null) || BaseViewComponent
|
|
293
|
-
|
|
294
|
-
elementType = Component || elementType
|
|
295
|
-
const isStringElement = typeof elementType === 'string'
|
|
296
|
-
|
|
297
|
-
const isExiting = presence?.[0] === false
|
|
298
|
-
|
|
299
|
-
const mediaState = useMedia(
|
|
300
|
-
// @ts-ignore, we just pass a stable object so we can get it later with
|
|
301
|
-
// should match to the one used in `setMediaShouldUpdate` below
|
|
302
|
-
stateRef,
|
|
303
|
-
debugProp ? { props, staticConfig } : null
|
|
304
|
-
)
|
|
305
|
-
|
|
306
|
-
setDidGetVariableValue(false)
|
|
307
|
-
|
|
308
|
-
const splitStyles = useSplitStyles(
|
|
309
|
-
props,
|
|
310
|
-
staticConfig,
|
|
311
|
-
themeState.theme,
|
|
312
|
-
{
|
|
313
|
-
...state,
|
|
314
|
-
mediaState,
|
|
315
|
-
noClassNames,
|
|
316
|
-
dynamicStylesInline: noClassNames,
|
|
317
|
-
hasTextAncestor,
|
|
318
|
-
resolveVariablesAs: 'auto',
|
|
319
|
-
isExiting,
|
|
320
|
-
},
|
|
321
|
-
null,
|
|
322
|
-
languageContext || undefined,
|
|
323
|
-
elementType,
|
|
324
|
-
debugProp
|
|
325
|
-
)
|
|
326
|
-
|
|
327
|
-
// only listen for changes if we are using raw theme values or media space, or dynamic media (native)
|
|
328
|
-
// array = space media breakpoints
|
|
329
|
-
const isMediaSpaced = Array.isArray(splitStyles.hasMedia)
|
|
330
|
-
const shouldListenForMedia =
|
|
331
|
-
didGetVariableValue() ||
|
|
332
|
-
isMediaSpaced ||
|
|
333
|
-
(noClassNames && splitStyles.hasMedia === true)
|
|
334
|
-
|
|
335
|
-
setMediaShouldUpdate(stateRef, {
|
|
336
|
-
enabled: shouldListenForMedia,
|
|
337
|
-
keys: noClassNames && isMediaSpaced ? (splitStyles.hasMedia as any) : null,
|
|
338
|
-
})
|
|
339
|
-
|
|
340
|
-
const hostRef = useServerRef<TamaguiElement>(null)
|
|
341
|
-
|
|
342
|
-
// animation setup
|
|
343
|
-
const isAnimatedReactNativeWeb = isAnimated && avoidClassesWhileAnimating
|
|
344
|
-
|
|
345
|
-
if (process.env.NODE_ENV === 'development') {
|
|
346
|
-
if (!process.env.TAMAGUI_TARGET) {
|
|
347
|
-
console.error(
|
|
348
|
-
`No process.env.TAMAGUI_TARGET set, please set it to "native" or "web".`
|
|
349
|
-
)
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
if (debugProp) {
|
|
353
|
-
console.groupCollapsed('props')
|
|
354
|
-
// prettier-ignore
|
|
355
|
-
console.log('props in', propsIn, 'mapped to', props, 'in order', Object.keys(props))
|
|
356
|
-
console.log('splitStyles', splitStyles)
|
|
357
|
-
// eslint-disable-next-line no-console
|
|
358
|
-
console.log('shouldListenForMedia', shouldListenForMedia)
|
|
359
|
-
// eslint-disable-next-line no-console
|
|
360
|
-
console.log('className', Object.values(splitStyles.classNames))
|
|
361
|
-
if (isClient) {
|
|
362
|
-
console.log('ref', hostRef, '(click to view)')
|
|
363
|
-
}
|
|
364
|
-
console.groupEnd()
|
|
365
|
-
if (debugProp === 'break') {
|
|
366
|
-
// rome-ignore lint/suspicious/noDebugger: ok
|
|
367
|
-
debugger
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
const {
|
|
373
|
-
viewProps: viewPropsIn,
|
|
374
|
-
pseudos,
|
|
375
|
-
style: splitStylesStyle,
|
|
376
|
-
classNames,
|
|
377
|
-
space,
|
|
378
|
-
} = splitStyles
|
|
379
|
-
|
|
380
|
-
const propsWithAnimation = props as UseAnimationProps
|
|
381
|
-
|
|
382
|
-
// once you set animation prop don't remove it, you can set to undefined/false
|
|
383
|
-
// reason is animations are heavy - no way around it, and must be run inline here (🙅 loading as a sub-component)
|
|
384
|
-
let animationStyles: any
|
|
385
|
-
if (!isRSC && isAnimated && useAnimations) {
|
|
386
|
-
const animations = useAnimations({
|
|
387
|
-
props: propsWithAnimation,
|
|
388
|
-
style: splitStylesStyle,
|
|
389
|
-
presence,
|
|
390
|
-
state,
|
|
391
|
-
pseudos: pseudos || null,
|
|
392
|
-
onDidAnimate: props.onDidAnimate,
|
|
393
|
-
hostRef,
|
|
394
|
-
staticConfig,
|
|
395
|
-
})
|
|
396
|
-
if (animations) {
|
|
397
|
-
animationStyles = animations.style
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
const {
|
|
402
|
-
hitSlop,
|
|
403
|
-
asChild,
|
|
404
|
-
children,
|
|
405
|
-
onPress,
|
|
406
|
-
onPressIn,
|
|
407
|
-
onPressOut,
|
|
408
|
-
onHoverIn,
|
|
409
|
-
onHoverOut,
|
|
410
|
-
themeShallow,
|
|
411
|
-
spaceDirection: _spaceDirection,
|
|
412
|
-
disabled: disabledProp,
|
|
413
|
-
onMouseUp,
|
|
414
|
-
onMouseDown,
|
|
415
|
-
onMouseEnter,
|
|
416
|
-
onMouseLeave,
|
|
417
|
-
hrefAttrs,
|
|
418
|
-
separator,
|
|
419
|
-
// ignore from here on out
|
|
420
|
-
forceStyle: _forceStyle,
|
|
421
|
-
// @ts-ignore for next/link compat etc
|
|
422
|
-
onClick,
|
|
423
|
-
theme: _themeProp,
|
|
424
|
-
// @ts-ignore
|
|
425
|
-
defaultVariants,
|
|
426
|
-
|
|
427
|
-
...nonTamaguiProps
|
|
428
|
-
} = viewPropsIn
|
|
429
|
-
|
|
430
|
-
const disabled =
|
|
431
|
-
(props.accessibilityState != null && props.accessibilityState.disabled === true) ||
|
|
432
|
-
props.accessibilityDisabled
|
|
433
|
-
|
|
434
|
-
// these can ultimately be for DOM, react-native-web views, or animated views
|
|
435
|
-
// so the type is pretty loose
|
|
436
|
-
let viewProps: Record<string, any>
|
|
437
|
-
|
|
438
|
-
// if react-native-web view just pass all props down
|
|
439
|
-
if (process.env.TAMAGUI_TARGET === 'web' && !isReactNative) {
|
|
440
|
-
// otherwise replicate react-native-web functionality
|
|
441
|
-
const {
|
|
442
|
-
// event props
|
|
443
|
-
onMoveShouldSetResponder,
|
|
444
|
-
onMoveShouldSetResponderCapture,
|
|
445
|
-
onResponderEnd,
|
|
446
|
-
onResponderGrant,
|
|
447
|
-
onResponderMove,
|
|
448
|
-
onResponderReject,
|
|
449
|
-
onResponderRelease,
|
|
450
|
-
onResponderStart,
|
|
451
|
-
onResponderTerminate,
|
|
452
|
-
onResponderTerminationRequest,
|
|
453
|
-
onScrollShouldSetResponder,
|
|
454
|
-
onScrollShouldSetResponderCapture,
|
|
455
|
-
onSelectionChangeShouldSetResponder,
|
|
456
|
-
onSelectionChangeShouldSetResponderCapture,
|
|
457
|
-
onStartShouldSetResponder,
|
|
458
|
-
onStartShouldSetResponderCapture,
|
|
459
|
-
|
|
460
|
-
// android
|
|
461
|
-
collapsable,
|
|
462
|
-
focusable,
|
|
463
|
-
|
|
464
|
-
// deprecated,
|
|
465
|
-
accessible,
|
|
466
|
-
accessibilityDisabled,
|
|
467
|
-
|
|
468
|
-
onLayout,
|
|
469
|
-
|
|
470
|
-
...webProps
|
|
471
|
-
} = nonTamaguiProps
|
|
472
|
-
|
|
473
|
-
viewProps = webProps
|
|
474
|
-
|
|
475
|
-
if (!isRSC) {
|
|
476
|
-
usePlatformMethods(hostRef as RefObject<Element>)
|
|
477
|
-
|
|
478
|
-
useElementLayout(hostRef as RefObject<Element>, onLayout as any)
|
|
479
|
-
|
|
480
|
-
useResponderEvents(hostRef, {
|
|
481
|
-
onMoveShouldSetResponder,
|
|
482
|
-
onMoveShouldSetResponderCapture,
|
|
483
|
-
onResponderEnd,
|
|
484
|
-
onResponderGrant,
|
|
485
|
-
onResponderMove,
|
|
486
|
-
onResponderReject,
|
|
487
|
-
onResponderRelease,
|
|
488
|
-
onResponderStart,
|
|
489
|
-
onResponderTerminate,
|
|
490
|
-
onResponderTerminationRequest,
|
|
491
|
-
onScrollShouldSetResponder,
|
|
492
|
-
onScrollShouldSetResponderCapture,
|
|
493
|
-
onSelectionChangeShouldSetResponder,
|
|
494
|
-
onSelectionChangeShouldSetResponderCapture,
|
|
495
|
-
onStartShouldSetResponder,
|
|
496
|
-
onStartShouldSetResponderCapture,
|
|
497
|
-
} as any)
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
if (props.href !== undefined && hrefAttrs !== undefined) {
|
|
501
|
-
const { download, rel, target } = hrefAttrs
|
|
502
|
-
if (download != null) {
|
|
503
|
-
viewProps.download = download
|
|
504
|
-
}
|
|
505
|
-
if (rel != null) {
|
|
506
|
-
viewProps.rel = rel
|
|
507
|
-
}
|
|
508
|
-
if (typeof target === 'string') {
|
|
509
|
-
viewProps.target = target.charAt(0) !== '_' ? `_${target}` : target
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
// FOCUS
|
|
514
|
-
// "focusable" indicates that an element may be a keyboard tab-stop.
|
|
515
|
-
// ported from RNW: TODO move into getSplitStyles
|
|
516
|
-
if (!props.tabIndex) {
|
|
517
|
-
const _focusable = focusable !== undefined ? focusable : accessible
|
|
518
|
-
const role = viewProps.role
|
|
519
|
-
if (_focusable === false) {
|
|
520
|
-
viewProps.tabIndex = '-1'
|
|
521
|
-
}
|
|
522
|
-
if (
|
|
523
|
-
// These native elements are focusable by default
|
|
524
|
-
elementType === 'a' ||
|
|
525
|
-
elementType === 'button' ||
|
|
526
|
-
elementType === 'input' ||
|
|
527
|
-
elementType === 'select' ||
|
|
528
|
-
elementType === 'textarea'
|
|
529
|
-
) {
|
|
530
|
-
if (_focusable === false || accessibilityDisabled === true) {
|
|
531
|
-
viewProps.tabIndex = '-1'
|
|
532
|
-
}
|
|
533
|
-
} else if (
|
|
534
|
-
// These roles are made focusable by default
|
|
535
|
-
role === 'button' ||
|
|
536
|
-
role === 'checkbox' ||
|
|
537
|
-
role === 'link' ||
|
|
538
|
-
role === 'radio' ||
|
|
539
|
-
role === 'textbox' ||
|
|
540
|
-
role === 'switch'
|
|
541
|
-
) {
|
|
542
|
-
if (_focusable !== false) {
|
|
543
|
-
viewProps.tabIndex = '0'
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
// Everything else must explicitly set the prop
|
|
547
|
-
if (_focusable === true) {
|
|
548
|
-
viewProps.tabIndex = '0'
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
} else {
|
|
552
|
-
viewProps = nonTamaguiProps
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
viewProps.ref = useComposedRefs(hostRef as any, forwardedRef)
|
|
556
|
-
|
|
557
|
-
if (process.env.NODE_ENV === 'development' && !isText && isWeb) {
|
|
558
|
-
Children.toArray(props.children).forEach((item) => {
|
|
559
|
-
// allow newlines because why not its annoying with mdx
|
|
560
|
-
if (typeof item === 'string' && item !== '\n') {
|
|
561
|
-
console.error(
|
|
562
|
-
`Unexpected text node: ${item}. A text node cannot be a child of a <View>.`
|
|
563
|
-
)
|
|
564
|
-
}
|
|
565
|
-
})
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
const unPress = useCallback(() => {
|
|
569
|
-
setStateShallow({
|
|
570
|
-
press: false,
|
|
571
|
-
pressIn: false,
|
|
572
|
-
})
|
|
573
|
-
}, [setStateShallow])
|
|
574
|
-
|
|
575
|
-
if (isWeb) {
|
|
576
|
-
useEffect(() => {
|
|
577
|
-
return () => {
|
|
578
|
-
mouseUps.delete(unPress)
|
|
579
|
-
}
|
|
580
|
-
}, [])
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
const shouldSetMounted = needsMount && state.unmounted
|
|
584
|
-
useEffect(() => {
|
|
585
|
-
if (!shouldSetMounted) return
|
|
586
|
-
if (state.unmounted === true && needsMount) {
|
|
587
|
-
setStateShallow({
|
|
588
|
-
unmounted: false,
|
|
589
|
-
})
|
|
590
|
-
return
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
setStateShallow({
|
|
594
|
-
unmounted: false,
|
|
595
|
-
})
|
|
596
|
-
}, [shouldSetMounted, state.unmounted])
|
|
597
|
-
|
|
598
|
-
let styles: Record<string, any>[]
|
|
599
|
-
|
|
600
|
-
if (isStringElement && shouldAvoidClasses && !shouldForcePseudo) {
|
|
601
|
-
styles = {
|
|
602
|
-
...(animationStyles ?? splitStylesStyle),
|
|
603
|
-
}
|
|
604
|
-
} else {
|
|
605
|
-
styles = [animationStyles ?? splitStylesStyle]
|
|
606
|
-
|
|
607
|
-
// ugly but for now...
|
|
608
|
-
if (shouldForcePseudo) {
|
|
609
|
-
const next = {}
|
|
610
|
-
styles.forEach((style) => Object.assign(next, style))
|
|
611
|
-
// @ts-ignore
|
|
612
|
-
Object.assign(splitStyles.style, next)
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
let fontFamily = isText
|
|
617
|
-
? splitStyles.fontFamily || staticConfig.defaultProps.fontFamily
|
|
618
|
-
: null
|
|
619
|
-
if (fontFamily && fontFamily[0] === '$') {
|
|
620
|
-
fontFamily = fontFamily.slice(1)
|
|
621
|
-
}
|
|
622
|
-
const fontFamilyClassName = fontFamily ? `font_${fontFamily}` : ''
|
|
623
|
-
|
|
624
|
-
const classList = [
|
|
625
|
-
hasEnterStyle && ((state.unmounted && needsMount) || !isClient)
|
|
626
|
-
? 't_will-mount'
|
|
627
|
-
: '',
|
|
628
|
-
componentName ? componentClassName : '',
|
|
629
|
-
fontFamilyClassName,
|
|
630
|
-
classNames ? Object.values(classNames).join(' ') : '',
|
|
631
|
-
]
|
|
632
|
-
|
|
633
|
-
const className = classList.join(' ')
|
|
634
|
-
|
|
635
|
-
if (process.env.TAMAGUI_TARGET === 'web') {
|
|
636
|
-
const style = animationStyles ?? splitStyles.style
|
|
637
|
-
|
|
638
|
-
if (isAnimatedReactNativeWeb) {
|
|
639
|
-
viewProps.style = style
|
|
640
|
-
} else if (isReactNative) {
|
|
641
|
-
const rnwStyle = { $$css: true }
|
|
642
|
-
for (const name of className.split(' ')) {
|
|
643
|
-
rnwStyle[name] = name
|
|
644
|
-
}
|
|
645
|
-
viewProps.style = [rnwStyle, ...(Array.isArray(style) ? style : [style])]
|
|
646
|
-
|
|
647
|
-
if (process.env.NODE_ENV === 'development') {
|
|
648
|
-
// turn debug data- props into dataSet in dev mode
|
|
649
|
-
Object.keys(viewProps).forEach((key) => {
|
|
650
|
-
if (key.startsWith('data-')) {
|
|
651
|
-
viewProps.dataSet ??= {}
|
|
652
|
-
viewProps.dataSet[key.replace('data-', '')] = viewProps[key]
|
|
653
|
-
delete viewProps[key]
|
|
654
|
-
}
|
|
655
|
-
})
|
|
656
|
-
}
|
|
657
|
-
} else {
|
|
658
|
-
viewProps.className = className
|
|
659
|
-
viewProps.style = style
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
if (process.env.TAMAGUI_TARGET === 'native') {
|
|
664
|
-
// swap out the right family based on weight/style
|
|
665
|
-
if (splitStyles.fontFamily) {
|
|
666
|
-
const faceInfo = tamaguiConfig.fontsParsed[splitStyles.fontFamily]?.face
|
|
667
|
-
if (faceInfo) {
|
|
668
|
-
const [weight, style] = (() => {
|
|
669
|
-
let weight: string | undefined
|
|
670
|
-
let style: string | undefined
|
|
671
|
-
for (let i = styles.length; i >= 0; i--) {
|
|
672
|
-
weight ??= styles[i]?.fontWeight
|
|
673
|
-
style ??= styles[i]?.fontStyle
|
|
674
|
-
}
|
|
675
|
-
return [weight || '400', style || 'normal'] as const
|
|
676
|
-
})()
|
|
677
|
-
const overrideFace = faceInfo[weight]?.[style]?.val
|
|
678
|
-
if (overrideFace) {
|
|
679
|
-
for (const style of styles) {
|
|
680
|
-
if (style?.fontFamily) {
|
|
681
|
-
style.fontFamily = overrideFace
|
|
682
|
-
style.fontWeight = undefined
|
|
683
|
-
style.fontStyle = undefined
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
// assign styles
|
|
691
|
-
viewProps.style = styles
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
const runtimePressStyle = !disabled && noClassNames && pseudos?.pressStyle
|
|
695
|
-
const attachPress = Boolean(
|
|
696
|
-
runtimePressStyle || onPress || onPressOut || onPressIn || onClick
|
|
697
|
-
)
|
|
698
|
-
const runtimeHoverStyle = !disabled && noClassNames && pseudos?.hoverStyle
|
|
699
|
-
const isHoverable =
|
|
700
|
-
isWeb &&
|
|
701
|
-
!!(runtimeHoverStyle || onHoverIn || onHoverOut || onMouseEnter || onMouseLeave)
|
|
702
|
-
|
|
703
|
-
const handlesPressEvents = !(isWeb || asChild)
|
|
704
|
-
|
|
705
|
-
// check presence rather than value to prevent reparenting bugs
|
|
706
|
-
// allows for onPress={x ? function : undefined} without re-ordering dom
|
|
707
|
-
const shouldAttach = Boolean(
|
|
708
|
-
attachPress ||
|
|
709
|
-
isHoverable ||
|
|
710
|
-
(noClassNames && 'pressStyle' in props) ||
|
|
711
|
-
(isWeb && noClassNames && 'hoverStyle' in props)
|
|
712
|
-
)
|
|
713
|
-
|
|
714
|
-
const events =
|
|
715
|
-
shouldAttach && !isRSC && !isDisabled && !asChild
|
|
716
|
-
? {
|
|
717
|
-
onPressOut: attachPress
|
|
718
|
-
? (e) => {
|
|
719
|
-
unPress()
|
|
720
|
-
onPressOut?.(e)
|
|
721
|
-
onMouseUp?.(e)
|
|
722
|
-
}
|
|
723
|
-
: undefined,
|
|
724
|
-
...(isHoverable && {
|
|
725
|
-
onMouseEnter: isHoverable
|
|
726
|
-
? (e) => {
|
|
727
|
-
const next: Partial<typeof state> = {}
|
|
728
|
-
if (isHoverable) {
|
|
729
|
-
next.hover = true
|
|
730
|
-
}
|
|
731
|
-
if (state.pressIn) {
|
|
732
|
-
next.press = true
|
|
733
|
-
}
|
|
734
|
-
if (isHoverable || state.pressIn) {
|
|
735
|
-
setStateShallow(next)
|
|
736
|
-
}
|
|
737
|
-
onHoverIn?.(e)
|
|
738
|
-
onMouseEnter?.(e)
|
|
739
|
-
}
|
|
740
|
-
: undefined,
|
|
741
|
-
onMouseLeave: isHoverable
|
|
742
|
-
? (e) => {
|
|
743
|
-
const next: Partial<typeof state> = {}
|
|
744
|
-
mouseUps.add(unPress)
|
|
745
|
-
if (isHoverable) {
|
|
746
|
-
next.hover = false
|
|
747
|
-
}
|
|
748
|
-
if (state.pressIn) {
|
|
749
|
-
next.press = false
|
|
750
|
-
next.pressIn = false
|
|
751
|
-
}
|
|
752
|
-
if (Object.keys(next).length) {
|
|
753
|
-
setStateShallow(next)
|
|
754
|
-
}
|
|
755
|
-
onHoverOut?.(e)
|
|
756
|
-
onMouseLeave?.(e)
|
|
757
|
-
}
|
|
758
|
-
: undefined,
|
|
759
|
-
}),
|
|
760
|
-
onPressIn: attachPress
|
|
761
|
-
? (e) => {
|
|
762
|
-
setStateShallow({
|
|
763
|
-
press: true,
|
|
764
|
-
pressIn: true,
|
|
765
|
-
hover: false,
|
|
766
|
-
})
|
|
767
|
-
onPressIn?.(e)
|
|
768
|
-
onMouseDown?.(e)
|
|
769
|
-
if (isWeb) {
|
|
770
|
-
mouseUps.add(unPress)
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
: undefined,
|
|
774
|
-
onPress: attachPress
|
|
775
|
-
? (e) => {
|
|
776
|
-
unPress()
|
|
777
|
-
// @ts-ignore
|
|
778
|
-
onClick?.(e)
|
|
779
|
-
onPress?.(e)
|
|
780
|
-
}
|
|
781
|
-
: undefined,
|
|
782
|
-
|
|
783
|
-
// replicating TouchableWithoutFeedback
|
|
784
|
-
...(!isWeb && {
|
|
785
|
-
cancelable: !props.rejectResponderTermination,
|
|
786
|
-
disabled: isDisabled,
|
|
787
|
-
hitSlop: props.hitSlop,
|
|
788
|
-
delayLongPress: props.delayLongPress,
|
|
789
|
-
delayPressIn: props.delayPressIn,
|
|
790
|
-
delayPressOut: props.delayPressOut,
|
|
791
|
-
focusable: viewProps.focusable ?? true,
|
|
792
|
-
minPressDuration: 0,
|
|
793
|
-
}),
|
|
794
|
-
}
|
|
795
|
-
: null
|
|
796
|
-
|
|
797
|
-
// EVENTS native
|
|
798
|
-
if (process.env.TAMAGUI_TARGET === 'native') {
|
|
799
|
-
// add focus events
|
|
800
|
-
const attachFocus = !!pseudos?.focusStyle
|
|
801
|
-
if (attachFocus) {
|
|
802
|
-
viewProps.onFocus = mergeEvent(viewProps.onFocus, () => {
|
|
803
|
-
setStateShallow({ focus: true })
|
|
804
|
-
})
|
|
805
|
-
viewProps.onBlur = mergeEvent(viewProps.onBlur, () => {
|
|
806
|
-
setStateShallow({ focus: false })
|
|
807
|
-
})
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
// use Pressability to get smooth unPress when you press + hold + move out
|
|
811
|
-
// only ever create once, use .configure() to update later
|
|
812
|
-
const pressability = usePressability(events ? { ...events, hitSlop } : {})
|
|
813
|
-
if (attachPress && events) {
|
|
814
|
-
for (const key in pressability) {
|
|
815
|
-
const og = props[key]
|
|
816
|
-
const val = pressability[key]
|
|
817
|
-
viewProps[key] =
|
|
818
|
-
og && !dontComposePressabilityKeys[key] ? composeEventHandlers(og, val) : val
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
const shouldReset = !!(themeShallow && themeState.isNewTheme)
|
|
824
|
-
if (shouldReset) {
|
|
825
|
-
stateRef.current.themeShallow = true
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
let content =
|
|
829
|
-
!children || asChild
|
|
830
|
-
? children
|
|
831
|
-
: spacedChildren({
|
|
832
|
-
separator,
|
|
833
|
-
children,
|
|
834
|
-
space,
|
|
835
|
-
direction: props.spaceDirection || 'both',
|
|
836
|
-
isZStack,
|
|
837
|
-
debug: debugProp,
|
|
838
|
-
})
|
|
839
|
-
|
|
840
|
-
if (asChild) {
|
|
841
|
-
elementType = Slot
|
|
842
|
-
viewProps = {
|
|
843
|
-
...viewProps,
|
|
844
|
-
onPress,
|
|
845
|
-
onPressIn,
|
|
846
|
-
onPressOut,
|
|
847
|
-
}
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
content = createElement(elementType, viewProps, content)
|
|
851
|
-
|
|
852
|
-
content = useThemedChildren(themeState, content, {
|
|
853
|
-
shallow: stateRef.current.themeShallow,
|
|
854
|
-
})
|
|
855
|
-
|
|
856
|
-
if (process.env.TAMAGUI_TARGET === 'web') {
|
|
857
|
-
if (events || isAnimatedReactNativeWeb) {
|
|
858
|
-
content = (
|
|
859
|
-
<span
|
|
860
|
-
className={`${isAnimatedReactNativeWeb ? className : ''} _dsp_contents`}
|
|
861
|
-
{...(events && {
|
|
862
|
-
onMouseEnter: events.onMouseEnter,
|
|
863
|
-
onMouseLeave: events.onMouseLeave,
|
|
864
|
-
onClick: events.onPress,
|
|
865
|
-
onMouseDown: events.onPressIn,
|
|
866
|
-
onMouseUp: events.onPressOut,
|
|
867
|
-
onTouchStart: events.onPressIn,
|
|
868
|
-
onTouchEnd: events.onPressOut,
|
|
869
|
-
})}
|
|
870
|
-
>
|
|
871
|
-
{content}
|
|
872
|
-
</span>
|
|
873
|
-
)
|
|
874
|
-
}
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
if (process.env.NODE_ENV === 'development' && process.env.DEBUG !== 'tamagui') {
|
|
878
|
-
if (debugProp) {
|
|
879
|
-
const element = typeof elementType === 'string' ? elementType : 'Component'
|
|
880
|
-
console.groupCollapsed(`render <${element} /> with props`, viewProps)
|
|
881
|
-
for (const key in viewProps) {
|
|
882
|
-
console.log(key, viewProps[key])
|
|
883
|
-
}
|
|
884
|
-
console.log('children', content)
|
|
885
|
-
console.groupEnd()
|
|
886
|
-
if (typeof window !== 'undefined') {
|
|
887
|
-
// prettier-ignore
|
|
888
|
-
console.log({ state, themeState, isAnimated, isAnimatedReactNativeWeb, tamaguiDefaultProps, viewProps, splitStyles, animationStyles, handlesPressEvents, isStringElement, classNamesIn: props.className?.split(' '), classNamesOut: viewProps.className?.split(' '), events, shouldAttach, styles, pseudos, content, shouldAvoidClasses, avoidClasses: avoidClassesWhileAnimating, animation: props.animation, style: splitStylesStyle, staticConfig, tamaguiConfig, shouldForcePseudo, classNamesFull: Object.fromEntries(Object.entries(classNames).map(([k, v]) => [v, getAllSelectors()[v]])) })
|
|
889
|
-
}
|
|
890
|
-
console.groupEnd()
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
|
|
894
|
-
return content
|
|
895
|
-
})
|
|
896
|
-
|
|
897
|
-
if (staticConfig.componentName) {
|
|
898
|
-
component.displayName = staticConfig.componentName
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
onConfiguredOnce((conf) => {
|
|
902
|
-
// one time only setup
|
|
903
|
-
if (!tamaguiConfig) {
|
|
904
|
-
tamaguiConfig = conf
|
|
905
|
-
|
|
906
|
-
if (tamaguiConfig.animations) {
|
|
907
|
-
AnimatedText = tamaguiConfig.animations.Text
|
|
908
|
-
AnimatedView = tamaguiConfig.animations.View
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
if (!initialTheme) {
|
|
912
|
-
const next = conf.themes[Object.keys(conf.themes)[0]]
|
|
913
|
-
initialTheme = proxyThemeVariables(next)
|
|
914
|
-
if (process.env.NODE_ENV === 'development') {
|
|
915
|
-
if (!initialTheme) {
|
|
916
|
-
console.log('Warning: Missing theme')
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
}
|
|
921
|
-
|
|
922
|
-
// per-component setup
|
|
923
|
-
// do this to make sure shorthands don't duplicate with.. longhands
|
|
924
|
-
mergeShorthands(staticConfig, tamaguiConfig)
|
|
925
|
-
|
|
926
|
-
let defaultPropsIn = staticConfig.defaultProps || {}
|
|
927
|
-
|
|
928
|
-
// because we run createTamagui after styled() defs, have to do some work here
|
|
929
|
-
// gather defaults props one time and merge downwards
|
|
930
|
-
// find last unprocessed and process
|
|
931
|
-
const parentNames = [...(staticConfig.parentNames || []), staticConfig.componentName]
|
|
932
|
-
|
|
933
|
-
if (tamaguiConfig.defaultProps && parentNames && staticConfig.componentName) {
|
|
934
|
-
defaultPropsIn = mergeConfigDefaultProps(
|
|
935
|
-
staticConfig.componentName,
|
|
936
|
-
defaultPropsIn,
|
|
937
|
-
tamaguiConfig.defaultProps,
|
|
938
|
-
parentNames,
|
|
939
|
-
tamaguiConfig
|
|
940
|
-
)
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
const debug = defaultPropsIn['debug']
|
|
944
|
-
|
|
945
|
-
// remove all classNames
|
|
946
|
-
const [ourProps, ourClassNames] = mergeProps(defaultPropsIn, {})
|
|
947
|
-
|
|
948
|
-
if (ourProps.tag) {
|
|
949
|
-
defaultTag = ourProps.tag
|
|
950
|
-
}
|
|
951
|
-
|
|
952
|
-
const noClassNames = !staticConfig.acceptsClassName
|
|
953
|
-
const { name, variants, defaultVariants, ...restProps } = ourProps
|
|
954
|
-
|
|
955
|
-
// must preserve prop order
|
|
956
|
-
// leave out className because we handle that already with initialSplitStyles.classNames
|
|
957
|
-
// otherwise it confuses variant functions getting className props
|
|
958
|
-
const [defaults, defaultsClassnames] = mergeProps(component.defaultProps as any, {
|
|
959
|
-
...defaultVariants,
|
|
960
|
-
...restProps,
|
|
961
|
-
})
|
|
962
|
-
|
|
963
|
-
// split - keep variables on props to be processed using theme values at runtime (native)
|
|
964
|
-
if (!isWeb) {
|
|
965
|
-
for (const key in staticConfig.defaultProps) {
|
|
966
|
-
const val = staticConfig.defaultProps[key]
|
|
967
|
-
if (validPseudoKeys[key]) continue
|
|
968
|
-
defaults[key] = val
|
|
969
|
-
}
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
// set to global
|
|
973
|
-
tamaguiDefaultProps = defaults
|
|
974
|
-
|
|
975
|
-
// add debug logs
|
|
976
|
-
if (process.env.NODE_ENV === 'development' && debug) {
|
|
977
|
-
if (process.env.IS_STATIC !== 'is_static') {
|
|
978
|
-
console.log(`🐛 [${staticConfig.componentName || 'Component'}]`, {
|
|
979
|
-
staticConfig,
|
|
980
|
-
tamaguiDefaultProps,
|
|
981
|
-
defaults,
|
|
982
|
-
defaultPropsIn,
|
|
983
|
-
defaultPropsKeyOrder: Object.keys(staticConfig.defaultProps),
|
|
984
|
-
defaultPropsInKeyOrder: Object.keys(defaultPropsIn).map((k) => [
|
|
985
|
-
k,
|
|
986
|
-
defaultPropsIn[k],
|
|
987
|
-
]),
|
|
988
|
-
ourProps,
|
|
989
|
-
ourClassNames,
|
|
990
|
-
defaultsClassnames,
|
|
991
|
-
defaultTag,
|
|
992
|
-
noClassNames,
|
|
993
|
-
})
|
|
994
|
-
}
|
|
995
|
-
}
|
|
996
|
-
})
|
|
997
|
-
|
|
998
|
-
let res: TamaguiComponent<ComponentPropTypes, Ref, BaseProps> = component as any
|
|
999
|
-
|
|
1000
|
-
if (configIn.memo) {
|
|
1001
|
-
res = memo(res) as any
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
res.staticConfig = {
|
|
1005
|
-
validStyles: staticConfig.validStyles || stylePropsView,
|
|
1006
|
-
...staticConfig,
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
// res.extractable HoC
|
|
1010
|
-
res.extractable = (Component: any, conf?: Partial<StaticConfig>) => {
|
|
1011
|
-
Component.staticConfig = extendStaticConfig(
|
|
1012
|
-
{
|
|
1013
|
-
Component,
|
|
1014
|
-
...conf,
|
|
1015
|
-
neverFlatten: true,
|
|
1016
|
-
defaultProps: {
|
|
1017
|
-
...Component.defaultProps,
|
|
1018
|
-
...conf?.defaultProps,
|
|
1019
|
-
},
|
|
1020
|
-
},
|
|
1021
|
-
res
|
|
1022
|
-
)
|
|
1023
|
-
return Component
|
|
1024
|
-
}
|
|
1025
|
-
|
|
1026
|
-
return res
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
|
-
// for elements to avoid spacing
|
|
1030
|
-
export const Unspaced = (props: { children?: any }) => {
|
|
1031
|
-
return props.children
|
|
1032
|
-
}
|
|
1033
|
-
Unspaced['isUnspaced'] = true
|
|
1034
|
-
|
|
1035
|
-
// dont used styled() here to avoid circular deps
|
|
1036
|
-
// keep inline to avoid circular deps
|
|
1037
|
-
|
|
1038
|
-
export const Spacer = createComponent<SpacerProps>({
|
|
1039
|
-
acceptsClassName: true,
|
|
1040
|
-
memo: true,
|
|
1041
|
-
componentName: 'Spacer',
|
|
1042
|
-
validStyles,
|
|
1043
|
-
|
|
1044
|
-
defaultProps: {
|
|
1045
|
-
...stackDefaultStyles,
|
|
1046
|
-
// avoid nesting issues
|
|
1047
|
-
tag: 'span',
|
|
1048
|
-
size: true,
|
|
1049
|
-
pointerEvents: 'none',
|
|
1050
|
-
},
|
|
1051
|
-
|
|
1052
|
-
variants: {
|
|
1053
|
-
size: {
|
|
1054
|
-
'...size': (size, { tokens }) => {
|
|
1055
|
-
size = size === true ? '$true' : size
|
|
1056
|
-
const sizePx = tokens.space[size] ?? size
|
|
1057
|
-
return {
|
|
1058
|
-
width: sizePx,
|
|
1059
|
-
height: sizePx,
|
|
1060
|
-
minWidth: sizePx,
|
|
1061
|
-
minHeight: sizePx,
|
|
1062
|
-
}
|
|
1063
|
-
},
|
|
1064
|
-
},
|
|
1065
|
-
|
|
1066
|
-
flex: {
|
|
1067
|
-
true: {
|
|
1068
|
-
flexGrow: 1,
|
|
1069
|
-
},
|
|
1070
|
-
},
|
|
1071
|
-
|
|
1072
|
-
direction: {
|
|
1073
|
-
horizontal: {
|
|
1074
|
-
height: 0,
|
|
1075
|
-
minHeight: 0,
|
|
1076
|
-
},
|
|
1077
|
-
vertical: {
|
|
1078
|
-
width: 0,
|
|
1079
|
-
minWidth: 0,
|
|
1080
|
-
},
|
|
1081
|
-
both: {},
|
|
1082
|
-
},
|
|
1083
|
-
} as const,
|
|
1084
|
-
})
|
|
1085
|
-
|
|
1086
|
-
export type SpacedChildrenProps = {
|
|
1087
|
-
isZStack?: boolean
|
|
1088
|
-
children?: React.ReactNode
|
|
1089
|
-
space?: SpaceTokens | number | null
|
|
1090
|
-
spaceFlex?: boolean | number
|
|
1091
|
-
direction?: SpaceDirection
|
|
1092
|
-
separator?: React.ReactNode
|
|
1093
|
-
debug?: DebugProp
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
export function spacedChildren(props: SpacedChildrenProps) {
|
|
1097
|
-
const { isZStack, children, space, direction, spaceFlex, separator } = props
|
|
1098
|
-
const hasSpace = !!(space || spaceFlex)
|
|
1099
|
-
const hasSeparator = !(separator === undefined || separator === null)
|
|
1100
|
-
if (!(hasSpace || hasSeparator || isZStack)) {
|
|
1101
|
-
return children
|
|
1102
|
-
}
|
|
1103
|
-
|
|
1104
|
-
const childrenList = Children.toArray(children)
|
|
1105
|
-
|
|
1106
|
-
const len = childrenList.length
|
|
1107
|
-
if (len <= 1 && !isZStack && !childrenList[0]?.['type']?.['shouldForwardSpace']) {
|
|
1108
|
-
return childrenList
|
|
1109
|
-
}
|
|
1110
|
-
|
|
1111
|
-
const final: React.ReactNode[] = []
|
|
1112
|
-
for (let [index, child] of childrenList.entries()) {
|
|
1113
|
-
const isEmpty =
|
|
1114
|
-
child === null ||
|
|
1115
|
-
child === undefined ||
|
|
1116
|
-
(Array.isArray(child) && child.length === 0)
|
|
1117
|
-
|
|
1118
|
-
// forward space
|
|
1119
|
-
if (!isEmpty && React.isValidElement(child) && child.type?.['shouldForwardSpace']) {
|
|
1120
|
-
child = React.cloneElement(child, {
|
|
1121
|
-
space,
|
|
1122
|
-
spaceFlex,
|
|
1123
|
-
separator,
|
|
1124
|
-
key: child.key,
|
|
1125
|
-
} as any)
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
// push them all, but wrap some in Fragment
|
|
1129
|
-
if (isEmpty || !child || (child['key'] && !isZStack)) {
|
|
1130
|
-
final.push(child)
|
|
1131
|
-
} else {
|
|
1132
|
-
final.push(
|
|
1133
|
-
<Fragment key={index}>
|
|
1134
|
-
{isZStack ? <AbsoluteFill>{child}</AbsoluteFill> : child}
|
|
1135
|
-
</Fragment>
|
|
1136
|
-
)
|
|
1137
|
-
}
|
|
1138
|
-
|
|
1139
|
-
// first child unspaced avoid insert space
|
|
1140
|
-
if (isUnspaced(child) && index === 0) continue
|
|
1141
|
-
// no spacing on ZStack
|
|
1142
|
-
if (isZStack) continue
|
|
1143
|
-
|
|
1144
|
-
const next = childrenList[index + 1]
|
|
1145
|
-
|
|
1146
|
-
if (next && !isUnspaced(next)) {
|
|
1147
|
-
if (separator) {
|
|
1148
|
-
if (hasSpace) {
|
|
1149
|
-
final.push(
|
|
1150
|
-
createSpacer({
|
|
1151
|
-
key: `_${index}_00tmgui`,
|
|
1152
|
-
direction,
|
|
1153
|
-
space,
|
|
1154
|
-
spaceFlex,
|
|
1155
|
-
})
|
|
1156
|
-
)
|
|
1157
|
-
}
|
|
1158
|
-
final.push(
|
|
1159
|
-
React.isValidElement(separator)
|
|
1160
|
-
? React.cloneElement(separator, { key: `sep_${index}` })
|
|
1161
|
-
: separator
|
|
1162
|
-
)
|
|
1163
|
-
if (hasSpace) {
|
|
1164
|
-
final.push(
|
|
1165
|
-
createSpacer({
|
|
1166
|
-
key: `_${index}01tmgui`,
|
|
1167
|
-
direction,
|
|
1168
|
-
space,
|
|
1169
|
-
spaceFlex,
|
|
1170
|
-
})
|
|
1171
|
-
)
|
|
1172
|
-
}
|
|
1173
|
-
} else {
|
|
1174
|
-
final.push(
|
|
1175
|
-
createSpacer({
|
|
1176
|
-
key: `_${index}02tmgui`,
|
|
1177
|
-
direction,
|
|
1178
|
-
space,
|
|
1179
|
-
spaceFlex,
|
|
1180
|
-
})
|
|
1181
|
-
)
|
|
1182
|
-
}
|
|
1183
|
-
}
|
|
1184
|
-
}
|
|
1185
|
-
|
|
1186
|
-
if (process.env.NODE_ENV === 'development') {
|
|
1187
|
-
if (props.debug) {
|
|
1188
|
-
console.log(` Spaced children`, final, props)
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
|
|
1192
|
-
return final
|
|
1193
|
-
}
|
|
1194
|
-
|
|
1195
|
-
type CreateSpacerProps = SpacedChildrenProps & { key: string }
|
|
1196
|
-
|
|
1197
|
-
function createSpacer({ key, direction, space, spaceFlex }: CreateSpacerProps) {
|
|
1198
|
-
return (
|
|
1199
|
-
// @ts-ignore this one blew up but the types seem better
|
|
1200
|
-
<Spacer
|
|
1201
|
-
key={key}
|
|
1202
|
-
size={space}
|
|
1203
|
-
direction={direction}
|
|
1204
|
-
{...(typeof spaceFlex !== 'undefined' && {
|
|
1205
|
-
flex: spaceFlex === true ? 1 : spaceFlex === false ? 0 : spaceFlex,
|
|
1206
|
-
})}
|
|
1207
|
-
/>
|
|
1208
|
-
)
|
|
1209
|
-
}
|
|
1210
|
-
|
|
1211
|
-
function isUnspaced(child: React.ReactNode) {
|
|
1212
|
-
// console.log('unspaced?', child, getMedia())
|
|
1213
|
-
return child?.['type']?.['isVisuallyHidden'] || child?.['type']?.['isUnspaced']
|
|
1214
|
-
}
|
|
1215
|
-
|
|
1216
|
-
const DefaultProps = new Map()
|
|
1217
|
-
|
|
1218
|
-
function mergeConfigDefaultProps(
|
|
1219
|
-
name: string,
|
|
1220
|
-
props: Record<string, any>,
|
|
1221
|
-
configDefaults: Record<string, Object>,
|
|
1222
|
-
parentNames: (string | undefined)[],
|
|
1223
|
-
conf: TamaguiInternalConfig
|
|
1224
|
-
) {
|
|
1225
|
-
const len = parentNames.length
|
|
1226
|
-
let prev
|
|
1227
|
-
|
|
1228
|
-
for (let i = 0; i < len; i++) {
|
|
1229
|
-
const n = parentNames[i]
|
|
1230
|
-
if (!n) continue
|
|
1231
|
-
if (DefaultProps.has(n)) {
|
|
1232
|
-
prev = DefaultProps.get(n)
|
|
1233
|
-
continue
|
|
1234
|
-
}
|
|
1235
|
-
const props = configDefaults[n]
|
|
1236
|
-
if (!props) {
|
|
1237
|
-
if (prev) {
|
|
1238
|
-
DefaultProps.set(n, prev)
|
|
1239
|
-
}
|
|
1240
|
-
continue
|
|
1241
|
-
}
|
|
1242
|
-
prev = mergeProps(prev || {}, props, false, conf.inverseShorthands)[0]
|
|
1243
|
-
DefaultProps.set(n, prev)
|
|
1244
|
-
}
|
|
1245
|
-
|
|
1246
|
-
// overwrite the user defined defaults on top of internal defined defaults
|
|
1247
|
-
const ourDefaultsMerged = DefaultProps.get(name)
|
|
1248
|
-
if (ourDefaultsMerged) {
|
|
1249
|
-
return mergeProps(props, ourDefaultsMerged, false, conf.inverseShorthands)[0]
|
|
1250
|
-
}
|
|
1251
|
-
return props
|
|
1252
|
-
}
|
|
1253
|
-
|
|
1254
|
-
// react native compat (web only)
|
|
1255
|
-
function usePlatformMethods(hostRef: RefObject<Element>) {
|
|
1256
|
-
useIsomorphicLayoutEffect(() => {
|
|
1257
|
-
const node = hostRef.current
|
|
1258
|
-
if (!node) return
|
|
1259
|
-
// @ts-ignore
|
|
1260
|
-
node.measure = (callback) => measureLayout(node, null, callback)
|
|
1261
|
-
// @ts-ignore
|
|
1262
|
-
node.measureLayout = (relativeToNode, success) =>
|
|
1263
|
-
measureLayout(node as HTMLElement, relativeToNode, success)
|
|
1264
|
-
// @ts-ignore
|
|
1265
|
-
node.measureInWindow = (callback) => {
|
|
1266
|
-
if (!node) return
|
|
1267
|
-
setTimeout(() => {
|
|
1268
|
-
const { height, left, top, width } = getRect(node as HTMLElement)!
|
|
1269
|
-
callback(left, top, width, height)
|
|
1270
|
-
}, 0)
|
|
1271
|
-
}
|
|
1272
|
-
}, [hostRef])
|
|
1273
|
-
}
|
|
1274
|
-
|
|
1275
|
-
const AbsoluteFill: any = createComponent({
|
|
1276
|
-
componentName: 'AbsoluteFill',
|
|
1277
|
-
defaultProps: {
|
|
1278
|
-
...stackDefaultStyles,
|
|
1279
|
-
flexDirection: 'column',
|
|
1280
|
-
position: 'absolute',
|
|
1281
|
-
top: 0,
|
|
1282
|
-
right: 0,
|
|
1283
|
-
bottom: 0,
|
|
1284
|
-
left: 0,
|
|
1285
|
-
pointerEvents: 'box-none',
|
|
1286
|
-
},
|
|
1287
|
-
})
|
|
1288
|
-
|
|
1289
|
-
const dontComposePressabilityKeys = {
|
|
1290
|
-
onClick: true,
|
|
1291
|
-
}
|