@tamagui/core 1.2.4 → 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/cjs/hooks/usePlatformMethods.js +48 -0
- package/dist/cjs/hooks/usePlatformMethods.js.map +7 -0
- package/dist/cjs/index.js +152 -75
- package/dist/cjs/index.js.map +3 -3
- package/dist/cjs/{types.js → reactNativeTypes.js} +3 -3
- package/dist/cjs/reactNativeTypes.js.map +7 -0
- package/dist/esm/hooks/usePlatformMethods.js +24 -0
- package/dist/esm/hooks/usePlatformMethods.js.map +7 -0
- package/dist/esm/index.js +157 -71
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/reactNativeTypes.js +1 -0
- package/dist/esm/{types-rnw.js.map → reactNativeTypes.js.map} +0 -0
- package/package.json +5 -11
- package/src/hooks/usePlatformMethods.ts +26 -0
- package/src/index.ts +214 -71
- package/src/reactNativeTypes.ts +104 -0
- package/types/hooks/usePlatformMethods.d.ts +3 -0
- package/types/hooks/usePlatformMethods.d.ts.map +1 -0
- package/types/index.d.ts +6 -54
- package/types/index.d.ts.map +1 -1
- package/types/reactNativeTypes.d.ts +26 -0
- package/types/reactNativeTypes.d.ts.map +1 -0
- package/dist/cjs/Tamagui.js +0 -77
- package/dist/cjs/Tamagui.js.map +0 -7
- package/dist/cjs/addTheme.js +0 -78
- package/dist/cjs/addTheme.js.map +0 -7
- package/dist/cjs/config.js +0 -91
- package/dist/cjs/config.js.map +0 -7
- package/dist/cjs/constants/constants.js +0 -49
- package/dist/cjs/constants/constants.js.map +0 -7
- package/dist/cjs/constants/isDevTools.js +0 -37
- package/dist/cjs/constants/isDevTools.js.map +0 -7
- package/dist/cjs/contexts/ButtonNestingContext.js +0 -30
- package/dist/cjs/contexts/ButtonNestingContext.js.map +0 -7
- package/dist/cjs/contexts/FontLanguageContext.js +0 -30
- package/dist/cjs/contexts/FontLanguageContext.js.map +0 -7
- package/dist/cjs/contexts/TextAncestorContext.js +0 -30
- package/dist/cjs/contexts/TextAncestorContext.js.map +0 -7
- package/dist/cjs/createComponent.js +0 -993
- package/dist/cjs/createComponent.js.map +0 -7
- package/dist/cjs/createFont.js +0 -69
- package/dist/cjs/createFont.js.map +0 -7
- package/dist/cjs/createFont.web.test.js +0 -125
- package/dist/cjs/createFont.web.test.js.map +0 -7
- package/dist/cjs/createShorthands.js +0 -31
- package/dist/cjs/createShorthands.js.map +0 -7
- package/dist/cjs/createTamagui.js +0 -206
- package/dist/cjs/createTamagui.js.map +0 -7
- package/dist/cjs/createTheme.js +0 -31
- package/dist/cjs/createTheme.js.map +0 -7
- package/dist/cjs/createTokens.js +0 -39
- package/dist/cjs/createTokens.js.map +0 -7
- package/dist/cjs/createTokens.web.test.js +0 -28
- package/dist/cjs/createTokens.web.test.js.map +0 -7
- package/dist/cjs/createVariable.js +0 -111
- package/dist/cjs/createVariable.js.map +0 -7
- package/dist/cjs/createVariable.web.test.js +0 -7
- package/dist/cjs/createVariable.web.test.js.map +0 -7
- package/dist/cjs/createVariables.js +0 -60
- package/dist/cjs/createVariables.js.map +0 -7
- package/dist/cjs/helpers/RNComponents.js +0 -40
- package/dist/cjs/helpers/RNComponents.js.map +0 -7
- package/dist/cjs/helpers/ThemeManager.js +0 -234
- package/dist/cjs/helpers/ThemeManager.js.map +0 -7
- package/dist/cjs/helpers/ThemeManager.test.js +0 -465
- package/dist/cjs/helpers/ThemeManager.test.js.map +0 -7
- package/dist/cjs/helpers/ThemeManagerContext.js +0 -30
- package/dist/cjs/helpers/ThemeManagerContext.js.map +0 -7
- package/dist/cjs/helpers/createMediaStyle.js +0 -67
- package/dist/cjs/helpers/createMediaStyle.js.map +0 -7
- package/dist/cjs/helpers/createPropMapper.js +0 -423
- package/dist/cjs/helpers/createPropMapper.js.map +0 -7
- package/dist/cjs/helpers/createProxy.js +0 -43
- package/dist/cjs/helpers/createProxy.js.map +0 -7
- package/dist/cjs/helpers/expandStyle.js +0 -95
- package/dist/cjs/helpers/expandStyle.js.map +0 -7
- package/dist/cjs/helpers/expandStyles.js +0 -116
- package/dist/cjs/helpers/expandStyles.js.map +0 -7
- package/dist/cjs/helpers/extendStaticConfig.js +0 -91
- package/dist/cjs/helpers/extendStaticConfig.js.map +0 -7
- package/dist/cjs/helpers/fixNativeShadow.js +0 -30
- package/dist/cjs/helpers/fixNativeShadow.js.map +0 -7
- package/dist/cjs/helpers/getAnimationDriver.js +0 -32
- package/dist/cjs/helpers/getAnimationDriver.js.map +0 -7
- package/dist/cjs/helpers/getExpandedShorthands.js +0 -40
- package/dist/cjs/helpers/getExpandedShorthands.js.map +0 -7
- package/dist/cjs/helpers/getFontLanguage.js +0 -29
- package/dist/cjs/helpers/getFontLanguage.js.map +0 -7
- package/dist/cjs/helpers/getSplitStyles.js +0 -848
- package/dist/cjs/helpers/getSplitStyles.js.map +0 -7
- package/dist/cjs/helpers/getStylesAtomic.js +0 -226
- package/dist/cjs/helpers/getStylesAtomic.js.map +0 -7
- package/dist/cjs/helpers/getStylesAtomic.native.js +0 -38
- package/dist/cjs/helpers/getStylesAtomic.native.js.map +0 -7
- package/dist/cjs/helpers/getThemeCSSRules.js +0 -110
- package/dist/cjs/helpers/getThemeCSSRules.js.map +0 -7
- package/dist/cjs/helpers/getThemeCSSRules.native.js +0 -31
- package/dist/cjs/helpers/getThemeCSSRules.native.js.map +0 -7
- package/dist/cjs/helpers/getVariantExtras.js +0 -92
- package/dist/cjs/helpers/getVariantExtras.js.map +0 -7
- package/dist/cjs/helpers/insertStyleRule.js +0 -218
- package/dist/cjs/helpers/insertStyleRule.js.map +0 -7
- package/dist/cjs/helpers/isObj.js +0 -29
- package/dist/cjs/helpers/isObj.js.map +0 -7
- package/dist/cjs/helpers/isTamaguiComponent.js +0 -32
- package/dist/cjs/helpers/isTamaguiComponent.js.map +0 -7
- package/dist/cjs/helpers/isTamaguiElement.js +0 -33
- package/dist/cjs/helpers/isTamaguiElement.js.map +0 -7
- package/dist/cjs/helpers/matchMedia.js +0 -42
- package/dist/cjs/helpers/matchMedia.js.map +0 -7
- package/dist/cjs/helpers/matchMedia.native.js +0 -48
- package/dist/cjs/helpers/matchMedia.native.js.map +0 -7
- package/dist/cjs/helpers/mergeProps.js +0 -54
- package/dist/cjs/helpers/mergeProps.js.map +0 -7
- package/dist/cjs/helpers/mergeTransform.js +0 -47
- package/dist/cjs/helpers/mergeTransform.js.map +0 -7
- package/dist/cjs/helpers/normalizeColor.js +0 -71
- package/dist/cjs/helpers/normalizeColor.js.map +0 -7
- package/dist/cjs/helpers/normalizeValueWithProperty.js +0 -138
- package/dist/cjs/helpers/normalizeValueWithProperty.js.map +0 -7
- package/dist/cjs/helpers/proxyThemeVariables.js +0 -40
- package/dist/cjs/helpers/proxyThemeVariables.js.map +0 -7
- package/dist/cjs/helpers/pseudoDescriptors.js +0 -53
- package/dist/cjs/helpers/pseudoDescriptors.js.map +0 -7
- package/dist/cjs/helpers/registerCSSVariable.js +0 -40
- package/dist/cjs/helpers/registerCSSVariable.js.map +0 -7
- package/dist/cjs/helpers/themeable.js +0 -62
- package/dist/cjs/helpers/themeable.js.map +0 -7
- package/dist/cjs/helpers/themes.js +0 -78
- package/dist/cjs/helpers/themes.js.map +0 -7
- package/dist/cjs/helpers/timer.js +0 -35
- package/dist/cjs/helpers/timer.js.map +0 -7
- package/dist/cjs/helpers/useShallowSetState.js +0 -59
- package/dist/cjs/helpers/useShallowSetState.js.map +0 -7
- package/dist/cjs/helpers/warnOnce.js +0 -38
- package/dist/cjs/helpers/warnOnce.js.map +0 -7
- package/dist/cjs/helpers/withStaticProperties.js +0 -32
- package/dist/cjs/helpers/withStaticProperties.js.map +0 -7
- package/dist/cjs/hooks/getThemeUnwrapped.js +0 -34
- package/dist/cjs/hooks/getThemeUnwrapped.js.map +0 -7
- package/dist/cjs/hooks/useId.js +0 -29
- package/dist/cjs/hooks/useId.js.map +0 -7
- package/dist/cjs/hooks/useIsTouchDevice.js +0 -33
- package/dist/cjs/hooks/useIsTouchDevice.js.map +0 -7
- package/dist/cjs/hooks/useMedia.js +0 -263
- package/dist/cjs/hooks/useMedia.js.map +0 -7
- package/dist/cjs/hooks/useSafeRef.js +0 -59
- package/dist/cjs/hooks/useSafeRef.js.map +0 -7
- package/dist/cjs/hooks/useServerHooks.js +0 -36
- package/dist/cjs/hooks/useServerHooks.js.map +0 -7
- package/dist/cjs/hooks/useStyle.js +0 -61
- package/dist/cjs/hooks/useStyle.js.map +0 -7
- package/dist/cjs/hooks/useTheme.js +0 -230
- package/dist/cjs/hooks/useTheme.js.map +0 -7
- package/dist/cjs/hooks/useThemeName.js +0 -52
- package/dist/cjs/hooks/useThemeName.js.map +0 -7
- package/dist/cjs/insertFont.js +0 -93
- package/dist/cjs/insertFont.js.map +0 -7
- package/dist/cjs/setupReactNative.js +0 -51
- package/dist/cjs/setupReactNative.js.map +0 -7
- package/dist/cjs/static.js +0 -20
- package/dist/cjs/static.js.map +0 -7
- package/dist/cjs/styled.js +0 -95
- package/dist/cjs/styled.js.map +0 -7
- package/dist/cjs/types-rnw.js +0 -17
- package/dist/cjs/types-rnw.js.map +0 -7
- package/dist/cjs/types.js.map +0 -7
- package/dist/cjs/updateTheme.js +0 -47
- package/dist/cjs/updateTheme.js.map +0 -7
- package/dist/cjs/views/FontLanguage.js +0 -41
- package/dist/cjs/views/FontLanguage.js.map +0 -7
- package/dist/cjs/views/FontLanguage.native.js +0 -35
- package/dist/cjs/views/FontLanguage.native.js.map +0 -7
- package/dist/cjs/views/FontLanguage.types.js +0 -17
- package/dist/cjs/views/FontLanguage.types.js.map +0 -7
- package/dist/cjs/views/Slot.js +0 -92
- package/dist/cjs/views/Slot.js.map +0 -7
- package/dist/cjs/views/Stack.js +0 -38
- package/dist/cjs/views/Stack.js.map +0 -7
- package/dist/cjs/views/Stack.web.test.js +0 -22
- package/dist/cjs/views/Stack.web.test.js.map +0 -7
- package/dist/cjs/views/TamaguiProvider.js +0 -90
- package/dist/cjs/views/TamaguiProvider.js.map +0 -7
- package/dist/cjs/views/Text.js +0 -94
- package/dist/cjs/views/Text.js.map +0 -7
- package/dist/cjs/views/Theme.js +0 -88
- package/dist/cjs/views/Theme.js.map +0 -7
- package/dist/cjs/views/ThemeProvider.js +0 -70
- package/dist/cjs/views/ThemeProvider.js.map +0 -7
- package/dist/esm/Tamagui.js +0 -41
- package/dist/esm/Tamagui.js.map +0 -7
- package/dist/esm/addTheme.js +0 -54
- package/dist/esm/addTheme.js.map +0 -7
- package/dist/esm/config.js +0 -58
- package/dist/esm/config.js.map +0 -7
- package/dist/esm/constants/constants.js +0 -22
- package/dist/esm/constants/constants.js.map +0 -7
- package/dist/esm/constants/isDevTools.js +0 -13
- package/dist/esm/constants/isDevTools.js.map +0 -7
- package/dist/esm/contexts/ButtonNestingContext.js +0 -6
- package/dist/esm/contexts/ButtonNestingContext.js.map +0 -7
- package/dist/esm/contexts/FontLanguageContext.js +0 -6
- package/dist/esm/contexts/FontLanguageContext.js.map +0 -7
- package/dist/esm/contexts/TextAncestorContext.js +0 -6
- package/dist/esm/contexts/TextAncestorContext.js.map +0 -7
- package/dist/esm/createComponent.js +0 -975
- package/dist/esm/createComponent.js.map +0 -7
- package/dist/esm/createFont.js +0 -45
- package/dist/esm/createFont.js.map +0 -7
- package/dist/esm/createFont.web.test.js +0 -124
- package/dist/esm/createFont.web.test.js.map +0 -7
- package/dist/esm/createShorthands.js +0 -7
- package/dist/esm/createShorthands.js.map +0 -7
- package/dist/esm/createTamagui.js +0 -190
- package/dist/esm/createTamagui.js.map +0 -7
- package/dist/esm/createTheme.js +0 -7
- package/dist/esm/createTheme.js.map +0 -7
- package/dist/esm/createTokens.js +0 -15
- package/dist/esm/createTokens.js.map +0 -7
- package/dist/esm/createTokens.web.test.js +0 -27
- package/dist/esm/createTokens.web.test.js.map +0 -7
- package/dist/esm/createVariable.js +0 -78
- package/dist/esm/createVariable.js.map +0 -7
- package/dist/esm/createVariable.web.test.js +0 -6
- package/dist/esm/createVariable.web.test.js.map +0 -7
- package/dist/esm/createVariables.js +0 -35
- package/dist/esm/createVariables.js.map +0 -7
- package/dist/esm/helpers/RNComponents.js +0 -16
- package/dist/esm/helpers/RNComponents.js.map +0 -7
- package/dist/esm/helpers/ThemeManager.js +0 -209
- package/dist/esm/helpers/ThemeManager.js.map +0 -7
- package/dist/esm/helpers/ThemeManager.test.js +0 -464
- package/dist/esm/helpers/ThemeManager.test.js.map +0 -7
- package/dist/esm/helpers/ThemeManagerContext.js +0 -6
- package/dist/esm/helpers/ThemeManagerContext.js.map +0 -7
- package/dist/esm/helpers/createMediaStyle.js +0 -42
- package/dist/esm/helpers/createMediaStyle.js.map +0 -7
- package/dist/esm/helpers/createPropMapper.js +0 -396
- package/dist/esm/helpers/createPropMapper.js.map +0 -7
- package/dist/esm/helpers/createProxy.js +0 -19
- package/dist/esm/helpers/createProxy.js.map +0 -7
- package/dist/esm/helpers/expandStyle.js +0 -71
- package/dist/esm/helpers/expandStyle.js.map +0 -7
- package/dist/esm/helpers/expandStyles.js +0 -90
- package/dist/esm/helpers/expandStyles.js.map +0 -7
- package/dist/esm/helpers/extendStaticConfig.js +0 -66
- package/dist/esm/helpers/extendStaticConfig.js.map +0 -7
- package/dist/esm/helpers/fixNativeShadow.js +0 -6
- package/dist/esm/helpers/fixNativeShadow.js.map +0 -7
- package/dist/esm/helpers/getAnimationDriver.js +0 -8
- package/dist/esm/helpers/getAnimationDriver.js.map +0 -7
- package/dist/esm/helpers/getExpandedShorthands.js +0 -16
- package/dist/esm/helpers/getExpandedShorthands.js.map +0 -7
- package/dist/esm/helpers/getFontLanguage.js +0 -5
- package/dist/esm/helpers/getFontLanguage.js.map +0 -7
- package/dist/esm/helpers/getSplitStyles.js +0 -847
- package/dist/esm/helpers/getSplitStyles.js.map +0 -7
- package/dist/esm/helpers/getStylesAtomic.js +0 -200
- package/dist/esm/helpers/getStylesAtomic.js.map +0 -7
- package/dist/esm/helpers/getStylesAtomic.native.js +0 -12
- package/dist/esm/helpers/getStylesAtomic.native.js.map +0 -7
- package/dist/esm/helpers/getThemeCSSRules.js +0 -86
- package/dist/esm/helpers/getThemeCSSRules.js.map +0 -7
- package/dist/esm/helpers/getThemeCSSRules.native.js +0 -7
- package/dist/esm/helpers/getThemeCSSRules.native.js.map +0 -7
- package/dist/esm/helpers/getVariantExtras.js +0 -67
- package/dist/esm/helpers/getVariantExtras.js.map +0 -7
- package/dist/esm/helpers/insertStyleRule.js +0 -186
- package/dist/esm/helpers/insertStyleRule.js.map +0 -7
- package/dist/esm/helpers/isObj.js +0 -5
- package/dist/esm/helpers/isObj.js.map +0 -7
- package/dist/esm/helpers/isTamaguiComponent.js +0 -8
- package/dist/esm/helpers/isTamaguiComponent.js.map +0 -7
- package/dist/esm/helpers/isTamaguiElement.js +0 -9
- package/dist/esm/helpers/isTamaguiElement.js.map +0 -7
- package/dist/esm/helpers/matchMedia.js +0 -17
- package/dist/esm/helpers/matchMedia.js.map +0 -7
- package/dist/esm/helpers/matchMedia.native.js +0 -23
- package/dist/esm/helpers/matchMedia.native.js.map +0 -7
- package/dist/esm/helpers/mergeProps.js +0 -30
- package/dist/esm/helpers/mergeProps.js.map +0 -7
- package/dist/esm/helpers/mergeTransform.js +0 -21
- package/dist/esm/helpers/mergeTransform.js.map +0 -7
- package/dist/esm/helpers/normalizeColor.js +0 -36
- package/dist/esm/helpers/normalizeColor.js.map +0 -7
- package/dist/esm/helpers/normalizeValueWithProperty.js +0 -113
- package/dist/esm/helpers/normalizeValueWithProperty.js.map +0 -7
- package/dist/esm/helpers/proxyThemeVariables.js +0 -16
- package/dist/esm/helpers/proxyThemeVariables.js.map +0 -7
- package/dist/esm/helpers/pseudoDescriptors.js +0 -29
- package/dist/esm/helpers/pseudoDescriptors.js.map +0 -7
- package/dist/esm/helpers/registerCSSVariable.js +0 -14
- package/dist/esm/helpers/registerCSSVariable.js.map +0 -7
- package/dist/esm/helpers/themeable.js +0 -28
- package/dist/esm/helpers/themeable.js.map +0 -7
- package/dist/esm/helpers/themes.js +0 -53
- package/dist/esm/helpers/themes.js.map +0 -7
- package/dist/esm/helpers/timer.js +0 -11
- package/dist/esm/helpers/timer.js.map +0 -7
- package/dist/esm/helpers/useShallowSetState.js +0 -35
- package/dist/esm/helpers/useShallowSetState.js.map +0 -7
- package/dist/esm/helpers/warnOnce.js +0 -14
- package/dist/esm/helpers/warnOnce.js.map +0 -7
- package/dist/esm/helpers/withStaticProperties.js +0 -8
- package/dist/esm/helpers/withStaticProperties.js.map +0 -7
- package/dist/esm/hooks/getThemeUnwrapped.js +0 -9
- package/dist/esm/hooks/getThemeUnwrapped.js.map +0 -7
- package/dist/esm/hooks/useId.js +0 -5
- package/dist/esm/hooks/useId.js.map +0 -7
- package/dist/esm/hooks/useIsTouchDevice.js +0 -9
- package/dist/esm/hooks/useIsTouchDevice.js.map +0 -7
- package/dist/esm/hooks/useMedia.js +0 -225
- package/dist/esm/hooks/useMedia.js.map +0 -7
- package/dist/esm/hooks/useSafeRef.js +0 -35
- package/dist/esm/hooks/useSafeRef.js.map +0 -7
- package/dist/esm/hooks/useServerHooks.js +0 -11
- package/dist/esm/hooks/useServerHooks.js.map +0 -7
- package/dist/esm/hooks/useStyle.js +0 -37
- package/dist/esm/hooks/useStyle.js.map +0 -7
- package/dist/esm/hooks/useTheme.js +0 -205
- package/dist/esm/hooks/useTheme.js.map +0 -7
- package/dist/esm/hooks/useThemeName.js +0 -28
- package/dist/esm/hooks/useThemeName.js.map +0 -7
- package/dist/esm/insertFont.js +0 -67
- package/dist/esm/insertFont.js.map +0 -7
- package/dist/esm/setupReactNative.js +0 -25
- package/dist/esm/setupReactNative.js.map +0 -7
- package/dist/esm/static.js +0 -3
- package/dist/esm/static.js.map +0 -7
- package/dist/esm/styled.js +0 -71
- package/dist/esm/styled.js.map +0 -7
- package/dist/esm/types-rnw.js +0 -1
- package/dist/esm/types.js +0 -1
- package/dist/esm/types.js.map +0 -7
- package/dist/esm/updateTheme.js +0 -23
- package/dist/esm/updateTheme.js.map +0 -7
- package/dist/esm/views/FontLanguage.js +0 -17
- package/dist/esm/views/FontLanguage.js.map +0 -7
- package/dist/esm/views/FontLanguage.native.js +0 -11
- package/dist/esm/views/FontLanguage.native.js.map +0 -7
- package/dist/esm/views/FontLanguage.types.js +0 -1
- package/dist/esm/views/FontLanguage.types.js.map +0 -7
- package/dist/esm/views/Slot.js +0 -71
- package/dist/esm/views/Slot.js.map +0 -7
- package/dist/esm/views/Stack.js +0 -14
- package/dist/esm/views/Stack.js.map +0 -7
- package/dist/esm/views/Stack.web.test.js +0 -21
- package/dist/esm/views/Stack.web.test.js.map +0 -7
- package/dist/esm/views/TamaguiProvider.js +0 -56
- package/dist/esm/views/TamaguiProvider.js.map +0 -7
- package/dist/esm/views/Text.js +0 -70
- package/dist/esm/views/Text.js.map +0 -7
- package/dist/esm/views/Theme.js +0 -63
- package/dist/esm/views/Theme.js.map +0 -7
- package/dist/esm/views/ThemeProvider.js +0 -45
- package/dist/esm/views/ThemeProvider.js.map +0 -7
- package/src/Tamagui.ts +0 -48
- package/src/__snapshots__/createTokens.test.ts.snap +0 -772
- package/src/__snapshots__/createTokens.web.test.tsx.snap +0 -772
- package/src/addTheme.ts +0 -65
- package/src/config.ts +0 -62
- package/src/constants/constants.ts +0 -17
- package/src/constants/isDevTools.ts +0 -12
- package/src/contexts/ButtonNestingContext.tsx +0 -3
- package/src/contexts/FontLanguageContext.tsx +0 -5
- package/src/contexts/TextAncestorContext.tsx +0 -3
- package/src/createComponent.tsx +0 -1293
- package/src/createFont.ts +0 -50
- package/src/createShorthands.ts +0 -7
- package/src/createTamagui.ts +0 -253
- package/src/createTheme.ts +0 -13
- package/src/createTokens.ts +0 -46
- package/src/createVariable.ts +0 -93
- package/src/createVariables.ts +0 -55
- package/src/helpers/RNComponents.tsx +0 -14
- package/src/helpers/ThemeManager.tsx +0 -285
- package/src/helpers/ThemeManagerContext.tsx +0 -5
- package/src/helpers/createMediaStyle.ts +0 -56
- package/src/helpers/createPropMapper.ts +0 -562
- package/src/helpers/createProxy.ts +0 -16
- package/src/helpers/expandStyle.ts +0 -82
- package/src/helpers/expandStyles.ts +0 -107
- package/src/helpers/extendStaticConfig.ts +0 -78
- package/src/helpers/fixNativeShadow.tsx +0 -2
- package/src/helpers/getAnimationDriver.tsx +0 -5
- package/src/helpers/getExpandedShorthands.ts +0 -17
- package/src/helpers/getFontLanguage.ts +0 -2
- package/src/helpers/getSplitStyles.tsx +0 -1137
- package/src/helpers/getStylesAtomic.native.ts +0 -8
- package/src/helpers/getStylesAtomic.ts +0 -274
- package/src/helpers/getThemeCSSRules.native.ts +0 -3
- package/src/helpers/getThemeCSSRules.ts +0 -120
- package/src/helpers/getVariantExtras.tsx +0 -85
- package/src/helpers/insertStyleRule.tsx +0 -220
- package/src/helpers/isObj.ts +0 -1
- package/src/helpers/isTamaguiComponent.tsx +0 -11
- package/src/helpers/isTamaguiElement.tsx +0 -15
- package/src/helpers/matchMedia.native.ts +0 -23
- package/src/helpers/matchMedia.ts +0 -16
- package/src/helpers/mergeProps.ts +0 -56
- package/src/helpers/mergeTransform.ts +0 -30
- package/src/helpers/normalizeColor.ts +0 -38
- package/src/helpers/normalizeValueWithProperty.ts +0 -129
- package/src/helpers/proxyThemeVariables.tsx +0 -15
- package/src/helpers/pseudoDescriptors.ts +0 -40
- package/src/helpers/registerCSSVariable.ts +0 -13
- package/src/helpers/themeable.tsx +0 -44
- package/src/helpers/themes.ts +0 -67
- package/src/helpers/timer.ts +0 -9
- package/src/helpers/useShallowSetState.tsx +0 -41
- package/src/helpers/warnOnce.tsx +0 -11
- package/src/helpers/withStaticProperties.tsx +0 -7
- package/src/hooks/getThemeUnwrapped.tsx +0 -5
- package/src/hooks/useId.tsx +0 -1
- package/src/hooks/useIsTouchDevice.tsx +0 -6
- package/src/hooks/useMedia.tsx +0 -298
- package/src/hooks/useSafeRef.ts +0 -45
- package/src/hooks/useServerHooks.tsx +0 -12
- package/src/hooks/useStyle.tsx +0 -49
- package/src/hooks/useTheme.tsx +0 -274
- package/src/hooks/useThemeName.tsx +0 -27
- package/src/insertFont.ts +0 -73
- package/src/setupReactNative.ts +0 -22
- package/src/static.ts +0 -5
- package/src/styled.tsx +0 -195
- package/src/types-rnw.tsx +0 -162
- package/src/types.tsx +0 -1405
- package/src/updateTheme.ts +0 -26
- package/src/views/FontLanguage.native.tsx +0 -12
- package/src/views/FontLanguage.tsx +0 -16
- package/src/views/FontLanguage.types.ts +0 -13
- package/src/views/Slot.tsx +0 -102
- package/src/views/Stack.tsx +0 -25
- package/src/views/TamaguiProvider.tsx +0 -65
- package/src/views/Text.tsx +0 -88
- package/src/views/Theme.tsx +0 -83
- package/src/views/ThemeProvider.tsx +0 -55
- package/types/Tamagui.d.ts +0 -30
- package/types/Tamagui.d.ts.map +0 -1
- package/types/addTheme.d.ts +0 -32
- package/types/addTheme.d.ts.map +0 -1
- package/types/config.d.ts +0 -49
- package/types/config.d.ts.map +0 -1
- package/types/constants/constants.d.ts +0 -21
- package/types/constants/constants.d.ts.map +0 -1
- package/types/constants/isDevTools.d.ts +0 -2
- package/types/constants/isDevTools.d.ts.map +0 -1
- package/types/contexts/ButtonNestingContext.d.ts +0 -3
- package/types/contexts/ButtonNestingContext.d.ts.map +0 -1
- package/types/contexts/FontLanguageContext.d.ts +0 -5
- package/types/contexts/FontLanguageContext.d.ts.map +0 -1
- package/types/contexts/TextAncestorContext.d.ts +0 -3
- package/types/contexts/TextAncestorContext.d.ts.map +0 -1
- package/types/createComponent.d.ts +0 -23
- package/types/createComponent.d.ts.map +0 -1
- package/types/createFont.d.ts +0 -3
- package/types/createFont.d.ts.map +0 -1
- package/types/createFont.web.test.d.ts +0 -2
- package/types/createFont.web.test.d.ts.map +0 -1
- package/types/createShorthands.d.ts +0 -3
- package/types/createShorthands.d.ts.map +0 -1
- package/types/createTamagui.d.ts +0 -3
- package/types/createTamagui.d.ts.map +0 -1
- package/types/createTheme.d.ts +0 -7
- package/types/createTheme.d.ts.map +0 -1
- package/types/createTokens.d.ts +0 -28
- package/types/createTokens.d.ts.map +0 -1
- package/types/createTokens.web.test.d.ts +0 -2
- package/types/createTokens.web.test.d.ts.map +0 -1
- package/types/createVariable.d.ts +0 -26
- package/types/createVariable.d.ts.map +0 -1
- package/types/createVariable.web.test.d.ts +0 -2
- package/types/createVariable.web.test.d.ts.map +0 -1
- package/types/createVariables.d.ts +0 -11
- package/types/createVariables.d.ts.map +0 -1
- package/types/helpers/RNComponents.d.ts +0 -2
- package/types/helpers/RNComponents.d.ts.map +0 -1
- package/types/helpers/ThemeManager.d.ts +0 -36
- package/types/helpers/ThemeManager.d.ts.map +0 -1
- package/types/helpers/ThemeManager.test.d.ts +0 -2
- package/types/helpers/ThemeManager.test.d.ts.map +0 -1
- package/types/helpers/ThemeManagerContext.d.ts +0 -4
- package/types/helpers/ThemeManagerContext.d.ts.map +0 -1
- package/types/helpers/createMediaStyle.d.ts +0 -6
- package/types/helpers/createMediaStyle.d.ts.map +0 -1
- package/types/helpers/createPropMapper.d.ts +0 -7
- package/types/helpers/createPropMapper.d.ts.map +0 -1
- package/types/helpers/createProxy.d.ts +0 -2
- package/types/helpers/createProxy.d.ts.map +0 -1
- package/types/helpers/expandStyle.d.ts +0 -6
- package/types/helpers/expandStyle.d.ts.map +0 -1
- package/types/helpers/expandStyles.d.ts +0 -26
- package/types/helpers/expandStyles.d.ts.map +0 -1
- package/types/helpers/extendStaticConfig.d.ts +0 -4
- package/types/helpers/extendStaticConfig.d.ts.map +0 -1
- package/types/helpers/fixNativeShadow.d.ts +0 -2
- package/types/helpers/fixNativeShadow.d.ts.map +0 -1
- package/types/helpers/getAnimationDriver.d.ts +0 -6
- package/types/helpers/getAnimationDriver.d.ts.map +0 -1
- package/types/helpers/getExpandedShorthands.d.ts +0 -3
- package/types/helpers/getExpandedShorthands.d.ts.map +0 -1
- package/types/helpers/getFontLanguage.d.ts +0 -2
- package/types/helpers/getFontLanguage.d.ts.map +0 -1
- package/types/helpers/getSplitStyles.d.ts +0 -43
- package/types/helpers/getSplitStyles.d.ts.map +0 -1
- package/types/helpers/getStylesAtomic.d.ts +0 -18
- package/types/helpers/getStylesAtomic.d.ts.map +0 -1
- package/types/helpers/getStylesAtomic.native.d.ts +0 -4
- package/types/helpers/getStylesAtomic.native.d.ts.map +0 -1
- package/types/helpers/getThemeCSSRules.d.ts +0 -8
- package/types/helpers/getThemeCSSRules.d.ts.map +0 -1
- package/types/helpers/getThemeCSSRules.native.d.ts +0 -2
- package/types/helpers/getThemeCSSRules.native.d.ts.map +0 -1
- package/types/helpers/getVariantExtras.d.ts +0 -5
- package/types/helpers/getVariantExtras.d.ts.map +0 -1
- package/types/helpers/insertStyleRule.d.ts +0 -13
- package/types/helpers/insertStyleRule.d.ts.map +0 -1
- package/types/helpers/isObj.d.ts +0 -2
- package/types/helpers/isObj.d.ts.map +0 -1
- package/types/helpers/isTamaguiComponent.d.ts +0 -5
- package/types/helpers/isTamaguiComponent.d.ts.map +0 -1
- package/types/helpers/isTamaguiElement.d.ts +0 -7
- package/types/helpers/isTamaguiElement.d.ts.map +0 -1
- package/types/helpers/matchMedia.d.ts +0 -6
- package/types/helpers/matchMedia.d.ts.map +0 -1
- package/types/helpers/matchMedia.native.d.ts +0 -4
- package/types/helpers/matchMedia.native.d.ts.map +0 -1
- package/types/helpers/mergeProps.d.ts +0 -17
- package/types/helpers/mergeProps.d.ts.map +0 -1
- package/types/helpers/mergeTransform.d.ts +0 -9
- package/types/helpers/mergeTransform.d.ts.map +0 -1
- package/types/helpers/normalizeColor.d.ts +0 -4
- package/types/helpers/normalizeColor.d.ts.map +0 -1
- package/types/helpers/normalizeValueWithProperty.d.ts +0 -7
- package/types/helpers/normalizeValueWithProperty.d.ts.map +0 -1
- package/types/helpers/proxyThemeVariables.d.ts +0 -2
- package/types/helpers/proxyThemeVariables.d.ts.map +0 -1
- package/types/helpers/pseudoDescriptors.d.ts +0 -10
- package/types/helpers/pseudoDescriptors.d.ts.map +0 -1
- package/types/helpers/registerCSSVariable.d.ts +0 -5
- package/types/helpers/registerCSSVariable.d.ts.map +0 -1
- package/types/helpers/themeable.d.ts +0 -12
- package/types/helpers/themeable.d.ts.map +0 -1
- package/types/helpers/themes.d.ts +0 -4
- package/types/helpers/themes.d.ts.map +0 -1
- package/types/helpers/timer.d.ts +0 -2
- package/types/helpers/timer.d.ts.map +0 -1
- package/types/helpers/useShallowSetState.d.ts +0 -5
- package/types/helpers/useShallowSetState.d.ts.map +0 -1
- package/types/helpers/warnOnce.d.ts +0 -2
- package/types/helpers/warnOnce.d.ts.map +0 -1
- package/types/helpers/withStaticProperties.d.ts +0 -2
- package/types/helpers/withStaticProperties.d.ts.map +0 -1
- package/types/hooks/getThemeUnwrapped.d.ts +0 -3
- package/types/hooks/getThemeUnwrapped.d.ts.map +0 -1
- package/types/hooks/useId.d.ts +0 -2
- package/types/hooks/useId.d.ts.map +0 -1
- package/types/hooks/useIsTouchDevice.d.ts +0 -2
- package/types/hooks/useIsTouchDevice.d.ts.map +0 -1
- package/types/hooks/useMedia.d.ts +0 -33
- package/types/hooks/useMedia.d.ts.map +0 -1
- package/types/hooks/useSafeRef.d.ts +0 -4
- package/types/hooks/useSafeRef.d.ts.map +0 -1
- package/types/hooks/useServerHooks.d.ts +0 -4
- package/types/hooks/useServerHooks.d.ts.map +0 -1
- package/types/hooks/useStyle.d.ts +0 -8
- package/types/hooks/useStyle.d.ts.map +0 -1
- package/types/hooks/useTheme.d.ts +0 -25
- package/types/hooks/useTheme.d.ts.map +0 -1
- package/types/hooks/useThemeName.d.ts +0 -5
- package/types/hooks/useThemeName.d.ts.map +0 -1
- package/types/insertFont.d.ts +0 -9
- package/types/insertFont.d.ts.map +0 -1
- package/types/setupReactNative.d.ts +0 -5
- package/types/setupReactNative.d.ts.map +0 -1
- package/types/static.d.ts +0 -3
- package/types/static.d.ts.map +0 -1
- package/types/styled.d.ts +0 -20
- package/types/styled.d.ts.map +0 -1
- package/types/types-rnw.d.ts +0 -74
- package/types/types-rnw.d.ts.map +0 -1
- package/types/types.d.ts +0 -673
- package/types/types.d.ts.map +0 -1
- package/types/updateTheme.d.ts +0 -30
- package/types/updateTheme.d.ts.map +0 -1
- package/types/views/FontLanguage.d.ts +0 -4
- package/types/views/FontLanguage.d.ts.map +0 -1
- package/types/views/FontLanguage.native.d.ts +0 -4
- package/types/views/FontLanguage.native.d.ts.map +0 -1
- package/types/views/FontLanguage.types.d.ts +0 -11
- package/types/views/FontLanguage.types.d.ts.map +0 -1
- package/types/views/Slot.d.ts +0 -11
- package/types/views/Slot.d.ts.map +0 -1
- package/types/views/Stack.d.ts +0 -4
- package/types/views/Stack.d.ts.map +0 -1
- package/types/views/Stack.web.test.d.ts +0 -2
- package/types/views/Stack.web.test.d.ts.map +0 -1
- package/types/views/TamaguiProvider.d.ts +0 -4
- package/types/views/TamaguiProvider.d.ts.map +0 -1
- package/types/views/Text.d.ts +0 -4
- package/types/views/Text.d.ts.map +0 -1
- package/types/views/Theme.d.ts +0 -8
- package/types/views/Theme.d.ts.map +0 -1
- package/types/views/ThemeProvider.d.ts +0 -12
- package/types/views/ThemeProvider.d.ts.map +0 -1
|
@@ -1,562 +0,0 @@
|
|
|
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 =
|
|
23
|
-
| 'auto'
|
|
24
|
-
| 'value'
|
|
25
|
-
| 'variable'
|
|
26
|
-
| 'both'
|
|
27
|
-
| 'non-color-value'
|
|
28
|
-
|
|
29
|
-
export const getReturnVariablesAs = (props: any, state: Partial<SplitStyleState>) => {
|
|
30
|
-
return !!props.animation || state.resolveVariablesAs === 'value'
|
|
31
|
-
? isWeb
|
|
32
|
-
? 'non-color-value'
|
|
33
|
-
: 'value'
|
|
34
|
-
: 'auto'
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export const createPropMapper = (staticConfig: StaticConfigParsed) => {
|
|
38
|
-
const variants = staticConfig.variants || {}
|
|
39
|
-
|
|
40
|
-
// temp remove classnames
|
|
41
|
-
const defaultProps = mergeProps(staticConfig.defaultProps || {}, {}, false)[0]
|
|
42
|
-
|
|
43
|
-
let conf: TamaguiInternalConfig
|
|
44
|
-
|
|
45
|
-
const mapper: PropMapper = (
|
|
46
|
-
key,
|
|
47
|
-
value,
|
|
48
|
-
theme,
|
|
49
|
-
propsIn,
|
|
50
|
-
state,
|
|
51
|
-
languageContext,
|
|
52
|
-
avoidDefaultProps = false,
|
|
53
|
-
debug
|
|
54
|
-
) => {
|
|
55
|
-
conf ||= getConfig()
|
|
56
|
-
|
|
57
|
-
const props = state.fallbackProps || propsIn
|
|
58
|
-
const returnVariablesAs = getReturnVariablesAs(props, state)
|
|
59
|
-
|
|
60
|
-
// handled here because we need to resolve this off tokens, its the only one-off like this
|
|
61
|
-
const fontFamily =
|
|
62
|
-
props[conf.inverseShorthands.fontFamily] ||
|
|
63
|
-
props.fontFamily ||
|
|
64
|
-
defaultProps.fontFamily ||
|
|
65
|
-
propsIn.fontFamily ||
|
|
66
|
-
'$body'
|
|
67
|
-
|
|
68
|
-
const variantValue = resolveVariants(
|
|
69
|
-
key,
|
|
70
|
-
value,
|
|
71
|
-
props,
|
|
72
|
-
defaultProps,
|
|
73
|
-
theme,
|
|
74
|
-
variants,
|
|
75
|
-
fontFamily,
|
|
76
|
-
conf,
|
|
77
|
-
returnVariablesAs,
|
|
78
|
-
staticConfig,
|
|
79
|
-
'',
|
|
80
|
-
languageContext,
|
|
81
|
-
avoidDefaultProps,
|
|
82
|
-
debug
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
if (variantValue) {
|
|
86
|
-
return variantValue
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
let shouldReturn = value !== undefined && value !== null
|
|
90
|
-
|
|
91
|
-
// handle shorthands
|
|
92
|
-
if (key in conf.shorthands) {
|
|
93
|
-
shouldReturn = true
|
|
94
|
-
key = conf.shorthands[key]
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (value) {
|
|
98
|
-
if (value[0] === '$') {
|
|
99
|
-
value = getToken(
|
|
100
|
-
key,
|
|
101
|
-
value,
|
|
102
|
-
conf,
|
|
103
|
-
theme,
|
|
104
|
-
fontFamily,
|
|
105
|
-
languageContext,
|
|
106
|
-
returnVariablesAs,
|
|
107
|
-
debug
|
|
108
|
-
)
|
|
109
|
-
} else if (isVariable(value)) {
|
|
110
|
-
value = resolveVariableValue(key, value, returnVariablesAs)
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (shouldReturn) {
|
|
115
|
-
return expandStyle(key, value) || [[key, value]]
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return mapper
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
type StyleResolver = (
|
|
123
|
-
key: string,
|
|
124
|
-
value: any,
|
|
125
|
-
props: Record<string, any>,
|
|
126
|
-
defaultProps: any,
|
|
127
|
-
theme: any,
|
|
128
|
-
variants: GenericVariantDefinitions,
|
|
129
|
-
fontFamily: string,
|
|
130
|
-
conf: TamaguiInternalConfig,
|
|
131
|
-
returnVariablesAs: 'auto' | 'value' | 'non-color-value',
|
|
132
|
-
staticConfig: StaticConfigParsed,
|
|
133
|
-
parentVariantKey: string,
|
|
134
|
-
languageContext?: LanguageContextType,
|
|
135
|
-
avoidDefaultProps?: boolean,
|
|
136
|
-
debug?: DebugProp
|
|
137
|
-
) => any
|
|
138
|
-
|
|
139
|
-
const resolveVariants: StyleResolver = (
|
|
140
|
-
key,
|
|
141
|
-
value,
|
|
142
|
-
props,
|
|
143
|
-
defaultProps,
|
|
144
|
-
theme,
|
|
145
|
-
variants,
|
|
146
|
-
fontFamily,
|
|
147
|
-
conf,
|
|
148
|
-
returnVariablesAs,
|
|
149
|
-
staticConfig,
|
|
150
|
-
parentVariantKey,
|
|
151
|
-
languageContext,
|
|
152
|
-
avoidDefaultProps = false,
|
|
153
|
-
debug
|
|
154
|
-
) => {
|
|
155
|
-
const variant = variants?.[key]
|
|
156
|
-
if (!variant || value === undefined) {
|
|
157
|
-
return
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
let variantValue = getVariantDefinition(variant, key, value, conf)
|
|
161
|
-
|
|
162
|
-
if (!variantValue) {
|
|
163
|
-
// variant at key exists, but no matching variant value, return nothing
|
|
164
|
-
if (process.env.NODE_ENV === 'development') {
|
|
165
|
-
if (staticConfig.validStyles?.[key]) {
|
|
166
|
-
return null
|
|
167
|
-
}
|
|
168
|
-
if (value === false) {
|
|
169
|
-
// don't warn on missing false values, common to only use true
|
|
170
|
-
return null
|
|
171
|
-
}
|
|
172
|
-
const name = staticConfig.componentName || '[UnnamedComponent]'
|
|
173
|
-
// eslint-disable-next-line no-console
|
|
174
|
-
console.warn(
|
|
175
|
-
`No variant found: ${name} has variant "${key}", but no matching value "${value}"`
|
|
176
|
-
)
|
|
177
|
-
}
|
|
178
|
-
return
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (typeof variantValue === 'function') {
|
|
182
|
-
const fn = variantValue as VariantSpreadFunction<any>
|
|
183
|
-
variantValue = fn(
|
|
184
|
-
value,
|
|
185
|
-
getVariantExtras(props, languageContext, theme, defaultProps, avoidDefaultProps)
|
|
186
|
-
)
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
let fontFamilyResult: any
|
|
190
|
-
|
|
191
|
-
if (isObj(variantValue)) {
|
|
192
|
-
const fontFamilyUpdate =
|
|
193
|
-
variantValue.fontFamily || variantValue[conf.inverseShorthands.fontFamily]
|
|
194
|
-
|
|
195
|
-
if (fontFamilyUpdate) {
|
|
196
|
-
fontFamilyResult = getFontFamilyFromNameOrVariable(fontFamilyUpdate, conf)
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
variantValue = resolveTokensAndVariants(
|
|
200
|
-
key,
|
|
201
|
-
variantValue,
|
|
202
|
-
props,
|
|
203
|
-
defaultProps,
|
|
204
|
-
theme,
|
|
205
|
-
variants,
|
|
206
|
-
fontFamilyResult || fontFamily,
|
|
207
|
-
conf,
|
|
208
|
-
returnVariablesAs,
|
|
209
|
-
staticConfig,
|
|
210
|
-
parentVariantKey,
|
|
211
|
-
languageContext,
|
|
212
|
-
avoidDefaultProps,
|
|
213
|
-
debug
|
|
214
|
-
)
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
if (variantValue) {
|
|
218
|
-
const next = Object.entries(expandStyles(variantValue))
|
|
219
|
-
|
|
220
|
-
// store any changed font family (only support variables for now)
|
|
221
|
-
if (fontFamilyResult && fontFamilyResult[0] === '$') {
|
|
222
|
-
fontFamilyCache.set(next, getVariableValue(fontFamilyResult))
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
return next
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
// handles finding and resolving the fontFamily to the token name
|
|
230
|
-
// this is used as `font_[name]` in className for nice css variable support
|
|
231
|
-
export function getFontFamilyFromNameOrVariable(input: any, conf: TamaguiInternalConfig) {
|
|
232
|
-
if (isVariable(input)) {
|
|
233
|
-
const val = variableToFontNameCache.get(input)
|
|
234
|
-
if (val) {
|
|
235
|
-
return val
|
|
236
|
-
} else {
|
|
237
|
-
for (const key in conf.fontsParsed) {
|
|
238
|
-
const familyVariable = conf.fontsParsed[key].family
|
|
239
|
-
if (isVariable(familyVariable)) {
|
|
240
|
-
variableToFontNameCache.set(familyVariable, key)
|
|
241
|
-
if (familyVariable === input) {
|
|
242
|
-
return key
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
} else if (typeof input === 'string') {
|
|
248
|
-
if (input?.[0] === '$') {
|
|
249
|
-
return input
|
|
250
|
-
} else {
|
|
251
|
-
// this could be mapped back to
|
|
252
|
-
if (process.env.NODE_ENV === 'development') {
|
|
253
|
-
// eslint-disable-next-line no-console
|
|
254
|
-
console.log('[tamagui] should map back', input)
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
const variableToFontNameCache = new WeakMap<Variable, string>()
|
|
261
|
-
|
|
262
|
-
// special helper for special font family
|
|
263
|
-
const fontFamilyCache = new WeakMap()
|
|
264
|
-
export const getPropMappedFontFamily = (expanded?: any) => {
|
|
265
|
-
return expanded && fontFamilyCache.get(expanded)
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
const resolveTokensAndVariants: StyleResolver = (
|
|
269
|
-
key, // we dont use key assume value is object instead
|
|
270
|
-
value,
|
|
271
|
-
props,
|
|
272
|
-
defaultProps,
|
|
273
|
-
theme,
|
|
274
|
-
variants,
|
|
275
|
-
fontFamily,
|
|
276
|
-
conf,
|
|
277
|
-
returnVariablesAs,
|
|
278
|
-
staticConfig,
|
|
279
|
-
parentVariantKey,
|
|
280
|
-
languageContext,
|
|
281
|
-
avoidDefaultProps,
|
|
282
|
-
debug
|
|
283
|
-
) => {
|
|
284
|
-
const res = {}
|
|
285
|
-
for (const rKey in value) {
|
|
286
|
-
const fKey = conf.shorthands[rKey] || rKey
|
|
287
|
-
const val = value[rKey]
|
|
288
|
-
|
|
289
|
-
if (fKey in variants) {
|
|
290
|
-
// avoids infinite loop if variant is matching a style prop
|
|
291
|
-
// eg: { variants: { flex: { true: { flex: 2 } } } }
|
|
292
|
-
if (parentVariantKey && parentVariantKey === key) {
|
|
293
|
-
res[fKey] = val
|
|
294
|
-
} else {
|
|
295
|
-
const variantOut = resolveVariants(
|
|
296
|
-
fKey,
|
|
297
|
-
val,
|
|
298
|
-
props,
|
|
299
|
-
defaultProps,
|
|
300
|
-
theme,
|
|
301
|
-
variants,
|
|
302
|
-
fontFamily,
|
|
303
|
-
conf,
|
|
304
|
-
returnVariablesAs,
|
|
305
|
-
staticConfig,
|
|
306
|
-
key,
|
|
307
|
-
languageContext,
|
|
308
|
-
avoidDefaultProps,
|
|
309
|
-
debug
|
|
310
|
-
)
|
|
311
|
-
|
|
312
|
-
const { pressStyle, hoverStyle, focusStyle, enterStyle, exitStyle, ...rest } =
|
|
313
|
-
Object.fromEntries(variantOut)
|
|
314
|
-
const subs = { pressStyle, hoverStyle, focusStyle, enterStyle, exitStyle }
|
|
315
|
-
Object.assign(res, rest)
|
|
316
|
-
for (const key in subs) {
|
|
317
|
-
if (subs[key]) {
|
|
318
|
-
res[key] ??= {}
|
|
319
|
-
Object.assign(res[key], subs[key])
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
continue
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
if (isVariable(val)) {
|
|
327
|
-
res[fKey] = !isWeb || returnVariablesAs === 'value' ? val.val : val.variable
|
|
328
|
-
continue
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
if (typeof val === 'string') {
|
|
332
|
-
const fVal =
|
|
333
|
-
val[0] === '$'
|
|
334
|
-
? getToken(
|
|
335
|
-
fKey,
|
|
336
|
-
val,
|
|
337
|
-
conf,
|
|
338
|
-
theme,
|
|
339
|
-
fontFamily,
|
|
340
|
-
languageContext,
|
|
341
|
-
returnVariablesAs,
|
|
342
|
-
debug
|
|
343
|
-
)
|
|
344
|
-
: val
|
|
345
|
-
res[fKey] = fVal
|
|
346
|
-
continue
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
if (isObj(val)) {
|
|
350
|
-
// sub-objects: media queries, pseudos, shadowOffset
|
|
351
|
-
res[fKey] ??= {}
|
|
352
|
-
Object.assign(
|
|
353
|
-
res[fKey],
|
|
354
|
-
resolveTokensAndVariants(
|
|
355
|
-
fKey,
|
|
356
|
-
val,
|
|
357
|
-
props,
|
|
358
|
-
defaultProps,
|
|
359
|
-
theme,
|
|
360
|
-
variants,
|
|
361
|
-
fontFamily,
|
|
362
|
-
conf,
|
|
363
|
-
returnVariablesAs,
|
|
364
|
-
staticConfig,
|
|
365
|
-
key,
|
|
366
|
-
languageContext,
|
|
367
|
-
avoidDefaultProps,
|
|
368
|
-
debug
|
|
369
|
-
)
|
|
370
|
-
)
|
|
371
|
-
} else {
|
|
372
|
-
// nullish values cant be tokens, need no extra parsing
|
|
373
|
-
res[fKey] = val
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
if (process.env.NODE_ENV === 'development') {
|
|
377
|
-
if (debug) {
|
|
378
|
-
if (res[fKey]?.[0] === '$') {
|
|
379
|
-
// eslint-disable-next-line no-console
|
|
380
|
-
console.warn(`⚠️ Missing token in theme ${theme.name}:`, fKey, res[fKey], theme)
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
return res
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
const tokenCats = ['size', 'color', 'radius', 'space', 'zIndex'].map((name) => ({
|
|
390
|
-
name,
|
|
391
|
-
spreadName: `...${name}`,
|
|
392
|
-
}))
|
|
393
|
-
|
|
394
|
-
// goes through specificity finding best matching variant function
|
|
395
|
-
function getVariantDefinition(
|
|
396
|
-
variant: any,
|
|
397
|
-
key: string,
|
|
398
|
-
value: any,
|
|
399
|
-
conf: TamaguiInternalConfig
|
|
400
|
-
) {
|
|
401
|
-
if (typeof variant === 'function') {
|
|
402
|
-
return variant
|
|
403
|
-
}
|
|
404
|
-
if (variant[value]) {
|
|
405
|
-
return variant[value]
|
|
406
|
-
}
|
|
407
|
-
const { tokensParsed } = conf
|
|
408
|
-
for (const { name, spreadName } of tokenCats) {
|
|
409
|
-
if (variant[spreadName] && value in tokensParsed[name]) {
|
|
410
|
-
return variant[spreadName]
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
let fn: any
|
|
414
|
-
const type = typeof value
|
|
415
|
-
if (type === 'number') {
|
|
416
|
-
fn = variant[':number']
|
|
417
|
-
} else if (type === 'string') {
|
|
418
|
-
fn = variant[':string']
|
|
419
|
-
} else if (value === true || value === false) {
|
|
420
|
-
fn = variant[':boolean']
|
|
421
|
-
}
|
|
422
|
-
// fallback to catch all or size
|
|
423
|
-
return fn || variant['...'] || variant['...size']
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
const fontShorthand = {
|
|
427
|
-
fontSize: 'size',
|
|
428
|
-
fontWeight: 'weight',
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
const getToken = (
|
|
432
|
-
key: string,
|
|
433
|
-
value: string,
|
|
434
|
-
conf: TamaguiInternalConfig,
|
|
435
|
-
theme: any,
|
|
436
|
-
fontFamily: string | undefined = '$body',
|
|
437
|
-
languageContext?: LanguageContextType,
|
|
438
|
-
resolveAs?: ResolveVariableTypes,
|
|
439
|
-
debug?: DebugProp
|
|
440
|
-
) => {
|
|
441
|
-
const tokensParsed = conf.tokensParsed
|
|
442
|
-
const fontsParsed = languageContext
|
|
443
|
-
? getFontsForLanguage(conf.fontsParsed, languageContext)
|
|
444
|
-
: conf.fontsParsed
|
|
445
|
-
let valOrVar: any
|
|
446
|
-
let hasSet = false
|
|
447
|
-
if (value in theme) {
|
|
448
|
-
valOrVar = theme[value]
|
|
449
|
-
hasSet = true
|
|
450
|
-
} else {
|
|
451
|
-
switch (key) {
|
|
452
|
-
case 'fontFamily':
|
|
453
|
-
valOrVar = fontsParsed[value]?.family || value
|
|
454
|
-
hasSet = true
|
|
455
|
-
break
|
|
456
|
-
case 'fontSize':
|
|
457
|
-
case 'lineHeight':
|
|
458
|
-
case 'letterSpacing':
|
|
459
|
-
case 'fontWeight':
|
|
460
|
-
valOrVar = fontsParsed[fontFamily]?.[fontShorthand[key] || key]?.[value] || value
|
|
461
|
-
hasSet = true
|
|
462
|
-
break
|
|
463
|
-
}
|
|
464
|
-
for (const cat in tokenCategories) {
|
|
465
|
-
if (key in tokenCategories[cat]) {
|
|
466
|
-
const res = tokensParsed[cat][value]
|
|
467
|
-
if (res) {
|
|
468
|
-
valOrVar = res
|
|
469
|
-
hasSet = true
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
if (!hasSet) {
|
|
474
|
-
const spaceVar = tokensParsed.space[value]
|
|
475
|
-
if (spaceVar) {
|
|
476
|
-
valOrVar = spaceVar
|
|
477
|
-
hasSet = true
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
if (process.env.NODE_ENV === 'development' && isDevTools && debug === 'verbose') {
|
|
483
|
-
// eslint-disable-next-line no-console
|
|
484
|
-
console.log(' ﹒ propMapper getToken', { key, valOrVar, theme, hasSet })
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
if (hasSet) {
|
|
488
|
-
return resolveVariableValue(key, valOrVar, resolveAs)
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
if (process.env.NODE_ENV === 'development') {
|
|
492
|
-
if (value && value[0] === '$') {
|
|
493
|
-
// eslint-disable-next-line no-console
|
|
494
|
-
console.warn(
|
|
495
|
-
`⚠️ You passed the value "${value}" to the style property "${key}", but there's no theme or token with the key "${value}". Using theme "${theme.name}".
|
|
496
|
-
|
|
497
|
-
Set the debug prop to true to see more detailed debug information.`
|
|
498
|
-
)
|
|
499
|
-
if (debug) {
|
|
500
|
-
if (isDevTools) {
|
|
501
|
-
// eslint-disable-next-line no-console
|
|
502
|
-
console.log('Looked in:', { theme, tokensParsed, fontsParsed })
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
return null
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
return value
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
function resolveVariableValue(
|
|
512
|
-
key: string,
|
|
513
|
-
valOrVar: Variable | any,
|
|
514
|
-
resolveAs: ResolveVariableTypes = 'auto'
|
|
515
|
-
) {
|
|
516
|
-
if (isVariable(valOrVar)) {
|
|
517
|
-
if (resolveAs === 'variable') {
|
|
518
|
-
return valOrVar
|
|
519
|
-
}
|
|
520
|
-
if (resolveAs === 'non-color-value') {
|
|
521
|
-
if (isWeb) {
|
|
522
|
-
if (key in tokenCategories.color) {
|
|
523
|
-
return valOrVar.variable
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
return valOrVar.val
|
|
527
|
-
}
|
|
528
|
-
if (!isWeb || resolveAs === 'value') {
|
|
529
|
-
return valOrVar.val
|
|
530
|
-
}
|
|
531
|
-
return valOrVar.variable
|
|
532
|
-
}
|
|
533
|
-
return valOrVar
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
// just specificy the least costly, all else go to `space` (most keys - we can exclude)
|
|
537
|
-
const tokenCategories = {
|
|
538
|
-
radius: {
|
|
539
|
-
borderRadius: true,
|
|
540
|
-
borderTopLeftRadius: true,
|
|
541
|
-
borderTopRightRadius: true,
|
|
542
|
-
borderBottomLeftRadius: true,
|
|
543
|
-
borderBottomRightRadius: true,
|
|
544
|
-
},
|
|
545
|
-
size: {
|
|
546
|
-
width: true,
|
|
547
|
-
height: true,
|
|
548
|
-
minWidth: true,
|
|
549
|
-
minHeight: true,
|
|
550
|
-
maxWidth: true,
|
|
551
|
-
maxHeight: true,
|
|
552
|
-
},
|
|
553
|
-
color: {
|
|
554
|
-
color: true,
|
|
555
|
-
backgroundColor: true,
|
|
556
|
-
borderColor: true,
|
|
557
|
-
borderBottomColor: true,
|
|
558
|
-
borderTopColor: true,
|
|
559
|
-
borderLeftColor: true,
|
|
560
|
-
borderRightColor: true,
|
|
561
|
-
},
|
|
562
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export function createProxy<A extends object>(target: A, handler: ProxyHandler<A>) {
|
|
2
|
-
if (process.env.NODE_ENV === 'development') {
|
|
3
|
-
if (typeof target !== 'object' || !target) {
|
|
4
|
-
// eslint-disable-next-line no-console
|
|
5
|
-
console.warn(
|
|
6
|
-
'Invalid object given for proxy:',
|
|
7
|
-
target,
|
|
8
|
-
`
|
|
9
|
-
|
|
10
|
-
This can be due to a missing theme or configuration given to Tamagui.`,
|
|
11
|
-
new Error().stack
|
|
12
|
-
)
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
return new Proxy(target || {}, handler)
|
|
16
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
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 'textAlignVertical': {
|
|
34
|
-
return [['verticalAlign', value === 'center' ? 'middle' : value]]
|
|
35
|
-
}
|
|
36
|
-
case 'writingDirection': {
|
|
37
|
-
return [['direction', value]]
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const longKey = EXPANSIONS[key]
|
|
43
|
-
if (longKey) {
|
|
44
|
-
return longKey.map((key) => {
|
|
45
|
-
return [key, value]
|
|
46
|
-
})
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const all = ['Top', 'Right', 'Bottom', 'Left']
|
|
51
|
-
const horiz = ['Right', 'Left']
|
|
52
|
-
const vert = ['Top', 'Bottom']
|
|
53
|
-
const xy = ['X', 'Y']
|
|
54
|
-
|
|
55
|
-
const EXPANSIONS: Record<string, string[]> = {
|
|
56
|
-
borderColor: ['TopColor', 'RightColor', 'BottomColor', 'LeftColor'],
|
|
57
|
-
borderRadius: [
|
|
58
|
-
'TopLeftRadius',
|
|
59
|
-
'TopRightRadius',
|
|
60
|
-
'BottomRightRadius',
|
|
61
|
-
'BottomLeftRadius',
|
|
62
|
-
],
|
|
63
|
-
borderWidth: ['TopWidth', 'RightWidth', 'BottomWidth', 'LeftWidth'],
|
|
64
|
-
margin: all,
|
|
65
|
-
marginHorizontal: horiz,
|
|
66
|
-
marginVertical: vert,
|
|
67
|
-
overscrollBehavior: xy,
|
|
68
|
-
padding: all,
|
|
69
|
-
paddingHorizontal: horiz,
|
|
70
|
-
paddingVertical: vert,
|
|
71
|
-
...(isWeb && {
|
|
72
|
-
// react-native only supports borderStyle
|
|
73
|
-
borderStyle: ['TopStyle', 'RightStyle', 'BottomStyle', 'LeftStyle'],
|
|
74
|
-
// react-native doesn't support X / Y
|
|
75
|
-
overflow: xy,
|
|
76
|
-
}),
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
for (const parent in EXPANSIONS) {
|
|
80
|
-
const prefix = parent.slice(0, /[A-Z]/.exec(parent)?.index ?? parent.length)
|
|
81
|
-
EXPANSIONS[parent] = EXPANSIONS[parent].map((k) => `${prefix}${k}`)
|
|
82
|
-
}
|