@tamagui/web 1.13.3 → 1.14.0
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/Tamagui.js +1 -76
- package/dist/cjs/Tamagui.js.map +2 -2
- package/dist/cjs/addTheme.js +2 -77
- package/dist/cjs/addTheme.js.map +2 -2
- package/dist/cjs/config.js +1 -122
- package/dist/cjs/config.js.map +2 -2
- package/dist/cjs/constants/constants.js +1 -48
- package/dist/cjs/constants/constants.js.map +2 -2
- package/dist/cjs/constants/isDevTools.js +1 -36
- package/dist/cjs/constants/isDevTools.js.map +2 -2
- package/dist/cjs/contexts/AnimationDriverContext.js +1 -29
- package/dist/cjs/contexts/AnimationDriverContext.js.map +2 -2
- package/dist/cjs/contexts/ButtonNestingContext.js +1 -29
- package/dist/cjs/contexts/ButtonNestingContext.js.map +2 -2
- package/dist/cjs/contexts/FontLanguageContext.js +1 -29
- package/dist/cjs/contexts/FontLanguageContext.js.map +2 -2
- package/dist/cjs/contexts/TextAncestorContext.js +1 -29
- package/dist/cjs/contexts/TextAncestorContext.js.map +2 -2
- package/dist/cjs/createComponent.js +2 -874
- package/dist/cjs/createComponent.js.map +3 -3
- package/dist/cjs/createFont.js +1 -68
- package/dist/cjs/createFont.js.map +2 -2
- package/dist/cjs/createShorthands.js +1 -30
- package/dist/cjs/createShorthands.js.map +2 -2
- package/dist/cjs/createTamagui.js +5 -202
- package/dist/cjs/createTamagui.js.map +2 -2
- package/dist/cjs/createTheme.js +1 -30
- package/dist/cjs/createTheme.js.map +2 -2
- package/dist/cjs/createTokens.js +1 -38
- package/dist/cjs/createTokens.js.map +2 -2
- package/dist/cjs/createVariable.js +1 -110
- package/dist/cjs/createVariable.js.map +2 -2
- package/dist/cjs/createVariables.js +1 -59
- package/dist/cjs/createVariables.js.map +2 -2
- package/dist/cjs/helpers/ThemeManager.js +1 -236
- package/dist/cjs/helpers/ThemeManager.js.map +3 -3
- package/dist/cjs/helpers/ThemeManagerContext.js +1 -29
- package/dist/cjs/helpers/ThemeManagerContext.js.map +2 -2
- package/dist/cjs/helpers/createMediaStyle.js +1 -66
- package/dist/cjs/helpers/createMediaStyle.js.map +2 -2
- package/dist/cjs/helpers/createPropMapper.js +2 -431
- package/dist/cjs/helpers/createPropMapper.js.map +2 -2
- package/dist/cjs/helpers/createProxy.js +2 -41
- package/dist/cjs/helpers/createProxy.js.map +2 -2
- package/dist/cjs/helpers/defaultOffset.js +1 -28
- package/dist/cjs/helpers/defaultOffset.js.map +2 -2
- package/dist/cjs/helpers/expandStyle.js +1 -85
- package/dist/cjs/helpers/expandStyle.js.map +2 -2
- package/dist/cjs/helpers/expandStyles.js +1 -76
- package/dist/cjs/helpers/expandStyles.js.map +2 -2
- package/dist/cjs/helpers/extendStaticConfig.js +1 -91
- package/dist/cjs/helpers/extendStaticConfig.js.map +2 -2
- package/dist/cjs/helpers/getAnimationDriver.js +1 -31
- package/dist/cjs/helpers/getAnimationDriver.js.map +2 -2
- package/dist/cjs/helpers/getExpandedShorthands.js +1 -38
- package/dist/cjs/helpers/getExpandedShorthands.js.map +2 -2
- package/dist/cjs/helpers/getFontLanguage.js +1 -28
- package/dist/cjs/helpers/getFontLanguage.js.map +2 -2
- package/dist/cjs/helpers/getSplitStyles.js +3 -865
- package/dist/cjs/helpers/getSplitStyles.js.map +3 -3
- package/dist/cjs/helpers/getStylesAtomic.js +1 -226
- package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
- package/dist/cjs/helpers/getStylesAtomic.native.js +1 -37
- package/dist/cjs/helpers/getStylesAtomic.native.js.map +2 -2
- package/dist/cjs/helpers/getThemeCSSRules.js +4 -126
- package/dist/cjs/helpers/getThemeCSSRules.js.map +2 -2
- package/dist/cjs/helpers/getThemeCSSRules.native.js +1 -30
- package/dist/cjs/helpers/getThemeCSSRules.native.js.map +2 -2
- package/dist/cjs/helpers/getVariantExtras.js +1 -91
- package/dist/cjs/helpers/getVariantExtras.js.map +2 -2
- package/dist/cjs/helpers/insertStyleRule.js +2 -222
- package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
- package/dist/cjs/helpers/isObj.js +1 -28
- package/dist/cjs/helpers/isObj.js.map +2 -2
- package/dist/cjs/helpers/isTamaguiComponent.js +1 -31
- package/dist/cjs/helpers/isTamaguiComponent.js.map +2 -2
- package/dist/cjs/helpers/isTamaguiElement.js +1 -32
- package/dist/cjs/helpers/isTamaguiElement.js.map +2 -2
- package/dist/cjs/helpers/matchMedia.js +1 -41
- package/dist/cjs/helpers/matchMedia.js.map +2 -2
- package/dist/cjs/helpers/matchMedia.native.js +1 -47
- package/dist/cjs/helpers/matchMedia.native.js.map +2 -2
- package/dist/cjs/helpers/mergeProps.js +1 -53
- package/dist/cjs/helpers/mergeProps.js.map +2 -2
- package/dist/cjs/helpers/normalizeColor.js +1 -66
- package/dist/cjs/helpers/normalizeColor.js.map +2 -2
- package/dist/cjs/helpers/normalizeShadow.js +1 -46
- package/dist/cjs/helpers/normalizeShadow.js.map +2 -2
- package/dist/cjs/helpers/normalizeShadow.native.js +1 -54
- package/dist/cjs/helpers/normalizeShadow.native.js.map +2 -2
- package/dist/cjs/helpers/normalizeStylePropKeys.js +1 -28
- package/dist/cjs/helpers/normalizeStylePropKeys.js.map +2 -2
- package/dist/cjs/helpers/normalizeStylePropKeys.native.js +1 -39
- package/dist/cjs/helpers/normalizeStylePropKeys.native.js.map +2 -2
- package/dist/cjs/helpers/normalizeValueWithProperty.js +1 -125
- package/dist/cjs/helpers/normalizeValueWithProperty.js.map +2 -2
- package/dist/cjs/helpers/proxyThemeVariables.js +1 -39
- package/dist/cjs/helpers/proxyThemeVariables.js.map +2 -2
- package/dist/cjs/helpers/pseudoDescriptors.js +1 -52
- package/dist/cjs/helpers/pseudoDescriptors.js.map +2 -2
- package/dist/cjs/helpers/registerCSSVariable.js +1 -39
- package/dist/cjs/helpers/registerCSSVariable.js.map +2 -2
- package/dist/cjs/helpers/themeable.js +1 -61
- package/dist/cjs/helpers/themeable.js.map +2 -2
- package/dist/cjs/helpers/themes.js +1 -75
- package/dist/cjs/helpers/themes.js.map +2 -2
- package/dist/cjs/helpers/timer.js +1 -34
- package/dist/cjs/helpers/timer.js.map +2 -2
- package/dist/cjs/helpers/useShallowSetState.js +1 -58
- package/dist/cjs/helpers/useShallowSetState.js.map +2 -2
- package/dist/cjs/helpers/warnOnce.js +1 -37
- package/dist/cjs/helpers/warnOnce.js.map +2 -2
- package/dist/cjs/helpers/withStaticProperties.js +1 -32
- package/dist/cjs/helpers/withStaticProperties.js.map +2 -2
- package/dist/cjs/hooks/getThemeUnwrapped.js +1 -33
- package/dist/cjs/hooks/getThemeUnwrapped.js.map +2 -2
- package/dist/cjs/hooks/useAnimationDriver.js +1 -33
- package/dist/cjs/hooks/useAnimationDriver.js.map +2 -2
- package/dist/cjs/hooks/useId.js +1 -28
- package/dist/cjs/hooks/useId.js.map +2 -2
- package/dist/cjs/hooks/useIsTouchDevice.js +1 -32
- package/dist/cjs/hooks/useIsTouchDevice.js.map +2 -2
- package/dist/cjs/hooks/useMedia.js +1 -264
- package/dist/cjs/hooks/useMedia.js.map +2 -2
- package/dist/cjs/hooks/useSafeRef.js +1 -58
- package/dist/cjs/hooks/useSafeRef.js.map +2 -2
- package/dist/cjs/hooks/useServerHooks.js +1 -35
- package/dist/cjs/hooks/useServerHooks.js.map +2 -2
- package/dist/cjs/hooks/useStyle.js +1 -60
- package/dist/cjs/hooks/useStyle.js.map +2 -2
- package/dist/cjs/hooks/useTheme.js +1 -229
- package/dist/cjs/hooks/useTheme.js.map +3 -3
- package/dist/cjs/hooks/useThemeName.js +1 -51
- package/dist/cjs/hooks/useThemeName.js.map +2 -2
- package/dist/cjs/index.js +1 -110
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/inject-styles.js +1 -39
- package/dist/cjs/inject-styles.js.map +2 -2
- package/dist/cjs/insertFont.js +1 -92
- package/dist/cjs/insertFont.js.map +2 -2
- package/dist/cjs/setupHooks.js +1 -33
- package/dist/cjs/setupHooks.js.map +2 -2
- package/dist/cjs/setupReactNative.js +1 -50
- package/dist/cjs/setupReactNative.js.map +2 -2
- package/dist/cjs/styled.js +1 -93
- package/dist/cjs/styled.js.map +2 -2
- package/dist/cjs/types.js +1 -16
- package/dist/cjs/types.js.map +3 -3
- package/dist/cjs/updateTheme.js +1 -46
- package/dist/cjs/updateTheme.js.map +2 -2
- package/dist/cjs/views/AnimationDriverProvider.js +1 -32
- package/dist/cjs/views/AnimationDriverProvider.js.map +2 -2
- package/dist/cjs/views/FontLanguage.js +1 -40
- package/dist/cjs/views/FontLanguage.js.map +2 -2
- package/dist/cjs/views/FontLanguage.native.js +1 -34
- package/dist/cjs/views/FontLanguage.native.js.map +2 -2
- package/dist/cjs/views/FontLanguage.types.js +1 -16
- package/dist/cjs/views/FontLanguage.types.js.map +2 -2
- package/dist/cjs/views/Slot.js +1 -91
- package/dist/cjs/views/Slot.js.map +2 -2
- package/dist/cjs/views/Stack.js +1 -37
- package/dist/cjs/views/Stack.js.map +2 -2
- package/dist/cjs/views/TamaguiProvider.js +1 -90
- package/dist/cjs/views/TamaguiProvider.js.map +2 -2
- package/dist/cjs/views/Text.js +1 -95
- package/dist/cjs/views/Text.js.map +2 -2
- package/dist/cjs/views/Theme.js +1 -80
- package/dist/cjs/views/Theme.js.map +3 -3
- package/dist/cjs/views/ThemeProvider.js +1 -69
- package/dist/cjs/views/ThemeProvider.js.map +2 -2
- package/dist/esm/Tamagui.js +1 -44
- package/dist/esm/Tamagui.js.map +2 -2
- package/dist/esm/Tamagui.mjs +1 -44
- package/dist/esm/Tamagui.mjs.map +2 -2
- package/dist/esm/addTheme.js +2 -53
- package/dist/esm/addTheme.js.map +2 -2
- package/dist/esm/addTheme.mjs +2 -53
- package/dist/esm/addTheme.mjs.map +2 -2
- package/dist/esm/config.js +1 -89
- package/dist/esm/config.js.map +2 -2
- package/dist/esm/config.mjs +1 -89
- package/dist/esm/config.mjs.map +2 -2
- package/dist/esm/constants/constants.js +1 -21
- package/dist/esm/constants/constants.js.map +2 -2
- package/dist/esm/constants/constants.mjs +1 -21
- package/dist/esm/constants/constants.mjs.map +2 -2
- package/dist/esm/constants/isDevTools.js +1 -12
- package/dist/esm/constants/isDevTools.js.map +2 -2
- package/dist/esm/constants/isDevTools.mjs +1 -12
- package/dist/esm/constants/isDevTools.mjs.map +2 -2
- package/dist/esm/contexts/AnimationDriverContext.js +1 -5
- package/dist/esm/contexts/AnimationDriverContext.js.map +2 -2
- package/dist/esm/contexts/AnimationDriverContext.mjs +1 -5
- package/dist/esm/contexts/AnimationDriverContext.mjs.map +2 -2
- package/dist/esm/contexts/ButtonNestingContext.js +1 -5
- package/dist/esm/contexts/ButtonNestingContext.js.map +2 -2
- package/dist/esm/contexts/ButtonNestingContext.mjs +1 -5
- package/dist/esm/contexts/ButtonNestingContext.mjs.map +2 -2
- package/dist/esm/contexts/FontLanguageContext.js +1 -5
- package/dist/esm/contexts/FontLanguageContext.js.map +2 -2
- package/dist/esm/contexts/FontLanguageContext.mjs +1 -5
- package/dist/esm/contexts/FontLanguageContext.mjs.map +2 -2
- package/dist/esm/contexts/TextAncestorContext.js +1 -5
- package/dist/esm/contexts/TextAncestorContext.js.map +2 -2
- package/dist/esm/contexts/TextAncestorContext.mjs +1 -5
- package/dist/esm/contexts/TextAncestorContext.mjs.map +2 -2
- package/dist/esm/createComponent.js +2 -846
- package/dist/esm/createComponent.js.map +3 -3
- package/dist/esm/createComponent.mjs +2 -846
- package/dist/esm/createComponent.mjs.map +3 -3
- package/dist/esm/createFont.js +1 -44
- package/dist/esm/createFont.js.map +2 -2
- package/dist/esm/createFont.mjs +1 -44
- package/dist/esm/createFont.mjs.map +2 -2
- package/dist/esm/createShorthands.js +1 -6
- package/dist/esm/createShorthands.js.map +2 -2
- package/dist/esm/createShorthands.mjs +1 -6
- package/dist/esm/createShorthands.mjs.map +2 -2
- package/dist/esm/createTamagui.js +5 -186
- package/dist/esm/createTamagui.js.map +2 -2
- package/dist/esm/createTamagui.mjs +5 -186
- package/dist/esm/createTamagui.mjs.map +2 -2
- package/dist/esm/createTheme.js +1 -6
- package/dist/esm/createTheme.js.map +2 -2
- package/dist/esm/createTheme.mjs +1 -6
- package/dist/esm/createTheme.mjs.map +2 -2
- package/dist/esm/createTokens.js +1 -14
- package/dist/esm/createTokens.js.map +2 -2
- package/dist/esm/createTokens.mjs +1 -14
- package/dist/esm/createTokens.mjs.map +2 -2
- package/dist/esm/createVariable.js +1 -77
- package/dist/esm/createVariable.js.map +2 -2
- package/dist/esm/createVariable.mjs +1 -77
- package/dist/esm/createVariable.mjs.map +2 -2
- package/dist/esm/createVariables.js +1 -34
- package/dist/esm/createVariables.js.map +2 -2
- package/dist/esm/createVariables.mjs +1 -34
- package/dist/esm/createVariables.mjs.map +2 -2
- package/dist/esm/helpers/ThemeManager.js +1 -211
- package/dist/esm/helpers/ThemeManager.js.map +3 -3
- package/dist/esm/helpers/ThemeManager.mjs +1 -211
- package/dist/esm/helpers/ThemeManager.mjs.map +3 -3
- package/dist/esm/helpers/ThemeManagerContext.js +1 -5
- package/dist/esm/helpers/ThemeManagerContext.js.map +2 -2
- package/dist/esm/helpers/ThemeManagerContext.mjs +1 -5
- package/dist/esm/helpers/ThemeManagerContext.mjs.map +2 -2
- package/dist/esm/helpers/createMediaStyle.js +1 -41
- package/dist/esm/helpers/createMediaStyle.js.map +2 -2
- package/dist/esm/helpers/createMediaStyle.mjs +1 -41
- package/dist/esm/helpers/createMediaStyle.mjs.map +2 -2
- package/dist/esm/helpers/createPropMapper.js +2 -404
- package/dist/esm/helpers/createPropMapper.js.map +2 -2
- package/dist/esm/helpers/createPropMapper.mjs +2 -404
- package/dist/esm/helpers/createPropMapper.mjs.map +2 -2
- package/dist/esm/helpers/createProxy.js +2 -17
- package/dist/esm/helpers/createProxy.js.map +2 -2
- package/dist/esm/helpers/createProxy.mjs +2 -17
- package/dist/esm/helpers/createProxy.mjs.map +2 -2
- package/dist/esm/helpers/defaultOffset.js +1 -4
- package/dist/esm/helpers/defaultOffset.js.map +2 -2
- package/dist/esm/helpers/defaultOffset.mjs +1 -4
- package/dist/esm/helpers/defaultOffset.mjs.map +2 -2
- package/dist/esm/helpers/expandStyle.js +1 -61
- package/dist/esm/helpers/expandStyle.js.map +2 -2
- package/dist/esm/helpers/expandStyle.mjs +1 -61
- package/dist/esm/helpers/expandStyle.mjs.map +2 -2
- package/dist/esm/helpers/expandStyles.js +1 -51
- package/dist/esm/helpers/expandStyles.js.map +2 -2
- package/dist/esm/helpers/expandStyles.mjs +1 -51
- package/dist/esm/helpers/expandStyles.mjs.map +2 -2
- package/dist/esm/helpers/extendStaticConfig.js +1 -66
- package/dist/esm/helpers/extendStaticConfig.js.map +2 -2
- package/dist/esm/helpers/extendStaticConfig.mjs +1 -66
- package/dist/esm/helpers/extendStaticConfig.mjs.map +2 -2
- package/dist/esm/helpers/getAnimationDriver.js +1 -7
- package/dist/esm/helpers/getAnimationDriver.js.map +2 -2
- package/dist/esm/helpers/getAnimationDriver.mjs +1 -7
- package/dist/esm/helpers/getAnimationDriver.mjs.map +2 -2
- package/dist/esm/helpers/getExpandedShorthands.js +1 -14
- package/dist/esm/helpers/getExpandedShorthands.js.map +2 -2
- package/dist/esm/helpers/getExpandedShorthands.mjs +1 -14
- package/dist/esm/helpers/getExpandedShorthands.mjs.map +2 -2
- package/dist/esm/helpers/getFontLanguage.js +1 -4
- package/dist/esm/helpers/getFontLanguage.js.map +2 -2
- package/dist/esm/helpers/getFontLanguage.mjs +1 -4
- package/dist/esm/helpers/getFontLanguage.mjs.map +2 -2
- package/dist/esm/helpers/getSplitStyles.js +3 -866
- package/dist/esm/helpers/getSplitStyles.js.map +3 -3
- package/dist/esm/helpers/getSplitStyles.mjs +3 -866
- package/dist/esm/helpers/getSplitStyles.mjs.map +3 -3
- package/dist/esm/helpers/getStylesAtomic.js +1 -200
- package/dist/esm/helpers/getStylesAtomic.js.map +2 -2
- package/dist/esm/helpers/getStylesAtomic.mjs +1 -200
- package/dist/esm/helpers/getStylesAtomic.mjs.map +2 -2
- package/dist/esm/helpers/getStylesAtomic.native.js +1 -11
- package/dist/esm/helpers/getStylesAtomic.native.js.map +2 -2
- package/dist/esm/helpers/getStylesAtomic.native.mjs +1 -11
- package/dist/esm/helpers/getStylesAtomic.native.mjs.map +2 -2
- package/dist/esm/helpers/getThemeCSSRules.js +4 -102
- package/dist/esm/helpers/getThemeCSSRules.js.map +2 -2
- package/dist/esm/helpers/getThemeCSSRules.mjs +4 -102
- package/dist/esm/helpers/getThemeCSSRules.mjs.map +2 -2
- package/dist/esm/helpers/getThemeCSSRules.native.js +1 -6
- package/dist/esm/helpers/getThemeCSSRules.native.js.map +2 -2
- package/dist/esm/helpers/getThemeCSSRules.native.mjs +1 -6
- package/dist/esm/helpers/getThemeCSSRules.native.mjs.map +2 -2
- package/dist/esm/helpers/getVariantExtras.js +1 -66
- package/dist/esm/helpers/getVariantExtras.js.map +2 -2
- package/dist/esm/helpers/getVariantExtras.mjs +1 -66
- package/dist/esm/helpers/getVariantExtras.mjs.map +2 -2
- package/dist/esm/helpers/insertStyleRule.js +2 -190
- package/dist/esm/helpers/insertStyleRule.js.map +2 -2
- package/dist/esm/helpers/insertStyleRule.mjs +2 -190
- package/dist/esm/helpers/insertStyleRule.mjs.map +2 -2
- package/dist/esm/helpers/isObj.js +1 -4
- package/dist/esm/helpers/isObj.js.map +2 -2
- package/dist/esm/helpers/isObj.mjs +1 -4
- package/dist/esm/helpers/isObj.mjs.map +2 -2
- package/dist/esm/helpers/isTamaguiComponent.js +1 -7
- package/dist/esm/helpers/isTamaguiComponent.js.map +2 -2
- package/dist/esm/helpers/isTamaguiComponent.mjs +1 -7
- package/dist/esm/helpers/isTamaguiComponent.mjs.map +2 -2
- package/dist/esm/helpers/isTamaguiElement.js +1 -8
- package/dist/esm/helpers/isTamaguiElement.js.map +2 -2
- package/dist/esm/helpers/isTamaguiElement.mjs +1 -8
- package/dist/esm/helpers/isTamaguiElement.mjs.map +2 -2
- package/dist/esm/helpers/matchMedia.js +1 -16
- package/dist/esm/helpers/matchMedia.js.map +2 -2
- package/dist/esm/helpers/matchMedia.mjs +1 -16
- package/dist/esm/helpers/matchMedia.mjs.map +2 -2
- package/dist/esm/helpers/matchMedia.native.js +1 -22
- package/dist/esm/helpers/matchMedia.native.js.map +2 -2
- package/dist/esm/helpers/matchMedia.native.mjs +1 -22
- package/dist/esm/helpers/matchMedia.native.mjs.map +2 -2
- package/dist/esm/helpers/mergeProps.js +1 -29
- package/dist/esm/helpers/mergeProps.js.map +2 -2
- package/dist/esm/helpers/mergeProps.mjs +1 -29
- package/dist/esm/helpers/mergeProps.mjs.map +2 -2
- package/dist/esm/helpers/normalizeColor.js +1 -30
- package/dist/esm/helpers/normalizeColor.js.map +2 -2
- package/dist/esm/helpers/normalizeColor.mjs +1 -30
- package/dist/esm/helpers/normalizeColor.mjs.map +2 -2
- package/dist/esm/helpers/normalizeShadow.js +1 -22
- package/dist/esm/helpers/normalizeShadow.js.map +2 -2
- package/dist/esm/helpers/normalizeShadow.mjs +1 -22
- package/dist/esm/helpers/normalizeShadow.mjs.map +2 -2
- package/dist/esm/helpers/normalizeShadow.native.js +1 -30
- package/dist/esm/helpers/normalizeShadow.native.js.map +2 -2
- package/dist/esm/helpers/normalizeShadow.native.mjs +1 -30
- package/dist/esm/helpers/normalizeShadow.native.mjs.map +2 -2
- package/dist/esm/helpers/normalizeStylePropKeys.js +1 -4
- package/dist/esm/helpers/normalizeStylePropKeys.js.map +2 -2
- package/dist/esm/helpers/normalizeStylePropKeys.mjs +1 -4
- package/dist/esm/helpers/normalizeStylePropKeys.mjs.map +2 -2
- package/dist/esm/helpers/normalizeStylePropKeys.native.js +1 -15
- package/dist/esm/helpers/normalizeStylePropKeys.native.js.map +2 -2
- package/dist/esm/helpers/normalizeStylePropKeys.native.mjs +1 -15
- package/dist/esm/helpers/normalizeStylePropKeys.native.mjs.map +2 -2
- package/dist/esm/helpers/normalizeValueWithProperty.js +1 -100
- package/dist/esm/helpers/normalizeValueWithProperty.js.map +2 -2
- package/dist/esm/helpers/normalizeValueWithProperty.mjs +1 -100
- package/dist/esm/helpers/normalizeValueWithProperty.mjs.map +2 -2
- package/dist/esm/helpers/proxyThemeVariables.js +1 -15
- package/dist/esm/helpers/proxyThemeVariables.js.map +2 -2
- package/dist/esm/helpers/proxyThemeVariables.mjs +1 -15
- package/dist/esm/helpers/proxyThemeVariables.mjs.map +2 -2
- package/dist/esm/helpers/pseudoDescriptors.js +1 -28
- package/dist/esm/helpers/pseudoDescriptors.js.map +2 -2
- package/dist/esm/helpers/pseudoDescriptors.mjs +1 -28
- package/dist/esm/helpers/pseudoDescriptors.mjs.map +2 -2
- package/dist/esm/helpers/registerCSSVariable.js +1 -13
- package/dist/esm/helpers/registerCSSVariable.js.map +2 -2
- package/dist/esm/helpers/registerCSSVariable.mjs +1 -13
- package/dist/esm/helpers/registerCSSVariable.mjs.map +2 -2
- package/dist/esm/helpers/themeable.js +1 -27
- package/dist/esm/helpers/themeable.js.map +2 -2
- package/dist/esm/helpers/themeable.mjs +1 -27
- package/dist/esm/helpers/themeable.mjs.map +2 -2
- package/dist/esm/helpers/themes.js +1 -50
- package/dist/esm/helpers/themes.js.map +2 -2
- package/dist/esm/helpers/themes.mjs +1 -50
- package/dist/esm/helpers/themes.mjs.map +2 -2
- package/dist/esm/helpers/timer.js +1 -10
- package/dist/esm/helpers/timer.js.map +2 -2
- package/dist/esm/helpers/timer.mjs +1 -10
- package/dist/esm/helpers/timer.mjs.map +2 -2
- package/dist/esm/helpers/useShallowSetState.js +1 -34
- package/dist/esm/helpers/useShallowSetState.js.map +2 -2
- package/dist/esm/helpers/useShallowSetState.mjs +1 -34
- package/dist/esm/helpers/useShallowSetState.mjs.map +2 -2
- package/dist/esm/helpers/warnOnce.js +1 -13
- package/dist/esm/helpers/warnOnce.js.map +2 -2
- package/dist/esm/helpers/warnOnce.mjs +1 -13
- package/dist/esm/helpers/warnOnce.mjs.map +2 -2
- package/dist/esm/helpers/withStaticProperties.js +1 -8
- package/dist/esm/helpers/withStaticProperties.js.map +2 -2
- package/dist/esm/helpers/withStaticProperties.mjs +1 -8
- package/dist/esm/helpers/withStaticProperties.mjs.map +2 -2
- package/dist/esm/hooks/getThemeUnwrapped.js +1 -8
- package/dist/esm/hooks/getThemeUnwrapped.js.map +2 -2
- package/dist/esm/hooks/getThemeUnwrapped.mjs +1 -8
- package/dist/esm/hooks/getThemeUnwrapped.mjs.map +2 -2
- package/dist/esm/hooks/useAnimationDriver.js +1 -9
- package/dist/esm/hooks/useAnimationDriver.js.map +2 -2
- package/dist/esm/hooks/useAnimationDriver.mjs +1 -9
- package/dist/esm/hooks/useAnimationDriver.mjs.map +2 -2
- package/dist/esm/hooks/useId.js +1 -4
- package/dist/esm/hooks/useId.js.map +2 -2
- package/dist/esm/hooks/useId.mjs +1 -4
- package/dist/esm/hooks/useId.mjs.map +2 -2
- package/dist/esm/hooks/useIsTouchDevice.js +1 -8
- package/dist/esm/hooks/useIsTouchDevice.js.map +2 -2
- package/dist/esm/hooks/useIsTouchDevice.mjs +1 -8
- package/dist/esm/hooks/useIsTouchDevice.mjs.map +2 -2
- package/dist/esm/hooks/useMedia.js +1 -225
- package/dist/esm/hooks/useMedia.js.map +2 -2
- package/dist/esm/hooks/useMedia.mjs +1 -225
- package/dist/esm/hooks/useMedia.mjs.map +2 -2
- package/dist/esm/hooks/useSafeRef.js +1 -34
- package/dist/esm/hooks/useSafeRef.js.map +2 -2
- package/dist/esm/hooks/useSafeRef.mjs +1 -34
- package/dist/esm/hooks/useSafeRef.mjs.map +2 -2
- package/dist/esm/hooks/useServerHooks.js +1 -10
- package/dist/esm/hooks/useServerHooks.js.map +2 -2
- package/dist/esm/hooks/useServerHooks.mjs +1 -10
- package/dist/esm/hooks/useServerHooks.mjs.map +2 -2
- package/dist/esm/hooks/useStyle.js +1 -36
- package/dist/esm/hooks/useStyle.js.map +2 -2
- package/dist/esm/hooks/useStyle.mjs +1 -36
- package/dist/esm/hooks/useStyle.mjs.map +2 -2
- package/dist/esm/hooks/useTheme.js +1 -204
- package/dist/esm/hooks/useTheme.js.map +3 -3
- package/dist/esm/hooks/useTheme.mjs +1 -204
- package/dist/esm/hooks/useTheme.mjs.map +3 -3
- package/dist/esm/hooks/useThemeName.js +1 -27
- package/dist/esm/hooks/useThemeName.js.map +2 -2
- package/dist/esm/hooks/useThemeName.mjs +1 -27
- package/dist/esm/hooks/useThemeName.mjs.map +2 -2
- package/dist/esm/index.js +1 -88
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/index.mjs +1 -88
- package/dist/esm/index.mjs.map +2 -2
- package/dist/esm/inject-styles.js +1 -15
- package/dist/esm/inject-styles.js.map +2 -2
- package/dist/esm/inject-styles.mjs +1 -15
- package/dist/esm/inject-styles.mjs.map +2 -2
- package/dist/esm/insertFont.js +1 -66
- package/dist/esm/insertFont.js.map +2 -2
- package/dist/esm/insertFont.mjs +1 -66
- package/dist/esm/insertFont.mjs.map +2 -2
- package/dist/esm/setupHooks.js +1 -8
- package/dist/esm/setupHooks.js.map +2 -2
- package/dist/esm/setupHooks.mjs +1 -8
- package/dist/esm/setupHooks.mjs.map +2 -2
- package/dist/esm/setupReactNative.js +1 -24
- package/dist/esm/setupReactNative.js.map +2 -2
- package/dist/esm/setupReactNative.mjs +1 -24
- package/dist/esm/setupReactNative.mjs.map +2 -2
- package/dist/esm/styled.js +1 -69
- package/dist/esm/styled.js.map +2 -2
- package/dist/esm/styled.mjs +1 -69
- package/dist/esm/styled.mjs.map +2 -2
- package/dist/esm/updateTheme.js +1 -22
- package/dist/esm/updateTheme.js.map +2 -2
- package/dist/esm/updateTheme.mjs +1 -22
- package/dist/esm/updateTheme.mjs.map +2 -2
- package/dist/esm/views/AnimationDriverProvider.js +1 -8
- package/dist/esm/views/AnimationDriverProvider.js.map +2 -2
- package/dist/esm/views/AnimationDriverProvider.mjs +1 -8
- package/dist/esm/views/AnimationDriverProvider.mjs.map +2 -2
- package/dist/esm/views/FontLanguage.js +1 -16
- package/dist/esm/views/FontLanguage.js.map +2 -2
- package/dist/esm/views/FontLanguage.mjs +1 -16
- package/dist/esm/views/FontLanguage.mjs.map +2 -2
- package/dist/esm/views/FontLanguage.native.js +1 -10
- package/dist/esm/views/FontLanguage.native.js.map +2 -2
- package/dist/esm/views/FontLanguage.native.mjs +1 -10
- package/dist/esm/views/FontLanguage.native.mjs.map +2 -2
- package/dist/esm/views/Slot.js +1 -65
- package/dist/esm/views/Slot.js.map +2 -2
- package/dist/esm/views/Slot.mjs +1 -65
- package/dist/esm/views/Slot.mjs.map +2 -2
- package/dist/esm/views/Stack.js +1 -13
- package/dist/esm/views/Stack.js.map +2 -2
- package/dist/esm/views/Stack.mjs +1 -13
- package/dist/esm/views/Stack.mjs.map +2 -2
- package/dist/esm/views/TamaguiProvider.js +1 -56
- package/dist/esm/views/TamaguiProvider.js.map +2 -2
- package/dist/esm/views/TamaguiProvider.mjs +1 -56
- package/dist/esm/views/TamaguiProvider.mjs.map +2 -2
- package/dist/esm/views/Text.js +1 -71
- package/dist/esm/views/Text.js.map +2 -2
- package/dist/esm/views/Text.mjs +1 -71
- package/dist/esm/views/Text.mjs.map +2 -2
- package/dist/esm/views/Theme.js +1 -55
- package/dist/esm/views/Theme.js.map +3 -3
- package/dist/esm/views/Theme.mjs +1 -55
- package/dist/esm/views/Theme.mjs.map +3 -3
- package/dist/esm/views/ThemeProvider.js +1 -44
- package/dist/esm/views/ThemeProvider.js.map +2 -2
- package/dist/esm/views/ThemeProvider.mjs +1 -44
- package/dist/esm/views/ThemeProvider.mjs.map +2 -2
- package/package.json +9 -9
- package/src/createComponent.tsx +38 -5
- package/src/helpers/ThemeManager.tsx +40 -32
- package/src/helpers/getSplitStyles.tsx +0 -8
- package/src/hooks/useTheme.tsx +145 -93
- package/src/types.tsx +2 -2
- package/src/views/Theme.tsx +49 -27
- package/types/createComponent.d.ts.map +1 -1
- package/types/helpers/ThemeManager.d.ts +1 -0
- package/types/helpers/ThemeManager.d.ts.map +1 -1
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/hooks/useTheme.d.ts +5 -7
- package/types/hooks/useTheme.d.ts.map +1 -1
- package/types/types.d.ts +2 -2
- package/types/types.d.ts.map +1 -1
- package/types/views/Theme.d.ts.map +1 -1
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/createTokens.ts"],
|
|
4
4
|
"sourcesContent": ["import { Variable } from './createVariable.js'\nimport { createVariables } from './createVariables.js'\nimport { CreateTokens } from './types.js'\n\n// tokens.color.dark.red ===> { var: `color-dark-red`, val: '' }\nexport function createTokens<T extends CreateTokens>(tokens: T): MakeTokens<T> {\n return createVariables(tokens) 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 // removes $ prefix allowing for defining either as $1: or 1:,\n // which is important because Chrome re-orders numerical-seeming keys :/\n [Key in keyof E extends `$${infer X}` ? X : keyof E]: Variable<string>\n }\n space: {\n [Key in keyof F extends `$${infer X}` ? X : keyof F]: Variable<number>\n }\n size: {\n [Key in keyof G extends `$${infer X}` ? X : keyof G]: Variable<number>\n }\n radius: {\n [Key in keyof H extends `$${infer X}` ? X : keyof H]: Variable<number>\n }\n zIndex: {\n [Key in keyof J extends `$${infer X}` ? X : keyof J]: Variable<number>\n }\n }\n : never\n\n// test\n// TODO move to tests\nconst tokens = createTokens({\n size: { 0: 1 },\n space: { 0: 1 },\n radius: { 0: 1 },\n zIndex: { 0: 1 },\n color: { 0: 'hi' },\n})\n"],
|
|
5
|
-
"mappings": "AACA,
|
|
6
|
-
"names": ["tokens"]
|
|
5
|
+
"mappings": "AACA,OAAS,mBAAAA,MAAuB,uBAIzB,SAASC,EAAqCC,EAA0B,CAC7E,OAAOF,EAAgBE,CAAM,CAC/B,CAiCA,MAAMA,EAASD,EAAa,CAC1B,KAAM,CAAE,EAAG,CAAE,EACb,MAAO,CAAE,EAAG,CAAE,EACd,OAAQ,CAAE,EAAG,CAAE,EACf,OAAQ,CAAE,EAAG,CAAE,EACf,MAAO,CAAE,EAAG,IAAK,CACnB,CAAC",
|
|
6
|
+
"names": ["createVariables", "createTokens", "tokens"]
|
|
7
7
|
}
|
|
@@ -1,78 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { simpleHash } from "@tamagui/helpers";
|
|
3
|
-
import { getConfig } from "./config.js";
|
|
4
|
-
const IS_VAR = "isVar";
|
|
5
|
-
const createVariable = (props) => {
|
|
6
|
-
if (isVariable(props))
|
|
7
|
-
return props;
|
|
8
|
-
const { key, name, val } = props;
|
|
9
|
-
return {
|
|
10
|
-
[IS_VAR]: true,
|
|
11
|
-
key,
|
|
12
|
-
name: simpleHash(name, 40),
|
|
13
|
-
val,
|
|
14
|
-
variable: isWeb ? createCSSVariable(name) : ""
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
function variableToString(vrble, getValue = false) {
|
|
18
|
-
if (isVariable(vrble)) {
|
|
19
|
-
if (!getValue && isWeb && vrble.variable) {
|
|
20
|
-
return vrble.variable;
|
|
21
|
-
}
|
|
22
|
-
return `${vrble.val}`;
|
|
23
|
-
}
|
|
24
|
-
return `${vrble || ""}`;
|
|
25
|
-
}
|
|
26
|
-
function isVariable(v) {
|
|
27
|
-
return v && typeof v === "object" && IS_VAR in v;
|
|
28
|
-
}
|
|
29
|
-
function getVariable(nameOrVariable) {
|
|
30
|
-
setDidGetVariableValue(true);
|
|
31
|
-
if (isVariable(nameOrVariable)) {
|
|
32
|
-
return variableToString(nameOrVariable);
|
|
33
|
-
}
|
|
34
|
-
const tokens = getConfig().tokensParsed;
|
|
35
|
-
return variableToString(tokens[nameOrVariable] ?? nameOrVariable);
|
|
36
|
-
}
|
|
37
|
-
let accessed = false;
|
|
38
|
-
const setDidGetVariableValue = (val) => accessed = val;
|
|
39
|
-
const didGetVariableValue = () => accessed;
|
|
40
|
-
function getVariableValue(v) {
|
|
41
|
-
if (isVariable(v)) {
|
|
42
|
-
setDidGetVariableValue(true);
|
|
43
|
-
return v.val;
|
|
44
|
-
}
|
|
45
|
-
return v;
|
|
46
|
-
}
|
|
47
|
-
function getVariableName(v) {
|
|
48
|
-
if (isVariable(v))
|
|
49
|
-
return v.name;
|
|
50
|
-
return v;
|
|
51
|
-
}
|
|
52
|
-
function getVariableVariable(v) {
|
|
53
|
-
if (isVariable(v))
|
|
54
|
-
return v.variable;
|
|
55
|
-
return v;
|
|
56
|
-
}
|
|
57
|
-
const createCSSVariable = (nameProp, includeVar = true) => {
|
|
58
|
-
if (process.env.NODE_ENV === "development") {
|
|
59
|
-
if (!nameProp || typeof nameProp !== "string") {
|
|
60
|
-
throw new Error(`createCSSVariable expected string: ${nameProp}`);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
const name = simpleHash(nameProp, 60);
|
|
64
|
-
return includeVar ? `var(--${name})` : name;
|
|
65
|
-
};
|
|
66
|
-
export {
|
|
67
|
-
createCSSVariable,
|
|
68
|
-
createVariable,
|
|
69
|
-
didGetVariableValue,
|
|
70
|
-
getVariable,
|
|
71
|
-
getVariableName,
|
|
72
|
-
getVariableValue,
|
|
73
|
-
getVariableVariable,
|
|
74
|
-
isVariable,
|
|
75
|
-
setDidGetVariableValue,
|
|
76
|
-
variableToString
|
|
77
|
-
};
|
|
1
|
+
import{isWeb as n}from"@tamagui/constants";import{simpleHash as i}from"@tamagui/helpers";import{getConfig as V}from"./config.js";const o="isVar",p=e=>{if(a(e))return e;const{key:r,name:t,val:b}=e;return{[o]:!0,key:r,name:i(t,40),val:b,variable:n?c(t):""}};function l(e,r=!1){return a(e)?!r&&n&&e.variable?e.variable:`${e.val}`:`${e||""}`}function a(e){return e&&typeof e=="object"&&o in e}function x(e){if(u(!0),a(e))return l(e);const r=V().tokensParsed;return l(r[e]??e)}let s=!1;const u=e=>s=e,A=()=>s;function m(e){return a(e)?(u(!0),e.val):e}function d(e){return a(e)?e.name:e}function k(e){return a(e)?e.variable:e}const c=(e,r=!0)=>{if(process.env.NODE_ENV==="development"&&(!e||typeof e!="string"))throw new Error(`createCSSVariable expected string: ${e}`);const t=i(e,60);return r?`var(--${t})`:t};export{c as createCSSVariable,p as createVariable,A as didGetVariableValue,x as getVariable,d as getVariableName,m as getVariableValue,k as getVariableVariable,a as isVariable,u as setDidGetVariableValue,l as variableToString};
|
|
78
2
|
//# sourceMappingURL=createVariable.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/createVariable.ts"],
|
|
4
4
|
"sourcesContent": ["import { isWeb } from '@tamagui/constants'\nimport { simpleHash } from '@tamagui/helpers'\n\nimport { getConfig } from './config.js'\n\n/**\n * Should rename this to Token\n * Moving to objects for React Server Components support\n */\n\nconst IS_VAR = 'isVar'\n\nexport interface Variable<A = any> {\n [IS_VAR]?: true\n variable?: string\n val: A\n name: string\n key: string\n}\n\nexport type MakeVariable<A = any> = A extends string | number ? Variable<A> : A\n\ntype VariableIn<A = any> = Pick<Variable<A>, 'key' | 'name' | 'val'>\nexport const createVariable = <A extends string | number | Variable = any>(\n props: VariableIn<A>\n): Variable<A> => {\n if (isVariable(props)) return props\n const { key, name, val } = props\n return {\n [IS_VAR]: true,\n key: key!,\n name: simpleHash(name, 40),\n val: val as any,\n variable: isWeb ? createCSSVariable(name) : '',\n }\n}\n\n// could do weakmap cache\nexport function variableToString(vrble?: any, getValue = false) {\n if (isVariable(vrble)) {\n if (!getValue && isWeb && vrble.variable) {\n return vrble.variable\n }\n return `${vrble.val}`\n }\n return `${vrble || ''}`\n}\n\nexport function isVariable(v: Variable | any): v is Variable {\n return v && typeof v === 'object' && IS_VAR in v\n}\n\nexport function getVariable(nameOrVariable: Variable | string) {\n setDidGetVariableValue(true)\n if (isVariable(nameOrVariable)) {\n return variableToString(nameOrVariable)\n }\n const tokens = getConfig().tokensParsed\n return variableToString(tokens[nameOrVariable] ?? nameOrVariable)\n}\n\nlet accessed = false\nexport const setDidGetVariableValue = (val: boolean) => (accessed = val)\nexport const didGetVariableValue = () => accessed\n\nexport function getVariableValue(v: Variable | any) {\n if (isVariable(v)) {\n setDidGetVariableValue(true)\n return v.val\n }\n return v\n}\n\nexport function getVariableName(v: Variable | any) {\n if (isVariable(v)) return v.name\n return v\n}\n\nexport function getVariableVariable(v: Variable | any) {\n if (isVariable(v)) return v.variable\n return v\n}\n\n// bugfix { space: { 0.5: 10 } } was generating var(--space-0.5) (invalid CSS):\nexport const createCSSVariable = (nameProp: string, includeVar = true) => {\n if (process.env.NODE_ENV === 'development') {\n if (!nameProp || typeof nameProp !== 'string') {\n throw new Error(`createCSSVariable expected string: ${nameProp}`)\n }\n }\n const name = simpleHash(nameProp, 60)\n return includeVar ? `var(--${name})` : name\n}\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AAAA,OAAS,SAAAA,MAAa,qBACtB,OAAS,cAAAC,MAAkB,mBAE3B,OAAS,aAAAC,MAAiB,cAO1B,MAAMC,EAAS,QAaFC,EACXC,GACgB,CAChB,GAAIC,EAAWD,CAAK,EAAG,OAAOA,EAC9B,KAAM,CAAE,IAAAE,EAAK,KAAAC,EAAM,IAAAC,CAAI,EAAIJ,EAC3B,MAAO,CACL,CAACF,CAAM,EAAG,GACV,IAAKI,EACL,KAAMN,EAAWO,EAAM,EAAE,EACzB,IAAKC,EACL,SAAUT,EAAQU,EAAkBF,CAAI,EAAI,EAC9C,CACF,EAGO,SAASG,EAAiBC,EAAaC,EAAW,GAAO,CAC9D,OAAIP,EAAWM,CAAK,EACd,CAACC,GAAYb,GAASY,EAAM,SACvBA,EAAM,SAER,GAAGA,EAAM,MAEX,GAAGA,GAAS,IACrB,CAEO,SAASN,EAAWQ,EAAkC,CAC3D,OAAOA,GAAK,OAAOA,GAAM,UAAYX,KAAUW,CACjD,CAEO,SAASC,EAAYC,EAAmC,CAE7D,GADAC,EAAuB,EAAI,EACvBX,EAAWU,CAAc,EAC3B,OAAOL,EAAiBK,CAAc,EAExC,MAAME,EAAShB,EAAU,EAAE,aAC3B,OAAOS,EAAiBO,EAAOF,CAAc,GAAKA,CAAc,CAClE,CAEA,IAAIG,EAAW,GACR,MAAMF,EAA0BR,GAAkBU,EAAWV,EACvDW,EAAsB,IAAMD,EAElC,SAASE,EAAiBP,EAAmB,CAClD,OAAIR,EAAWQ,CAAC,GACdG,EAAuB,EAAI,EACpBH,EAAE,KAEJA,CACT,CAEO,SAASQ,EAAgBR,EAAmB,CACjD,OAAIR,EAAWQ,CAAC,EAAUA,EAAE,KACrBA,CACT,CAEO,SAASS,EAAoBT,EAAmB,CACrD,OAAIR,EAAWQ,CAAC,EAAUA,EAAE,SACrBA,CACT,CAGO,MAAMJ,EAAoB,CAACc,EAAkBC,EAAa,KAAS,CACxE,GAAI,QAAQ,IAAI,WAAa,gBACvB,CAACD,GAAY,OAAOA,GAAa,UACnC,MAAM,IAAI,MAAM,sCAAsCA,GAAU,EAGpE,MAAMhB,EAAOP,EAAWuB,EAAU,EAAE,EACpC,OAAOC,EAAa,SAASjB,KAAUA,CACzC",
|
|
6
|
+
"names": ["isWeb", "simpleHash", "getConfig", "IS_VAR", "createVariable", "props", "isVariable", "key", "name", "val", "createCSSVariable", "variableToString", "vrble", "getValue", "v", "getVariable", "nameOrVariable", "setDidGetVariableValue", "tokens", "accessed", "didGetVariableValue", "getVariableValue", "getVariableName", "getVariableVariable", "nameProp", "includeVar"]
|
|
7
7
|
}
|
|
@@ -1,78 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { simpleHash } from "@tamagui/helpers";
|
|
3
|
-
import { getConfig } from "./config.js";
|
|
4
|
-
const IS_VAR = "isVar";
|
|
5
|
-
const createVariable = (props) => {
|
|
6
|
-
if (isVariable(props))
|
|
7
|
-
return props;
|
|
8
|
-
const { key, name, val } = props;
|
|
9
|
-
return {
|
|
10
|
-
[IS_VAR]: true,
|
|
11
|
-
key,
|
|
12
|
-
name: simpleHash(name, 40),
|
|
13
|
-
val,
|
|
14
|
-
variable: isWeb ? createCSSVariable(name) : ""
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
function variableToString(vrble, getValue = false) {
|
|
18
|
-
if (isVariable(vrble)) {
|
|
19
|
-
if (!getValue && isWeb && vrble.variable) {
|
|
20
|
-
return vrble.variable;
|
|
21
|
-
}
|
|
22
|
-
return `${vrble.val}`;
|
|
23
|
-
}
|
|
24
|
-
return `${vrble || ""}`;
|
|
25
|
-
}
|
|
26
|
-
function isVariable(v) {
|
|
27
|
-
return v && typeof v === "object" && IS_VAR in v;
|
|
28
|
-
}
|
|
29
|
-
function getVariable(nameOrVariable) {
|
|
30
|
-
setDidGetVariableValue(true);
|
|
31
|
-
if (isVariable(nameOrVariable)) {
|
|
32
|
-
return variableToString(nameOrVariable);
|
|
33
|
-
}
|
|
34
|
-
const tokens = getConfig().tokensParsed;
|
|
35
|
-
return variableToString(tokens[nameOrVariable] ?? nameOrVariable);
|
|
36
|
-
}
|
|
37
|
-
let accessed = false;
|
|
38
|
-
const setDidGetVariableValue = (val) => accessed = val;
|
|
39
|
-
const didGetVariableValue = () => accessed;
|
|
40
|
-
function getVariableValue(v) {
|
|
41
|
-
if (isVariable(v)) {
|
|
42
|
-
setDidGetVariableValue(true);
|
|
43
|
-
return v.val;
|
|
44
|
-
}
|
|
45
|
-
return v;
|
|
46
|
-
}
|
|
47
|
-
function getVariableName(v) {
|
|
48
|
-
if (isVariable(v))
|
|
49
|
-
return v.name;
|
|
50
|
-
return v;
|
|
51
|
-
}
|
|
52
|
-
function getVariableVariable(v) {
|
|
53
|
-
if (isVariable(v))
|
|
54
|
-
return v.variable;
|
|
55
|
-
return v;
|
|
56
|
-
}
|
|
57
|
-
const createCSSVariable = (nameProp, includeVar = true) => {
|
|
58
|
-
if (process.env.NODE_ENV === "development") {
|
|
59
|
-
if (!nameProp || typeof nameProp !== "string") {
|
|
60
|
-
throw new Error(`createCSSVariable expected string: ${nameProp}`);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
const name = simpleHash(nameProp, 60);
|
|
64
|
-
return includeVar ? `var(--${name})` : name;
|
|
65
|
-
};
|
|
66
|
-
export {
|
|
67
|
-
createCSSVariable,
|
|
68
|
-
createVariable,
|
|
69
|
-
didGetVariableValue,
|
|
70
|
-
getVariable,
|
|
71
|
-
getVariableName,
|
|
72
|
-
getVariableValue,
|
|
73
|
-
getVariableVariable,
|
|
74
|
-
isVariable,
|
|
75
|
-
setDidGetVariableValue,
|
|
76
|
-
variableToString
|
|
77
|
-
};
|
|
1
|
+
import{isWeb as n}from"@tamagui/constants";import{simpleHash as i}from"@tamagui/helpers";import{getConfig as V}from"./config.js";const o="isVar",p=e=>{if(a(e))return e;const{key:r,name:t,val:b}=e;return{[o]:!0,key:r,name:i(t,40),val:b,variable:n?c(t):""}};function l(e,r=!1){return a(e)?!r&&n&&e.variable?e.variable:`${e.val}`:`${e||""}`}function a(e){return e&&typeof e=="object"&&o in e}function x(e){if(u(!0),a(e))return l(e);const r=V().tokensParsed;return l(r[e]??e)}let s=!1;const u=e=>s=e,A=()=>s;function m(e){return a(e)?(u(!0),e.val):e}function d(e){return a(e)?e.name:e}function k(e){return a(e)?e.variable:e}const c=(e,r=!0)=>{if(process.env.NODE_ENV==="development"&&(!e||typeof e!="string"))throw new Error(`createCSSVariable expected string: ${e}`);const t=i(e,60);return r?`var(--${t})`:t};export{c as createCSSVariable,p as createVariable,A as didGetVariableValue,x as getVariable,d as getVariableName,m as getVariableValue,k as getVariableVariable,a as isVariable,u as setDidGetVariableValue,l as variableToString};
|
|
78
2
|
//# sourceMappingURL=createVariable.mjs.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/createVariable.ts"],
|
|
4
4
|
"sourcesContent": ["import { isWeb } from '@tamagui/constants'\nimport { simpleHash } from '@tamagui/helpers'\n\nimport { getConfig } from './config.js'\n\n/**\n * Should rename this to Token\n * Moving to objects for React Server Components support\n */\n\nconst IS_VAR = 'isVar'\n\nexport interface Variable<A = any> {\n [IS_VAR]?: true\n variable?: string\n val: A\n name: string\n key: string\n}\n\nexport type MakeVariable<A = any> = A extends string | number ? Variable<A> : A\n\ntype VariableIn<A = any> = Pick<Variable<A>, 'key' | 'name' | 'val'>\nexport const createVariable = <A extends string | number | Variable = any>(\n props: VariableIn<A>\n): Variable<A> => {\n if (isVariable(props)) return props\n const { key, name, val } = props\n return {\n [IS_VAR]: true,\n key: key!,\n name: simpleHash(name, 40),\n val: val as any,\n variable: isWeb ? createCSSVariable(name) : '',\n }\n}\n\n// could do weakmap cache\nexport function variableToString(vrble?: any, getValue = false) {\n if (isVariable(vrble)) {\n if (!getValue && isWeb && vrble.variable) {\n return vrble.variable\n }\n return `${vrble.val}`\n }\n return `${vrble || ''}`\n}\n\nexport function isVariable(v: Variable | any): v is Variable {\n return v && typeof v === 'object' && IS_VAR in v\n}\n\nexport function getVariable(nameOrVariable: Variable | string) {\n setDidGetVariableValue(true)\n if (isVariable(nameOrVariable)) {\n return variableToString(nameOrVariable)\n }\n const tokens = getConfig().tokensParsed\n return variableToString(tokens[nameOrVariable] ?? nameOrVariable)\n}\n\nlet accessed = false\nexport const setDidGetVariableValue = (val: boolean) => (accessed = val)\nexport const didGetVariableValue = () => accessed\n\nexport function getVariableValue(v: Variable | any) {\n if (isVariable(v)) {\n setDidGetVariableValue(true)\n return v.val\n }\n return v\n}\n\nexport function getVariableName(v: Variable | any) {\n if (isVariable(v)) return v.name\n return v\n}\n\nexport function getVariableVariable(v: Variable | any) {\n if (isVariable(v)) return v.variable\n return v\n}\n\n// bugfix { space: { 0.5: 10 } } was generating var(--space-0.5) (invalid CSS):\nexport const createCSSVariable = (nameProp: string, includeVar = true) => {\n if (process.env.NODE_ENV === 'development') {\n if (!nameProp || typeof nameProp !== 'string') {\n throw new Error(`createCSSVariable expected string: ${nameProp}`)\n }\n }\n const name = simpleHash(nameProp, 60)\n return includeVar ? `var(--${name})` : name\n}\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AAAA,OAAS,SAAAA,MAAa,qBACtB,OAAS,cAAAC,MAAkB,mBAE3B,OAAS,aAAAC,MAAiB,cAO1B,MAAMC,EAAS,QAaFC,EACXC,GACgB,CAChB,GAAIC,EAAWD,CAAK,EAAG,OAAOA,EAC9B,KAAM,CAAE,IAAAE,EAAK,KAAAC,EAAM,IAAAC,CAAI,EAAIJ,EAC3B,MAAO,CACL,CAACF,CAAM,EAAG,GACV,IAAKI,EACL,KAAMN,EAAWO,EAAM,EAAE,EACzB,IAAKC,EACL,SAAUT,EAAQU,EAAkBF,CAAI,EAAI,EAC9C,CACF,EAGO,SAASG,EAAiBC,EAAaC,EAAW,GAAO,CAC9D,OAAIP,EAAWM,CAAK,EACd,CAACC,GAAYb,GAASY,EAAM,SACvBA,EAAM,SAER,GAAGA,EAAM,MAEX,GAAGA,GAAS,IACrB,CAEO,SAASN,EAAWQ,EAAkC,CAC3D,OAAOA,GAAK,OAAOA,GAAM,UAAYX,KAAUW,CACjD,CAEO,SAASC,EAAYC,EAAmC,CAE7D,GADAC,EAAuB,EAAI,EACvBX,EAAWU,CAAc,EAC3B,OAAOL,EAAiBK,CAAc,EAExC,MAAME,EAAShB,EAAU,EAAE,aAC3B,OAAOS,EAAiBO,EAAOF,CAAc,GAAKA,CAAc,CAClE,CAEA,IAAIG,EAAW,GACR,MAAMF,EAA0BR,GAAkBU,EAAWV,EACvDW,EAAsB,IAAMD,EAElC,SAASE,EAAiBP,EAAmB,CAClD,OAAIR,EAAWQ,CAAC,GACdG,EAAuB,EAAI,EACpBH,EAAE,KAEJA,CACT,CAEO,SAASQ,EAAgBR,EAAmB,CACjD,OAAIR,EAAWQ,CAAC,EAAUA,EAAE,KACrBA,CACT,CAEO,SAASS,EAAoBT,EAAmB,CACrD,OAAIR,EAAWQ,CAAC,EAAUA,EAAE,SACrBA,CACT,CAGO,MAAMJ,EAAoB,CAACc,EAAkBC,EAAa,KAAS,CACxE,GAAI,QAAQ,IAAI,WAAa,gBACvB,CAACD,GAAY,OAAOA,GAAa,UACnC,MAAM,IAAI,MAAM,sCAAsCA,GAAU,EAGpE,MAAMhB,EAAOP,EAAWuB,EAAU,EAAE,EACpC,OAAOC,EAAa,SAASjB,KAAUA,CACzC",
|
|
6
|
+
"names": ["isWeb", "simpleHash", "getConfig", "IS_VAR", "createVariable", "props", "isVariable", "key", "name", "val", "createCSSVariable", "variableToString", "vrble", "getValue", "v", "getVariable", "nameOrVariable", "setDidGetVariableValue", "tokens", "accessed", "didGetVariableValue", "getVariableValue", "getVariableName", "getVariableVariable", "nameProp", "includeVar"]
|
|
7
7
|
}
|
|
@@ -1,35 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { createVariable, isVariable } from "./createVariable.js";
|
|
3
|
-
const tokensKeysOrdered = /* @__PURE__ */ new WeakMap();
|
|
4
|
-
const createVariables = (tokens, parentPath = "", isFont = false) => {
|
|
5
|
-
const res = {};
|
|
6
|
-
let i = 0;
|
|
7
|
-
for (let key in tokens) {
|
|
8
|
-
i++;
|
|
9
|
-
const val = tokens[key];
|
|
10
|
-
if (key[0] === "$") {
|
|
11
|
-
key = key.slice(1);
|
|
12
|
-
}
|
|
13
|
-
if (isVariable(val)) {
|
|
14
|
-
res[key] = val;
|
|
15
|
-
continue;
|
|
16
|
-
}
|
|
17
|
-
const niceKey = simpleHash(key);
|
|
18
|
-
let name = isFont ? niceKey.slice(0, 2) : i;
|
|
19
|
-
name = parentPath ? `${parentPath}-${name}` : niceKey;
|
|
20
|
-
if (val && typeof val === "object") {
|
|
21
|
-
res[key] = createVariables(tokens[key], name);
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
res[key] = isVariable(val) ? val : createVariable({ val, name, key: niceKey });
|
|
25
|
-
}
|
|
26
|
-
if (parentPath === "size" || parentPath === "space") {
|
|
27
|
-
tokensKeysOrdered.set(res, Object.keys(tokens));
|
|
28
|
-
}
|
|
29
|
-
return res;
|
|
30
|
-
};
|
|
31
|
-
export {
|
|
32
|
-
createVariables,
|
|
33
|
-
tokensKeysOrdered
|
|
34
|
-
};
|
|
1
|
+
import{simpleHash as l}from"@tamagui/helpers";import{createVariable as y,isVariable as o}from"./createVariable.js";const p=new WeakMap,V=(i,a="",b=!1)=>{const n={};let c=0;for(let e in i){c++;const t=i[e];if(e[0]==="$"&&(e=e.slice(1)),o(t)){n[e]=t;continue}const s=l(e);let r=b?s.slice(0,2):c;if(r=a?`${a}-${r}`:s,t&&typeof t=="object"){n[e]=V(i[e],r);continue}n[e]=o(t)?t:y({val:t,name:r,key:s})}return(a==="size"||a==="space")&&p.set(n,Object.keys(i)),n};export{V as createVariables,p as tokensKeysOrdered};
|
|
35
2
|
//# sourceMappingURL=createVariables.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/createVariables.ts"],
|
|
4
4
|
"sourcesContent": ["import { simpleHash } from '@tamagui/helpers'\n\nimport { Variable, createVariable, isVariable } from './createVariable.js'\n\ntype DeepTokenObject<Val extends string | number = any> = {\n [key: string]: Val | DeepTokenObject<Val>\n}\n\nexport type DeepVariableObject<A extends DeepTokenObject> = {\n [Key in keyof A]: A[Key] extends string | number\n ? Variable<A[Key]>\n : A[Key] extends DeepTokenObject\n ? DeepVariableObject<A[Key]>\n : never\n}\n\nexport const tokensKeysOrdered = new WeakMap()\n\nexport const createVariables = <A extends DeepTokenObject>(\n tokens: A,\n parentPath = '',\n isFont = false\n): DeepVariableObject<A> => {\n const res: any = {}\n let i = 0\n for (let key in tokens) {\n i++\n const val = tokens[key]\n // always remove $ prefix\n if (key[0] === '$') {\n // @ts-ignore\n key = key.slice(1)\n }\n if (isVariable(val)) {\n res[key] = val\n continue\n }\n const niceKey = simpleHash(key)\n let name = isFont ? niceKey.slice(0, 2) : i\n name = parentPath ? `${parentPath}-${name}` : niceKey\n if (val && typeof val === 'object') {\n // recurse\n res[key] = createVariables(tokens[key] as any, name)\n continue\n }\n res[key] = isVariable(val) ? val : createVariable({ val, name, key: niceKey })\n }\n\n // ordering for relative sizing for now just size/space\n if (parentPath === 'size' || parentPath === 'space') {\n tokensKeysOrdered.set(res, Object.keys(tokens))\n }\n\n return res\n}\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AAAA,OAAS,cAAAA,MAAkB,mBAE3B,OAAmB,kBAAAC,EAAgB,cAAAC,MAAkB,sBAc9C,MAAMC,EAAoB,IAAI,QAExBC,EAAkB,CAC7BC,EACAC,EAAa,GACbC,EAAS,KACiB,CAC1B,MAAMC,EAAW,CAAC,EAClB,IAAIC,EAAI,EACR,QAASC,KAAOL,EAAQ,CACtBI,IACA,MAAME,EAAMN,EAAOK,CAAG,EAMtB,GAJIA,EAAI,CAAC,IAAM,MAEbA,EAAMA,EAAI,MAAM,CAAC,GAEfR,EAAWS,CAAG,EAAG,CACnBH,EAAIE,CAAG,EAAIC,EACX,QACF,CACA,MAAMC,EAAUZ,EAAWU,CAAG,EAC9B,IAAIG,EAAON,EAASK,EAAQ,MAAM,EAAG,CAAC,EAAIH,EAE1C,GADAI,EAAOP,EAAa,GAAGA,KAAcO,IAASD,EAC1CD,GAAO,OAAOA,GAAQ,SAAU,CAElCH,EAAIE,CAAG,EAAIN,EAAgBC,EAAOK,CAAG,EAAUG,CAAI,EACnD,QACF,CACAL,EAAIE,CAAG,EAAIR,EAAWS,CAAG,EAAIA,EAAMV,EAAe,CAAE,IAAAU,EAAK,KAAAE,EAAM,IAAKD,CAAQ,CAAC,CAC/E,CAGA,OAAIN,IAAe,QAAUA,IAAe,UAC1CH,EAAkB,IAAIK,EAAK,OAAO,KAAKH,CAAM,CAAC,EAGzCG,CACT",
|
|
6
|
+
"names": ["simpleHash", "createVariable", "isVariable", "tokensKeysOrdered", "createVariables", "tokens", "parentPath", "isFont", "res", "i", "key", "val", "niceKey", "name"]
|
|
7
7
|
}
|
|
@@ -1,35 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { createVariable, isVariable } from "./createVariable.js";
|
|
3
|
-
const tokensKeysOrdered = /* @__PURE__ */ new WeakMap();
|
|
4
|
-
const createVariables = (tokens, parentPath = "", isFont = false) => {
|
|
5
|
-
const res = {};
|
|
6
|
-
let i = 0;
|
|
7
|
-
for (let key in tokens) {
|
|
8
|
-
i++;
|
|
9
|
-
const val = tokens[key];
|
|
10
|
-
if (key[0] === "$") {
|
|
11
|
-
key = key.slice(1);
|
|
12
|
-
}
|
|
13
|
-
if (isVariable(val)) {
|
|
14
|
-
res[key] = val;
|
|
15
|
-
continue;
|
|
16
|
-
}
|
|
17
|
-
const niceKey = simpleHash(key);
|
|
18
|
-
let name = isFont ? niceKey.slice(0, 2) : i;
|
|
19
|
-
name = parentPath ? `${parentPath}-${name}` : niceKey;
|
|
20
|
-
if (val && typeof val === "object") {
|
|
21
|
-
res[key] = createVariables(tokens[key], name);
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
res[key] = isVariable(val) ? val : createVariable({ val, name, key: niceKey });
|
|
25
|
-
}
|
|
26
|
-
if (parentPath === "size" || parentPath === "space") {
|
|
27
|
-
tokensKeysOrdered.set(res, Object.keys(tokens));
|
|
28
|
-
}
|
|
29
|
-
return res;
|
|
30
|
-
};
|
|
31
|
-
export {
|
|
32
|
-
createVariables,
|
|
33
|
-
tokensKeysOrdered
|
|
34
|
-
};
|
|
1
|
+
import{simpleHash as l}from"@tamagui/helpers";import{createVariable as y,isVariable as o}from"./createVariable.js";const p=new WeakMap,V=(i,a="",b=!1)=>{const n={};let c=0;for(let e in i){c++;const t=i[e];if(e[0]==="$"&&(e=e.slice(1)),o(t)){n[e]=t;continue}const s=l(e);let r=b?s.slice(0,2):c;if(r=a?`${a}-${r}`:s,t&&typeof t=="object"){n[e]=V(i[e],r);continue}n[e]=o(t)?t:y({val:t,name:r,key:s})}return(a==="size"||a==="space")&&p.set(n,Object.keys(i)),n};export{V as createVariables,p as tokensKeysOrdered};
|
|
35
2
|
//# sourceMappingURL=createVariables.mjs.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/createVariables.ts"],
|
|
4
4
|
"sourcesContent": ["import { simpleHash } from '@tamagui/helpers'\n\nimport { Variable, createVariable, isVariable } from './createVariable.js'\n\ntype DeepTokenObject<Val extends string | number = any> = {\n [key: string]: Val | DeepTokenObject<Val>\n}\n\nexport type DeepVariableObject<A extends DeepTokenObject> = {\n [Key in keyof A]: A[Key] extends string | number\n ? Variable<A[Key]>\n : A[Key] extends DeepTokenObject\n ? DeepVariableObject<A[Key]>\n : never\n}\n\nexport const tokensKeysOrdered = new WeakMap()\n\nexport const createVariables = <A extends DeepTokenObject>(\n tokens: A,\n parentPath = '',\n isFont = false\n): DeepVariableObject<A> => {\n const res: any = {}\n let i = 0\n for (let key in tokens) {\n i++\n const val = tokens[key]\n // always remove $ prefix\n if (key[0] === '$') {\n // @ts-ignore\n key = key.slice(1)\n }\n if (isVariable(val)) {\n res[key] = val\n continue\n }\n const niceKey = simpleHash(key)\n let name = isFont ? niceKey.slice(0, 2) : i\n name = parentPath ? `${parentPath}-${name}` : niceKey\n if (val && typeof val === 'object') {\n // recurse\n res[key] = createVariables(tokens[key] as any, name)\n continue\n }\n res[key] = isVariable(val) ? val : createVariable({ val, name, key: niceKey })\n }\n\n // ordering for relative sizing for now just size/space\n if (parentPath === 'size' || parentPath === 'space') {\n tokensKeysOrdered.set(res, Object.keys(tokens))\n }\n\n return res\n}\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AAAA,OAAS,cAAAA,MAAkB,mBAE3B,OAAmB,kBAAAC,EAAgB,cAAAC,MAAkB,sBAc9C,MAAMC,EAAoB,IAAI,QAExBC,EAAkB,CAC7BC,EACAC,EAAa,GACbC,EAAS,KACiB,CAC1B,MAAMC,EAAW,CAAC,EAClB,IAAIC,EAAI,EACR,QAASC,KAAOL,EAAQ,CACtBI,IACA,MAAME,EAAMN,EAAOK,CAAG,EAMtB,GAJIA,EAAI,CAAC,IAAM,MAEbA,EAAMA,EAAI,MAAM,CAAC,GAEfR,EAAWS,CAAG,EAAG,CACnBH,EAAIE,CAAG,EAAIC,EACX,QACF,CACA,MAAMC,EAAUZ,EAAWU,CAAG,EAC9B,IAAIG,EAAON,EAASK,EAAQ,MAAM,EAAG,CAAC,EAAIH,EAE1C,GADAI,EAAOP,EAAa,GAAGA,KAAcO,IAASD,EAC1CD,GAAO,OAAOA,GAAQ,SAAU,CAElCH,EAAIE,CAAG,EAAIN,EAAgBC,EAAOK,CAAG,EAAUG,CAAI,EACnD,QACF,CACAL,EAAIE,CAAG,EAAIR,EAAWS,CAAG,EAAIA,EAAMV,EAAe,CAAE,IAAAU,EAAK,KAAAE,EAAM,IAAKD,CAAQ,CAAC,CAC/E,CAGA,OAAIN,IAAe,QAAUA,IAAe,UAC1CH,EAAkB,IAAIK,EAAK,OAAO,KAAKH,CAAM,CAAC,EAGzCG,CACT",
|
|
6
|
+
"names": ["simpleHash", "createVariable", "isVariable", "tokensKeysOrdered", "createVariables", "tokens", "parentPath", "isFont", "res", "i", "key", "val", "niceKey", "name"]
|
|
7
7
|
}
|
|
@@ -1,212 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { THEME_CLASSNAME_PREFIX, THEME_NAME_SEPARATOR } from "../constants/constants.js";
|
|
3
|
-
import { getThemeUnwrapped } from "../hooks/getThemeUnwrapped.js";
|
|
4
|
-
const emptyState = { name: "" };
|
|
5
|
-
function hasNoThemeUpdatingProps(props) {
|
|
6
|
-
return !(props.name || props.componentName || props.inverse || props.reset);
|
|
7
|
-
}
|
|
8
|
-
class ThemeManager {
|
|
9
|
-
constructor(props = {}, parentManager) {
|
|
10
|
-
this.props = props;
|
|
11
|
-
this.themeListeners = /* @__PURE__ */ new Set();
|
|
12
|
-
this.parentManager = null;
|
|
13
|
-
this.state = emptyState;
|
|
14
|
-
this._allKeys = null;
|
|
15
|
-
if (parentManager === "root") {
|
|
16
|
-
this.updateState(props, false);
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
if (!parentManager) {
|
|
20
|
-
if (process.env.NODE_ENV !== "production") {
|
|
21
|
-
console.trace();
|
|
22
|
-
throw new Error(`No parent manager given`);
|
|
23
|
-
}
|
|
24
|
-
throw `\u274C`;
|
|
25
|
-
}
|
|
26
|
-
this.themeListeners = parentManager.themeListeners;
|
|
27
|
-
if (hasNoThemeUpdatingProps(props)) {
|
|
28
|
-
return parentManager;
|
|
29
|
-
}
|
|
30
|
-
if (parentManager) {
|
|
31
|
-
this.parentManager = parentManager;
|
|
32
|
-
}
|
|
33
|
-
const updatedState = this.getStateIfChanged(props);
|
|
34
|
-
if (updatedState) {
|
|
35
|
-
this.state = updatedState;
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
return parentManager || this;
|
|
39
|
-
}
|
|
40
|
-
updateState(props = this.props || {}, notify = true) {
|
|
41
|
-
const shouldFlush = (() => {
|
|
42
|
-
if (props.forceTheme) {
|
|
43
|
-
this.state.theme = props.forceTheme;
|
|
44
|
-
this.state.name = props.name || "";
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
const nextState = this.getStateIfChanged(props);
|
|
48
|
-
if (nextState) {
|
|
49
|
-
this.state = nextState;
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
|
-
})();
|
|
53
|
-
if (shouldFlush) {
|
|
54
|
-
this._allKeys = null;
|
|
55
|
-
notify && this.notify();
|
|
56
|
-
return this.state;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
getStateIfChanged(props = this.props, state = this.state, parentManager = this.parentManager) {
|
|
60
|
-
const _ = this.getState(props, parentManager);
|
|
61
|
-
if (state && state !== emptyState && !_) {
|
|
62
|
-
return parentManager == null ? void 0 : parentManager.state;
|
|
63
|
-
}
|
|
64
|
-
if (this.getStateShouldChange(_, state)) {
|
|
65
|
-
return _;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
getStateShouldChange(nextState, state = this.state) {
|
|
69
|
-
if (!(nextState == null ? void 0 : nextState.theme) || nextState.theme === (state == null ? void 0 : state.theme)) {
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
return true;
|
|
73
|
-
}
|
|
74
|
-
getState(props = this.props, parentManager = this.parentManager) {
|
|
75
|
-
return getState(props, parentManager) || (process.env.TAMAGUI_TARGET === "native" ? (parentManager == null ? void 0 : parentManager.state) || null : null);
|
|
76
|
-
}
|
|
77
|
-
get allKeys() {
|
|
78
|
-
var _a;
|
|
79
|
-
this._allKeys ||= /* @__PURE__ */ new Set([
|
|
80
|
-
...((_a = this.parentManager) == null ? void 0 : _a.allKeys) || [],
|
|
81
|
-
...Object.keys(this.state.theme || {})
|
|
82
|
-
]);
|
|
83
|
-
return this._allKeys;
|
|
84
|
-
}
|
|
85
|
-
// gets value going up to parents
|
|
86
|
-
getValue(key, state) {
|
|
87
|
-
if (!key)
|
|
88
|
-
return;
|
|
89
|
-
let theme = (state || this.state).theme;
|
|
90
|
-
let manager = this;
|
|
91
|
-
while (theme && manager) {
|
|
92
|
-
if (key in theme) {
|
|
93
|
-
return theme[key];
|
|
94
|
-
}
|
|
95
|
-
manager = manager.parentManager;
|
|
96
|
-
theme = manager == null ? void 0 : manager.state.theme;
|
|
97
|
-
}
|
|
98
|
-
const tokens = getTokens();
|
|
99
|
-
if (key in tokens.color) {
|
|
100
|
-
return tokens.color[key];
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
notify() {
|
|
104
|
-
this.themeListeners.forEach((cb) => cb(this.state.name, this));
|
|
105
|
-
}
|
|
106
|
-
onChangeTheme(cb) {
|
|
107
|
-
this.themeListeners.add(cb);
|
|
108
|
-
return () => {
|
|
109
|
-
this.themeListeners.delete(cb);
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
function getNextThemeClassName(name, isInverting = false) {
|
|
114
|
-
const next = `t_sub_theme ${THEME_CLASSNAME_PREFIX}${name}`;
|
|
115
|
-
if (isInverting) {
|
|
116
|
-
return next + // ensure you invert to base dark as well as specific dark
|
|
117
|
-
// ... logic should likely be elsewhere
|
|
118
|
-
(next.includes("dark_") ? ` t_dark` : next.includes("light_") ? ` t_light` : "");
|
|
119
|
-
}
|
|
120
|
-
return next.replace("light_", "").replace("dark_", "");
|
|
121
|
-
}
|
|
122
|
-
const cache = /* @__PURE__ */ new WeakMap();
|
|
123
|
-
function getState(props, parentManager) {
|
|
124
|
-
var _a, _b, _c;
|
|
125
|
-
const cached = cache.get(props);
|
|
126
|
-
if (cached && cached[0] === parentManager) {
|
|
127
|
-
return cached[1];
|
|
128
|
-
}
|
|
129
|
-
const themes = getThemes();
|
|
130
|
-
if (props.name && props.reset) {
|
|
131
|
-
throw new Error("Cannot reset + set new name");
|
|
132
|
-
}
|
|
133
|
-
if (props.reset && !(parentManager == null ? void 0 : parentManager.parentManager)) {
|
|
134
|
-
console.warn("Cannot reset no grandparent exists");
|
|
135
|
-
return null;
|
|
136
|
-
}
|
|
137
|
-
let result = null;
|
|
138
|
-
const nextName = props.reset ? ((_b = (_a = parentManager == null ? void 0 : parentManager.parentManager) == null ? void 0 : _a.state) == null ? void 0 : _b.name) || "" : props.name || "";
|
|
139
|
-
const { componentName } = props;
|
|
140
|
-
const parentName = ((_c = parentManager == null ? void 0 : parentManager.state) == null ? void 0 : _c.name) || "";
|
|
141
|
-
const base = parentName.split(THEME_NAME_SEPARATOR);
|
|
142
|
-
const lastSegment = base[base.length - 1];
|
|
143
|
-
const isParentAComponentTheme = parentName && lastSegment[0].toUpperCase() === lastSegment[0];
|
|
144
|
-
if (isParentAComponentTheme) {
|
|
145
|
-
base.pop();
|
|
146
|
-
}
|
|
147
|
-
const parentBaseTheme = isParentAComponentTheme ? base.slice(0, base.length).join(THEME_NAME_SEPARATOR) : parentName;
|
|
148
|
-
const max = base.length;
|
|
149
|
-
const min = componentName && !nextName ? max : 0;
|
|
150
|
-
if (process.env.NODE_ENV === "development" && props.debug === "verbose")
|
|
151
|
-
[console.groupCollapsed("ThemeManager.getState()", props, { parentName, parentBaseTheme, base, min, max, isParentAComponentTheme }), console.trace(), console.groupEnd()];
|
|
152
|
-
for (let i = max; i >= min; i--) {
|
|
153
|
-
let prefix = base.slice(0, i).join(THEME_NAME_SEPARATOR);
|
|
154
|
-
if (props.inverse) {
|
|
155
|
-
prefix = inverseThemeName(prefix);
|
|
156
|
-
}
|
|
157
|
-
const potentials = [];
|
|
158
|
-
if (prefix && prefix !== parentBaseTheme) {
|
|
159
|
-
potentials.push(prefix);
|
|
160
|
-
}
|
|
161
|
-
if (nextName) {
|
|
162
|
-
potentials.unshift(prefix ? `${prefix}_${nextName}` : nextName);
|
|
163
|
-
}
|
|
164
|
-
if (i === 1) {
|
|
165
|
-
const lastSegment2 = potentials.findIndex((x) => !x.includes("_"));
|
|
166
|
-
if (lastSegment2 > 0) {
|
|
167
|
-
potentials.splice(lastSegment2, 0, nextName);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
if (componentName) {
|
|
171
|
-
if (nextName) {
|
|
172
|
-
potentials.push(
|
|
173
|
-
`${prefix.slice(
|
|
174
|
-
0,
|
|
175
|
-
prefix.indexOf(THEME_NAME_SEPARATOR)
|
|
176
|
-
)}_${nextName}_${componentName}`
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
|
-
potentials.push(`${prefix}_${componentName}`);
|
|
180
|
-
if (nextName) {
|
|
181
|
-
potentials.unshift(`${prefix}_${nextName}_${componentName}`);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
const found = potentials.find((t) => t in themes);
|
|
185
|
-
if (process.env.NODE_ENV === "development" && props.debug === "verbose")
|
|
186
|
-
console.log("getState found", found, "from", potentials, "parentName", parentName);
|
|
187
|
-
if (found) {
|
|
188
|
-
if (found === parentName) {
|
|
189
|
-
break;
|
|
190
|
-
}
|
|
191
|
-
result = {
|
|
192
|
-
name: found,
|
|
193
|
-
theme: getThemeUnwrapped(themes[found]),
|
|
194
|
-
className: getNextThemeClassName(found, props.inverse),
|
|
195
|
-
parentName
|
|
196
|
-
};
|
|
197
|
-
break;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
if (parentManager) {
|
|
201
|
-
cache.set(props, [parentManager, result]);
|
|
202
|
-
}
|
|
203
|
-
return result;
|
|
204
|
-
}
|
|
205
|
-
const inverseThemeName = (themeName) => {
|
|
206
|
-
return themeName.startsWith("light") ? themeName.replace(/^light/, "dark") : themeName.replace(/^dark/, "light");
|
|
207
|
-
};
|
|
208
|
-
export {
|
|
209
|
-
ThemeManager,
|
|
210
|
-
hasNoThemeUpdatingProps
|
|
211
|
-
};
|
|
1
|
+
import{getThemes as C,getTokens as P}from"../config.js";import{THEME_CLASSNAME_PREFIX as $,THEME_NAME_SEPARATOR as f}from"../constants/constants.js";import{getThemeUnwrapped as w}from"../hooks/getThemeUnwrapped.js";const v={name:""};function b(s){return!(s.name||s.componentName||s.inverse||s.reset)}let A=0;class U{constructor(e={},t){this.props=e;this.id=A++;this.themeListeners=new Set;this.parentManager=null;this.state=v;this._allKeys=null;if(t==="root"){this.updateState(e,!1);return}if(!t)throw process.env.NODE_ENV!=="production"?new Error("No parent manager given, this is likely due to duplicated Tamagui dependencies. Check your lockfile for mis-matched versions."):"\u274C";if(b(e))return t;t&&(this.parentManager=t);const i=this.getStateIfChanged(e);if(i){this.state=i;return}return t||this}updateState(e=this.props||{},t=!0){if((()=>{if(e.forceTheme)return this.state.theme=e.forceTheme,this.state.name=e.name||"",!0;const n=this.getStateIfChanged(e);if(n)return this.props=e,this.state=n,!0})())return this._allKeys=null,t&&this.notify(),this.state}getStateIfChanged(e=this.props,t=this.state,i=this.parentManager){const n=this.getState(e,i);if(t&&t!==v&&!n)return i==null?void 0:i.state;if(this.getStateShouldChange(n,t))return n}getStateShouldChange(e,t=this.state){return!(!(e!=null&&e.theme)||e.theme===(t==null?void 0:t.theme))}getState(e=this.props,t=this.parentManager){return x(e,t)||process.env.TAMAGUI_TARGET==="native"&&(t==null?void 0:t.state)||null}get allKeys(){var e;return this._allKeys||=new Set([...((e=this.parentManager)==null?void 0:e.allKeys)||[],...Object.keys(this.state.theme||{})]),this._allKeys}getValue(e,t){if(!e)return;let i=(t||this.state).theme,n=this;for(;i&&n;){if(e in i)return i[e];n=n.parentManager,i=n==null?void 0:n.state.theme}const h=P();if(e in h.color)return h.color[e]}notify(){this.themeListeners.forEach(e=>e(this.state.name,this))}onChangeTheme(e){return this.themeListeners.add(e),()=>{this.themeListeners.delete(e)}}}function k(s,e=!1){const t=`t_sub_theme ${$}${s}`;return e?t+(t.includes("dark_")?" t_dark":t.includes("light_")?" t_light":""):t.replace("light_","").replace("dark_","")}function x(s,e){var E,N,p;const t=C();if(s.name&&s.reset)throw new Error("Cannot reset + set new name");if(s.reset&&!(e!=null&&e.parentManager))return process.env.NODE_ENV==="development"&&console.warn("Cannot reset no grandparent exists"),null;let i=null;const n=s.reset?((N=(E=e==null?void 0:e.parentManager)==null?void 0:E.state)==null?void 0:N.name)||"":s.name||"",{componentName:h}=s,a=((p=e==null?void 0:e.state)==null?void 0:p.name)||"",o=a.split(f),T=o[o.length-1],g=a&&T[0].toUpperCase()===T[0];g&&o.pop();const S=g?o.slice(0,o.length).join(f):a,d=o.length,_=h&&!n?d:0;process.env.NODE_ENV==="development"&&typeof s.debug=="string"&&(console.groupCollapsed("ThemeManager.getState()"),console.log({parentName:a,parentBaseTheme:S,base:o,min:_,max:d,isParentComponentTheme:g}));for(let c=d;c>=_;c--){let l=o.slice(0,c).join(f);s.inverse&&(l=L(l));const r=[];if(l&&l!==S&&r.push(l),n&&r.unshift(l?`${l}_${n}`:n),c===1){const m=r.findIndex(y=>!y.includes("_"));m>0&&r.splice(m,0,n)}if(h){if(n){const m=l.slice(0,l.indexOf(f));r.push(`${m}_${n}_${h}`)}r.push(`${l}_${h}`),n&&r.unshift(`${l}_${n}_${h}`)}const u=r.find(m=>m in t);if(process.env.NODE_ENV==="development"&&typeof s.debug=="string"&&console.log(" - ",{found:u,potentials:r}),u){i={name:u,theme:w(t[u]),className:k(u,s.inverse),parentName:a};break}}return process.env.NODE_ENV==="development"&&typeof s.debug=="string"&&(console.log({result:i}),console.trace(),console.groupEnd()),i}const L=s=>s.startsWith("light")?s.replace(/^light/,"dark"):s.replace(/^dark/,"light");export{U as ThemeManager,b as hasNoThemeUpdatingProps};
|
|
212
2
|
//# sourceMappingURL=ThemeManager.js.map
|