@tamagui/web 3.0.0-beta.924.1 → 3.0.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/_withNativeStyle.cjs +3 -0
- package/dist/cjs/_withNativeStyle.native.cjs +3 -0
- package/dist/cjs/_withNativeStyle.native.js +3 -0
- package/dist/cjs/_withNativeStyle.native.js.map +1 -1
- package/dist/cjs/_withStableStyle.native.cjs +1 -5
- package/dist/cjs/_withStableStyle.native.js +1 -5
- package/dist/cjs/_withStableStyle.native.js.map +1 -1
- package/dist/cjs/config.cjs +6 -3
- package/dist/cjs/config.native.cjs +7 -5
- package/dist/cjs/config.native.js +7 -5
- package/dist/cjs/config.native.js.map +1 -1
- package/dist/cjs/contexts/ComponentContext.cjs +1 -0
- package/dist/cjs/contexts/ComponentContext.native.cjs +8 -0
- package/dist/cjs/contexts/ComponentContext.native.js +8 -0
- package/dist/cjs/contexts/ComponentContext.native.js.map +1 -1
- package/dist/cjs/createComponent.cjs +46 -32
- package/dist/cjs/createComponent.native.cjs +92 -72
- package/dist/cjs/createComponent.native.js +92 -72
- package/dist/cjs/createComponent.native.js.map +1 -1
- package/dist/cjs/createTamagui.cjs +32 -14
- package/dist/cjs/createTamagui.native.cjs +33 -19
- package/dist/cjs/createTamagui.native.js +33 -19
- package/dist/cjs/createTamagui.native.js.map +1 -1
- package/dist/cjs/createTokens.native.cjs +1 -5
- package/dist/cjs/createTokens.native.js +1 -5
- package/dist/cjs/createTokens.native.js.map +1 -1
- package/dist/cjs/createVariable.native.cjs +1 -5
- package/dist/cjs/createVariable.native.js +1 -5
- package/dist/cjs/createVariable.native.js.map +1 -1
- package/dist/cjs/createVariables.native.cjs +2 -6
- package/dist/cjs/createVariables.native.js +2 -6
- package/dist/cjs/createVariables.native.js.map +1 -1
- package/dist/cjs/dom/html.cjs +87 -329
- package/dist/cjs/dom/html.native.cjs +53 -2
- package/dist/cjs/dom/html.native.js +53 -2
- package/dist/cjs/dom/html.native.js.map +1 -1
- package/dist/cjs/{helpers/timer.native.js → dom/htmlReset.cjs} +6 -12
- package/dist/cjs/{helpers/timer.native.cjs → dom/htmlReset.native.cjs} +6 -8
- package/dist/cjs/dom/htmlReset.native.js +30 -0
- package/dist/cjs/dom/htmlReset.native.js.map +1 -0
- package/dist/cjs/dom/htmlRuntime.native.cjs +4 -0
- package/dist/cjs/dom/htmlRuntime.native.js +4 -0
- package/dist/cjs/dom/htmlRuntime.native.js.map +1 -1
- package/dist/cjs/dom/htmlStaticConfig.cjs +44 -0
- package/dist/cjs/dom/htmlStaticConfig.native.cjs +46 -0
- package/dist/cjs/dom/htmlStaticConfig.native.js +48 -0
- package/dist/cjs/dom/htmlStaticConfig.native.js.map +1 -0
- package/dist/cjs/dom/primitives.native.cjs +81 -34
- package/dist/cjs/dom/primitives.native.js +81 -34
- package/dist/cjs/dom/primitives.native.js.map +1 -1
- package/dist/cjs/eventHandling.cjs +10 -4
- package/dist/cjs/eventHandling.native.cjs +52 -16
- package/dist/cjs/eventHandling.native.js +52 -16
- package/dist/cjs/eventHandling.native.js.map +1 -1
- package/dist/cjs/helpers/NativeTextBinding.cjs +36 -0
- package/dist/cjs/helpers/NativeTextBinding.native.cjs +39 -0
- package/dist/cjs/helpers/NativeTextBinding.native.js +41 -0
- package/dist/cjs/helpers/NativeTextBinding.native.js.map +1 -0
- package/dist/cjs/helpers/configVariables.native.cjs +2 -6
- package/dist/cjs/helpers/configVariables.native.js +2 -6
- package/dist/cjs/helpers/configVariables.native.js.map +1 -1
- package/dist/cjs/helpers/createDesignSystem.cjs +14 -10
- package/dist/cjs/helpers/createDesignSystem.native.cjs +5 -4
- package/dist/cjs/helpers/createDesignSystem.native.js +5 -4
- package/dist/cjs/helpers/createDesignSystem.native.js.map +1 -1
- package/dist/cjs/helpers/createStyledContext.native.cjs +1 -5
- package/dist/cjs/helpers/createStyledContext.native.js +1 -5
- package/dist/cjs/helpers/createStyledContext.native.js.map +1 -1
- package/dist/cjs/helpers/expandStyle.cjs +45 -1
- package/dist/cjs/helpers/expandStyle.native.cjs +38 -2
- package/dist/cjs/helpers/expandStyle.native.js +38 -2
- package/dist/cjs/helpers/expandStyle.native.js.map +1 -1
- package/dist/cjs/helpers/expandStyles.cjs +15 -3
- package/dist/cjs/helpers/expandStyles.native.cjs +14 -8
- package/dist/cjs/helpers/expandStyles.native.js +14 -8
- package/dist/cjs/helpers/expandStyles.native.js.map +1 -1
- package/dist/cjs/helpers/fluid.cjs +56 -0
- package/dist/cjs/helpers/fluid.native.cjs +58 -0
- package/dist/cjs/helpers/fluid.native.js +60 -0
- package/dist/cjs/helpers/fluid.native.js.map +1 -0
- package/dist/cjs/helpers/formatDiagnostic.native.cjs +2 -6
- package/dist/cjs/helpers/formatDiagnostic.native.js +2 -6
- package/dist/cjs/helpers/formatDiagnostic.native.js.map +1 -1
- package/dist/cjs/helpers/getCSSStylesAtomic.cjs +6 -6
- package/dist/cjs/helpers/getSplitStyles.cjs +366 -150
- package/dist/cjs/helpers/getSplitStyles.native.cjs +584 -184
- package/dist/cjs/helpers/getSplitStyles.native.js +584 -184
- package/dist/cjs/helpers/getSplitStyles.native.js.map +1 -1
- package/dist/cjs/helpers/getThemeCSSRules.cjs +37 -25
- package/dist/cjs/helpers/grammarConfig.cjs +6 -14
- package/dist/cjs/helpers/grammarConfig.native.cjs +32 -22
- package/dist/cjs/helpers/grammarConfig.native.js +32 -22
- package/dist/cjs/helpers/grammarConfig.native.js.map +1 -1
- package/dist/cjs/helpers/insertStyleRule.cjs +11 -4
- package/dist/cjs/helpers/insertStyleRule.native.cjs +8 -11
- package/dist/cjs/helpers/insertStyleRule.native.js +8 -11
- package/dist/cjs/helpers/insertStyleRule.native.js.map +1 -1
- package/dist/cjs/helpers/isObj.native.cjs +1 -5
- package/dist/cjs/helpers/isObj.native.js +1 -5
- package/dist/cjs/helpers/isObj.native.js.map +1 -1
- package/dist/cjs/helpers/mainThreadPressEvents.native.cjs +48 -100
- package/dist/cjs/helpers/mainThreadPressEvents.native.js +48 -100
- package/dist/cjs/helpers/mainThreadPressEvents.native.js.map +1 -1
- package/dist/cjs/helpers/mergeProps.cjs +18 -21
- package/dist/cjs/helpers/mergeProps.native.cjs +20 -23
- package/dist/cjs/helpers/mergeProps.native.js +20 -23
- package/dist/cjs/helpers/mergeProps.native.js.map +1 -1
- package/dist/cjs/helpers/nativeOnlyProps.cjs +0 -1
- package/dist/cjs/helpers/nativeOnlyProps.native.cjs +0 -1
- package/dist/cjs/helpers/nativeOnlyProps.native.js +0 -1
- package/dist/cjs/helpers/nativeOnlyProps.native.js.map +1 -1
- package/dist/cjs/helpers/nativeTextMetrics.cjs +74 -0
- package/dist/cjs/helpers/nativeTextMetrics.native.cjs +77 -0
- package/dist/cjs/helpers/nativeTextMetrics.native.js +79 -0
- package/dist/cjs/helpers/nativeTextMetrics.native.js.map +1 -0
- package/dist/cjs/helpers/normalizeColor.native.cjs +17 -2
- package/dist/cjs/helpers/normalizeColor.native.js +17 -2
- package/dist/cjs/helpers/normalizeColor.native.js.map +1 -1
- package/dist/cjs/helpers/normalizeValueWithProperty.cjs +2 -1
- package/dist/cjs/helpers/normalizeValueWithProperty.native.cjs +3 -6
- package/dist/cjs/helpers/normalizeValueWithProperty.native.js +3 -6
- package/dist/cjs/helpers/normalizeValueWithProperty.native.js.map +1 -1
- package/dist/cjs/helpers/objectIdentityKey.native.cjs +1 -5
- package/dist/cjs/helpers/objectIdentityKey.native.js +1 -5
- package/dist/cjs/helpers/objectIdentityKey.native.js.map +1 -1
- package/dist/cjs/helpers/parseNativeStyle.cjs +187 -0
- package/dist/cjs/helpers/parseNativeStyle.native.cjs +6 -4
- package/dist/cjs/helpers/parseNativeStyle.native.js +6 -4
- package/dist/cjs/helpers/parseNativeStyle.native.js.map +1 -1
- package/dist/cjs/helpers/proxyThemeToParents.cjs +9 -2
- package/dist/cjs/helpers/proxyThemeToParents.native.cjs +28 -2
- package/dist/cjs/helpers/proxyThemeToParents.native.js +28 -2
- package/dist/cjs/helpers/proxyThemeToParents.native.js.map +1 -1
- package/dist/cjs/helpers/resolveAnimationDriver.native.cjs +1 -5
- package/dist/cjs/helpers/resolveAnimationDriver.native.js +1 -5
- package/dist/cjs/helpers/resolveAnimationDriver.native.js.map +1 -1
- package/dist/cjs/helpers/{timer.cjs → resolveNativeUnits.cjs} +12 -8
- package/dist/cjs/helpers/resolveNativeUnits.native.cjs +205 -0
- package/dist/cjs/helpers/resolveNativeUnits.native.js +207 -0
- package/dist/cjs/helpers/resolveNativeUnits.native.js.map +1 -0
- package/dist/cjs/helpers/resolveRem.native.cjs +18 -21
- package/dist/cjs/helpers/resolveRem.native.js +18 -21
- package/dist/cjs/helpers/resolveRem.native.js.map +1 -1
- package/dist/cjs/helpers/resolveSizing.cjs +124 -0
- package/dist/cjs/helpers/resolveSizing.native.cjs +133 -0
- package/dist/cjs/helpers/resolveSizing.native.js +135 -0
- package/dist/cjs/helpers/resolveSizing.native.js.map +1 -0
- package/dist/cjs/helpers/resolveVariableValue.cjs +7 -7
- package/dist/cjs/helpers/resolveVariableValue.native.cjs +7 -9
- package/dist/cjs/helpers/resolveVariableValue.native.js +7 -9
- package/dist/cjs/helpers/resolveVariableValue.native.js.map +1 -1
- package/dist/cjs/helpers/resolveVariantStyle.native.cjs +2 -6
- package/dist/cjs/helpers/resolveVariantStyle.native.js +2 -6
- package/dist/cjs/helpers/resolveVariantStyle.native.js.map +1 -1
- package/dist/cjs/helpers/skipProps.cjs +0 -1
- package/dist/cjs/helpers/skipProps.native.cjs +0 -1
- package/dist/cjs/helpers/skipProps.native.js +0 -1
- package/dist/cjs/helpers/skipProps.native.js.map +1 -1
- package/dist/cjs/helpers/styleFrontend.cjs +23 -1
- package/dist/cjs/helpers/styleFrontend.native.cjs +23 -1
- package/dist/cjs/helpers/styleFrontend.native.js +23 -1
- package/dist/cjs/helpers/styleFrontend.native.js.map +1 -1
- package/dist/cjs/helpers/styleStaticConfigCore.cjs +5 -4
- package/dist/cjs/helpers/styleStaticConfigCore.native.cjs +7 -4
- package/dist/cjs/helpers/styleStaticConfigCore.native.js +7 -4
- package/dist/cjs/helpers/styleStaticConfigCore.native.js.map +1 -1
- package/dist/cjs/helpers/styledDynamic.cjs +5 -0
- package/dist/cjs/helpers/styledDynamic.native.cjs +8 -7
- package/dist/cjs/helpers/styledDynamic.native.js +8 -7
- package/dist/cjs/helpers/styledDynamic.native.js.map +1 -1
- package/dist/cjs/helpers/subscribeToContextGroup.cjs +16 -7
- package/dist/cjs/helpers/subscribeToContextGroup.native.cjs +18 -8
- package/dist/cjs/helpers/subscribeToContextGroup.native.js +18 -8
- package/dist/cjs/helpers/subscribeToContextGroup.native.js.map +1 -1
- package/dist/cjs/helpers/themeRef.native.cjs +1 -5
- package/dist/cjs/helpers/themeRef.native.js +1 -5
- package/dist/cjs/helpers/themeRef.native.js.map +1 -1
- package/dist/cjs/helpers/themes.cjs +26 -11
- package/dist/cjs/helpers/themes.native.cjs +26 -11
- package/dist/cjs/helpers/themes.native.js +26 -11
- package/dist/cjs/helpers/themes.native.js.map +1 -1
- package/dist/cjs/helpers/tokenCategories.cjs +2 -2
- package/dist/cjs/helpers/tokenCategories.native.cjs +2 -2
- package/dist/cjs/helpers/tokenCategories.native.js +2 -2
- package/dist/cjs/helpers/tokenCategories.native.js.map +1 -1
- package/dist/cjs/helpers/variables.cjs +1 -1
- package/dist/cjs/helpers/variables.native.cjs +4 -8
- package/dist/cjs/helpers/variables.native.js +4 -8
- package/dist/cjs/helpers/variables.native.js.map +1 -1
- package/dist/cjs/helpers/warnOnce.cjs +6 -0
- package/dist/cjs/helpers/warnOnce.native.cjs +6 -0
- package/dist/cjs/helpers/warnOnce.native.js +6 -0
- package/dist/cjs/helpers/warnOnce.native.js.map +1 -1
- package/dist/cjs/helpers/webPropsToSkip.native.cjs +3 -3
- package/dist/cjs/helpers/webPropsToSkip.native.js +3 -3
- package/dist/cjs/helpers/webPropsToSkip.native.js.map +1 -1
- package/dist/cjs/helpers/wrapStyleTags.cjs +1 -1
- package/dist/cjs/helpers/wrapStyleTags.native.cjs +1 -1
- package/dist/cjs/helpers/wrapStyleTags.native.js +1 -1
- package/dist/cjs/helpers/wrapStyleTags.native.js.map +1 -1
- package/dist/cjs/hooks/useComponentState.native.cjs +1 -5
- package/dist/cjs/hooks/useComponentState.native.js +1 -5
- package/dist/cjs/hooks/useComponentState.native.js.map +1 -1
- package/dist/cjs/hooks/useMedia.cjs +27 -34
- package/dist/cjs/hooks/useMedia.native.cjs +45 -51
- package/dist/cjs/hooks/useMedia.native.js +45 -51
- package/dist/cjs/hooks/useMedia.native.js.map +1 -1
- package/dist/cjs/hooks/useSplitStyles.cjs +1 -1
- package/dist/cjs/hooks/useSplitStyles.native.cjs +1 -1
- package/dist/cjs/hooks/useSplitStyles.native.js +1 -1
- package/dist/cjs/hooks/useSplitStyles.native.js.map +1 -1
- package/dist/cjs/hooks/useThemeState.cjs +37 -47
- package/dist/cjs/hooks/useThemeState.native.cjs +44 -50
- package/dist/cjs/hooks/useThemeState.native.js +44 -50
- package/dist/cjs/hooks/useThemeState.native.js.map +1 -1
- package/dist/cjs/index.cjs +7 -0
- package/dist/cjs/index.native.cjs +7 -0
- package/dist/cjs/index.native.js +7 -0
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/internal-runtime.cjs +22 -0
- package/dist/cjs/internal-runtime.native.cjs +22 -0
- package/dist/cjs/internal-runtime.native.js +22 -0
- package/dist/cjs/internal-runtime.native.js.map +1 -1
- package/dist/cjs/static-resolve.native.cjs +2 -9
- package/dist/cjs/static-resolve.native.js +2 -9
- package/dist/cjs/static-resolve.native.js.map +1 -1
- package/dist/cjs/style.cjs +1 -1
- package/dist/cjs/style.native.cjs +4 -7
- package/dist/cjs/style.native.js +4 -7
- package/dist/cjs/style.native.js.map +1 -1
- package/dist/cjs/views/Theme.cjs +10 -17
- package/dist/cjs/views/Theme.native.cjs +9 -11
- package/dist/cjs/views/Theme.native.js +9 -11
- package/dist/cjs/views/Theme.native.js.map +1 -1
- package/dist/cjs/views/ThemeDebug.cjs +1 -1
- package/dist/cjs/views/ThemeUpdate.cjs +1 -1
- package/dist/cjs/views/ThemeUpdate.native.cjs +1 -1
- package/dist/cjs/views/ThemeUpdate.native.js +1 -1
- package/dist/cjs/views/ThemeUpdate.native.js.map +1 -1
- package/dist/esm/_withNativeStyle.mjs +4 -1
- package/dist/esm/_withNativeStyle.mjs.map +1 -1
- package/dist/esm/_withNativeStyle.native.js +4 -1
- package/dist/esm/_withNativeStyle.native.js.map +1 -1
- package/dist/esm/_withStableStyle.native.js +1 -5
- package/dist/esm/_withStableStyle.native.js.map +1 -1
- package/dist/esm/config.mjs +6 -3
- package/dist/esm/config.mjs.map +1 -1
- package/dist/esm/config.native.js +7 -5
- package/dist/esm/config.native.js.map +1 -1
- package/dist/esm/contexts/ComponentContext.mjs +9 -9
- package/dist/esm/contexts/ComponentContext.mjs.map +1 -1
- package/dist/esm/contexts/ComponentContext.native.js +16 -9
- package/dist/esm/contexts/ComponentContext.native.js.map +1 -1
- package/dist/esm/createComponent.mjs +45 -42
- package/dist/esm/createComponent.mjs.map +1 -1
- package/dist/esm/createComponent.native.js +93 -82
- package/dist/esm/createComponent.native.js.map +1 -1
- package/dist/esm/createTamagui.mjs +33 -15
- package/dist/esm/createTamagui.mjs.map +1 -1
- package/dist/esm/createTamagui.native.js +34 -20
- package/dist/esm/createTamagui.native.js.map +1 -1
- package/dist/esm/createTokens.native.js +1 -5
- package/dist/esm/createTokens.native.js.map +1 -1
- package/dist/esm/createVariable.native.js +1 -5
- package/dist/esm/createVariable.native.js.map +1 -1
- package/dist/esm/createVariables.native.js +2 -6
- package/dist/esm/createVariables.native.js.map +1 -1
- package/dist/esm/dom/html.mjs +87 -329
- package/dist/esm/dom/html.mjs.map +1 -1
- package/dist/esm/dom/html.native.js +53 -2
- package/dist/esm/dom/html.native.js.map +1 -1
- package/dist/esm/dom/htmlReset.mjs +6 -0
- package/dist/esm/dom/htmlReset.mjs.map +1 -0
- package/dist/esm/dom/htmlReset.native.js +6 -0
- package/dist/esm/dom/htmlReset.native.js.map +1 -0
- package/dist/esm/dom/htmlRuntime.native.js +4 -0
- package/dist/esm/dom/htmlRuntime.native.js.map +1 -1
- package/dist/esm/dom/htmlStaticConfig.mjs +22 -0
- package/dist/esm/dom/htmlStaticConfig.mjs.map +1 -0
- package/dist/esm/dom/htmlStaticConfig.native.js +22 -0
- package/dist/esm/dom/htmlStaticConfig.native.js.map +1 -0
- package/dist/esm/dom/primitives.native.js +81 -34
- package/dist/esm/dom/primitives.native.js.map +1 -1
- package/dist/esm/eventHandling.mjs +10 -4
- package/dist/esm/eventHandling.mjs.map +1 -1
- package/dist/esm/eventHandling.native.js +52 -16
- package/dist/esm/eventHandling.native.js.map +1 -1
- package/dist/esm/helpers/NativeTextBinding.mjs +17 -0
- package/dist/esm/helpers/NativeTextBinding.mjs.map +1 -0
- package/dist/esm/helpers/NativeTextBinding.native.js +18 -0
- package/dist/esm/helpers/NativeTextBinding.native.js.map +1 -0
- package/dist/esm/helpers/configVariables.native.js +2 -6
- package/dist/esm/helpers/configVariables.native.js.map +1 -1
- package/dist/esm/helpers/createDesignSystem.mjs +14 -10
- package/dist/esm/helpers/createDesignSystem.mjs.map +1 -1
- package/dist/esm/helpers/createDesignSystem.native.js +4 -4
- package/dist/esm/helpers/createDesignSystem.native.js.map +1 -1
- package/dist/esm/helpers/createStyledContext.native.js +1 -5
- package/dist/esm/helpers/createStyledContext.native.js.map +1 -1
- package/dist/esm/helpers/expandStyle.mjs +41 -1
- package/dist/esm/helpers/expandStyle.mjs.map +1 -1
- package/dist/esm/helpers/expandStyle.native.js +36 -3
- package/dist/esm/helpers/expandStyle.native.js.map +1 -1
- package/dist/esm/helpers/expandStyles.mjs +15 -3
- package/dist/esm/helpers/expandStyles.mjs.map +1 -1
- package/dist/esm/helpers/expandStyles.native.js +14 -8
- package/dist/esm/helpers/expandStyles.native.js.map +1 -1
- package/dist/esm/helpers/fluid.mjs +36 -0
- package/dist/esm/helpers/fluid.mjs.map +1 -0
- package/dist/esm/helpers/fluid.native.js +36 -0
- package/dist/esm/helpers/fluid.native.js.map +1 -0
- package/dist/esm/helpers/formatDiagnostic.native.js +2 -6
- package/dist/esm/helpers/formatDiagnostic.native.js.map +1 -1
- package/dist/esm/helpers/getCSSStylesAtomic.mjs +6 -6
- package/dist/esm/helpers/getCSSStylesAtomic.mjs.map +1 -1
- package/dist/esm/helpers/getSplitStyles.mjs +364 -150
- package/dist/esm/helpers/getSplitStyles.mjs.map +1 -1
- package/dist/esm/helpers/getSplitStyles.native.js +588 -188
- package/dist/esm/helpers/getSplitStyles.native.js.map +1 -1
- package/dist/esm/helpers/getThemeCSSRules.mjs +37 -25
- package/dist/esm/helpers/getThemeCSSRules.mjs.map +1 -1
- package/dist/esm/helpers/grammarConfig.mjs +6 -14
- package/dist/esm/helpers/grammarConfig.mjs.map +1 -1
- package/dist/esm/helpers/grammarConfig.native.js +32 -22
- package/dist/esm/helpers/grammarConfig.native.js.map +1 -1
- package/dist/esm/helpers/insertStyleRule.mjs +11 -4
- package/dist/esm/helpers/insertStyleRule.mjs.map +1 -1
- package/dist/esm/helpers/insertStyleRule.native.js +4 -4
- package/dist/esm/helpers/insertStyleRule.native.js.map +1 -1
- package/dist/esm/helpers/isObj.native.js +1 -5
- package/dist/esm/helpers/isObj.native.js.map +1 -1
- package/dist/esm/helpers/mainThreadPressEvents.native.js +48 -100
- package/dist/esm/helpers/mainThreadPressEvents.native.js.map +1 -1
- package/dist/esm/helpers/mergeProps.mjs +18 -21
- package/dist/esm/helpers/mergeProps.mjs.map +1 -1
- package/dist/esm/helpers/mergeProps.native.js +20 -23
- package/dist/esm/helpers/mergeProps.native.js.map +1 -1
- package/dist/esm/helpers/nativeOnlyProps.mjs +0 -1
- package/dist/esm/helpers/nativeOnlyProps.mjs.map +1 -1
- package/dist/esm/helpers/nativeOnlyProps.native.js +0 -1
- package/dist/esm/helpers/nativeOnlyProps.native.js.map +1 -1
- package/dist/esm/helpers/nativeTextMetrics.mjs +55 -0
- package/dist/esm/helpers/nativeTextMetrics.mjs.map +1 -0
- package/dist/esm/helpers/nativeTextMetrics.native.js +56 -0
- package/dist/esm/helpers/nativeTextMetrics.native.js.map +1 -0
- package/dist/esm/helpers/normalizeColor.native.js +17 -2
- package/dist/esm/helpers/normalizeColor.native.js.map +1 -1
- package/dist/esm/helpers/normalizeValueWithProperty.mjs +2 -1
- package/dist/esm/helpers/normalizeValueWithProperty.mjs.map +1 -1
- package/dist/esm/helpers/normalizeValueWithProperty.native.js +3 -6
- package/dist/esm/helpers/normalizeValueWithProperty.native.js.map +1 -1
- package/dist/esm/helpers/objectIdentityKey.native.js +1 -5
- package/dist/esm/helpers/objectIdentityKey.native.js.map +1 -1
- package/dist/esm/helpers/parseNativeStyle.mjs +168 -0
- package/dist/esm/helpers/parseNativeStyle.mjs.map +1 -0
- package/dist/esm/helpers/parseNativeStyle.native.js +4 -1
- package/dist/esm/helpers/parseNativeStyle.native.js.map +1 -1
- package/dist/esm/helpers/proxyThemeToParents.mjs +10 -2
- package/dist/esm/helpers/proxyThemeToParents.mjs.map +1 -1
- package/dist/esm/helpers/proxyThemeToParents.native.js +29 -2
- package/dist/esm/helpers/proxyThemeToParents.native.js.map +1 -1
- package/dist/esm/helpers/resolveAnimationDriver.native.js +1 -5
- package/dist/esm/helpers/resolveAnimationDriver.native.js.map +1 -1
- package/dist/esm/helpers/resolveNativeUnits.mjs +9 -0
- package/dist/esm/helpers/resolveNativeUnits.mjs.map +1 -0
- package/dist/esm/helpers/resolveNativeUnits.native.js +178 -0
- package/dist/esm/helpers/resolveNativeUnits.native.js.map +1 -0
- package/dist/esm/helpers/resolveRem.native.js +18 -21
- package/dist/esm/helpers/resolveRem.native.js.map +1 -1
- package/dist/esm/helpers/resolveSizing.mjs +102 -0
- package/dist/esm/helpers/resolveSizing.mjs.map +1 -0
- package/dist/esm/helpers/resolveSizing.native.js +109 -0
- package/dist/esm/helpers/resolveSizing.native.js.map +1 -0
- package/dist/esm/helpers/resolveVariableValue.mjs +7 -7
- package/dist/esm/helpers/resolveVariableValue.mjs.map +1 -1
- package/dist/esm/helpers/resolveVariableValue.native.js +7 -9
- package/dist/esm/helpers/resolveVariableValue.native.js.map +1 -1
- package/dist/esm/helpers/resolveVariantStyle.native.js +2 -6
- package/dist/esm/helpers/resolveVariantStyle.native.js.map +1 -1
- package/dist/esm/helpers/skipProps.mjs +0 -1
- package/dist/esm/helpers/skipProps.mjs.map +1 -1
- package/dist/esm/helpers/skipProps.native.js +0 -1
- package/dist/esm/helpers/skipProps.native.js.map +1 -1
- package/dist/esm/helpers/styleFrontend.mjs +20 -1
- package/dist/esm/helpers/styleFrontend.mjs.map +1 -1
- package/dist/esm/helpers/styleFrontend.native.js +20 -1
- package/dist/esm/helpers/styleFrontend.native.js.map +1 -1
- package/dist/esm/helpers/styleStaticConfigCore.mjs +5 -4
- package/dist/esm/helpers/styleStaticConfigCore.mjs.map +1 -1
- package/dist/esm/helpers/styleStaticConfigCore.native.js +7 -4
- package/dist/esm/helpers/styleStaticConfigCore.native.js.map +1 -1
- package/dist/esm/helpers/styledDynamic.mjs +5 -0
- package/dist/esm/helpers/styledDynamic.mjs.map +1 -1
- package/dist/esm/helpers/styledDynamic.native.js +8 -7
- package/dist/esm/helpers/styledDynamic.native.js.map +1 -1
- package/dist/esm/helpers/subscribeToContextGroup.mjs +16 -7
- package/dist/esm/helpers/subscribeToContextGroup.mjs.map +1 -1
- package/dist/esm/helpers/subscribeToContextGroup.native.js +18 -8
- package/dist/esm/helpers/subscribeToContextGroup.native.js.map +1 -1
- package/dist/esm/helpers/themeRef.native.js +1 -5
- package/dist/esm/helpers/themeRef.native.js.map +1 -1
- package/dist/esm/helpers/themes.mjs +20 -11
- package/dist/esm/helpers/themes.mjs.map +1 -1
- package/dist/esm/helpers/themes.native.js +20 -11
- package/dist/esm/helpers/themes.native.js.map +1 -1
- package/dist/esm/helpers/tokenCategories.mjs +2 -2
- package/dist/esm/helpers/tokenCategories.mjs.map +1 -1
- package/dist/esm/helpers/tokenCategories.native.js +2 -2
- package/dist/esm/helpers/tokenCategories.native.js.map +1 -1
- package/dist/esm/helpers/variables.mjs +1 -1
- package/dist/esm/helpers/variables.mjs.map +1 -1
- package/dist/esm/helpers/variables.native.js +4 -8
- package/dist/esm/helpers/variables.native.js.map +1 -1
- package/dist/esm/helpers/warnOnce.mjs +6 -1
- package/dist/esm/helpers/warnOnce.mjs.map +1 -1
- package/dist/esm/helpers/warnOnce.native.js +6 -1
- package/dist/esm/helpers/warnOnce.native.js.map +1 -1
- package/dist/esm/helpers/webPropsToSkip.native.js +3 -3
- package/dist/esm/helpers/webPropsToSkip.native.js.map +1 -1
- package/dist/esm/helpers/wrapStyleTags.mjs +1 -1
- package/dist/esm/helpers/wrapStyleTags.mjs.map +1 -1
- package/dist/esm/helpers/wrapStyleTags.native.js +1 -1
- package/dist/esm/helpers/wrapStyleTags.native.js.map +1 -1
- package/dist/esm/hooks/useComponentState.native.js +1 -5
- package/dist/esm/hooks/useComponentState.native.js.map +1 -1
- package/dist/esm/hooks/useMedia.mjs +27 -34
- package/dist/esm/hooks/useMedia.mjs.map +1 -1
- package/dist/esm/hooks/useMedia.native.js +45 -51
- package/dist/esm/hooks/useMedia.native.js.map +1 -1
- package/dist/esm/hooks/useSplitStyles.mjs +1 -1
- package/dist/esm/hooks/useSplitStyles.mjs.map +1 -1
- package/dist/esm/hooks/useSplitStyles.native.js +1 -1
- package/dist/esm/hooks/useSplitStyles.native.js.map +1 -1
- package/dist/esm/hooks/useThemeState.mjs +36 -48
- package/dist/esm/hooks/useThemeState.mjs.map +1 -1
- package/dist/esm/hooks/useThemeState.native.js +44 -50
- package/dist/esm/hooks/useThemeState.native.js.map +1 -1
- package/dist/esm/index.js +4 -1
- package/dist/esm/index.mjs +4 -1
- package/dist/esm/index.native.js +4 -1
- package/dist/esm/internal-runtime.mjs +22 -3
- package/dist/esm/internal-runtime.mjs.map +1 -1
- package/dist/esm/internal-runtime.native.js +22 -3
- package/dist/esm/internal-runtime.native.js.map +1 -1
- package/dist/esm/static-resolve.native.js +2 -9
- package/dist/esm/static-resolve.native.js.map +1 -1
- package/dist/esm/style.mjs +1 -1
- package/dist/esm/style.mjs.map +1 -1
- package/dist/esm/style.native.js +4 -7
- package/dist/esm/style.native.js.map +1 -1
- package/dist/esm/views/Theme.mjs +15 -14
- package/dist/esm/views/Theme.mjs.map +1 -1
- package/dist/esm/views/Theme.native.js +15 -15
- package/dist/esm/views/Theme.native.js.map +1 -1
- package/dist/esm/views/ThemeDebug.mjs +1 -1
- package/dist/esm/views/ThemeDebug.mjs.map +1 -1
- package/dist/esm/views/ThemeUpdate.mjs +1 -1
- package/dist/esm/views/ThemeUpdate.mjs.map +1 -1
- package/dist/esm/views/ThemeUpdate.native.js +1 -1
- package/dist/esm/views/ThemeUpdate.native.js.map +1 -1
- package/package.json +20 -18
- package/reset.css +11 -0
- package/src/_withNativeStyle.tsx +6 -1
- package/src/config.ts +6 -6
- package/src/contexts/ComponentContext.tsx +8 -0
- package/src/createComponent.tsx +177 -57
- package/src/createStyledHOC.tsx +25 -26
- package/src/createTamagui.ts +47 -28
- package/src/dom/contract.ts +4 -1
- package/src/dom/html.native.tsx +55 -2
- package/src/dom/html.tsx +189 -388
- package/src/dom/htmlReset.ts +15 -0
- package/src/dom/htmlRuntime.native.tsx +5 -0
- package/src/dom/htmlStaticConfig.ts +40 -0
- package/src/dom/primitives.native.tsx +138 -33
- package/src/dom/standalone.ts +2 -1
- package/src/dom/styleTypes.ts +82 -92
- package/src/eventHandling.native.ts +61 -11
- package/src/eventHandling.ts +19 -4
- package/src/helpers/NativeTextBinding.tsx +26 -0
- package/src/helpers/createDesignSystem.ts +24 -8
- package/src/helpers/expandStyle.ts +88 -4
- package/src/helpers/expandStyles.ts +6 -11
- package/src/helpers/fluid.ts +66 -0
- package/src/helpers/getCSSStylesAtomic.ts +11 -6
- package/src/helpers/getSplitStyles.tsx +1032 -296
- package/src/helpers/getThemeCSSRules.ts +73 -35
- package/src/helpers/grammarConfig.ts +23 -8
- package/src/helpers/insertStyleRule.tsx +14 -8
- package/src/helpers/mainThreadPressEvents.native.ts +65 -141
- package/src/helpers/mergeProps.ts +29 -62
- package/src/helpers/nativeOnlyProps.ts +0 -1
- package/src/helpers/nativeTextMetrics.ts +77 -0
- package/src/helpers/normalizeColor.native.ts +29 -4
- package/src/helpers/normalizeValueWithProperty.ts +2 -1
- package/src/helpers/{parseNativeStyle.native.ts → parseNativeStyle.ts} +8 -1
- package/src/helpers/proxyThemeToParents.ts +13 -2
- package/src/helpers/resolveNativeUnits.native.ts +247 -0
- package/src/helpers/resolveNativeUnits.ts +10 -0
- package/src/helpers/resolveRem.native.ts +25 -26
- package/src/helpers/resolveSizing.ts +167 -0
- package/src/helpers/resolveVariableValue.ts +21 -17
- package/src/helpers/skipProps.ts +0 -1
- package/src/helpers/styleFrontend.ts +39 -0
- package/src/helpers/styleProvenance.ts +1 -1
- package/src/helpers/styleStaticConfigCore.ts +15 -4
- package/src/helpers/styledDynamic.ts +3 -1
- package/src/helpers/subscribeToContextGroup.tsx +16 -7
- package/src/helpers/themes.ts +27 -11
- package/src/helpers/tokenCategories.ts +15 -3
- package/src/helpers/variables.ts +2 -2
- package/src/helpers/warnOnce.ts +6 -0
- package/src/helpers/webPropsToSkip.native.ts +9 -3
- package/src/helpers/wrapStyleTags.tsx +4 -1
- package/src/hooks/useMedia.tsx +36 -47
- package/src/hooks/useSplitStyles.tsx +4 -1
- package/src/hooks/useThemeState.ts +69 -74
- package/src/index.ts +13 -0
- package/src/interfaces/RNExclusiveTypes.ts +1 -3
- package/src/internal-runtime.ts +43 -2
- package/src/style.ts +4 -1
- package/src/styled.tsx +34 -3
- package/src/types.tsx +412 -132
- package/src/views/Theme.tsx +18 -21
- package/src/views/ThemeDebug.tsx +1 -1
- package/src/views/ThemeUpdate.tsx +1 -1
- package/types/_withNativeStyle.d.ts.map +1 -1
- package/types/config.d.ts.map +1 -1
- package/types/contexts/ComponentContext.d.ts +1 -1
- package/types/contexts/ComponentContext.d.ts.map +1 -1
- package/types/createComponent.d.ts.map +1 -1
- package/types/createStyledHOC.d.ts +5 -2
- package/types/createStyledHOC.d.ts.map +1 -1
- package/types/createTamagui.d.ts.map +1 -1
- package/types/dom/contract.d.ts +4 -1
- package/types/dom/contract.d.ts.map +1 -1
- package/types/dom/html.d.ts +60 -51
- package/types/dom/html.d.ts.map +1 -1
- package/types/dom/html.native.d.ts.map +1 -1
- package/types/dom/htmlReset.d.ts +10 -0
- package/types/dom/htmlReset.d.ts.map +1 -0
- package/types/dom/htmlRuntime.native.d.ts.map +1 -1
- package/types/dom/htmlStaticConfig.d.ts +22 -0
- package/types/dom/htmlStaticConfig.d.ts.map +1 -0
- package/types/dom/primitives.native.d.ts.map +1 -1
- package/types/dom/standalone.d.ts +2 -1
- package/types/dom/standalone.d.ts.map +1 -1
- package/types/dom/styleTypes.d.ts +63 -84
- package/types/dom/styleTypes.d.ts.map +1 -1
- package/types/eventHandling.d.ts +12 -4
- package/types/eventHandling.d.ts.map +1 -1
- package/types/eventHandling.native.d.ts.map +1 -1
- package/types/helpers/NativeTextBinding.d.ts +11 -0
- package/types/helpers/NativeTextBinding.d.ts.map +1 -0
- package/types/helpers/createDesignSystem.d.ts.map +1 -1
- package/types/helpers/expandStyle.d.ts +1 -0
- package/types/helpers/expandStyle.d.ts.map +1 -1
- package/types/helpers/expandStyles.d.ts.map +1 -1
- package/types/helpers/fluid.d.ts +21 -0
- package/types/helpers/fluid.d.ts.map +1 -0
- package/types/helpers/getCSSStylesAtomic.d.ts +3 -1
- package/types/helpers/getCSSStylesAtomic.d.ts.map +1 -1
- package/types/helpers/getSplitStyles.d.ts +2 -1
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/helpers/getThemeCSSRules.d.ts.map +1 -1
- package/types/helpers/grammarConfig.d.ts.map +1 -1
- package/types/helpers/insertStyleRule.d.ts.map +1 -1
- package/types/helpers/mainThreadPressEvents.native.d.ts +0 -7
- package/types/helpers/mainThreadPressEvents.native.d.ts.map +1 -1
- package/types/helpers/mergeProps.d.ts +1 -15
- package/types/helpers/mergeProps.d.ts.map +1 -1
- package/types/helpers/nativeOnlyProps.d.ts +0 -1
- package/types/helpers/nativeOnlyProps.d.ts.map +1 -1
- package/types/helpers/nativeTextMetrics.d.ts +16 -0
- package/types/helpers/nativeTextMetrics.d.ts.map +1 -0
- package/types/helpers/normalizeColor.native.d.ts +4 -1
- package/types/helpers/normalizeColor.native.d.ts.map +1 -1
- package/types/helpers/normalizeShadow.native.d.ts +3 -1
- package/types/helpers/normalizeShadow.native.d.ts.map +1 -1
- package/types/helpers/normalizeValueWithProperty.d.ts.map +1 -1
- package/types/helpers/{parseNativeStyle.native.d.ts → parseNativeStyle.d.ts} +1 -1
- package/types/helpers/parseNativeStyle.d.ts.map +1 -0
- package/types/helpers/proxyThemeToParents.d.ts +1 -1
- package/types/helpers/proxyThemeToParents.d.ts.map +1 -1
- package/types/helpers/resolveNativeUnits.d.ts +6 -0
- package/types/helpers/resolveNativeUnits.d.ts.map +1 -0
- package/types/helpers/resolveNativeUnits.native.d.ts +16 -0
- package/types/helpers/resolveNativeUnits.native.d.ts.map +1 -0
- package/types/helpers/resolveRem.native.d.ts +6 -4
- package/types/helpers/resolveRem.native.d.ts.map +1 -1
- package/types/helpers/resolveSizing.d.ts +90 -0
- package/types/helpers/resolveSizing.d.ts.map +1 -0
- package/types/helpers/resolveVariableValue.d.ts.map +1 -1
- package/types/helpers/skipProps.d.ts +0 -1
- package/types/helpers/skipProps.d.ts.map +1 -1
- package/types/helpers/styleFrontend.d.ts +21 -0
- package/types/helpers/styleFrontend.d.ts.map +1 -1
- package/types/helpers/styleProvenance.d.ts +1 -1
- package/types/helpers/styleProvenance.d.ts.map +1 -1
- package/types/helpers/styleStaticConfigCore.d.ts.map +1 -1
- package/types/helpers/styledDynamic.d.ts +1 -1
- package/types/helpers/styledDynamic.d.ts.map +1 -1
- package/types/helpers/themes.d.ts +4 -0
- package/types/helpers/themes.d.ts.map +1 -1
- package/types/helpers/tokenCategories.d.ts +1 -1
- package/types/helpers/tokenCategories.d.ts.map +1 -1
- package/types/helpers/warnOnce.d.ts +1 -0
- package/types/helpers/warnOnce.d.ts.map +1 -1
- package/types/helpers/webPropsToSkip.native.d.ts +6 -2
- package/types/helpers/webPropsToSkip.native.d.ts.map +1 -1
- package/types/helpers/wrapStyleTags.d.ts.map +1 -1
- package/types/hooks/useMedia.d.ts +5 -2
- package/types/hooks/useMedia.d.ts.map +1 -1
- package/types/hooks/useSplitStyles.d.ts.map +1 -1
- package/types/hooks/useThemeState.d.ts.map +1 -1
- package/types/index.d.ts +4 -1
- package/types/index.d.ts.map +1 -1
- package/types/interfaces/RNExclusiveTypes.d.ts +2 -3
- package/types/interfaces/RNExclusiveTypes.d.ts.map +1 -1
- package/types/internal-runtime.d.ts +12 -1
- package/types/internal-runtime.d.ts.map +1 -1
- package/types/style.d.ts.map +1 -1
- package/types/styled.d.ts +7 -4
- package/types/styled.d.ts.map +1 -1
- package/types/types.d.ts +258 -102
- package/types/types.d.ts.map +1 -1
- package/types/views/Theme.d.ts.map +1 -1
- package/dist/cjs/helpers/timer.native.js.map +0 -1
- package/dist/esm/helpers/timer.mjs +0 -13
- package/dist/esm/helpers/timer.mjs.map +0 -1
- package/dist/esm/helpers/timer.native.js +0 -13
- package/dist/esm/helpers/timer.native.js.map +0 -1
- package/src/helpers/timer.ts +0 -9
- package/types/helpers/parseNativeStyle.native.d.ts.map +0 -1
- package/types/helpers/timer.d.ts +0 -2
- package/types/helpers/timer.d.ts.map +0 -1
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { isVariable } from '../createVariable'
|
|
2
|
+
import { resolveVariableValue } from './resolveVariableValue'
|
|
3
|
+
|
|
4
|
+
export type NativeTextMetrics = {
|
|
5
|
+
fontSize?: number
|
|
6
|
+
inheritsFontSize?: boolean
|
|
7
|
+
// numbers retain a ratio; lengths retain their unit until host finalization.
|
|
8
|
+
lineHeight?: number | `${number}px` | 'normal'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type AnimatedTextChannel = {
|
|
12
|
+
fontSize: unknown
|
|
13
|
+
driver: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type NativeTextContext = {
|
|
17
|
+
parentFontSize?: number
|
|
18
|
+
parentLineHeight?: NativeTextMetrics['lineHeight']
|
|
19
|
+
animatedText?: AnimatedTextChannel | null
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// called after the winning font size and line height are known, on both native frontends.
|
|
23
|
+
export function resolveTextMetrics(
|
|
24
|
+
style: Record<string, unknown>,
|
|
25
|
+
lineHeight: unknown,
|
|
26
|
+
parent?: NativeTextContext,
|
|
27
|
+
isStatic = false,
|
|
28
|
+
apply = true
|
|
29
|
+
): NativeTextMetrics {
|
|
30
|
+
if (isVariable(lineHeight))
|
|
31
|
+
lineHeight = resolveVariableValue('lineHeight', lineHeight, 'value')
|
|
32
|
+
let fontSize =
|
|
33
|
+
typeof style.fontSize === 'number' ? style.fontSize : parent?.parentFontSize
|
|
34
|
+
const inheritsFontSize = style.fontSize == null && !!parent?.animatedText
|
|
35
|
+
if (apply && style.fontSize == null && fontSize !== undefined && !inheritsFontSize)
|
|
36
|
+
style.fontSize = fontSize
|
|
37
|
+
let leading: NativeTextMetrics['lineHeight']
|
|
38
|
+
if (lineHeight == null || lineHeight === 'inherit' || lineHeight === 'unset') {
|
|
39
|
+
leading = parent?.parentLineHeight
|
|
40
|
+
} else if (lineHeight === 'normal' || lineHeight === 'initial') {
|
|
41
|
+
leading = 'normal'
|
|
42
|
+
} else if (typeof lineHeight === 'number') {
|
|
43
|
+
leading = lineHeight
|
|
44
|
+
} else if (typeof lineHeight === 'string') {
|
|
45
|
+
if (/^(?:\d+\.?\d*|\.\d+)px$/.test(lineHeight)) {
|
|
46
|
+
leading = lineHeight as `${number}px`
|
|
47
|
+
} else if (lineHeight.trim() !== '' && Number.isFinite(+lineHeight)) {
|
|
48
|
+
leading = +lineHeight
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (typeof leading === 'number' && (!Number.isFinite(leading) || leading < 0)) {
|
|
53
|
+
delete style.lineHeight
|
|
54
|
+
return { fontSize, ...(inheritsFontSize && { inheritsFontSize }) }
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!apply)
|
|
58
|
+
return {
|
|
59
|
+
fontSize,
|
|
60
|
+
lineHeight: leading,
|
|
61
|
+
...(inheritsFontSize && { inheritsFontSize }),
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (typeof leading === 'number') {
|
|
65
|
+
if (fontSize === undefined && !isStatic && !inheritsFontSize) {
|
|
66
|
+
fontSize = 14
|
|
67
|
+
style.fontSize = fontSize
|
|
68
|
+
}
|
|
69
|
+
if (inheritsFontSize || fontSize === undefined) delete style.lineHeight
|
|
70
|
+
else style.lineHeight = fontSize * leading
|
|
71
|
+
} else if (leading && leading !== 'normal') {
|
|
72
|
+
style.lineHeight = Number.parseFloat(leading)
|
|
73
|
+
} else if (lineHeight != null || leading === 'normal') {
|
|
74
|
+
delete style.lineHeight
|
|
75
|
+
}
|
|
76
|
+
return { fontSize, lineHeight: leading, ...(inheritsFontSize && { inheritsFontSize }) }
|
|
77
|
+
}
|
|
@@ -2,10 +2,33 @@ import { normalizeCSSColor, rgba } from '@tamagui/normalize-css-color'
|
|
|
2
2
|
|
|
3
3
|
export { rgba } from '@tamagui/normalize-css-color'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// a theme value on native can be a DynamicColorIOS object rather than a string
|
|
6
|
+
type DynamicColor = { dynamic: Record<string, string> }
|
|
7
|
+
|
|
8
|
+
const isDynamicColor = (color: any): color is DynamicColor =>
|
|
9
|
+
typeof color.dynamic === 'object' && color.dynamic !== null
|
|
10
|
+
|
|
11
|
+
export const normalizeColor = (
|
|
12
|
+
color?: string | DynamicColor | null,
|
|
13
|
+
opacity?: number
|
|
14
|
+
) => {
|
|
6
15
|
if (!color) return
|
|
7
|
-
//
|
|
8
|
-
|
|
16
|
+
// DynamicColorIOS carries one color per appearance, so an opacity has to reach
|
|
17
|
+
// each variant. returning the object untouched is what made `$color/50` resolve
|
|
18
|
+
// to the fully opaque color on native.
|
|
19
|
+
//
|
|
20
|
+
// opacity 1 means "no override" here, not "make it opaque": the shadow call
|
|
21
|
+
// site in getSplitStyles defaults its opacity argument to 1, so applying it
|
|
22
|
+
// would drop a shadow token's own alpha and paint solid black.
|
|
23
|
+
if (typeof color !== 'string') {
|
|
24
|
+
if (opacity === undefined || opacity === 1 || !isDynamicColor(color)) return color
|
|
25
|
+
const dynamic: Record<string, string> = {}
|
|
26
|
+
for (const key in color.dynamic) {
|
|
27
|
+
const variant = normalizeColor(color.dynamic[key], opacity)
|
|
28
|
+
if (typeof variant === 'string') dynamic[key] = variant
|
|
29
|
+
}
|
|
30
|
+
return { ...color, dynamic }
|
|
31
|
+
}
|
|
9
32
|
|
|
10
33
|
const rgbaVal = getRgba(color)
|
|
11
34
|
if (rgbaVal) {
|
|
@@ -21,7 +44,9 @@ export const normalizeColor = (color?: string | null, opacity?: number) => {
|
|
|
21
44
|
export const getRgba = (color: string) => {
|
|
22
45
|
// handle dynamic color objects
|
|
23
46
|
if (typeof color !== 'string') return
|
|
24
|
-
|
|
47
|
+
// RN accepts the alpha forms with a slash, but requires the `a` function name.
|
|
48
|
+
const nativeColor = color.replace(/^(rgb|hsl)\((?=[^)]*\/)/, '$1a(')
|
|
49
|
+
const colorNum = normalizeCSSColor(nativeColor)
|
|
25
50
|
if (colorNum != null) {
|
|
26
51
|
return rgba(colorNum)
|
|
27
52
|
}
|
|
@@ -13,7 +13,7 @@ import { stylePropsAll, stylePropsUnitless } from '@tamagui/helpers'
|
|
|
13
13
|
// every lookup on this hot path a slow one
|
|
14
14
|
const unitfulProps = new Set(
|
|
15
15
|
[...Object.keys(stylePropsAll), 'translateX', 'translateY'].filter(
|
|
16
|
-
(key) => !stylePropsUnitless[key]
|
|
16
|
+
(key) => key !== 'lineHeight' && !stylePropsUnitless[key]
|
|
17
17
|
)
|
|
18
18
|
)
|
|
19
19
|
|
|
@@ -23,6 +23,7 @@ const pxStringRe = /^-?\d*\.?\d+px$/
|
|
|
23
23
|
|
|
24
24
|
export function normalizeValueWithProperty(value: any, property = ''): any {
|
|
25
25
|
if (!isWeb) {
|
|
26
|
+
if (property === 'lineHeight') return value
|
|
26
27
|
if (typeof value === 'string' && pxStringRe.test(value)) {
|
|
27
28
|
return Number.parseFloat(value)
|
|
28
29
|
}
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
* so this code is dead-code-eliminated on web builds.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import { normalizeColor } from './normalizeColor'
|
|
13
|
+
|
|
12
14
|
type TokenMap = Map<string, any>
|
|
13
15
|
|
|
14
16
|
export function parseNativeStyle(
|
|
@@ -32,7 +34,7 @@ function resolveColor(raw: string, tokenMap?: TokenMap): any {
|
|
|
32
34
|
if (tokenMap && tokenMap.has(raw)) {
|
|
33
35
|
return tokenMap.get(raw)
|
|
34
36
|
}
|
|
35
|
-
return raw
|
|
37
|
+
return raw.includes('(') && !raw.includes(',') ? normalizeColor(raw) : raw
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
// the direction grammar React Native itself accepts, sourced from
|
|
@@ -54,6 +56,11 @@ function gradientPosition(token: string): number | string | undefined {
|
|
|
54
56
|
|
|
55
57
|
// parse "linear-gradient(direction, color1 pos1, color2 pos2, ...)"
|
|
56
58
|
function parseBackgroundImage(css: string, tokenMap?: TokenMap): any[] | undefined {
|
|
59
|
+
// React Native represents `background-image: none` as an empty processed
|
|
60
|
+
// background list. Returning the list here also routes the Tailwind utility
|
|
61
|
+
// to RN's `experimental_backgroundImage` host key instead of leaking the web
|
|
62
|
+
// `backgroundImage` alias into native styles.
|
|
63
|
+
if (css.trim() === 'none') return []
|
|
57
64
|
const match = css.match(/^linear-gradient\((.+)\)$/s)
|
|
58
65
|
if (!match) return undefined
|
|
59
66
|
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { DedupedThemes, ThemeParsed } from '../types'
|
|
2
|
+
import { copyAuthoredThemeScheme } from './themes'
|
|
2
3
|
|
|
3
4
|
const themesRaw: Record<string, ThemeParsed> = {}
|
|
4
5
|
|
|
5
6
|
// this seems expensive but its necessary to do two loops unless we want to refactor a variety of things again
|
|
6
7
|
// not *too* much work but not a big cost doing the two loops
|
|
7
8
|
export function proxyThemesToParents(
|
|
8
|
-
dedupedThemes: DedupedThemes
|
|
9
|
+
dedupedThemes: DedupedThemes,
|
|
10
|
+
declarationOrder?: string[]
|
|
9
11
|
): Record<string, ThemeParsed> {
|
|
10
12
|
// fill it in so we can look it up next
|
|
11
13
|
for (const { names, theme } of dedupedThemes) {
|
|
@@ -27,6 +29,15 @@ export function proxyThemesToParents(
|
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
31
|
|
|
32
|
+
// dedupedThemes is sorted for deterministic CSS cascade, but TamaguiProvider
|
|
33
|
+
// falls back to Object.keys(themes)[0] — reorder to match config (#3764)
|
|
34
|
+
if (declarationOrder) {
|
|
35
|
+
const ordered: Record<string, ThemeParsed> = {}
|
|
36
|
+
for (const k of declarationOrder) if (k in themes) ordered[k] = themes[k]
|
|
37
|
+
for (const k in themes) if (!(k in ordered)) ordered[k] = themes[k]
|
|
38
|
+
return ordered
|
|
39
|
+
}
|
|
40
|
+
|
|
30
41
|
return themes
|
|
31
42
|
}
|
|
32
43
|
|
|
@@ -48,5 +59,5 @@ export function proxyThemeToParents(themeName: string, theme: ThemeParsed) {
|
|
|
48
59
|
Object.assign(out, themesRaw[parent])
|
|
49
60
|
}
|
|
50
61
|
Object.assign(out, theme)
|
|
51
|
-
return out
|
|
62
|
+
return copyAuthoredThemeScheme(out, theme)
|
|
52
63
|
}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { Dimensions, PixelRatio } from 'react-native'
|
|
2
|
+
|
|
3
|
+
export interface UnitContext {
|
|
4
|
+
windowWidth: number
|
|
5
|
+
windowHeight: number
|
|
6
|
+
fontScale: number
|
|
7
|
+
remBaseFontSize: number
|
|
8
|
+
containerWidth: number
|
|
9
|
+
containerHeight: number
|
|
10
|
+
elementFontSize: number
|
|
11
|
+
isFontSizeProp: boolean
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const UNIT_RE =
|
|
15
|
+
/^([+-]?\s*\d*\.?\d+)(px|rem|em|[dls]?vw|[dls]?vh|vmin|vmax|cqi|cqw|cqh|cqb)?$/i
|
|
16
|
+
|
|
17
|
+
export function isDynamicUnitValue(value: unknown): boolean {
|
|
18
|
+
if (typeof value !== 'string') return false
|
|
19
|
+
const trimmed = value.trim()
|
|
20
|
+
if (
|
|
21
|
+
trimmed.startsWith('clamp(') ||
|
|
22
|
+
trimmed.startsWith('CLAMP(') ||
|
|
23
|
+
trimmed.startsWith('calc(') ||
|
|
24
|
+
trimmed.startsWith('CALC(')
|
|
25
|
+
)
|
|
26
|
+
return true
|
|
27
|
+
// a unit suffix only counts when a number precedes it. matching the suffix
|
|
28
|
+
// alone turns every word ending in one into a length: 'System' ends in `em`
|
|
29
|
+
// and resolved to 0, wiping out fontFamily
|
|
30
|
+
return !!UNIT_RE.exec(trimmed.replace(/\s+/g, ''))?.[2]
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function getUnitContext(key: string, styleState?: any): UnitContext {
|
|
34
|
+
const window = Dimensions.get('window')
|
|
35
|
+
const fontScale =
|
|
36
|
+
typeof PixelRatio !== 'undefined' && PixelRatio.getFontScale
|
|
37
|
+
? PixelRatio.getFontScale()
|
|
38
|
+
: 1
|
|
39
|
+
const remBaseFontSize = styleState?.conf?.settings?.remBaseFontSize ?? 16
|
|
40
|
+
const isFontSizeProp = key === 'fontSize'
|
|
41
|
+
const elementFontSize =
|
|
42
|
+
typeof styleState?.style?.fontSize === 'number'
|
|
43
|
+
? styleState.style.fontSize
|
|
44
|
+
: remBaseFontSize
|
|
45
|
+
|
|
46
|
+
// Look up container layout from group context or component state
|
|
47
|
+
const groupContext = styleState?.flatGroupContext
|
|
48
|
+
const groupEntry = groupContext?.['@']
|
|
49
|
+
const groupLayout =
|
|
50
|
+
groupEntry?.state?.layout || styleState?.componentState?.group?.['@']?.layout
|
|
51
|
+
|
|
52
|
+
let containerWidth = groupLayout?.width
|
|
53
|
+
let containerHeight = groupLayout?.height
|
|
54
|
+
|
|
55
|
+
// First-frame seed if unmeasured
|
|
56
|
+
if (containerWidth === undefined || containerWidth === 0) {
|
|
57
|
+
const maxWidth =
|
|
58
|
+
typeof styleState?.style?.maxWidth === 'number'
|
|
59
|
+
? styleState.style.maxWidth
|
|
60
|
+
: undefined
|
|
61
|
+
containerWidth = Math.min(window.width, maxWidth ?? Infinity)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (containerHeight === undefined || containerHeight === 0) {
|
|
65
|
+
containerHeight = window.height
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
windowWidth: window.width,
|
|
70
|
+
windowHeight: window.height,
|
|
71
|
+
fontScale,
|
|
72
|
+
remBaseFontSize,
|
|
73
|
+
containerWidth,
|
|
74
|
+
containerHeight,
|
|
75
|
+
elementFontSize,
|
|
76
|
+
isFontSizeProp,
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function resolveSingleUnit(val: string, ctx: UnitContext): number {
|
|
81
|
+
const trimmed = val.replace(/\s+/g, '')
|
|
82
|
+
const match = UNIT_RE.exec(trimmed)
|
|
83
|
+
if (!match) return Number(trimmed) || 0
|
|
84
|
+
|
|
85
|
+
const num = Number.parseFloat(match[1])
|
|
86
|
+
if (Number.isNaN(num)) return 0
|
|
87
|
+
|
|
88
|
+
const unit = (match[2] || 'px').toLowerCase()
|
|
89
|
+
|
|
90
|
+
switch (unit) {
|
|
91
|
+
case 'px':
|
|
92
|
+
return num
|
|
93
|
+
case 'rem':
|
|
94
|
+
// Accessibility: layout props scale with OS fontScale; fontSize leaves scaling to RN Text
|
|
95
|
+
return num * ctx.remBaseFontSize * (ctx.isFontSizeProp ? 1 : ctx.fontScale)
|
|
96
|
+
case 'em':
|
|
97
|
+
return num * ctx.elementFontSize
|
|
98
|
+
// a native window has no collapsing browser chrome, so the dynamic, large
|
|
99
|
+
// and small viewports are all the window
|
|
100
|
+
case 'vw':
|
|
101
|
+
case 'dvw':
|
|
102
|
+
case 'lvw':
|
|
103
|
+
case 'svw':
|
|
104
|
+
return (num / 100) * ctx.windowWidth
|
|
105
|
+
case 'vh':
|
|
106
|
+
case 'dvh':
|
|
107
|
+
case 'lvh':
|
|
108
|
+
case 'svh':
|
|
109
|
+
return (num / 100) * ctx.windowHeight
|
|
110
|
+
case 'vmin':
|
|
111
|
+
return (num / 100) * Math.min(ctx.windowWidth, ctx.windowHeight)
|
|
112
|
+
case 'vmax':
|
|
113
|
+
return (num / 100) * Math.max(ctx.windowWidth, ctx.windowHeight)
|
|
114
|
+
case 'cqi':
|
|
115
|
+
case 'cqw':
|
|
116
|
+
return (num / 100) * ctx.containerWidth
|
|
117
|
+
case 'cqh':
|
|
118
|
+
case 'cqb':
|
|
119
|
+
return (num / 100) * ctx.containerHeight
|
|
120
|
+
default:
|
|
121
|
+
return num
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function evaluateCalc(expr: string, ctx: UnitContext): number {
|
|
126
|
+
let s = expr.trim()
|
|
127
|
+
if (s.toLowerCase().startsWith('calc(') && s.endsWith(')')) {
|
|
128
|
+
s = s.slice(5, -1).trim()
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const tokens = s.match(/[()*/+-]|[^\s()*/+-]+/g) || []
|
|
132
|
+
let pos = 0
|
|
133
|
+
const peek = () => tokens[pos]
|
|
134
|
+
const consume = () => tokens[pos++]
|
|
135
|
+
|
|
136
|
+
function parseExpression(): number {
|
|
137
|
+
let left = parseTerm()
|
|
138
|
+
while (peek() === '+' || peek() === '-') {
|
|
139
|
+
const op = consume()
|
|
140
|
+
const right = parseTerm()
|
|
141
|
+
if (op === '+') left += right
|
|
142
|
+
else left -= right
|
|
143
|
+
}
|
|
144
|
+
return left
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function parseTerm(): number {
|
|
148
|
+
let left = parseFactor()
|
|
149
|
+
while (peek() === '*' || peek() === '/') {
|
|
150
|
+
const op = consume()
|
|
151
|
+
const right = parseFactor()
|
|
152
|
+
if (op === '*') left *= right
|
|
153
|
+
else left = right !== 0 ? left / right : 0
|
|
154
|
+
}
|
|
155
|
+
return left
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function parseFactor(): number {
|
|
159
|
+
if (peek() === '+') {
|
|
160
|
+
consume()
|
|
161
|
+
return parseFactor()
|
|
162
|
+
}
|
|
163
|
+
if (peek() === '-') {
|
|
164
|
+
consume()
|
|
165
|
+
return -parseFactor()
|
|
166
|
+
}
|
|
167
|
+
return parsePrimary()
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function parsePrimary(): number {
|
|
171
|
+
if (peek() === '(') {
|
|
172
|
+
consume()
|
|
173
|
+
const val = parseExpression()
|
|
174
|
+
if (peek() === ')') consume()
|
|
175
|
+
return val
|
|
176
|
+
}
|
|
177
|
+
const token = consume()
|
|
178
|
+
return token ? resolveSingleUnit(token, ctx) : 0
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return parseExpression()
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export function resolveClamp(val: string, ctx: UnitContext): number {
|
|
185
|
+
// Extract content between first '(' and last ')'
|
|
186
|
+
const start = val.indexOf('(')
|
|
187
|
+
const end = val.lastIndexOf(')')
|
|
188
|
+
if (start === -1 || end === -1 || end <= start) return 0
|
|
189
|
+
|
|
190
|
+
let inner = val.slice(start + 1, end).trim()
|
|
191
|
+
const args = splitClampArgs(inner)
|
|
192
|
+
if (args.length < 3) return 0
|
|
193
|
+
|
|
194
|
+
const min = resolveSingleUnit(args[0], ctx)
|
|
195
|
+
const max = resolveSingleUnit(args[2], ctx)
|
|
196
|
+
const pref = evaluateCalc(args[1], ctx)
|
|
197
|
+
|
|
198
|
+
const lower = Math.min(min, max)
|
|
199
|
+
const upper = Math.max(min, max)
|
|
200
|
+
return Math.min(Math.max(pref, lower), upper)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function splitClampArgs(inner: string): string[] {
|
|
204
|
+
const parts: string[] = []
|
|
205
|
+
let depth = 0
|
|
206
|
+
let current = ''
|
|
207
|
+
|
|
208
|
+
for (let i = 0; i < inner.length; i++) {
|
|
209
|
+
const char = inner[i]
|
|
210
|
+
if (char === '(') depth++
|
|
211
|
+
else if (char === ')') depth--
|
|
212
|
+
|
|
213
|
+
if (char === ',' && depth === 0) {
|
|
214
|
+
parts.push(current.trim())
|
|
215
|
+
current = ''
|
|
216
|
+
} else {
|
|
217
|
+
current += char
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (current.trim()) {
|
|
222
|
+
parts.push(current.trim())
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return parts
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export function resolveNativeUnits(key: string, value: any, styleState?: any): any {
|
|
229
|
+
if (typeof value !== 'string') return value
|
|
230
|
+
|
|
231
|
+
const trimmed = value.trim()
|
|
232
|
+
if (!isDynamicUnitValue(trimmed)) {
|
|
233
|
+
return value
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const ctx = getUnitContext(key, styleState)
|
|
237
|
+
|
|
238
|
+
if (trimmed.startsWith('clamp(') || trimmed.startsWith('CLAMP(')) {
|
|
239
|
+
return resolveClamp(trimmed, ctx)
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if (trimmed.startsWith('calc(') || trimmed.startsWith('CALC(')) {
|
|
243
|
+
return evaluateCalc(trimmed, ctx)
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return resolveSingleUnit(trimmed, ctx)
|
|
247
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web pass-through: browsers resolve clamp(), cqi, vw, and rem natively.
|
|
3
|
+
*/
|
|
4
|
+
export function resolveNativeUnits(_key: string, value: any, _styleState?: any): any {
|
|
5
|
+
return value
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function isDynamicUnitValue(_value: unknown): boolean {
|
|
9
|
+
return false
|
|
10
|
+
}
|
|
@@ -1,44 +1,43 @@
|
|
|
1
1
|
import { PixelRatio } from 'react-native'
|
|
2
2
|
import { getConfig } from '../config'
|
|
3
3
|
|
|
4
|
-
const remRegex =
|
|
4
|
+
const remRegex = /^-?(\d*\.?\d+)rem$/i
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Resolves rem values to pixel values on native platforms.
|
|
8
|
-
* Uses PixelRatio.getFontScale()
|
|
8
|
+
* Uses PixelRatio.getFontScale() for layout props (margin, padding, radius).
|
|
9
|
+
* For fontSize, leaves OS scaling to React Native Text component to avoid double-scaling.
|
|
9
10
|
*
|
|
10
|
-
* @param value - A string value
|
|
11
|
+
* @param value - A string value containing rem units (e.g. "1.5rem")
|
|
12
|
+
* @param isFontSize - Whether the target property is fontSize
|
|
11
13
|
* @returns The numeric pixel value
|
|
12
14
|
*/
|
|
13
|
-
export function resolveRem(value: string): number {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const numericValue = Number.parseFloat(value)
|
|
20
|
-
if (!Number.isNaN(numericValue)) {
|
|
21
|
-
return PixelRatio.getFontScale() * baseFontSize * numericValue
|
|
15
|
+
export function resolveRem(value: string, isFontSize = false): number {
|
|
16
|
+
let baseFontSize = 16
|
|
17
|
+
try {
|
|
18
|
+
const config = getConfig()
|
|
19
|
+
if (config?.settings?.remBaseFontSize) {
|
|
20
|
+
baseFontSize = config.settings.remBaseFontSize
|
|
22
21
|
}
|
|
23
|
-
}
|
|
22
|
+
} catch {}
|
|
23
|
+
const trimmed = value.trim()
|
|
24
|
+
const match = remRegex.exec(trimmed)
|
|
25
|
+
if (!match) return 0
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
let match: RegExpExecArray | null
|
|
28
|
-
while ((match = remRegex.exec(value)) !== null) {
|
|
29
|
-
const numericValue = Number.parseFloat(match[1])
|
|
30
|
-
if (!Number.isNaN(numericValue)) {
|
|
31
|
-
result += PixelRatio.getFontScale() * baseFontSize * numericValue
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
remRegex.lastIndex = 0 // Reset regex state
|
|
27
|
+
const numericValue = Number.parseFloat(match[1])
|
|
28
|
+
if (Number.isNaN(numericValue)) return 0
|
|
35
29
|
|
|
36
|
-
|
|
30
|
+
const scale =
|
|
31
|
+
isFontSize || typeof PixelRatio === 'undefined' || !PixelRatio.getFontScale
|
|
32
|
+
? 1
|
|
33
|
+
: PixelRatio.getFontScale()
|
|
34
|
+
const sign = trimmed.startsWith('-') ? -1 : 1
|
|
35
|
+
return sign * numericValue * baseFontSize * scale
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
/**
|
|
40
|
-
* Checks if a value is a rem string
|
|
39
|
+
* Checks if a value is a strict rem string (e.g. "1.5rem", "-0.5rem")
|
|
41
40
|
*/
|
|
42
41
|
export function isRemValue(value: unknown): value is string {
|
|
43
|
-
return typeof value === 'string' && value.
|
|
42
|
+
return typeof value === 'string' && remRegex.test(value.trim())
|
|
44
43
|
}
|