@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,50 @@
|
|
|
1
|
+
import { FontWeightSteps, GenericFont } from './types'
|
|
2
|
+
|
|
3
|
+
const fontWeights: FontWeightSteps[] = [
|
|
4
|
+
'100',
|
|
5
|
+
'200',
|
|
6
|
+
'300',
|
|
7
|
+
'400',
|
|
8
|
+
'500',
|
|
9
|
+
'600',
|
|
10
|
+
'700',
|
|
11
|
+
'800',
|
|
12
|
+
'900',
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
const processSection = <T>(
|
|
16
|
+
section: string | Record<string, T>,
|
|
17
|
+
keys: string[],
|
|
18
|
+
defaultValue?: any
|
|
19
|
+
): string | Record<string, T> => {
|
|
20
|
+
if (typeof section === 'string') return section
|
|
21
|
+
|
|
22
|
+
const sectionKeys = Object.keys(section)
|
|
23
|
+
let fillValue = section[sectionKeys[0]]
|
|
24
|
+
|
|
25
|
+
return Object.fromEntries(
|
|
26
|
+
[...new Set([...keys, ...sectionKeys])].map((key) => {
|
|
27
|
+
const value = section[key] ?? defaultValue ?? fillValue
|
|
28
|
+
fillValue = value
|
|
29
|
+
defaultValue = value
|
|
30
|
+
return [key, value]
|
|
31
|
+
})
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const createFont = <A extends GenericFont>(font: A): A => {
|
|
36
|
+
const sizeKeys = Object.keys(font.size)
|
|
37
|
+
const processedFont = Object.fromEntries(
|
|
38
|
+
Object.entries(font).map(([key, section]) => {
|
|
39
|
+
return [
|
|
40
|
+
key,
|
|
41
|
+
processSection(
|
|
42
|
+
section as any,
|
|
43
|
+
key === 'face' ? fontWeights : sizeKeys,
|
|
44
|
+
key === 'face' ? { normal: font.family } : undefined
|
|
45
|
+
),
|
|
46
|
+
]
|
|
47
|
+
})
|
|
48
|
+
)
|
|
49
|
+
return Object.freeze(processedFont) as A
|
|
50
|
+
}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { isRSC, isWeb } from '@tamagui/constants'
|
|
2
|
+
|
|
3
|
+
import { configListeners, setConfig } from './config'
|
|
4
|
+
import { createVariables, tokensKeysOrdered } from './createVariables'
|
|
5
|
+
import { getThemeCSSRules } from './helpers/getThemeCSSRules'
|
|
6
|
+
import {
|
|
7
|
+
getAllRules,
|
|
8
|
+
listenForSheetChanges,
|
|
9
|
+
scanAllSheets,
|
|
10
|
+
} from './helpers/insertStyleRule'
|
|
11
|
+
import {
|
|
12
|
+
registerCSSVariable,
|
|
13
|
+
tokensValueToVariable,
|
|
14
|
+
variableToCSS,
|
|
15
|
+
} from './helpers/registerCSSVariable'
|
|
16
|
+
import { ensureThemeVariable, proxyThemeToParents } from './helpers/themes'
|
|
17
|
+
import { configureMedia } from './hooks/useMedia'
|
|
18
|
+
import { parseFont, registerFontVariables } from './insertFont'
|
|
19
|
+
import { Tamagui } from './Tamagui'
|
|
20
|
+
import {
|
|
21
|
+
CreateTamaguiProps,
|
|
22
|
+
InferTamaguiConfig,
|
|
23
|
+
TamaguiInternalConfig,
|
|
24
|
+
ThemeParsed,
|
|
25
|
+
} from './types'
|
|
26
|
+
|
|
27
|
+
// config is re-run by the @tamagui/static, dont double validate
|
|
28
|
+
const createdConfigs = new WeakMap<any, boolean>()
|
|
29
|
+
|
|
30
|
+
export function createTamagui<Conf extends CreateTamaguiProps>(
|
|
31
|
+
configIn: Conf
|
|
32
|
+
): InferTamaguiConfig<Conf> {
|
|
33
|
+
if (createdConfigs.has(configIn)) {
|
|
34
|
+
return configIn as any
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (process.env.NODE_ENV === 'development') {
|
|
38
|
+
if (!configIn.tokens) {
|
|
39
|
+
throw new Error('Must define tokens')
|
|
40
|
+
}
|
|
41
|
+
if (!configIn.themes) {
|
|
42
|
+
throw new Error('Must define themes')
|
|
43
|
+
}
|
|
44
|
+
if (!configIn.fonts) {
|
|
45
|
+
throw new Error('Must define fonts')
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
scanAllSheets()
|
|
50
|
+
listenForSheetChanges()
|
|
51
|
+
|
|
52
|
+
const fontTokens = Object.fromEntries(
|
|
53
|
+
Object.entries(configIn.fonts!).map(([k, v]) => {
|
|
54
|
+
return [k, createVariables(v, 'f', true)]
|
|
55
|
+
})
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
const fontsParsed = (() => {
|
|
59
|
+
const res = {} as typeof fontTokens
|
|
60
|
+
for (const familyName in fontTokens) {
|
|
61
|
+
res[`$${familyName}`] = parseFont(fontTokens[familyName])
|
|
62
|
+
}
|
|
63
|
+
return res!
|
|
64
|
+
})()
|
|
65
|
+
|
|
66
|
+
const themeConfig = (() => {
|
|
67
|
+
const themes = { ...configIn.themes }
|
|
68
|
+
const cssRuleSets: string[] = []
|
|
69
|
+
|
|
70
|
+
if (isWeb) {
|
|
71
|
+
const declarations: string[] = []
|
|
72
|
+
const fontDeclarations: Record<
|
|
73
|
+
string,
|
|
74
|
+
{ name: string; declarations: string[]; language?: string }
|
|
75
|
+
> = {}
|
|
76
|
+
|
|
77
|
+
for (const key in configIn.tokens) {
|
|
78
|
+
for (const skey in configIn.tokens[key]) {
|
|
79
|
+
const val = configIn.tokens[key][skey]
|
|
80
|
+
registerCSSVariable(val)
|
|
81
|
+
declarations.push(variableToCSS(val))
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
for (const key in fontsParsed) {
|
|
86
|
+
const fontParsed = fontsParsed[key]
|
|
87
|
+
const [name, language] = key.includes('_') ? key.split('_') : [key]
|
|
88
|
+
const fontVars = registerFontVariables(fontParsed)
|
|
89
|
+
fontDeclarations[key] = {
|
|
90
|
+
name: name.slice(1),
|
|
91
|
+
declarations: fontVars,
|
|
92
|
+
language,
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const sep =
|
|
97
|
+
process.env.NODE_ENV === 'development' ? configIn.cssStyleSeparator || ' ' : ''
|
|
98
|
+
|
|
99
|
+
function declarationsToRuleSet(decs: string[], selector = '') {
|
|
100
|
+
return `:root${selector} {${sep}${[...decs].join(`;${sep}`)}${sep}}`
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// non-font
|
|
104
|
+
cssRuleSets.push(declarationsToRuleSet(declarations))
|
|
105
|
+
|
|
106
|
+
// fonts
|
|
107
|
+
if (fontDeclarations) {
|
|
108
|
+
for (const key in fontDeclarations) {
|
|
109
|
+
const { name, declarations, language = 'default' } = fontDeclarations[key]
|
|
110
|
+
const fontSelector = `.font_${name}`
|
|
111
|
+
const langSelector = `:root .t_lang-${name}-${language} ${fontSelector}`
|
|
112
|
+
const selectors =
|
|
113
|
+
language === 'default' ? ` ${fontSelector}, ${langSelector}` : langSelector
|
|
114
|
+
const specificRuleSet = declarationsToRuleSet(declarations, selectors)
|
|
115
|
+
cssRuleSets.push(specificRuleSet)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// dedupe themes to avoid duplicate CSS generation
|
|
121
|
+
type DedupedTheme = {
|
|
122
|
+
names: string[]
|
|
123
|
+
theme: ThemeParsed
|
|
124
|
+
}
|
|
125
|
+
const dedupedThemes: {
|
|
126
|
+
[key: string]: DedupedTheme
|
|
127
|
+
} = {}
|
|
128
|
+
const existing = new WeakMap<ThemeParsed, DedupedTheme>()
|
|
129
|
+
|
|
130
|
+
// first, de-dupe and parse them
|
|
131
|
+
for (const themeName in themes) {
|
|
132
|
+
const rawTheme = themes[themeName] as ThemeParsed
|
|
133
|
+
|
|
134
|
+
// if existing, avoid
|
|
135
|
+
if (existing.has(rawTheme)) {
|
|
136
|
+
const e = existing.get(rawTheme)!
|
|
137
|
+
themes[themeName] = e.theme
|
|
138
|
+
e.names.push(themeName)
|
|
139
|
+
continue
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// ensure each theme object unique for dedupe
|
|
143
|
+
const theme = { ...rawTheme }
|
|
144
|
+
// parse into variables
|
|
145
|
+
for (const key in theme) {
|
|
146
|
+
// make sure properly names theme variables
|
|
147
|
+
ensureThemeVariable(theme, key)
|
|
148
|
+
}
|
|
149
|
+
themes[themeName] = theme
|
|
150
|
+
|
|
151
|
+
// set deduped
|
|
152
|
+
dedupedThemes[themeName] = {
|
|
153
|
+
names: [themeName],
|
|
154
|
+
theme,
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
existing.set(rawTheme, dedupedThemes[themeName])
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// then, generate CSS from de-duped
|
|
161
|
+
let themeRuleSets: string[] = []
|
|
162
|
+
|
|
163
|
+
if (isWeb || isRSC) {
|
|
164
|
+
for (const themeName in dedupedThemes) {
|
|
165
|
+
themeRuleSets = [
|
|
166
|
+
...themeRuleSets,
|
|
167
|
+
...getThemeCSSRules({
|
|
168
|
+
config: configIn,
|
|
169
|
+
themeName,
|
|
170
|
+
...dedupedThemes[themeName],
|
|
171
|
+
}),
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// proxy upwards to get parent variables (themes are subset going down)
|
|
177
|
+
for (const themeName in themes) {
|
|
178
|
+
themes[themeName] = proxyThemeToParents(themeName, themes[themeName], themes)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
tokensValueToVariable.clear()
|
|
182
|
+
|
|
183
|
+
return {
|
|
184
|
+
themes,
|
|
185
|
+
cssRuleSets,
|
|
186
|
+
themeRuleSets,
|
|
187
|
+
}
|
|
188
|
+
})()
|
|
189
|
+
|
|
190
|
+
// faster $lookups
|
|
191
|
+
const tokensParsed: any = Object.fromEntries(
|
|
192
|
+
Object.entries(configIn.tokens).map(([k, v]) => {
|
|
193
|
+
const val = Object.fromEntries(Object.entries(v).map(([k, v]) => [`$${k}`, v]))
|
|
194
|
+
tokensKeysOrdered.set(val, tokensKeysOrdered.get(v))
|
|
195
|
+
return [k, val]
|
|
196
|
+
})
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
const shorthands = configIn.shorthands || {}
|
|
200
|
+
|
|
201
|
+
const config: TamaguiInternalConfig = {
|
|
202
|
+
fontLanguages: [],
|
|
203
|
+
animations: {} as any,
|
|
204
|
+
media: {},
|
|
205
|
+
...configIn,
|
|
206
|
+
// already processed by createTokens()
|
|
207
|
+
tokens: configIn.tokens as any,
|
|
208
|
+
// vite made this into a function if it wasn't set
|
|
209
|
+
shorthands: { ...shorthands },
|
|
210
|
+
inverseShorthands: shorthands
|
|
211
|
+
? Object.fromEntries(Object.entries(shorthands).map(([k, v]) => [v, k]))
|
|
212
|
+
: {},
|
|
213
|
+
themes: themeConfig.themes as any,
|
|
214
|
+
fontsParsed,
|
|
215
|
+
themeConfig,
|
|
216
|
+
tokensParsed,
|
|
217
|
+
parsed: true,
|
|
218
|
+
getCSS: (separator = '\n') => {
|
|
219
|
+
return `
|
|
220
|
+
._ovs-contain {overscroll-behavior:contain;}
|
|
221
|
+
.t_unmounted .t_will-mount {opacity:0;visibility:hidden;}
|
|
222
|
+
.is_Text .is_Text {display:inline-flex;}
|
|
223
|
+
._dsp_contents {display:contents;}
|
|
224
|
+
${themeConfig.cssRuleSets.join(separator)}
|
|
225
|
+
${themeConfig.themeRuleSets.join(separator)}
|
|
226
|
+
${getAllRules().join(separator)}`
|
|
227
|
+
},
|
|
228
|
+
// const tokens = [...getToken(tokens.size[0])]
|
|
229
|
+
// .spacer-sm + ._dsp_contents._dsp-sm-hidden { margin-left: -var(--${}) }
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
configureMedia(config)
|
|
233
|
+
setConfig(config)
|
|
234
|
+
|
|
235
|
+
if (configListeners.size) {
|
|
236
|
+
configListeners.forEach((cb) => cb(config))
|
|
237
|
+
configListeners.clear()
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
createdConfigs.set(config, true)
|
|
241
|
+
|
|
242
|
+
if (process.env.NODE_ENV === 'development') {
|
|
243
|
+
if (process.env.DEBUG?.startsWith('tamagui')) {
|
|
244
|
+
// eslint-disable-next-line no-console
|
|
245
|
+
console.log('Tamagui config:', config)
|
|
246
|
+
}
|
|
247
|
+
if (!globalThis['Tamagui']) {
|
|
248
|
+
globalThis['Tamagui'] = Tamagui
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
return config as any
|
|
253
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Variable } from './createVariable'
|
|
2
|
+
|
|
3
|
+
type GenericTheme = { [key: string]: string | Variable }
|
|
4
|
+
|
|
5
|
+
// export const themeToVariableToValueMap = new WeakMap<any, Record<string, string>>()
|
|
6
|
+
|
|
7
|
+
export const createTheme = <Theme extends GenericTheme>(
|
|
8
|
+
theme: Theme
|
|
9
|
+
): {
|
|
10
|
+
[K in keyof Theme]: Theme[K] | string | Variable
|
|
11
|
+
} => {
|
|
12
|
+
return theme
|
|
13
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Variable } from './createVariable'
|
|
2
|
+
import { createVariables } from './createVariables'
|
|
3
|
+
import { CreateTokens } from './types'
|
|
4
|
+
|
|
5
|
+
// tokens.color.dark.red ===> { var: `color-dark-red`, val: '' }
|
|
6
|
+
export function createTokens<T extends CreateTokens>(tokens: T): MakeTokens<T> {
|
|
7
|
+
return createVariables(tokens) as any
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// verbose but gives us nice types...
|
|
11
|
+
type MakeTokens<T> = T extends {
|
|
12
|
+
color: infer E
|
|
13
|
+
space: infer F
|
|
14
|
+
size: infer G
|
|
15
|
+
radius: infer H
|
|
16
|
+
zIndex: infer J
|
|
17
|
+
}
|
|
18
|
+
? {
|
|
19
|
+
color: {
|
|
20
|
+
// removes $ prefix allowing for defining either as $1: or 1:,
|
|
21
|
+
// which is important because Chrome re-orders numerical-seeming keys :/
|
|
22
|
+
[Key in keyof E extends `$${infer X}` ? X : keyof E]: Variable<string>
|
|
23
|
+
}
|
|
24
|
+
space: {
|
|
25
|
+
[Key in keyof F extends `$${infer X}` ? X : keyof F]: Variable<number>
|
|
26
|
+
}
|
|
27
|
+
size: {
|
|
28
|
+
[Key in keyof G extends `$${infer X}` ? X : keyof G]: Variable<number>
|
|
29
|
+
}
|
|
30
|
+
radius: {
|
|
31
|
+
[Key in keyof H extends `$${infer X}` ? X : keyof H]: Variable<number>
|
|
32
|
+
}
|
|
33
|
+
zIndex: {
|
|
34
|
+
[Key in keyof J extends `$${infer X}` ? X : keyof J]: Variable<number>
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
: never
|
|
38
|
+
|
|
39
|
+
// test
|
|
40
|
+
const tokens = createTokens({
|
|
41
|
+
size: { 0: 1 },
|
|
42
|
+
space: { 0: 1 },
|
|
43
|
+
radius: { 0: 1 },
|
|
44
|
+
zIndex: { 0: 1 },
|
|
45
|
+
color: { 0: 'hi' },
|
|
46
|
+
})
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { isWeb } from '@tamagui/constants'
|
|
2
|
+
import { simpleHash } from '@tamagui/helpers'
|
|
3
|
+
|
|
4
|
+
import { getConfig } from './config'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Should rename this to Token
|
|
8
|
+
* Moving to objects for React Server Components support
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const IS_VAR = 'isVar'
|
|
12
|
+
|
|
13
|
+
export interface Variable<A = any> {
|
|
14
|
+
[IS_VAR]?: true
|
|
15
|
+
variable?: string
|
|
16
|
+
val: A
|
|
17
|
+
name: string
|
|
18
|
+
key: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type MakeVariable<A = any> = A extends string | number ? Variable<A> : A
|
|
22
|
+
|
|
23
|
+
type VariableIn<A = any> = Pick<Variable<A>, 'key' | 'name' | 'val'>
|
|
24
|
+
export const createVariable = <A extends string | number | Variable = any>(
|
|
25
|
+
props: VariableIn<A>
|
|
26
|
+
): Variable<A> => {
|
|
27
|
+
if (isVariable(props)) return props
|
|
28
|
+
const { key, name, val } = props
|
|
29
|
+
return {
|
|
30
|
+
[IS_VAR]: true,
|
|
31
|
+
key: key!,
|
|
32
|
+
name: simpleHash(name, 40),
|
|
33
|
+
val: val as any,
|
|
34
|
+
variable: isWeb ? createCSSVariable(name) : '',
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// could do weakmap cache
|
|
39
|
+
export function variableToString(vrble?: any, getValue = false) {
|
|
40
|
+
if (isVariable(vrble)) {
|
|
41
|
+
if (!getValue && isWeb && vrble.variable) {
|
|
42
|
+
return vrble.variable
|
|
43
|
+
}
|
|
44
|
+
return `${vrble.val}`
|
|
45
|
+
}
|
|
46
|
+
return `${vrble || ''}`
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function isVariable(v: Variable | any): v is Variable {
|
|
50
|
+
return v && typeof v === 'object' && IS_VAR in v
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function getVariable(nameOrVariable: Variable | string) {
|
|
54
|
+
setDidGetVariableValue(true)
|
|
55
|
+
if (isVariable(nameOrVariable)) {
|
|
56
|
+
return variableToString(nameOrVariable)
|
|
57
|
+
}
|
|
58
|
+
const tokens = getConfig().tokensParsed
|
|
59
|
+
return variableToString(tokens[nameOrVariable] ?? nameOrVariable)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
let accessed = false
|
|
63
|
+
export const setDidGetVariableValue = (val: boolean) => (accessed = val)
|
|
64
|
+
export const didGetVariableValue = () => accessed
|
|
65
|
+
|
|
66
|
+
export function getVariableValue(v: Variable | any) {
|
|
67
|
+
if (isVariable(v)) {
|
|
68
|
+
setDidGetVariableValue(true)
|
|
69
|
+
return v.val
|
|
70
|
+
}
|
|
71
|
+
return v
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function getVariableName(v: Variable | any) {
|
|
75
|
+
if (isVariable(v)) return v.name
|
|
76
|
+
return v
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function getVariableVariable(v: Variable | any) {
|
|
80
|
+
if (isVariable(v)) return v.variable
|
|
81
|
+
return v
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// bugfix { space: { 0.5: 10 } } was generating var(--space-0.5) (invalid CSS):
|
|
85
|
+
export const createCSSVariable = (nameProp: string, includeVar = true) => {
|
|
86
|
+
if (process.env.NODE_ENV === 'development') {
|
|
87
|
+
if (!nameProp || typeof nameProp !== 'string') {
|
|
88
|
+
throw new Error(`createCSSVariable expected string: ${nameProp}`)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const name = simpleHash(nameProp, 60)
|
|
92
|
+
return includeVar ? `var(--${name})` : name
|
|
93
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { simpleHash } from '@tamagui/helpers'
|
|
2
|
+
|
|
3
|
+
import { Variable, createVariable, isVariable } from './createVariable'
|
|
4
|
+
|
|
5
|
+
type DeepTokenObject<Val extends string | number = any> = {
|
|
6
|
+
[key: string]: Val | DeepTokenObject<Val>
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type DeepVariableObject<A extends DeepTokenObject> = {
|
|
10
|
+
[Key in keyof A]: A[Key] extends string | number
|
|
11
|
+
? Variable<A[Key]>
|
|
12
|
+
: A[Key] extends DeepTokenObject
|
|
13
|
+
? DeepVariableObject<A[Key]>
|
|
14
|
+
: never
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const tokensKeysOrdered = new WeakMap()
|
|
18
|
+
|
|
19
|
+
export const createVariables = <A extends DeepTokenObject>(
|
|
20
|
+
tokens: A,
|
|
21
|
+
parentPath = '',
|
|
22
|
+
isFont = false
|
|
23
|
+
): DeepVariableObject<A> => {
|
|
24
|
+
const res: any = {}
|
|
25
|
+
let i = 0
|
|
26
|
+
for (let key in tokens) {
|
|
27
|
+
i++
|
|
28
|
+
const val = tokens[key]
|
|
29
|
+
// always remove $ prefix
|
|
30
|
+
if (key[0] === '$') {
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
key = key.slice(1)
|
|
33
|
+
}
|
|
34
|
+
if (isVariable(val)) {
|
|
35
|
+
res[key] = val
|
|
36
|
+
continue
|
|
37
|
+
}
|
|
38
|
+
const niceKey = simpleHash(key)
|
|
39
|
+
let name = isFont ? niceKey.slice(0, 2) : i
|
|
40
|
+
name = parentPath ? `${parentPath}-${name}` : niceKey
|
|
41
|
+
if (val && typeof val === 'object') {
|
|
42
|
+
// recurse
|
|
43
|
+
res[key] = createVariables(tokens[key] as any, name)
|
|
44
|
+
continue
|
|
45
|
+
}
|
|
46
|
+
res[key] = isVariable(val) ? val : createVariable({ val, name, key: niceKey })
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// ordering for relative sizing for now just size/space
|
|
50
|
+
if (parentPath === 'size' || parentPath === 'space') {
|
|
51
|
+
tokensKeysOrdered.set(res, Object.keys(tokens))
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return res
|
|
55
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Image, Text, TextInput, View } from 'react-native'
|
|
2
|
+
|
|
3
|
+
// limited support
|
|
4
|
+
export const RNComponents = new Set<any>([
|
|
5
|
+
Image,
|
|
6
|
+
TextInput,
|
|
7
|
+
Text,
|
|
8
|
+
View,
|
|
9
|
+
// see fake-react-native + styled() check
|
|
10
|
+
'Image',
|
|
11
|
+
'TextInput',
|
|
12
|
+
'Text',
|
|
13
|
+
'View',
|
|
14
|
+
])
|