@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,1133 @@
|
|
|
1
|
+
import { useComposedRefs } from '@tamagui/compose-refs'
|
|
2
|
+
import { isClient, isRSC, isServer, isWeb } from '@tamagui/constants'
|
|
3
|
+
import {
|
|
4
|
+
composeEventHandlers,
|
|
5
|
+
stylePropsView,
|
|
6
|
+
validPseudoKeys,
|
|
7
|
+
validStyles,
|
|
8
|
+
} from '@tamagui/helpers'
|
|
9
|
+
import React, {
|
|
10
|
+
Children,
|
|
11
|
+
Fragment,
|
|
12
|
+
createElement,
|
|
13
|
+
forwardRef,
|
|
14
|
+
memo,
|
|
15
|
+
useCallback,
|
|
16
|
+
useContext,
|
|
17
|
+
useEffect,
|
|
18
|
+
useRef,
|
|
19
|
+
} from 'react'
|
|
20
|
+
|
|
21
|
+
import { onConfiguredOnce } from './config'
|
|
22
|
+
import { stackDefaultStyles } from './constants/constants'
|
|
23
|
+
import { FontLanguageContext } from './contexts/FontLanguageContext'
|
|
24
|
+
import { TextAncestorContext } from './contexts/TextAncestorContext'
|
|
25
|
+
import { didGetVariableValue, setDidGetVariableValue } from './createVariable'
|
|
26
|
+
import { extendStaticConfig, parseStaticConfig } from './helpers/extendStaticConfig'
|
|
27
|
+
import { useSplitStyles } from './helpers/getSplitStyles'
|
|
28
|
+
import { getAllSelectors } from './helpers/insertStyleRule'
|
|
29
|
+
import { mergeProps } from './helpers/mergeProps'
|
|
30
|
+
import { proxyThemeVariables } from './helpers/proxyThemeVariables'
|
|
31
|
+
import { useShallowSetState } from './helpers/useShallowSetState'
|
|
32
|
+
import { setMediaShouldUpdate, useMedia } from './hooks/useMedia'
|
|
33
|
+
import { useServerRef, useServerState } from './hooks/useServerHooks'
|
|
34
|
+
import { useThemeWithState } from './hooks/useTheme'
|
|
35
|
+
import { hooks } from './setupHooks'
|
|
36
|
+
import {
|
|
37
|
+
DebugProp,
|
|
38
|
+
SpaceDirection,
|
|
39
|
+
SpaceTokens,
|
|
40
|
+
SpacerProps,
|
|
41
|
+
StaticConfig,
|
|
42
|
+
StaticConfigParsed,
|
|
43
|
+
StylableComponent,
|
|
44
|
+
TamaguiComponent,
|
|
45
|
+
TamaguiComponentEvents,
|
|
46
|
+
TamaguiComponentState,
|
|
47
|
+
TamaguiConfig,
|
|
48
|
+
TamaguiElement,
|
|
49
|
+
TamaguiInternalConfig,
|
|
50
|
+
UseAnimationHook,
|
|
51
|
+
UseAnimationProps,
|
|
52
|
+
} from './types'
|
|
53
|
+
import { Slot, mergeEvent } from './views/Slot'
|
|
54
|
+
import { useThemedChildren } from './views/Theme'
|
|
55
|
+
|
|
56
|
+
// let t
|
|
57
|
+
// import { timer } from '@tamagui/timer'
|
|
58
|
+
// if (true || process.env.ANALYZE) {
|
|
59
|
+
// t = require().timer()
|
|
60
|
+
// setTimeout(() => {
|
|
61
|
+
// const out = t.print()
|
|
62
|
+
// if (isClient) {
|
|
63
|
+
// alert(out)
|
|
64
|
+
// }
|
|
65
|
+
// }, 2000)
|
|
66
|
+
// }
|
|
67
|
+
|
|
68
|
+
// this appears to fix expo / babel not picking this up sometimes? really odd
|
|
69
|
+
process.env.TAMAGUI_TARGET
|
|
70
|
+
|
|
71
|
+
export const defaultComponentState: TamaguiComponentState = {
|
|
72
|
+
hover: false,
|
|
73
|
+
press: false,
|
|
74
|
+
pressIn: false,
|
|
75
|
+
focus: false,
|
|
76
|
+
unmounted: true,
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const defaultComponentStateMounted: TamaguiComponentState = {
|
|
80
|
+
...defaultComponentState,
|
|
81
|
+
unmounted: false,
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* All things that need one-time setup after createTamagui is called
|
|
86
|
+
*/
|
|
87
|
+
let tamaguiConfig: TamaguiInternalConfig
|
|
88
|
+
let AnimatedText: any
|
|
89
|
+
let AnimatedView: any
|
|
90
|
+
let initialTheme: any
|
|
91
|
+
|
|
92
|
+
export const mouseUps = new Set<Function>()
|
|
93
|
+
if (typeof document !== 'undefined') {
|
|
94
|
+
const cancelTouches = () => {
|
|
95
|
+
mouseUps.forEach((x) => x())
|
|
96
|
+
mouseUps.clear()
|
|
97
|
+
}
|
|
98
|
+
addEventListener('mouseup', cancelTouches)
|
|
99
|
+
addEventListener('touchend', cancelTouches)
|
|
100
|
+
addEventListener('touchcancel', cancelTouches)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// mutates
|
|
104
|
+
function mergeShorthands(
|
|
105
|
+
{ defaultProps }: StaticConfigParsed,
|
|
106
|
+
{ shorthands }: TamaguiConfig
|
|
107
|
+
) {
|
|
108
|
+
// they are defined in correct order already { ...parent, ...child }
|
|
109
|
+
for (const key of Object.keys(defaultProps)) {
|
|
110
|
+
defaultProps[shorthands[key] || key] = defaultProps[key]
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Only on native do we need the actual underlying View/Text
|
|
116
|
+
* On the web we avoid react-native dep altogether.
|
|
117
|
+
*/
|
|
118
|
+
let BaseText: any
|
|
119
|
+
let BaseView: any
|
|
120
|
+
let hasSetupBaseViews = false
|
|
121
|
+
|
|
122
|
+
export function createComponent<
|
|
123
|
+
ComponentPropTypes extends Object = {},
|
|
124
|
+
Ref = TamaguiElement,
|
|
125
|
+
BaseProps = never
|
|
126
|
+
>(
|
|
127
|
+
configIn: Partial<StaticConfig> | StaticConfigParsed,
|
|
128
|
+
ParentComponent?: StylableComponent
|
|
129
|
+
) {
|
|
130
|
+
const staticConfig = (() => {
|
|
131
|
+
const next = extendStaticConfig(configIn, ParentComponent)
|
|
132
|
+
if ('parsed' in next) {
|
|
133
|
+
return next
|
|
134
|
+
} else {
|
|
135
|
+
return parseStaticConfig(next)
|
|
136
|
+
}
|
|
137
|
+
})()
|
|
138
|
+
|
|
139
|
+
const defaultComponentClassName = `is_${staticConfig.componentName}`
|
|
140
|
+
let tamaguiDefaultProps: any
|
|
141
|
+
let defaultTag: string | undefined
|
|
142
|
+
|
|
143
|
+
// see onConfiguredOnce below which attaches a name then to this component
|
|
144
|
+
const component = forwardRef<Ref, ComponentPropTypes>((propsIn: any, forwardedRef) => {
|
|
145
|
+
if (process.env.TAMAGUI_TARGET === 'native') {
|
|
146
|
+
// todo this could be moved to a cleaner location
|
|
147
|
+
if (!hasSetupBaseViews) {
|
|
148
|
+
hasSetupBaseViews = true
|
|
149
|
+
const baseViews = hooks.getBaseViews?.()
|
|
150
|
+
if (baseViews) {
|
|
151
|
+
BaseText = baseViews.Text
|
|
152
|
+
BaseView = baseViews.View
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// test only
|
|
158
|
+
if (process.env.NODE_ENV === 'test') {
|
|
159
|
+
if (propsIn['data-test-renders']) {
|
|
160
|
+
propsIn['data-test-renders']['current'] ??= 0
|
|
161
|
+
propsIn['data-test-renders']['current'] += 1
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
// const time = t.start({ quiet: true })
|
|
165
|
+
|
|
166
|
+
// React inserts default props after your props for some reason...
|
|
167
|
+
// order important so we do loops, you can't just spread because JS does weird things
|
|
168
|
+
let props: any
|
|
169
|
+
if (tamaguiDefaultProps && !propsIn.asChild) {
|
|
170
|
+
props = mergeProps(tamaguiDefaultProps, propsIn)[0]
|
|
171
|
+
} else {
|
|
172
|
+
props = propsIn
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const debugProp = props['debug'] as DebugProp
|
|
176
|
+
const { Component, isText, isZStack } = staticConfig
|
|
177
|
+
const componentName = props.componentName || staticConfig.componentName
|
|
178
|
+
const componentClassName = props.asChild
|
|
179
|
+
? ''
|
|
180
|
+
: props.componentName
|
|
181
|
+
? `is_${props.componentName}`
|
|
182
|
+
: defaultComponentClassName
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Component state for tracking animations, pseudos
|
|
186
|
+
*/
|
|
187
|
+
const animationsConfig = tamaguiConfig.animations
|
|
188
|
+
const useAnimations = animationsConfig?.useAnimations as UseAnimationHook | undefined
|
|
189
|
+
const avoidClassesWhileAnimating = animationsConfig.isReactNative
|
|
190
|
+
const hasEnterStyle = !!props.enterStyle
|
|
191
|
+
const needsMount = Boolean(
|
|
192
|
+
(isWeb ? isClient : true) && (hasEnterStyle || props.animation)
|
|
193
|
+
)
|
|
194
|
+
const states = useServerState<TamaguiComponentState>(
|
|
195
|
+
needsMount ? defaultComponentState! : defaultComponentStateMounted!
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
const state = propsIn.forceStyle
|
|
199
|
+
? { ...states[0], [propsIn.forceStyle]: true }
|
|
200
|
+
: states[0]
|
|
201
|
+
const setState = states[1]
|
|
202
|
+
const setStateShallow = useShallowSetState(setState, debugProp, componentName)
|
|
203
|
+
|
|
204
|
+
// conditional but if ever true stays true
|
|
205
|
+
// [animated, inversed]
|
|
206
|
+
const stateRef = useRef(
|
|
207
|
+
undefined as any as {
|
|
208
|
+
hasAnimated?: boolean
|
|
209
|
+
themeShallow?: boolean
|
|
210
|
+
didAccessThemeVariableValue?: boolean
|
|
211
|
+
}
|
|
212
|
+
)
|
|
213
|
+
stateRef.current ??= {}
|
|
214
|
+
|
|
215
|
+
const isAnimated = (() => {
|
|
216
|
+
const next = !!(useAnimations && props.animation)
|
|
217
|
+
if (next && !stateRef.current.hasAnimated) {
|
|
218
|
+
stateRef.current.hasAnimated = true
|
|
219
|
+
}
|
|
220
|
+
return next || stateRef.current.hasAnimated
|
|
221
|
+
})()
|
|
222
|
+
|
|
223
|
+
const usePresence = tamaguiConfig.animations?.usePresence
|
|
224
|
+
const presence = !isRSC && isAnimated ? usePresence() : null
|
|
225
|
+
|
|
226
|
+
// set enter/exit variants onto our new props object
|
|
227
|
+
if (isAnimated && presence) {
|
|
228
|
+
const presenceState = presence[2]
|
|
229
|
+
if (presenceState) {
|
|
230
|
+
if (state.unmounted && presenceState.enterVariant) {
|
|
231
|
+
props[presenceState.enterVariant] = true
|
|
232
|
+
}
|
|
233
|
+
if (!presenceState.isPresent && presenceState.exitVariant) {
|
|
234
|
+
props[presenceState.exitVariant] = true
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const isReactNative = Boolean(
|
|
240
|
+
staticConfig.isReactNative || (isAnimated && tamaguiConfig.animations.isReactNative)
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
if (process.env.NODE_ENV === 'development') {
|
|
244
|
+
if (debugProp) {
|
|
245
|
+
// prettier-ignore
|
|
246
|
+
const name = `${componentName || Component?.displayName || Component?.name || '[Unnamed Component]'}`
|
|
247
|
+
const type = isReactNative ? '(rnw)' : ''
|
|
248
|
+
const dataIs = propsIn['data-is'] || ''
|
|
249
|
+
const banner = `${name}${dataIs ? ` ${dataIs}` : ''} ${type}`
|
|
250
|
+
console.group(`%c ${banner}`, 'background: yellow;')
|
|
251
|
+
if (!isServer) {
|
|
252
|
+
console.log('state', state)
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
const shouldAvoidClasses =
|
|
258
|
+
!isWeb ||
|
|
259
|
+
!!(props.animation && avoidClassesWhileAnimating) ||
|
|
260
|
+
!staticConfig.acceptsClassName
|
|
261
|
+
const shouldForcePseudo = !!propsIn.forceStyle
|
|
262
|
+
const noClassNames = shouldAvoidClasses || shouldForcePseudo
|
|
263
|
+
|
|
264
|
+
const themeState = useThemeWithState({
|
|
265
|
+
name: props.theme,
|
|
266
|
+
componentName,
|
|
267
|
+
reset: props.reset,
|
|
268
|
+
inverse: props.themeInverse,
|
|
269
|
+
// @ts-expect-error
|
|
270
|
+
disable: props['data-themeable'],
|
|
271
|
+
debug: props.debug,
|
|
272
|
+
shouldUpdate: () => !!stateRef.current.didAccessThemeVariableValue,
|
|
273
|
+
})!
|
|
274
|
+
|
|
275
|
+
const hasTextAncestor = !!(isWeb && isText ? useContext(TextAncestorContext) : false)
|
|
276
|
+
const languageContext = isRSC ? null : useContext(FontLanguageContext)
|
|
277
|
+
const isDisabled = props.disabled ?? props.accessibilityState?.disabled
|
|
278
|
+
|
|
279
|
+
const isTaggable = !Component || typeof Component === 'string'
|
|
280
|
+
// default to tag, fallback to component (when both strings)
|
|
281
|
+
const element = isWeb
|
|
282
|
+
? isTaggable
|
|
283
|
+
? props.tag || defaultTag || Component
|
|
284
|
+
: Component
|
|
285
|
+
: Component
|
|
286
|
+
|
|
287
|
+
const BaseTextComponent = BaseText || element || 'span'
|
|
288
|
+
const BaseViewComponent = BaseView || element || (hasTextAncestor ? 'span' : 'div')
|
|
289
|
+
let elementType = isText
|
|
290
|
+
? (isAnimated ? AnimatedText : null) || BaseTextComponent
|
|
291
|
+
: (isAnimated ? AnimatedView : null) || BaseViewComponent
|
|
292
|
+
|
|
293
|
+
elementType = Component || elementType
|
|
294
|
+
const isStringElement = typeof elementType === 'string'
|
|
295
|
+
|
|
296
|
+
const isExiting = presence?.[0] === false
|
|
297
|
+
|
|
298
|
+
const mediaState = useMedia(
|
|
299
|
+
// @ts-ignore, we just pass a stable object so we can get it later with
|
|
300
|
+
// should match to the one used in `setMediaShouldUpdate` below
|
|
301
|
+
stateRef,
|
|
302
|
+
debugProp ? { props, staticConfig } : null
|
|
303
|
+
)
|
|
304
|
+
|
|
305
|
+
setDidGetVariableValue(false)
|
|
306
|
+
|
|
307
|
+
const splitStyles = useSplitStyles(
|
|
308
|
+
props,
|
|
309
|
+
staticConfig,
|
|
310
|
+
themeState.theme,
|
|
311
|
+
{
|
|
312
|
+
...state,
|
|
313
|
+
mediaState,
|
|
314
|
+
noClassNames,
|
|
315
|
+
dynamicStylesInline: noClassNames,
|
|
316
|
+
hasTextAncestor,
|
|
317
|
+
resolveVariablesAs: 'auto',
|
|
318
|
+
isExiting,
|
|
319
|
+
},
|
|
320
|
+
null,
|
|
321
|
+
languageContext || undefined,
|
|
322
|
+
elementType,
|
|
323
|
+
debugProp
|
|
324
|
+
)
|
|
325
|
+
|
|
326
|
+
// only listen for changes if we are using raw theme values or media space, or dynamic media (native)
|
|
327
|
+
// array = space media breakpoints
|
|
328
|
+
const isMediaSpaced = Array.isArray(splitStyles.hasMedia)
|
|
329
|
+
const shouldListenForMedia =
|
|
330
|
+
didGetVariableValue() ||
|
|
331
|
+
isMediaSpaced ||
|
|
332
|
+
(noClassNames && splitStyles.hasMedia === true)
|
|
333
|
+
|
|
334
|
+
setMediaShouldUpdate(stateRef, {
|
|
335
|
+
enabled: shouldListenForMedia,
|
|
336
|
+
keys: noClassNames && isMediaSpaced ? (splitStyles.hasMedia as any) : null,
|
|
337
|
+
})
|
|
338
|
+
|
|
339
|
+
const hostRef = useServerRef<TamaguiElement>(null)
|
|
340
|
+
|
|
341
|
+
// animation setup
|
|
342
|
+
const isAnimatedReactNativeWeb = isAnimated && avoidClassesWhileAnimating
|
|
343
|
+
|
|
344
|
+
if (process.env.NODE_ENV === 'development') {
|
|
345
|
+
if (!process.env.TAMAGUI_TARGET) {
|
|
346
|
+
console.error(
|
|
347
|
+
`No process.env.TAMAGUI_TARGET set, please set it to "native" or "web".`
|
|
348
|
+
)
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (debugProp) {
|
|
352
|
+
console.groupCollapsed('props')
|
|
353
|
+
// prettier-ignore
|
|
354
|
+
console.log('props in', propsIn, 'mapped to', props, 'in order', Object.keys(props))
|
|
355
|
+
console.log('splitStyles', splitStyles)
|
|
356
|
+
// eslint-disable-next-line no-console
|
|
357
|
+
console.log('shouldListenForMedia', shouldListenForMedia)
|
|
358
|
+
// eslint-disable-next-line no-console
|
|
359
|
+
console.log('className', Object.values(splitStyles.classNames))
|
|
360
|
+
if (isClient) {
|
|
361
|
+
console.log('ref', hostRef, '(click to view)')
|
|
362
|
+
}
|
|
363
|
+
console.groupEnd()
|
|
364
|
+
if (debugProp === 'break') {
|
|
365
|
+
// rome-ignore lint/suspicious/noDebugger: ok
|
|
366
|
+
debugger
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
const {
|
|
372
|
+
viewProps: viewPropsIn,
|
|
373
|
+
pseudos,
|
|
374
|
+
style: splitStylesStyle,
|
|
375
|
+
classNames,
|
|
376
|
+
space,
|
|
377
|
+
} = splitStyles
|
|
378
|
+
|
|
379
|
+
const propsWithAnimation = props as UseAnimationProps
|
|
380
|
+
|
|
381
|
+
// once you set animation prop don't remove it, you can set to undefined/false
|
|
382
|
+
// reason is animations are heavy - no way around it, and must be run inline here (🙅 loading as a sub-component)
|
|
383
|
+
let animationStyles: any
|
|
384
|
+
if (!isRSC && isAnimated && useAnimations) {
|
|
385
|
+
const animations = useAnimations({
|
|
386
|
+
props: propsWithAnimation,
|
|
387
|
+
style: splitStylesStyle,
|
|
388
|
+
presence,
|
|
389
|
+
state,
|
|
390
|
+
pseudos: pseudos || null,
|
|
391
|
+
onDidAnimate: props.onDidAnimate,
|
|
392
|
+
hostRef,
|
|
393
|
+
staticConfig,
|
|
394
|
+
})
|
|
395
|
+
if (animations) {
|
|
396
|
+
animationStyles = animations.style
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
const {
|
|
401
|
+
hitSlop,
|
|
402
|
+
asChild,
|
|
403
|
+
children,
|
|
404
|
+
onPress,
|
|
405
|
+
onPressIn,
|
|
406
|
+
onPressOut,
|
|
407
|
+
onHoverIn,
|
|
408
|
+
onHoverOut,
|
|
409
|
+
themeShallow,
|
|
410
|
+
spaceDirection: _spaceDirection,
|
|
411
|
+
disabled: disabledProp,
|
|
412
|
+
onMouseUp,
|
|
413
|
+
onMouseDown,
|
|
414
|
+
onMouseEnter,
|
|
415
|
+
onMouseLeave,
|
|
416
|
+
separator,
|
|
417
|
+
// ignore from here on out
|
|
418
|
+
forceStyle: _forceStyle,
|
|
419
|
+
// @ts-ignore for next/link compat etc
|
|
420
|
+
onClick,
|
|
421
|
+
theme: _themeProp,
|
|
422
|
+
// @ts-ignore
|
|
423
|
+
defaultVariants,
|
|
424
|
+
|
|
425
|
+
...nonTamaguiProps
|
|
426
|
+
} = viewPropsIn
|
|
427
|
+
|
|
428
|
+
const disabled = props.accessibilityState?.disabled || props.accessibilityDisabled
|
|
429
|
+
|
|
430
|
+
// these can ultimately be for DOM, react-native-web views, or animated views
|
|
431
|
+
// so the type is pretty loose
|
|
432
|
+
let viewProps: Record<string, any>
|
|
433
|
+
|
|
434
|
+
// if react-native-web view just pass all props down
|
|
435
|
+
if (process.env.TAMAGUI_TARGET === 'web' && !isReactNative && !asChild) {
|
|
436
|
+
viewProps = hooks.usePropsTransform?.(elementType, viewPropsIn, hostRef)
|
|
437
|
+
} else {
|
|
438
|
+
viewProps = nonTamaguiProps
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
viewProps.ref = useComposedRefs(hostRef as any, forwardedRef)
|
|
442
|
+
|
|
443
|
+
if (process.env.NODE_ENV === 'development') {
|
|
444
|
+
if (!isText && isWeb && !staticConfig.isHOC) {
|
|
445
|
+
Children.toArray(props.children).forEach((item) => {
|
|
446
|
+
// allow newlines because why not its annoying with mdx
|
|
447
|
+
if (typeof item === 'string' && item !== '\n') {
|
|
448
|
+
console.error(
|
|
449
|
+
`Unexpected text node: ${item}. A text node cannot be a child of a <View>.`
|
|
450
|
+
)
|
|
451
|
+
}
|
|
452
|
+
})
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
const unPress = useCallback(() => {
|
|
457
|
+
setStateShallow({
|
|
458
|
+
press: false,
|
|
459
|
+
pressIn: false,
|
|
460
|
+
})
|
|
461
|
+
}, [setStateShallow])
|
|
462
|
+
|
|
463
|
+
if (isWeb) {
|
|
464
|
+
useEffect(() => {
|
|
465
|
+
return () => {
|
|
466
|
+
mouseUps.delete(unPress)
|
|
467
|
+
}
|
|
468
|
+
}, [])
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
const shouldSetMounted = needsMount && state.unmounted
|
|
472
|
+
useEffect(() => {
|
|
473
|
+
if (!shouldSetMounted) return
|
|
474
|
+
if (state.unmounted === true && needsMount) {
|
|
475
|
+
setStateShallow({
|
|
476
|
+
unmounted: false,
|
|
477
|
+
})
|
|
478
|
+
return
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
setStateShallow({
|
|
482
|
+
unmounted: false,
|
|
483
|
+
})
|
|
484
|
+
}, [shouldSetMounted, state.unmounted])
|
|
485
|
+
|
|
486
|
+
let styles: Record<string, any>[]
|
|
487
|
+
|
|
488
|
+
if (isStringElement && shouldAvoidClasses && !shouldForcePseudo) {
|
|
489
|
+
styles = {
|
|
490
|
+
...(animationStyles ?? splitStylesStyle),
|
|
491
|
+
}
|
|
492
|
+
} else {
|
|
493
|
+
styles = [animationStyles ?? splitStylesStyle]
|
|
494
|
+
|
|
495
|
+
// ugly but for now...
|
|
496
|
+
if (shouldForcePseudo) {
|
|
497
|
+
const next = {}
|
|
498
|
+
styles.forEach((style) => Object.assign(next, style))
|
|
499
|
+
// @ts-ignore
|
|
500
|
+
Object.assign(splitStyles.style, next)
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
let fontFamily = isText
|
|
505
|
+
? splitStyles.fontFamily || staticConfig.defaultProps.fontFamily
|
|
506
|
+
: null
|
|
507
|
+
if (fontFamily && fontFamily[0] === '$') {
|
|
508
|
+
fontFamily = fontFamily.slice(1)
|
|
509
|
+
}
|
|
510
|
+
const fontFamilyClassName = fontFamily ? `font_${fontFamily}` : ''
|
|
511
|
+
|
|
512
|
+
const classList = [
|
|
513
|
+
hasEnterStyle && ((state.unmounted && needsMount) || !isClient)
|
|
514
|
+
? 't_will-mount'
|
|
515
|
+
: '',
|
|
516
|
+
componentName ? componentClassName : '',
|
|
517
|
+
fontFamilyClassName,
|
|
518
|
+
classNames ? Object.values(classNames).join(' ') : '',
|
|
519
|
+
]
|
|
520
|
+
|
|
521
|
+
const className = classList.join(' ')
|
|
522
|
+
|
|
523
|
+
if (process.env.TAMAGUI_TARGET === 'web') {
|
|
524
|
+
const style = animationStyles ?? splitStyles.style
|
|
525
|
+
|
|
526
|
+
if (isAnimatedReactNativeWeb) {
|
|
527
|
+
viewProps.style = style
|
|
528
|
+
} else if (isReactNative) {
|
|
529
|
+
const rnwStyle = { $$css: true }
|
|
530
|
+
for (const name of className.split(' ')) {
|
|
531
|
+
rnwStyle[name] = name
|
|
532
|
+
}
|
|
533
|
+
viewProps.style = [rnwStyle, ...(Array.isArray(style) ? style : [style])]
|
|
534
|
+
|
|
535
|
+
if (process.env.NODE_ENV === 'development') {
|
|
536
|
+
// turn debug data- props into dataSet in dev mode
|
|
537
|
+
Object.keys(viewProps).forEach((key) => {
|
|
538
|
+
if (key.startsWith('data-')) {
|
|
539
|
+
viewProps.dataSet ??= {}
|
|
540
|
+
viewProps.dataSet[key.replace('data-', '')] = viewProps[key]
|
|
541
|
+
delete viewProps[key]
|
|
542
|
+
}
|
|
543
|
+
})
|
|
544
|
+
}
|
|
545
|
+
} else {
|
|
546
|
+
viewProps.className = className
|
|
547
|
+
viewProps.style = style
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
// TODO MOVE INTO HOOK
|
|
552
|
+
if (process.env.TAMAGUI_TARGET === 'native') {
|
|
553
|
+
// swap out the right family based on weight/style
|
|
554
|
+
if (splitStyles.fontFamily) {
|
|
555
|
+
const faceInfo = tamaguiConfig.fontsParsed[splitStyles.fontFamily]?.face
|
|
556
|
+
if (faceInfo) {
|
|
557
|
+
const [weight, style] = (() => {
|
|
558
|
+
let weight: string | undefined
|
|
559
|
+
let style: string | undefined
|
|
560
|
+
for (let i = styles.length; i >= 0; i--) {
|
|
561
|
+
weight ??= styles[i]?.fontWeight
|
|
562
|
+
style ??= styles[i]?.fontStyle
|
|
563
|
+
}
|
|
564
|
+
return [weight || '400', style || 'normal'] as const
|
|
565
|
+
})()
|
|
566
|
+
const overrideFace = faceInfo[weight]?.[style]?.val
|
|
567
|
+
if (overrideFace) {
|
|
568
|
+
for (const style of styles) {
|
|
569
|
+
if (style?.fontFamily) {
|
|
570
|
+
style.fontFamily = overrideFace
|
|
571
|
+
style.fontWeight = undefined
|
|
572
|
+
style.fontStyle = undefined
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// assign styles
|
|
580
|
+
viewProps.style = styles
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
const runtimePressStyle = !disabled && noClassNames && pseudos?.pressStyle
|
|
584
|
+
const attachPress = Boolean(
|
|
585
|
+
runtimePressStyle || onPress || onPressOut || onPressIn || onClick
|
|
586
|
+
)
|
|
587
|
+
const runtimeHoverStyle = !disabled && noClassNames && pseudos?.hoverStyle
|
|
588
|
+
const isHoverable =
|
|
589
|
+
isWeb &&
|
|
590
|
+
!!(runtimeHoverStyle || onHoverIn || onHoverOut || onMouseEnter || onMouseLeave)
|
|
591
|
+
|
|
592
|
+
const handlesPressEvents = !(isWeb || asChild)
|
|
593
|
+
|
|
594
|
+
// check presence rather than value to prevent reparenting bugs
|
|
595
|
+
// allows for onPress={x ? function : undefined} without re-ordering dom
|
|
596
|
+
const shouldAttach = Boolean(
|
|
597
|
+
attachPress ||
|
|
598
|
+
isHoverable ||
|
|
599
|
+
(noClassNames && 'pressStyle' in props) ||
|
|
600
|
+
(isWeb && noClassNames && 'hoverStyle' in props)
|
|
601
|
+
)
|
|
602
|
+
|
|
603
|
+
const events: TamaguiComponentEvents | null =
|
|
604
|
+
shouldAttach && !isRSC && !isDisabled && !asChild
|
|
605
|
+
? {
|
|
606
|
+
onPressOut: attachPress
|
|
607
|
+
? (e) => {
|
|
608
|
+
unPress()
|
|
609
|
+
onPressOut?.(e)
|
|
610
|
+
onMouseUp?.(e)
|
|
611
|
+
}
|
|
612
|
+
: undefined,
|
|
613
|
+
...(isHoverable && {
|
|
614
|
+
onMouseEnter: isHoverable
|
|
615
|
+
? (e) => {
|
|
616
|
+
const next: Partial<typeof state> = {}
|
|
617
|
+
if (isHoverable) {
|
|
618
|
+
next.hover = true
|
|
619
|
+
}
|
|
620
|
+
if (state.pressIn) {
|
|
621
|
+
next.press = true
|
|
622
|
+
}
|
|
623
|
+
if (isHoverable || state.pressIn) {
|
|
624
|
+
setStateShallow(next)
|
|
625
|
+
}
|
|
626
|
+
onHoverIn?.(e)
|
|
627
|
+
onMouseEnter?.(e)
|
|
628
|
+
}
|
|
629
|
+
: undefined,
|
|
630
|
+
onMouseLeave: isHoverable
|
|
631
|
+
? (e) => {
|
|
632
|
+
const next: Partial<typeof state> = {}
|
|
633
|
+
mouseUps.add(unPress)
|
|
634
|
+
if (isHoverable) {
|
|
635
|
+
next.hover = false
|
|
636
|
+
}
|
|
637
|
+
if (state.pressIn) {
|
|
638
|
+
next.press = false
|
|
639
|
+
next.pressIn = false
|
|
640
|
+
}
|
|
641
|
+
if (Object.keys(next).length) {
|
|
642
|
+
setStateShallow(next)
|
|
643
|
+
}
|
|
644
|
+
onHoverOut?.(e)
|
|
645
|
+
onMouseLeave?.(e)
|
|
646
|
+
}
|
|
647
|
+
: undefined,
|
|
648
|
+
}),
|
|
649
|
+
onPressIn: attachPress
|
|
650
|
+
? (e) => {
|
|
651
|
+
setStateShallow({
|
|
652
|
+
press: true,
|
|
653
|
+
pressIn: true,
|
|
654
|
+
hover: false,
|
|
655
|
+
})
|
|
656
|
+
onPressIn?.(e)
|
|
657
|
+
onMouseDown?.(e)
|
|
658
|
+
if (isWeb) {
|
|
659
|
+
mouseUps.add(unPress)
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
: undefined,
|
|
663
|
+
onPress: attachPress
|
|
664
|
+
? (e) => {
|
|
665
|
+
unPress()
|
|
666
|
+
// @ts-ignore
|
|
667
|
+
onClick?.(e)
|
|
668
|
+
onPress?.(e)
|
|
669
|
+
}
|
|
670
|
+
: undefined,
|
|
671
|
+
|
|
672
|
+
// replicating TouchableWithoutFeedback
|
|
673
|
+
...(!isWeb && {
|
|
674
|
+
cancelable: !props.rejectResponderTermination,
|
|
675
|
+
disabled: isDisabled,
|
|
676
|
+
hitSlop: props.hitSlop,
|
|
677
|
+
delayLongPress: props.delayLongPress,
|
|
678
|
+
delayPressIn: props.delayPressIn,
|
|
679
|
+
delayPressOut: props.delayPressOut,
|
|
680
|
+
focusable: viewProps.focusable ?? true,
|
|
681
|
+
minPressDuration: 0,
|
|
682
|
+
}),
|
|
683
|
+
}
|
|
684
|
+
: null
|
|
685
|
+
|
|
686
|
+
// EVENTS native
|
|
687
|
+
hooks.useEvents?.(viewProps, events, splitStyles, setStateShallow)
|
|
688
|
+
|
|
689
|
+
const shouldReset = !!(themeShallow && themeState.isNewTheme)
|
|
690
|
+
if (shouldReset) {
|
|
691
|
+
stateRef.current.themeShallow = true
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
let content =
|
|
695
|
+
!children || asChild
|
|
696
|
+
? children
|
|
697
|
+
: spacedChildren({
|
|
698
|
+
separator,
|
|
699
|
+
children,
|
|
700
|
+
space,
|
|
701
|
+
direction: props.spaceDirection || 'both',
|
|
702
|
+
isZStack,
|
|
703
|
+
debug: debugProp,
|
|
704
|
+
})
|
|
705
|
+
|
|
706
|
+
if (asChild) {
|
|
707
|
+
elementType = Slot
|
|
708
|
+
viewProps = {
|
|
709
|
+
...viewProps,
|
|
710
|
+
onPress,
|
|
711
|
+
onPressIn,
|
|
712
|
+
onPressOut,
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
content = createElement(elementType, viewProps, content)
|
|
717
|
+
|
|
718
|
+
content = useThemedChildren(themeState, content, {
|
|
719
|
+
shallow: stateRef.current.themeShallow,
|
|
720
|
+
})
|
|
721
|
+
|
|
722
|
+
if (process.env.TAMAGUI_TARGET === 'web') {
|
|
723
|
+
if (events || isAnimatedReactNativeWeb) {
|
|
724
|
+
content = (
|
|
725
|
+
<span
|
|
726
|
+
className={`${isAnimatedReactNativeWeb ? className : ''} _dsp_contents`}
|
|
727
|
+
{...(events && {
|
|
728
|
+
onMouseEnter: events.onMouseEnter,
|
|
729
|
+
onMouseLeave: events.onMouseLeave,
|
|
730
|
+
onClick: events.onPress,
|
|
731
|
+
onMouseDown: events.onPressIn,
|
|
732
|
+
onMouseUp: events.onPressOut,
|
|
733
|
+
onTouchStart: events.onPressIn,
|
|
734
|
+
onTouchEnd: events.onPressOut,
|
|
735
|
+
})}
|
|
736
|
+
>
|
|
737
|
+
{content}
|
|
738
|
+
</span>
|
|
739
|
+
)
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
if (process.env.NODE_ENV === 'development' && process.env.DEBUG !== 'tamagui') {
|
|
744
|
+
if (debugProp) {
|
|
745
|
+
const element = typeof elementType === 'string' ? elementType : 'Component'
|
|
746
|
+
console.groupCollapsed(`render <${element} /> with props`, viewProps)
|
|
747
|
+
for (const key in viewProps) {
|
|
748
|
+
console.log(key, viewProps[key])
|
|
749
|
+
}
|
|
750
|
+
console.log('children', content)
|
|
751
|
+
console.groupEnd()
|
|
752
|
+
if (typeof window !== 'undefined') {
|
|
753
|
+
// prettier-ignore
|
|
754
|
+
console.log({ state, themeState, isAnimated, isAnimatedReactNativeWeb, tamaguiDefaultProps, viewProps, splitStyles, animationStyles, handlesPressEvents, isStringElement, classNamesIn: props.className?.split(' '), classNamesOut: viewProps.className?.split(' '), events, shouldAttach, styles, pseudos, content, shouldAvoidClasses, avoidClasses: avoidClassesWhileAnimating, animation: props.animation, style: splitStylesStyle, staticConfig, tamaguiConfig, shouldForcePseudo, classNamesFull: Object.fromEntries(Object.entries(classNames).map(([k, v]) => [v, getAllSelectors()[v]])) })
|
|
755
|
+
}
|
|
756
|
+
console.groupEnd()
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
return content
|
|
761
|
+
})
|
|
762
|
+
|
|
763
|
+
if (staticConfig.componentName) {
|
|
764
|
+
component.displayName = staticConfig.componentName
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
onConfiguredOnce((conf) => {
|
|
768
|
+
// one time only setup
|
|
769
|
+
if (!tamaguiConfig) {
|
|
770
|
+
tamaguiConfig = conf
|
|
771
|
+
|
|
772
|
+
if (tamaguiConfig.animations) {
|
|
773
|
+
AnimatedText = tamaguiConfig.animations.Text
|
|
774
|
+
AnimatedView = tamaguiConfig.animations.View
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
if (!initialTheme) {
|
|
778
|
+
const next = conf.themes[Object.keys(conf.themes)[0]]
|
|
779
|
+
initialTheme = proxyThemeVariables(next)
|
|
780
|
+
if (process.env.NODE_ENV === 'development') {
|
|
781
|
+
if (!initialTheme) {
|
|
782
|
+
console.log('Warning: Missing theme')
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
// per-component setup
|
|
789
|
+
// do this to make sure shorthands don't duplicate with.. longhands
|
|
790
|
+
mergeShorthands(staticConfig, tamaguiConfig)
|
|
791
|
+
|
|
792
|
+
let defaultPropsIn = staticConfig.defaultProps || {}
|
|
793
|
+
|
|
794
|
+
// because we run createTamagui after styled() defs, have to do some work here
|
|
795
|
+
// gather defaults props one time and merge downwards
|
|
796
|
+
// find last unprocessed and process
|
|
797
|
+
const parentNames = [...(staticConfig.parentNames || []), staticConfig.componentName]
|
|
798
|
+
|
|
799
|
+
if (tamaguiConfig.defaultProps && parentNames && staticConfig.componentName) {
|
|
800
|
+
defaultPropsIn = mergeConfigDefaultProps(
|
|
801
|
+
staticConfig.componentName,
|
|
802
|
+
defaultPropsIn,
|
|
803
|
+
tamaguiConfig.defaultProps,
|
|
804
|
+
parentNames,
|
|
805
|
+
tamaguiConfig
|
|
806
|
+
)
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
const debug = defaultPropsIn['debug']
|
|
810
|
+
|
|
811
|
+
// remove all classNames
|
|
812
|
+
const [ourProps, ourClassNames] = mergeProps(defaultPropsIn, {})
|
|
813
|
+
|
|
814
|
+
if (ourProps.tag) {
|
|
815
|
+
defaultTag = ourProps.tag
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
const noClassNames = !staticConfig.acceptsClassName
|
|
819
|
+
const { name, variants, defaultVariants, ...restProps } = ourProps
|
|
820
|
+
|
|
821
|
+
// must preserve prop order
|
|
822
|
+
// leave out className because we handle that already with initialSplitStyles.classNames
|
|
823
|
+
// otherwise it confuses variant functions getting className props
|
|
824
|
+
const [defaults, defaultsClassnames] = mergeProps(component.defaultProps as any, {
|
|
825
|
+
...defaultVariants,
|
|
826
|
+
...restProps,
|
|
827
|
+
})
|
|
828
|
+
|
|
829
|
+
// split - keep variables on props to be processed using theme values at runtime (native)
|
|
830
|
+
if (!isWeb) {
|
|
831
|
+
for (const key in staticConfig.defaultProps) {
|
|
832
|
+
const val = staticConfig.defaultProps[key]
|
|
833
|
+
if (validPseudoKeys[key]) continue
|
|
834
|
+
defaults[key] = val
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
// set to global
|
|
839
|
+
tamaguiDefaultProps = defaults
|
|
840
|
+
|
|
841
|
+
// add debug logs
|
|
842
|
+
if (process.env.NODE_ENV === 'development' && debug) {
|
|
843
|
+
if (process.env.IS_STATIC !== 'is_static') {
|
|
844
|
+
console.log(`🐛 [${staticConfig.componentName || 'Component'}]`, {
|
|
845
|
+
staticConfig,
|
|
846
|
+
tamaguiDefaultProps,
|
|
847
|
+
defaults,
|
|
848
|
+
defaultPropsIn,
|
|
849
|
+
defaultPropsKeyOrder: Object.keys(staticConfig.defaultProps),
|
|
850
|
+
defaultPropsInKeyOrder: Object.keys(defaultPropsIn).map((k) => [
|
|
851
|
+
k,
|
|
852
|
+
defaultPropsIn[k],
|
|
853
|
+
]),
|
|
854
|
+
ourProps,
|
|
855
|
+
ourClassNames,
|
|
856
|
+
defaultsClassnames,
|
|
857
|
+
defaultTag,
|
|
858
|
+
noClassNames,
|
|
859
|
+
})
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
})
|
|
863
|
+
|
|
864
|
+
let res: TamaguiComponent<ComponentPropTypes, Ref, BaseProps> = component as any
|
|
865
|
+
|
|
866
|
+
if (configIn.memo) {
|
|
867
|
+
res = memo(res) as any
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
res.staticConfig = {
|
|
871
|
+
validStyles: staticConfig.validStyles || stylePropsView,
|
|
872
|
+
...staticConfig,
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
// res.extractable HoC
|
|
876
|
+
res.extractable = (Component: any, conf?: Partial<StaticConfig>) => {
|
|
877
|
+
Component.staticConfig = extendStaticConfig(
|
|
878
|
+
{
|
|
879
|
+
Component,
|
|
880
|
+
...conf,
|
|
881
|
+
neverFlatten: true,
|
|
882
|
+
isHOC: true,
|
|
883
|
+
defaultProps: {
|
|
884
|
+
...Component.defaultProps,
|
|
885
|
+
...conf?.defaultProps,
|
|
886
|
+
},
|
|
887
|
+
},
|
|
888
|
+
res
|
|
889
|
+
)
|
|
890
|
+
return Component
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
return res
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
// for elements to avoid spacing
|
|
897
|
+
export const Unspaced = (props: { children?: any }) => {
|
|
898
|
+
return props.children
|
|
899
|
+
}
|
|
900
|
+
Unspaced['isUnspaced'] = true
|
|
901
|
+
|
|
902
|
+
// dont used styled() here to avoid circular deps
|
|
903
|
+
// keep inline to avoid circular deps
|
|
904
|
+
|
|
905
|
+
export const Spacer = createComponent<SpacerProps>({
|
|
906
|
+
acceptsClassName: true,
|
|
907
|
+
memo: true,
|
|
908
|
+
componentName: 'Spacer',
|
|
909
|
+
validStyles,
|
|
910
|
+
|
|
911
|
+
defaultProps: {
|
|
912
|
+
...stackDefaultStyles,
|
|
913
|
+
// avoid nesting issues
|
|
914
|
+
tag: 'span',
|
|
915
|
+
size: true,
|
|
916
|
+
pointerEvents: 'none',
|
|
917
|
+
},
|
|
918
|
+
|
|
919
|
+
variants: {
|
|
920
|
+
size: {
|
|
921
|
+
'...size': (size, { tokens }) => {
|
|
922
|
+
size = size === true ? '$true' : size
|
|
923
|
+
const sizePx = tokens.space[size] ?? size
|
|
924
|
+
return {
|
|
925
|
+
width: sizePx,
|
|
926
|
+
height: sizePx,
|
|
927
|
+
minWidth: sizePx,
|
|
928
|
+
minHeight: sizePx,
|
|
929
|
+
}
|
|
930
|
+
},
|
|
931
|
+
},
|
|
932
|
+
|
|
933
|
+
flex: {
|
|
934
|
+
true: {
|
|
935
|
+
flexGrow: 1,
|
|
936
|
+
},
|
|
937
|
+
},
|
|
938
|
+
|
|
939
|
+
direction: {
|
|
940
|
+
horizontal: {
|
|
941
|
+
height: 0,
|
|
942
|
+
minHeight: 0,
|
|
943
|
+
},
|
|
944
|
+
vertical: {
|
|
945
|
+
width: 0,
|
|
946
|
+
minWidth: 0,
|
|
947
|
+
},
|
|
948
|
+
both: {},
|
|
949
|
+
},
|
|
950
|
+
} as const,
|
|
951
|
+
})
|
|
952
|
+
|
|
953
|
+
export type SpacedChildrenProps = {
|
|
954
|
+
isZStack?: boolean
|
|
955
|
+
children?: React.ReactNode
|
|
956
|
+
space?: SpaceTokens | number | null
|
|
957
|
+
spaceFlex?: boolean | number
|
|
958
|
+
direction?: SpaceDirection
|
|
959
|
+
separator?: React.ReactNode
|
|
960
|
+
debug?: DebugProp
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
export function spacedChildren(props: SpacedChildrenProps) {
|
|
964
|
+
const { isZStack, children, space, direction, spaceFlex, separator } = props
|
|
965
|
+
const hasSpace = !!(space || spaceFlex)
|
|
966
|
+
const hasSeparator = !(separator === undefined || separator === null)
|
|
967
|
+
if (!(hasSpace || hasSeparator || isZStack)) {
|
|
968
|
+
return children
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
const childrenList = Children.toArray(children)
|
|
972
|
+
|
|
973
|
+
const len = childrenList.length
|
|
974
|
+
if (len <= 1 && !isZStack && !childrenList[0]?.['type']?.['shouldForwardSpace']) {
|
|
975
|
+
return childrenList
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
const final: React.ReactNode[] = []
|
|
979
|
+
for (let [index, child] of childrenList.entries()) {
|
|
980
|
+
const isEmpty =
|
|
981
|
+
child === null ||
|
|
982
|
+
child === undefined ||
|
|
983
|
+
(Array.isArray(child) && child.length === 0)
|
|
984
|
+
|
|
985
|
+
// forward space
|
|
986
|
+
if (!isEmpty && React.isValidElement(child) && child.type?.['shouldForwardSpace']) {
|
|
987
|
+
child = React.cloneElement(child, {
|
|
988
|
+
space,
|
|
989
|
+
spaceFlex,
|
|
990
|
+
separator,
|
|
991
|
+
key: child.key,
|
|
992
|
+
} as any)
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
// push them all, but wrap some in Fragment
|
|
996
|
+
if (isEmpty || !child || (child['key'] && !isZStack)) {
|
|
997
|
+
final.push(child)
|
|
998
|
+
} else {
|
|
999
|
+
final.push(
|
|
1000
|
+
<Fragment key={index}>
|
|
1001
|
+
{isZStack ? <AbsoluteFill>{child}</AbsoluteFill> : child}
|
|
1002
|
+
</Fragment>
|
|
1003
|
+
)
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
// first child unspaced avoid insert space
|
|
1007
|
+
if (isUnspaced(child) && index === 0) continue
|
|
1008
|
+
// no spacing on ZStack
|
|
1009
|
+
if (isZStack) continue
|
|
1010
|
+
|
|
1011
|
+
const next = childrenList[index + 1]
|
|
1012
|
+
|
|
1013
|
+
if (next && !isUnspaced(next)) {
|
|
1014
|
+
if (separator) {
|
|
1015
|
+
if (hasSpace) {
|
|
1016
|
+
final.push(
|
|
1017
|
+
createSpacer({
|
|
1018
|
+
key: `_${index}_00tmgui`,
|
|
1019
|
+
direction,
|
|
1020
|
+
space,
|
|
1021
|
+
spaceFlex,
|
|
1022
|
+
})
|
|
1023
|
+
)
|
|
1024
|
+
}
|
|
1025
|
+
final.push(
|
|
1026
|
+
React.isValidElement(separator)
|
|
1027
|
+
? React.cloneElement(separator, { key: `sep_${index}` })
|
|
1028
|
+
: separator
|
|
1029
|
+
)
|
|
1030
|
+
if (hasSpace) {
|
|
1031
|
+
final.push(
|
|
1032
|
+
createSpacer({
|
|
1033
|
+
key: `_${index}01tmgui`,
|
|
1034
|
+
direction,
|
|
1035
|
+
space,
|
|
1036
|
+
spaceFlex,
|
|
1037
|
+
})
|
|
1038
|
+
)
|
|
1039
|
+
}
|
|
1040
|
+
} else {
|
|
1041
|
+
final.push(
|
|
1042
|
+
createSpacer({
|
|
1043
|
+
key: `_${index}02tmgui`,
|
|
1044
|
+
direction,
|
|
1045
|
+
space,
|
|
1046
|
+
spaceFlex,
|
|
1047
|
+
})
|
|
1048
|
+
)
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
if (process.env.NODE_ENV === 'development') {
|
|
1054
|
+
if (props.debug) {
|
|
1055
|
+
console.log(` Spaced children`, final, props)
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
return final
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
type CreateSpacerProps = SpacedChildrenProps & { key: string }
|
|
1063
|
+
|
|
1064
|
+
function createSpacer({ key, direction, space, spaceFlex }: CreateSpacerProps) {
|
|
1065
|
+
return (
|
|
1066
|
+
// @ts-ignore this one blew up but the types seem better
|
|
1067
|
+
<Spacer
|
|
1068
|
+
key={key}
|
|
1069
|
+
size={space}
|
|
1070
|
+
direction={direction}
|
|
1071
|
+
{...(typeof spaceFlex !== 'undefined' && {
|
|
1072
|
+
flex: spaceFlex === true ? 1 : spaceFlex === false ? 0 : spaceFlex,
|
|
1073
|
+
})}
|
|
1074
|
+
/>
|
|
1075
|
+
)
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
function isUnspaced(child: React.ReactNode) {
|
|
1079
|
+
// console.log('unspaced?', child, getMedia())
|
|
1080
|
+
return child?.['type']?.['isVisuallyHidden'] || child?.['type']?.['isUnspaced']
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
const DefaultProps = new Map()
|
|
1084
|
+
|
|
1085
|
+
function mergeConfigDefaultProps(
|
|
1086
|
+
name: string,
|
|
1087
|
+
props: Record<string, any>,
|
|
1088
|
+
configDefaults: Record<string, Object>,
|
|
1089
|
+
parentNames: (string | undefined)[],
|
|
1090
|
+
conf: TamaguiInternalConfig
|
|
1091
|
+
) {
|
|
1092
|
+
const len = parentNames.length
|
|
1093
|
+
let prev
|
|
1094
|
+
|
|
1095
|
+
for (let i = 0; i < len; i++) {
|
|
1096
|
+
const n = parentNames[i]
|
|
1097
|
+
if (!n) continue
|
|
1098
|
+
if (DefaultProps.has(n)) {
|
|
1099
|
+
prev = DefaultProps.get(n)
|
|
1100
|
+
continue
|
|
1101
|
+
}
|
|
1102
|
+
const props = configDefaults[n]
|
|
1103
|
+
if (!props) {
|
|
1104
|
+
if (prev) {
|
|
1105
|
+
DefaultProps.set(n, prev)
|
|
1106
|
+
}
|
|
1107
|
+
continue
|
|
1108
|
+
}
|
|
1109
|
+
prev = mergeProps(prev || {}, props, false, conf.inverseShorthands)[0]
|
|
1110
|
+
DefaultProps.set(n, prev)
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
// overwrite the user defined defaults on top of internal defined defaults
|
|
1114
|
+
const ourDefaultsMerged = DefaultProps.get(name)
|
|
1115
|
+
if (ourDefaultsMerged) {
|
|
1116
|
+
return mergeProps(props, ourDefaultsMerged, false, conf.inverseShorthands)[0]
|
|
1117
|
+
}
|
|
1118
|
+
return props
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
const AbsoluteFill: any = createComponent({
|
|
1122
|
+
componentName: 'AbsoluteFill',
|
|
1123
|
+
defaultProps: {
|
|
1124
|
+
...stackDefaultStyles,
|
|
1125
|
+
flexDirection: 'column',
|
|
1126
|
+
position: 'absolute',
|
|
1127
|
+
top: 0,
|
|
1128
|
+
right: 0,
|
|
1129
|
+
bottom: 0,
|
|
1130
|
+
left: 0,
|
|
1131
|
+
pointerEvents: 'box-none',
|
|
1132
|
+
},
|
|
1133
|
+
})
|