@tamagui/core 1.0.0-beta.8 → 1.0.1-beta.100
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/Pressability.js +28 -0
- package/dist/cjs/Pressability.js.map +7 -0
- package/dist/cjs/Pressability.native.js +28 -0
- package/dist/cjs/Pressability.native.js.map +7 -0
- package/dist/cjs/Tamagui.js +6 -8
- package/dist/cjs/Tamagui.js.map +2 -2
- package/dist/cjs/ThemeManager.js +25 -32
- package/dist/cjs/ThemeManager.js.map +2 -2
- package/dist/cjs/conf.js +20 -15
- package/dist/cjs/conf.js.map +2 -2
- package/dist/cjs/constants/constants.js +1 -1
- package/dist/cjs/constants/constants.js.map +1 -1
- package/dist/cjs/constants/platform.js +8 -8
- package/dist/cjs/constants/platform.js.map +2 -2
- package/dist/cjs/constants/rnw.js +5 -19
- package/dist/cjs/constants/rnw.js.map +2 -2
- package/dist/cjs/constants/rnw.native.js +28 -0
- package/dist/cjs/constants/rnw.native.js.map +7 -0
- package/dist/cjs/createComponent.js +612 -295
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/createFont.js +2 -3
- package/dist/cjs/createFont.js.map +2 -2
- package/dist/cjs/createShorthands.js +0 -2
- package/dist/cjs/createShorthands.js.map +1 -1
- package/dist/cjs/createTamagui.js +147 -100
- package/dist/cjs/createTamagui.js.map +2 -2
- package/dist/cjs/createTheme.js +3 -2
- package/dist/cjs/createTheme.js.map +2 -2
- package/dist/cjs/createTokens.js +4 -21
- package/dist/cjs/createTokens.js.map +2 -2
- package/dist/cjs/createVariable.js +39 -14
- package/dist/cjs/createVariable.js.map +2 -2
- package/dist/cjs/createVariables.js +55 -0
- package/dist/cjs/createVariables.js.map +7 -0
- package/dist/cjs/helpers/areEqualSets.js +2 -3
- package/dist/cjs/helpers/areEqualSets.js.map +1 -1
- package/dist/cjs/helpers/assignNativePropsToWeb.js +187 -0
- package/dist/cjs/helpers/assignNativePropsToWeb.js.map +7 -0
- package/dist/cjs/helpers/assignNativePropsToWeb.native.js +29 -0
- package/dist/cjs/helpers/assignNativePropsToWeb.native.js.map +7 -0
- package/dist/cjs/helpers/calc.js +70 -0
- package/dist/cjs/helpers/calc.js.map +7 -0
- package/dist/cjs/helpers/createMediaStyle.js +4 -4
- package/dist/cjs/helpers/createMediaStyle.js.map +2 -2
- package/dist/cjs/helpers/createPropMapper.js +133 -113
- package/dist/cjs/helpers/createPropMapper.js.map +2 -2
- package/dist/cjs/helpers/createShallowUpdate.js +3 -4
- package/dist/cjs/helpers/createShallowUpdate.js.map +2 -2
- package/dist/cjs/helpers/createTamaguiProvider.js +16 -18
- package/dist/cjs/helpers/createTamaguiProvider.js.map +2 -2
- package/dist/cjs/helpers/cssHash.js +50 -0
- package/dist/cjs/helpers/cssHash.js.map +7 -0
- package/dist/cjs/helpers/expandStyle.js +111 -0
- package/dist/cjs/helpers/expandStyle.js.map +7 -0
- package/dist/cjs/helpers/expandStyles.js +126 -0
- package/dist/cjs/helpers/expandStyles.js.map +7 -0
- package/dist/cjs/helpers/extendStaticConfig.js +25 -17
- package/dist/cjs/helpers/extendStaticConfig.js.map +2 -2
- package/dist/cjs/helpers/fixNativeShadow.js +2 -3
- package/dist/cjs/helpers/fixNativeShadow.js.map +1 -1
- package/dist/cjs/helpers/getExpandedShorthands.js +0 -2
- package/dist/cjs/helpers/getExpandedShorthands.js.map +1 -1
- package/dist/cjs/helpers/getFont.js +61 -0
- package/dist/cjs/helpers/getFont.js.map +7 -0
- package/dist/cjs/helpers/getSize.js +17 -9
- package/dist/cjs/helpers/getSize.js.map +2 -2
- package/dist/cjs/helpers/getSplitStyles.js +268 -168
- package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
- package/dist/cjs/helpers/getStackSize.js +45 -0
- package/dist/cjs/helpers/getStackSize.js.map +7 -0
- package/dist/cjs/helpers/getStylesAtomic.js +178 -118
- package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
- package/dist/cjs/helpers/getStylesAtomic.native.js +0 -2
- package/dist/cjs/helpers/getStylesAtomic.native.js.map +1 -1
- package/dist/cjs/helpers/getTextSize.js +3 -4
- package/dist/cjs/helpers/getTextSize.js.map +2 -2
- package/dist/cjs/helpers/getVariantExtras.js +46 -0
- package/dist/cjs/helpers/getVariantExtras.js.map +7 -0
- package/dist/cjs/helpers/insertStyleRule.js +55 -37
- package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
- package/dist/cjs/helpers/isObj.js +1 -2
- package/dist/cjs/helpers/isObj.js.map +1 -1
- package/dist/cjs/helpers/isTamaguiComponent.js +36 -0
- package/dist/cjs/helpers/isTamaguiComponent.js.map +7 -0
- package/dist/cjs/helpers/isTamaguiElement.js +4 -5
- package/dist/cjs/helpers/isTamaguiElement.js.map +2 -2
- package/dist/cjs/helpers/matchMedia.js +2 -3
- package/dist/cjs/helpers/matchMedia.js.map +1 -1
- package/dist/cjs/helpers/matchMedia.native.js +1 -2
- package/dist/cjs/helpers/matchMedia.native.js.map +1 -1
- package/dist/cjs/helpers/mergeProps.js +49 -0
- package/dist/cjs/helpers/mergeProps.js.map +7 -0
- package/dist/cjs/helpers/mergeTransform.js +41 -0
- package/dist/cjs/helpers/mergeTransform.js.map +7 -0
- package/dist/cjs/helpers/nativeGestureHandler.native.js +18 -0
- package/dist/cjs/helpers/nativeGestureHandler.native.js.map +7 -0
- package/dist/cjs/helpers/normalizeColor.js +76 -0
- package/dist/cjs/helpers/normalizeColor.js.map +7 -0
- package/dist/cjs/helpers/normalizeValueWithProperty.js +90 -0
- package/dist/cjs/helpers/normalizeValueWithProperty.js.map +7 -0
- package/dist/cjs/helpers/proxyThemeVariables.js +1 -3
- package/dist/cjs/helpers/proxyThemeVariables.js.map +1 -1
- package/dist/cjs/helpers/pseudoDescriptors.js +41 -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 +3 -5
- package/dist/cjs/helpers/themeable.js.map +2 -2
- package/dist/cjs/helpers/validate.js +39 -37
- package/dist/cjs/helpers/validate.js.map +2 -2
- package/dist/cjs/helpers/withStaticProperties.js +2 -3
- package/dist/cjs/helpers/withStaticProperties.js.map +1 -1
- package/dist/cjs/helpers/wrapThemeManagerContext.js +0 -2
- package/dist/cjs/helpers/wrapThemeManagerContext.js.map +2 -2
- package/dist/cjs/hooks/useConstant.js +0 -2
- package/dist/cjs/hooks/useConstant.js.map +1 -1
- package/dist/cjs/hooks/useFeatures.js +22 -20
- package/dist/cjs/hooks/useFeatures.js.map +2 -2
- package/dist/cjs/hooks/useId.js +5 -6
- package/dist/cjs/hooks/useId.js.map +2 -2
- package/dist/cjs/hooks/useIsMounted.js +2 -4
- package/dist/cjs/hooks/useIsMounted.js.map +2 -2
- package/dist/cjs/hooks/useIsTouchDevice.js +3 -4
- package/dist/cjs/hooks/useIsTouchDevice.js.map +2 -2
- package/dist/cjs/hooks/useMedia.js +11 -15
- package/dist/cjs/hooks/useMedia.js.map +1 -1
- package/dist/cjs/hooks/usePressable.js +2 -3
- package/dist/cjs/hooks/usePressable.js.map +1 -1
- package/dist/cjs/hooks/usePrevious.js +1 -0
- package/dist/cjs/hooks/usePrevious.js.map +7 -0
- package/dist/cjs/hooks/useTheme.js +21 -33
- package/dist/cjs/hooks/useTheme.js.map +2 -2
- package/dist/cjs/hooks/useUnmountEffect.js +0 -2
- package/dist/cjs/hooks/useUnmountEffect.js.map +1 -1
- package/dist/cjs/index.js +21 -12
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/insertFont.js +89 -0
- package/dist/cjs/insertFont.js.map +7 -0
- package/dist/cjs/static.js +3 -1
- package/dist/cjs/static.js.map +2 -2
- package/dist/cjs/styled.js +0 -3
- package/dist/cjs/styled.js.map +2 -2
- package/dist/cjs/types-rnw.js.map +1 -1
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/views/Slot.js +40 -26
- package/dist/cjs/views/Slot.js.map +2 -2
- package/dist/cjs/views/Text.js +11 -15
- package/dist/cjs/views/Text.js.map +2 -2
- package/dist/cjs/views/TextAncestorContext.js +4 -6
- package/dist/cjs/views/TextAncestorContext.js.map +2 -2
- package/dist/cjs/views/Theme.js +6 -9
- package/dist/cjs/views/Theme.js.map +2 -2
- package/dist/cjs/views/ThemeInverse.js +7 -5
- package/dist/cjs/views/ThemeInverse.js.map +2 -2
- package/dist/cjs/views/ThemeProvider.js +6 -6
- package/dist/cjs/views/ThemeProvider.js.map +2 -2
- package/dist/cjs/views/ThemeReset.js +3 -3
- package/dist/cjs/views/ThemeReset.js.map +2 -2
- package/dist/esm/Pressability.js +5 -0
- package/dist/esm/Pressability.js.map +7 -0
- package/dist/esm/Pressability.native.js +5 -0
- package/dist/esm/Pressability.native.js.map +7 -0
- package/dist/esm/Tamagui.js +5 -8
- package/dist/esm/Tamagui.js.map +2 -2
- package/dist/esm/ThemeManager.js +25 -33
- package/dist/esm/ThemeManager.js.map +2 -2
- package/dist/esm/conf.js +18 -15
- package/dist/esm/conf.js.map +2 -2
- package/dist/esm/constants/constants.js +24 -9
- package/dist/esm/constants/constants.js.map +2 -2
- package/dist/esm/constants/platform.js +6 -6
- package/dist/esm/constants/platform.js.map +2 -2
- package/dist/esm/constants/rnw.js +2 -20
- package/dist/esm/constants/rnw.js.map +2 -2
- package/dist/esm/constants/rnw.native.js +5 -0
- package/dist/esm/constants/rnw.native.js.map +7 -0
- package/dist/esm/createComponent.js +705 -331
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/createFont.js +2 -4
- package/dist/esm/createFont.js.map +2 -2
- package/dist/esm/createShorthands.js +0 -3
- package/dist/esm/createShorthands.js.map +1 -1
- package/dist/esm/createTamagui.js +172 -105
- package/dist/esm/createTamagui.js.map +2 -2
- package/dist/esm/createTheme.js +3 -3
- package/dist/esm/createTheme.js.map +2 -2
- package/dist/esm/createTokens.js +3 -20
- package/dist/esm/createTokens.js.map +2 -2
- package/dist/esm/createVariable.js +38 -14
- package/dist/esm/createVariable.js.map +2 -2
- package/dist/esm/createVariables.js +32 -0
- package/dist/esm/createVariables.js.map +7 -0
- package/dist/esm/helpers/areEqualSets.js +2 -4
- package/dist/esm/helpers/areEqualSets.js.map +1 -1
- package/dist/esm/helpers/assignNativePropsToWeb.js +164 -0
- package/dist/esm/helpers/assignNativePropsToWeb.js.map +7 -0
- package/dist/esm/helpers/assignNativePropsToWeb.native.js +6 -0
- package/dist/esm/helpers/assignNativePropsToWeb.native.js.map +7 -0
- package/dist/esm/helpers/calc.js +47 -0
- package/dist/esm/helpers/calc.js.map +7 -0
- package/dist/esm/helpers/createMediaStyle.js +4 -5
- package/dist/esm/helpers/createMediaStyle.js.map +2 -2
- package/dist/esm/helpers/createPropMapper.js +131 -114
- package/dist/esm/helpers/createPropMapper.js.map +2 -2
- package/dist/esm/helpers/createShallowUpdate.js +19 -5
- package/dist/esm/helpers/createShallowUpdate.js.map +2 -2
- package/dist/esm/helpers/createTamaguiProvider.js +46 -19
- package/dist/esm/helpers/createTamaguiProvider.js.map +2 -2
- package/dist/esm/helpers/cssHash.js +27 -0
- package/dist/esm/helpers/cssHash.js.map +7 -0
- package/dist/esm/helpers/expandStyle.js +90 -0
- package/dist/esm/helpers/expandStyle.js.map +7 -0
- package/dist/esm/helpers/expandStyles.js +103 -0
- package/dist/esm/helpers/expandStyles.js.map +7 -0
- package/dist/esm/helpers/extendStaticConfig.js +46 -40
- package/dist/esm/helpers/extendStaticConfig.js.map +2 -2
- package/dist/esm/helpers/fixNativeShadow.js +2 -4
- package/dist/esm/helpers/fixNativeShadow.js.map +1 -1
- package/dist/esm/helpers/getExpandedShorthands.js +0 -3
- package/dist/esm/helpers/getExpandedShorthands.js.map +1 -1
- package/dist/{jsx/helpers/getTextSize.js → esm/helpers/getFont.js} +12 -7
- package/dist/esm/helpers/getFont.js.map +7 -0
- package/dist/esm/helpers/getSize.js +15 -9
- package/dist/esm/helpers/getSize.js.map +2 -2
- package/dist/esm/helpers/getSplitStyles.js +282 -176
- package/dist/esm/helpers/getSplitStyles.js.map +2 -2
- package/dist/esm/helpers/getStackSize.js +22 -0
- package/dist/esm/helpers/getStackSize.js.map +7 -0
- package/dist/esm/helpers/getStylesAtomic.js +188 -110
- package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
- package/dist/esm/helpers/getStylesAtomic.native.js +0 -3
- package/dist/esm/helpers/getStylesAtomic.native.js.map +1 -1
- package/dist/esm/helpers/getTextSize.js +3 -5
- package/dist/esm/helpers/getTextSize.js.map +2 -2
- package/dist/esm/helpers/getVariantExtras.js +23 -0
- package/dist/esm/helpers/getVariantExtras.js.map +7 -0
- package/dist/esm/helpers/insertStyleRule.js +55 -38
- package/dist/esm/helpers/insertStyleRule.js.map +2 -2
- package/dist/esm/helpers/isObj.js +1 -3
- package/dist/esm/helpers/isObj.js.map +1 -1
- package/dist/esm/helpers/isTamaguiComponent.js +13 -0
- package/dist/esm/helpers/isTamaguiComponent.js.map +7 -0
- package/dist/esm/helpers/isTamaguiElement.js +4 -6
- package/dist/esm/helpers/isTamaguiElement.js.map +2 -2
- package/dist/esm/helpers/matchMedia.js +2 -4
- package/dist/esm/helpers/matchMedia.js.map +1 -1
- package/dist/esm/helpers/matchMedia.native.js +1 -3
- package/dist/esm/helpers/matchMedia.native.js.map +1 -1
- package/dist/esm/helpers/mergeProps.js +26 -0
- package/dist/esm/helpers/mergeProps.js.map +7 -0
- package/dist/esm/helpers/mergeTransform.js +17 -0
- package/dist/esm/helpers/mergeTransform.js.map +7 -0
- package/dist/esm/helpers/nativeGestureHandler.native.js +2 -0
- package/dist/esm/helpers/nativeGestureHandler.native.js.map +7 -0
- package/dist/esm/helpers/normalizeColor.js +49 -0
- package/dist/esm/helpers/normalizeColor.js.map +7 -0
- package/dist/esm/helpers/normalizeValueWithProperty.js +67 -0
- package/dist/esm/helpers/normalizeValueWithProperty.js.map +7 -0
- package/dist/esm/helpers/proxyThemeVariables.js +1 -4
- package/dist/esm/helpers/proxyThemeVariables.js.map +1 -1
- package/dist/esm/helpers/pseudoDescriptors.js +18 -0
- package/dist/esm/helpers/pseudoDescriptors.js.map +7 -0
- package/dist/esm/helpers/registerCSSVariable.js +15 -0
- package/dist/esm/helpers/registerCSSVariable.js.map +7 -0
- package/dist/esm/helpers/themeable.js +34 -5
- package/dist/esm/helpers/themeable.js.map +2 -2
- package/dist/esm/helpers/validate.js +42 -19
- package/dist/esm/helpers/validate.js.map +2 -2
- package/dist/esm/helpers/withStaticProperties.js +2 -4
- package/dist/esm/helpers/withStaticProperties.js.map +1 -1
- package/dist/esm/helpers/wrapThemeManagerContext.js +0 -3
- package/dist/esm/helpers/wrapThemeManagerContext.js.map +2 -2
- package/dist/esm/hooks/useConstant.js +0 -3
- package/dist/esm/hooks/useConstant.js.map +1 -1
- package/dist/esm/hooks/useFeatures.js +59 -26
- package/dist/esm/hooks/useFeatures.js.map +2 -2
- package/dist/esm/hooks/useId.js +8 -11
- package/dist/esm/hooks/useId.js.map +2 -2
- package/dist/esm/hooks/useIsMounted.js +1 -4
- package/dist/esm/hooks/useIsMounted.js.map +2 -2
- package/dist/esm/hooks/useIsTouchDevice.js +4 -6
- package/dist/esm/hooks/useIsTouchDevice.js.map +2 -2
- package/dist/esm/hooks/useMedia.js +28 -21
- package/dist/esm/hooks/useMedia.js.map +1 -1
- package/dist/esm/hooks/usePressable.js +18 -5
- package/dist/esm/hooks/usePressable.js.map +1 -1
- package/dist/esm/hooks/usePrevious.js +1 -0
- package/dist/esm/hooks/usePrevious.js.map +7 -0
- package/dist/esm/hooks/useTheme.js +45 -41
- package/dist/esm/hooks/useTheme.js.map +2 -2
- package/dist/esm/hooks/useUnmountEffect.js +0 -3
- package/dist/esm/hooks/useUnmountEffect.js.map +1 -1
- package/dist/esm/index.js +18 -9
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/insertFont.js +64 -0
- package/dist/esm/insertFont.js.map +7 -0
- package/dist/esm/static.js +3 -1
- package/dist/esm/static.js.map +2 -2
- package/dist/esm/styled.js +37 -12
- package/dist/esm/styled.js.map +2 -2
- package/dist/esm/views/Slot.js +74 -34
- package/dist/esm/views/Slot.js.map +2 -2
- package/dist/esm/views/Stack.js +21 -3
- package/dist/esm/views/Stack.js.map +1 -1
- package/dist/esm/views/Text.js +27 -19
- package/dist/esm/views/Text.js.map +2 -2
- package/dist/esm/views/TextAncestorContext.js +4 -7
- package/dist/esm/views/TextAncestorContext.js.map +2 -2
- package/dist/esm/views/Theme.js +6 -10
- package/dist/esm/views/Theme.js.map +2 -2
- package/dist/esm/views/ThemeInverse.js +8 -7
- package/dist/esm/views/ThemeInverse.js.map +2 -2
- package/dist/esm/views/ThemeProvider.js +6 -7
- package/dist/esm/views/ThemeProvider.js.map +2 -2
- package/dist/esm/views/ThemeReset.js +3 -4
- package/dist/esm/views/ThemeReset.js.map +2 -2
- package/package.json +18 -11
- package/reset.css +41 -0
- package/types/Pressability.d.ts +2 -0
- package/types/Pressability.native.d.ts +2 -0
- package/types/Tamagui.d.ts +4 -6
- package/types/Tamagui.d.ts.map +1 -1
- package/types/ThemeContext.d.ts +0 -0
- package/types/ThemeContext.d.ts.map +0 -0
- package/types/ThemeManager.d.ts +10 -7
- package/types/ThemeManager.d.ts.map +1 -1
- package/types/conf.d.ts +3 -4
- package/types/conf.d.ts.map +1 -1
- package/types/constants/constants.d.ts +1 -1
- package/types/constants/platform.d.ts +2 -2
- package/types/constants/rnw.d.ts +1 -1
- package/types/constants/rnw.d.ts.map +1 -1
- package/types/constants/rnw.native.d.ts +2 -0
- package/types/contexts/ButtonInsideButtonContext.d.ts +0 -0
- package/types/createComponent.d.ts +40 -15
- package/types/createComponent.d.ts.map +1 -1
- package/types/createFont.d.ts +0 -0
- package/types/createFont.d.ts.map +0 -0
- package/types/createShorthands.d.ts +0 -0
- package/types/createTamagui.d.ts +10 -2
- package/types/createTamagui.d.ts.map +1 -1
- package/types/createTheme.d.ts +1 -1
- package/types/createTokens.d.ts +0 -1
- package/types/createTokens.d.ts.map +1 -1
- package/types/createVariable.d.ts +16 -11
- package/types/createVariables.d.ts +10 -0
- package/types/defaultComponentState.d.ts +0 -0
- package/types/helpers/RNComponents.d.ts +0 -0
- package/types/helpers/areEqualSets.d.ts +0 -0
- package/types/helpers/assignNativePropsToWeb.d.ts +2 -0
- package/types/helpers/assignNativePropsToWeb.d.ts.map +1 -0
- package/types/helpers/assignNativePropsToWeb.native.d.ts +2 -0
- package/types/helpers/calc.d.ts +12 -0
- package/types/helpers/calc.d.ts.map +1 -0
- package/types/helpers/createMediaStyle.d.ts +1 -1
- package/types/helpers/createMediaStyle.d.ts.map +1 -1
- package/types/helpers/createPropMapper.d.ts +4 -3
- package/types/helpers/createPropMapper.d.ts.map +1 -1
- package/types/helpers/createShallowUpdate.d.ts +1 -2
- package/types/helpers/createTamaguiProvider.d.ts +2 -6
- package/types/helpers/createTamaguiProvider.d.ts.map +1 -1
- package/types/helpers/cssHash.d.ts +2 -0
- package/types/helpers/cssHash.d.ts.map +1 -0
- package/types/helpers/expandStyle.d.ts +2 -0
- package/types/helpers/expandStyle.d.ts.map +1 -0
- package/types/helpers/expandStyles.d.ts +7 -0
- package/types/helpers/expandStyles.d.ts.map +1 -0
- package/types/helpers/extendStaticConfig.d.ts +0 -0
- package/types/helpers/extendStaticConfig.d.ts.map +1 -1
- package/types/helpers/fixNativeShadow.d.ts +0 -0
- package/types/helpers/getExpandedShorthands.d.ts +0 -0
- package/types/helpers/getExpandedShorthands.d.ts.map +0 -0
- package/types/helpers/getFont.d.ts +3 -0
- package/types/helpers/getFont.d.ts.map +1 -0
- package/types/helpers/getSize.d.ts +3 -2
- package/types/helpers/getSize.d.ts.map +1 -1
- package/types/helpers/getSplitStyles.d.ts +10 -7
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/helpers/getStackSize.d.ts +8 -0
- package/types/helpers/getStackSize.d.ts.map +1 -0
- package/types/helpers/getStylesAtomic.d.ts +7 -17
- package/types/helpers/getStylesAtomic.d.ts.map +1 -1
- package/types/helpers/getStylesAtomic.native.d.ts +0 -0
- package/types/helpers/getVariantExtras.d.ts +7 -0
- package/types/helpers/getVariantExtras.d.ts.map +1 -0
- package/types/helpers/insertStyleRule.d.ts +1 -1
- package/types/helpers/isObj.d.ts +0 -0
- package/types/helpers/isTamaguiComponent.d.ts +5 -0
- package/types/helpers/isTamaguiComponent.d.ts.map +1 -0
- package/types/helpers/isTamaguiElement.d.ts +1 -1
- package/types/helpers/isTamaguiElement.d.ts.map +1 -1
- package/types/helpers/matchMedia.d.ts +0 -0
- package/types/helpers/matchMedia.native.d.ts +0 -0
- package/types/helpers/mergeProps.d.ts +2 -0
- package/types/helpers/mergeTransform.d.ts +7 -0
- package/types/helpers/nativeGestureHandler.native.d.ts +2 -0
- package/types/helpers/normalizeColor.d.ts +3 -0
- package/types/helpers/normalizeColor.d.ts.map +1 -0
- package/types/helpers/normalizeValueWithProperty.d.ts +2 -0
- package/types/helpers/normalizeValueWithProperty.d.ts.map +1 -0
- package/types/helpers/proxyThemeVariables.d.ts +0 -0
- package/types/helpers/pseudoDescriptors.d.ts +16 -0
- package/types/helpers/registerCSSVariable.d.ts +5 -0
- package/types/helpers/themeable.d.ts +0 -0
- package/types/helpers/themeable.d.ts.map +1 -1
- package/types/helpers/validate.d.ts +0 -0
- package/types/helpers/withStaticProperties.d.ts +0 -0
- package/types/helpers/wrapThemeManagerContext.d.ts +0 -0
- package/types/helpers/wrapThemeManagerContext.d.ts.map +0 -0
- package/types/hooks/useConstant.d.ts +0 -0
- package/types/hooks/useFeatures.d.ts +11 -5
- package/types/hooks/useFeatures.d.ts.map +1 -1
- package/types/hooks/useId.d.ts +0 -0
- package/types/hooks/useIsMounted.d.ts +0 -0
- package/types/hooks/useIsTouchDevice.d.ts +0 -0
- package/types/hooks/useMedia.d.ts +0 -0
- package/types/hooks/useMedia.d.ts.map +0 -0
- package/types/hooks/usePressable.d.ts +0 -0
- package/types/hooks/usePrevious.d.ts +1 -0
- package/types/hooks/useTheme.d.ts +15 -6
- package/types/hooks/useTheme.d.ts.map +1 -1
- package/types/hooks/useUnmountEffect.d.ts +0 -0
- package/types/index.d.ts +16 -6
- package/types/index.d.ts.map +1 -1
- package/types/insertFont.d.ts +6 -0
- package/types/insertFont.d.ts.map +1 -0
- package/types/static.d.ts +3 -1
- package/types/static.d.ts.map +1 -1
- package/types/styled.d.ts +2 -2
- package/types/styled.d.ts.map +1 -1
- package/types/types-rnw.d.ts +0 -0
- package/types/types.d.ts +71 -51
- package/types/types.d.ts.map +1 -1
- package/types/views/Slot.d.ts +1 -0
- package/types/views/Stack.d.ts +0 -0
- package/types/views/Stack.d.ts.map +0 -0
- package/types/views/Text.d.ts +0 -0
- package/types/views/Text.d.ts.map +1 -1
- package/types/views/TextAncestorContext.d.ts +0 -0
- package/types/views/TextAncestorContext.d.ts.map +1 -1
- package/types/views/Theme.d.ts +1 -9
- package/types/views/Theme.d.ts.map +1 -1
- package/types/views/ThemeInverse.d.ts +0 -0
- package/types/views/ThemeInverse.d.ts.map +1 -1
- package/types/views/ThemeProvider.d.ts +2 -0
- package/types/views/ThemeProvider.d.ts.map +1 -1
- package/types/views/ThemeReset.d.ts +0 -0
- package/types/views/ThemeReset.d.ts.map +0 -0
- package/dist/cjs/helpers/addStylesUsingClassname.js +0 -87
- package/dist/cjs/helpers/addStylesUsingClassname.js.map +0 -7
- package/dist/cjs/helpers/fixNativeShadow.native.js +0 -63
- package/dist/cjs/helpers/fixNativeShadow.native.js.map +0 -7
- package/dist/cjs/helpers/getButtonSize.js +0 -45
- package/dist/cjs/helpers/getButtonSize.js.map +0 -7
- package/dist/esm/helpers/addStylesUsingClassname.js +0 -64
- package/dist/esm/helpers/addStylesUsingClassname.js.map +0 -7
- package/dist/esm/helpers/fixNativeShadow.native.js +0 -41
- package/dist/esm/helpers/fixNativeShadow.native.js.map +0 -7
- package/dist/esm/helpers/getButtonSize.js +0 -24
- package/dist/esm/helpers/getButtonSize.js.map +0 -7
- package/dist/jsx/Tamagui.js +0 -41
- package/dist/jsx/ThemeContext.js +0 -5
- package/dist/jsx/ThemeManager.js +0 -186
- package/dist/jsx/conf.js +0 -35
- package/dist/jsx/constants/constants.js +0 -17
- package/dist/jsx/constants/platform.js +0 -25
- package/dist/jsx/constants/rnw.js +0 -23
- package/dist/jsx/contexts/ButtonInsideButtonContext.js +0 -5
- package/dist/jsx/createComponent.js +0 -617
- package/dist/jsx/createFont.js +0 -27
- package/dist/jsx/createShorthands.js +0 -9
- package/dist/jsx/createTamagui.js +0 -201
- package/dist/jsx/createTheme.js +0 -6
- package/dist/jsx/createTokens.js +0 -28
- package/dist/jsx/createVariable.js +0 -48
- package/dist/jsx/defaultComponentState.js +0 -0
- package/dist/jsx/helpers/RNComponents.js +0 -11
- package/dist/jsx/helpers/addStylesUsingClassname.js +0 -63
- package/dist/jsx/helpers/areEqualSets.js +0 -15
- package/dist/jsx/helpers/createMediaStyle.js +0 -30
- package/dist/jsx/helpers/createPropMapper.js +0 -237
- package/dist/jsx/helpers/createShallowUpdate.js +0 -18
- package/dist/jsx/helpers/createTamaguiProvider.js +0 -34
- package/dist/jsx/helpers/extendStaticConfig.js +0 -61
- package/dist/jsx/helpers/fixNativeShadow.js +0 -7
- package/dist/jsx/helpers/fixNativeShadow.native.js +0 -40
- package/dist/jsx/helpers/getButtonSize.js +0 -23
- package/dist/jsx/helpers/getExpandedShorthands.js +0 -18
- package/dist/jsx/helpers/getSize.js +0 -12
- package/dist/jsx/helpers/getSplitStyles.js +0 -302
- package/dist/jsx/helpers/getStylesAtomic.js +0 -130
- package/dist/jsx/helpers/getStylesAtomic.native.js +0 -9
- package/dist/jsx/helpers/insertStyleRule.js +0 -94
- package/dist/jsx/helpers/isObj.js +0 -6
- package/dist/jsx/helpers/isTamaguiElement.js +0 -10
- package/dist/jsx/helpers/matchMedia.js +0 -17
- package/dist/jsx/helpers/matchMedia.native.js +0 -8
- package/dist/jsx/helpers/proxyThemeVariables.js +0 -17
- package/dist/jsx/helpers/themeable.js +0 -24
- package/dist/jsx/helpers/validate.js +0 -75
- package/dist/jsx/helpers/withStaticProperties.js +0 -9
- package/dist/jsx/helpers/wrapThemeManagerContext.js +0 -10
- package/dist/jsx/hooks/useConstant.js +0 -14
- package/dist/jsx/hooks/useFeatures.js +0 -167
- package/dist/jsx/hooks/useId.js +0 -34
- package/dist/jsx/hooks/useIsMounted.js +0 -18
- package/dist/jsx/hooks/useIsTouchDevice.js +0 -16
- package/dist/jsx/hooks/useMedia.js +0 -158
- package/dist/jsx/hooks/usePressable.js +0 -13
- package/dist/jsx/hooks/useTheme.js +0 -177
- package/dist/jsx/hooks/useUnmountEffect.js +0 -10
- package/dist/jsx/index.js +0 -54
- package/dist/jsx/static.js +0 -16
- package/dist/jsx/styled.js +0 -48
- package/dist/jsx/types-rnw.js +0 -0
- package/dist/jsx/types.js +0 -0
- package/dist/jsx/views/Slot.js +0 -56
- package/dist/jsx/views/Stack.js +0 -12
- package/dist/jsx/views/Text.js +0 -61
- package/dist/jsx/views/TextAncestorContext.js +0 -15
- package/dist/jsx/views/Theme.js +0 -31
- package/dist/jsx/views/ThemeInverse.js +0 -22
- package/dist/jsx/views/ThemeProvider.js +0 -35
- package/dist/jsx/views/ThemeReset.js +0 -34
- package/types/constants/constants.d.ts.map +0 -1
- package/types/constants/platform.d.ts.map +0 -1
- package/types/contexts/ButtonInsideButtonContext.d.ts.map +0 -1
- package/types/createShorthands.d.ts.map +0 -1
- package/types/createTheme.d.ts.map +0 -1
- package/types/createVariable.d.ts.map +0 -1
- package/types/defaultComponentState.d.ts.map +0 -1
- package/types/helpers/RNComponents.d.ts.map +0 -1
- package/types/helpers/addStylesUsingClassname.d.ts +0 -3
- package/types/helpers/addStylesUsingClassname.d.ts.map +0 -1
- package/types/helpers/areEqualSets.d.ts.map +0 -1
- package/types/helpers/createShallowUpdate.d.ts.map +0 -1
- package/types/helpers/fixNativeShadow.d.ts.map +0 -1
- package/types/helpers/fixNativeShadow.native.d.ts +0 -2
- package/types/helpers/fixNativeShadow.native.d.ts.map +0 -1
- package/types/helpers/getButtonSize.d.ts +0 -8
- package/types/helpers/getButtonSize.d.ts.map +0 -1
- package/types/helpers/getStylesAtomic.native.d.ts.map +0 -1
- package/types/helpers/getTextSize.d.ts +0 -3
- package/types/helpers/getTextSize.d.ts.map +0 -1
- package/types/helpers/insertStyleRule.d.ts.map +0 -1
- package/types/helpers/isObj.d.ts.map +0 -1
- package/types/helpers/matchMedia.d.ts.map +0 -1
- package/types/helpers/matchMedia.native.d.ts.map +0 -1
- package/types/helpers/proxyThemeVariables.d.ts.map +0 -1
- package/types/helpers/validate.d.ts.map +0 -1
- package/types/helpers/withStaticProperties.d.ts.map +0 -1
- package/types/hooks/useConstant.d.ts.map +0 -1
- package/types/hooks/useId.d.ts.map +0 -1
- package/types/hooks/useIsMounted.d.ts.map +0 -1
- package/types/hooks/useIsTouchDevice.d.ts.map +0 -1
- package/types/hooks/usePressable.d.ts.map +0 -1
- package/types/hooks/useUnmountEffect.d.ts.map +0 -1
- package/types/types-rnw.d.ts.map +0 -1
- package/types/views/Slot.d.ts.map +0 -1
|
@@ -19,7 +19,6 @@ var __spreadValues = (a, b) => {
|
|
|
19
19
|
return a;
|
|
20
20
|
};
|
|
21
21
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
23
22
|
var __export = (target, all) => {
|
|
24
23
|
for (var name in all)
|
|
25
24
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -35,16 +34,21 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
35
34
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
35
|
var createTamagui_exports = {};
|
|
37
36
|
__export(createTamagui_exports, {
|
|
38
|
-
createTamagui: () => createTamagui
|
|
37
|
+
createTamagui: () => createTamagui,
|
|
38
|
+
reversedShorthands: () => reversedShorthands
|
|
39
39
|
});
|
|
40
40
|
module.exports = __toCommonJS(createTamagui_exports);
|
|
41
41
|
var import_conf = require("./conf");
|
|
42
42
|
var import_constants = require("./constants/constants");
|
|
43
43
|
var import_platform = require("./constants/platform");
|
|
44
44
|
var import_createVariable = require("./createVariable");
|
|
45
|
+
var import_createVariables = require("./createVariables");
|
|
45
46
|
var import_createTamaguiProvider = require("./helpers/createTamaguiProvider");
|
|
46
47
|
var import_insertStyleRule = require("./helpers/insertStyleRule");
|
|
48
|
+
var import_registerCSSVariable = require("./helpers/registerCSSVariable");
|
|
47
49
|
var import_useMedia = require("./hooks/useMedia");
|
|
50
|
+
var import_insertFont = require("./insertFont");
|
|
51
|
+
var import_Tamagui = require("./Tamagui");
|
|
48
52
|
const createdConfigs = /* @__PURE__ */ new WeakMap();
|
|
49
53
|
function createTamagui(config) {
|
|
50
54
|
if (createdConfigs.has(config)) {
|
|
@@ -57,156 +61,196 @@ function createTamagui(config) {
|
|
|
57
61
|
if (!config.themes) {
|
|
58
62
|
throw new Error(`No themes provided to Tamagui config`);
|
|
59
63
|
}
|
|
64
|
+
if (!config.fonts) {
|
|
65
|
+
throw new Error(`No fonts provided to Tamagui config`);
|
|
66
|
+
}
|
|
60
67
|
}
|
|
61
68
|
if ((0, import_conf.getHasConfigured)()) {
|
|
62
|
-
console.warn(
|
|
69
|
+
console.warn(`Warning: createTamagui called twice (maybe HMR)`);
|
|
63
70
|
}
|
|
64
71
|
(0, import_useMedia.configureMedia)({
|
|
65
72
|
queries: config.media,
|
|
66
73
|
defaultActive: config.mediaQueryDefaultActive
|
|
67
74
|
});
|
|
75
|
+
const fontTokens = (0, import_createVariables.createVariables)(config.fonts);
|
|
76
|
+
const fontsParsed = (() => {
|
|
77
|
+
const res = {};
|
|
78
|
+
for (const familyName in fontTokens) {
|
|
79
|
+
res[`$${familyName}`] = (0, import_insertFont.parseFont)(fontTokens[familyName]);
|
|
80
|
+
}
|
|
81
|
+
return res;
|
|
82
|
+
})();
|
|
68
83
|
const themeConfig = (() => {
|
|
69
|
-
|
|
84
|
+
const themes = __spreadValues({}, config.themes);
|
|
70
85
|
let cssRules = [];
|
|
71
|
-
const varsByValue = /* @__PURE__ */ new Map();
|
|
72
86
|
if (import_platform.isWeb) {
|
|
73
|
-
const tokenRules = /* @__PURE__ */ new Set();
|
|
74
|
-
const addVar = /* @__PURE__ */ __name((v) => {
|
|
75
|
-
varsByValue[v.val] = v;
|
|
76
|
-
const rule = `--${(0, import_createVariable.createCSSVariable)(v.name, false)}:${typeof v.val === "number" ? `${v.val}px` : v.val}`;
|
|
77
|
-
tokenRules.add(rule);
|
|
78
|
-
}, "addVar");
|
|
79
87
|
for (const key in config.tokens) {
|
|
80
88
|
for (const skey in config.tokens[key]) {
|
|
81
89
|
const val = config.tokens[key][skey];
|
|
82
|
-
|
|
83
|
-
for (const fkey in val) {
|
|
84
|
-
if (fkey === "family") {
|
|
85
|
-
addVar(val[fkey]);
|
|
86
|
-
} else {
|
|
87
|
-
for (const fskey in val[fkey]) {
|
|
88
|
-
addVar(val[fkey][fskey]);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
} else {
|
|
93
|
-
addVar(val);
|
|
94
|
-
}
|
|
90
|
+
(0, import_registerCSSVariable.registerCSSVariable)(val);
|
|
95
91
|
}
|
|
96
92
|
}
|
|
93
|
+
for (const key in fontsParsed) {
|
|
94
|
+
const fontParsed = fontsParsed[key];
|
|
95
|
+
(0, import_insertFont.registerFontVariables)(fontParsed);
|
|
96
|
+
}
|
|
97
97
|
const sep = process.env.NODE_ENV === "development" ? config.cssStyleSeparator || " " : "";
|
|
98
|
-
cssRules.push(`:root {${sep}${[...tokenRules].join(`;${sep}`)}${sep}}`);
|
|
98
|
+
cssRules.push(`:root {${sep}${[...import_registerCSSVariable.tokenRules].join(`;${sep}`)}${sep}}`);
|
|
99
99
|
}
|
|
100
100
|
const hasDarkLight = "light" in config.themes && "dark" in config.themes;
|
|
101
101
|
const CNP = `.${import_constants.THEME_CLASSNAME_PREFIX}`;
|
|
102
|
-
|
|
102
|
+
const dedupedThemes = {};
|
|
103
|
+
const existing = /* @__PURE__ */ new WeakMap();
|
|
104
|
+
for (const themeName in themes) {
|
|
105
|
+
const rawTheme = themes[themeName];
|
|
106
|
+
if (existing.has(rawTheme)) {
|
|
107
|
+
const e = existing.get(rawTheme);
|
|
108
|
+
themes[themeName] = e.theme;
|
|
109
|
+
e.names.push(themeName);
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
103
112
|
const theme = __spreadValues({}, config.themes[themeName]);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
for (const themeKey in theme) {
|
|
107
|
-
if (import_platform.isWeb) {
|
|
108
|
-
const val = theme[themeKey];
|
|
109
|
-
const varName = val instanceof import_createVariable.Variable ? val.name : (_a = varsByValue[val]) == null ? void 0 : _a.name;
|
|
110
|
-
vars += `--${themeKey}:${varName ? (0, import_createVariable.createCSSVariable)(varName) : `${val}`};`;
|
|
111
|
-
}
|
|
112
|
-
ensureThemeVariable(theme, themeKey);
|
|
113
|
+
for (const key in theme) {
|
|
114
|
+
ensureThemeVariable(theme, key);
|
|
113
115
|
}
|
|
114
|
-
|
|
116
|
+
themes[themeName] = theme;
|
|
117
|
+
dedupedThemes[themeName] = {
|
|
118
|
+
names: [themeName],
|
|
119
|
+
theme
|
|
120
|
+
};
|
|
121
|
+
existing.set(config.themes[themeName], dedupedThemes[themeName]);
|
|
122
|
+
}
|
|
123
|
+
if (import_platform.isWeb) {
|
|
124
|
+
for (const themeName in dedupedThemes) {
|
|
125
|
+
const { theme, names } = dedupedThemes[themeName];
|
|
126
|
+
let vars = "";
|
|
127
|
+
for (const themeKey in theme) {
|
|
128
|
+
const variable = theme[themeKey];
|
|
129
|
+
let value = null;
|
|
130
|
+
if (variable.isFloating || !import_registerCSSVariable.tokensValueToVariable.has(variable.val)) {
|
|
131
|
+
value = variable.val;
|
|
132
|
+
} else {
|
|
133
|
+
value = import_registerCSSVariable.tokensValueToVariable.get(variable.val).variable;
|
|
134
|
+
}
|
|
135
|
+
vars += `--${themeKey}:${value};`;
|
|
136
|
+
}
|
|
115
137
|
const isDarkOrLightBase = themeName === "dark" || themeName === "light";
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
138
|
+
const selectors = names.map((name) => {
|
|
139
|
+
return `${CNP}${name}`;
|
|
140
|
+
});
|
|
119
141
|
if (hasDarkLight) {
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
order
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
142
|
+
for (const subName of names) {
|
|
143
|
+
const isDark = isDarkOrLightBase || subName.startsWith("dark_");
|
|
144
|
+
const childSelector = `${CNP}${subName.replace(isDark ? "dark_" : "light_", "")}`;
|
|
145
|
+
const order = isDark ? ["dark", "light"] : ["light", "dark"];
|
|
146
|
+
if (isDarkOrLightBase) {
|
|
147
|
+
order.reverse();
|
|
148
|
+
}
|
|
149
|
+
const [stronger, weaker] = order;
|
|
150
|
+
const max = config.maxDarkLightNesting ?? 3;
|
|
151
|
+
new Array(Math.round(max * 1.5)).fill(void 0).forEach((_, pi) => {
|
|
152
|
+
const isOdd = pi % 2 === 1;
|
|
153
|
+
if (isOdd && pi < 3)
|
|
154
|
+
return;
|
|
155
|
+
const parents = new Array(pi + 1).fill(void 0).map((_2, psi) => {
|
|
156
|
+
return `${CNP}${psi % 2 === 0 ? stronger : weaker}`;
|
|
157
|
+
});
|
|
158
|
+
let parentSelectors = parents.length > 1 ? parents.slice(1) : parents;
|
|
159
|
+
if (isOdd) {
|
|
160
|
+
const [_first, second, ...rest] = parentSelectors;
|
|
161
|
+
parentSelectors = [second, ...rest, second];
|
|
162
|
+
}
|
|
163
|
+
selectors.push(`${parentSelectors.join(" ")} ${childSelector}`);
|
|
132
164
|
});
|
|
133
|
-
|
|
134
|
-
});
|
|
165
|
+
}
|
|
135
166
|
}
|
|
136
167
|
const rootSep = config.themeClassNameOnRoot ? "" : " ";
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
168
|
+
const css2 = `${selectors.map((x) => `:root${rootSep}${x}`).join(", ")} {${vars}}`;
|
|
169
|
+
cssRules.push(css2);
|
|
170
|
+
if (config.shouldAddPrefersColorThemes && isDarkOrLightBase) {
|
|
171
|
+
const isDark = themeName.startsWith("dark");
|
|
172
|
+
cssRules.push(`@media(prefers-color-scheme: ${isDark ? "dark" : "light"}) {
|
|
173
|
+
body { background:${theme.background}; color: ${theme.color} }
|
|
174
|
+
:root {${vars} }
|
|
175
|
+
}`);
|
|
145
176
|
}
|
|
146
177
|
}
|
|
147
178
|
}
|
|
148
|
-
|
|
179
|
+
for (const themeName in themes) {
|
|
180
|
+
const cur = [];
|
|
181
|
+
const parents = themeName.split("_").slice(0, -1).map((part) => {
|
|
182
|
+
cur.push(part);
|
|
183
|
+
return cur.join("_");
|
|
184
|
+
});
|
|
185
|
+
if (!parents.length)
|
|
186
|
+
continue;
|
|
187
|
+
themes[themeName] = new Proxy(themes[themeName], {
|
|
188
|
+
get(target, key) {
|
|
189
|
+
if (Reflect.has(target, key)) {
|
|
190
|
+
return Reflect.get(target, key);
|
|
191
|
+
}
|
|
192
|
+
for (let i = parents.length - 1; i >= 0; i--) {
|
|
193
|
+
const parent = themes[parents[i]];
|
|
194
|
+
if (!parent) {
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
if (Reflect.has(parent, key)) {
|
|
198
|
+
return Reflect.get(parent, key);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
import_registerCSSVariable.tokensValueToVariable.clear();
|
|
149
205
|
Object.freeze(cssRules);
|
|
150
206
|
const css = cssRules.join("\n");
|
|
151
207
|
return {
|
|
208
|
+
themes,
|
|
152
209
|
cssRules,
|
|
153
210
|
css
|
|
154
211
|
};
|
|
155
212
|
})();
|
|
156
213
|
const tokensParsed = parseTokens(config.tokens);
|
|
157
|
-
const
|
|
158
|
-
if (!config.fonts) {
|
|
159
|
-
throw new Error(`No fonts defined!`);
|
|
160
|
-
}
|
|
161
|
-
const res = {};
|
|
162
|
-
for (const familyName in config.fonts) {
|
|
163
|
-
const family = config.fonts[familyName];
|
|
164
|
-
const parsed = {};
|
|
165
|
-
for (const attrKey in family) {
|
|
166
|
-
const attr = family[attrKey];
|
|
167
|
-
if (attrKey === "family") {
|
|
168
|
-
parsed[attrKey] = attr;
|
|
169
|
-
continue;
|
|
170
|
-
}
|
|
171
|
-
parsed[attrKey] = Object.keys(attr).reduce((acc, cur) => {
|
|
172
|
-
acc[`$${cur}`] = attr[cur];
|
|
173
|
-
return acc;
|
|
174
|
-
}, {});
|
|
175
|
-
}
|
|
176
|
-
res[`$${familyName}`] = parsed;
|
|
177
|
-
}
|
|
178
|
-
return res;
|
|
179
|
-
})();
|
|
180
|
-
const getCSS = /* @__PURE__ */ __name(() => {
|
|
214
|
+
const getCSS = () => {
|
|
181
215
|
return `${themeConfig.css}
|
|
182
216
|
${(0, import_insertStyleRule.getInsertedRules)().join("\n")}`;
|
|
183
|
-
}
|
|
217
|
+
};
|
|
218
|
+
if (config.shorthands) {
|
|
219
|
+
for (const key in config.shorthands) {
|
|
220
|
+
reversedShorthands[config.shorthands[key]] = key;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
184
223
|
const next = __spreadProps(__spreadValues({
|
|
224
|
+
defaultTheme: "light",
|
|
185
225
|
fonts: {},
|
|
186
226
|
animations: {},
|
|
187
227
|
shorthands: {},
|
|
188
228
|
media: {}
|
|
189
229
|
}, config), {
|
|
190
|
-
|
|
191
|
-
getCSS,
|
|
192
|
-
defaultTheme: "light"
|
|
193
|
-
}, config)),
|
|
230
|
+
themes: themeConfig.themes,
|
|
194
231
|
fontsParsed,
|
|
195
232
|
themeConfig,
|
|
196
233
|
tokensParsed,
|
|
197
234
|
parsed: true,
|
|
198
|
-
getCSS
|
|
235
|
+
getCSS,
|
|
236
|
+
Provider: null
|
|
199
237
|
});
|
|
238
|
+
next.Provider = (0, import_createTamaguiProvider.createTamaguiProvider)(next);
|
|
200
239
|
(0, import_conf.setConfig)(next);
|
|
201
240
|
if (import_conf.configListeners.size) {
|
|
202
241
|
import_conf.configListeners.forEach((cb) => cb(next));
|
|
203
242
|
import_conf.configListeners.clear();
|
|
204
243
|
}
|
|
205
244
|
createdConfigs.set(next, true);
|
|
245
|
+
if (process.env.NODE_ENV === "development") {
|
|
246
|
+
if (!globalThis["Tamagui"]) {
|
|
247
|
+
globalThis["Tamagui"] = import_Tamagui.Tamagui;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
206
250
|
return next;
|
|
207
251
|
}
|
|
208
|
-
|
|
209
|
-
const parseTokens =
|
|
252
|
+
const reversedShorthands = {};
|
|
253
|
+
const parseTokens = (tokens) => {
|
|
210
254
|
const res = {};
|
|
211
255
|
for (const key in tokens) {
|
|
212
256
|
res[key] = {};
|
|
@@ -215,26 +259,29 @@ const parseTokens = /* @__PURE__ */ __name((tokens) => {
|
|
|
215
259
|
}
|
|
216
260
|
}
|
|
217
261
|
return res;
|
|
218
|
-
}
|
|
262
|
+
};
|
|
219
263
|
function ensureThemeVariable(theme, key) {
|
|
220
264
|
const val = theme[key];
|
|
265
|
+
const themeKey = key;
|
|
221
266
|
if (!(0, import_createVariable.isVariable)(val)) {
|
|
222
267
|
theme[key] = (0, import_createVariable.createVariable)({
|
|
223
|
-
|
|
268
|
+
key: themeKey,
|
|
269
|
+
name: themeKey,
|
|
224
270
|
val
|
|
225
271
|
});
|
|
226
272
|
} else {
|
|
227
|
-
if (val.name !==
|
|
273
|
+
if (val.name !== themeKey) {
|
|
228
274
|
theme[key] = (0, import_createVariable.createVariable)({
|
|
229
|
-
|
|
275
|
+
key: val.name,
|
|
276
|
+
name: themeKey,
|
|
230
277
|
val: val.val
|
|
231
278
|
});
|
|
232
279
|
}
|
|
233
280
|
}
|
|
234
281
|
}
|
|
235
|
-
__name(ensureThemeVariable, "ensureThemeVariable");
|
|
236
282
|
// Annotate the CommonJS export names for ESM import in node:
|
|
237
283
|
0 && (module.exports = {
|
|
238
|
-
createTamagui
|
|
284
|
+
createTamagui,
|
|
285
|
+
reversedShorthands
|
|
239
286
|
});
|
|
240
287
|
//# sourceMappingURL=createTamagui.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/createTamagui.ts"],
|
|
4
|
-
"sourcesContent": ["import { configListeners, getHasConfigured, setConfig } from './conf'\nimport { THEME_CLASSNAME_PREFIX } from './constants/constants'\nimport { isWeb } from './constants/platform'\nimport { Variable, createCSSVariable, createVariable, isVariable } from './createVariable'\nimport { createTamaguiProvider } from './helpers/createTamaguiProvider'\nimport { getInsertedRules } from './helpers/insertStyleRule'\nimport { configureMedia } from './hooks/useMedia'\nimport {\n AnimationDriver,\n CreateTamaguiConfig,\n GenericTamaguiConfig,\n MediaQueryKey,\n TamaguiInternalConfig,\n} from './types'\n\nexport type CreateTamaguiProps =\n // user then re-defines the types after createTamagui returns the typed object they want\n Partial<Omit<GenericTamaguiConfig, 'themes' | 'tokens' | 'animations'>> & {\n animations?: AnimationDriver<any>\n tokens: GenericTamaguiConfig['tokens']\n themes: {\n [key: string]: {\n [key: string]: string | number | Variable\n }\n }\n\n // for the first render, determines which media queries are true\n // useful for SSR\n mediaQueryDefaultActive?: MediaQueryKey[]\n\n // what's between each CSS style rule, set to \"\\n\" to be easier to read\n // defaults: \"\\n\" when NODE_ENV=development, \"\" otherwise\n cssStyleSeparator?: string\n\n // (Advanced)\n // on the web, tamagui treats `dark` and `light` themes as special and\n // generates extra CSS to avoid having to re-render the entire page.\n // this CSS relies on specificity hacks that multiply by your sub-themes.\n // this sets the maxiumum number of nested dark/light themes you can do\n // defaults to 3 for a balance, but can be higher if you nest them deeply.\n maxDarkLightNesting?: number\n\n // adds @media(prefers-color-scheme) media queries for dark/light\n shouldAddPrefersColorThemes?: boolean\n\n // only if you put the theme classname on the html element we have to generate diff\n themeClassNameOnRoot?: boolean\n }\n\n// config is re-run by the @tamagui/static, dont double validate\nconst createdConfigs = new WeakMap<any, boolean>()\n\nexport function createTamagui<Conf extends CreateTamaguiProps>(\n config: Conf\n): Conf extends Partial<CreateTamaguiConfig<infer A, infer B, infer C, infer D, infer E, infer F>>\n ? TamaguiInternalConfig<A, B, C, D, E, F>\n : unknown {\n if (createdConfigs.has(config)) {\n return config as any\n }\n\n if (process.env.NODE_ENV === 'development') {\n if (!config.tokens) {\n throw new Error(`No tokens provided to Tamagui config`)\n }\n if (!config.themes) {\n throw new Error(`No themes provided to Tamagui config`)\n }\n }\n\n // test env loads a few times as it runs diff tests\n if (getHasConfigured()) {\n console.warn('Called createTamagui twice! Should never do so')\n // throw new Error(`#000 createTamagui called twice`)\n }\n\n configureMedia({\n queries: config.media as any,\n defaultActive: config.mediaQueryDefaultActive,\n })\n\n const themeConfig = (() => {\n let cssRules: string[] = []\n const varsByValue = new Map<string, Variable>()\n\n if (isWeb) {\n // tokens\n const tokenRules = new Set<string>()\n\n const addVar = (v: Variable) => {\n varsByValue[v.val] = v\n const rule = `--${createCSSVariable(v.name, false)}:${\n typeof v.val === 'number' ? `${v.val}px` : v.val\n }`\n tokenRules.add(rule)\n }\n\n for (const key in config.tokens) {\n for (const skey in config.tokens[key]) {\n const val = config.tokens[key][skey]\n if (key === 'font') {\n for (const fkey in val) {\n if (fkey === 'family') {\n addVar(val[fkey])\n } else {\n for (const fskey in val[fkey]) {\n addVar(val[fkey][fskey])\n }\n }\n }\n } else {\n addVar(val)\n }\n }\n }\n const sep = process.env.NODE_ENV === 'development' ? config.cssStyleSeparator || ' ' : ''\n cssRules.push(`:root {${sep}${[...tokenRules].join(`;${sep}`)}${sep}}`)\n }\n\n // special case for SSR\n const hasDarkLight = 'light' in config.themes && 'dark' in config.themes\n const CNP = `.${THEME_CLASSNAME_PREFIX}`\n\n // themes\n for (const themeName in config.themes) {\n // to allow using the same theme with diff names, be sure we don't mutate!\n const theme = { ...config.themes[themeName] }\n config.themes[themeName] = theme\n let vars = ''\n\n for (const themeKey in theme) {\n if (isWeb) {\n const val = theme[themeKey]\n // TODO sanity check is necessary\n const varName = val instanceof Variable ? val.name : varsByValue[val]?.name\n vars += `--${themeKey}:${varName ? createCSSVariable(varName) : `${val}`};`\n }\n // make sure properly names theme variables\n ensureThemeVariable(theme, themeKey)\n }\n\n if (isWeb) {\n const isDarkOrLightBase = themeName === 'dark' || themeName === 'light'\n const isDark = themeName.startsWith('dark')\n const selector = `${CNP}${themeName}`\n const selectors = [selector]\n\n // since we dont specify dark/light in classnames we have to do an awkward specificity war\n // use config.maxDarkLightNesting to determine how deep you can nest until it breaks\n if (hasDarkLight) {\n const childSelector = `${CNP}${themeName.replace('dark_', '').replace('light_', '')}`\n const order = isDark ? ['dark', 'light'] : ['light', 'dark']\n if (isDarkOrLightBase) {\n order.reverse()\n }\n const [stronger, weaker] = order\n const max = config.maxDarkLightNesting ?? 3\n new Array(max * 2).fill(undefined).forEach((_, pi) => {\n if (pi % 2 === 1) return\n const parents = new Array(pi + 1).fill(undefined).map((_, psi) => {\n return `${CNP}${psi % 2 === 0 ? stronger : weaker}`\n })\n selectors.push(\n `${(parents.length > 1 ? parents.slice(1) : parents).join(' ')} ${childSelector}`\n )\n })\n }\n\n const rootSep = config.themeClassNameOnRoot ? '' : ' '\n cssRules.push(`${selectors.map((x) => `:root${rootSep}${x}`).join(', ')} {${vars}}`)\n\n if (config.shouldAddPrefersColorThemes ?? true) {\n // add media prefers for dark/light base\n if (isDarkOrLightBase) {\n cssRules.push(\n `@media(prefers-color-scheme: ${isDark ? 'dark' : 'light'}) {\n body { background:${theme.background}; color: ${theme.color} }\n :root {${vars} } \n }`\n )\n }\n }\n }\n }\n\n varsByValue.clear()\n Object.freeze(cssRules)\n const css = cssRules.join('\\n')\n\n return {\n cssRules,\n css,\n }\n })()\n\n // faster lookups token keys become $keys to match input\n const tokensParsed: any = parseTokens(config.tokens)\n\n const fontsParsed = (() => {\n if (!config.fonts) {\n throw new Error(`No fonts defined!`)\n }\n const res = {} as typeof config.fonts\n for (const familyName in config.fonts) {\n const family = config.fonts[familyName]\n const parsed = {}\n for (const attrKey in family) {\n const attr = family[attrKey]\n if (attrKey === 'family') {\n parsed[attrKey] = attr\n continue\n }\n parsed[attrKey] = Object.keys(attr).reduce((acc, cur) => {\n acc[`$${cur}`] = attr[cur]\n return acc\n }, {})\n }\n res[`$${familyName}`] = parsed as any\n }\n return res!\n })()\n\n const getCSS = () => {\n return `${themeConfig.css}\\n${getInsertedRules().join('\\n')}`\n }\n\n const next: TamaguiInternalConfig = {\n fonts: {},\n animations: {} as any,\n shorthands: {},\n media: {},\n ...config,\n Provider: createTamaguiProvider({\n getCSS,\n defaultTheme: 'light',\n ...config,\n }),\n fontsParsed,\n themeConfig,\n tokensParsed,\n parsed: true,\n getCSS,\n }\n\n setConfig(next)\n\n if (configListeners.size) {\n configListeners.forEach((cb) => cb(next))\n configListeners.clear()\n }\n\n createdConfigs.set(next, true)\n\n // @ts-expect-error\n return next\n}\n\nconst parseTokens = (tokens: any) => {\n const res: any = {}\n for (const key in tokens) {\n res[key] = {}\n for (const skey in tokens[key]) {\n res[key][`$${skey}`] = tokens[key][skey]\n }\n }\n return res\n}\n\n// mutates, freeze after\n// shared by createTamagui so extracted here\nfunction ensureThemeVariable(theme: any, key: string) {\n const val = theme[key]\n if (!isVariable(val)) {\n theme[key] = createVariable({\n name: key,\n val,\n })\n } else {\n if (val.name !== key) {\n // rename to theme name\n theme[key] = createVariable({\n name: key,\n val: val.val,\n })\n }\n }\n}\n\n// for quick testing types:\n// const x = createTamagui({\n// shorthands: {},\n// media: {},\n// themes: {},\n// tokens: {\n// font: {},\n// color: {},\n// radius: {},\n// size: {},\n// space: {},\n// zIndex: {},\n// },\n// })\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { configListeners, getHasConfigured, setConfig } from './conf'\nimport { THEME_CLASSNAME_PREFIX } from './constants/constants'\nimport { isWeb } from './constants/platform'\nimport { SpacerProps } from './createComponent'\nimport { Variable, createVariable, isVariable } from './createVariable'\nimport { createVariables } from './createVariables'\nimport { createTamaguiProvider } from './helpers/createTamaguiProvider'\nimport { getInsertedRules } from './helpers/insertStyleRule'\nimport {\n registerCSSVariable,\n tokenRules,\n tokensValueToVariable,\n} from './helpers/registerCSSVariable'\nimport { configureMedia } from './hooks/useMedia'\nimport { parseFont, registerFontVariables } from './insertFont'\nimport { Tamagui } from './Tamagui'\nimport {\n AnimationDriver,\n CreateTamaguiConfig,\n GenericTamaguiConfig,\n MediaQueryKey,\n StackProps,\n TamaguiInternalConfig,\n TextProps,\n ThemeObject,\n} from './types'\n\nexport type CreateTamaguiProps =\n // user then re-defines the types after createTamagui returns the typed object they want\n Partial<Omit<GenericTamaguiConfig, 'themes' | 'tokens' | 'animations'>> & {\n animations?: AnimationDriver<any>\n tokens: GenericTamaguiConfig['tokens']\n themes: {\n [key: string]: {\n [key: string]: string | number | Variable\n }\n }\n\n defaultProps?: Record<string, any> & {\n Stack?: StackProps\n Text?: TextProps\n Spacer?: SpacerProps\n }\n\n // for the first render, determines which media queries are true\n // useful for SSR\n mediaQueryDefaultActive?: MediaQueryKey[]\n\n // what's between each CSS style rule, set to \"\\n\" to be easier to read\n // defaults: \"\\n\" when NODE_ENV=development, \"\" otherwise\n cssStyleSeparator?: string\n\n // (Advanced)\n // on the web, tamagui treats `dark` and `light` themes as special and\n // generates extra CSS to avoid having to re-render the entire page.\n // this CSS relies on specificity hacks that multiply by your sub-themes.\n // this sets the maxiumum number of nested dark/light themes you can do\n // defaults to 3 for a balance, but can be higher if you nest them deeply.\n maxDarkLightNesting?: number\n\n // adds @media(prefers-color-scheme) media queries for dark/light\n shouldAddPrefersColorThemes?: boolean\n\n // only if you put the theme classname on the html element we have to generate diff\n themeClassNameOnRoot?: boolean\n }\n\n// config is re-run by the @tamagui/static, dont double validate\nconst createdConfigs = new WeakMap<any, boolean>()\n\nexport type InferTamaguiConfig<Conf extends CreateTamaguiProps> = Conf extends Partial<\n CreateTamaguiConfig<infer A, infer B, infer C, infer D, infer E, infer F>\n>\n ? TamaguiInternalConfig<A, B, C, D, E, F>\n : unknown\n\nexport function createTamagui<Conf extends CreateTamaguiProps>(\n config: Conf\n): InferTamaguiConfig<Conf> {\n if (createdConfigs.has(config)) {\n return config as any\n }\n\n if (process.env.NODE_ENV === 'development') {\n if (!config.tokens) {\n throw new Error(`No tokens provided to Tamagui config`)\n }\n if (!config.themes) {\n throw new Error(`No themes provided to Tamagui config`)\n }\n if (!config.fonts) {\n throw new Error(`No fonts provided to Tamagui config`)\n }\n }\n\n // test env loads a few times as it runs diff tests\n if (getHasConfigured()) {\n console.warn(`Warning: createTamagui called twice (maybe HMR)`)\n }\n\n configureMedia({\n queries: config.media as any,\n defaultActive: config.mediaQueryDefaultActive,\n })\n\n const fontTokens = createVariables(config.fonts!)\n const fontsParsed = (() => {\n const res = {} as typeof fontTokens\n for (const familyName in fontTokens) {\n res[`$${familyName}`] = parseFont(fontTokens[familyName])\n }\n return res!\n })()\n\n const themeConfig = (() => {\n const themes = { ...config.themes }\n let cssRules: string[] = []\n\n if (isWeb) {\n for (const key in config.tokens) {\n for (const skey in config.tokens[key]) {\n const val = config.tokens[key][skey]\n registerCSSVariable(val)\n }\n }\n\n for (const key in fontsParsed) {\n const fontParsed = fontsParsed[key]\n registerFontVariables(fontParsed)\n }\n\n const sep = process.env.NODE_ENV === 'development' ? config.cssStyleSeparator || ' ' : ''\n cssRules.push(`:root {${sep}${[...tokenRules].join(`;${sep}`)}${sep}}`)\n }\n\n // special case for SSR\n const hasDarkLight = 'light' in config.themes && 'dark' in config.themes\n const CNP = `.${THEME_CLASSNAME_PREFIX}`\n\n // dedupe themes to avoid duplicate CSS generation\n type DedupedTheme = {\n names: string[]\n theme: ThemeObject\n }\n const dedupedThemes: {\n [key: string]: DedupedTheme\n } = {}\n const existing = new WeakMap<ThemeObject, DedupedTheme>()\n\n // first, de-dupe and parse them\n for (const themeName in themes) {\n const rawTheme = themes[themeName]\n\n // if existing, avoid\n if (existing.has(rawTheme)) {\n const e = existing.get(rawTheme)!\n themes[themeName] = e.theme\n e.names.push(themeName)\n continue\n }\n\n // parse into variables\n const theme = { ...config.themes[themeName] }\n for (const key in theme) {\n // make sure properly names theme variables\n ensureThemeVariable(theme, key)\n }\n themes[themeName] = theme\n\n // set deduped\n dedupedThemes[themeName] = {\n names: [themeName],\n theme,\n }\n existing.set(config.themes[themeName], dedupedThemes[themeName])\n }\n\n // then, generate from de-duped\n if (isWeb) {\n for (const themeName in dedupedThemes) {\n const { theme, names } = dedupedThemes[themeName]\n let vars = ''\n\n for (const themeKey in theme) {\n const variable = theme[themeKey] as Variable\n let value: any = null\n if (variable.isFloating || !tokensValueToVariable.has(variable.val)) {\n value = variable.val\n } else {\n value = tokensValueToVariable.get(variable.val)!.variable\n }\n vars += `--${themeKey}:${value};`\n }\n\n const isDarkOrLightBase = themeName === 'dark' || themeName === 'light'\n const selectors = names.map((name) => {\n return `${CNP}${name}`\n })\n\n // since we dont specify dark/light in classnames we have to do an awkward specificity war\n // use config.maxDarkLightNesting to determine how deep you can nest until it breaks\n if (hasDarkLight) {\n for (const subName of names) {\n const isDark = isDarkOrLightBase || subName.startsWith('dark_')\n const childSelector = `${CNP}${subName.replace(isDark ? 'dark_' : 'light_', '')}`\n const order = isDark ? ['dark', 'light'] : ['light', 'dark']\n if (isDarkOrLightBase) {\n order.reverse()\n }\n const [stronger, weaker] = order\n const max = config.maxDarkLightNesting ?? 3\n\n new Array(Math.round(max * 1.5)).fill(undefined).forEach((_, pi) => {\n const isOdd = pi % 2 === 1\n if (isOdd && pi < 3) return\n const parents = new Array(pi + 1).fill(undefined).map((_, psi) => {\n return `${CNP}${psi % 2 === 0 ? stronger : weaker}`\n })\n let parentSelectors = parents.length > 1 ? parents.slice(1) : parents\n if (isOdd) {\n const [_first, second, ...rest] = parentSelectors\n parentSelectors = [second, ...rest, second]\n }\n selectors.push(`${parentSelectors.join(' ')} ${childSelector}`)\n })\n }\n }\n\n const rootSep = config.themeClassNameOnRoot ? '' : ' '\n const css = `${selectors.map((x) => `:root${rootSep}${x}`).join(', ')} {${vars}}`\n cssRules.push(css)\n\n if (config.shouldAddPrefersColorThemes && isDarkOrLightBase) {\n // add media prefers for dark/light base\n const isDark = themeName.startsWith('dark')\n cssRules.push(\n `@media(prefers-color-scheme: ${isDark ? 'dark' : 'light'}) {\n body { background:${theme.background}; color: ${theme.color} }\n :root {${vars} } \n }`\n )\n }\n }\n }\n\n // proxy upwards to get parent variables (themes are subset going down)\n for (const themeName in themes) {\n // we could test if this is better as just a straight object spread or fancier proxy\n const cur: string[] = []\n // if theme is dark_blue_alt1_Button\n // this will be the parent names in order: ['dark', 'dark_blue', 'dark_blue_alt1\"]\n const parents = themeName\n .split('_')\n .slice(0, -1)\n .map((part) => {\n cur.push(part)\n return cur.join('_')\n })\n\n if (!parents.length) continue\n\n themes[themeName] = new Proxy(themes[themeName], {\n get(target, key) {\n if (Reflect.has(target, key)) {\n return Reflect.get(target, key)\n }\n // check parents\n for (let i = parents.length - 1; i >= 0; i--) {\n const parent = themes[parents[i]]\n if (!parent) {\n continue\n }\n if (Reflect.has(parent, key)) {\n return Reflect.get(parent, key)\n }\n }\n },\n })\n }\n\n tokensValueToVariable.clear()\n Object.freeze(cssRules)\n const css = cssRules.join('\\n')\n\n return {\n themes,\n cssRules,\n css,\n }\n })()\n\n // faster lookups token keys become $keys to match input\n const tokensParsed: any = parseTokens(config.tokens)\n\n const getCSS = () => {\n return `${themeConfig.css}\\n${getInsertedRules().join('\\n')}`\n }\n\n if (config.shorthands) {\n for (const key in config.shorthands) {\n reversedShorthands[config.shorthands[key]] = key\n }\n }\n\n const next: TamaguiInternalConfig = {\n defaultTheme: 'light',\n fonts: {},\n animations: {} as any,\n shorthands: {},\n media: {},\n ...config,\n themes: themeConfig.themes,\n fontsParsed,\n themeConfig,\n tokensParsed,\n parsed: true,\n getCSS,\n Provider: null as any,\n }\n\n next.Provider = createTamaguiProvider(next)\n\n setConfig(next)\n\n if (configListeners.size) {\n configListeners.forEach((cb) => cb(next))\n configListeners.clear()\n }\n\n createdConfigs.set(next, true)\n\n if (process.env.NODE_ENV === 'development') {\n if (!globalThis['Tamagui']) {\n globalThis['Tamagui'] = Tamagui\n }\n }\n\n // @ts-expect-error\n return next\n}\n\nexport const reversedShorthands: Record<string, string> = {}\n\nconst parseTokens = (tokens: any) => {\n const res: any = {}\n for (const key in tokens) {\n res[key] = {}\n for (const skey in tokens[key]) {\n res[key][`$${skey}`] = tokens[key][skey]\n }\n }\n return res\n}\n\n// mutates, freeze after\n// shared by createTamagui so extracted here\nfunction ensureThemeVariable(theme: any, key: string) {\n const val = theme[key]\n const themeKey = key\n if (!isVariable(val)) {\n theme[key] = createVariable({\n key: themeKey,\n name: themeKey,\n val,\n })\n } else {\n if (val.name !== themeKey) {\n // rename to theme name\n theme[key] = createVariable({\n key: val.name,\n name: themeKey,\n val: val.val,\n })\n }\n }\n}\n\n// for quick testing types:\n// const x = createTamagui({\n// shorthands: {},\n// media: {},\n// themes: {},\n// tokens: {\n// font: {},\n// color: {},\n// radius: {},\n// size: {},\n// space: {},\n// zIndex: {},\n// },\n// })\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/createTheme.js
CHANGED
|
@@ -2,7 +2,6 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
5
|
var __export = (target, all) => {
|
|
7
6
|
for (var name in all)
|
|
8
7
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -21,7 +20,9 @@ __export(createTheme_exports, {
|
|
|
21
20
|
createTheme: () => createTheme
|
|
22
21
|
});
|
|
23
22
|
module.exports = __toCommonJS(createTheme_exports);
|
|
24
|
-
const createTheme =
|
|
23
|
+
const createTheme = (theme) => {
|
|
24
|
+
return theme;
|
|
25
|
+
};
|
|
25
26
|
// Annotate the CommonJS export names for ESM import in node:
|
|
26
27
|
0 && (module.exports = {
|
|
27
28
|
createTheme
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/createTheme.ts"],
|
|
4
|
-
"sourcesContent": ["import { Variable } from './createVariable'\n\ntype GenericTheme = { [key: string]: string | Variable }\n\nexport const createTheme = <Theme extends GenericTheme>(\n theme: Theme\n): {\n [K in keyof Theme]: Theme[K] | string | Variable\n} => theme\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { Variable } from './createVariable'\n\ntype GenericTheme = { [key: string]: string | Variable }\n\nexport const createTheme = <Theme extends GenericTheme>(\n theme: Theme\n): {\n [K in keyof Theme]: Theme[K] | string | Variable\n} => {\n return theme\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIO,MAAM,cAAc,CACzB,UAGG;AACH,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/createTokens.js
CHANGED
|
@@ -2,7 +2,6 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
5
|
var __export = (target, all) => {
|
|
7
6
|
for (var name in all)
|
|
8
7
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -18,35 +17,19 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
18
|
var createTokens_exports = {};
|
|
20
19
|
__export(createTokens_exports, {
|
|
21
|
-
createTokens: () => createTokens
|
|
22
|
-
mapTokensToVariables: () => mapTokensToVariables
|
|
20
|
+
createTokens: () => createTokens
|
|
23
21
|
});
|
|
24
22
|
module.exports = __toCommonJS(createTokens_exports);
|
|
25
|
-
var
|
|
23
|
+
var import_createVariables = require("./createVariables");
|
|
26
24
|
var import_validate = require("./helpers/validate");
|
|
27
25
|
function createTokens(tokens) {
|
|
28
26
|
if (process.env.NODE_ENV === "development") {
|
|
29
27
|
(0, import_validate.validateTokens)(tokens);
|
|
30
28
|
}
|
|
31
|
-
return
|
|
29
|
+
return (0, import_createVariables.createVariables)(tokens);
|
|
32
30
|
}
|
|
33
|
-
__name(createTokens, "createTokens");
|
|
34
|
-
const mapTokensToVariables = /* @__PURE__ */ __name((tokens, parentPath = "") => {
|
|
35
|
-
const res = {};
|
|
36
|
-
for (const key in tokens) {
|
|
37
|
-
let val = tokens[key];
|
|
38
|
-
const name = parentPath ? `${parentPath}-${key}` : key;
|
|
39
|
-
if (val && typeof val === "object") {
|
|
40
|
-
res[key] = mapTokensToVariables(tokens[key], name);
|
|
41
|
-
} else {
|
|
42
|
-
res[key] = (0, import_createVariable.createVariable)({ val, name });
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return res;
|
|
46
|
-
}, "mapTokensToVariables");
|
|
47
31
|
// Annotate the CommonJS export names for ESM import in node:
|
|
48
32
|
0 && (module.exports = {
|
|
49
|
-
createTokens
|
|
50
|
-
mapTokensToVariables
|
|
33
|
+
createTokens
|
|
51
34
|
});
|
|
52
35
|
//# sourceMappingURL=createTokens.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/createTokens.ts"],
|
|
4
|
-
"sourcesContent": ["import { Variable
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { Variable } from './createVariable'\nimport { createVariables } from './createVariables'\nimport { validateTokens } from './helpers/validate'\nimport { CreateTokens } from './types'\n\n// tokens.color.dark.red ===> { var: `color-dark-red`, val: '' }\nexport function createTokens<T extends CreateTokens>(tokens: T): MakeTokens<T> {\n if (process.env.NODE_ENV === 'development') {\n validateTokens(tokens)\n }\n return createVariables(tokens as any) as any\n}\n\n// verbose but gives us nice types...\ntype MakeTokens<T> = T extends {\n color: infer E\n space: infer F\n size: infer G\n radius: infer H\n zIndex: infer J\n}\n ? {\n color: {\n [key in keyof E]: Variable\n }\n space: {\n [key in keyof F]: Variable\n }\n size: {\n [key in keyof G]: Variable\n }\n radius: {\n [key in keyof H]: Variable\n }\n zIndex: {\n [key in keyof J]: Variable\n }\n }\n : never\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,6BAAgC;AAChC,sBAA+B;AAIxB,sBAA8C,QAA0B;AAC7E,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,wCAAe,MAAM;AAAA,EACvB;AACA,SAAO,4CAAgB,MAAa;AACtC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,7 +2,6 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
5
|
var __export = (target, all) => {
|
|
7
6
|
for (var name in all)
|
|
8
7
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -18,12 +17,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
18
|
var createVariable_exports = {};
|
|
20
19
|
__export(createVariable_exports, {
|
|
21
|
-
IS_VARIABLE_SYMBOL: () => IS_VARIABLE_SYMBOL,
|
|
22
20
|
Variable: () => Variable,
|
|
23
21
|
createCSSVariable: () => createCSSVariable,
|
|
24
22
|
createVariable: () => createVariable,
|
|
25
23
|
getVariableName: () => getVariableName,
|
|
26
24
|
getVariableValue: () => getVariableValue,
|
|
25
|
+
getVariableVariable: () => getVariableVariable,
|
|
27
26
|
isVariable: () => isVariable
|
|
28
27
|
});
|
|
29
28
|
module.exports = __toCommonJS(createVariable_exports);
|
|
@@ -31,47 +30,73 @@ var import_platform = require("./constants/platform");
|
|
|
31
30
|
var _a;
|
|
32
31
|
const IS_VARIABLE_SYMBOL = "__isVariable__";
|
|
33
32
|
class Variable {
|
|
34
|
-
constructor(
|
|
33
|
+
constructor(props) {
|
|
35
34
|
this[_a] = true;
|
|
35
|
+
this.isFloating = false;
|
|
36
|
+
const { val, name, key, isFloating } = props;
|
|
36
37
|
this.val = isVariable(val) ? val.val : val;
|
|
37
38
|
this.name = name;
|
|
38
|
-
this.
|
|
39
|
+
this.key = key;
|
|
40
|
+
this.variable = import_platform.isWeb ? createCSSVariable(name) : "";
|
|
41
|
+
if (isFloating) {
|
|
42
|
+
this.isFloating = true;
|
|
43
|
+
}
|
|
39
44
|
}
|
|
40
45
|
toString() {
|
|
41
46
|
return `${import_platform.isWeb ? this.variable : this.val}`;
|
|
42
47
|
}
|
|
43
48
|
}
|
|
44
|
-
__name(Variable, "Variable");
|
|
45
49
|
_a = IS_VARIABLE_SYMBOL;
|
|
46
|
-
const createVariable =
|
|
50
|
+
const createVariable = (props) => {
|
|
51
|
+
if (isVariable(props)) {
|
|
52
|
+
return props;
|
|
53
|
+
}
|
|
54
|
+
return new Variable(props);
|
|
55
|
+
};
|
|
47
56
|
function isVariable(v) {
|
|
48
|
-
return v instanceof Variable || v && v[IS_VARIABLE_SYMBOL];
|
|
57
|
+
return !!(v instanceof Variable || v && v[IS_VARIABLE_SYMBOL]);
|
|
49
58
|
}
|
|
50
|
-
__name(isVariable, "isVariable");
|
|
51
59
|
function getVariableValue(v) {
|
|
52
60
|
if (isVariable(v))
|
|
53
61
|
return v.val;
|
|
54
62
|
return v;
|
|
55
63
|
}
|
|
56
|
-
__name(getVariableValue, "getVariableValue");
|
|
57
64
|
function getVariableName(v) {
|
|
58
65
|
if (isVariable(v))
|
|
59
66
|
return v.name;
|
|
60
67
|
return v;
|
|
61
68
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
69
|
+
function getVariableVariable(v) {
|
|
70
|
+
if (isVariable(v))
|
|
71
|
+
return v.variable;
|
|
72
|
+
return v;
|
|
73
|
+
}
|
|
74
|
+
const createCSSVariable = (nameProp, includeVar = true) => {
|
|
75
|
+
if (process.env.NODE_ENV === "development") {
|
|
76
|
+
if (!nameProp || typeof nameProp !== "string") {
|
|
77
|
+
console.warn("invalid name", nameProp);
|
|
78
|
+
return ``;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
let name = "";
|
|
82
|
+
for (let i = 0; i < nameProp.length; i++) {
|
|
83
|
+
const code = nameProp.charCodeAt(i);
|
|
84
|
+
if (code >= 65 && code <= 90 || code >= 97 && code <= 122 || code == 95 || code === 45 || code >= 48 && code <= 57) {
|
|
85
|
+
name += nameProp[i];
|
|
86
|
+
} else {
|
|
87
|
+
name += `-c${code}-`;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
65
90
|
return includeVar ? `var(--${name})` : name;
|
|
66
|
-
}
|
|
91
|
+
};
|
|
67
92
|
// Annotate the CommonJS export names for ESM import in node:
|
|
68
93
|
0 && (module.exports = {
|
|
69
|
-
IS_VARIABLE_SYMBOL,
|
|
70
94
|
Variable,
|
|
71
95
|
createCSSVariable,
|
|
72
96
|
createVariable,
|
|
73
97
|
getVariableName,
|
|
74
98
|
getVariableValue,
|
|
99
|
+
getVariableVariable,
|
|
75
100
|
isVariable
|
|
76
101
|
});
|
|
77
102
|
//# sourceMappingURL=createVariable.js.map
|