@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,523 @@
|
|
|
1
|
+
import { isWeb } from '@tamagui/constants'
|
|
2
|
+
|
|
3
|
+
import { getConfig } from '../config'
|
|
4
|
+
import { isDevTools } from '../constants/isDevTools'
|
|
5
|
+
import { Variable, getVariableValue, isVariable } from '../createVariable'
|
|
6
|
+
import {
|
|
7
|
+
DebugProp,
|
|
8
|
+
GenericVariantDefinitions,
|
|
9
|
+
PropMapper,
|
|
10
|
+
SplitStyleState,
|
|
11
|
+
StaticConfigParsed,
|
|
12
|
+
TamaguiInternalConfig,
|
|
13
|
+
VariantSpreadFunction,
|
|
14
|
+
} from '../types'
|
|
15
|
+
import { LanguageContextType } from '../views/FontLanguage.types'
|
|
16
|
+
import { expandStyle } from './expandStyle'
|
|
17
|
+
import { expandStyles } from './expandStyles'
|
|
18
|
+
import { getFontsForLanguage, getVariantExtras } from './getVariantExtras'
|
|
19
|
+
import { isObj } from './isObj'
|
|
20
|
+
import { mergeProps } from './mergeProps'
|
|
21
|
+
|
|
22
|
+
export type ResolveVariableTypes = 'auto' | 'value' | 'variable' | 'both' | 'non-color-value'
|
|
23
|
+
|
|
24
|
+
export const getReturnVariablesAs = (props: any, state: Partial<SplitStyleState>) => {
|
|
25
|
+
return !!props.animation || state.resolveVariablesAs === 'value'
|
|
26
|
+
? isWeb
|
|
27
|
+
? 'non-color-value'
|
|
28
|
+
: 'value'
|
|
29
|
+
: 'auto'
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const createPropMapper = (staticConfig: StaticConfigParsed) => {
|
|
33
|
+
const variants = staticConfig.variants || {}
|
|
34
|
+
|
|
35
|
+
// temp remove classnames
|
|
36
|
+
const defaultProps = mergeProps(staticConfig.defaultProps || {}, {}, false)[0]
|
|
37
|
+
|
|
38
|
+
const mapper: PropMapper = (
|
|
39
|
+
key,
|
|
40
|
+
value,
|
|
41
|
+
theme,
|
|
42
|
+
propsIn,
|
|
43
|
+
state,
|
|
44
|
+
languageContext,
|
|
45
|
+
avoidDefaultProps = false,
|
|
46
|
+
debug
|
|
47
|
+
) => {
|
|
48
|
+
const conf = getConfig()
|
|
49
|
+
if (!conf) {
|
|
50
|
+
throw new Error(`No tamagui config setup`)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const props = state.fallbackProps || propsIn
|
|
54
|
+
const returnVariablesAs = getReturnVariablesAs(props, state)
|
|
55
|
+
|
|
56
|
+
// handled here because we need to resolve this off tokens, its the only one-off like this
|
|
57
|
+
const fontFamily =
|
|
58
|
+
props[conf.inverseShorthands.fontFamily] ||
|
|
59
|
+
props.fontFamily ||
|
|
60
|
+
defaultProps.fontFamily ||
|
|
61
|
+
propsIn.fontFamily ||
|
|
62
|
+
'$body'
|
|
63
|
+
|
|
64
|
+
const variantValue = resolveVariants(
|
|
65
|
+
key,
|
|
66
|
+
value,
|
|
67
|
+
props,
|
|
68
|
+
defaultProps,
|
|
69
|
+
theme,
|
|
70
|
+
variants,
|
|
71
|
+
fontFamily,
|
|
72
|
+
conf,
|
|
73
|
+
returnVariablesAs,
|
|
74
|
+
staticConfig,
|
|
75
|
+
'',
|
|
76
|
+
languageContext,
|
|
77
|
+
avoidDefaultProps,
|
|
78
|
+
debug
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
if (variantValue) {
|
|
82
|
+
return variantValue
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
let shouldReturn = value !== undefined && value !== null
|
|
86
|
+
|
|
87
|
+
// handle shorthands
|
|
88
|
+
if (conf.shorthands[key]) {
|
|
89
|
+
shouldReturn = true
|
|
90
|
+
key = conf.shorthands[key]
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (value) {
|
|
94
|
+
if (value[0] === '$') {
|
|
95
|
+
value = getToken(
|
|
96
|
+
key,
|
|
97
|
+
value,
|
|
98
|
+
conf,
|
|
99
|
+
theme,
|
|
100
|
+
fontFamily,
|
|
101
|
+
languageContext,
|
|
102
|
+
returnVariablesAs,
|
|
103
|
+
debug
|
|
104
|
+
)
|
|
105
|
+
} else if (isVariable(value)) {
|
|
106
|
+
value = resolveVariableValue(key, value, returnVariablesAs)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (shouldReturn) {
|
|
111
|
+
return expandStyle(key, value) || [[key, value]]
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return mapper
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
type StyleResolver = (
|
|
119
|
+
key: string,
|
|
120
|
+
value: any,
|
|
121
|
+
props: Record<string, any>,
|
|
122
|
+
defaultProps: any,
|
|
123
|
+
theme: any,
|
|
124
|
+
variants: GenericVariantDefinitions,
|
|
125
|
+
fontFamily: string,
|
|
126
|
+
conf: TamaguiInternalConfig,
|
|
127
|
+
returnVariablesAs: 'auto' | 'value' | 'non-color-value',
|
|
128
|
+
staticConfig: StaticConfigParsed,
|
|
129
|
+
parentVariantKey: string,
|
|
130
|
+
languageContext?: LanguageContextType,
|
|
131
|
+
avoidDefaultProps?: boolean,
|
|
132
|
+
debug?: DebugProp
|
|
133
|
+
) => any
|
|
134
|
+
|
|
135
|
+
const resolveVariants: StyleResolver = (
|
|
136
|
+
key,
|
|
137
|
+
value,
|
|
138
|
+
props,
|
|
139
|
+
defaultProps,
|
|
140
|
+
theme,
|
|
141
|
+
variants,
|
|
142
|
+
fontFamily,
|
|
143
|
+
conf,
|
|
144
|
+
returnVariablesAs,
|
|
145
|
+
staticConfig,
|
|
146
|
+
parentVariantKey,
|
|
147
|
+
languageContext,
|
|
148
|
+
avoidDefaultProps = false,
|
|
149
|
+
debug
|
|
150
|
+
) => {
|
|
151
|
+
const variant = variants && variants[key]
|
|
152
|
+
if (!variant || value === undefined) {
|
|
153
|
+
return
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
let variantValue = getVariantDefinition(variant, key, value, conf)
|
|
157
|
+
|
|
158
|
+
if (!variantValue) {
|
|
159
|
+
// variant at key exists, but no matching variant value, return nothing
|
|
160
|
+
if (process.env.NODE_ENV === 'development') {
|
|
161
|
+
if (staticConfig.validStyles?.[key]) {
|
|
162
|
+
return null
|
|
163
|
+
}
|
|
164
|
+
if (value === false) {
|
|
165
|
+
// don't warn on missing false values, common to only use true
|
|
166
|
+
return null
|
|
167
|
+
}
|
|
168
|
+
const name = staticConfig.componentName || '[UnnamedComponent]'
|
|
169
|
+
// eslint-disable-next-line no-console
|
|
170
|
+
console.warn(
|
|
171
|
+
`No variant found: ${name} has variant "${key}", but no matching value "${value}"`
|
|
172
|
+
)
|
|
173
|
+
}
|
|
174
|
+
return
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (typeof variantValue === 'function') {
|
|
178
|
+
const fn = variantValue as VariantSpreadFunction<any>
|
|
179
|
+
variantValue = fn(
|
|
180
|
+
value,
|
|
181
|
+
getVariantExtras(props, languageContext, theme, defaultProps, avoidDefaultProps)
|
|
182
|
+
)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
let fontFamilyResult: any
|
|
186
|
+
|
|
187
|
+
if (isObj(variantValue)) {
|
|
188
|
+
const fontFamilyUpdate =
|
|
189
|
+
variantValue.fontFamily || variantValue[conf.inverseShorthands.fontFamily]
|
|
190
|
+
|
|
191
|
+
if (fontFamilyUpdate) {
|
|
192
|
+
fontFamilyResult = getFontFamilyFromNameOrVariable(fontFamilyUpdate, conf)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
variantValue = resolveTokensAndVariants(
|
|
196
|
+
key,
|
|
197
|
+
variantValue,
|
|
198
|
+
props,
|
|
199
|
+
defaultProps,
|
|
200
|
+
theme,
|
|
201
|
+
variants,
|
|
202
|
+
fontFamilyResult || fontFamily,
|
|
203
|
+
conf,
|
|
204
|
+
returnVariablesAs,
|
|
205
|
+
staticConfig,
|
|
206
|
+
parentVariantKey,
|
|
207
|
+
languageContext,
|
|
208
|
+
avoidDefaultProps,
|
|
209
|
+
debug
|
|
210
|
+
)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (variantValue) {
|
|
214
|
+
const next = Object.entries(expandStyles(variantValue))
|
|
215
|
+
|
|
216
|
+
// store any changed font family (only support variables for now)
|
|
217
|
+
if (fontFamilyResult && fontFamilyResult[0] === '$') {
|
|
218
|
+
fontFamilyCache.set(next, getVariableValue(fontFamilyResult))
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return next
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// handles finding and resolving the fontFamily to the token name
|
|
226
|
+
// this is used as `font_[name]` in className for nice css variable support
|
|
227
|
+
export function getFontFamilyFromNameOrVariable(input: any, conf: TamaguiInternalConfig) {
|
|
228
|
+
if (isVariable(input)) {
|
|
229
|
+
const val = variableToFontNameCache.get(input)
|
|
230
|
+
if (val) {
|
|
231
|
+
return val
|
|
232
|
+
} else {
|
|
233
|
+
for (const key in conf.fontsParsed) {
|
|
234
|
+
const familyVariable = conf.fontsParsed[key].family
|
|
235
|
+
if (isVariable(familyVariable)) {
|
|
236
|
+
variableToFontNameCache.set(familyVariable, key)
|
|
237
|
+
if (familyVariable === input) {
|
|
238
|
+
return key
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
} else if (typeof input === 'string') {
|
|
244
|
+
if (input?.[0] === '$') {
|
|
245
|
+
return input
|
|
246
|
+
} else {
|
|
247
|
+
// this could be mapped back to
|
|
248
|
+
if (process.env.NODE_ENV === 'development') {
|
|
249
|
+
// eslint-disable-next-line no-console
|
|
250
|
+
console.log('[tamagui] should map back', input)
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const variableToFontNameCache = new WeakMap<Variable, string>()
|
|
257
|
+
|
|
258
|
+
// special helper for special font family
|
|
259
|
+
const fontFamilyCache = new WeakMap()
|
|
260
|
+
export const getPropMappedFontFamily = (expanded?: any) => {
|
|
261
|
+
return expanded && fontFamilyCache.get(expanded)
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const resolveTokensAndVariants: StyleResolver = (
|
|
265
|
+
key, // we dont use key assume value is object instead
|
|
266
|
+
value,
|
|
267
|
+
props,
|
|
268
|
+
defaultProps,
|
|
269
|
+
theme,
|
|
270
|
+
variants,
|
|
271
|
+
fontFamily,
|
|
272
|
+
conf,
|
|
273
|
+
returnVariablesAs,
|
|
274
|
+
staticConfig,
|
|
275
|
+
parentVariantKey,
|
|
276
|
+
languageContext,
|
|
277
|
+
avoidDefaultProps,
|
|
278
|
+
debug
|
|
279
|
+
) => {
|
|
280
|
+
const res = {}
|
|
281
|
+
for (const rKey in value) {
|
|
282
|
+
const fKey = conf.shorthands[rKey] || rKey
|
|
283
|
+
const val = value[rKey]
|
|
284
|
+
|
|
285
|
+
if (isVariable(val)) {
|
|
286
|
+
res[fKey] = !isWeb || returnVariablesAs === 'value' ? val.val : val.variable
|
|
287
|
+
} else if (variants[fKey]) {
|
|
288
|
+
// avoids infinite loop if variant is matching a style prop
|
|
289
|
+
// eg: { variants: { flex: { true: { flex: 2 } } } }
|
|
290
|
+
if (parentVariantKey === key) {
|
|
291
|
+
res[fKey] = val
|
|
292
|
+
} else {
|
|
293
|
+
Object.assign(
|
|
294
|
+
res,
|
|
295
|
+
Object.fromEntries(
|
|
296
|
+
resolveVariants(
|
|
297
|
+
fKey,
|
|
298
|
+
val,
|
|
299
|
+
props,
|
|
300
|
+
defaultProps,
|
|
301
|
+
theme,
|
|
302
|
+
variants,
|
|
303
|
+
fontFamily,
|
|
304
|
+
conf,
|
|
305
|
+
returnVariablesAs,
|
|
306
|
+
staticConfig,
|
|
307
|
+
key,
|
|
308
|
+
languageContext,
|
|
309
|
+
avoidDefaultProps,
|
|
310
|
+
debug
|
|
311
|
+
)
|
|
312
|
+
)
|
|
313
|
+
)
|
|
314
|
+
}
|
|
315
|
+
} else if (typeof val === 'string') {
|
|
316
|
+
const fVal =
|
|
317
|
+
val[0] === '$'
|
|
318
|
+
? getToken(fKey, val, conf, theme, fontFamily, languageContext, returnVariablesAs, debug)
|
|
319
|
+
: val
|
|
320
|
+
res[fKey] = fVal
|
|
321
|
+
} else {
|
|
322
|
+
if (isObj(val)) {
|
|
323
|
+
// sub-objects: media queries, pseudos, shadowOffset
|
|
324
|
+
res[fKey] = resolveTokensAndVariants(
|
|
325
|
+
fKey,
|
|
326
|
+
val,
|
|
327
|
+
props,
|
|
328
|
+
defaultProps,
|
|
329
|
+
theme,
|
|
330
|
+
variants,
|
|
331
|
+
fontFamily,
|
|
332
|
+
conf,
|
|
333
|
+
returnVariablesAs,
|
|
334
|
+
staticConfig,
|
|
335
|
+
key,
|
|
336
|
+
languageContext,
|
|
337
|
+
avoidDefaultProps,
|
|
338
|
+
debug
|
|
339
|
+
)
|
|
340
|
+
} else {
|
|
341
|
+
// nullish values cant be tokens, need no extra parsing
|
|
342
|
+
res[fKey] = value[fKey]
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
if (process.env.NODE_ENV === 'development') {
|
|
346
|
+
if (res[fKey]?.[0] === '$') {
|
|
347
|
+
console.warn(`⚠️ Missing token in theme ${theme.name}:`, fKey, res[fKey])
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return res
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// goes through specificity finding best matching variant function
|
|
355
|
+
function getVariantDefinition(variant: any, key: string, value: any, conf: TamaguiInternalConfig) {
|
|
356
|
+
if (typeof variant === 'function') {
|
|
357
|
+
return variant
|
|
358
|
+
}
|
|
359
|
+
if (variant[value]) {
|
|
360
|
+
return variant[value]
|
|
361
|
+
}
|
|
362
|
+
const { tokensParsed } = conf
|
|
363
|
+
if (variant['...size'] && value in tokensParsed.size) {
|
|
364
|
+
return variant['...size']
|
|
365
|
+
}
|
|
366
|
+
if (variant['...color'] && value in tokensParsed.color) {
|
|
367
|
+
return variant['...color']
|
|
368
|
+
}
|
|
369
|
+
if (variant['...radius'] && value in tokensParsed.radius) {
|
|
370
|
+
return variant['...radius']
|
|
371
|
+
}
|
|
372
|
+
if (variant['...space'] && value in tokensParsed.space) {
|
|
373
|
+
return variant['...space']
|
|
374
|
+
}
|
|
375
|
+
if (variant['...zIndex'] && value in tokensParsed.zIndex) {
|
|
376
|
+
return variant['...zIndex']
|
|
377
|
+
}
|
|
378
|
+
let fn: any
|
|
379
|
+
if (typeof value === 'number') {
|
|
380
|
+
fn = variant[':number']
|
|
381
|
+
} else if (typeof value === 'string') {
|
|
382
|
+
fn = variant[':string']
|
|
383
|
+
} else if (value === true || value === false) {
|
|
384
|
+
fn = variant[':boolean']
|
|
385
|
+
}
|
|
386
|
+
// fallback to catch all or size
|
|
387
|
+
return fn || variant['...'] || variant['...size']
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
const fontShorthand = {
|
|
391
|
+
fontSize: 'size',
|
|
392
|
+
fontWeight: 'weight',
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
const getToken = (
|
|
396
|
+
key: string,
|
|
397
|
+
value: string,
|
|
398
|
+
conf: TamaguiInternalConfig,
|
|
399
|
+
theme: any,
|
|
400
|
+
fontFamily: string | undefined = '$body',
|
|
401
|
+
languageContext?: LanguageContextType,
|
|
402
|
+
resolveAs?: ResolveVariableTypes,
|
|
403
|
+
debug?: DebugProp
|
|
404
|
+
) => {
|
|
405
|
+
const tokensParsed = conf.tokensParsed
|
|
406
|
+
const fontsParsed = languageContext
|
|
407
|
+
? getFontsForLanguage(conf.fontsParsed, languageContext)
|
|
408
|
+
: conf.fontsParsed
|
|
409
|
+
let valOrVar: any
|
|
410
|
+
let hasSet = false
|
|
411
|
+
if (theme[value]) {
|
|
412
|
+
valOrVar = theme[value]
|
|
413
|
+
hasSet = true
|
|
414
|
+
} else {
|
|
415
|
+
switch (key) {
|
|
416
|
+
case 'fontFamily':
|
|
417
|
+
valOrVar = fontsParsed[value]?.family || value
|
|
418
|
+
hasSet = true
|
|
419
|
+
break
|
|
420
|
+
case 'fontSize':
|
|
421
|
+
case 'lineHeight':
|
|
422
|
+
case 'letterSpacing':
|
|
423
|
+
case 'fontWeight':
|
|
424
|
+
valOrVar = fontsParsed[fontFamily]?.[fontShorthand[key] || key]?.[value] || value
|
|
425
|
+
hasSet = true
|
|
426
|
+
break
|
|
427
|
+
}
|
|
428
|
+
for (const cat in tokenCategories) {
|
|
429
|
+
if (key in tokenCategories[cat]) {
|
|
430
|
+
const res = tokensParsed[cat][value]
|
|
431
|
+
if (res) {
|
|
432
|
+
valOrVar = res
|
|
433
|
+
hasSet = true
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
if (!hasSet) {
|
|
438
|
+
const spaceVar = tokensParsed.space[value]
|
|
439
|
+
if (spaceVar) {
|
|
440
|
+
valOrVar = spaceVar
|
|
441
|
+
hasSet = true
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
if (hasSet) {
|
|
446
|
+
if (process.env.NODE_ENV === 'development' && isDevTools && debug === 'verbose') {
|
|
447
|
+
// eslint-disable-next-line no-console
|
|
448
|
+
console.log(` ﹒ propMapper getToken`, key, valOrVar)
|
|
449
|
+
}
|
|
450
|
+
return resolveVariableValue(key, valOrVar, resolveAs)
|
|
451
|
+
}
|
|
452
|
+
if (process.env.NODE_ENV === 'development') {
|
|
453
|
+
if (value && value[0] === '$') {
|
|
454
|
+
// eslint-disable-next-line no-console
|
|
455
|
+
console.trace(
|
|
456
|
+
`⚠️ You've passed the value "${value}" to the style property "${key}", but there's no theme or token with the key "${value}". Using theme "${theme.name}".
|
|
457
|
+
|
|
458
|
+
Set the debug prop to true to see more detailed debug information.`
|
|
459
|
+
)
|
|
460
|
+
if (debug) {
|
|
461
|
+
if (isDevTools) {
|
|
462
|
+
// eslint-disable-next-line no-console
|
|
463
|
+
console.log('Looked in:', { theme, tokensParsed, fontsParsed })
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
return null
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
return value
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
function resolveVariableValue(
|
|
473
|
+
key: string,
|
|
474
|
+
valOrVar: Variable | any,
|
|
475
|
+
resolveAs: ResolveVariableTypes = 'auto'
|
|
476
|
+
) {
|
|
477
|
+
if (isVariable(valOrVar)) {
|
|
478
|
+
if (resolveAs === 'variable') {
|
|
479
|
+
return valOrVar
|
|
480
|
+
}
|
|
481
|
+
if (resolveAs === 'non-color-value') {
|
|
482
|
+
if (isWeb) {
|
|
483
|
+
if (key in tokenCategories.color) {
|
|
484
|
+
return valOrVar.variable
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
return valOrVar.val
|
|
488
|
+
}
|
|
489
|
+
if (!isWeb || resolveAs === 'value') {
|
|
490
|
+
return valOrVar.val
|
|
491
|
+
}
|
|
492
|
+
return valOrVar.variable
|
|
493
|
+
}
|
|
494
|
+
return valOrVar
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
// just specificy the least costly, all else go to `space` (most keys - we can exclude)
|
|
498
|
+
const tokenCategories = {
|
|
499
|
+
radius: {
|
|
500
|
+
borderRadius: true,
|
|
501
|
+
borderTopLeftRadius: true,
|
|
502
|
+
borderTopRightRadius: true,
|
|
503
|
+
borderBottomLeftRadius: true,
|
|
504
|
+
borderBottomRightRadius: true,
|
|
505
|
+
},
|
|
506
|
+
size: {
|
|
507
|
+
width: true,
|
|
508
|
+
height: true,
|
|
509
|
+
minWidth: true,
|
|
510
|
+
minHeight: true,
|
|
511
|
+
maxWidth: true,
|
|
512
|
+
maxHeight: true,
|
|
513
|
+
},
|
|
514
|
+
color: {
|
|
515
|
+
color: true,
|
|
516
|
+
backgroundColor: true,
|
|
517
|
+
borderColor: true,
|
|
518
|
+
borderBottomColor: true,
|
|
519
|
+
borderTopColor: true,
|
|
520
|
+
borderLeftColor: true,
|
|
521
|
+
borderRightColor: true,
|
|
522
|
+
},
|
|
523
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Some parts adapted from react-native-web
|
|
3
|
+
* Copyright (c) Nicolas Gallagher licensed under the MIT license.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { isWeb } from '@tamagui/constants'
|
|
7
|
+
|
|
8
|
+
export function expandStyle(key: string, value: any) {
|
|
9
|
+
if (process.env.TAMAGUI_TARGET === 'web') {
|
|
10
|
+
if (key === 'flex') {
|
|
11
|
+
// The 'flex' property value in React Native must be a positive integer,
|
|
12
|
+
// 0, or -1.
|
|
13
|
+
if (value <= -1) {
|
|
14
|
+
return [
|
|
15
|
+
['flexGrow', 0],
|
|
16
|
+
['flexShrink', 1],
|
|
17
|
+
['flexBasis', 'auto'],
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
// normalizing to better align with native
|
|
21
|
+
// see spec for flex shorthand https://developer.mozilla.org/en-US/docs/Web/CSS/flex
|
|
22
|
+
if (value >= 0) {
|
|
23
|
+
return [
|
|
24
|
+
['flexGrow', value],
|
|
25
|
+
['flexShrink', 1],
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
return
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// web only
|
|
32
|
+
switch (key) {
|
|
33
|
+
case 'aspectRatio': {
|
|
34
|
+
return [[key, value.toString()]]
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
case 'textAlignVertical': {
|
|
38
|
+
return [['verticalAlign', value === 'center' ? 'middle' : value]]
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
case 'textDecorationLine': {
|
|
42
|
+
return [['textDecorationLine', value]]
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
case 'writingDirection': {
|
|
46
|
+
return [['direction', value]]
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const longKey = STYLE_SHORT_FORM_EXPANSIONS[key]
|
|
52
|
+
if (longKey) {
|
|
53
|
+
return longKey.map((key) => {
|
|
54
|
+
return [key, value]
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const STYLE_SHORT_FORM_EXPANSIONS: Record<string, string[]> = {
|
|
60
|
+
borderColor: ['borderTopColor', 'borderRightColor', 'borderBottomColor', 'borderLeftColor'],
|
|
61
|
+
borderRadius: [
|
|
62
|
+
'borderTopLeftRadius',
|
|
63
|
+
'borderTopRightRadius',
|
|
64
|
+
'borderBottomRightRadius',
|
|
65
|
+
'borderBottomLeftRadius',
|
|
66
|
+
],
|
|
67
|
+
borderWidth: ['borderTopWidth', 'borderRightWidth', 'borderBottomWidth', 'borderLeftWidth'],
|
|
68
|
+
margin: ['marginTop', 'marginRight', 'marginBottom', 'marginLeft'],
|
|
69
|
+
marginHorizontal: ['marginRight', 'marginLeft'],
|
|
70
|
+
marginVertical: ['marginTop', 'marginBottom'],
|
|
71
|
+
overscrollBehavior: ['overscrollBehaviorX', 'overscrollBehaviorY'],
|
|
72
|
+
padding: ['paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft'],
|
|
73
|
+
paddingHorizontal: ['paddingRight', 'paddingLeft'],
|
|
74
|
+
paddingVertical: ['paddingTop', 'paddingBottom'],
|
|
75
|
+
...(isWeb && {
|
|
76
|
+
// react-native only supports borderStyle
|
|
77
|
+
borderStyle: ['borderTopStyle', 'borderRightStyle', 'borderBottomStyle', 'borderLeftStyle'],
|
|
78
|
+
// react-native doesn't support X / Y
|
|
79
|
+
overflow: ['overflowX', 'overflowY'],
|
|
80
|
+
}),
|
|
81
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { isWeb } from '@tamagui/constants'
|
|
2
|
+
|
|
3
|
+
import { getConfig } from '../config'
|
|
4
|
+
import { expandStyle } from './expandStyle'
|
|
5
|
+
import { colorToRGBA, normalizeColor } from './normalizeColor'
|
|
6
|
+
import { normalizeValueWithProperty } from './normalizeValueWithProperty.js'
|
|
7
|
+
import { pseudoDescriptors } from './pseudoDescriptors'
|
|
8
|
+
|
|
9
|
+
let shorthands: Record<string, string> | null = null
|
|
10
|
+
export const defaultOffset = { height: 0, width: 0 }
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* This is what you want to run before Object.assign() a style onto another.
|
|
14
|
+
* It does the following:
|
|
15
|
+
* 1. Turns user shorthands into longhands, ie px = paddingHorizontal
|
|
16
|
+
* 2. Normalizes various inconsistent styles to be more consistent
|
|
17
|
+
* 3. Expands react-native shorthands, ie paddingHorizontal => paddingLeft, paddingRight
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export function expandStyles(style: Record<string, any>, config = getConfig()) {
|
|
21
|
+
const res: Record<string, any> = {}
|
|
22
|
+
|
|
23
|
+
for (let key in style) {
|
|
24
|
+
shorthands = shorthands || (config ? config.shorthands : null)
|
|
25
|
+
if (shorthands) {
|
|
26
|
+
key = shorthands[key] || key
|
|
27
|
+
}
|
|
28
|
+
if (key in pseudoDescriptors) {
|
|
29
|
+
res[key] = expandStyles(style[key])
|
|
30
|
+
continue
|
|
31
|
+
}
|
|
32
|
+
const val = normalizeValueWithProperty(style[key], key)
|
|
33
|
+
// expand react-native shorthands
|
|
34
|
+
const out = expandStyle(key, val)
|
|
35
|
+
if (out) {
|
|
36
|
+
Object.assign(res, Object.fromEntries(out))
|
|
37
|
+
} else {
|
|
38
|
+
res[key] = val
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
fixStyles(res)
|
|
43
|
+
|
|
44
|
+
return res
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function fixStyles(style: Record<string, any>) {
|
|
48
|
+
if (style.shadowRadius) {
|
|
49
|
+
Object.assign(style, normalizeShadow(style))
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// ensure border style set by default to solid
|
|
53
|
+
for (const key in borderDefaults) {
|
|
54
|
+
if (style[key] && !style[borderDefaults[key]]) {
|
|
55
|
+
style[borderDefaults[key]] = 'solid'
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const borderDefaults = {
|
|
61
|
+
borderWidth: 'borderStyle',
|
|
62
|
+
borderBottomWidth: 'borderBottomStyle',
|
|
63
|
+
borderTopWidth: 'borderTopStyle',
|
|
64
|
+
borderLeftWidth: 'borderLeftStyle',
|
|
65
|
+
borderRightWidth: 'borderRightStyle',
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function normalizeShadow({
|
|
69
|
+
shadowColor,
|
|
70
|
+
shadowOffset,
|
|
71
|
+
shadowOpacity,
|
|
72
|
+
shadowRadius,
|
|
73
|
+
}: Record<string, any>) {
|
|
74
|
+
const { height, width } = shadowOffset || defaultOffset
|
|
75
|
+
const colorStr = String(shadowColor || 'black')
|
|
76
|
+
return {
|
|
77
|
+
shadowOffset: {
|
|
78
|
+
width: normalizeValueWithProperty(width || 0),
|
|
79
|
+
height: normalizeValueWithProperty(height || 0),
|
|
80
|
+
},
|
|
81
|
+
shadowRadius: normalizeValueWithProperty(shadowRadius || 0),
|
|
82
|
+
...(isWeb && {
|
|
83
|
+
shadowColor: normalizeColor(colorStr, shadowOpacity),
|
|
84
|
+
}),
|
|
85
|
+
...(process.env.TAMAGUI_TARGET === 'native' &&
|
|
86
|
+
(() => {
|
|
87
|
+
// on native fix bug - shadows behave better if turned into non-alpha rgb() + shadowOpacity
|
|
88
|
+
const rgba = colorToRGBA(colorStr)
|
|
89
|
+
if (!rgba) {
|
|
90
|
+
if (process.env.NODE_ENV === 'development') {
|
|
91
|
+
// eslint-disable-next-line no-console
|
|
92
|
+
console.warn('No rgba form', colorStr)
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
shadowColor,
|
|
96
|
+
shadowOpacity,
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const [r, g, b, a] = rgba
|
|
100
|
+
return {
|
|
101
|
+
shadowColor: `rgb(${r},${g},${b})`,
|
|
102
|
+
shadowOpacity: shadowOpacity ?? a,
|
|
103
|
+
}
|
|
104
|
+
})()),
|
|
105
|
+
}
|
|
106
|
+
}
|