@tamagui/web 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 +1 -0
- package/dist/cjs/Tamagui.js +77 -0
- package/dist/cjs/Tamagui.js.map +7 -0
- package/dist/cjs/addTheme.js +78 -0
- package/dist/cjs/addTheme.js.map +7 -0
- package/dist/cjs/config.js +91 -0
- package/dist/cjs/config.js.map +7 -0
- package/dist/cjs/constants/constants.js +49 -0
- package/dist/cjs/constants/constants.js.map +7 -0
- package/dist/cjs/constants/isDevTools.js +37 -0
- package/dist/cjs/constants/isDevTools.js.map +7 -0
- package/dist/cjs/contexts/ButtonNestingContext.js +30 -0
- package/dist/cjs/contexts/ButtonNestingContext.js.map +7 -0
- package/dist/cjs/contexts/FontLanguageContext.js +30 -0
- package/dist/cjs/contexts/FontLanguageContext.js.map +7 -0
- package/dist/cjs/contexts/TextAncestorContext.js +30 -0
- package/dist/cjs/contexts/TextAncestorContext.js.map +7 -0
- package/dist/cjs/createComponent.js +874 -0
- package/dist/cjs/createComponent.js.map +7 -0
- package/dist/cjs/createFont.js +69 -0
- package/dist/cjs/createFont.js.map +7 -0
- package/dist/cjs/createShorthands.js +31 -0
- package/dist/cjs/createShorthands.js.map +7 -0
- package/dist/cjs/createTamagui.js +206 -0
- package/dist/cjs/createTamagui.js.map +7 -0
- package/dist/cjs/createTheme.js +31 -0
- package/dist/cjs/createTheme.js.map +7 -0
- package/dist/cjs/createTokens.js +39 -0
- package/dist/cjs/createTokens.js.map +7 -0
- package/dist/cjs/createVariable.js +111 -0
- package/dist/cjs/createVariable.js.map +7 -0
- package/dist/cjs/createVariables.js +60 -0
- package/dist/cjs/createVariables.js.map +7 -0
- package/dist/cjs/helpers/RNComponents.js +40 -0
- package/dist/cjs/helpers/RNComponents.js.map +7 -0
- package/dist/cjs/helpers/ThemeManager.js +234 -0
- package/dist/cjs/helpers/ThemeManager.js.map +7 -0
- package/dist/cjs/helpers/ThemeManagerContext.js +30 -0
- package/dist/cjs/helpers/ThemeManagerContext.js.map +7 -0
- package/dist/cjs/helpers/createMediaStyle.js +67 -0
- package/dist/cjs/helpers/createMediaStyle.js.map +7 -0
- package/dist/cjs/helpers/createPropMapper.js +423 -0
- package/dist/cjs/helpers/createPropMapper.js.map +7 -0
- package/dist/cjs/helpers/createProxy.js +43 -0
- package/dist/cjs/helpers/createProxy.js.map +7 -0
- package/dist/cjs/helpers/expandStyle.js +95 -0
- package/dist/cjs/helpers/expandStyle.js.map +7 -0
- package/dist/cjs/helpers/expandStyles.js +116 -0
- package/dist/cjs/helpers/expandStyles.js.map +7 -0
- package/dist/cjs/helpers/extendStaticConfig.js +91 -0
- package/dist/cjs/helpers/extendStaticConfig.js.map +7 -0
- package/dist/cjs/helpers/getAnimationDriver.js +32 -0
- package/dist/cjs/helpers/getAnimationDriver.js.map +7 -0
- package/dist/cjs/helpers/getExpandedShorthands.js +40 -0
- package/dist/cjs/helpers/getExpandedShorthands.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/getSplitStyles.js +850 -0
- package/dist/cjs/helpers/getSplitStyles.js.map +7 -0
- package/dist/cjs/helpers/getStylesAtomic.js +226 -0
- package/dist/cjs/helpers/getStylesAtomic.js.map +7 -0
- package/dist/cjs/helpers/getStylesAtomic.native.js +38 -0
- package/dist/cjs/helpers/getStylesAtomic.native.js.map +7 -0
- package/dist/cjs/helpers/getThemeCSSRules.js +110 -0
- package/dist/cjs/helpers/getThemeCSSRules.js.map +7 -0
- package/dist/cjs/helpers/getThemeCSSRules.native.js +31 -0
- package/dist/cjs/helpers/getThemeCSSRules.native.js.map +7 -0
- package/dist/cjs/helpers/getVariantExtras.js +92 -0
- package/dist/cjs/helpers/getVariantExtras.js.map +7 -0
- package/dist/cjs/helpers/insertStyleRule.js +218 -0
- package/dist/cjs/helpers/insertStyleRule.js.map +7 -0
- package/dist/cjs/helpers/isObj.js +29 -0
- package/dist/cjs/helpers/isObj.js.map +7 -0
- package/dist/cjs/helpers/isTamaguiComponent.js +32 -0
- package/dist/cjs/helpers/isTamaguiComponent.js.map +7 -0
- package/dist/cjs/helpers/isTamaguiElement.js +33 -0
- package/dist/cjs/helpers/isTamaguiElement.js.map +7 -0
- package/dist/cjs/helpers/matchMedia.js +42 -0
- package/dist/cjs/helpers/matchMedia.js.map +7 -0
- package/dist/cjs/helpers/matchMedia.native.js +48 -0
- package/dist/cjs/helpers/matchMedia.native.js.map +7 -0
- package/dist/cjs/helpers/mergeProps.js +54 -0
- package/dist/cjs/helpers/mergeProps.js.map +7 -0
- package/dist/cjs/helpers/mergeTransform.js +47 -0
- package/dist/cjs/helpers/mergeTransform.js.map +7 -0
- package/dist/cjs/helpers/normalizeColor.js +71 -0
- package/dist/cjs/helpers/normalizeColor.js.map +7 -0
- package/dist/cjs/helpers/normalizeValueWithProperty.js +138 -0
- package/dist/cjs/helpers/normalizeValueWithProperty.js.map +7 -0
- package/dist/cjs/helpers/proxyThemeVariables.js +40 -0
- package/dist/cjs/helpers/proxyThemeVariables.js.map +7 -0
- package/dist/cjs/helpers/pseudoDescriptors.js +53 -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/themeable.js +62 -0
- package/dist/cjs/helpers/themeable.js.map +7 -0
- package/dist/cjs/helpers/themes.js +78 -0
- package/dist/cjs/helpers/themes.js.map +7 -0
- package/dist/cjs/helpers/timer.js +35 -0
- package/dist/cjs/helpers/timer.js.map +7 -0
- package/dist/cjs/helpers/useShallowSetState.js +59 -0
- package/dist/cjs/helpers/useShallowSetState.js.map +7 -0
- package/dist/cjs/helpers/warnOnce.js +38 -0
- package/dist/cjs/helpers/warnOnce.js.map +7 -0
- package/dist/cjs/helpers/withStaticProperties.js +32 -0
- package/dist/cjs/helpers/withStaticProperties.js.map +7 -0
- package/dist/cjs/hooks/getThemeUnwrapped.js +34 -0
- package/dist/cjs/hooks/getThemeUnwrapped.js.map +7 -0
- package/dist/cjs/hooks/useId.js +29 -0
- package/dist/cjs/hooks/useId.js.map +7 -0
- package/dist/cjs/hooks/useIsTouchDevice.js +33 -0
- package/dist/cjs/hooks/useIsTouchDevice.js.map +7 -0
- package/dist/cjs/hooks/useMedia.js +263 -0
- package/dist/cjs/hooks/useMedia.js.map +7 -0
- package/dist/cjs/hooks/useSafeRef.js +59 -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/useStyle.js +61 -0
- package/dist/cjs/hooks/useStyle.js.map +7 -0
- package/dist/cjs/hooks/useTheme.js +230 -0
- package/dist/cjs/hooks/useTheme.js.map +7 -0
- package/dist/cjs/hooks/useThemeName.js +52 -0
- package/dist/cjs/hooks/useThemeName.js.map +7 -0
- package/dist/cjs/index.js +104 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/inject-styles.js +40 -0
- package/dist/cjs/inject-styles.js.map +7 -0
- package/dist/cjs/insertFont.js +93 -0
- package/dist/cjs/insertFont.js.map +7 -0
- package/dist/cjs/setupHooks.js +34 -0
- package/dist/cjs/setupHooks.js.map +7 -0
- package/dist/cjs/setupReactNative.js +51 -0
- package/dist/cjs/setupReactNative.js.map +7 -0
- package/dist/cjs/styled.js +95 -0
- package/dist/cjs/styled.js.map +7 -0
- package/dist/cjs/types.js +17 -0
- package/dist/cjs/types.js.map +7 -0
- package/dist/cjs/updateTheme.js +47 -0
- package/dist/cjs/updateTheme.js.map +7 -0
- package/dist/cjs/views/FontLanguage.js +41 -0
- package/dist/cjs/views/FontLanguage.js.map +7 -0
- package/dist/cjs/views/FontLanguage.native.js +35 -0
- package/dist/cjs/views/FontLanguage.native.js.map +7 -0
- package/dist/cjs/views/FontLanguage.types.js +17 -0
- package/dist/cjs/views/FontLanguage.types.js.map +7 -0
- package/dist/cjs/views/Slot.js +92 -0
- package/dist/cjs/views/Slot.js.map +7 -0
- package/dist/cjs/views/Stack.js +38 -0
- package/dist/cjs/views/Stack.js.map +7 -0
- package/dist/cjs/views/TamaguiProvider.js +90 -0
- package/dist/cjs/views/TamaguiProvider.js.map +7 -0
- package/dist/cjs/views/Text.js +94 -0
- package/dist/cjs/views/Text.js.map +7 -0
- package/dist/cjs/views/Theme.js +88 -0
- package/dist/cjs/views/Theme.js.map +7 -0
- package/dist/cjs/views/ThemeProvider.js +70 -0
- package/dist/cjs/views/ThemeProvider.js.map +7 -0
- package/dist/esm/Tamagui.js +41 -0
- package/dist/esm/Tamagui.js.map +7 -0
- package/dist/esm/addTheme.js +54 -0
- package/dist/esm/addTheme.js.map +7 -0
- package/dist/esm/config.js +58 -0
- package/dist/esm/config.js.map +7 -0
- package/dist/esm/constants/constants.js +22 -0
- package/dist/esm/constants/constants.js.map +7 -0
- package/dist/esm/constants/isDevTools.js +13 -0
- package/dist/esm/constants/isDevTools.js.map +7 -0
- package/dist/esm/contexts/ButtonNestingContext.js +6 -0
- package/dist/esm/contexts/ButtonNestingContext.js.map +7 -0
- package/dist/esm/contexts/FontLanguageContext.js +6 -0
- package/dist/esm/contexts/FontLanguageContext.js.map +7 -0
- package/dist/esm/contexts/TextAncestorContext.js +6 -0
- package/dist/esm/contexts/TextAncestorContext.js.map +7 -0
- package/dist/esm/createComponent.js +849 -0
- package/dist/esm/createComponent.js.map +7 -0
- package/dist/esm/createFont.js +45 -0
- package/dist/esm/createFont.js.map +7 -0
- package/dist/esm/createShorthands.js +7 -0
- package/dist/esm/createShorthands.js.map +7 -0
- package/dist/esm/createTamagui.js +190 -0
- package/dist/esm/createTamagui.js.map +7 -0
- package/dist/esm/createTheme.js +7 -0
- package/dist/esm/createTheme.js.map +7 -0
- package/dist/esm/createTokens.js +15 -0
- package/dist/esm/createTokens.js.map +7 -0
- package/dist/esm/createVariable.js +78 -0
- package/dist/esm/createVariable.js.map +7 -0
- package/dist/esm/createVariables.js +35 -0
- package/dist/esm/createVariables.js.map +7 -0
- package/dist/esm/helpers/RNComponents.js +16 -0
- package/dist/esm/helpers/RNComponents.js.map +7 -0
- package/dist/esm/helpers/ThemeManager.js +209 -0
- package/dist/esm/helpers/ThemeManager.js.map +7 -0
- package/dist/esm/helpers/ThemeManagerContext.js +6 -0
- package/dist/esm/helpers/ThemeManagerContext.js.map +7 -0
- package/dist/esm/helpers/createMediaStyle.js +42 -0
- package/dist/esm/helpers/createMediaStyle.js.map +7 -0
- package/dist/esm/helpers/createPropMapper.js +396 -0
- package/dist/esm/helpers/createPropMapper.js.map +7 -0
- package/dist/esm/helpers/createProxy.js +19 -0
- package/dist/esm/helpers/createProxy.js.map +7 -0
- package/dist/esm/helpers/expandStyle.js +71 -0
- package/dist/esm/helpers/expandStyle.js.map +7 -0
- package/dist/esm/helpers/expandStyles.js +90 -0
- package/dist/esm/helpers/expandStyles.js.map +7 -0
- package/dist/esm/helpers/extendStaticConfig.js +66 -0
- package/dist/esm/helpers/extendStaticConfig.js.map +7 -0
- package/dist/esm/helpers/getAnimationDriver.js +8 -0
- package/dist/esm/helpers/getAnimationDriver.js.map +7 -0
- package/dist/esm/helpers/getExpandedShorthands.js +16 -0
- package/dist/esm/helpers/getExpandedShorthands.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/getSplitStyles.js +849 -0
- package/dist/esm/helpers/getSplitStyles.js.map +7 -0
- package/dist/esm/helpers/getStylesAtomic.js +200 -0
- package/dist/esm/helpers/getStylesAtomic.js.map +7 -0
- package/dist/esm/helpers/getStylesAtomic.native.js +12 -0
- package/dist/esm/helpers/getStylesAtomic.native.js.map +7 -0
- package/dist/esm/helpers/getThemeCSSRules.js +86 -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 +67 -0
- package/dist/esm/helpers/getVariantExtras.js.map +7 -0
- package/dist/esm/helpers/insertStyleRule.js +186 -0
- package/dist/esm/helpers/insertStyleRule.js.map +7 -0
- package/dist/esm/helpers/isObj.js +5 -0
- package/dist/esm/helpers/isObj.js.map +7 -0
- package/dist/esm/helpers/isTamaguiComponent.js +8 -0
- package/dist/esm/helpers/isTamaguiComponent.js.map +7 -0
- package/dist/esm/helpers/isTamaguiElement.js +9 -0
- package/dist/esm/helpers/isTamaguiElement.js.map +7 -0
- package/dist/esm/helpers/matchMedia.js +17 -0
- package/dist/esm/helpers/matchMedia.js.map +7 -0
- package/dist/esm/helpers/matchMedia.native.js +23 -0
- package/dist/esm/helpers/matchMedia.native.js.map +7 -0
- package/dist/esm/helpers/mergeProps.js +30 -0
- package/dist/esm/helpers/mergeProps.js.map +7 -0
- package/dist/esm/helpers/mergeTransform.js +21 -0
- package/dist/esm/helpers/mergeTransform.js.map +7 -0
- package/dist/esm/helpers/normalizeColor.js +36 -0
- package/dist/esm/helpers/normalizeColor.js.map +7 -0
- package/dist/esm/helpers/normalizeValueWithProperty.js +113 -0
- package/dist/esm/helpers/normalizeValueWithProperty.js.map +7 -0
- package/dist/esm/helpers/proxyThemeVariables.js +16 -0
- package/dist/esm/helpers/proxyThemeVariables.js.map +7 -0
- package/dist/esm/helpers/pseudoDescriptors.js +29 -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/themeable.js +28 -0
- package/dist/esm/helpers/themeable.js.map +7 -0
- package/dist/esm/helpers/themes.js +53 -0
- package/dist/esm/helpers/themes.js.map +7 -0
- package/dist/esm/helpers/timer.js +11 -0
- package/dist/esm/helpers/timer.js.map +7 -0
- package/dist/esm/helpers/useShallowSetState.js +35 -0
- package/dist/esm/helpers/useShallowSetState.js.map +7 -0
- package/dist/esm/helpers/warnOnce.js +14 -0
- package/dist/esm/helpers/warnOnce.js.map +7 -0
- package/dist/esm/helpers/withStaticProperties.js +8 -0
- package/dist/esm/helpers/withStaticProperties.js.map +7 -0
- package/dist/esm/hooks/getThemeUnwrapped.js +9 -0
- package/dist/esm/hooks/getThemeUnwrapped.js.map +7 -0
- package/dist/esm/hooks/useId.js +5 -0
- package/dist/esm/hooks/useId.js.map +7 -0
- package/dist/esm/hooks/useIsTouchDevice.js +9 -0
- package/dist/esm/hooks/useIsTouchDevice.js.map +7 -0
- package/dist/esm/hooks/useMedia.js +225 -0
- package/dist/esm/hooks/useMedia.js.map +7 -0
- package/dist/esm/hooks/useSafeRef.js +35 -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/useStyle.js +37 -0
- package/dist/esm/hooks/useStyle.js.map +7 -0
- package/dist/esm/hooks/useTheme.js +205 -0
- package/dist/esm/hooks/useTheme.js.map +7 -0
- package/dist/esm/hooks/useThemeName.js +28 -0
- package/dist/esm/hooks/useThemeName.js.map +7 -0
- package/dist/esm/index.js +77 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/inject-styles.js +16 -0
- package/dist/esm/inject-styles.js.map +7 -0
- package/dist/esm/insertFont.js +67 -0
- package/dist/esm/insertFont.js.map +7 -0
- package/dist/esm/setupHooks.js +9 -0
- package/dist/esm/setupHooks.js.map +7 -0
- package/dist/esm/setupReactNative.js +25 -0
- package/dist/esm/setupReactNative.js.map +7 -0
- package/dist/esm/styled.js +71 -0
- package/dist/esm/styled.js.map +7 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/types.js.map +7 -0
- package/dist/esm/updateTheme.js +23 -0
- package/dist/esm/updateTheme.js.map +7 -0
- package/dist/esm/views/FontLanguage.js +17 -0
- package/dist/esm/views/FontLanguage.js.map +7 -0
- package/dist/esm/views/FontLanguage.native.js +11 -0
- package/dist/esm/views/FontLanguage.native.js.map +7 -0
- package/dist/esm/views/FontLanguage.types.js +1 -0
- package/dist/esm/views/FontLanguage.types.js.map +7 -0
- package/dist/esm/views/Slot.js +66 -0
- package/dist/esm/views/Slot.js.map +7 -0
- package/dist/esm/views/Stack.js +14 -0
- package/dist/esm/views/Stack.js.map +7 -0
- package/dist/esm/views/TamaguiProvider.js +56 -0
- package/dist/esm/views/TamaguiProvider.js.map +7 -0
- package/dist/esm/views/Text.js +70 -0
- package/dist/esm/views/Text.js.map +7 -0
- package/dist/esm/views/Theme.js +63 -0
- package/dist/esm/views/Theme.js.map +7 -0
- package/dist/esm/views/ThemeProvider.js +45 -0
- package/dist/esm/views/ThemeProvider.js.map +7 -0
- package/package.json +73 -0
- package/reset.css +37 -0
- package/src/Tamagui.ts +48 -0
- package/src/addTheme.ts +65 -0
- package/src/config.ts +62 -0
- package/src/constants/constants.ts +17 -0
- package/src/constants/isDevTools.ts +12 -0
- package/src/contexts/ButtonNestingContext.tsx +3 -0
- package/src/contexts/FontLanguageContext.tsx +5 -0
- package/src/contexts/TextAncestorContext.tsx +3 -0
- package/src/createComponent.tsx +1133 -0
- package/src/createFont.ts +50 -0
- package/src/createShorthands.ts +7 -0
- package/src/createTamagui.ts +253 -0
- package/src/createTheme.ts +13 -0
- package/src/createTokens.ts +46 -0
- package/src/createVariable.ts +93 -0
- package/src/createVariables.ts +55 -0
- package/src/helpers/RNComponents.tsx +14 -0
- package/src/helpers/ThemeManager.tsx +285 -0
- package/src/helpers/ThemeManagerContext.tsx +5 -0
- package/src/helpers/createMediaStyle.ts +55 -0
- package/src/helpers/createPropMapper.ts +562 -0
- package/src/helpers/createProxy.ts +16 -0
- package/src/helpers/expandStyle.ts +82 -0
- package/src/helpers/expandStyles.ts +107 -0
- package/src/helpers/extendStaticConfig.ts +78 -0
- package/src/helpers/getAnimationDriver.tsx +5 -0
- package/src/helpers/getExpandedShorthands.ts +17 -0
- package/src/helpers/getFontLanguage.ts +2 -0
- package/src/helpers/getSplitStyles.tsx +1133 -0
- package/src/helpers/getStylesAtomic.native.ts +8 -0
- package/src/helpers/getStylesAtomic.ts +274 -0
- package/src/helpers/getThemeCSSRules.native.ts +3 -0
- package/src/helpers/getThemeCSSRules.ts +120 -0
- package/src/helpers/getVariantExtras.tsx +85 -0
- package/src/helpers/insertStyleRule.tsx +218 -0
- package/src/helpers/isObj.ts +1 -0
- package/src/helpers/isTamaguiComponent.tsx +11 -0
- package/src/helpers/isTamaguiElement.tsx +11 -0
- package/src/helpers/matchMedia.native.ts +23 -0
- package/src/helpers/matchMedia.ts +16 -0
- package/src/helpers/mergeProps.ts +56 -0
- package/src/helpers/mergeTransform.ts +30 -0
- package/src/helpers/normalizeColor.ts +38 -0
- package/src/helpers/normalizeValueWithProperty.ts +129 -0
- package/src/helpers/proxyThemeVariables.tsx +15 -0
- package/src/helpers/pseudoDescriptors.ts +40 -0
- package/src/helpers/registerCSSVariable.ts +13 -0
- package/src/helpers/themeable.tsx +44 -0
- package/src/helpers/themes.ts +67 -0
- package/src/helpers/timer.ts +9 -0
- package/src/helpers/useShallowSetState.tsx +41 -0
- package/src/helpers/warnOnce.tsx +11 -0
- package/src/helpers/withStaticProperties.tsx +7 -0
- package/src/hooks/getThemeUnwrapped.tsx +5 -0
- package/src/hooks/useId.tsx +1 -0
- package/src/hooks/useIsTouchDevice.tsx +6 -0
- package/src/hooks/useMedia.tsx +298 -0
- package/src/hooks/useSafeRef.ts +45 -0
- package/src/hooks/useServerHooks.tsx +12 -0
- package/src/hooks/useStyle.tsx +49 -0
- package/src/hooks/useTheme.tsx +274 -0
- package/src/hooks/useThemeName.tsx +27 -0
- package/src/index.ts +72 -0
- package/src/inject-styles.ts +20 -0
- package/src/insertFont.ts +73 -0
- package/src/setupHooks.ts +35 -0
- package/src/setupReactNative.ts +22 -0
- package/src/styled.tsx +195 -0
- package/src/types.tsx +1459 -0
- package/src/updateTheme.ts +26 -0
- package/src/views/FontLanguage.native.tsx +12 -0
- package/src/views/FontLanguage.tsx +16 -0
- package/src/views/FontLanguage.types.ts +13 -0
- package/src/views/Slot.tsx +95 -0
- package/src/views/Stack.tsx +25 -0
- package/src/views/TamaguiProvider.tsx +65 -0
- package/src/views/Text.tsx +87 -0
- package/src/views/Theme.tsx +83 -0
- package/src/views/ThemeProvider.tsx +55 -0
- package/types/Tamagui.d.ts +30 -0
- package/types/Tamagui.d.ts.map +1 -0
- package/types/addTheme.d.ts +32 -0
- package/types/addTheme.d.ts.map +1 -0
- package/types/config.d.ts +49 -0
- package/types/config.d.ts.map +1 -0
- package/types/constants/constants.d.ts +21 -0
- package/types/constants/constants.d.ts.map +1 -0
- package/types/constants/isDevTools.d.ts +2 -0
- package/types/constants/isDevTools.d.ts.map +1 -0
- package/types/contexts/ButtonNestingContext.d.ts +3 -0
- package/types/contexts/ButtonNestingContext.d.ts.map +1 -0
- package/types/contexts/FontLanguageContext.d.ts +5 -0
- package/types/contexts/FontLanguageContext.d.ts.map +1 -0
- package/types/contexts/TextAncestorContext.d.ts +3 -0
- package/types/contexts/TextAncestorContext.d.ts.map +1 -0
- package/types/createComponent.d.ts +23 -0
- package/types/createComponent.d.ts.map +1 -0
- package/types/createFont.d.ts +3 -0
- package/types/createFont.d.ts.map +1 -0
- package/types/createShorthands.d.ts +3 -0
- package/types/createShorthands.d.ts.map +1 -0
- package/types/createTamagui.d.ts +3 -0
- package/types/createTamagui.d.ts.map +1 -0
- package/types/createTheme.d.ts +7 -0
- package/types/createTheme.d.ts.map +1 -0
- package/types/createTokens.d.ts +28 -0
- package/types/createTokens.d.ts.map +1 -0
- package/types/createVariable.d.ts +26 -0
- package/types/createVariable.d.ts.map +1 -0
- package/types/createVariables.d.ts +11 -0
- package/types/createVariables.d.ts.map +1 -0
- package/types/helpers/RNComponents.d.ts +2 -0
- package/types/helpers/RNComponents.d.ts.map +1 -0
- package/types/helpers/ThemeManager.d.ts +36 -0
- package/types/helpers/ThemeManager.d.ts.map +1 -0
- package/types/helpers/ThemeManagerContext.d.ts +4 -0
- package/types/helpers/ThemeManagerContext.d.ts.map +1 -0
- package/types/helpers/createMediaStyle.d.ts +5 -0
- package/types/helpers/createMediaStyle.d.ts.map +1 -0
- package/types/helpers/createPropMapper.d.ts +7 -0
- package/types/helpers/createPropMapper.d.ts.map +1 -0
- package/types/helpers/createProxy.d.ts +2 -0
- package/types/helpers/createProxy.d.ts.map +1 -0
- package/types/helpers/expandStyle.d.ts +6 -0
- package/types/helpers/expandStyle.d.ts.map +1 -0
- package/types/helpers/expandStyles.d.ts +26 -0
- package/types/helpers/expandStyles.d.ts.map +1 -0
- package/types/helpers/extendStaticConfig.d.ts +4 -0
- package/types/helpers/extendStaticConfig.d.ts.map +1 -0
- package/types/helpers/getAnimationDriver.d.ts +6 -0
- package/types/helpers/getAnimationDriver.d.ts.map +1 -0
- package/types/helpers/getExpandedShorthands.d.ts +3 -0
- package/types/helpers/getExpandedShorthands.d.ts.map +1 -0
- package/types/helpers/getFontLanguage.d.ts +2 -0
- package/types/helpers/getFontLanguage.d.ts.map +1 -0
- package/types/helpers/getSplitStyles.d.ts +31 -0
- package/types/helpers/getSplitStyles.d.ts.map +1 -0
- package/types/helpers/getStylesAtomic.d.ts +18 -0
- package/types/helpers/getStylesAtomic.d.ts.map +1 -0
- package/types/helpers/getStylesAtomic.native.d.ts +4 -0
- package/types/helpers/getStylesAtomic.native.d.ts.map +1 -0
- package/types/helpers/getThemeCSSRules.d.ts +8 -0
- package/types/helpers/getThemeCSSRules.d.ts.map +1 -0
- package/types/helpers/getThemeCSSRules.native.d.ts +2 -0
- package/types/helpers/getThemeCSSRules.native.d.ts.map +1 -0
- package/types/helpers/getVariantExtras.d.ts +5 -0
- package/types/helpers/getVariantExtras.d.ts.map +1 -0
- package/types/helpers/insertStyleRule.d.ts +11 -0
- package/types/helpers/insertStyleRule.d.ts.map +1 -0
- package/types/helpers/isObj.d.ts +2 -0
- package/types/helpers/isObj.d.ts.map +1 -0
- package/types/helpers/isTamaguiComponent.d.ts +5 -0
- package/types/helpers/isTamaguiComponent.d.ts.map +1 -0
- package/types/helpers/isTamaguiElement.d.ts +3 -0
- package/types/helpers/isTamaguiElement.d.ts.map +1 -0
- package/types/helpers/matchMedia.d.ts +6 -0
- package/types/helpers/matchMedia.d.ts.map +1 -0
- package/types/helpers/matchMedia.native.d.ts +4 -0
- package/types/helpers/matchMedia.native.d.ts.map +1 -0
- package/types/helpers/mergeProps.d.ts +17 -0
- package/types/helpers/mergeProps.d.ts.map +1 -0
- package/types/helpers/mergeTransform.d.ts +9 -0
- package/types/helpers/mergeTransform.d.ts.map +1 -0
- package/types/helpers/normalizeColor.d.ts +4 -0
- package/types/helpers/normalizeColor.d.ts.map +1 -0
- package/types/helpers/normalizeValueWithProperty.d.ts +7 -0
- package/types/helpers/normalizeValueWithProperty.d.ts.map +1 -0
- package/types/helpers/proxyThemeVariables.d.ts +2 -0
- package/types/helpers/proxyThemeVariables.d.ts.map +1 -0
- package/types/helpers/pseudoDescriptors.d.ts +10 -0
- package/types/helpers/pseudoDescriptors.d.ts.map +1 -0
- package/types/helpers/registerCSSVariable.d.ts +5 -0
- package/types/helpers/registerCSSVariable.d.ts.map +1 -0
- package/types/helpers/themeable.d.ts +12 -0
- package/types/helpers/themeable.d.ts.map +1 -0
- package/types/helpers/themes.d.ts +4 -0
- package/types/helpers/themes.d.ts.map +1 -0
- package/types/helpers/timer.d.ts +2 -0
- package/types/helpers/timer.d.ts.map +1 -0
- package/types/helpers/useShallowSetState.d.ts +5 -0
- package/types/helpers/useShallowSetState.d.ts.map +1 -0
- package/types/helpers/warnOnce.d.ts +2 -0
- package/types/helpers/warnOnce.d.ts.map +1 -0
- package/types/helpers/withStaticProperties.d.ts +2 -0
- package/types/helpers/withStaticProperties.d.ts.map +1 -0
- package/types/hooks/getThemeUnwrapped.d.ts +3 -0
- package/types/hooks/getThemeUnwrapped.d.ts.map +1 -0
- package/types/hooks/useId.d.ts +2 -0
- package/types/hooks/useId.d.ts.map +1 -0
- package/types/hooks/useIsTouchDevice.d.ts +2 -0
- package/types/hooks/useIsTouchDevice.d.ts.map +1 -0
- package/types/hooks/useMedia.d.ts +33 -0
- package/types/hooks/useMedia.d.ts.map +1 -0
- package/types/hooks/useSafeRef.d.ts +4 -0
- package/types/hooks/useSafeRef.d.ts.map +1 -0
- package/types/hooks/useServerHooks.d.ts +4 -0
- package/types/hooks/useServerHooks.d.ts.map +1 -0
- package/types/hooks/useStyle.d.ts +8 -0
- package/types/hooks/useStyle.d.ts.map +1 -0
- package/types/hooks/useTheme.d.ts +25 -0
- package/types/hooks/useTheme.d.ts.map +1 -0
- package/types/hooks/useThemeName.d.ts +5 -0
- package/types/hooks/useThemeName.d.ts.map +1 -0
- package/types/index.d.ts +56 -0
- package/types/index.d.ts.map +1 -0
- package/types/inject-styles.d.ts +7 -0
- package/types/inject-styles.d.ts.map +1 -0
- package/types/insertFont.d.ts +9 -0
- package/types/insertFont.d.ts.map +1 -0
- package/types/setupHooks.d.ts +14 -0
- package/types/setupHooks.d.ts.map +1 -0
- package/types/setupReactNative.d.ts +5 -0
- package/types/setupReactNative.d.ts.map +1 -0
- package/types/styled.d.ts +20 -0
- package/types/styled.d.ts.map +1 -0
- package/types/types.d.ts +715 -0
- package/types/types.d.ts.map +1 -0
- package/types/updateTheme.d.ts +30 -0
- package/types/updateTheme.d.ts.map +1 -0
- package/types/views/FontLanguage.d.ts +4 -0
- package/types/views/FontLanguage.d.ts.map +1 -0
- package/types/views/FontLanguage.native.d.ts +4 -0
- package/types/views/FontLanguage.native.d.ts.map +1 -0
- package/types/views/FontLanguage.types.d.ts +11 -0
- package/types/views/FontLanguage.types.d.ts.map +1 -0
- package/types/views/Slot.d.ts +11 -0
- package/types/views/Slot.d.ts.map +1 -0
- package/types/views/Stack.d.ts +4 -0
- package/types/views/Stack.d.ts.map +1 -0
- package/types/views/TamaguiProvider.d.ts +4 -0
- package/types/views/TamaguiProvider.d.ts.map +1 -0
- package/types/views/Text.d.ts +4 -0
- package/types/views/Text.d.ts.map +1 -0
- package/types/views/Theme.d.ts +8 -0
- package/types/views/Theme.d.ts.map +1 -0
- package/types/views/ThemeProvider.d.ts +12 -0
- package/types/views/ThemeProvider.d.ts.map +1 -0
|
@@ -0,0 +1,562 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
}
|