@tamagui/core 1.0.1-beta.19 → 1.0.1-beta.190
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Tamagui.js +14 -12
- package/dist/cjs/Tamagui.js.map +2 -2
- package/dist/cjs/addTheme.js +80 -0
- package/dist/cjs/addTheme.js.map +7 -0
- package/dist/cjs/{conf.js → config.js} +33 -19
- package/dist/cjs/config.js.map +7 -0
- package/dist/cjs/constants/constants.js +11 -23
- package/dist/cjs/constants/constants.js.map +2 -2
- package/dist/cjs/{helpers/nativeGestureHandler.js → constants/isDevTools.js} +8 -8
- package/dist/cjs/constants/isDevTools.js.map +7 -0
- package/dist/cjs/constants/platform.js +32 -16
- package/dist/cjs/constants/platform.js.map +2 -2
- package/dist/cjs/constants/platform.native.js +62 -0
- package/dist/cjs/constants/platform.native.js.map +7 -0
- package/dist/cjs/contexts/ButtonInsideButtonContext.js +1 -0
- package/dist/cjs/contexts/ButtonInsideButtonContext.js.map +1 -1
- package/dist/cjs/contexts/FontLanguageContext.js +30 -0
- package/dist/cjs/contexts/FontLanguageContext.js.map +7 -0
- package/dist/cjs/{views → contexts}/TextAncestorContext.js +11 -13
- package/dist/cjs/contexts/TextAncestorContext.js.map +7 -0
- package/dist/cjs/{ThemeContext.js → contexts/ThemeContext.js} +1 -0
- package/dist/cjs/contexts/ThemeContext.js.map +7 -0
- package/dist/cjs/createComponent.js +925 -484
- package/dist/cjs/createComponent.js.map +3 -3
- package/dist/cjs/createFont.js +5 -8
- package/dist/cjs/createFont.js.map +2 -2
- package/dist/cjs/createShorthands.js +1 -2
- package/dist/cjs/createShorthands.js.map +1 -1
- package/dist/cjs/createTamagui.js +129 -177
- package/dist/cjs/createTamagui.js.map +3 -3
- package/dist/cjs/createTheme.js +4 -2
- package/dist/cjs/createTheme.js.map +2 -2
- package/dist/cjs/createTokens.js +5 -25
- package/dist/cjs/createTokens.js.map +2 -2
- package/dist/cjs/createVariable.js +52 -28
- package/dist/cjs/createVariable.js.map +2 -2
- package/dist/cjs/createVariables.js +52 -0
- package/dist/cjs/createVariables.js.map +7 -0
- package/dist/cjs/helpers/RNComponents.js +12 -11
- package/dist/cjs/helpers/RNComponents.js.map +2 -2
- package/dist/cjs/{ThemeManager.js → helpers/ThemeManager.js} +54 -52
- package/dist/cjs/helpers/ThemeManager.js.map +7 -0
- package/dist/cjs/helpers/areEqualSets.js +3 -3
- package/dist/cjs/helpers/areEqualSets.js.map +1 -1
- package/dist/cjs/helpers/assignNativePropsToWeb.js +188 -0
- package/dist/cjs/helpers/assignNativePropsToWeb.js.map +7 -0
- package/dist/cjs/helpers/assignNativePropsToWeb.native.js +30 -0
- package/dist/cjs/helpers/assignNativePropsToWeb.native.js.map +7 -0
- package/dist/cjs/helpers/calc.js +71 -0
- package/dist/cjs/helpers/calc.js.map +7 -0
- package/dist/cjs/helpers/createMediaStyle.js +17 -9
- package/dist/cjs/helpers/createMediaStyle.js.map +2 -2
- package/dist/cjs/helpers/createPropMapper.js +268 -120
- package/dist/cjs/helpers/createPropMapper.js.map +2 -2
- package/dist/cjs/helpers/createShallowUpdate.js +14 -25
- package/dist/cjs/helpers/createShallowUpdate.js.map +2 -2
- package/dist/cjs/helpers/expandStyle.js +90 -0
- package/dist/cjs/helpers/expandStyle.js.map +7 -0
- package/dist/cjs/helpers/expandStyles.js +115 -0
- package/dist/cjs/helpers/expandStyles.js.map +7 -0
- package/dist/cjs/helpers/extendStaticConfig.js +49 -37
- package/dist/cjs/helpers/extendStaticConfig.js.map +2 -2
- package/dist/cjs/helpers/fixNativeShadow.js +3 -3
- package/dist/cjs/helpers/fixNativeShadow.js.map +1 -1
- package/dist/cjs/helpers/getAnimationDriver.js +32 -0
- package/dist/cjs/helpers/getAnimationDriver.js.map +7 -0
- package/dist/cjs/helpers/getExpandedShorthands.js +4 -5
- package/dist/cjs/helpers/getExpandedShorthands.js.map +2 -2
- package/dist/cjs/helpers/{getTextSize.js → getFont.js} +22 -12
- package/dist/cjs/helpers/getFont.js.map +7 -0
- package/dist/cjs/helpers/getFontLanguage.js +29 -0
- package/dist/cjs/helpers/getFontLanguage.js.map +7 -0
- package/dist/cjs/helpers/getSize.js +19 -10
- package/dist/cjs/helpers/getSize.js.map +2 -2
- package/dist/cjs/helpers/getSplitStyles.js +381 -208
- package/dist/cjs/helpers/getSplitStyles.js.map +3 -3
- package/dist/cjs/helpers/getStackSize.js +46 -0
- package/dist/cjs/helpers/getStackSize.js.map +7 -0
- package/dist/cjs/helpers/getStylesAtomic.js +199 -133
- package/dist/cjs/helpers/getStylesAtomic.js.map +3 -3
- package/dist/cjs/helpers/getStylesAtomic.native.js +1 -2
- package/dist/cjs/helpers/getStylesAtomic.native.js.map +1 -1
- package/dist/cjs/helpers/getThemeCSSRules.js +103 -0
- package/dist/cjs/helpers/getThemeCSSRules.js.map +7 -0
- package/dist/cjs/{nativeGestureHandler.native.js → helpers/getThemeCSSRules.native.js} +18 -5
- package/dist/cjs/helpers/getThemeCSSRules.native.js.map +7 -0
- package/dist/cjs/helpers/getVariantExtras.js +88 -0
- package/dist/cjs/helpers/getVariantExtras.js.map +7 -0
- package/dist/cjs/helpers/insertStyleRule.js +87 -52
- package/dist/cjs/helpers/insertStyleRule.js.map +3 -3
- package/dist/cjs/helpers/isObj.js +2 -2
- package/dist/cjs/helpers/isObj.js.map +1 -1
- package/dist/cjs/helpers/isTamaguiComponent.js +37 -0
- package/dist/cjs/helpers/isTamaguiComponent.js.map +7 -0
- package/dist/cjs/helpers/isTamaguiElement.js +5 -5
- package/dist/cjs/helpers/isTamaguiElement.js.map +2 -2
- package/dist/cjs/helpers/matchMedia.js +7 -6
- package/dist/cjs/helpers/matchMedia.js.map +2 -2
- package/dist/cjs/helpers/matchMedia.native.js +6 -3
- package/dist/cjs/helpers/matchMedia.native.js.map +2 -2
- package/dist/cjs/helpers/mergeProps.js +54 -0
- package/dist/cjs/helpers/mergeProps.js.map +7 -0
- package/dist/cjs/helpers/mergeTransform.js +42 -0
- package/dist/cjs/helpers/mergeTransform.js.map +7 -0
- package/dist/cjs/helpers/normalizeColor.js +80 -0
- package/dist/cjs/helpers/normalizeColor.js.map +7 -0
- package/dist/cjs/helpers/normalizeValueWithProperty.js +93 -0
- package/dist/cjs/helpers/normalizeValueWithProperty.js.map +7 -0
- package/dist/cjs/helpers/proxyThemeVariables.js +7 -4
- package/dist/cjs/helpers/proxyThemeVariables.js.map +2 -2
- package/dist/cjs/helpers/pseudoDescriptors.js +42 -0
- package/dist/cjs/helpers/pseudoDescriptors.js.map +7 -0
- package/dist/cjs/helpers/registerCSSVariable.js +40 -0
- package/dist/cjs/helpers/registerCSSVariable.js.map +7 -0
- package/dist/cjs/helpers/{wrapThemeManagerContext.js → startTransition.js} +12 -15
- package/dist/cjs/helpers/startTransition.js.map +7 -0
- package/dist/cjs/helpers/themeable.js +17 -40
- package/dist/cjs/helpers/themeable.js.map +3 -3
- package/dist/cjs/helpers/themes.js +79 -0
- package/dist/cjs/helpers/themes.js.map +7 -0
- package/dist/cjs/helpers/useShallowSetState.js +44 -0
- package/dist/cjs/helpers/useShallowSetState.js.map +7 -0
- package/dist/cjs/helpers/validate.js +1 -122
- package/dist/cjs/helpers/validate.js.map +3 -3
- package/dist/cjs/helpers/withStaticProperties.js +3 -3
- package/dist/cjs/helpers/withStaticProperties.js.map +1 -1
- package/dist/cjs/hooks/getThemeUnwrapped.js +39 -0
- package/dist/cjs/hooks/getThemeUnwrapped.js.map +7 -0
- package/dist/cjs/hooks/useConstant.js +4 -2
- package/dist/cjs/hooks/useConstant.js.map +2 -2
- package/dist/cjs/hooks/useDidFinishSSR.js +60 -0
- package/dist/cjs/hooks/useDidFinishSSR.js.map +7 -0
- package/dist/cjs/hooks/useId.js +3 -33
- package/dist/cjs/hooks/useId.js.map +2 -2
- package/dist/cjs/hooks/useIsMounted.js +3 -4
- package/dist/cjs/hooks/useIsMounted.js.map +2 -2
- package/dist/cjs/hooks/useIsSSR.js +46 -0
- package/dist/cjs/hooks/useIsSSR.js.map +7 -0
- package/dist/cjs/hooks/useIsTouchDevice.js +11 -9
- package/dist/cjs/hooks/useIsTouchDevice.js.map +2 -2
- package/dist/cjs/hooks/useMedia.js +162 -113
- package/dist/cjs/hooks/useMedia.js.map +3 -3
- package/dist/cjs/hooks/usePressable.js +4 -18
- package/dist/cjs/hooks/usePressable.js.map +1 -1
- package/dist/cjs/hooks/useSafeRef.js +60 -0
- package/dist/cjs/hooks/useSafeRef.js.map +7 -0
- package/dist/cjs/hooks/useServerHooks.js +36 -0
- package/dist/cjs/hooks/useServerHooks.js.map +7 -0
- package/dist/cjs/hooks/useTheme.js +166 -132
- package/dist/cjs/hooks/useTheme.js.map +3 -3
- package/dist/cjs/hooks/useUnmountEffect.js +1 -2
- package/dist/cjs/hooks/useUnmountEffect.js.map +1 -1
- package/dist/cjs/index.js +59 -21
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/injectStyles.js +40 -0
- package/dist/cjs/injectStyles.js.map +7 -0
- package/dist/cjs/insertFont.js +93 -0
- package/dist/cjs/insertFont.js.map +7 -0
- package/dist/cjs/static.js +22 -15
- package/dist/cjs/static.js.map +2 -2
- package/dist/cjs/styled.js +47 -44
- package/dist/cjs/styled.js.map +2 -2
- package/dist/cjs/types-rnw.js +1 -0
- package/dist/cjs/types-rnw.js.map +2 -2
- package/dist/cjs/types.js +1 -0
- package/dist/cjs/types.js.map +2 -2
- package/dist/cjs/updateTheme.js +47 -0
- package/dist/cjs/updateTheme.js.map +7 -0
- package/dist/cjs/vendor/Pressability.js +32 -0
- package/dist/cjs/vendor/Pressability.js.map +7 -0
- package/dist/cjs/vendor/Pressability.native.js +32 -0
- package/dist/cjs/vendor/Pressability.native.js.map +7 -0
- package/dist/cjs/views/FontLanguage.js +38 -0
- package/dist/cjs/views/FontLanguage.js.map +7 -0
- package/dist/cjs/views/FontLanguage.native.js +38 -0
- package/dist/cjs/views/FontLanguage.native.js.map +7 -0
- package/dist/cjs/{helpers/nativeGestureHandler.native.js → views/FontLanguage.types.js} +4 -5
- package/dist/cjs/views/FontLanguage.types.js.map +7 -0
- package/dist/cjs/views/Slot.js +63 -65
- package/dist/cjs/views/Slot.js.map +2 -2
- package/dist/cjs/views/Stack.js +4 -19
- package/dist/cjs/views/Stack.js.map +1 -1
- package/dist/cjs/views/TamaguiProvider.js +82 -0
- package/dist/cjs/views/TamaguiProvider.js.map +7 -0
- package/dist/cjs/views/Text.js +28 -29
- package/dist/cjs/views/Text.js.map +2 -2
- package/dist/cjs/views/Theme.js +43 -21
- package/dist/cjs/views/Theme.js.map +3 -3
- package/dist/cjs/views/ThemeInverse.js +25 -25
- package/dist/cjs/views/ThemeInverse.js.map +2 -2
- package/dist/cjs/views/ThemeProvider.js +35 -23
- package/dist/cjs/views/ThemeProvider.js.map +3 -3
- package/dist/cjs/views/ThemeReset.js +18 -12
- package/dist/cjs/views/ThemeReset.js.map +3 -3
- package/dist/esm/Tamagui.js +8 -11
- package/dist/esm/Tamagui.js.map +2 -2
- package/dist/esm/addTheme.js +56 -0
- package/dist/esm/addTheme.js.map +7 -0
- package/dist/esm/config.js +45 -0
- package/dist/esm/config.js.map +7 -0
- package/dist/esm/constants/constants.js +2 -2
- package/dist/esm/constants/constants.js.map +2 -2
- package/dist/esm/constants/isDevTools.js +5 -0
- package/dist/esm/constants/isDevTools.js.map +7 -0
- package/dist/esm/constants/platform.js +25 -12
- package/dist/esm/constants/platform.js.map +2 -2
- package/dist/esm/constants/platform.native.js +28 -0
- package/dist/esm/constants/platform.native.js.map +7 -0
- package/dist/esm/contexts/ButtonInsideButtonContext.js +0 -0
- package/dist/esm/contexts/ButtonInsideButtonContext.js.map +1 -1
- package/dist/esm/contexts/FontLanguageContext.js +6 -0
- package/dist/esm/contexts/FontLanguageContext.js.map +7 -0
- package/dist/esm/contexts/TextAncestorContext.js +17 -0
- package/dist/esm/contexts/TextAncestorContext.js.map +7 -0
- package/dist/esm/{ThemeContext.js → contexts/ThemeContext.js} +0 -0
- package/dist/esm/contexts/ThemeContext.js.map +7 -0
- package/dist/esm/createComponent.js +891 -389
- package/dist/esm/createComponent.js.map +3 -3
- package/dist/esm/createFont.js +4 -9
- package/dist/esm/createFont.js.map +2 -2
- package/dist/esm/createShorthands.js +0 -3
- package/dist/esm/createShorthands.js.map +1 -1
- package/dist/esm/createTamagui.js +128 -158
- package/dist/esm/createTamagui.js.map +3 -3
- package/dist/esm/createTheme.js +3 -3
- package/dist/esm/createTheme.js.map +2 -2
- package/dist/esm/createTokens.js +3 -24
- package/dist/esm/createTokens.js.map +2 -2
- package/dist/esm/createVariable.js +47 -26
- package/dist/esm/createVariable.js.map +2 -2
- package/dist/esm/createVariables.js +28 -0
- package/dist/esm/createVariables.js.map +7 -0
- package/dist/esm/helpers/RNComponents.js +11 -8
- package/dist/esm/helpers/RNComponents.js.map +2 -2
- package/dist/esm/{ThemeManager.js → helpers/ThemeManager.js} +53 -53
- package/dist/esm/helpers/ThemeManager.js.map +7 -0
- package/dist/esm/helpers/areEqualSets.js +2 -4
- package/dist/esm/helpers/areEqualSets.js.map +1 -1
- package/dist/esm/helpers/assignNativePropsToWeb.js +164 -0
- package/dist/esm/helpers/assignNativePropsToWeb.js.map +7 -0
- package/dist/esm/helpers/assignNativePropsToWeb.native.js +6 -0
- package/dist/esm/helpers/assignNativePropsToWeb.native.js.map +7 -0
- package/dist/esm/helpers/calc.js +47 -0
- package/dist/esm/helpers/calc.js.map +7 -0
- package/dist/esm/helpers/createMediaStyle.js +16 -10
- package/dist/esm/helpers/createMediaStyle.js.map +2 -2
- package/dist/esm/helpers/createPropMapper.js +263 -121
- package/dist/esm/helpers/createPropMapper.js.map +2 -2
- package/dist/esm/helpers/createShallowUpdate.js +13 -12
- package/dist/esm/helpers/createShallowUpdate.js.map +2 -2
- package/dist/esm/helpers/expandStyle.js +66 -0
- package/dist/esm/helpers/expandStyle.js.map +7 -0
- package/dist/esm/helpers/expandStyles.js +89 -0
- package/dist/esm/helpers/expandStyles.js.map +7 -0
- package/dist/esm/helpers/extendStaticConfig.js +35 -28
- package/dist/esm/helpers/extendStaticConfig.js.map +2 -2
- package/dist/esm/helpers/fixNativeShadow.js +2 -4
- package/dist/esm/helpers/fixNativeShadow.js.map +1 -1
- package/dist/esm/helpers/getAnimationDriver.js +8 -0
- package/dist/esm/helpers/getAnimationDriver.js.map +7 -0
- package/dist/esm/helpers/getExpandedShorthands.js +2 -5
- package/dist/esm/helpers/getExpandedShorthands.js.map +2 -2
- package/dist/esm/helpers/{getTextSize.js → getFont.js} +17 -9
- package/dist/esm/helpers/getFont.js.map +7 -0
- package/dist/esm/helpers/getFontLanguage.js +5 -0
- package/dist/esm/helpers/getFontLanguage.js.map +7 -0
- package/dist/esm/helpers/getSize.js +16 -10
- package/dist/esm/helpers/getSize.js.map +2 -2
- package/dist/esm/helpers/getSplitStyles.js +364 -188
- package/dist/esm/helpers/getSplitStyles.js.map +3 -3
- package/dist/esm/helpers/getStackSize.js +22 -0
- package/dist/esm/helpers/getStackSize.js.map +7 -0
- package/dist/esm/helpers/getStylesAtomic.js +187 -108
- package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
- package/dist/esm/helpers/getStylesAtomic.native.js +0 -3
- package/dist/esm/helpers/getStylesAtomic.native.js.map +1 -1
- package/dist/esm/helpers/getThemeCSSRules.js +79 -0
- package/dist/esm/helpers/getThemeCSSRules.js.map +7 -0
- package/dist/esm/helpers/getThemeCSSRules.native.js +7 -0
- package/dist/esm/helpers/getThemeCSSRules.native.js.map +7 -0
- package/dist/esm/helpers/getVariantExtras.js +63 -0
- package/dist/esm/helpers/getVariantExtras.js.map +7 -0
- package/dist/esm/helpers/insertStyleRule.js +82 -50
- package/dist/esm/helpers/insertStyleRule.js.map +3 -3
- package/dist/esm/helpers/isObj.js +1 -3
- package/dist/esm/helpers/isObj.js.map +1 -1
- package/dist/esm/helpers/isTamaguiComponent.js +13 -0
- package/dist/esm/helpers/isTamaguiComponent.js.map +7 -0
- package/dist/esm/helpers/isTamaguiElement.js +4 -6
- package/dist/esm/helpers/isTamaguiElement.js.map +2 -2
- package/dist/esm/helpers/matchMedia.js +6 -7
- package/dist/esm/helpers/matchMedia.js.map +2 -2
- package/dist/esm/helpers/matchMedia.native.js +1 -3
- package/dist/esm/helpers/matchMedia.native.js.map +1 -1
- package/dist/esm/helpers/mergeProps.js +30 -0
- package/dist/esm/helpers/mergeProps.js.map +7 -0
- package/dist/esm/helpers/mergeTransform.js +17 -0
- package/dist/esm/helpers/mergeTransform.js.map +7 -0
- package/dist/esm/helpers/normalizeColor.js +49 -0
- package/dist/esm/helpers/normalizeColor.js.map +7 -0
- package/dist/esm/helpers/normalizeValueWithProperty.js +69 -0
- package/dist/esm/helpers/normalizeValueWithProperty.js.map +7 -0
- package/dist/esm/helpers/proxyThemeVariables.js +6 -5
- package/dist/esm/helpers/proxyThemeVariables.js.map +2 -2
- package/dist/esm/helpers/pseudoDescriptors.js +18 -0
- package/dist/esm/helpers/pseudoDescriptors.js.map +7 -0
- package/dist/esm/helpers/registerCSSVariable.js +14 -0
- package/dist/esm/helpers/registerCSSVariable.js.map +7 -0
- package/dist/esm/helpers/startTransition.js +6 -0
- package/dist/esm/helpers/startTransition.js.map +7 -0
- package/dist/esm/helpers/themeable.js +11 -9
- package/dist/esm/helpers/themeable.js.map +2 -2
- package/dist/esm/helpers/themes.js +54 -0
- package/dist/esm/helpers/themes.js.map +7 -0
- package/dist/esm/helpers/useShallowSetState.js +20 -0
- package/dist/esm/helpers/useShallowSetState.js.map +7 -0
- package/dist/esm/helpers/validate.js +0 -75
- package/dist/esm/helpers/validate.js.map +3 -3
- package/dist/esm/helpers/withStaticProperties.js +2 -4
- package/dist/esm/helpers/withStaticProperties.js.map +1 -1
- package/dist/esm/hooks/getThemeUnwrapped.js +14 -0
- package/dist/esm/hooks/getThemeUnwrapped.js.map +7 -0
- package/dist/esm/hooks/useConstant.js +4 -4
- package/dist/esm/hooks/useConstant.js.map +2 -2
- package/dist/esm/hooks/useDidFinishSSR.js +35 -0
- package/dist/esm/hooks/useDidFinishSSR.js.map +7 -0
- package/dist/esm/hooks/useId.js +1 -31
- package/dist/esm/hooks/useId.js.map +2 -2
- package/dist/esm/hooks/useIsMounted.js +1 -4
- package/dist/esm/hooks/useIsMounted.js.map +2 -2
- package/dist/esm/hooks/useIsSSR.js +22 -0
- package/dist/esm/hooks/useIsSSR.js.map +7 -0
- package/dist/esm/hooks/useIsTouchDevice.js +10 -10
- package/dist/esm/hooks/useIsTouchDevice.js.map +2 -2
- package/dist/esm/hooks/useMedia.js +157 -103
- package/dist/esm/hooks/useMedia.js.map +3 -3
- package/dist/esm/hooks/usePressable.js +2 -4
- package/dist/esm/hooks/usePressable.js.map +1 -1
- package/dist/esm/hooks/useSafeRef.js +36 -0
- package/dist/esm/hooks/useSafeRef.js.map +7 -0
- package/dist/esm/hooks/useServerHooks.js +11 -0
- package/dist/esm/hooks/useServerHooks.js.map +7 -0
- package/dist/esm/hooks/useTheme.js +159 -109
- package/dist/esm/hooks/useTheme.js.map +3 -3
- package/dist/esm/hooks/useUnmountEffect.js +0 -3
- package/dist/esm/hooks/useUnmountEffect.js.map +1 -1
- package/dist/esm/index.js +51 -13
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/injectStyles.js +16 -0
- package/dist/esm/injectStyles.js.map +7 -0
- package/dist/esm/insertFont.js +67 -0
- package/dist/esm/insertFont.js.map +7 -0
- package/dist/esm/static.js +15 -15
- package/dist/esm/static.js.map +2 -2
- package/dist/esm/styled.js +40 -12
- package/dist/esm/styled.js.map +2 -2
- package/dist/esm/types-rnw.js +0 -0
- package/dist/esm/types-rnw.js.map +0 -0
- package/dist/esm/types.js +0 -0
- package/dist/esm/types.js.map +0 -0
- package/dist/esm/updateTheme.js +23 -0
- package/dist/esm/updateTheme.js.map +7 -0
- package/dist/esm/vendor/Pressability.js +7 -0
- package/dist/esm/vendor/Pressability.js.map +7 -0
- package/dist/esm/vendor/Pressability.native.js +7 -0
- package/dist/esm/vendor/Pressability.native.js.map +7 -0
- package/dist/esm/views/FontLanguage.js +14 -0
- package/dist/esm/views/FontLanguage.js.map +7 -0
- package/dist/esm/views/FontLanguage.native.js +14 -0
- package/dist/esm/views/FontLanguage.native.js.map +7 -0
- package/dist/esm/views/FontLanguage.types.js +1 -0
- package/dist/{cjs/defaultComponentState.js.map → esm/views/FontLanguage.types.js.map} +0 -0
- package/dist/esm/views/Slot.js +50 -32
- package/dist/esm/views/Slot.js.map +2 -2
- package/dist/esm/views/Stack.js +0 -0
- package/dist/esm/views/Stack.js.map +1 -1
- package/dist/esm/views/TamaguiProvider.js +52 -0
- package/dist/esm/views/TamaguiProvider.js.map +7 -0
- package/dist/esm/views/Text.js +13 -5
- package/dist/esm/views/Text.js.map +2 -2
- package/dist/esm/views/Theme.js +35 -19
- package/dist/esm/views/Theme.js.map +3 -3
- package/dist/esm/views/ThemeInverse.js +22 -20
- package/dist/esm/views/ThemeInverse.js.map +2 -2
- package/dist/esm/views/ThemeProvider.js +28 -21
- package/dist/esm/views/ThemeProvider.js.map +2 -2
- package/dist/esm/views/ThemeReset.js +13 -12
- package/dist/esm/views/ThemeReset.js.map +2 -2
- package/package.json +48 -16
- package/reset.css +25 -4
- package/src/Tamagui.ts +44 -0
- package/src/addTheme.ts +67 -0
- package/src/config.ts +45 -0
- package/src/constants/constants.ts +15 -0
- package/src/constants/isDevTools.ts +6 -0
- package/src/constants/platform.native.ts +14 -0
- package/src/constants/platform.ts +41 -0
- package/src/contexts/ButtonInsideButtonContext.tsx +3 -0
- package/src/contexts/FontLanguageContext.tsx +5 -0
- package/src/contexts/TextAncestorContext.tsx +10 -0
- package/src/contexts/ThemeContext.tsx +5 -0
- package/src/createComponent.tsx +1599 -0
- package/src/createFont.ts +29 -0
- package/src/createShorthands.ts +5 -0
- package/src/createTamagui.ts +229 -0
- package/src/createTheme.ts +13 -0
- package/src/createTokens.ts +35 -0
- package/src/createVariable.ts +85 -0
- package/src/createVariables.ts +42 -0
- package/src/helpers/RNComponents.tsx +14 -0
- package/src/helpers/ThemeManager.tsx +235 -0
- package/src/helpers/areEqualSets.tsx +9 -0
- package/src/helpers/assignNativePropsToWeb.native.tsx +1 -0
- package/src/helpers/assignNativePropsToWeb.tsx +178 -0
- package/src/helpers/calc.ts +68 -0
- package/src/helpers/createMediaStyle.ts +48 -0
- package/src/helpers/createPropMapper.ts +523 -0
- package/src/helpers/expandStyle.ts +81 -0
- package/src/helpers/expandStyles.ts +106 -0
- package/src/helpers/extendStaticConfig.ts +76 -0
- package/src/helpers/fixNativeShadow.tsx +2 -0
- package/src/helpers/getAnimationDriver.tsx +5 -0
- package/src/helpers/getExpandedShorthands.ts +15 -0
- package/src/helpers/getFont.tsx +43 -0
- package/src/helpers/getFontLanguage.ts +2 -0
- package/src/helpers/getSize.ts +22 -0
- package/src/helpers/getSplitStyles.tsx +738 -0
- package/src/helpers/getStackSize.ts +22 -0
- package/src/helpers/getStylesAtomic.native.ts +3 -0
- package/src/helpers/getStylesAtomic.ts +292 -0
- package/src/helpers/getThemeCSSRules.native.ts +3 -0
- package/src/helpers/getThemeCSSRules.ts +105 -0
- package/src/helpers/getVariantExtras.tsx +84 -0
- package/src/helpers/insertStyleRule.tsx +150 -0
- package/src/helpers/isObj.ts +1 -0
- package/src/helpers/isTamaguiComponent.tsx +15 -0
- package/src/helpers/isTamaguiElement.tsx +12 -0
- package/src/helpers/matchMedia.native.ts +6 -0
- package/src/helpers/matchMedia.ts +16 -0
- package/src/helpers/mergeProps.ts +56 -0
- package/src/helpers/mergeTransform.ts +16 -0
- package/src/helpers/normalizeColor.ts +53 -0
- package/src/helpers/normalizeValueWithProperty.ts +80 -0
- package/src/helpers/proxyThemeVariables.tsx +18 -0
- package/src/helpers/pseudoDescriptors.ts +18 -0
- package/src/helpers/registerCSSVariable.ts +11 -0
- package/src/helpers/startTransition.ts +4 -0
- package/src/helpers/themeable.tsx +45 -0
- package/src/helpers/themes.ts +69 -0
- package/src/helpers/useShallowSetState.tsx +20 -0
- package/src/helpers/validate.ts +80 -0
- package/src/helpers/withStaticProperties.tsx +7 -0
- package/src/hooks/getThemeUnwrapped.tsx +8 -0
- package/src/hooks/useConstant.tsx +19 -0
- package/src/hooks/useId.tsx +1 -0
- package/src/hooks/useIsMounted.ts +16 -0
- package/src/hooks/useIsTouchDevice.tsx +20 -0
- package/src/hooks/useMedia.tsx +266 -0
- package/src/hooks/usePressable.tsx +9 -0
- package/src/hooks/useSafeRef.ts +49 -0
- package/src/hooks/useServerHooks.tsx +12 -0
- package/src/hooks/useTheme.tsx +299 -0
- package/src/hooks/useUnmountEffect.ts +5 -0
- package/src/index.ts +83 -0
- package/src/injectStyles.ts +20 -0
- package/src/insertFont.ts +70 -0
- package/src/static.ts +15 -0
- package/src/styled.tsx +198 -0
- package/src/types-rnw.tsx +162 -0
- package/src/types.tsx +1307 -0
- package/src/updateTheme.ts +23 -0
- package/src/vendor/Pressability.native.tsx +3 -0
- package/src/vendor/Pressability.tsx +2 -0
- package/src/views/FontLanguage.native.tsx +9 -0
- package/src/views/FontLanguage.tsx +18 -0
- package/src/views/FontLanguage.types.ts +13 -0
- package/src/views/Slot.tsx +151 -0
- package/src/views/Stack.tsx +24 -0
- package/src/views/TamaguiProvider.tsx +56 -0
- package/src/views/Text.tsx +79 -0
- package/src/views/Theme.tsx +72 -0
- package/src/views/ThemeInverse.tsx +33 -0
- package/src/views/ThemeProvider.tsx +63 -0
- package/src/views/ThemeReset.tsx +43 -0
- package/types/Tamagui.d.ts +6 -8
- package/types/addTheme.d.ts +11 -0
- package/types/conf.d.ts +4 -5
- package/types/config.d.ts +47 -0
- package/types/constants/constants.d.ts +1 -1
- package/types/constants/isDevTools.d.ts +2 -0
- package/types/constants/platform.d.ts +7 -6
- package/types/constants/platform.native.d.ts +13 -0
- package/types/contexts/FontLanguageContext.d.ts +5 -0
- package/types/{views → contexts}/TextAncestorContext.d.ts +0 -0
- package/types/{ThemeContext.d.ts → contexts/ThemeContext.d.ts} +1 -1
- package/types/createComponent.d.ts +32 -15
- package/types/createComponent.server.d.ts +36 -0
- package/types/createTamagui.d.ts +2 -17
- package/types/createTheme.d.ts +1 -1
- package/types/createTokens.d.ts +5 -6
- package/types/createVariable.d.ts +24 -12
- package/types/createVariables.d.ts +10 -0
- package/types/helpers/RNComponents.d.ts +1 -1
- package/types/helpers/ThemeManager.d.ts +46 -0
- package/types/helpers/assignNativePropsToWeb.d.ts +2 -0
- package/types/helpers/assignNativePropsToWeb.native.d.ts +2 -0
- package/types/helpers/calc.d.ts +17 -0
- package/types/helpers/createMediaStyle.d.ts +2 -4
- package/types/helpers/createPropMapper.d.ts +6 -3
- package/types/helpers/createShallowUpdate.d.ts +1 -2
- package/types/helpers/cssHash.d.ts +2 -0
- package/types/helpers/expandStyle.d.ts +6 -0
- package/types/helpers/expandStyles.d.ts +26 -0
- package/types/helpers/getAnimationDriver.d.ts +6 -0
- package/types/helpers/getFont.d.ts +3 -0
- package/types/helpers/getFontLanguage.d.ts +2 -0
- package/types/helpers/getSize.d.ts +3 -2
- package/types/helpers/getSplitStyles.d.ts +16 -9
- package/types/helpers/getStackSize.d.ts +8 -0
- package/types/helpers/getStylesAtomic.d.ts +17 -22
- package/types/helpers/getThemeCSSRules.d.ts +8 -0
- package/types/helpers/getThemeCSSRules.native.d.ts +2 -0
- package/types/helpers/getVariantExtras.d.ts +5 -0
- package/types/helpers/insertStyleRule.d.ts +7 -3
- package/types/helpers/isTamaguiComponent.d.ts +5 -0
- package/types/helpers/isTamaguiElement.d.ts +5 -1
- package/types/helpers/matchMedia.d.ts +1 -1
- package/types/helpers/mergeProps.d.ts +17 -0
- package/types/helpers/mergeTransform.d.ts +7 -0
- package/types/helpers/normalizeColor.d.ts +3 -0
- package/types/helpers/normalizeValueWithProperty.d.ts +6 -0
- package/types/helpers/pseudoDescriptors.d.ts +16 -0
- package/types/helpers/registerCSSVariable.d.ts +5 -0
- package/types/helpers/startTransition.d.ts +3 -0
- package/types/helpers/themes.d.ts +4 -0
- package/types/helpers/useAnimationDriver.d.ts +1 -0
- package/types/helpers/useShallowSetState.d.ts +3 -0
- package/types/helpers/validate.d.ts +0 -3
- package/types/hooks/getThemeUnwrapped.d.ts +3 -0
- package/types/hooks/useAnimationDriver.d.ts +1 -0
- package/types/hooks/useDidFinishSSR.d.ts +3 -0
- package/types/hooks/useFeatures.d.ts +10 -5
- package/types/hooks/useId.d.ts +1 -8
- package/types/hooks/useIsSSR.d.ts +4 -0
- package/types/hooks/useMedia.d.ts +20 -6
- package/types/hooks/useSafeRef.d.ts +4 -0
- package/types/hooks/useServerContext.d.ts +2 -0
- package/types/hooks/useServerHooks.d.ts +4 -0
- package/types/hooks/useTheme.d.ts +21 -31
- package/types/index.d.ts +29 -9
- package/types/injectStyles.d.ts +7 -0
- package/types/insertFont.d.ts +9 -0
- package/types/static.d.ts +2 -15
- package/types/styled.d.ts +7 -3
- package/types/types.d.ts +277 -77
- package/types/updateTheme.d.ts +9 -0
- package/types/vendor/Pressability.d.ts +3 -0
- package/types/vendor/Pressability.native.d.ts +3 -0
- package/types/views/FontLanguage.d.ts +4 -0
- package/types/views/FontLanguage.native.d.ts +4 -0
- package/types/views/FontLanguage.types.d.ts +11 -0
- package/types/views/Slot.d.ts +1 -0
- package/types/views/TamaguiProvider.d.ts +4 -0
- package/types/views/Theme.d.ts +3 -9
- package/types/views/ThemeInverse.d.ts +4 -8
- package/types/views/ThemeProvider.d.ts +2 -1
- package/dist/cjs/ThemeContext.js.map +0 -7
- package/dist/cjs/ThemeManager.js.map +0 -7
- package/dist/cjs/conf.js.map +0 -7
- package/dist/cjs/constants/rnw.js +0 -46
- package/dist/cjs/constants/rnw.js.map +0 -7
- package/dist/cjs/defaultComponentState.js +0 -1
- package/dist/cjs/helpers/addStylesUsingClassname.js +0 -87
- package/dist/cjs/helpers/addStylesUsingClassname.js.map +0 -7
- package/dist/cjs/helpers/createTamaguiProvider.js +0 -93
- package/dist/cjs/helpers/createTamaguiProvider.js.map +0 -7
- package/dist/cjs/helpers/fixNativeShadow.native.js +0 -53
- package/dist/cjs/helpers/fixNativeShadow.native.js.map +0 -7
- package/dist/cjs/helpers/getButtonSize.js +0 -45
- package/dist/cjs/helpers/getButtonSize.js.map +0 -7
- package/dist/cjs/helpers/getTextSize.js.map +0 -7
- package/dist/cjs/helpers/nativeGestureHandler.js.map +0 -7
- package/dist/cjs/helpers/nativeGestureHandler.native.js.map +0 -7
- package/dist/cjs/helpers/wrapThemeManagerContext.js.map +0 -7
- package/dist/cjs/hooks/useFeatures.js +0 -228
- package/dist/cjs/hooks/useFeatures.js.map +0 -7
- package/dist/cjs/hooks/usePrevious.js +0 -1
- package/dist/cjs/hooks/usePrevious.js.map +0 -7
- package/dist/cjs/nativeGestureHandler.native.js.map +0 -7
- package/dist/cjs/views/TextAncestorContext.js.map +0 -7
- package/dist/esm/ThemeContext.js.map +0 -7
- package/dist/esm/ThemeManager.js.map +0 -7
- package/dist/esm/conf.js +0 -36
- package/dist/esm/conf.js.map +0 -7
- package/dist/esm/constants/rnw.js +0 -24
- package/dist/esm/constants/rnw.js.map +0 -7
- package/dist/esm/defaultComponentState.js +0 -1
- package/dist/esm/defaultComponentState.js.map +0 -7
- package/dist/esm/helpers/addStylesUsingClassname.js +0 -64
- package/dist/esm/helpers/addStylesUsingClassname.js.map +0 -7
- package/dist/esm/helpers/createTamaguiProvider.js +0 -40
- package/dist/esm/helpers/createTamaguiProvider.js.map +0 -7
- package/dist/esm/helpers/fixNativeShadow.native.js +0 -32
- package/dist/esm/helpers/fixNativeShadow.native.js.map +0 -7
- package/dist/esm/helpers/getButtonSize.js +0 -24
- package/dist/esm/helpers/getButtonSize.js.map +0 -7
- package/dist/esm/helpers/getTextSize.js.map +0 -7
- package/dist/esm/helpers/nativeGestureHandler.js +0 -7
- package/dist/esm/helpers/nativeGestureHandler.js.map +0 -7
- package/dist/esm/helpers/nativeGestureHandler.native.js +0 -2
- package/dist/esm/helpers/nativeGestureHandler.native.js.map +0 -7
- package/dist/esm/helpers/wrapThemeManagerContext.js +0 -14
- package/dist/esm/helpers/wrapThemeManagerContext.js.map +0 -7
- package/dist/esm/hooks/useFeatures.js +0 -173
- package/dist/esm/hooks/useFeatures.js.map +0 -7
- package/dist/esm/hooks/usePrevious.js +0 -1
- package/dist/esm/hooks/usePrevious.js.map +0 -7
- package/dist/esm/nativeGestureHandler.native.js +0 -2
- package/dist/esm/nativeGestureHandler.native.js.map +0 -7
- package/dist/esm/views/TextAncestorContext.js +0 -18
- package/dist/esm/views/TextAncestorContext.js.map +0 -7
- package/dist/jsx/Tamagui.js +0 -41
- package/dist/jsx/ThemeContext.js +0 -5
- package/dist/jsx/ThemeManager.js +0 -186
- package/dist/jsx/conf.js +0 -35
- package/dist/jsx/constants/constants.js +0 -17
- package/dist/jsx/constants/platform.js +0 -25
- package/dist/jsx/constants/rnw.js +0 -23
- package/dist/jsx/contexts/ButtonInsideButtonContext.js +0 -5
- package/dist/jsx/createComponent.js +0 -636
- package/dist/jsx/createFont.js +0 -27
- package/dist/jsx/createShorthands.js +0 -9
- package/dist/jsx/createTamagui.js +0 -201
- package/dist/jsx/createTheme.js +0 -6
- package/dist/jsx/createTokens.js +0 -28
- package/dist/jsx/createVariable.js +0 -48
- package/dist/jsx/defaultComponentState.js +0 -0
- package/dist/jsx/helpers/RNComponents.js +0 -11
- package/dist/jsx/helpers/addStylesUsingClassname.js +0 -63
- package/dist/jsx/helpers/areEqualSets.js +0 -15
- package/dist/jsx/helpers/createMediaStyle.js +0 -30
- package/dist/jsx/helpers/createPropMapper.js +0 -237
- package/dist/jsx/helpers/createShallowUpdate.js +0 -18
- package/dist/jsx/helpers/createTamaguiProvider.js +0 -34
- package/dist/jsx/helpers/extendStaticConfig.js +0 -61
- package/dist/jsx/helpers/fixNativeShadow.js +0 -7
- package/dist/jsx/helpers/fixNativeShadow.native.js +0 -31
- package/dist/jsx/helpers/getButtonSize.js +0 -23
- package/dist/jsx/helpers/getExpandedShorthands.js +0 -18
- package/dist/jsx/helpers/getSize.js +0 -12
- package/dist/jsx/helpers/getSplitStyles.js +0 -322
- package/dist/jsx/helpers/getStylesAtomic.js +0 -130
- package/dist/jsx/helpers/getStylesAtomic.native.js +0 -9
- package/dist/jsx/helpers/getTextSize.js +0 -33
- package/dist/jsx/helpers/insertStyleRule.js +0 -94
- package/dist/jsx/helpers/isObj.js +0 -6
- package/dist/jsx/helpers/isTamaguiElement.js +0 -10
- package/dist/jsx/helpers/matchMedia.js +0 -17
- package/dist/jsx/helpers/matchMedia.native.js +0 -8
- package/dist/jsx/helpers/nativeGestureHandler.js +0 -6
- package/dist/jsx/helpers/nativeGestureHandler.native.js +0 -1
- package/dist/jsx/helpers/proxyThemeVariables.js +0 -17
- package/dist/jsx/helpers/themeable.js +0 -24
- package/dist/jsx/helpers/validate.js +0 -75
- package/dist/jsx/helpers/withStaticProperties.js +0 -9
- package/dist/jsx/helpers/wrapThemeManagerContext.js +0 -10
- package/dist/jsx/hooks/useConstant.js +0 -14
- package/dist/jsx/hooks/useFeatures.js +0 -167
- package/dist/jsx/hooks/useId.js +0 -34
- package/dist/jsx/hooks/useIsMounted.js +0 -18
- package/dist/jsx/hooks/useIsTouchDevice.js +0 -16
- package/dist/jsx/hooks/useMedia.js +0 -158
- package/dist/jsx/hooks/usePressable.js +0 -13
- package/dist/jsx/hooks/usePrevious.js +0 -0
- package/dist/jsx/hooks/useTheme.js +0 -177
- package/dist/jsx/hooks/useUnmountEffect.js +0 -10
- package/dist/jsx/index.js +0 -54
- package/dist/jsx/nativeGestureHandler.native.js +0 -1
- package/dist/jsx/static.js +0 -16
- package/dist/jsx/styled.js +0 -47
- package/dist/jsx/types-rnw.js +0 -0
- package/dist/jsx/types.js +0 -0
- package/dist/jsx/views/Slot.js +0 -75
- package/dist/jsx/views/Stack.js +0 -12
- package/dist/jsx/views/Text.js +0 -56
- package/dist/jsx/views/TextAncestorContext.js +0 -15
- package/dist/jsx/views/Theme.js +0 -31
- package/dist/jsx/views/ThemeInverse.js +0 -27
- package/dist/jsx/views/ThemeProvider.js +0 -35
- package/dist/jsx/views/ThemeReset.js +0 -34
- package/types/Tamagui.d.ts.map +0 -1
- package/types/ThemeContext.d.ts.map +0 -1
- package/types/ThemeManager.d.ts +0 -49
- package/types/ThemeManager.d.ts.map +0 -1
- package/types/conf.d.ts.map +0 -1
- package/types/constants/constants.d.ts.map +0 -1
- package/types/constants/platform.d.ts.map +0 -1
- package/types/constants/rnw.d.ts +0 -2
- package/types/constants/rnw.d.ts.map +0 -1
- package/types/contexts/ButtonInsideButtonContext.d.ts.map +0 -1
- package/types/createComponent.d.ts.map +0 -1
- package/types/createFont.d.ts.map +0 -1
- package/types/createShorthands.d.ts.map +0 -1
- package/types/createTamagui.d.ts.map +0 -1
- package/types/createTheme.d.ts.map +0 -1
- package/types/createTokens.d.ts.map +0 -1
- package/types/createVariable.d.ts.map +0 -1
- package/types/defaultComponentState.d.ts +0 -1
- package/types/defaultComponentState.d.ts.map +0 -1
- package/types/helpers/RNComponents.d.ts.map +0 -1
- package/types/helpers/addStylesUsingClassname.d.ts +0 -3
- package/types/helpers/addStylesUsingClassname.d.ts.map +0 -1
- package/types/helpers/areEqualSets.d.ts.map +0 -1
- package/types/helpers/createMediaStyle.d.ts.map +0 -1
- package/types/helpers/createPropMapper.d.ts.map +0 -1
- package/types/helpers/createShallowUpdate.d.ts.map +0 -1
- package/types/helpers/createTamaguiProvider.d.ts +0 -7
- package/types/helpers/createTamaguiProvider.d.ts.map +0 -1
- package/types/helpers/extendStaticConfig.d.ts.map +0 -1
- package/types/helpers/fixNativeShadow.d.ts.map +0 -1
- package/types/helpers/fixNativeShadow.native.d.ts +0 -3
- package/types/helpers/fixNativeShadow.native.d.ts.map +0 -1
- package/types/helpers/getButtonSize.d.ts +0 -8
- package/types/helpers/getButtonSize.d.ts.map +0 -1
- package/types/helpers/getExpandedShorthands.d.ts.map +0 -1
- package/types/helpers/getSize.d.ts.map +0 -1
- package/types/helpers/getSplitStyles.d.ts.map +0 -1
- package/types/helpers/getStylesAtomic.d.ts.map +0 -1
- package/types/helpers/getStylesAtomic.native.d.ts.map +0 -1
- package/types/helpers/getTextSize.d.ts +0 -3
- package/types/helpers/getTextSize.d.ts.map +0 -1
- package/types/helpers/insertStyleRule.d.ts.map +0 -1
- package/types/helpers/isObj.d.ts.map +0 -1
- package/types/helpers/isTamaguiElement.d.ts.map +0 -1
- package/types/helpers/matchMedia.d.ts.map +0 -1
- package/types/helpers/matchMedia.native.d.ts.map +0 -1
- package/types/helpers/nativeGestureHandler.d.ts +0 -2
- package/types/helpers/nativeGestureHandler.d.ts.map +0 -1
- package/types/helpers/nativeGestureHandler.native.d.ts +0 -2
- package/types/helpers/nativeGestureHandler.native.d.ts.map +0 -1
- package/types/helpers/proxyThemeVariables.d.ts.map +0 -1
- package/types/helpers/themeable.d.ts.map +0 -1
- package/types/helpers/validate.d.ts.map +0 -1
- package/types/helpers/withStaticProperties.d.ts.map +0 -1
- package/types/helpers/wrapThemeManagerContext.d.ts +0 -3
- package/types/helpers/wrapThemeManagerContext.d.ts.map +0 -1
- package/types/hooks/useConstant.d.ts.map +0 -1
- package/types/hooks/useFeatures.d.ts.map +0 -1
- package/types/hooks/useId.d.ts.map +0 -1
- package/types/hooks/useIsMounted.d.ts.map +0 -1
- package/types/hooks/useIsTouchDevice.d.ts.map +0 -1
- package/types/hooks/useMedia.d.ts.map +0 -1
- package/types/hooks/usePressable.d.ts.map +0 -1
- package/types/hooks/usePrevious.d.ts +0 -1
- package/types/hooks/usePrevious.d.ts.map +0 -1
- package/types/hooks/useTheme.d.ts.map +0 -1
- package/types/hooks/useUnmountEffect.d.ts.map +0 -1
- package/types/index.d.ts.map +0 -1
- package/types/nativeGestureHandler.native.d.ts +0 -2
- package/types/nativeGestureHandler.native.d.ts.map +0 -1
- package/types/static.d.ts.map +0 -1
- package/types/styled.d.ts.map +0 -1
- package/types/types-rnw.d.ts.map +0 -1
- package/types/types.d.ts.map +0 -1
- package/types/views/Slot.d.ts.map +0 -1
- package/types/views/Stack.d.ts.map +0 -1
- package/types/views/Text.d.ts.map +0 -1
- package/types/views/TextAncestorContext.d.ts.map +0 -1
- package/types/views/Theme.d.ts.map +0 -1
- package/types/views/ThemeInverse.d.ts.map +0 -1
- package/types/views/ThemeProvider.d.ts.map +0 -1
- package/types/views/ThemeReset.d.ts.map +0 -1
|
@@ -0,0 +1,1599 @@
|
|
|
1
|
+
import { isClient, isRSC, isWeb, useIsomorphicLayoutEffect } from '@tamagui/constants'
|
|
2
|
+
/* eslint-disable react-hooks/rules-of-hooks */
|
|
3
|
+
import {
|
|
4
|
+
composeEventHandlers,
|
|
5
|
+
stylePropsView,
|
|
6
|
+
validPseudoKeys,
|
|
7
|
+
validStyles,
|
|
8
|
+
} from '@tamagui/helpers'
|
|
9
|
+
import {
|
|
10
|
+
useElementLayout,
|
|
11
|
+
useMergeRefs,
|
|
12
|
+
usePlatformMethods,
|
|
13
|
+
useResponderEvents,
|
|
14
|
+
} from '@tamagui/rnw'
|
|
15
|
+
import { useForceUpdate } from '@tamagui/use-force-update'
|
|
16
|
+
import React, {
|
|
17
|
+
Children,
|
|
18
|
+
Fragment,
|
|
19
|
+
createElement,
|
|
20
|
+
forwardRef,
|
|
21
|
+
memo,
|
|
22
|
+
useCallback,
|
|
23
|
+
useContext,
|
|
24
|
+
useEffect,
|
|
25
|
+
} from 'react'
|
|
26
|
+
import { Text, View, ViewStyle } from 'react-native'
|
|
27
|
+
|
|
28
|
+
import { getConfig, onConfiguredOnce } from './config'
|
|
29
|
+
import { stackDefaultStyles } from './constants/constants'
|
|
30
|
+
import { FontLanguageContext } from './contexts/FontLanguageContext'
|
|
31
|
+
import { TextAncestorContext } from './contexts/TextAncestorContext'
|
|
32
|
+
import { assignNativePropsToWeb } from './helpers/assignNativePropsToWeb'
|
|
33
|
+
import { getReturnVariablesAs } from './helpers/createPropMapper'
|
|
34
|
+
import { extendStaticConfig, parseStaticConfig } from './helpers/extendStaticConfig'
|
|
35
|
+
import {
|
|
36
|
+
SplitStyleResult,
|
|
37
|
+
getSubStyle,
|
|
38
|
+
insertSplitStyles,
|
|
39
|
+
useSplitStyles,
|
|
40
|
+
} from './helpers/getSplitStyles'
|
|
41
|
+
import { getAllSelectors } from './helpers/insertStyleRule'
|
|
42
|
+
import { mergeProps } from './helpers/mergeProps'
|
|
43
|
+
import { proxyThemeVariables } from './helpers/proxyThemeVariables'
|
|
44
|
+
import { useShallowSetState } from './helpers/useShallowSetState'
|
|
45
|
+
import { addMediaQueryListener, getInitialMediaState } from './hooks/useMedia'
|
|
46
|
+
import { usePressable } from './hooks/usePressable'
|
|
47
|
+
import { useServerRef, useServerState } from './hooks/useServerHooks'
|
|
48
|
+
import { getThemeManager, useTheme } from './hooks/useTheme'
|
|
49
|
+
import {
|
|
50
|
+
SpaceDirection,
|
|
51
|
+
SpaceTokens,
|
|
52
|
+
SpacerProps,
|
|
53
|
+
StaticConfig,
|
|
54
|
+
StaticConfigParsed,
|
|
55
|
+
StylableComponent,
|
|
56
|
+
TamaguiComponent,
|
|
57
|
+
TamaguiComponentState,
|
|
58
|
+
TamaguiConfig,
|
|
59
|
+
TamaguiElement,
|
|
60
|
+
TamaguiInternalConfig,
|
|
61
|
+
UseAnimationHook,
|
|
62
|
+
UseAnimationProps,
|
|
63
|
+
} from './types'
|
|
64
|
+
import { usePressability } from './vendor/Pressability'
|
|
65
|
+
import { Slot, mergeEvent } from './views/Slot'
|
|
66
|
+
import { wrapThemeManagerContext } from './views/Theme'
|
|
67
|
+
|
|
68
|
+
React['keep']
|
|
69
|
+
|
|
70
|
+
let defaultComponentState: TamaguiComponentState | null = null
|
|
71
|
+
|
|
72
|
+
export const mouseUps = new Set<Function>()
|
|
73
|
+
if (typeof document !== 'undefined') {
|
|
74
|
+
const cancelTouches = () => {
|
|
75
|
+
mouseUps.forEach((x) => x())
|
|
76
|
+
mouseUps.clear()
|
|
77
|
+
}
|
|
78
|
+
document.addEventListener('mouseup', cancelTouches)
|
|
79
|
+
document.addEventListener('touchend', cancelTouches)
|
|
80
|
+
document.addEventListener('touchcancel', cancelTouches)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// mutates
|
|
84
|
+
function mergeShorthands({ defaultProps }: StaticConfigParsed, { shorthands }: TamaguiConfig) {
|
|
85
|
+
// they are defined in correct order already { ...parent, ...child }
|
|
86
|
+
for (const key of Object.keys(defaultProps)) {
|
|
87
|
+
defaultProps[shorthands[key] || key] = defaultProps[key]
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
let initialTheme: any
|
|
92
|
+
let config: TamaguiInternalConfig
|
|
93
|
+
|
|
94
|
+
export function createComponent<
|
|
95
|
+
ComponentPropTypes extends Object = {},
|
|
96
|
+
Ref = TamaguiElement,
|
|
97
|
+
BaseProps = never
|
|
98
|
+
>(configIn: Partial<StaticConfig> | StaticConfigParsed, ParentComponent?: StylableComponent) {
|
|
99
|
+
const staticConfig = (() => {
|
|
100
|
+
const next = extendStaticConfig(configIn, ParentComponent)
|
|
101
|
+
if ('parsed' in next) {
|
|
102
|
+
return next
|
|
103
|
+
} else {
|
|
104
|
+
return parseStaticConfig(next)
|
|
105
|
+
}
|
|
106
|
+
})()
|
|
107
|
+
|
|
108
|
+
const defaultComponentClassName = `is_${staticConfig.componentName}`
|
|
109
|
+
let tamaguiConfig: TamaguiInternalConfig
|
|
110
|
+
let AnimatedText: any
|
|
111
|
+
let AnimatedView: any
|
|
112
|
+
let avoidClasses = true
|
|
113
|
+
let defaultNativeStyle: any
|
|
114
|
+
let tamaguiDefaultProps: any
|
|
115
|
+
let initialSplitStyles: SplitStyleResult
|
|
116
|
+
|
|
117
|
+
// see onConfiguredOnce below which attaches a name then to this component
|
|
118
|
+
const component = forwardRef<Ref, ComponentPropTypes>((propsIn: any, forwardedRef) => {
|
|
119
|
+
// React inserts default props after your props for some reason...
|
|
120
|
+
// order important so we do loops, you can't just spread because JS does weird things
|
|
121
|
+
let props: any
|
|
122
|
+
if (tamaguiDefaultProps && !propsIn.asChild) {
|
|
123
|
+
props = mergeProps(tamaguiDefaultProps, propsIn)[0]
|
|
124
|
+
} else {
|
|
125
|
+
props = propsIn
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const debugProp = props['debug']
|
|
129
|
+
|
|
130
|
+
const { Component, isText, isZStack } = staticConfig
|
|
131
|
+
const componentName = props.componentName || staticConfig.componentName
|
|
132
|
+
const componentClassName = props.asChild
|
|
133
|
+
? ''
|
|
134
|
+
: props.componentName
|
|
135
|
+
? `is_${props.componentName}`
|
|
136
|
+
: defaultComponentClassName
|
|
137
|
+
|
|
138
|
+
const forceUpdate = useForceUpdate()
|
|
139
|
+
config = config || getConfig()
|
|
140
|
+
const theme = useTheme(props.theme, componentName, props, forceUpdate)
|
|
141
|
+
|
|
142
|
+
const states = useServerState<TamaguiComponentState>(defaultComponentState!)
|
|
143
|
+
const state = propsIn.forceStyle ? { ...states[0], [propsIn.forceStyle]: true } : states[0]
|
|
144
|
+
|
|
145
|
+
const shouldAvoidClasses = !!(props.animation && avoidClasses) || !staticConfig.acceptsClassName
|
|
146
|
+
const shouldForcePseudo = !!propsIn.forceStyle
|
|
147
|
+
const hasTextAncestor = !!(isWeb && isText ? useContext(TextAncestorContext) : false)
|
|
148
|
+
const splitStyleState =
|
|
149
|
+
!shouldAvoidClasses && !shouldForcePseudo
|
|
150
|
+
? {
|
|
151
|
+
...state,
|
|
152
|
+
hasTextAncestor,
|
|
153
|
+
dynamicStylesInline: true,
|
|
154
|
+
}
|
|
155
|
+
: ({
|
|
156
|
+
...state,
|
|
157
|
+
noClassNames: true,
|
|
158
|
+
dynamicStylesInline: true,
|
|
159
|
+
hasTextAncestor,
|
|
160
|
+
resolveVariablesAs: 'value',
|
|
161
|
+
} as const)
|
|
162
|
+
|
|
163
|
+
const languageContext = isRSC ? null : useContext(FontLanguageContext)
|
|
164
|
+
|
|
165
|
+
const splitStyles = useSplitStyles(
|
|
166
|
+
props,
|
|
167
|
+
staticConfig,
|
|
168
|
+
theme,
|
|
169
|
+
splitStyleState,
|
|
170
|
+
props.asChild ? null : initialSplitStyles?.classNames,
|
|
171
|
+
languageContext || undefined,
|
|
172
|
+
debugProp
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
const hostRef = useServerRef<TamaguiElement>(null)
|
|
176
|
+
const setState = states[1]
|
|
177
|
+
const setStateShallow = useShallowSetState(setState)
|
|
178
|
+
|
|
179
|
+
if (process.env.NODE_ENV === 'development') {
|
|
180
|
+
if (!process.env.TAMAGUI_TARGET) {
|
|
181
|
+
// eslint-disable-next-line no-console
|
|
182
|
+
console.error(`No process.env.TAMAGUI_TARGET set, please set it to "native" or "web".`)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (debugProp) {
|
|
186
|
+
const name = `${
|
|
187
|
+
componentName || Component?.displayName || Component?.name || '[Unnamed Component]'
|
|
188
|
+
}`
|
|
189
|
+
const type = staticConfig.isReactNativeWeb ? 'rnw' : 'tamagui'
|
|
190
|
+
const banner = `${name} ${propsIn['data-is'] || ''} ${type}`
|
|
191
|
+
// eslint-disable-next-line no-console
|
|
192
|
+
console.group(`%c 🐛 ${banner}`, 'background: yellow;')
|
|
193
|
+
// eslint-disable-next-line no-console
|
|
194
|
+
console.groupCollapsed('initial props/state')
|
|
195
|
+
// eslint-disable-next-line no-console
|
|
196
|
+
console.log('props', propsIn)
|
|
197
|
+
// eslint-disable-next-line no-console
|
|
198
|
+
console.log('splitStyles', splitStyles)
|
|
199
|
+
// eslint-disable-next-line no-console
|
|
200
|
+
console.log('className', Object.values(splitStyles.classNames))
|
|
201
|
+
if (typeof window !== 'undefined') {
|
|
202
|
+
// eslint-disable-next-line no-console
|
|
203
|
+
console.log('ref', hostRef, '(click to view)')
|
|
204
|
+
}
|
|
205
|
+
// eslint-disable-next-line no-console
|
|
206
|
+
console.groupEnd()
|
|
207
|
+
if (debugProp === 'break') {
|
|
208
|
+
// eslint-disable-next-line no-debugger
|
|
209
|
+
debugger
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const {
|
|
215
|
+
viewProps: viewPropsIn,
|
|
216
|
+
pseudos,
|
|
217
|
+
medias,
|
|
218
|
+
style: splitStylesStyle,
|
|
219
|
+
classNames,
|
|
220
|
+
mediaKeys,
|
|
221
|
+
} = splitStyles
|
|
222
|
+
|
|
223
|
+
// media queries
|
|
224
|
+
useIsomorphicLayoutEffect(() => {
|
|
225
|
+
if (!mediaKeys.length) {
|
|
226
|
+
return
|
|
227
|
+
}
|
|
228
|
+
const disposers: any[] = []
|
|
229
|
+
for (const key of mediaKeys) {
|
|
230
|
+
disposers.push(
|
|
231
|
+
addMediaQueryListener(key, (next: boolean) => {
|
|
232
|
+
setState((prev) => {
|
|
233
|
+
if (prev.mediaState![key] !== next) {
|
|
234
|
+
return {
|
|
235
|
+
...prev,
|
|
236
|
+
mediaState: {
|
|
237
|
+
...prev.mediaState,
|
|
238
|
+
[key]: next,
|
|
239
|
+
},
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return prev
|
|
243
|
+
})
|
|
244
|
+
})
|
|
245
|
+
)
|
|
246
|
+
}
|
|
247
|
+
return () => {}
|
|
248
|
+
}, [mediaKeys.join(',')])
|
|
249
|
+
|
|
250
|
+
// animations
|
|
251
|
+
const useAnimations = tamaguiConfig?.animations?.useAnimations as UseAnimationHook | undefined
|
|
252
|
+
|
|
253
|
+
const nextIsAnimated = !!(useAnimations && props.animation)
|
|
254
|
+
// conditional but if ever true stays true
|
|
255
|
+
const isAnimated = nextIsAnimated || state.hasAnimation
|
|
256
|
+
if (nextIsAnimated && !state.hasAnimation) {
|
|
257
|
+
setStateShallow({ hasAnimation: true })
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
const animationFeatureStylesIn = props.animation
|
|
261
|
+
? { ...defaultNativeStyle, ...splitStylesStyle }
|
|
262
|
+
: null
|
|
263
|
+
const propsWithAnimation = props as UseAnimationProps
|
|
264
|
+
|
|
265
|
+
// lets make changing the key mandatory for adding/removing animations
|
|
266
|
+
// reason is animations are heavy no way around it, and must be run inline here (🙅 loading as a sub-component)
|
|
267
|
+
// because they need to sync update on first render. it's pretty rare too going to/from no animation => animation
|
|
268
|
+
// so requiring key change on animation change is least-bad option.
|
|
269
|
+
// plus, React use() may let us get away with conditional hooks soon :)
|
|
270
|
+
if (!isRSC && isAnimated && useAnimations) {
|
|
271
|
+
const animationState = useAnimations(propsWithAnimation, {
|
|
272
|
+
state,
|
|
273
|
+
pseudos,
|
|
274
|
+
onDidAnimate: props.onDidAnimate,
|
|
275
|
+
hostRef,
|
|
276
|
+
staticConfig,
|
|
277
|
+
getStyle({ isExiting, isEntering, exitVariant, enterVariant } = {}) {
|
|
278
|
+
// we have to merge such that transforms keys all exist
|
|
279
|
+
const style = animationFeatureStylesIn
|
|
280
|
+
|
|
281
|
+
const enterStyle = isEntering
|
|
282
|
+
? enterVariant && staticConfig.variants?.[enterVariant]['true']
|
|
283
|
+
? getSubStyle(
|
|
284
|
+
'',
|
|
285
|
+
staticConfig.variants?.[enterVariant]['true'],
|
|
286
|
+
staticConfig,
|
|
287
|
+
theme,
|
|
288
|
+
props,
|
|
289
|
+
state,
|
|
290
|
+
tamaguiConfig
|
|
291
|
+
) || pseudos.enterStyle
|
|
292
|
+
: pseudos.enterStyle
|
|
293
|
+
: null
|
|
294
|
+
|
|
295
|
+
const exitStyle = isExiting
|
|
296
|
+
? exitVariant && staticConfig.variants?.[exitVariant]['true']
|
|
297
|
+
? getSubStyle(
|
|
298
|
+
'',
|
|
299
|
+
staticConfig.variants?.[exitVariant]['true'],
|
|
300
|
+
staticConfig,
|
|
301
|
+
theme,
|
|
302
|
+
props,
|
|
303
|
+
state,
|
|
304
|
+
tamaguiConfig
|
|
305
|
+
) || pseudos.exitStyle
|
|
306
|
+
: pseudos.exitStyle
|
|
307
|
+
: null
|
|
308
|
+
|
|
309
|
+
// if you have hoverStyle={{ scale: 1.1 }} and don't have scale set on the base style
|
|
310
|
+
// no animation will run! this is really confusing. this will look at all variants,
|
|
311
|
+
// and fill in base styles if they don't exist. eg:
|
|
312
|
+
// input:
|
|
313
|
+
// base: {}
|
|
314
|
+
// hoverStyle: { scale: 2 }
|
|
315
|
+
// enterStyle: { x: 100 }
|
|
316
|
+
// output:
|
|
317
|
+
// base: { x: 0, scale: 1 }
|
|
318
|
+
ensureBaseHasDefaults(
|
|
319
|
+
style,
|
|
320
|
+
// enterStyle,
|
|
321
|
+
pseudos.hoverStyle,
|
|
322
|
+
pseudos.focusStyle,
|
|
323
|
+
pseudos.pressStyle,
|
|
324
|
+
pseudos.pressStyle
|
|
325
|
+
)
|
|
326
|
+
|
|
327
|
+
enterStyle && isEntering && merge(style, enterStyle)
|
|
328
|
+
state.hover && pseudos.hoverStyle && merge(style, pseudos.hoverStyle)
|
|
329
|
+
state.focus && pseudos.focusStyle && merge(style, pseudos.focusStyle)
|
|
330
|
+
state.press && pseudos.pressStyle && merge(style, pseudos.pressStyle)
|
|
331
|
+
exitStyle && isExiting && merge(style, exitStyle)
|
|
332
|
+
|
|
333
|
+
if (process.env.NODE_ENV === 'development') {
|
|
334
|
+
if (debugProp) {
|
|
335
|
+
// eslint-disable-next-line no-console
|
|
336
|
+
console.log('animation style', style)
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
return style
|
|
341
|
+
},
|
|
342
|
+
//, delay
|
|
343
|
+
})
|
|
344
|
+
|
|
345
|
+
// must be properly memoized
|
|
346
|
+
if (animationState !== state.animation) {
|
|
347
|
+
setStateShallow({
|
|
348
|
+
animation: animationState,
|
|
349
|
+
})
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
const {
|
|
354
|
+
tag,
|
|
355
|
+
hitSlop,
|
|
356
|
+
asChild,
|
|
357
|
+
children,
|
|
358
|
+
onPress,
|
|
359
|
+
onPressIn,
|
|
360
|
+
onPressOut,
|
|
361
|
+
onHoverIn,
|
|
362
|
+
onHoverOut,
|
|
363
|
+
themeShallow,
|
|
364
|
+
space: spaceProp,
|
|
365
|
+
spaceDirection: _spaceDirection,
|
|
366
|
+
disabled: disabledProp,
|
|
367
|
+
onMouseUp,
|
|
368
|
+
onMouseDown,
|
|
369
|
+
onMouseEnter,
|
|
370
|
+
onMouseLeave,
|
|
371
|
+
hrefAttrs,
|
|
372
|
+
separator,
|
|
373
|
+
// ignore from here on out
|
|
374
|
+
forceStyle: _forceStyle,
|
|
375
|
+
// @ts-ignore for next/link compat etc
|
|
376
|
+
onClick,
|
|
377
|
+
theme: _themeProp,
|
|
378
|
+
// @ts-ignore
|
|
379
|
+
defaultVariants,
|
|
380
|
+
|
|
381
|
+
...nonTamaguiProps
|
|
382
|
+
} = viewPropsIn
|
|
383
|
+
|
|
384
|
+
// get the right component
|
|
385
|
+
const isTaggable = !Component || typeof Component === 'string'
|
|
386
|
+
|
|
387
|
+
// default to tag, fallback to component (when both strings)
|
|
388
|
+
const element = isWeb ? (isTaggable ? tag || Component : Component) : Component
|
|
389
|
+
const BaseTextComponent = !isWeb ? Text : element || 'span'
|
|
390
|
+
const BaseViewComponent = !isWeb ? View : element || (hasTextAncestor ? 'span' : 'div')
|
|
391
|
+
let elementType = isText
|
|
392
|
+
? (isAnimated ? AnimatedText || Text : null) || BaseTextComponent
|
|
393
|
+
: (isAnimated ? AnimatedView || View : null) || BaseViewComponent
|
|
394
|
+
|
|
395
|
+
elementType = Component || elementType
|
|
396
|
+
const isStringElement = typeof elementType === 'string'
|
|
397
|
+
|
|
398
|
+
const disabled =
|
|
399
|
+
(props.accessibilityState != null && props.accessibilityState.disabled === true) ||
|
|
400
|
+
props.accessibilityDisabled
|
|
401
|
+
|
|
402
|
+
// these can ultimately be for DOM, react-native-web views, or animated views
|
|
403
|
+
// so the type is pretty loose
|
|
404
|
+
let viewProps: Record<string, any>
|
|
405
|
+
|
|
406
|
+
const hasEnterStyle = !!props.enterStyle
|
|
407
|
+
const shouldSetMounted = Boolean(
|
|
408
|
+
(isWeb ? isClient : true) && (hasEnterStyle || props.animation) && !state.mounted
|
|
409
|
+
)
|
|
410
|
+
const setMounted = shouldSetMounted
|
|
411
|
+
? () => {
|
|
412
|
+
// for some reason without some small delay it doesn't animate css
|
|
413
|
+
setTimeout(
|
|
414
|
+
() => {
|
|
415
|
+
setStateShallow({
|
|
416
|
+
mounted: true,
|
|
417
|
+
})
|
|
418
|
+
},
|
|
419
|
+
isWeb ? 10 : 0
|
|
420
|
+
)
|
|
421
|
+
}
|
|
422
|
+
: undefined
|
|
423
|
+
|
|
424
|
+
// if react-native-web view just pass all props down
|
|
425
|
+
if (process.env.TAMAGUI_TARGET === 'web' && !staticConfig.isReactNativeWeb) {
|
|
426
|
+
// otherwise replicate react-native-web functionality
|
|
427
|
+
const {
|
|
428
|
+
// event props
|
|
429
|
+
onMoveShouldSetResponder,
|
|
430
|
+
onMoveShouldSetResponderCapture,
|
|
431
|
+
onResponderEnd,
|
|
432
|
+
onResponderGrant,
|
|
433
|
+
onResponderMove,
|
|
434
|
+
onResponderReject,
|
|
435
|
+
onResponderRelease,
|
|
436
|
+
onResponderStart,
|
|
437
|
+
onResponderTerminate,
|
|
438
|
+
onResponderTerminationRequest,
|
|
439
|
+
onScrollShouldSetResponder,
|
|
440
|
+
onScrollShouldSetResponderCapture,
|
|
441
|
+
onSelectionChangeShouldSetResponder,
|
|
442
|
+
onSelectionChangeShouldSetResponderCapture,
|
|
443
|
+
onStartShouldSetResponder,
|
|
444
|
+
onStartShouldSetResponderCapture,
|
|
445
|
+
|
|
446
|
+
// react-native props
|
|
447
|
+
nativeID,
|
|
448
|
+
|
|
449
|
+
// react-native-web accessibility props
|
|
450
|
+
// @ts-ignore
|
|
451
|
+
accessibilityActiveDescendant,
|
|
452
|
+
// @ts-ignore
|
|
453
|
+
accessibilityAtomic,
|
|
454
|
+
// @ts-ignore
|
|
455
|
+
accessibilityAutoComplete,
|
|
456
|
+
// @ts-ignore
|
|
457
|
+
accessibilityBusy,
|
|
458
|
+
// @ts-ignore
|
|
459
|
+
accessibilityChecked,
|
|
460
|
+
// @ts-ignore
|
|
461
|
+
accessibilityColumnCount,
|
|
462
|
+
// @ts-ignore
|
|
463
|
+
accessibilityColumnIndex,
|
|
464
|
+
// @ts-ignore
|
|
465
|
+
accessibilityColumnSpan,
|
|
466
|
+
// @ts-ignore
|
|
467
|
+
accessibilityControls,
|
|
468
|
+
// @ts-ignore
|
|
469
|
+
accessibilityCurrent,
|
|
470
|
+
// @ts-ignore
|
|
471
|
+
accessibilityDescribedBy,
|
|
472
|
+
// @ts-ignore
|
|
473
|
+
accessibilityDetails,
|
|
474
|
+
// @ts-ignore
|
|
475
|
+
accessibilityDisabled,
|
|
476
|
+
// @ts-ignore
|
|
477
|
+
accessibilityErrorMessage,
|
|
478
|
+
// @ts-ignore
|
|
479
|
+
accessibilityExpanded,
|
|
480
|
+
// @ts-ignore
|
|
481
|
+
accessibilityFlowTo,
|
|
482
|
+
// @ts-ignore
|
|
483
|
+
accessibilityHasPopup,
|
|
484
|
+
// @ts-ignore
|
|
485
|
+
accessibilityHidden,
|
|
486
|
+
// @ts-ignore
|
|
487
|
+
accessibilityInvalid,
|
|
488
|
+
// @ts-ignore
|
|
489
|
+
accessibilityKeyShortcuts,
|
|
490
|
+
// @ts-ignore
|
|
491
|
+
accessibilityLabel,
|
|
492
|
+
// @ts-ignore
|
|
493
|
+
accessibilityLabelledBy,
|
|
494
|
+
// @ts-ignore
|
|
495
|
+
accessibilityLevel,
|
|
496
|
+
// @ts-ignore
|
|
497
|
+
accessibilityLiveRegion,
|
|
498
|
+
// @ts-ignore
|
|
499
|
+
accessibilityModal,
|
|
500
|
+
// @ts-ignore
|
|
501
|
+
accessibilityMultiline,
|
|
502
|
+
// @ts-ignore
|
|
503
|
+
accessibilityMultiSelectable,
|
|
504
|
+
// @ts-ignore
|
|
505
|
+
accessibilityOrientation,
|
|
506
|
+
// @ts-ignore
|
|
507
|
+
accessibilityOwns,
|
|
508
|
+
// @ts-ignore
|
|
509
|
+
accessibilityPlaceholder,
|
|
510
|
+
// @ts-ignore
|
|
511
|
+
accessibilityPosInSet,
|
|
512
|
+
// @ts-ignore
|
|
513
|
+
accessibilityPressed,
|
|
514
|
+
// @ts-ignore
|
|
515
|
+
accessibilityReadOnly,
|
|
516
|
+
// @ts-ignore
|
|
517
|
+
accessibilityRequired,
|
|
518
|
+
// @ts-ignore
|
|
519
|
+
accessibilityRole,
|
|
520
|
+
// @ts-ignore
|
|
521
|
+
accessibilityRoleDescription,
|
|
522
|
+
// @ts-ignore
|
|
523
|
+
accessibilityRowCount,
|
|
524
|
+
// @ts-ignore
|
|
525
|
+
accessibilityRowIndex,
|
|
526
|
+
// @ts-ignore
|
|
527
|
+
accessibilityRowSpan,
|
|
528
|
+
// @ts-ignore
|
|
529
|
+
accessibilitySelected,
|
|
530
|
+
// @ts-ignore
|
|
531
|
+
accessibilitySetSize,
|
|
532
|
+
// @ts-ignore
|
|
533
|
+
accessibilitySort,
|
|
534
|
+
// @ts-ignore
|
|
535
|
+
accessibilityValueMax,
|
|
536
|
+
// @ts-ignore
|
|
537
|
+
accessibilityValueMin,
|
|
538
|
+
// @ts-ignore
|
|
539
|
+
accessibilityValueNow,
|
|
540
|
+
// @ts-ignore
|
|
541
|
+
accessibilityValueText,
|
|
542
|
+
|
|
543
|
+
// deprecated
|
|
544
|
+
accessible,
|
|
545
|
+
accessibilityState,
|
|
546
|
+
accessibilityValue,
|
|
547
|
+
|
|
548
|
+
// android
|
|
549
|
+
collapsable,
|
|
550
|
+
focusable,
|
|
551
|
+
|
|
552
|
+
onLayout,
|
|
553
|
+
|
|
554
|
+
...webProps
|
|
555
|
+
} = nonTamaguiProps
|
|
556
|
+
|
|
557
|
+
viewProps = webProps
|
|
558
|
+
|
|
559
|
+
assignNativePropsToWeb(elementType, viewProps, nonTamaguiProps)
|
|
560
|
+
|
|
561
|
+
if (!isRSC) {
|
|
562
|
+
useElementLayout(hostRef, onLayout)
|
|
563
|
+
|
|
564
|
+
// from react-native-web
|
|
565
|
+
useResponderEvents(hostRef, {
|
|
566
|
+
onMoveShouldSetResponder,
|
|
567
|
+
onMoveShouldSetResponderCapture,
|
|
568
|
+
onResponderEnd,
|
|
569
|
+
onResponderGrant,
|
|
570
|
+
onResponderMove,
|
|
571
|
+
onResponderReject,
|
|
572
|
+
onResponderRelease,
|
|
573
|
+
onResponderStart,
|
|
574
|
+
onResponderTerminate,
|
|
575
|
+
onResponderTerminationRequest,
|
|
576
|
+
onScrollShouldSetResponder,
|
|
577
|
+
onScrollShouldSetResponderCapture,
|
|
578
|
+
onSelectionChangeShouldSetResponder,
|
|
579
|
+
onSelectionChangeShouldSetResponderCapture,
|
|
580
|
+
onStartShouldSetResponder,
|
|
581
|
+
onStartShouldSetResponderCapture,
|
|
582
|
+
})
|
|
583
|
+
|
|
584
|
+
// from react-native-web
|
|
585
|
+
const platformMethodsRef = usePlatformMethods(viewProps)
|
|
586
|
+
|
|
587
|
+
const setRef = useMergeRefs(hostRef, platformMethodsRef, forwardedRef as any, setMounted)
|
|
588
|
+
|
|
589
|
+
viewProps.ref = setRef
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
if (props.href != undefined && hrefAttrs != undefined) {
|
|
593
|
+
const { download, rel, target } = hrefAttrs
|
|
594
|
+
if (download != null) {
|
|
595
|
+
viewProps.download = download
|
|
596
|
+
}
|
|
597
|
+
if (rel != null) {
|
|
598
|
+
viewProps.rel = rel
|
|
599
|
+
}
|
|
600
|
+
if (typeof target === 'string') {
|
|
601
|
+
viewProps.target = target.charAt(0) !== '_' ? '_' + target : target
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
// FOCUS
|
|
606
|
+
// "focusable" indicates that an element may be a keyboard tab-stop.
|
|
607
|
+
const _focusable = focusable != undefined ? focusable : accessible
|
|
608
|
+
const role = viewProps.role
|
|
609
|
+
if (_focusable === false) {
|
|
610
|
+
viewProps.tabIndex = '-1'
|
|
611
|
+
}
|
|
612
|
+
if (
|
|
613
|
+
// These native elements are focusable by default
|
|
614
|
+
elementType === 'a' ||
|
|
615
|
+
elementType === 'button' ||
|
|
616
|
+
elementType === 'input' ||
|
|
617
|
+
elementType === 'select' ||
|
|
618
|
+
elementType === 'textarea'
|
|
619
|
+
) {
|
|
620
|
+
if (_focusable === false || accessibilityDisabled === true) {
|
|
621
|
+
viewProps.tabIndex = '-1'
|
|
622
|
+
}
|
|
623
|
+
} else if (
|
|
624
|
+
// These roles are made focusable by default
|
|
625
|
+
role === 'button' ||
|
|
626
|
+
role === 'checkbox' ||
|
|
627
|
+
role === 'link' ||
|
|
628
|
+
role === 'radio' ||
|
|
629
|
+
role === 'textbox' ||
|
|
630
|
+
role === 'switch'
|
|
631
|
+
) {
|
|
632
|
+
if (_focusable !== false) {
|
|
633
|
+
viewProps.tabIndex = '0'
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
// Everything else must explicitly set the prop
|
|
637
|
+
if (_focusable === true) {
|
|
638
|
+
viewProps.tabIndex = '0'
|
|
639
|
+
}
|
|
640
|
+
} else {
|
|
641
|
+
viewProps = nonTamaguiProps
|
|
642
|
+
if (forwardedRef) {
|
|
643
|
+
// @ts-ignore
|
|
644
|
+
viewProps.ref = forwardedRef
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
if (process.env.NODE_ENV === 'development' && !isText && isWeb && !staticConfig.isHOC) {
|
|
649
|
+
Children.toArray(props.children).forEach((item) => {
|
|
650
|
+
if (typeof item === 'string') {
|
|
651
|
+
// eslint-disable-next-line no-console
|
|
652
|
+
console.error(`Unexpected text node: ${item}. A text node cannot be a child of a <View>.`)
|
|
653
|
+
}
|
|
654
|
+
})
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
const unPress = useCallback(() => {
|
|
658
|
+
setStateShallow({
|
|
659
|
+
press: false,
|
|
660
|
+
pressIn: false,
|
|
661
|
+
})
|
|
662
|
+
}, [setStateShallow])
|
|
663
|
+
|
|
664
|
+
if (!isRSC) {
|
|
665
|
+
useEffect(() => {
|
|
666
|
+
return () => {
|
|
667
|
+
mouseUps.delete(unPress)
|
|
668
|
+
}
|
|
669
|
+
}, [unPress])
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
let styles: any[]
|
|
673
|
+
|
|
674
|
+
const animationStyles = state.animation ? state.animation.style : null
|
|
675
|
+
|
|
676
|
+
if (isStringElement && shouldAvoidClasses && !shouldForcePseudo) {
|
|
677
|
+
styles = {
|
|
678
|
+
...defaultNativeStyle,
|
|
679
|
+
...(animationStyles ?? splitStylesStyle),
|
|
680
|
+
...medias,
|
|
681
|
+
}
|
|
682
|
+
} else {
|
|
683
|
+
styles = [isWeb ? null : defaultNativeStyle, animationStyles ?? splitStylesStyle, medias]
|
|
684
|
+
if (!animationStyles && initialSplitStyles) {
|
|
685
|
+
const initPseudos = initialSplitStyles.pseudos
|
|
686
|
+
!state.mounted && addPseudoToStyles(styles, initPseudos, pseudos, 'enterStyle')
|
|
687
|
+
state.hover &&
|
|
688
|
+
addPseudoToStyles(styles, initPseudos, pseudos, 'hoverStyle', shouldForcePseudo)
|
|
689
|
+
state.focus &&
|
|
690
|
+
addPseudoToStyles(styles, initPseudos, pseudos, 'focusStyle', shouldForcePseudo)
|
|
691
|
+
state.press &&
|
|
692
|
+
addPseudoToStyles(styles, initPseudos, pseudos, 'pressStyle', shouldForcePseudo)
|
|
693
|
+
}
|
|
694
|
+
// ugly but for now...
|
|
695
|
+
if (shouldForcePseudo) {
|
|
696
|
+
const next = {}
|
|
697
|
+
for (const style of styles) {
|
|
698
|
+
if (style) {
|
|
699
|
+
Object.assign(next, style)
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
// @ts-ignore
|
|
703
|
+
Object.assign(splitStyles.style, next)
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
if (process.env.TAMAGUI_TARGET === 'web') {
|
|
708
|
+
let fontFamily = isText
|
|
709
|
+
? splitStyles.fontFamily || staticConfig.defaultProps.fontFamily
|
|
710
|
+
: null
|
|
711
|
+
if (fontFamily && fontFamily[0] === '$') {
|
|
712
|
+
fontFamily = fontFamily.slice(1)
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
if (process.env.NODE_ENV === 'development') {
|
|
716
|
+
if (fontFamily?.startsWith(`var(`)) {
|
|
717
|
+
// eslint-disable-next-line no-console
|
|
718
|
+
console.warn(
|
|
719
|
+
`Received variable instead of resolved name of font, this is a bug. Please report on Github.`,
|
|
720
|
+
{
|
|
721
|
+
fontFamily,
|
|
722
|
+
props,
|
|
723
|
+
splitStyles,
|
|
724
|
+
staticConfig,
|
|
725
|
+
}
|
|
726
|
+
)
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
const classList = [
|
|
731
|
+
componentName ? componentClassName : '',
|
|
732
|
+
fontFamily ? `font_${fontFamily}` : '',
|
|
733
|
+
theme.className,
|
|
734
|
+
classNames ? Object.values(classNames).join(' ') : '',
|
|
735
|
+
]
|
|
736
|
+
|
|
737
|
+
const className = classList.join(' ')
|
|
738
|
+
const style = animationStyles ?? splitStyles.style
|
|
739
|
+
|
|
740
|
+
// TODO this is specific to reanimated rn
|
|
741
|
+
const isAnimatedReactNativeWeb = props.animation && avoidClasses
|
|
742
|
+
|
|
743
|
+
if (staticConfig.isReactNativeWeb || isAnimatedReactNativeWeb) {
|
|
744
|
+
viewProps.dataSet = {
|
|
745
|
+
...viewProps.dataSet,
|
|
746
|
+
className,
|
|
747
|
+
id: props.id,
|
|
748
|
+
}
|
|
749
|
+
if (process.env.NODE_ENV === 'development') {
|
|
750
|
+
// turn debug data- props into dataSet in dev mode
|
|
751
|
+
Object.keys(viewProps).forEach((key) => {
|
|
752
|
+
if (key.startsWith('data-')) {
|
|
753
|
+
viewProps.dataSet[key.replace('data-', '')] = viewProps[key]
|
|
754
|
+
delete viewProps[key]
|
|
755
|
+
}
|
|
756
|
+
})
|
|
757
|
+
}
|
|
758
|
+
} else {
|
|
759
|
+
viewProps.className = className
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
viewProps.style = style
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
if (process.env.TAMAGUI_TARGET === 'native') {
|
|
766
|
+
// add ref
|
|
767
|
+
const mergedRef = useMergeRefs(forwardedRef, hostRef, setMounted)
|
|
768
|
+
viewProps.ref = mergedRef
|
|
769
|
+
|
|
770
|
+
// swap out the right family based on weight/style
|
|
771
|
+
if (splitStyles.fontFamily) {
|
|
772
|
+
const faceInfo = config.fontsParsed[splitStyles.fontFamily]?.face
|
|
773
|
+
if (faceInfo) {
|
|
774
|
+
const [weight, style] = (() => {
|
|
775
|
+
let weight: string | undefined
|
|
776
|
+
let style: string | undefined
|
|
777
|
+
for (let i = styles.length; i >= 0; i--) {
|
|
778
|
+
weight ??= styles[i]?.fontWeight
|
|
779
|
+
style ??= styles[i]?.fontStyle
|
|
780
|
+
}
|
|
781
|
+
return [weight || '400', style || 'normal'] as const
|
|
782
|
+
})()
|
|
783
|
+
const overrideFace = faceInfo[weight]?.[style]?.val
|
|
784
|
+
if (overrideFace) {
|
|
785
|
+
for (const style of styles) {
|
|
786
|
+
if (style?.fontFamily) {
|
|
787
|
+
style.fontFamily = overrideFace
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
// assign styles
|
|
795
|
+
viewProps.style = styles
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
// TODO need to loop active variants and see if they have matchin pseudos and apply as well
|
|
799
|
+
const initialPseudos = initialSplitStyles?.pseudos
|
|
800
|
+
const attachPress = !!(
|
|
801
|
+
pseudos?.pressStyle ||
|
|
802
|
+
initialPseudos?.pressStyle ||
|
|
803
|
+
onPress ||
|
|
804
|
+
onPressOut ||
|
|
805
|
+
onPressIn ||
|
|
806
|
+
onClick
|
|
807
|
+
)
|
|
808
|
+
|
|
809
|
+
const isHoverable = isWeb
|
|
810
|
+
const attachHover =
|
|
811
|
+
isHoverable &&
|
|
812
|
+
!!((pseudos && pseudos.hoverStyle) || onHoverIn || onHoverOut || onMouseEnter || onMouseLeave)
|
|
813
|
+
|
|
814
|
+
const handlesPressEvents = !isStringElement && !asChild
|
|
815
|
+
const pressKey = handlesPressEvents ? 'onPress' : 'onClick'
|
|
816
|
+
const pressInKey = handlesPressEvents ? 'onPressIn' : 'onMouseDown'
|
|
817
|
+
const pressOutKey = handlesPressEvents ? 'onPressOut' : 'onMouseUp'
|
|
818
|
+
|
|
819
|
+
// check presence to prevent reparenting bugs, allows for onPress={x ? function : undefined} usage
|
|
820
|
+
const shouldAttach =
|
|
821
|
+
!asChild &&
|
|
822
|
+
(attachPress ||
|
|
823
|
+
attachHover ||
|
|
824
|
+
'pressStyle' in props ||
|
|
825
|
+
'onPress' in props ||
|
|
826
|
+
'onPressIn' in props ||
|
|
827
|
+
'onPressOut' in props ||
|
|
828
|
+
(isWeb &&
|
|
829
|
+
('hoverStyle' in props ||
|
|
830
|
+
'onHoverIn' in props ||
|
|
831
|
+
'onHoverOut' in props ||
|
|
832
|
+
'onMouseEnter' in props ||
|
|
833
|
+
'onMouseLeave' in props)))
|
|
834
|
+
|
|
835
|
+
const events =
|
|
836
|
+
shouldAttach && !isRSC
|
|
837
|
+
? {
|
|
838
|
+
[pressOutKey]: attachPress
|
|
839
|
+
? (e) => {
|
|
840
|
+
unPress()
|
|
841
|
+
onPressOut?.(e)
|
|
842
|
+
onMouseUp?.(e)
|
|
843
|
+
}
|
|
844
|
+
: undefined,
|
|
845
|
+
...(isHoverable && {
|
|
846
|
+
onMouseEnter: attachHover
|
|
847
|
+
? (e) => {
|
|
848
|
+
const next: Partial<typeof state> = {}
|
|
849
|
+
if (attachHover) {
|
|
850
|
+
next.hover = true
|
|
851
|
+
}
|
|
852
|
+
if (state.pressIn) {
|
|
853
|
+
next.press = true
|
|
854
|
+
}
|
|
855
|
+
if (Object.keys(next).length) {
|
|
856
|
+
setStateShallow(next)
|
|
857
|
+
}
|
|
858
|
+
onHoverIn?.(e)
|
|
859
|
+
onMouseEnter?.(e)
|
|
860
|
+
}
|
|
861
|
+
: undefined,
|
|
862
|
+
onMouseLeave: attachHover
|
|
863
|
+
? (e) => {
|
|
864
|
+
const next: Partial<typeof state> = {}
|
|
865
|
+
mouseUps.add(unPress)
|
|
866
|
+
if (attachHover) {
|
|
867
|
+
next.hover = false
|
|
868
|
+
}
|
|
869
|
+
if (state.pressIn) {
|
|
870
|
+
next.press = false
|
|
871
|
+
next.pressIn = false
|
|
872
|
+
}
|
|
873
|
+
if (Object.keys(next).length) {
|
|
874
|
+
setStateShallow(next)
|
|
875
|
+
}
|
|
876
|
+
onHoverOut?.(e)
|
|
877
|
+
onMouseLeave?.(e)
|
|
878
|
+
}
|
|
879
|
+
: undefined,
|
|
880
|
+
}),
|
|
881
|
+
[pressInKey]: attachPress
|
|
882
|
+
? (e) => {
|
|
883
|
+
setStateShallow({
|
|
884
|
+
press: true,
|
|
885
|
+
pressIn: true,
|
|
886
|
+
hover: false,
|
|
887
|
+
})
|
|
888
|
+
onPressIn?.(e)
|
|
889
|
+
onMouseDown?.(e)
|
|
890
|
+
if (isWeb) {
|
|
891
|
+
mouseUps.add(unPress)
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
: null,
|
|
895
|
+
[pressKey]: attachPress
|
|
896
|
+
? (e) => {
|
|
897
|
+
unPress()
|
|
898
|
+
onClick?.(e)
|
|
899
|
+
onPress?.(e)
|
|
900
|
+
}
|
|
901
|
+
: null,
|
|
902
|
+
|
|
903
|
+
// replicating TouchableWithoutFeedback
|
|
904
|
+
...(!isWeb && {
|
|
905
|
+
cancelable: !props.rejectResponderTermination,
|
|
906
|
+
disabled:
|
|
907
|
+
props.disabled !== null ? props.disabled : props.accessibilityState?.disabled,
|
|
908
|
+
hitSlop: props.hitSlop,
|
|
909
|
+
delayLongPress: props.delayLongPress,
|
|
910
|
+
delayPressIn: props.delayPressIn,
|
|
911
|
+
delayPressOut: props.delayPressOut,
|
|
912
|
+
focusable: viewProps.focusable ?? true,
|
|
913
|
+
minPressDuration: 0,
|
|
914
|
+
}),
|
|
915
|
+
}
|
|
916
|
+
: null
|
|
917
|
+
|
|
918
|
+
let space = spaceProp
|
|
919
|
+
|
|
920
|
+
// find space by media query
|
|
921
|
+
if (state.mediaState && mediaKeys.length) {
|
|
922
|
+
for (const key in state.mediaState) {
|
|
923
|
+
if (!state.mediaState[key]) continue
|
|
924
|
+
if (props[key] && props[key].space !== undefined) {
|
|
925
|
+
space = props[key].space
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
const themeManager = getThemeManager(theme)
|
|
931
|
+
|
|
932
|
+
const shouldSetChildrenThemeToParent = Boolean(
|
|
933
|
+
themeShallow && themeManager && themeManager.didChangeTheme
|
|
934
|
+
)
|
|
935
|
+
|
|
936
|
+
const shouldProvideThemeManager =
|
|
937
|
+
shouldSetChildrenThemeToParent || (themeManager && themeManager.didChangeTheme)
|
|
938
|
+
|
|
939
|
+
const childEls =
|
|
940
|
+
!children || asChild
|
|
941
|
+
? children
|
|
942
|
+
: wrapThemeManagerContext(
|
|
943
|
+
spacedChildren({
|
|
944
|
+
separator,
|
|
945
|
+
children,
|
|
946
|
+
space,
|
|
947
|
+
direction: props.spaceDirection || 'both',
|
|
948
|
+
isZStack,
|
|
949
|
+
}),
|
|
950
|
+
// only set context if changed theme
|
|
951
|
+
shouldProvideThemeManager ? themeManager : undefined,
|
|
952
|
+
shouldSetChildrenThemeToParent
|
|
953
|
+
)
|
|
954
|
+
|
|
955
|
+
let content: any
|
|
956
|
+
|
|
957
|
+
if (asChild) {
|
|
958
|
+
elementType = Slot
|
|
959
|
+
viewProps = {
|
|
960
|
+
...viewProps,
|
|
961
|
+
onPress,
|
|
962
|
+
onPressIn,
|
|
963
|
+
onPressOut,
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
// EVENTS: web
|
|
968
|
+
if (!isRSC && isWeb) {
|
|
969
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
970
|
+
const [pressableProps] = usePressable(
|
|
971
|
+
events
|
|
972
|
+
? {
|
|
973
|
+
disabled,
|
|
974
|
+
...(hitSlop && {
|
|
975
|
+
hitSlop,
|
|
976
|
+
}),
|
|
977
|
+
onPressOut: events[pressOutKey],
|
|
978
|
+
onPressIn: events[pressInKey],
|
|
979
|
+
onPress: events[pressKey],
|
|
980
|
+
}
|
|
981
|
+
: {
|
|
982
|
+
disabled: true,
|
|
983
|
+
}
|
|
984
|
+
)
|
|
985
|
+
if (events) {
|
|
986
|
+
if (handlesPressEvents) {
|
|
987
|
+
Object.assign(viewProps, pressableProps)
|
|
988
|
+
} else {
|
|
989
|
+
Object.assign(viewProps, events)
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
// EVENTS native
|
|
995
|
+
if (process.env.TAMAGUI_TARGET === 'native') {
|
|
996
|
+
// add focus events
|
|
997
|
+
const attachFocus = !!(
|
|
998
|
+
(pseudos && pseudos.focusStyle) ||
|
|
999
|
+
(initialPseudos && initialPseudos.focusStyle)
|
|
1000
|
+
)
|
|
1001
|
+
if (attachFocus) {
|
|
1002
|
+
viewProps.onFocus = mergeEvent(viewProps.onFocus, () => {
|
|
1003
|
+
setStateShallow({ focus: true })
|
|
1004
|
+
})
|
|
1005
|
+
viewProps.onBlur = mergeEvent(viewProps.onBlur, () => {
|
|
1006
|
+
setStateShallow({ focus: false })
|
|
1007
|
+
})
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
// use Pressability to get smooth unPress when you press + hold + move out
|
|
1011
|
+
// only ever create once, use .configure() to update later
|
|
1012
|
+
const pressability = usePressability(events)
|
|
1013
|
+
if (attachPress && events) {
|
|
1014
|
+
const dontComposePressabilityKeys = {
|
|
1015
|
+
onClick: true,
|
|
1016
|
+
}
|
|
1017
|
+
if (hitSlop) {
|
|
1018
|
+
viewProps.hitSlop = hitSlop
|
|
1019
|
+
}
|
|
1020
|
+
for (const key in pressability) {
|
|
1021
|
+
const og = props[key]
|
|
1022
|
+
const val = pressability[key]
|
|
1023
|
+
viewProps[key] =
|
|
1024
|
+
og && !dontComposePressabilityKeys[key] ? composeEventHandlers(og, val) : val
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
content = createElement(elementType, viewProps, childEls)
|
|
1030
|
+
|
|
1031
|
+
if (process.env.TAMAGUI_TARGET === 'web') {
|
|
1032
|
+
// only necessary when animating because some AnimatedView which wraps RNW View doesn't forward dataSet className
|
|
1033
|
+
const isAnimatedRNWView = isAnimated && typeof elementType !== 'string' // assuming for now as reanimated is only driver
|
|
1034
|
+
const shouldWrapWithComponentTheme =
|
|
1035
|
+
!!theme.className &&
|
|
1036
|
+
isAnimatedRNWView &&
|
|
1037
|
+
getReturnVariablesAs(props, splitStyleState) === 'non-color-value'
|
|
1038
|
+
const shouldWrapWithHover = Boolean(events || isRSC) && attachHover
|
|
1039
|
+
|
|
1040
|
+
if (shouldWrapWithHover || shouldWrapWithComponentTheme) {
|
|
1041
|
+
const themeClassName = shouldWrapWithComponentTheme ? `${theme.className}` : ''
|
|
1042
|
+
const hoverClassName = shouldWrapWithHover ? 't_Hoverable' : ''
|
|
1043
|
+
content = (
|
|
1044
|
+
<span
|
|
1045
|
+
className={`${hoverClassName} ${themeClassName}`}
|
|
1046
|
+
style={{
|
|
1047
|
+
display: 'contents',
|
|
1048
|
+
}}
|
|
1049
|
+
{...(events &&
|
|
1050
|
+
shouldWrapWithHover && {
|
|
1051
|
+
onMouseEnter: events.onMouseEnter,
|
|
1052
|
+
onMouseLeave: events.onMouseLeave,
|
|
1053
|
+
})}
|
|
1054
|
+
>
|
|
1055
|
+
{content}
|
|
1056
|
+
</span>
|
|
1057
|
+
)
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
if (process.env.NODE_ENV === 'development') {
|
|
1062
|
+
if (debugProp) {
|
|
1063
|
+
const element = typeof elementType === 'string' ? elementType : 'Component'
|
|
1064
|
+
// eslint-disable-next-line no-console
|
|
1065
|
+
console.groupCollapsed(`render <${element} /> with props`, viewProps)
|
|
1066
|
+
for (const key in viewProps) {
|
|
1067
|
+
// eslint-disable-next-line no-console
|
|
1068
|
+
console.log(key, viewProps[key])
|
|
1069
|
+
}
|
|
1070
|
+
// eslint-disable-next-line no-console
|
|
1071
|
+
console.log('children', content)
|
|
1072
|
+
// eslint-disable-next-line no-console
|
|
1073
|
+
console.groupEnd()
|
|
1074
|
+
if (typeof window !== 'undefined') {
|
|
1075
|
+
// prettier-ignore
|
|
1076
|
+
// eslint-disable-next-line no-console
|
|
1077
|
+
console.log({ state, shouldProvideThemeManager, tamaguiDefaultProps, viewProps, splitStyles, animationStyles, handlesPressEvents, isStringElement, classNamesIn: props.className?.split(' '), classNamesOut: viewProps.className?.split(' '), events, shouldAttach, styles, pseudos, content, childEls, shouldAvoidClasses, avoidClasses, animation: props.animation, style: splitStylesStyle, defaultNativeStyle, initialSplitStyles, ...(typeof window !== 'undefined' ? { theme, themeClassName: theme.className, staticConfig, tamaguiConfig, events, shouldAvoidClasses, shouldForcePseudo, classNames: Object.fromEntries(Object.entries(classNames).map(([k, v]) => [v, getAllSelectors()[v]])) } : null) })
|
|
1078
|
+
}
|
|
1079
|
+
// eslint-disable-next-line no-console
|
|
1080
|
+
console.groupEnd()
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
return content
|
|
1085
|
+
})
|
|
1086
|
+
|
|
1087
|
+
if (staticConfig.componentName) {
|
|
1088
|
+
component.displayName = staticConfig.componentName
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
// Once configuration is run and all components are registered
|
|
1092
|
+
// get default props + className and analyze styles
|
|
1093
|
+
onConfiguredOnce((conf) => {
|
|
1094
|
+
if (!defaultComponentState) {
|
|
1095
|
+
defaultComponentState = Object.freeze({
|
|
1096
|
+
hover: false,
|
|
1097
|
+
press: false,
|
|
1098
|
+
pressIn: false,
|
|
1099
|
+
focus: false,
|
|
1100
|
+
// only used by enterStyle
|
|
1101
|
+
mounted: false,
|
|
1102
|
+
animation: null,
|
|
1103
|
+
mediaState: getInitialMediaState(),
|
|
1104
|
+
})
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
// in static mode we just use these to lookup configuration
|
|
1108
|
+
// ... we likely want this? need to test
|
|
1109
|
+
if (process.env.IS_STATIC === 'is_static') return
|
|
1110
|
+
|
|
1111
|
+
tamaguiConfig = conf
|
|
1112
|
+
|
|
1113
|
+
// do this to make sure shorthands don't duplicate with.. longhands
|
|
1114
|
+
mergeShorthands(staticConfig, tamaguiConfig)
|
|
1115
|
+
|
|
1116
|
+
if (tamaguiConfig.animations) {
|
|
1117
|
+
avoidClasses = !!tamaguiConfig.animations.avoidClasses
|
|
1118
|
+
AnimatedText = tamaguiConfig.animations.Text
|
|
1119
|
+
AnimatedView = tamaguiConfig.animations.View
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
if (!initialTheme) {
|
|
1123
|
+
const next = conf.themes[conf.defaultTheme || Object.keys(conf.themes)[0]]
|
|
1124
|
+
initialTheme = proxyThemeVariables(next)
|
|
1125
|
+
if (!initialTheme && process.env.NODE_ENV === 'development') {
|
|
1126
|
+
// eslint-disable-next-line no-console
|
|
1127
|
+
console.log(`Warning: Missing theme`)
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
// adds in user defined default props
|
|
1132
|
+
config = getConfig()
|
|
1133
|
+
|
|
1134
|
+
let defaultPropsIn = staticConfig.defaultProps || {}
|
|
1135
|
+
|
|
1136
|
+
// because we run createTamagui after styled() defs, have to do some work here
|
|
1137
|
+
// gather defaults props one time and merge downwards
|
|
1138
|
+
// find last unprocessed and process
|
|
1139
|
+
const parentNames = [...(staticConfig.parentNames || []), staticConfig.componentName]
|
|
1140
|
+
|
|
1141
|
+
if (config.defaultProps && parentNames && staticConfig.componentName) {
|
|
1142
|
+
defaultPropsIn = mergeConfigDefaultProps(
|
|
1143
|
+
staticConfig.componentName,
|
|
1144
|
+
defaultPropsIn,
|
|
1145
|
+
config.defaultProps,
|
|
1146
|
+
parentNames,
|
|
1147
|
+
conf
|
|
1148
|
+
)
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
const debug = defaultPropsIn['debug']
|
|
1152
|
+
|
|
1153
|
+
if (process.env.NODE_ENV === 'development' && debug === 'break') {
|
|
1154
|
+
// eslint-disable-next-line no-debugger
|
|
1155
|
+
debugger
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
// remove all classNames
|
|
1159
|
+
const [parentProps, parentClassNames] = mergeProps(defaultPropsIn, {}, true)
|
|
1160
|
+
|
|
1161
|
+
initialSplitStyles = insertSplitStyles(
|
|
1162
|
+
parentProps,
|
|
1163
|
+
staticConfig,
|
|
1164
|
+
initialTheme,
|
|
1165
|
+
{
|
|
1166
|
+
mounted: true,
|
|
1167
|
+
hover: false,
|
|
1168
|
+
press: false,
|
|
1169
|
+
pressIn: false,
|
|
1170
|
+
focus: false,
|
|
1171
|
+
resolveVariablesAs: 'both',
|
|
1172
|
+
noClassNames: !staticConfig.acceptsClassName,
|
|
1173
|
+
keepVariantsAsProps: true,
|
|
1174
|
+
},
|
|
1175
|
+
undefined,
|
|
1176
|
+
undefined,
|
|
1177
|
+
debug
|
|
1178
|
+
)
|
|
1179
|
+
|
|
1180
|
+
// must preserve prop order
|
|
1181
|
+
// leave out className because we handle that already with initialSplitStyles.classNames
|
|
1182
|
+
// otherwise it confuses variant functions getting className props
|
|
1183
|
+
const [defaults, defaultsClassnames] = mergeProps(
|
|
1184
|
+
component.defaultProps as any,
|
|
1185
|
+
initialSplitStyles.viewProps,
|
|
1186
|
+
true
|
|
1187
|
+
// conf.inverseShorthands
|
|
1188
|
+
)
|
|
1189
|
+
|
|
1190
|
+
// avoid passing className props to variants
|
|
1191
|
+
initialSplitStyles.classNames = {
|
|
1192
|
+
...parentClassNames,
|
|
1193
|
+
...defaultsClassnames,
|
|
1194
|
+
...initialSplitStyles.classNames,
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
defaultNativeStyle = {}
|
|
1198
|
+
|
|
1199
|
+
const validStyles = staticConfig.validStyles || stylePropsView
|
|
1200
|
+
|
|
1201
|
+
// split - keep variables on props to be processed using theme values at runtime (native)
|
|
1202
|
+
if (!isWeb) {
|
|
1203
|
+
for (const key in staticConfig.defaultProps) {
|
|
1204
|
+
const val = staticConfig.defaultProps[key]
|
|
1205
|
+
if (validPseudoKeys[key]) continue
|
|
1206
|
+
if ((typeof val === 'string' && val[0] === '$') || !validStyles[key]) {
|
|
1207
|
+
defaults[key] = val
|
|
1208
|
+
} else {
|
|
1209
|
+
defaultNativeStyle[key] = val
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
if (Object.keys(defaults).length) {
|
|
1215
|
+
tamaguiDefaultProps = defaults
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
// add debug logs
|
|
1219
|
+
if (process.env.NODE_ENV === 'development' && debug) {
|
|
1220
|
+
if (process.env.IS_STATIC !== 'is_static') {
|
|
1221
|
+
// eslint-disable-next-line no-console
|
|
1222
|
+
console.log(`🐛 [${staticConfig.componentName || 'Component'}]`, {
|
|
1223
|
+
staticConfig,
|
|
1224
|
+
initialSplitStyles,
|
|
1225
|
+
tamaguiDefaultProps,
|
|
1226
|
+
defaultNativeStyle,
|
|
1227
|
+
defaults,
|
|
1228
|
+
defaultPropsIn,
|
|
1229
|
+
})
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
})
|
|
1233
|
+
|
|
1234
|
+
let res: TamaguiComponent<ComponentPropTypes, Ref, BaseProps> = component as any
|
|
1235
|
+
|
|
1236
|
+
if (configIn.memo) {
|
|
1237
|
+
res = memo(res) as any
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
res.staticConfig = {
|
|
1241
|
+
validStyles: staticConfig.validStyles || stylePropsView,
|
|
1242
|
+
...staticConfig,
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
// res.extractable HoC
|
|
1246
|
+
res.extractable = (Component: any, conf?: Partial<StaticConfig>) => {
|
|
1247
|
+
Component.staticConfig = extendStaticConfig(
|
|
1248
|
+
{
|
|
1249
|
+
Component,
|
|
1250
|
+
...conf,
|
|
1251
|
+
neverFlatten: true,
|
|
1252
|
+
isHOC: true,
|
|
1253
|
+
defaultProps: {
|
|
1254
|
+
...Component.defaultProps,
|
|
1255
|
+
...conf?.defaultProps,
|
|
1256
|
+
},
|
|
1257
|
+
},
|
|
1258
|
+
res
|
|
1259
|
+
)
|
|
1260
|
+
return Component
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
return res
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
// for elements to avoid spacing
|
|
1267
|
+
export const Unspaced = (props: { children?: any }) => {
|
|
1268
|
+
return props.children
|
|
1269
|
+
}
|
|
1270
|
+
Unspaced['isUnspaced'] = true
|
|
1271
|
+
|
|
1272
|
+
// dont used styled() here to avoid circular deps
|
|
1273
|
+
// keep inline to avoid circular deps
|
|
1274
|
+
|
|
1275
|
+
export const Spacer = createComponent<SpacerProps>({
|
|
1276
|
+
memo: true,
|
|
1277
|
+
componentName: 'Spacer',
|
|
1278
|
+
validStyles,
|
|
1279
|
+
defaultProps: {
|
|
1280
|
+
...stackDefaultStyles,
|
|
1281
|
+
// avoid nesting issues
|
|
1282
|
+
tag: 'span',
|
|
1283
|
+
size: true,
|
|
1284
|
+
},
|
|
1285
|
+
variants: {
|
|
1286
|
+
size: {
|
|
1287
|
+
'...size': (size, { tokens }) => {
|
|
1288
|
+
size = size == true ? '$true' : size
|
|
1289
|
+
const sizePx = tokens.space[size] ?? size
|
|
1290
|
+
return {
|
|
1291
|
+
width: sizePx,
|
|
1292
|
+
height: sizePx,
|
|
1293
|
+
minWidth: sizePx,
|
|
1294
|
+
minHeight: sizePx,
|
|
1295
|
+
}
|
|
1296
|
+
},
|
|
1297
|
+
},
|
|
1298
|
+
|
|
1299
|
+
flex: {
|
|
1300
|
+
true: {
|
|
1301
|
+
flexGrow: 1,
|
|
1302
|
+
},
|
|
1303
|
+
},
|
|
1304
|
+
|
|
1305
|
+
direction: {
|
|
1306
|
+
horizontal: {
|
|
1307
|
+
height: 0,
|
|
1308
|
+
minHeight: 0,
|
|
1309
|
+
},
|
|
1310
|
+
vertical: {
|
|
1311
|
+
width: 0,
|
|
1312
|
+
minWidth: 0,
|
|
1313
|
+
},
|
|
1314
|
+
both: {},
|
|
1315
|
+
},
|
|
1316
|
+
} as const,
|
|
1317
|
+
|
|
1318
|
+
defaultVariants: {
|
|
1319
|
+
direction: 'both',
|
|
1320
|
+
},
|
|
1321
|
+
})
|
|
1322
|
+
|
|
1323
|
+
export type SpacedChildrenProps = {
|
|
1324
|
+
isZStack?: boolean
|
|
1325
|
+
children?: React.ReactNode
|
|
1326
|
+
space?: SpaceTokens | number | null
|
|
1327
|
+
spaceFlex?: boolean | number
|
|
1328
|
+
direction?: SpaceDirection
|
|
1329
|
+
separator?: React.ReactNode
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
export function spacedChildren({
|
|
1333
|
+
isZStack,
|
|
1334
|
+
children,
|
|
1335
|
+
space,
|
|
1336
|
+
direction,
|
|
1337
|
+
spaceFlex,
|
|
1338
|
+
separator,
|
|
1339
|
+
}: SpacedChildrenProps) {
|
|
1340
|
+
const hasSpace = !!(space || spaceFlex)
|
|
1341
|
+
const hasSeparator = !(separator === undefined || separator === null)
|
|
1342
|
+
if (!hasSpace && !hasSeparator && !isZStack) {
|
|
1343
|
+
return children
|
|
1344
|
+
}
|
|
1345
|
+
const childrenList = Children.toArray(children)
|
|
1346
|
+
if (childrenList.length <= 1 && !isZStack) {
|
|
1347
|
+
return childrenList
|
|
1348
|
+
}
|
|
1349
|
+
const final: React.ReactNode[] = []
|
|
1350
|
+
for (const [index, child] of childrenList.entries()) {
|
|
1351
|
+
const isEmpty =
|
|
1352
|
+
child === null || child === undefined || (Array.isArray(child) && child.length === 0)
|
|
1353
|
+
|
|
1354
|
+
// push them all, but wrap some in Fragment
|
|
1355
|
+
if (isEmpty || !child || (child['key'] && !isZStack)) {
|
|
1356
|
+
final.push(child)
|
|
1357
|
+
} else {
|
|
1358
|
+
final.push(
|
|
1359
|
+
<Fragment key={index}>{isZStack ? <AbsoluteFill>{child}</AbsoluteFill> : child}</Fragment>
|
|
1360
|
+
)
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
// first child unspaced avoid insert space
|
|
1364
|
+
if (isUnspaced(child) && index === 0) {
|
|
1365
|
+
continue
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
// no spacing on ZStack
|
|
1369
|
+
if (isZStack) {
|
|
1370
|
+
continue
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
const next = childrenList[index + 1]
|
|
1374
|
+
|
|
1375
|
+
if (next && !isUnspaced(next)) {
|
|
1376
|
+
if (separator) {
|
|
1377
|
+
if (hasSpace) {
|
|
1378
|
+
final.push(
|
|
1379
|
+
createSpacer({
|
|
1380
|
+
key: `_${index}_before_sep_spacer`,
|
|
1381
|
+
direction,
|
|
1382
|
+
space,
|
|
1383
|
+
spaceFlex,
|
|
1384
|
+
})
|
|
1385
|
+
)
|
|
1386
|
+
}
|
|
1387
|
+
final.push(
|
|
1388
|
+
React.isValidElement(separator)
|
|
1389
|
+
? React.cloneElement(separator, { key: `sep_${index}` })
|
|
1390
|
+
: separator
|
|
1391
|
+
)
|
|
1392
|
+
if (hasSpace) {
|
|
1393
|
+
final.push(
|
|
1394
|
+
createSpacer({
|
|
1395
|
+
key: `_${index}_after_sep_spacer`,
|
|
1396
|
+
direction,
|
|
1397
|
+
space,
|
|
1398
|
+
spaceFlex,
|
|
1399
|
+
})
|
|
1400
|
+
)
|
|
1401
|
+
}
|
|
1402
|
+
} else {
|
|
1403
|
+
final.push(
|
|
1404
|
+
createSpacer({
|
|
1405
|
+
key: `_${index}_spacer`,
|
|
1406
|
+
direction,
|
|
1407
|
+
space,
|
|
1408
|
+
spaceFlex,
|
|
1409
|
+
})
|
|
1410
|
+
)
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
return final
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
type CreateSpacerProps = SpacedChildrenProps & { key: string }
|
|
1419
|
+
|
|
1420
|
+
function createSpacer({ key, direction, space, spaceFlex }: CreateSpacerProps) {
|
|
1421
|
+
return (
|
|
1422
|
+
<Spacer
|
|
1423
|
+
key={key}
|
|
1424
|
+
size={space}
|
|
1425
|
+
direction={direction}
|
|
1426
|
+
{...(spaceFlex && {
|
|
1427
|
+
flex: spaceFlex,
|
|
1428
|
+
})}
|
|
1429
|
+
/>
|
|
1430
|
+
)
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
function isUnspaced(child: React.ReactNode) {
|
|
1434
|
+
// console.log('unspaced?', child, getMedia())
|
|
1435
|
+
return child?.['type']?.['isVisuallyHidden'] || child?.['type']?.['isUnspaced']
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
function AbsoluteFill(props: { children?: any }) {
|
|
1439
|
+
return (
|
|
1440
|
+
<View pointerEvents="box-none" style={absoluteFill}>
|
|
1441
|
+
{props.children}
|
|
1442
|
+
</View>
|
|
1443
|
+
)
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
const absoluteFill = {
|
|
1447
|
+
position: 'absolute',
|
|
1448
|
+
top: 0,
|
|
1449
|
+
left: 0,
|
|
1450
|
+
right: 0,
|
|
1451
|
+
bottom: 0,
|
|
1452
|
+
} as const
|
|
1453
|
+
|
|
1454
|
+
// this can be done with CSS entirely right?
|
|
1455
|
+
// const shouldWrapTextAncestor = isWeb && isText && !hasTextAncestor
|
|
1456
|
+
// if (shouldWrapTextAncestor) {
|
|
1457
|
+
// // from react-native-web
|
|
1458
|
+
// content = createElement(TextAncestorContext.Provider, { value: true }, content)
|
|
1459
|
+
// }
|
|
1460
|
+
|
|
1461
|
+
export function processIDRefList(idRefList: string | Array<string>): string {
|
|
1462
|
+
return Array.isArray(idRefList) ? idRefList.join(' ') : idRefList
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
export const accessibilityRoleToWebRole = {
|
|
1466
|
+
adjustable: 'slider',
|
|
1467
|
+
button: 'button',
|
|
1468
|
+
header: 'heading',
|
|
1469
|
+
image: 'img',
|
|
1470
|
+
imagebutton: null,
|
|
1471
|
+
keyboardkey: null,
|
|
1472
|
+
label: null,
|
|
1473
|
+
link: 'link',
|
|
1474
|
+
none: 'presentation',
|
|
1475
|
+
search: 'search',
|
|
1476
|
+
summary: 'region',
|
|
1477
|
+
text: null,
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
function addPseudoToStyles(
|
|
1481
|
+
styles: any[],
|
|
1482
|
+
initialPseudos: SplitStyleResult['pseudos'],
|
|
1483
|
+
pseudos: any,
|
|
1484
|
+
name: string,
|
|
1485
|
+
force = false
|
|
1486
|
+
) {
|
|
1487
|
+
// on web use pseudo object { hoverStyle } to keep specificity with concatClassName
|
|
1488
|
+
const pseudoStyle = pseudos[name]
|
|
1489
|
+
const shouldNestObject = isWeb && name !== 'enterStyle' && name !== 'exitStyle'
|
|
1490
|
+
const defaultPseudoStyle = initialPseudos[name]
|
|
1491
|
+
const style = defaultPseudoStyle ? { ...defaultPseudoStyle, ...pseudoStyle } : pseudoStyle
|
|
1492
|
+
if (style) {
|
|
1493
|
+
styles.push(shouldNestObject && !force ? { [name]: style } : style)
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
const DefaultProps = new Map()
|
|
1498
|
+
|
|
1499
|
+
function mergeConfigDefaultProps(
|
|
1500
|
+
name: string,
|
|
1501
|
+
props: Record<string, any>,
|
|
1502
|
+
configDefaults: Record<string, Object>,
|
|
1503
|
+
parentNames: (string | undefined)[],
|
|
1504
|
+
conf: TamaguiInternalConfig
|
|
1505
|
+
) {
|
|
1506
|
+
const len = parentNames.length
|
|
1507
|
+
let prev
|
|
1508
|
+
|
|
1509
|
+
for (let i = 0; i < len; i++) {
|
|
1510
|
+
const n = parentNames[i]
|
|
1511
|
+
if (!n) continue
|
|
1512
|
+
if (DefaultProps.has(n)) {
|
|
1513
|
+
prev = DefaultProps.get(n)
|
|
1514
|
+
continue
|
|
1515
|
+
}
|
|
1516
|
+
const props = configDefaults[n]
|
|
1517
|
+
if (!props) {
|
|
1518
|
+
if (prev) {
|
|
1519
|
+
DefaultProps.set(n, prev)
|
|
1520
|
+
}
|
|
1521
|
+
continue
|
|
1522
|
+
}
|
|
1523
|
+
prev = mergeProps(prev || {}, props, false, conf.inverseShorthands)[0]
|
|
1524
|
+
DefaultProps.set(n, prev)
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
// overwrite the user defined defaults on top of internal defined defaults
|
|
1528
|
+
const ourDefaultsMerged = DefaultProps.get(name)
|
|
1529
|
+
if (ourDefaultsMerged) {
|
|
1530
|
+
return mergeProps(props, ourDefaultsMerged, false, conf.inverseShorthands)[0]
|
|
1531
|
+
}
|
|
1532
|
+
return props
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
const defaults = {
|
|
1536
|
+
left: 0,
|
|
1537
|
+
right: 0,
|
|
1538
|
+
top: 0,
|
|
1539
|
+
bottom: 0,
|
|
1540
|
+
opacity: 1,
|
|
1541
|
+
translateX: 0,
|
|
1542
|
+
translateY: 0,
|
|
1543
|
+
skew: 0,
|
|
1544
|
+
skewX: 0,
|
|
1545
|
+
skewY: 0,
|
|
1546
|
+
scale: 1,
|
|
1547
|
+
rotate: '0deg',
|
|
1548
|
+
rotateY: '0deg',
|
|
1549
|
+
rotateX: '0deg',
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
function ensureBaseHasDefaults(base: ViewStyle, ...pseudos: (ViewStyle | null | undefined)[]) {
|
|
1553
|
+
for (const pseudo of pseudos) {
|
|
1554
|
+
if (!pseudo) continue
|
|
1555
|
+
for (const key in pseudo) {
|
|
1556
|
+
const val = pseudo[key]
|
|
1557
|
+
// can we just use merge() here?
|
|
1558
|
+
if (key === 'transform') {
|
|
1559
|
+
if (typeof val === 'string') {
|
|
1560
|
+
continue
|
|
1561
|
+
}
|
|
1562
|
+
for (const t of val) {
|
|
1563
|
+
const tkey = Object.keys(t)[0]
|
|
1564
|
+
const defaultVal = defaults[tkey]
|
|
1565
|
+
const tDefaultVal = { [tkey]: defaultVal } as any
|
|
1566
|
+
if (!base.transform) {
|
|
1567
|
+
base.transform = [tDefaultVal]
|
|
1568
|
+
} else {
|
|
1569
|
+
if (!base.transform.find((x) => x[tkey])) {
|
|
1570
|
+
base.transform.push(tDefaultVal)
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
} else {
|
|
1575
|
+
if (!(key in base)) {
|
|
1576
|
+
base[key] = defaults[key]
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
function merge(base: ViewStyle, next: ViewStyle) {
|
|
1584
|
+
if (!next.transform || !base.transform) {
|
|
1585
|
+
Object.assign(base, next)
|
|
1586
|
+
return
|
|
1587
|
+
}
|
|
1588
|
+
const { transform, ...rest } = next
|
|
1589
|
+
Object.assign(base, rest)
|
|
1590
|
+
for (const t of transform) {
|
|
1591
|
+
const key = Object.keys(t)[0]
|
|
1592
|
+
const existing = base.transform.find((x) => key in x)
|
|
1593
|
+
if (existing) {
|
|
1594
|
+
existing[key] = t[key]
|
|
1595
|
+
} else {
|
|
1596
|
+
base.transform.push(t)
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1599
|
+
}
|