@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,458 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { concatClassName, stylePropsView } from "@tamagui/helpers";
|
|
4
|
+
import { useForceUpdate } from "@tamagui/use-force-update";
|
|
5
|
+
import {
|
|
6
|
+
Children,
|
|
7
|
+
Fragment,
|
|
8
|
+
createElement,
|
|
9
|
+
forwardRef,
|
|
10
|
+
useCallback,
|
|
11
|
+
useContext,
|
|
12
|
+
useEffect,
|
|
13
|
+
useRef,
|
|
14
|
+
useState
|
|
15
|
+
} from "react";
|
|
16
|
+
import { StyleSheet, Text, View } from "react-native";
|
|
17
|
+
import { stackDefaultStyles } from "./constants/constants";
|
|
18
|
+
import { isTouchDevice, isWeb } from "./constants/platform";
|
|
19
|
+
import { rnw } from "./constants/rnw";
|
|
20
|
+
import { onConfiguredOnce } from "./createTamagui";
|
|
21
|
+
import { addStylesUsingClassname, useStylesAsClassname } from "./helpers/addStylesUsingClassname";
|
|
22
|
+
import { extendStaticConfig, parseStaticConfig } from "./helpers/extendStaticConfig";
|
|
23
|
+
import { getSplitStyles } from "./helpers/getSplitStyles";
|
|
24
|
+
import { useFeatures } from "./hooks/useFeatures";
|
|
25
|
+
import { usePressable } from "./hooks/usePressable";
|
|
26
|
+
import { TextAncestorContext } from "./views/TextAncestorContext";
|
|
27
|
+
import { ThemeManagerContext } from "./views/ThemeManagerContext";
|
|
28
|
+
const mouseUps = new Set();
|
|
29
|
+
if (typeof document !== "undefined") {
|
|
30
|
+
document.addEventListener("mouseup", () => {
|
|
31
|
+
mouseUps.forEach((x) => x());
|
|
32
|
+
mouseUps.clear();
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function createComponent(configIn) {
|
|
36
|
+
let staticConfig;
|
|
37
|
+
if ("parsed" in configIn) {
|
|
38
|
+
staticConfig = configIn;
|
|
39
|
+
} else {
|
|
40
|
+
staticConfig = parseStaticConfig(configIn);
|
|
41
|
+
}
|
|
42
|
+
const { Component, validStyles, isText, isZStack } = staticConfig;
|
|
43
|
+
const validStyleProps = validStyles ?? stylePropsView;
|
|
44
|
+
let defaultProps = null;
|
|
45
|
+
let tamaguiConfig;
|
|
46
|
+
let defaultsStyle;
|
|
47
|
+
let defaultsClassName = "";
|
|
48
|
+
let initialTheme;
|
|
49
|
+
const component = forwardRef((props, forwardedRef) => {
|
|
50
|
+
const forceUpdate = useForceUpdate();
|
|
51
|
+
const features = useFeatures(props, { forceUpdate });
|
|
52
|
+
const manager = useContext(ThemeManagerContext);
|
|
53
|
+
const [state, set_] = useState(() => ({
|
|
54
|
+
hover: false,
|
|
55
|
+
press: false,
|
|
56
|
+
pressIn: false,
|
|
57
|
+
theme: manager.name
|
|
58
|
+
}));
|
|
59
|
+
const set = /* @__PURE__ */ __name((next) => set_((prev) => {
|
|
60
|
+
for (const key in next) {
|
|
61
|
+
if (prev[key] !== next[key]) {
|
|
62
|
+
return { ...prev, ...next };
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return prev;
|
|
66
|
+
}), "set");
|
|
67
|
+
if (process.env.NODE_ENV === "development" && !isText && isWeb) {
|
|
68
|
+
Children.toArray(props.children).forEach((item) => {
|
|
69
|
+
if (typeof item === "string") {
|
|
70
|
+
console.error(`Unexpected text node: ${item}. A text node cannot be a child of a <View>.`);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
const hasTextAncestor = isWeb ? useContext(TextAncestorContext) : false;
|
|
75
|
+
const hostRef = useRef(null);
|
|
76
|
+
const theme = manager.theme || initialTheme;
|
|
77
|
+
const {
|
|
78
|
+
viewProps: viewPropsIn,
|
|
79
|
+
pseudos,
|
|
80
|
+
style,
|
|
81
|
+
classNames
|
|
82
|
+
} = getSplitStyles(props, staticConfig, theme);
|
|
83
|
+
const {
|
|
84
|
+
tag,
|
|
85
|
+
hitSlop,
|
|
86
|
+
children,
|
|
87
|
+
pointerEvents,
|
|
88
|
+
onPress,
|
|
89
|
+
onPressIn,
|
|
90
|
+
onPressOut,
|
|
91
|
+
onHoverIn,
|
|
92
|
+
onHoverOut,
|
|
93
|
+
space,
|
|
94
|
+
disabled,
|
|
95
|
+
onMouseEnter,
|
|
96
|
+
onMouseLeave,
|
|
97
|
+
hrefAttrs,
|
|
98
|
+
onMoveShouldSetResponder,
|
|
99
|
+
onMoveShouldSetResponderCapture,
|
|
100
|
+
onResponderEnd,
|
|
101
|
+
onResponderGrant,
|
|
102
|
+
onResponderMove,
|
|
103
|
+
onResponderReject,
|
|
104
|
+
onResponderRelease,
|
|
105
|
+
onResponderStart,
|
|
106
|
+
onResponderTerminate,
|
|
107
|
+
onResponderTerminationRequest,
|
|
108
|
+
onScrollShouldSetResponder,
|
|
109
|
+
onScrollShouldSetResponderCapture,
|
|
110
|
+
onSelectionChangeShouldSetResponder,
|
|
111
|
+
onSelectionChangeShouldSetResponderCapture,
|
|
112
|
+
onStartShouldSetResponder,
|
|
113
|
+
onStartShouldSetResponderCapture,
|
|
114
|
+
onMouseDown,
|
|
115
|
+
onClick,
|
|
116
|
+
accessible,
|
|
117
|
+
accessibilityRole,
|
|
118
|
+
onLayout,
|
|
119
|
+
...viewProps
|
|
120
|
+
} = viewPropsIn;
|
|
121
|
+
if (!isWeb) {
|
|
122
|
+
if (accessible)
|
|
123
|
+
viewProps.accessible = accessible;
|
|
124
|
+
if (accessibilityRole)
|
|
125
|
+
viewProps.accessibilityRole = accessibilityRole;
|
|
126
|
+
}
|
|
127
|
+
if (isWeb) {
|
|
128
|
+
rnw.useResponderEvents(hostRef, {
|
|
129
|
+
onMoveShouldSetResponder,
|
|
130
|
+
onMoveShouldSetResponderCapture,
|
|
131
|
+
onResponderEnd,
|
|
132
|
+
onResponderGrant,
|
|
133
|
+
onResponderMove,
|
|
134
|
+
onResponderReject,
|
|
135
|
+
onResponderRelease,
|
|
136
|
+
onResponderStart,
|
|
137
|
+
onResponderTerminate,
|
|
138
|
+
onResponderTerminationRequest,
|
|
139
|
+
onScrollShouldSetResponder,
|
|
140
|
+
onScrollShouldSetResponderCapture,
|
|
141
|
+
onSelectionChangeShouldSetResponder,
|
|
142
|
+
onSelectionChangeShouldSetResponderCapture,
|
|
143
|
+
onStartShouldSetResponder,
|
|
144
|
+
onStartShouldSetResponderCapture
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
const isTracking = useRef(false);
|
|
148
|
+
const internal = useRef();
|
|
149
|
+
if (!internal.current) {
|
|
150
|
+
internal.current = {
|
|
151
|
+
isMounted: true
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
useEffect(() => {
|
|
155
|
+
internal.current.isMounted = true;
|
|
156
|
+
const dispose = manager?.onChangeTheme((name) => {
|
|
157
|
+
if (isTracking.current) {
|
|
158
|
+
set({ theme: name });
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
return () => {
|
|
162
|
+
dispose();
|
|
163
|
+
mouseUps.delete(unPress);
|
|
164
|
+
isTracking.current = false;
|
|
165
|
+
internal.current.isMounted = false;
|
|
166
|
+
};
|
|
167
|
+
}, [manager]);
|
|
168
|
+
const element = isWeb ? !Component || typeof Component === "string" ? tag || Component : Component : Component;
|
|
169
|
+
const ReactView = !isWeb ? View : element || (hasTextAncestor ? "span" : "div");
|
|
170
|
+
const ReactText = !isWeb ? Text : element || "span";
|
|
171
|
+
const ViewComponent = isText ? ReactText : ReactView;
|
|
172
|
+
const isHovering = !isTouchDevice && !disabled && pseudos && state.hover;
|
|
173
|
+
const isPressing = !disabled && pseudos && state.press;
|
|
174
|
+
const styles = [
|
|
175
|
+
style,
|
|
176
|
+
isHovering ? pseudos.hoverStyle || null : null,
|
|
177
|
+
isPressing ? pseudos.pressStyle || null : null
|
|
178
|
+
];
|
|
179
|
+
if (isWeb) {
|
|
180
|
+
const stylesClassNames = useStylesAsClassname(styles);
|
|
181
|
+
const classList = isText ? [
|
|
182
|
+
defaultsClassName,
|
|
183
|
+
classNames,
|
|
184
|
+
stylesClassNames,
|
|
185
|
+
props.className
|
|
186
|
+
] : [defaultsClassName, props.className, classNames, stylesClassNames];
|
|
187
|
+
const className = concatClassName(...classList);
|
|
188
|
+
if (process.env.NODE_ENV === "development") {
|
|
189
|
+
if (props["debug"]) {
|
|
190
|
+
console.log("\u{1F95A} className", { style, styles, classList, stylesClassNames, className });
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
viewProps.className = className;
|
|
194
|
+
} else {
|
|
195
|
+
viewProps.style = styles;
|
|
196
|
+
}
|
|
197
|
+
if (pointerEvents) {
|
|
198
|
+
viewProps.pointerEvents = pointerEvents;
|
|
199
|
+
}
|
|
200
|
+
if (isWeb) {
|
|
201
|
+
const platformMethodsRef = rnw.usePlatformMethods(viewProps);
|
|
202
|
+
const setRef = rnw.useMergeRefs(hostRef, platformMethodsRef, forwardedRef);
|
|
203
|
+
viewProps.ref = setRef;
|
|
204
|
+
if (props.href != null && hrefAttrs != null) {
|
|
205
|
+
const { download, rel, target } = hrefAttrs;
|
|
206
|
+
if (download != null) {
|
|
207
|
+
viewProps.download = download;
|
|
208
|
+
}
|
|
209
|
+
if (rel != null) {
|
|
210
|
+
viewProps.rel = rel;
|
|
211
|
+
}
|
|
212
|
+
if (typeof target === "string") {
|
|
213
|
+
viewProps.target = target.charAt(0) !== "_" ? "_" + target : target;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
} else {
|
|
217
|
+
if (forwardedRef) {
|
|
218
|
+
viewProps.ref = forwardedRef;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
const attachPress = !!(pseudos && pseudos.pressStyle || onPress || onPressOut || onPressIn || onClick);
|
|
222
|
+
const attachHover = isWeb && !isTouchDevice && !!(pseudos && pseudos.hoverStyle || onHoverIn || onHoverOut || onMouseEnter || onMouseLeave);
|
|
223
|
+
const shouldAttach = internal.current.hasEverHadEvents || attachPress || attachHover || "pressStyle" in props || "onPress" in props || "onPressIn" in props || "onPressOut" in props || isWeb && ("hoverStyle" in props || "onClick" in props || "onHoverIn" in props || "onHoverOut" in props || "onMouseEnter" in props || "onMouseLeave" in props);
|
|
224
|
+
if (shouldAttach) {
|
|
225
|
+
internal.current.hasEverHadEvents = true;
|
|
226
|
+
}
|
|
227
|
+
const unPress = useCallback(() => {
|
|
228
|
+
if (!internal.current.isMounted)
|
|
229
|
+
return;
|
|
230
|
+
set({
|
|
231
|
+
press: false,
|
|
232
|
+
pressIn: false
|
|
233
|
+
});
|
|
234
|
+
}, []);
|
|
235
|
+
const events = shouldAttach ? {
|
|
236
|
+
...!isWeb && {
|
|
237
|
+
onPressOut: (e) => {
|
|
238
|
+
unPress();
|
|
239
|
+
onPressOut?.(e);
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
...isWeb && !isTouchDevice && {
|
|
243
|
+
onMouseEnter: attachHover || attachPress ? (e) => {
|
|
244
|
+
let next = {};
|
|
245
|
+
if (attachHover) {
|
|
246
|
+
next.hover = true;
|
|
247
|
+
}
|
|
248
|
+
if (state.pressIn) {
|
|
249
|
+
next.press = true;
|
|
250
|
+
}
|
|
251
|
+
if (Object.keys(next).length) {
|
|
252
|
+
set(next);
|
|
253
|
+
}
|
|
254
|
+
onHoverIn?.(e);
|
|
255
|
+
onMouseEnter?.(e);
|
|
256
|
+
} : void 0,
|
|
257
|
+
onMouseLeave: attachHover || attachPress ? (e) => {
|
|
258
|
+
let next = {};
|
|
259
|
+
mouseUps.add(unPress);
|
|
260
|
+
if (attachHover) {
|
|
261
|
+
next.hover = false;
|
|
262
|
+
}
|
|
263
|
+
if (state.pressIn) {
|
|
264
|
+
next.press = false;
|
|
265
|
+
next.pressIn = false;
|
|
266
|
+
}
|
|
267
|
+
if (Object.keys(next).length) {
|
|
268
|
+
set(next);
|
|
269
|
+
}
|
|
270
|
+
onHoverOut?.(e);
|
|
271
|
+
onMouseLeave?.(e);
|
|
272
|
+
} : void 0
|
|
273
|
+
},
|
|
274
|
+
onMouseDown: attachPress ? (e) => {
|
|
275
|
+
set({
|
|
276
|
+
press: true,
|
|
277
|
+
pressIn: true
|
|
278
|
+
});
|
|
279
|
+
onPressIn?.(e);
|
|
280
|
+
onMouseDown?.(e);
|
|
281
|
+
} : onPressIn,
|
|
282
|
+
onClick: attachPress ? (e) => {
|
|
283
|
+
onPress?.(e);
|
|
284
|
+
onClick?.(e);
|
|
285
|
+
unPress();
|
|
286
|
+
onPressOut?.(e);
|
|
287
|
+
} : onPressOut
|
|
288
|
+
} : null;
|
|
289
|
+
if (events) {
|
|
290
|
+
if (typeof ViewComponent !== "string") {
|
|
291
|
+
const [pressProps] = usePressable({
|
|
292
|
+
disabled,
|
|
293
|
+
hitSlop,
|
|
294
|
+
onPressIn: events.onMouseDown,
|
|
295
|
+
onPressOut: events.onPressOut,
|
|
296
|
+
onPress: events.onClick
|
|
297
|
+
});
|
|
298
|
+
Object.assign(viewProps, pressProps);
|
|
299
|
+
} else {
|
|
300
|
+
Object.assign(viewProps, events);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
const childEls = spacedChildren({
|
|
304
|
+
children,
|
|
305
|
+
space,
|
|
306
|
+
flexDirection: props.flexDirection || defaultProps?.flexDirection,
|
|
307
|
+
isZStack
|
|
308
|
+
});
|
|
309
|
+
let content;
|
|
310
|
+
if (isWeb && rnw) {
|
|
311
|
+
const domProps = rnw.createDOMProps(viewProps);
|
|
312
|
+
const className = domProps.className && domProps.className !== viewProps.className ? `${domProps.className} ${viewProps.className}` : viewProps.className;
|
|
313
|
+
Object.assign(viewProps, domProps);
|
|
314
|
+
viewProps.className = className;
|
|
315
|
+
content = createElement(ViewComponent, viewProps, childEls);
|
|
316
|
+
} else {
|
|
317
|
+
content = createElement(ViewComponent, viewProps, childEls);
|
|
318
|
+
}
|
|
319
|
+
const shouldWrapTextAncestor = isWeb && isText && !hasTextAncestor;
|
|
320
|
+
if (shouldWrapTextAncestor) {
|
|
321
|
+
content = createElement(TextAncestorContext.Provider, { value: true }, content);
|
|
322
|
+
}
|
|
323
|
+
if (process.env.NODE_ENV === "development") {
|
|
324
|
+
if (props["debug"]) {
|
|
325
|
+
viewProps["debug"] = true;
|
|
326
|
+
console.log("\u{1F95A} props in:", props);
|
|
327
|
+
console.log("\u{1F95A} props out:", viewProps);
|
|
328
|
+
console.log(props.onClick?.toString());
|
|
329
|
+
console.log("\u{1F95A} etc:", { shouldAttach, ViewComponent, viewProps, styles, pseudos, content, childEls });
|
|
330
|
+
if (isWeb) {
|
|
331
|
+
console.log("\u{1F95A} component info", { staticConfig, tamaguiConfig });
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return <>
|
|
336
|
+
{features}
|
|
337
|
+
{content}
|
|
338
|
+
</>;
|
|
339
|
+
});
|
|
340
|
+
onConfiguredOnce((conf) => {
|
|
341
|
+
tamaguiConfig = conf;
|
|
342
|
+
initialTheme = conf.themes[conf.defaultTheme || Object.keys(conf.themes)[0]];
|
|
343
|
+
const next = getSplitStyles(staticConfig.defaultProps, staticConfig, initialTheme, true);
|
|
344
|
+
if (isWeb) {
|
|
345
|
+
if (next.classNames) {
|
|
346
|
+
defaultsClassName += next.classNames + " ";
|
|
347
|
+
}
|
|
348
|
+
defaultsClassName += addStylesUsingClassname([next.style, next.pseudos]);
|
|
349
|
+
} else {
|
|
350
|
+
if (!hasWarnedOnce) {
|
|
351
|
+
hasWarnedOnce = true;
|
|
352
|
+
console.log("\u26A0\uFE0F TODO account for default styles for media queries");
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
component.defaultProps = {
|
|
356
|
+
...next.viewProps,
|
|
357
|
+
...component.defaultProps
|
|
358
|
+
};
|
|
359
|
+
if (process.env.NODE_ENV === "development") {
|
|
360
|
+
if (staticConfig.defaultProps?.debug) {
|
|
361
|
+
console.log("tamagui debug component:", next, defaultsClassName, component.defaultProps);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
component["staticConfig"] = {
|
|
366
|
+
validStyles: validStyleProps,
|
|
367
|
+
...staticConfig
|
|
368
|
+
};
|
|
369
|
+
const res = component;
|
|
370
|
+
res["extractable"] = (Component2, conf) => {
|
|
371
|
+
Component2["staticConfig"] = extendStaticConfig(res, {
|
|
372
|
+
...conf,
|
|
373
|
+
neverFlatten: true,
|
|
374
|
+
defaultProps: {
|
|
375
|
+
...Component2.defaultProps,
|
|
376
|
+
...conf?.defaultProps
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
return Component2;
|
|
380
|
+
};
|
|
381
|
+
return res;
|
|
382
|
+
}
|
|
383
|
+
__name(createComponent, "createComponent");
|
|
384
|
+
let hasWarnedOnce = false;
|
|
385
|
+
const Spacer = createComponent({
|
|
386
|
+
defaultProps: {
|
|
387
|
+
...stackDefaultStyles,
|
|
388
|
+
size: true
|
|
389
|
+
},
|
|
390
|
+
variants: {
|
|
391
|
+
size: {
|
|
392
|
+
"...size": (size, { tokens }) => {
|
|
393
|
+
size = size == true ? "$true" : size;
|
|
394
|
+
return {
|
|
395
|
+
width: tokens.size[size] ?? size,
|
|
396
|
+
height: tokens.size[size] ?? size
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
direction: {
|
|
401
|
+
horizontal: {
|
|
402
|
+
height: 0
|
|
403
|
+
},
|
|
404
|
+
vertical: {
|
|
405
|
+
width: 0
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
function spacedChildren({
|
|
411
|
+
isZStack,
|
|
412
|
+
children,
|
|
413
|
+
space,
|
|
414
|
+
flexDirection
|
|
415
|
+
}) {
|
|
416
|
+
if (!space && !isZStack) {
|
|
417
|
+
return children;
|
|
418
|
+
}
|
|
419
|
+
const childrenList = Children.toArray(children);
|
|
420
|
+
const len = childrenList.length;
|
|
421
|
+
if (len === 1) {
|
|
422
|
+
return children;
|
|
423
|
+
}
|
|
424
|
+
const next = [];
|
|
425
|
+
for (const [index, child] of childrenList.entries()) {
|
|
426
|
+
if (child === null || child === void 0) {
|
|
427
|
+
continue;
|
|
428
|
+
}
|
|
429
|
+
const key = `${child?.["key"] ?? index}`;
|
|
430
|
+
next.push(<Fragment key={key}>{isZStack ? <Absolute>{child}</Absolute> : child}</Fragment>);
|
|
431
|
+
if (child?.["type"]?.["isVisuallyHidden"]) {
|
|
432
|
+
continue;
|
|
433
|
+
}
|
|
434
|
+
if (index !== len - 1) {
|
|
435
|
+
if (space) {
|
|
436
|
+
next.push(<Spacer key={`${key}_spacer`} direction={flexDirection === "row" || flexDirection === "row-reverse" ? "horizontal" : "vertical"} size={space} />);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
return next;
|
|
441
|
+
}
|
|
442
|
+
__name(spacedChildren, "spacedChildren");
|
|
443
|
+
const Absolute = /* @__PURE__ */ __name(({ children }) => <View style={sheet.fullscreen}>{children}</View>, "Absolute");
|
|
444
|
+
const sheet = StyleSheet.create({
|
|
445
|
+
fullscreen: {
|
|
446
|
+
position: "absolute",
|
|
447
|
+
top: 0,
|
|
448
|
+
left: 0,
|
|
449
|
+
right: 0,
|
|
450
|
+
bottom: 0
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
export {
|
|
454
|
+
Spacer,
|
|
455
|
+
createComponent,
|
|
456
|
+
mouseUps,
|
|
457
|
+
spacedChildren
|
|
458
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { validateFont } from "./helpers/validate";
|
|
4
|
+
const createFont = /* @__PURE__ */ __name((font) => {
|
|
5
|
+
if (process.env.NODE_ENV === "development") {
|
|
6
|
+
validateFont(font);
|
|
7
|
+
}
|
|
8
|
+
const sizeKeys = Object.keys(font.size);
|
|
9
|
+
for (const key in font) {
|
|
10
|
+
if (key === "size" || key === "family")
|
|
11
|
+
continue;
|
|
12
|
+
const section = font[key];
|
|
13
|
+
const keys = Object.keys(section);
|
|
14
|
+
let fillVal = section[keys[0]];
|
|
15
|
+
for (const sKey of sizeKeys) {
|
|
16
|
+
if (!(sKey in section)) {
|
|
17
|
+
section[sKey] = fillVal;
|
|
18
|
+
} else {
|
|
19
|
+
fillVal = section[sKey];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return Object.freeze(font);
|
|
24
|
+
}, "createFont");
|
|
25
|
+
export {
|
|
26
|
+
createFont
|
|
27
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
function createShorthands(shorthands) {
|
|
4
|
+
return Object.freeze(shorthands);
|
|
5
|
+
}
|
|
6
|
+
__name(createShorthands, "createShorthands");
|
|
7
|
+
export {
|
|
8
|
+
createShorthands
|
|
9
|
+
};
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { getStyleRules } from "@tamagui/helpers";
|
|
4
|
+
import { Variable, createVariable, isVariable } from "./createVariable";
|
|
5
|
+
import { createTamaguiProvider } from "./helpers/createTamaguiProvider";
|
|
6
|
+
import { validateConfig } from "./helpers/validate";
|
|
7
|
+
import { configureMedia } from "./hooks/useMedia";
|
|
8
|
+
let conf;
|
|
9
|
+
const getHasConfigured = /* @__PURE__ */ __name(() => !!conf, "getHasConfigured");
|
|
10
|
+
const getTamagui = /* @__PURE__ */ __name(() => conf, "getTamagui");
|
|
11
|
+
const getTokens = /* @__PURE__ */ __name(() => conf.tokensParsed, "getTokens");
|
|
12
|
+
const getThemes = /* @__PURE__ */ __name(() => conf.themes, "getThemes");
|
|
13
|
+
const configListeners = new Set();
|
|
14
|
+
const onConfiguredOnce = /* @__PURE__ */ __name((cb) => {
|
|
15
|
+
if (conf) {
|
|
16
|
+
cb(conf);
|
|
17
|
+
} else {
|
|
18
|
+
configListeners.add(cb);
|
|
19
|
+
}
|
|
20
|
+
}, "onConfiguredOnce");
|
|
21
|
+
const PREFIX = `theme--`;
|
|
22
|
+
function createTamagui(config) {
|
|
23
|
+
if (process.env.NODE_ENV === "development") {
|
|
24
|
+
if (!config["parsed"]) {
|
|
25
|
+
validateConfig(config);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (conf) {
|
|
29
|
+
console.warn("Called createTamagui twice! Should never do so");
|
|
30
|
+
}
|
|
31
|
+
configureMedia({
|
|
32
|
+
queries: config.media,
|
|
33
|
+
defaultActive: config.mediaQueryDefaultActive
|
|
34
|
+
});
|
|
35
|
+
const themeConfig = (() => {
|
|
36
|
+
let cssRules = [];
|
|
37
|
+
let tokenRule = `:root {`;
|
|
38
|
+
const varsByValue = new Map();
|
|
39
|
+
const addVar = /* @__PURE__ */ __name((v) => {
|
|
40
|
+
varsByValue[v.val] = v;
|
|
41
|
+
const rule = `--${v.name}:${typeof v.val === "number" ? `${v.val}px` : v.val};`;
|
|
42
|
+
tokenRule += rule;
|
|
43
|
+
}, "addVar");
|
|
44
|
+
for (const key in config.tokens) {
|
|
45
|
+
for (const skey in config.tokens[key]) {
|
|
46
|
+
const val = config.tokens[key][skey];
|
|
47
|
+
if (key === "font") {
|
|
48
|
+
for (const fkey in val) {
|
|
49
|
+
if (fkey === "family") {
|
|
50
|
+
addVar(val[fkey]);
|
|
51
|
+
} else {
|
|
52
|
+
for (const fskey in val[fkey]) {
|
|
53
|
+
addVar(val[fkey][fskey]);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
addVar(val);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
cssRules.push(`${tokenRule}
|
|
63
|
+
}`);
|
|
64
|
+
for (const themeName in config.themes) {
|
|
65
|
+
config.themes[themeName] = { ...config.themes[themeName] };
|
|
66
|
+
const theme = config.themes[themeName];
|
|
67
|
+
let vars = "";
|
|
68
|
+
for (const themeKey in theme) {
|
|
69
|
+
const val = theme[themeKey];
|
|
70
|
+
const getVariableCSS = /* @__PURE__ */ __name((inv) => {
|
|
71
|
+
const v = varsByValue[inv] ?? inv;
|
|
72
|
+
return isVariable(v) ? `--${themeKey}:var(--${v.name});` : `--${themeKey}:${v};`;
|
|
73
|
+
}, "getVariableCSS");
|
|
74
|
+
vars += getVariableCSS(val);
|
|
75
|
+
if (!isVariable(val)) {
|
|
76
|
+
theme[themeKey] = createVariable({
|
|
77
|
+
name: themeKey,
|
|
78
|
+
val
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const [themeClassName, parentName] = themeName.includes("-") ? themeName.split("-") : [themeName, ""];
|
|
83
|
+
const oppositeName = parentName === "dark" ? "light" : "dark";
|
|
84
|
+
const cssParentSel = parentName ? `.${PREFIX}${parentName}` : "";
|
|
85
|
+
const cssChildSel = `.${PREFIX}${themeClassName}`;
|
|
86
|
+
const cssSel = `${cssParentSel} ${cssChildSel}`;
|
|
87
|
+
const cssRule = `${cssSel}, .${PREFIX}${oppositeName} ${cssSel} {
|
|
88
|
+
${vars}
|
|
89
|
+
}`;
|
|
90
|
+
cssRules.push(cssRule);
|
|
91
|
+
}
|
|
92
|
+
Object.freeze(cssRules);
|
|
93
|
+
return {
|
|
94
|
+
cssRules,
|
|
95
|
+
css: cssRules.join("\n")
|
|
96
|
+
};
|
|
97
|
+
})();
|
|
98
|
+
const tokensParsed = parseTokens(config.tokens);
|
|
99
|
+
const themeParsed = {};
|
|
100
|
+
const firstKey = Object.keys(config.themes)[0];
|
|
101
|
+
for (const key in config.themes[firstKey]) {
|
|
102
|
+
const val = config.themes[firstKey][key].val;
|
|
103
|
+
themeParsed[`$${key}`] = new Variable({ val, name: key });
|
|
104
|
+
}
|
|
105
|
+
const next = {
|
|
106
|
+
shorthands: {},
|
|
107
|
+
...config,
|
|
108
|
+
Provider: createTamaguiProvider({
|
|
109
|
+
defaultTheme: "light",
|
|
110
|
+
...config
|
|
111
|
+
}),
|
|
112
|
+
themeConfig,
|
|
113
|
+
themeParsed,
|
|
114
|
+
tokensParsed,
|
|
115
|
+
parsed: true,
|
|
116
|
+
getCSS() {
|
|
117
|
+
return `${themeConfig.css}
|
|
118
|
+
${[...getStyleRules()].join("\n")}`;
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
conf = next;
|
|
122
|
+
if (configListeners.size) {
|
|
123
|
+
configListeners.forEach((cb) => cb(next));
|
|
124
|
+
configListeners.clear();
|
|
125
|
+
}
|
|
126
|
+
return next;
|
|
127
|
+
}
|
|
128
|
+
__name(createTamagui, "createTamagui");
|
|
129
|
+
function getThemeParentClassName(themeName) {
|
|
130
|
+
return `theme-parent ${themeName ? `${PREFIX}${themeName}` : ""}`;
|
|
131
|
+
}
|
|
132
|
+
__name(getThemeParentClassName, "getThemeParentClassName");
|
|
133
|
+
const parseTokens = /* @__PURE__ */ __name((tokens) => {
|
|
134
|
+
const res = {};
|
|
135
|
+
for (const key in tokens) {
|
|
136
|
+
res[key] = {};
|
|
137
|
+
if (key === "font") {
|
|
138
|
+
for (const family in tokens.font) {
|
|
139
|
+
const obj = {};
|
|
140
|
+
res.font[`$${family}`] = obj;
|
|
141
|
+
for (const attrKey in tokens.font[family]) {
|
|
142
|
+
const attr = tokens.font[family][attrKey];
|
|
143
|
+
if (attrKey === "family") {
|
|
144
|
+
obj[attrKey] = attr;
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
obj[attrKey] = Object.keys(attr).reduce((acc, cur) => {
|
|
148
|
+
acc[`$${cur}`] = attr[cur];
|
|
149
|
+
return acc;
|
|
150
|
+
}, {});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
for (const skey in tokens[key]) {
|
|
156
|
+
res[key][`$${skey}`] = tokens[key][skey];
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return res;
|
|
160
|
+
}, "parseTokens");
|
|
161
|
+
export {
|
|
162
|
+
createTamagui,
|
|
163
|
+
getHasConfigured,
|
|
164
|
+
getTamagui,
|
|
165
|
+
getThemeParentClassName,
|
|
166
|
+
getThemes,
|
|
167
|
+
getTokens,
|
|
168
|
+
onConfiguredOnce
|
|
169
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { Variable, createVariable } from "./createVariable";
|
|
4
|
+
const createTheme = /* @__PURE__ */ __name((theme) => {
|
|
5
|
+
const res = {};
|
|
6
|
+
for (const key in theme) {
|
|
7
|
+
const val = theme[key];
|
|
8
|
+
if (!(val instanceof Variable)) {
|
|
9
|
+
res[key] = createVariable({
|
|
10
|
+
name: key,
|
|
11
|
+
val
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return res;
|
|
16
|
+
}, "createTheme");
|
|
17
|
+
export {
|
|
18
|
+
createTheme
|
|
19
|
+
};
|