@tamagui/core 1.0.0-alpha.10 → 1.0.0-alpha.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/createComponent.js +2 -1
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/createTamagui.js +2 -0
- package/dist/cjs/createTamagui.js.map +2 -2
- package/dist/cjs/createVariable.js +1 -1
- package/dist/cjs/createVariable.js.map +2 -2
- package/dist/cjs/helpers/createPropMapper.js +20 -13
- package/dist/cjs/helpers/createPropMapper.js.map +2 -2
- package/dist/cjs/hooks/useMedia.js +4 -2
- package/dist/cjs/hooks/useMedia.js.map +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/views/Text.js +2 -2
- package/dist/cjs/views/Text.js.map +2 -2
- package/dist/cjs/views/Theme.js +15 -12
- package/dist/cjs/views/Theme.js.map +2 -2
- package/dist/{constants → esm/constants}/constants.js +0 -0
- package/dist/{constants → esm/constants}/constants.js.map +1 -1
- package/dist/{constants → esm/constants}/platform.js +0 -0
- package/dist/{constants → esm/constants}/platform.js.map +1 -1
- package/dist/{constants → esm/constants}/pseudos.js +0 -0
- package/dist/{constants → esm/constants}/pseudos.js.map +1 -1
- package/dist/{constants → esm/constants}/rnw.js +0 -0
- package/dist/{constants → esm/constants}/rnw.js.map +1 -1
- package/dist/{createComponent.js → esm/createComponent.js} +2 -1
- package/dist/esm/createComponent.js.map +7 -0
- package/dist/{createFont.js → esm/createFont.js} +0 -0
- package/dist/{createFont.js.map → esm/createFont.js.map} +1 -1
- package/dist/{createShorthands.js → esm/createShorthands.js} +0 -0
- package/dist/{createShorthands.js.map → esm/createShorthands.js.map} +1 -1
- package/dist/{createTamagui.js → esm/createTamagui.js} +2 -0
- package/dist/esm/createTamagui.js.map +7 -0
- package/dist/{createTheme.js → esm/createTheme.js} +0 -0
- package/dist/{createTheme.js.map → esm/createTheme.js.map} +1 -1
- package/dist/{createTokens.js → esm/createTokens.js} +0 -0
- package/dist/{createTokens.js.map → esm/createTokens.js.map} +1 -1
- package/dist/{createVariable.js → esm/createVariable.js} +1 -1
- package/dist/{createVariable.js.map → esm/createVariable.js.map} +3 -3
- package/dist/{helpers → esm/helpers}/addStylesUsingClassname.js +0 -0
- package/dist/{helpers → esm/helpers}/addStylesUsingClassname.js.map +1 -1
- package/dist/{helpers → esm/helpers}/createMediaStyle.js +0 -0
- package/dist/{helpers → esm/helpers}/createMediaStyle.js.map +1 -1
- package/dist/{helpers → esm/helpers}/createPropMapper.js +14 -7
- package/dist/esm/helpers/createPropMapper.js.map +7 -0
- package/dist/{helpers → esm/helpers}/createTamaguiProvider.js +0 -0
- package/dist/{helpers → esm/helpers}/createTamaguiProvider.js.map +1 -1
- package/dist/{helpers → esm/helpers}/extendStaticConfig.js +0 -0
- package/dist/{helpers → esm/helpers}/extendStaticConfig.js.map +1 -1
- package/dist/{helpers → esm/helpers}/fixNativeShadow.js +0 -0
- package/dist/{helpers → esm/helpers}/fixNativeShadow.js.map +1 -1
- package/dist/{helpers → esm/helpers}/fixNativeShadow.native.js +0 -0
- package/dist/{helpers → esm/helpers}/fixNativeShadow.native.js.map +1 -1
- package/dist/{helpers → esm/helpers}/getSplitStyles.js +0 -0
- package/dist/{helpers → esm/helpers}/getSplitStyles.js.map +1 -1
- package/dist/{helpers → esm/helpers}/getStylesAtomic.js +0 -0
- package/dist/{helpers → esm/helpers}/getStylesAtomic.js.map +1 -1
- package/dist/{helpers → esm/helpers}/getStylesAtomic.native.js +0 -0
- package/dist/{helpers → esm/helpers}/getStylesAtomic.native.js.map +1 -1
- package/dist/{helpers → esm/helpers}/insertStyleRule.js +0 -0
- package/dist/{helpers → esm/helpers}/insertStyleRule.js.map +1 -1
- package/dist/{helpers → esm/helpers}/isObj.js +0 -0
- package/dist/{helpers → esm/helpers}/isObj.js.map +1 -1
- package/dist/{helpers → esm/helpers}/isTamaguiElement.js +0 -0
- package/dist/{helpers → esm/helpers}/isTamaguiElement.js.map +1 -1
- package/dist/{helpers → esm/helpers}/matchMedia.js +0 -0
- package/dist/{helpers → esm/helpers}/matchMedia.js.map +1 -1
- package/dist/{helpers → esm/helpers}/matchMedia.native.js +0 -0
- package/dist/{helpers → esm/helpers}/matchMedia.native.js.map +1 -1
- package/dist/{helpers → esm/helpers}/themeable.js +0 -0
- package/dist/{helpers → esm/helpers}/themeable.js.map +1 -1
- package/dist/{helpers → esm/helpers}/validate.js +0 -0
- package/dist/{helpers → esm/helpers}/validate.js.map +1 -1
- package/dist/{hooks → esm/hooks}/useConstant.js +0 -0
- package/dist/{hooks → esm/hooks}/useConstant.js.map +1 -1
- package/dist/{hooks → esm/hooks}/useFeatures.js +0 -0
- package/dist/{hooks → esm/hooks}/useFeatures.js.map +1 -1
- package/dist/{hooks → esm/hooks}/useMedia.js +4 -2
- package/dist/esm/hooks/useMedia.js.map +7 -0
- package/dist/{hooks → esm/hooks}/usePressable.js +0 -0
- package/dist/{hooks → esm/hooks}/usePressable.js.map +1 -1
- package/dist/{hooks → esm/hooks}/useTheme.js +0 -0
- package/dist/{hooks → esm/hooks}/useTheme.js.map +1 -1
- package/dist/{index.js → esm/index.js} +0 -0
- package/dist/{index.js.map → esm/index.js.map} +1 -1
- package/dist/{static → esm/static}/postProcessStyles.js +0 -0
- package/dist/{static → esm/static}/postProcessStyles.js.map +1 -1
- package/dist/{static.js → esm/static.js} +0 -0
- package/dist/{static.js.map → esm/static.js.map} +1 -1
- package/dist/{styled.js → esm/styled.js} +0 -0
- package/dist/{styled.js.map → esm/styled.js.map} +1 -1
- package/dist/{types.js → esm/types.js} +0 -0
- package/dist/{types.js.map → esm/types.js.map} +0 -0
- package/dist/{views → esm/views}/Animated.js +0 -0
- package/dist/{views → esm/views}/Animated.js.map +1 -1
- package/dist/{views → esm/views}/Stack.js +0 -0
- package/dist/{views → esm/views}/Stack.js.map +1 -1
- package/dist/{views → esm/views}/Text.js +1 -1
- package/dist/esm/views/Text.js.map +7 -0
- package/dist/{views → esm/views}/TextAncestorContext.js +0 -0
- package/dist/{views → esm/views}/TextAncestorContext.js.map +1 -1
- package/dist/{views → esm/views}/Theme.js +15 -12
- package/dist/esm/views/Theme.js.map +7 -0
- package/dist/{views → esm/views}/ThemeContext.js +0 -0
- package/dist/{views → esm/views}/ThemeContext.js.map +1 -1
- package/dist/{views → esm/views}/ThemeInverse.js +0 -0
- package/dist/{views → esm/views}/ThemeInverse.js.map +1 -1
- package/dist/{views → esm/views}/ThemeManagerContext.js +0 -0
- package/dist/{views → esm/views}/ThemeManagerContext.js.map +1 -1
- package/dist/{views → esm/views}/ThemeProvider.js +0 -0
- package/dist/{views → esm/views}/ThemeProvider.js.map +1 -1
- package/dist/jsx/constants/constants.js +13 -0
- package/dist/jsx/constants/platform.js +18 -0
- package/dist/jsx/constants/pseudos.js +17 -0
- package/dist/jsx/constants/rnw.js +21 -0
- package/dist/jsx/createComponent.js +458 -0
- package/dist/jsx/createFont.js +27 -0
- package/dist/jsx/createShorthands.js +9 -0
- package/dist/jsx/createTamagui.js +169 -0
- package/dist/jsx/createTheme.js +19 -0
- package/dist/jsx/createTokens.js +32 -0
- package/dist/jsx/createVariable.js +24 -0
- package/dist/jsx/helpers/addStylesUsingClassname.js +56 -0
- package/dist/jsx/helpers/createMediaStyle.js +33 -0
- package/dist/jsx/helpers/createPropMapper.js +159 -0
- package/dist/jsx/helpers/createTamaguiProvider.js +19 -0
- package/dist/jsx/helpers/extendStaticConfig.js +58 -0
- package/dist/jsx/helpers/fixNativeShadow.js +7 -0
- package/dist/jsx/helpers/fixNativeShadow.native.js +29 -0
- package/dist/jsx/helpers/getSplitStyles.js +149 -0
- package/dist/jsx/helpers/getStylesAtomic.js +82 -0
- package/dist/jsx/helpers/getStylesAtomic.native.js +9 -0
- package/dist/jsx/helpers/insertStyleRule.js +23 -0
- package/dist/jsx/helpers/isObj.js +6 -0
- package/dist/{helpers/isTamaguiComponent.js → jsx/helpers/isTamaguiElement.js} +3 -4
- package/dist/jsx/helpers/matchMedia.js +17 -0
- package/dist/jsx/helpers/matchMedia.native.js +8 -0
- package/dist/jsx/helpers/themeable.js +23 -0
- package/dist/{helpers/validateConfig.js → jsx/helpers/validate.js} +35 -22
- package/dist/jsx/hooks/useConstant.js +14 -0
- package/dist/jsx/hooks/useFeatures.js +57 -0
- package/dist/jsx/hooks/useMedia.js +172 -0
- package/dist/jsx/hooks/usePressable.js +12 -0
- package/dist/jsx/hooks/useTheme.js +88 -0
- package/dist/jsx/index.js +31 -0
- package/dist/jsx/static/postProcessStyles.js +17 -0
- package/dist/jsx/static.js +14 -0
- package/dist/jsx/styled.js +20 -0
- package/dist/jsx/types.js +0 -0
- package/dist/jsx/views/Animated.js +74 -0
- package/dist/jsx/views/Stack.js +11 -0
- package/dist/jsx/views/Text.js +59 -0
- package/dist/jsx/views/TextAncestorContext.js +14 -0
- package/dist/jsx/views/Theme.js +62 -0
- package/dist/jsx/views/ThemeContext.js +5 -0
- package/dist/jsx/views/ThemeInverse.js +22 -0
- package/dist/jsx/views/ThemeManagerContext.js +60 -0
- package/dist/jsx/views/ThemeProvider.js +39 -0
- package/package.json +10 -11
- package/src/createComponent.tsx +4 -2
- package/src/createTamagui.ts +1 -0
- package/src/createVariable.ts +1 -1
- package/src/helpers/createPropMapper.ts +14 -6
- package/src/hooks/useMedia.tsx +5 -3
- package/src/types.tsx +6 -6
- package/src/views/Text.tsx +2 -1
- package/src/views/Theme.tsx +24 -20
- package/{dist/packages/core/src → types}/constants/constants.d.ts +0 -0
- package/types/constants/constants.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/constants/platform.d.ts +0 -0
- package/types/constants/platform.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/constants/pseudos.d.ts +0 -0
- package/types/constants/pseudos.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/constants/rnw.d.ts +0 -0
- package/types/constants/rnw.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/createComponent.d.ts +3 -2
- package/types/createComponent.d.ts.map +1 -0
- package/types/createFont.d.ts +3 -0
- package/types/createFont.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/createShorthands.d.ts +0 -0
- package/types/createShorthands.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/createTamagui.d.ts +18 -1
- package/types/createTamagui.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/createTheme.d.ts +0 -0
- package/types/createTheme.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/createTokens.d.ts +24 -14
- package/types/createTokens.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/createVariable.d.ts +1 -0
- package/types/createVariable.d.ts.map +1 -0
- package/types/helpers/addStylesUsingClassname.d.ts +3 -0
- package/types/helpers/addStylesUsingClassname.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/helpers/createMediaStyle.d.ts +0 -1
- package/types/helpers/createMediaStyle.d.ts.map +1 -0
- package/types/helpers/createPropMapper.d.ts +3 -0
- package/types/helpers/createPropMapper.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/helpers/createTamaguiProvider.d.ts +0 -0
- package/types/helpers/createTamaguiProvider.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/helpers/extendStaticConfig.d.ts +1 -1
- package/types/helpers/extendStaticConfig.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/helpers/fixNativeShadow.d.ts +0 -0
- package/types/helpers/fixNativeShadow.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/helpers/fixNativeShadow.native.d.ts +0 -0
- package/types/helpers/fixNativeShadow.native.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/helpers/getSplitStyles.d.ts +0 -0
- package/types/helpers/getSplitStyles.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/helpers/getStylesAtomic.d.ts +0 -1
- package/types/helpers/getStylesAtomic.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/helpers/getStylesAtomic.native.d.ts +0 -0
- package/types/helpers/getStylesAtomic.native.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/helpers/insertStyleRule.d.ts +0 -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/isTamaguiElement.d.ts +3 -0
- package/types/helpers/isTamaguiElement.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/helpers/matchMedia.d.ts +0 -0
- package/types/helpers/matchMedia.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/helpers/matchMedia.native.d.ts +0 -0
- package/types/helpers/matchMedia.native.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/helpers/themeable.d.ts +0 -0
- package/types/helpers/themeable.d.ts.map +1 -0
- package/types/helpers/validate.d.ts +4 -0
- package/types/helpers/validate.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/hooks/useConstant.d.ts +0 -0
- package/types/hooks/useConstant.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/hooks/useFeatures.d.ts +0 -0
- package/types/hooks/useFeatures.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/hooks/useMedia.d.ts +0 -0
- package/types/hooks/useMedia.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/hooks/usePressable.d.ts +0 -0
- package/types/hooks/usePressable.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/hooks/useTheme.d.ts +3 -1
- package/types/hooks/useTheme.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/index.d.ts +3 -1
- package/types/index.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/static/postProcessStyles.d.ts +0 -0
- package/types/static/postProcessStyles.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/static.d.ts +3 -0
- package/types/static.d.ts.map +1 -0
- package/types/styled.d.ts +21 -0
- package/types/styled.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/types.d.ts +71 -70
- package/types/types.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/views/Animated.d.ts +0 -0
- package/types/views/Animated.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/views/Stack.d.ts +0 -0
- package/types/views/Stack.d.ts.map +1 -0
- package/types/views/Text.d.ts +3 -0
- package/types/views/Text.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/views/TextAncestorContext.d.ts +0 -0
- package/types/views/TextAncestorContext.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/views/Theme.d.ts +1 -1
- package/types/views/Theme.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/views/ThemeContext.d.ts +0 -0
- package/types/views/ThemeContext.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/views/ThemeInverse.d.ts +0 -0
- package/types/views/ThemeInverse.d.ts.map +1 -0
- package/types/views/ThemeManagerContext.d.ts +22 -0
- package/types/views/ThemeManagerContext.d.ts.map +1 -0
- package/{dist/packages/core/src → types}/views/ThemeProvider.d.ts +0 -0
- package/types/views/ThemeProvider.d.ts.map +1 -0
- package/dist/constants/styleConstants.js +0 -46
- package/dist/constants/styleConstants.js.map +0 -7
- package/dist/createComponent.js.map +0 -7
- package/dist/createTamagui.js.map +0 -7
- package/dist/helpers/createPropMapper.js.map +0 -7
- package/dist/helpers/isComponent.js +0 -10
- package/dist/helpers/isComponent.js.map +0 -7
- package/dist/helpers/isTamaguiComponent.js.map +0 -7
- package/dist/helpers/pseudos.js +0 -1
- package/dist/helpers/pseudos.js.map +0 -7
- package/dist/helpers/validateConfig.js.map +0 -7
- package/dist/helpers/validateTokens.js +0 -29
- package/dist/helpers/validateTokens.js.map +0 -7
- package/dist/hooks/useForceUpdate.js +0 -28
- package/dist/hooks/useForceUpdate.js.map +0 -7
- package/dist/hooks/useMedia.js.map +0 -7
- package/dist/index.cjs +0 -2202
- package/dist/index.cjs.map +0 -7
- package/dist/packages/core/src/constants/constants.d.ts.map +0 -1
- package/dist/packages/core/src/constants/platform.d.ts.map +0 -1
- package/dist/packages/core/src/constants/pseudos.d.ts.map +0 -1
- package/dist/packages/core/src/constants/rnw.d.ts.map +0 -1
- package/dist/packages/core/src/createComponent.d.ts.map +0 -1
- package/dist/packages/core/src/createShorthands.d.ts.map +0 -1
- package/dist/packages/core/src/createTamagui.d.ts.map +0 -1
- package/dist/packages/core/src/createTheme.d.ts.map +0 -1
- package/dist/packages/core/src/createTokens.d.ts.map +0 -1
- package/dist/packages/core/src/createVariable.d.ts.map +0 -1
- package/dist/packages/core/src/helpers/addStylesUsingClassname.d.ts +0 -2
- package/dist/packages/core/src/helpers/addStylesUsingClassname.d.ts.map +0 -1
- package/dist/packages/core/src/helpers/createMediaStyle.d.ts.map +0 -1
- package/dist/packages/core/src/helpers/createTamaguiProvider.d.ts.map +0 -1
- package/dist/packages/core/src/helpers/extendStaticConfig.d.ts.map +0 -1
- package/dist/packages/core/src/helpers/fixNativeShadow.d.ts.map +0 -1
- package/dist/packages/core/src/helpers/fixNativeShadow.native.d.ts.map +0 -1
- package/dist/packages/core/src/helpers/getSplitStyles.d.ts.map +0 -1
- package/dist/packages/core/src/helpers/getStylesAtomic.d.ts.map +0 -1
- package/dist/packages/core/src/helpers/getStylesAtomic.native.d.ts.map +0 -1
- package/dist/packages/core/src/helpers/insertStyleRule.d.ts.map +0 -1
- package/dist/packages/core/src/helpers/matchMedia.d.ts.map +0 -1
- package/dist/packages/core/src/helpers/matchMedia.native.d.ts.map +0 -1
- package/dist/packages/core/src/helpers/themeable.d.ts.map +0 -1
- package/dist/packages/core/src/hooks/useConstant.d.ts.map +0 -1
- package/dist/packages/core/src/hooks/useFeatures.d.ts.map +0 -1
- package/dist/packages/core/src/hooks/useForceUpdate.d.ts +0 -2
- package/dist/packages/core/src/hooks/useForceUpdate.d.ts.map +0 -1
- package/dist/packages/core/src/hooks/useMedia.d.ts.map +0 -1
- package/dist/packages/core/src/hooks/usePressable.d.ts.map +0 -1
- package/dist/packages/core/src/hooks/useTheme.d.ts.map +0 -1
- package/dist/packages/core/src/index.d.ts.map +0 -1
- package/dist/packages/core/src/static/postProcessStyles.d.ts.map +0 -1
- package/dist/packages/core/src/static.d.ts.map +0 -1
- package/dist/packages/core/src/styled.d.ts +0 -16
- package/dist/packages/core/src/styled.d.ts.map +0 -1
- package/dist/packages/core/src/types.d.ts.map +0 -1
- package/dist/packages/core/src/views/Animated.d.ts.map +0 -1
- package/dist/packages/core/src/views/Stack.d.ts.map +0 -1
- package/dist/packages/core/src/views/Text.d.ts +0 -3
- package/dist/packages/core/src/views/Text.d.ts.map +0 -1
- package/dist/packages/core/src/views/TextAncestorContext.d.ts.map +0 -1
- package/dist/packages/core/src/views/Theme.d.ts.map +0 -1
- package/dist/packages/core/src/views/ThemeContext.d.ts.map +0 -1
- package/dist/packages/core/src/views/ThemeInverse.d.ts.map +0 -1
- package/dist/packages/core/src/views/ThemeManagerContext.d.ts +0 -15
- package/dist/packages/core/src/views/ThemeManagerContext.d.ts.map +0 -1
- package/dist/packages/core/src/views/ThemeProvider.d.ts.map +0 -1
- package/dist/packages/helpers/src/AllRules.d.ts +0 -3
- package/dist/packages/helpers/src/AllRules.d.ts.map +0 -1
- package/dist/packages/helpers/src/concatClassName.d.ts +0 -2
- package/dist/packages/helpers/src/concatClassName.d.ts.map +0 -1
- package/dist/packages/helpers/src/index.d.ts +0 -5
- package/dist/packages/helpers/src/index.d.ts.map +0 -1
- package/dist/packages/helpers/src/types.d.ts +0 -8
- package/dist/packages/helpers/src/types.d.ts.map +0 -1
- package/dist/packages/helpers/src/validStyleProps.d.ts +0 -475
- package/dist/packages/helpers/src/validStyleProps.d.ts.map +0 -1
- package/dist/views/SafeAreaProvider.js +0 -30
- package/dist/views/SafeAreaProvider.js.map +0 -7
- package/dist/views/Text.js.map +0 -7
- package/dist/views/Theme.js.map +0 -7
- package/types.d.ts +0 -559
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { stylePropsTextOnly, validStyles } from "@tamagui/helpers";
|
|
2
|
+
import { isWeb } from "../constants/platform";
|
|
3
|
+
import { createComponent } from "../createComponent";
|
|
4
|
+
const ellipseStyle = {
|
|
5
|
+
maxWidth: "100%",
|
|
6
|
+
overflow: "hidden",
|
|
7
|
+
textOverflow: "ellipsis",
|
|
8
|
+
whiteSpace: "nowrap"
|
|
9
|
+
};
|
|
10
|
+
const Text = createComponent({
|
|
11
|
+
isText: true,
|
|
12
|
+
defaultProps: {
|
|
13
|
+
display: isWeb ? "inline" : "inline-flex",
|
|
14
|
+
boxSizing: "border-box",
|
|
15
|
+
fontFamily: "System",
|
|
16
|
+
wordWrap: "break-word"
|
|
17
|
+
},
|
|
18
|
+
variants: {
|
|
19
|
+
numberOfLines: {
|
|
20
|
+
1: ellipseStyle,
|
|
21
|
+
"[number]": (lines) => lines > 1 ? { WebkitLineClamp: 1 } : null
|
|
22
|
+
},
|
|
23
|
+
selectable: {
|
|
24
|
+
true: {
|
|
25
|
+
userSelect: "text"
|
|
26
|
+
},
|
|
27
|
+
false: {
|
|
28
|
+
userSelect: "none"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
pressable: {
|
|
32
|
+
true: {
|
|
33
|
+
cursor: "pointer"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
ellipse: {
|
|
37
|
+
true: isWeb ? ellipseStyle : {
|
|
38
|
+
numberOfLines: 1,
|
|
39
|
+
lineBreakMode: "clip"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
deoptProps: new Set(isWeb ? [] : ["ellipse"]),
|
|
44
|
+
validStyles: {
|
|
45
|
+
...validStyles,
|
|
46
|
+
...stylePropsTextOnly,
|
|
47
|
+
...isWeb && {
|
|
48
|
+
userSelect: true,
|
|
49
|
+
textOverflow: true,
|
|
50
|
+
whiteSpace: true,
|
|
51
|
+
wordWrap: true,
|
|
52
|
+
selectable: true,
|
|
53
|
+
cursor: true
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
export {
|
|
58
|
+
Text
|
|
59
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { rnw } from "../constants/rnw";
|
|
4
|
+
const TextAncestorContext = rnw?.TextAncestorContext;
|
|
5
|
+
const TextAncestorProvider = /* @__PURE__ */ __name((props) => {
|
|
6
|
+
if (TextAncestorContext) {
|
|
7
|
+
return <TextAncestorContext.Provider value={false}>{props.children}</TextAncestorContext.Provider>;
|
|
8
|
+
}
|
|
9
|
+
return props.children;
|
|
10
|
+
}, "TextAncestorProvider");
|
|
11
|
+
export {
|
|
12
|
+
TextAncestorContext,
|
|
13
|
+
TextAncestorProvider
|
|
14
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { useContext, useState } from "react";
|
|
4
|
+
import { isWeb, useIsomorphicLayoutEffect } from "../constants/platform";
|
|
5
|
+
import { getThemeParentClassName } from "../createTamagui";
|
|
6
|
+
import { useConstant } from "../hooks/useConstant";
|
|
7
|
+
import { ThemeContext } from "./ThemeContext";
|
|
8
|
+
import { ThemeManager, ThemeManagerContext } from "./ThemeManagerContext";
|
|
9
|
+
const Theme = /* @__PURE__ */ __name((props) => {
|
|
10
|
+
const parent = useContext(ThemeManagerContext);
|
|
11
|
+
const themes = useContext(ThemeContext);
|
|
12
|
+
const [parentName, setParentName] = useState(parent.name || "light");
|
|
13
|
+
if (!themes) {
|
|
14
|
+
console.warn("Error, no themes in context", props);
|
|
15
|
+
return props.children;
|
|
16
|
+
}
|
|
17
|
+
const nextNameParent = `${props.name}-${parentName}`;
|
|
18
|
+
const nextNameParentParent = `${props.name}-${parent.parentName}`;
|
|
19
|
+
const name = !props.name ? null : props.name in themes ? props.name : nextNameParent in themes ? nextNameParent : nextNameParentParent in themes ? nextNameParentParent : null;
|
|
20
|
+
const theme = name ? themes[name] : null;
|
|
21
|
+
const themeManager = useConstant(() => {
|
|
22
|
+
if (!theme) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const manager = new ThemeManager();
|
|
26
|
+
if (name) {
|
|
27
|
+
manager.setActiveTheme({ name, theme: themes[name], parentName });
|
|
28
|
+
}
|
|
29
|
+
return manager;
|
|
30
|
+
});
|
|
31
|
+
useIsomorphicLayoutEffect(() => {
|
|
32
|
+
if (!themeManager) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (name) {
|
|
36
|
+
themeManager.setActiveTheme({ name, theme, parentName });
|
|
37
|
+
}
|
|
38
|
+
return parent.onChangeTheme((next) => {
|
|
39
|
+
if (next) {
|
|
40
|
+
themeManager.setActiveTheme({ name: next, theme: themes[next], parentName });
|
|
41
|
+
setParentName(next);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}, [themes, name, parentName]);
|
|
45
|
+
if (!name || !theme) {
|
|
46
|
+
return props.children;
|
|
47
|
+
}
|
|
48
|
+
const contents = themeManager ? <ThemeManagerContext.Provider value={themeManager}>{props.children}</ThemeManagerContext.Provider> : props.children;
|
|
49
|
+
if (isWeb) {
|
|
50
|
+
if (props.disableThemeClass) {
|
|
51
|
+
return contents;
|
|
52
|
+
}
|
|
53
|
+
if (name) {
|
|
54
|
+
const color = themes[name]?.["color"]?.["variable"];
|
|
55
|
+
return <div className={getThemeParentClassName(props.name)} style={{ display: "contents", color }}>{contents}</div>;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return contents;
|
|
59
|
+
}, "Theme");
|
|
60
|
+
export {
|
|
61
|
+
Theme
|
|
62
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { useDefaultThemeName, useThemeName } from "../hooks/useTheme";
|
|
4
|
+
import { Theme } from "./Theme";
|
|
5
|
+
let inversions = {
|
|
6
|
+
light: "dark",
|
|
7
|
+
dark: "light"
|
|
8
|
+
};
|
|
9
|
+
function setThemeInversions(next) {
|
|
10
|
+
inversions = next;
|
|
11
|
+
}
|
|
12
|
+
__name(setThemeInversions, "setThemeInversions");
|
|
13
|
+
const ThemeInverse = /* @__PURE__ */ __name((props) => {
|
|
14
|
+
const themeName = useThemeName();
|
|
15
|
+
const defaultTheme = useDefaultThemeName();
|
|
16
|
+
const name = inversions[themeName] || inversions[defaultTheme] || null;
|
|
17
|
+
return <Theme name={name}>{props.children}</Theme>;
|
|
18
|
+
}, "ThemeInverse");
|
|
19
|
+
export {
|
|
20
|
+
ThemeInverse,
|
|
21
|
+
setThemeInversions
|
|
22
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { createContext } from "react";
|
|
4
|
+
class ThemeManager {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.name = "light";
|
|
7
|
+
this.parentName = null;
|
|
8
|
+
this.keys = new Map();
|
|
9
|
+
this.listeners = new Map();
|
|
10
|
+
this.themeListeners = new Set();
|
|
11
|
+
this.theme = null;
|
|
12
|
+
}
|
|
13
|
+
setActiveTheme({
|
|
14
|
+
name,
|
|
15
|
+
theme,
|
|
16
|
+
parentName
|
|
17
|
+
}) {
|
|
18
|
+
if (name === this.name)
|
|
19
|
+
return;
|
|
20
|
+
this.name = name;
|
|
21
|
+
this.theme = theme;
|
|
22
|
+
this.parentName = parentName || null;
|
|
23
|
+
this.update();
|
|
24
|
+
}
|
|
25
|
+
track(uuid, keys) {
|
|
26
|
+
if (!this.name)
|
|
27
|
+
return;
|
|
28
|
+
this.keys.set(uuid, keys);
|
|
29
|
+
}
|
|
30
|
+
update() {
|
|
31
|
+
if (!this.name) {
|
|
32
|
+
this.keys.clear();
|
|
33
|
+
}
|
|
34
|
+
for (const [uuid, keys] of this.keys.entries()) {
|
|
35
|
+
if (keys.size) {
|
|
36
|
+
this.listeners.get(uuid)?.();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
this.themeListeners.forEach((cb) => cb(this.name, this));
|
|
40
|
+
}
|
|
41
|
+
onChangeTheme(cb) {
|
|
42
|
+
this.themeListeners.add(cb);
|
|
43
|
+
return () => {
|
|
44
|
+
this.themeListeners.delete(cb);
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
onUpdate(uuid, cb) {
|
|
48
|
+
this.listeners.set(uuid, cb);
|
|
49
|
+
return () => {
|
|
50
|
+
this.listeners.delete(uuid);
|
|
51
|
+
this.keys.delete(uuid);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
__name(ThemeManager, "ThemeManager");
|
|
56
|
+
const ThemeManagerContext = createContext(new ThemeManager());
|
|
57
|
+
export {
|
|
58
|
+
ThemeManager,
|
|
59
|
+
ThemeManagerContext
|
|
60
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { useIsomorphicLayoutEffect } from "../constants/platform";
|
|
5
|
+
import { getHasConfigured, getThemeParentClassName } from "../createTamagui";
|
|
6
|
+
import { Theme } from "./Theme";
|
|
7
|
+
import { ThemeContext } from "./ThemeContext";
|
|
8
|
+
const GET_DEFAULT_THEME = "___TGUI";
|
|
9
|
+
const ThemeProvider = /* @__PURE__ */ __name((props) => {
|
|
10
|
+
if (!getHasConfigured()) {
|
|
11
|
+
throw new Error(`Missing configureThemes() call, add to your root file`);
|
|
12
|
+
}
|
|
13
|
+
useIsomorphicLayoutEffect(() => {
|
|
14
|
+
if (props.disableRootThemeClass) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (typeof document !== "undefined") {
|
|
18
|
+
const cns = getThemeParentClassName(`${props.defaultTheme}`).split(" ");
|
|
19
|
+
cns.forEach((cn) => document.body.classList.add(cn));
|
|
20
|
+
return () => {
|
|
21
|
+
cns.forEach((cn) => document.body.classList.remove(cn));
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}, []);
|
|
25
|
+
const themeContext = useMemo(() => {
|
|
26
|
+
return new Proxy(props.themes, {
|
|
27
|
+
get(target, key) {
|
|
28
|
+
if (key === GET_DEFAULT_THEME)
|
|
29
|
+
return props.defaultTheme;
|
|
30
|
+
return Reflect.get(target, key);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}, [props.themes]);
|
|
34
|
+
return <ThemeContext.Provider value={themeContext}><Theme name={props.defaultTheme} disableThemeClass={props.disableRootThemeClass}>{props.children}</Theme></ThemeContext.Provider>;
|
|
35
|
+
}, "ThemeProvider");
|
|
36
|
+
export {
|
|
37
|
+
GET_DEFAULT_THEME,
|
|
38
|
+
ThemeProvider
|
|
39
|
+
};
|
package/package.json
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/core",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.14",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist",
|
|
7
|
-
"typings": "types
|
|
7
|
+
"typings": "types",
|
|
8
8
|
"scripts": {
|
|
9
|
-
"build": "tamagui-build
|
|
10
|
-
"watch": "tamagui-build --
|
|
9
|
+
"build": "tamagui-build",
|
|
10
|
+
"watch": "tamagui-build --watch"
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
|
-
"
|
|
14
|
-
"types.d.ts",
|
|
13
|
+
"types",
|
|
15
14
|
"dist",
|
|
16
15
|
"src"
|
|
17
16
|
],
|
|
18
17
|
"dependencies": {
|
|
19
|
-
"@tamagui/helpers": "^1.0.0-alpha.
|
|
18
|
+
"@tamagui/helpers": "^1.0.0-alpha.14",
|
|
20
19
|
"@tamagui/ow": "^0.28.1",
|
|
21
|
-
"@tamagui/use-debounce": "^1.0.0-alpha.
|
|
22
|
-
"@tamagui/use-force-update": "^1.0.0-alpha.
|
|
20
|
+
"@tamagui/use-debounce": "^1.0.0-alpha.12",
|
|
21
|
+
"@tamagui/use-force-update": "^1.0.0-alpha.12",
|
|
23
22
|
"react": "*",
|
|
24
23
|
"react-dom": "*"
|
|
25
24
|
},
|
|
@@ -27,7 +26,7 @@
|
|
|
27
26
|
"react-native-web": "*"
|
|
28
27
|
},
|
|
29
28
|
"devDependencies": {
|
|
30
|
-
"@tamagui/build": "^1.0.0-alpha.
|
|
29
|
+
"@tamagui/build": "^1.0.0-alpha.12",
|
|
31
30
|
"@types/react": "^17.0.35",
|
|
32
31
|
"esbuild": "^0.11.20",
|
|
33
32
|
"typescript": "^4.4.4"
|
|
@@ -38,5 +37,5 @@
|
|
|
38
37
|
"engines": {
|
|
39
38
|
"node": ">=16"
|
|
40
39
|
},
|
|
41
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "48c3e4fd3c5dfff277061176b10be2b1295089c4"
|
|
42
41
|
}
|
package/src/createComponent.tsx
CHANGED
|
@@ -99,12 +99,14 @@ export function createComponent<A extends Object = DefaultProps>(
|
|
|
99
99
|
const hasTextAncestor = isWeb ? useContext(TextAncestorContext) : false
|
|
100
100
|
const hostRef = useRef(null)
|
|
101
101
|
|
|
102
|
+
const theme = (manager.theme as any) || initialTheme
|
|
103
|
+
|
|
102
104
|
const {
|
|
103
105
|
viewProps: viewPropsIn,
|
|
104
106
|
pseudos,
|
|
105
107
|
style,
|
|
106
108
|
classNames,
|
|
107
|
-
} = getSplitStyles(props, staticConfig,
|
|
109
|
+
} = getSplitStyles(props, staticConfig, theme)
|
|
108
110
|
|
|
109
111
|
const {
|
|
110
112
|
tag,
|
|
@@ -239,7 +241,7 @@ export function createComponent<A extends Object = DefaultProps>(
|
|
|
239
241
|
]
|
|
240
242
|
: [defaultsClassName, props.className, classNames, stylesClassNames]
|
|
241
243
|
|
|
242
|
-
// @ts-
|
|
244
|
+
// @ts-ignore we are optimizing using arguments
|
|
243
245
|
const className = concatClassName(...classList)
|
|
244
246
|
if (process.env.NODE_ENV === 'development') {
|
|
245
247
|
if (props['debug']) {
|
package/src/createTamagui.ts
CHANGED
|
@@ -31,6 +31,7 @@ export const getHasConfigured = () => !!conf
|
|
|
31
31
|
|
|
32
32
|
export const getTamagui = () => conf!
|
|
33
33
|
export const getTokens = () => conf!.tokensParsed
|
|
34
|
+
export const getThemes = () => conf!.themes
|
|
34
35
|
|
|
35
36
|
type ConfigListener = (conf: TamaguiInternalConfig) => void
|
|
36
37
|
const configListeners = new Set<ConfigListener>()
|
package/src/createVariable.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isWeb } from '../constants/platform'
|
|
1
2
|
import { getTamagui } from '../createTamagui'
|
|
2
3
|
import { Variable } from '../createVariable'
|
|
3
4
|
import { StaticConfig, TamaguiInternalConfig } from '../types'
|
|
@@ -37,7 +38,7 @@ export const createPropMapper = (c: StaticConfig) => {
|
|
|
37
38
|
: val
|
|
38
39
|
|
|
39
40
|
if (isObj(res)) {
|
|
40
|
-
resolveTokens(res, conf, fontFamily)
|
|
41
|
+
resolveTokens(res, conf, theme, fontFamily)
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
return res
|
|
@@ -53,7 +54,7 @@ export const createPropMapper = (c: StaticConfig) => {
|
|
|
53
54
|
|
|
54
55
|
if (value && value[0] === '$') {
|
|
55
56
|
shouldReturn = true
|
|
56
|
-
value = getToken(key, value, conf, fontFamily)
|
|
57
|
+
value = getToken(key, value, conf, theme, fontFamily)
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
if (value instanceof Variable) {
|
|
@@ -69,19 +70,19 @@ export const createPropMapper = (c: StaticConfig) => {
|
|
|
69
70
|
}
|
|
70
71
|
}
|
|
71
72
|
|
|
72
|
-
const resolveTokens = (res: any, conf: TamaguiInternalConfig, fontFamily: any) => {
|
|
73
|
+
const resolveTokens = (res: any, conf: TamaguiInternalConfig, theme: any, fontFamily: any) => {
|
|
73
74
|
for (const rKey in res) {
|
|
74
75
|
const fKey = conf.shorthands[rKey] || rKey
|
|
75
76
|
const val = res[rKey]
|
|
76
77
|
if (val instanceof Variable) {
|
|
77
78
|
res[fKey] = val.variable
|
|
78
79
|
} else if (typeof val === 'string') {
|
|
79
|
-
const fVal = val[0] === '$' ? getToken(fKey, val, conf, fontFamily) : val
|
|
80
|
+
const fVal = val[0] === '$' ? getToken(fKey, val, conf, theme, fontFamily) : val
|
|
80
81
|
res[fKey] = fVal
|
|
81
82
|
} else {
|
|
82
83
|
if (isObj(val)) {
|
|
83
84
|
// for things like shadowOffset which is a sub-object
|
|
84
|
-
resolveTokens(val, conf, fontFamily)
|
|
85
|
+
resolveTokens(val, conf, theme, fontFamily)
|
|
85
86
|
}
|
|
86
87
|
// nullish values cant be tokens so need no exrta parsing
|
|
87
88
|
}
|
|
@@ -92,10 +93,17 @@ const getToken = (
|
|
|
92
93
|
key: string,
|
|
93
94
|
value: string,
|
|
94
95
|
{ tokensParsed, themeParsed }: TamaguiInternalConfig,
|
|
96
|
+
theme: any,
|
|
95
97
|
fontFamily: string | undefined = '$body'
|
|
96
98
|
) => {
|
|
97
99
|
if (themeParsed[value]) {
|
|
98
|
-
|
|
100
|
+
if (isWeb && themeParsed[value].variable) {
|
|
101
|
+
return themeParsed[value].variable
|
|
102
|
+
} else {
|
|
103
|
+
if (value && value[0] === '$') {
|
|
104
|
+
return theme[`${value.slice(1)}`]?.val || themeParsed[value]?.val
|
|
105
|
+
}
|
|
106
|
+
}
|
|
99
107
|
}
|
|
100
108
|
let valOrVar: any
|
|
101
109
|
if (key === 'fontFamily') {
|
package/src/hooks/useMedia.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useForceUpdate } from '@tamagui/use-force-update'
|
|
2
2
|
import { useRef } from 'react'
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { useIsomorphicLayoutEffect } from '../constants/platform'
|
|
5
5
|
import { matchMedia } from '../helpers/matchMedia'
|
|
6
6
|
import {
|
|
7
7
|
ConfigureMediaQueryOptions,
|
|
@@ -28,13 +28,15 @@ let conf: MediaQueries | null = null
|
|
|
28
28
|
export const mediaQueryConfig = new Proxy<MediaQueries>({} as any, {
|
|
29
29
|
get(target, key) {
|
|
30
30
|
if (!conf) {
|
|
31
|
-
|
|
31
|
+
console.warn('Warning: accessing media query before init')
|
|
32
|
+
return null
|
|
32
33
|
}
|
|
33
34
|
return Reflect.get(conf, key)
|
|
34
35
|
},
|
|
35
36
|
ownKeys() {
|
|
36
37
|
if (!conf) {
|
|
37
|
-
|
|
38
|
+
console.warn('Warning: accessing media query before init')
|
|
39
|
+
return []
|
|
38
40
|
}
|
|
39
41
|
return Object.keys(conf)
|
|
40
42
|
},
|
package/src/types.tsx
CHANGED
|
@@ -225,7 +225,7 @@ export type WithThemeValues<T extends object> = {
|
|
|
225
225
|
type WithShorthands<StyleProps> = {
|
|
226
226
|
[Key in keyof Shorthands]?: Shorthands[Key] extends keyof StyleProps
|
|
227
227
|
? StyleProps[Shorthands[Key]] | null
|
|
228
|
-
:
|
|
228
|
+
: undefined
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
//
|
|
@@ -263,11 +263,11 @@ type WebOnlyStyleProps = {
|
|
|
263
263
|
pointerEvents?: ViewProps['pointerEvents']
|
|
264
264
|
}
|
|
265
265
|
|
|
266
|
-
type
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
>
|
|
266
|
+
export type StackStylePropsBase = Omit<ViewStyle, 'display' | 'backfaceVisibility' | 'elevation'> &
|
|
267
|
+
TransformStyleProps &
|
|
268
|
+
WebOnlyStyleProps
|
|
269
|
+
|
|
270
|
+
export type StackStyleProps = WithThemeShorthandsPseudosAndMedia<StackStylePropsBase>
|
|
271
271
|
|
|
272
272
|
export type StackProps = Omit<RNWInternalProps, 'children'> &
|
|
273
273
|
Omit<ViewProps, 'display' | 'children'> &
|
package/src/views/Text.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { stylePropsTextOnly, validStyles } from '@tamagui/helpers'
|
|
2
|
+
|
|
1
3
|
import { isWeb } from '../constants/platform'
|
|
2
4
|
import { createComponent } from '../createComponent'
|
|
3
|
-
import { stylePropsTextOnly, validStyles } from '../static'
|
|
4
5
|
import { TextProps } from '../types'
|
|
5
6
|
|
|
6
7
|
const ellipseStyle = {
|
package/src/views/Theme.tsx
CHANGED
|
@@ -9,7 +9,7 @@ import { ThemeManager, ThemeManagerContext } from './ThemeManagerContext'
|
|
|
9
9
|
|
|
10
10
|
export type ThemeProps = {
|
|
11
11
|
disableThemeClass?: boolean
|
|
12
|
-
name: ThemeName | null
|
|
12
|
+
name: Exclude<ThemeName, number> | null
|
|
13
13
|
children?: any
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -21,19 +21,19 @@ export const Theme = (props: ThemeProps) => {
|
|
|
21
21
|
console.warn('Error, no themes in context', props)
|
|
22
22
|
return props.children
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
const nextNameParent = `${name}-${parentName}`
|
|
26
|
-
const nextNameParentParent = `${name}-${parent.parentName}`
|
|
27
|
-
const
|
|
24
|
+
|
|
25
|
+
const nextNameParent = `${props.name}-${parentName}`
|
|
26
|
+
const nextNameParentParent = `${props.name}-${parent.parentName}`
|
|
27
|
+
const name = !props.name
|
|
28
28
|
? null
|
|
29
|
-
: name in themes
|
|
30
|
-
? name
|
|
29
|
+
: props.name in themes
|
|
30
|
+
? props.name
|
|
31
31
|
: nextNameParent in themes
|
|
32
32
|
? nextNameParent
|
|
33
33
|
: nextNameParentParent in themes
|
|
34
34
|
? nextNameParentParent
|
|
35
35
|
: null
|
|
36
|
-
const theme =
|
|
36
|
+
const theme = name ? themes[name] : null
|
|
37
37
|
const themeManager = useConstant<ThemeManager | null>(() => {
|
|
38
38
|
if (!theme) {
|
|
39
39
|
return null
|
|
@@ -49,14 +49,16 @@ export const Theme = (props: ThemeProps) => {
|
|
|
49
49
|
if (!themeManager) {
|
|
50
50
|
return
|
|
51
51
|
}
|
|
52
|
-
|
|
52
|
+
if (name) {
|
|
53
|
+
themeManager.setActiveTheme({ name, theme, parentName })
|
|
54
|
+
}
|
|
53
55
|
return parent.onChangeTheme((next) => {
|
|
54
56
|
if (next) {
|
|
55
57
|
themeManager.setActiveTheme({ name: next, theme: themes[next], parentName })
|
|
56
58
|
setParentName(next)
|
|
57
59
|
}
|
|
58
60
|
})
|
|
59
|
-
}, [themes,
|
|
61
|
+
}, [themes, name, parentName])
|
|
60
62
|
|
|
61
63
|
if (!name || !theme) {
|
|
62
64
|
return props.children
|
|
@@ -74,16 +76,18 @@ export const Theme = (props: ThemeProps) => {
|
|
|
74
76
|
if (props.disableThemeClass) {
|
|
75
77
|
return contents
|
|
76
78
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
if (name) {
|
|
80
|
+
const color = themes[name]?.['color']?.['variable']
|
|
81
|
+
return (
|
|
82
|
+
<div
|
|
83
|
+
className={getThemeParentClassName(props.name)}
|
|
84
|
+
// in order to provide currentColor, set color by default
|
|
85
|
+
style={{ display: 'contents', color }}
|
|
86
|
+
>
|
|
87
|
+
{contents}
|
|
88
|
+
</div>
|
|
89
|
+
)
|
|
90
|
+
}
|
|
87
91
|
}
|
|
88
92
|
|
|
89
93
|
return contents
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB;;;;;;CAS9B,CAAA"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../src/constants/platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAmB,MAAM,OAAO,CAAA;AAGlD,eAAO,MAAM,KAAK,SAAuE,CAAA;AACzF,eAAO,MAAM,KAAK,SAAyC,CAAA;AAC3D,eAAO,MAAM,yBAAyB,kBAAsC,CAAA;AAC5E,eAAO,MAAM,QAAQ,SAA+E,CAAA;AACpG,eAAO,MAAM,gBAAgB,SAA4D,CAAA;AACzF,eAAO,MAAM,aAAa,SAA6B,CAAA;AACvD,eAAO,MAAM,QAAQ,SAKA,CAAA"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pseudos.d.ts","sourceRoot":"","sources":["../../src/constants/pseudos.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO;;;;;;;;;;;;;CAanB,CAAA"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rnw.d.ts","sourceRoot":"","sources":["../../src/constants/rnw.tsx"],"names":[],"mappings":"AAEA,eAAO,MAAM,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,CAAA"}
|
|
@@ -4,10 +4,11 @@ export declare const mouseUps: Set<Function>;
|
|
|
4
4
|
declare type DefaultProps = {};
|
|
5
5
|
export declare function createComponent<A extends Object = DefaultProps>(configIn: Partial<StaticConfig> | StaticConfigParsed): StaticComponent<A, void, StaticConfigParsed, any>;
|
|
6
6
|
export declare const Spacer: StaticComponent<{
|
|
7
|
-
size?: number | undefined;
|
|
7
|
+
size?: number | `$${string}` | `$${number}` | undefined;
|
|
8
8
|
flex?: number | boolean | undefined;
|
|
9
9
|
}, void, StaticConfigParsed, any>;
|
|
10
|
-
export declare function spacedChildren({ children, space, flexDirection, }: {
|
|
10
|
+
export declare function spacedChildren({ isZStack, children, space, flexDirection, }: {
|
|
11
|
+
isZStack?: boolean;
|
|
11
12
|
children: any;
|
|
12
13
|
space?: any;
|
|
13
14
|
flexDirection?: ViewStyle['flexDirection'];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createComponent.d.ts","sourceRoot":"","sources":["../src/createComponent.tsx"],"names":[],"mappings":"AAaA,OAAO,EAA0B,SAAS,EAAE,MAAM,cAAc,CAAA;AAWhE,OAAO,EAEL,eAAe,EACf,YAAY,EACZ,kBAAkB,EAEnB,MAAM,SAAS,CAAA;AAIhB,eAAO,MAAM,QAAQ,eAAsB,CAAA;AAS3C,aAAK,YAAY,GAAG,EAAE,CAAA;AAEtB,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,GAAG,YAAY,EAC7D,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,kBAAkB,qDAudrD;AAOD,eAAO,MAAM,MAAM;;;iCAyBjB,CAAA;AAEF,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,aAAa,GACd,EAAE;IACD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,EAAE,GAAG,CAAA;IACb,KAAK,CAAC,EAAE,GAAG,CAAA;IACX,aAAa,CAAC,EAAE,SAAS,CAAC,eAAe,CAAC,CAAA;CAC3C,OAwCA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFont.d.ts","sourceRoot":"","sources":["../src/createFont.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAErC,eAAO,MAAM,UAAU,uCA2BtB,CAAA"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createShorthands.d.ts","sourceRoot":"","sources":["../src/createShorthands.ts"],"names":[],"mappings":"AAEA,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC,GAAG,CAAC,CAEnF"}
|