@tamagui/web 3.0.0-beta.924.1 → 3.0.1
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
package/src/hooks/useMedia.tsx
CHANGED
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
} from '../helpers/mediaState'
|
|
15
15
|
export { mediaKeyMatch } from '../helpers/mediaState'
|
|
16
16
|
import type {
|
|
17
|
-
ComponentContextI,
|
|
18
17
|
DebugProp,
|
|
19
18
|
MediaQueryState,
|
|
20
19
|
TamaguiInternalConfig,
|
|
@@ -171,6 +170,10 @@ type MediaState = {
|
|
|
171
170
|
// for any earlier-rendered media-dependent sibling.
|
|
172
171
|
const States = new WeakMap<any, MediaState>()
|
|
173
172
|
|
|
173
|
+
// the same per-instance rule holds for the emitter: createComponent passes its
|
|
174
|
+
// stateRef.current, so a media change restyles that component alone
|
|
175
|
+
type MediaEmitter = { mediaEmit?: (state: UseMediaState) => void }
|
|
176
|
+
|
|
174
177
|
// shared "touch tracker" prototype: one object whose enumerable getter
|
|
175
178
|
// properties are pre-defined for every configured media key. Hermes inlines
|
|
176
179
|
// getter calls; the old `new Proxy(state, { get })` path forced an interpreted
|
|
@@ -247,8 +250,8 @@ type MediaRef = {
|
|
|
247
250
|
// by mutating `proxyTarget` and re-reading it in the get trap.
|
|
248
251
|
proxyTarget: MediaQueryState
|
|
249
252
|
proxy: UseMediaState
|
|
250
|
-
getSnapshot: () => MediaQueryState
|
|
251
|
-
|
|
253
|
+
getSnapshot: (inRender?: boolean) => MediaQueryState
|
|
254
|
+
emitter?: MediaEmitter
|
|
252
255
|
uid?: object
|
|
253
256
|
debug?: DebugProp
|
|
254
257
|
optimizeForFirstRender: boolean
|
|
@@ -318,7 +321,7 @@ function sameMediaKeys(a: Set<string> | null, b: Set<string> | null) {
|
|
|
318
321
|
}
|
|
319
322
|
|
|
320
323
|
export function useMedia(
|
|
321
|
-
|
|
324
|
+
emitter?: MediaEmitter,
|
|
322
325
|
debug?: DebugProp,
|
|
323
326
|
// per-component-instance key for the States map (createComponent passes
|
|
324
327
|
// stateRef.current, matching its setMediaShouldUpdate call)
|
|
@@ -345,7 +348,7 @@ export function useMedia(
|
|
|
345
348
|
proxyTarget: initial,
|
|
346
349
|
proxy: undefined as unknown as UseMediaState,
|
|
347
350
|
getSnapshot: undefined as unknown as () => MediaQueryState,
|
|
348
|
-
|
|
351
|
+
emitter,
|
|
349
352
|
uid,
|
|
350
353
|
debug,
|
|
351
354
|
optimizeForFirstRender,
|
|
@@ -362,56 +365,42 @@ export function useMedia(
|
|
|
362
365
|
} as MediaRefSlot
|
|
363
366
|
r.proxy = tracker as UseMediaState
|
|
364
367
|
}
|
|
365
|
-
r.getSnapshot = () => {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
if (ms === r.lastState) {
|
|
369
|
-
return r.lastState
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
if (r.componentContext?.mediaEmit) {
|
|
373
|
-
r.componentContext.mediaEmit(ms)
|
|
374
|
-
r.pendingState = ms
|
|
375
|
-
return r.lastState
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
r.lastState = ms
|
|
379
|
-
return ms
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
const curKeys = mediaListenKeys(r)!
|
|
383
|
-
const { lastState, pendingState } = r
|
|
384
|
-
|
|
385
|
-
if (!curKeys.size) {
|
|
386
|
-
return lastState
|
|
387
|
-
}
|
|
388
|
-
|
|
368
|
+
r.getSnapshot = (inRender) => {
|
|
369
|
+
const { lastState } = r
|
|
370
|
+
const curKeys = mediaListenKeys(r)
|
|
389
371
|
const ms = getMedia()
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
372
|
+
if (curKeys) {
|
|
373
|
+
let changed = false
|
|
374
|
+
for (const key of curKeys) {
|
|
375
|
+
if (ms[key] !== (r.pendingState || lastState)[key]) {
|
|
376
|
+
if (process.env.NODE_ENV === 'development' && r.debug) {
|
|
377
|
+
console.warn(`useMedia() ✍️`, key, lastState[key], '=>', ms[key])
|
|
378
|
+
}
|
|
379
|
+
changed = true
|
|
380
|
+
break
|
|
394
381
|
}
|
|
395
|
-
|
|
396
|
-
// in emitter mode (no-rerender) avoid changing state, instead emit
|
|
397
|
-
if (r.componentContext?.mediaEmit) {
|
|
398
|
-
r.componentContext.mediaEmit(ms)
|
|
399
|
-
r.pendingState = ms
|
|
400
|
-
return lastState
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
r.lastState = ms
|
|
404
|
-
|
|
405
|
-
return ms
|
|
406
382
|
}
|
|
383
|
+
if (!changed) return lastState
|
|
384
|
+
} else if (ms === lastState) {
|
|
385
|
+
return lastState
|
|
407
386
|
}
|
|
408
387
|
|
|
409
|
-
|
|
388
|
+
// render-time emits update siblings through setState, so defer those
|
|
389
|
+
// until render finishes; effect and subscription emits stay synchronous.
|
|
390
|
+
const mediaEmit = r.emitter?.mediaEmit
|
|
391
|
+
if (mediaEmit) {
|
|
392
|
+
if (inRender) queueMicrotask(() => mediaEmit(ms))
|
|
393
|
+
else mediaEmit(ms)
|
|
394
|
+
r.pendingState = ms
|
|
395
|
+
return lastState
|
|
396
|
+
}
|
|
397
|
+
r.lastState = ms
|
|
398
|
+
return ms
|
|
410
399
|
}
|
|
411
400
|
internalRef.current = r
|
|
412
401
|
} else {
|
|
413
402
|
// refresh per-render inputs the closures read through the ref
|
|
414
|
-
internalRef.current.
|
|
403
|
+
internalRef.current.emitter = emitter
|
|
415
404
|
internalRef.current.uid = uid
|
|
416
405
|
internalRef.current.debug = debug
|
|
417
406
|
}
|
|
@@ -440,7 +429,7 @@ export function useMedia(
|
|
|
440
429
|
? initState
|
|
441
430
|
: ref.optimizeForFirstRender && ref.renderVersion === 1
|
|
442
431
|
? ref.lastState
|
|
443
|
-
: ref.getSnapshot()
|
|
432
|
+
: ref.getSnapshot(true)
|
|
444
433
|
ref.proxyTarget = state
|
|
445
434
|
if (!ref.optimizeForFirstRender) {
|
|
446
435
|
;(ref.proxy as any)[refSlot].proxyTarget = state
|
|
@@ -29,7 +29,10 @@ export const useSplitStyles: StyleSplitter = (
|
|
|
29
29
|
|
|
30
30
|
const res = getSplitStyles(a, b, c, d, e, f, g, h, i, j, k, l, m, n)
|
|
31
31
|
|
|
32
|
-
if (
|
|
32
|
+
if (
|
|
33
|
+
process.env.TAMAGUI_RUNTIME !== 'island' &&
|
|
34
|
+
process.env.TAMAGUI_TARGET !== 'native'
|
|
35
|
+
) {
|
|
33
36
|
useInsertEffectCompat(() => {
|
|
34
37
|
if (res) {
|
|
35
38
|
insertStyleRules(res.rulesToInsert)
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
useRef,
|
|
9
9
|
type MutableRefObject,
|
|
10
10
|
} from 'react'
|
|
11
|
+
import { getThemeScheme as getScheme } from '@tamagui/helpers'
|
|
11
12
|
import { getConfig, getSetting } from '../config'
|
|
12
13
|
import { MISSING_THEME_MESSAGE } from '../constants/constants'
|
|
13
14
|
import type {
|
|
@@ -17,6 +18,7 @@ import type {
|
|
|
17
18
|
UseThemeWithStateProps,
|
|
18
19
|
} from '../types'
|
|
19
20
|
import type { ThemeUpdateState } from '../helpers/themeUpdateState'
|
|
21
|
+
import { getAuthoredThemeScheme } from '../helpers/themes'
|
|
20
22
|
|
|
21
23
|
type ID = string
|
|
22
24
|
|
|
@@ -29,7 +31,6 @@ const HadTheme = new WeakMap<object, boolean>()
|
|
|
29
31
|
const PendingUpdate = new Map<any, boolean | 'force'>()
|
|
30
32
|
|
|
31
33
|
const states: Map<ID, ThemeState | undefined> = new Map()
|
|
32
|
-
const localStates: Map<ID, ThemeState | undefined> = new Map()
|
|
33
34
|
|
|
34
35
|
let shouldForce = false
|
|
35
36
|
export const forceUpdateThemes = () => {
|
|
@@ -110,7 +111,7 @@ export const useThemeState = (
|
|
|
110
111
|
}
|
|
111
112
|
|
|
112
113
|
const id = useId()
|
|
113
|
-
const propsKey =
|
|
114
|
+
const propsKey = `${props.name || ''}${props.forceClassName || ''}${props._themeUpdate?.key || ''}`
|
|
114
115
|
|
|
115
116
|
if (cascadeOnChange) {
|
|
116
117
|
registerThemeProviderChain(id, parentId, props)
|
|
@@ -119,20 +120,14 @@ export const useThemeState = (
|
|
|
119
120
|
const ref = useRef<ThemeStateRef>(null as any)
|
|
120
121
|
const r = (ref.current ||= {
|
|
121
122
|
id,
|
|
122
|
-
parentId,
|
|
123
|
-
props,
|
|
124
|
-
propsKey,
|
|
125
|
-
isRoot,
|
|
126
|
-
keys,
|
|
127
|
-
schemeKeys,
|
|
128
123
|
optimizeForFirstRender,
|
|
129
124
|
renderVersion: 0,
|
|
130
|
-
})
|
|
125
|
+
} as ThemeStateRef)
|
|
131
126
|
r.props = props
|
|
132
127
|
r.propsKey = propsKey
|
|
133
128
|
r.isRoot = isRoot
|
|
134
129
|
r.keys = keys
|
|
135
|
-
r.schemeKeys = schemeKeys
|
|
130
|
+
if (process.env.TAMAGUI_TARGET === 'native') r.schemeKeys = schemeKeys
|
|
136
131
|
r.parentId = parentId
|
|
137
132
|
r.renderVersion++
|
|
138
133
|
|
|
@@ -145,15 +140,15 @@ export const useThemeState = (
|
|
|
145
140
|
|
|
146
141
|
if (r.lastSnap && !states.has(r.id)) {
|
|
147
142
|
states.set(r.id, r.lastSnap)
|
|
148
|
-
|
|
143
|
+
r.state = r.lastSnap
|
|
149
144
|
}
|
|
150
145
|
|
|
151
146
|
if (cascadeOnChange && !themeProviderParents.has(r.id)) {
|
|
152
147
|
registerThemeProviderChain(r.id, r.parentId, r.props)
|
|
153
148
|
}
|
|
154
149
|
|
|
155
|
-
if (r.unsubscribe && r.
|
|
156
|
-
|
|
150
|
+
if (r.unsubscribe && r.subscribedTo !== r.parentId) {
|
|
151
|
+
r.unsubscribe?.()
|
|
157
152
|
}
|
|
158
153
|
|
|
159
154
|
if (shouldSubscribeToTheme(r, cascadeOnChange)) {
|
|
@@ -177,19 +172,19 @@ export const useThemeState = (
|
|
|
177
172
|
PendingUpdate.set(sid, forced ? 'force' : true)
|
|
178
173
|
cb(forced)
|
|
179
174
|
})
|
|
180
|
-
r.
|
|
175
|
+
r.subscribedTo = pid
|
|
181
176
|
r.unsubscribe = () => {
|
|
182
177
|
allListeners.delete(sid)
|
|
183
178
|
listenersByParent[pid]?.delete(sid)
|
|
184
|
-
|
|
179
|
+
r.state = undefined
|
|
185
180
|
states.delete(sid)
|
|
186
181
|
PendingUpdate.delete(sid)
|
|
187
182
|
r.unsubscribe = undefined
|
|
188
|
-
r.
|
|
183
|
+
r.subscribedTo = undefined
|
|
189
184
|
}
|
|
190
185
|
}
|
|
191
186
|
} else if (r.unsubscribe) {
|
|
192
|
-
|
|
187
|
+
r.unsubscribe?.()
|
|
193
188
|
}
|
|
194
189
|
|
|
195
190
|
return () => {
|
|
@@ -222,6 +217,7 @@ export const useThemeState = (
|
|
|
222
217
|
}
|
|
223
218
|
|
|
224
219
|
type SnapshotRef = {
|
|
220
|
+
state?: ThemeState
|
|
225
221
|
id: string
|
|
226
222
|
parentId: string
|
|
227
223
|
props: UseThemeWithStateProps
|
|
@@ -235,7 +231,7 @@ type SnapshotRef = {
|
|
|
235
231
|
type ThemeStateRef = SnapshotRef & {
|
|
236
232
|
renderVersion: number
|
|
237
233
|
unsubscribe?: () => void
|
|
238
|
-
|
|
234
|
+
subscribedTo?: string
|
|
239
235
|
lastSnap?: ThemeState
|
|
240
236
|
}
|
|
241
237
|
|
|
@@ -249,15 +245,11 @@ const shouldSubscribeToTheme = (r: ThemeStateRef, cascadeOnChange: boolean): boo
|
|
|
249
245
|
r.props.needsUpdate?.()
|
|
250
246
|
)
|
|
251
247
|
|
|
252
|
-
function cleanupThemeSubscription(r: ThemeStateRef) {
|
|
253
|
-
r.unsubscribe?.()
|
|
254
|
-
}
|
|
255
|
-
|
|
256
248
|
function cleanupThemeState(r: ThemeStateRef) {
|
|
257
249
|
if (r.unsubscribe) {
|
|
258
|
-
|
|
250
|
+
r.unsubscribe()
|
|
259
251
|
} else {
|
|
260
|
-
|
|
252
|
+
r.state = undefined
|
|
261
253
|
states.delete(r.id)
|
|
262
254
|
PendingUpdate.delete(r.id)
|
|
263
255
|
}
|
|
@@ -266,23 +258,17 @@ function cleanupThemeState(r: ThemeStateRef) {
|
|
|
266
258
|
}
|
|
267
259
|
|
|
268
260
|
const getSnapshotImpl = (r: SnapshotRef): ThemeState => {
|
|
269
|
-
const {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
propsKey,
|
|
274
|
-
isRoot,
|
|
275
|
-
keys,
|
|
276
|
-
schemeKeys,
|
|
277
|
-
optimizeForFirstRender,
|
|
278
|
-
} = r
|
|
279
|
-
let local = localStates.get(id)
|
|
261
|
+
const { id, parentId, props, propsKey, isRoot, keys, optimizeForFirstRender } = r
|
|
262
|
+
const schemeKeys = process.env.TAMAGUI_TARGET === 'native' ? r.schemeKeys : undefined
|
|
263
|
+
// useId values repeat across server renders; each hook owns its snapshot.
|
|
264
|
+
let local = r.state
|
|
280
265
|
const parentState = states.get(parentId)
|
|
281
266
|
|
|
282
267
|
if (local && !PendingUpdate.has(id)) {
|
|
283
268
|
if (
|
|
284
269
|
parentState &&
|
|
285
270
|
(local as any)._parentName === parentState.name &&
|
|
271
|
+
(local as any)._parentSchemeAuthored === parentState.schemeAuthored &&
|
|
286
272
|
(local as any)._propsKey === propsKey
|
|
287
273
|
) {
|
|
288
274
|
return local
|
|
@@ -299,17 +285,23 @@ const getSnapshotImpl = (r: SnapshotRef): ThemeState => {
|
|
|
299
285
|
local.scheme !== parentState.scheme &&
|
|
300
286
|
getThemeBaseName(local.name) === getThemeBaseName(parentState.name)
|
|
301
287
|
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
288
|
+
const canSkipForSchemeChange = Boolean(
|
|
289
|
+
isSchemeOnlyChange &&
|
|
290
|
+
keys.current?.size &&
|
|
291
|
+
schemeKeys?.current?.size === keys.current.size
|
|
292
|
+
)
|
|
307
293
|
|
|
294
|
+
// forceClassName renders its resolved name as classes, so a nameless one that
|
|
295
|
+
// mirrors its parent still has to re-render when the parent's scheme flips
|
|
308
296
|
const needsUpdate = props.passThrough
|
|
309
297
|
? false
|
|
310
298
|
: optimizeForFirstRender
|
|
311
299
|
? true
|
|
312
|
-
: isRoot ||
|
|
300
|
+
: isRoot ||
|
|
301
|
+
props.forceClassName ||
|
|
302
|
+
props.name === 'light' ||
|
|
303
|
+
props.name === 'dark' ||
|
|
304
|
+
props.name === null
|
|
313
305
|
? true
|
|
314
306
|
: !HasRenderedOnce.get(keys)
|
|
315
307
|
? true
|
|
@@ -343,7 +335,7 @@ const getSnapshotImpl = (r: SnapshotRef): ThemeState => {
|
|
|
343
335
|
|
|
344
336
|
if (!local || rerender) {
|
|
345
337
|
local = { ...next }
|
|
346
|
-
|
|
338
|
+
r.state = local
|
|
347
339
|
}
|
|
348
340
|
|
|
349
341
|
if (next !== local) {
|
|
@@ -351,6 +343,8 @@ const getSnapshotImpl = (r: SnapshotRef): ThemeState => {
|
|
|
351
343
|
local.id = id
|
|
352
344
|
}
|
|
353
345
|
;(local as any)._parentName = parentState?.name
|
|
346
|
+
// scheme intent can change while the resolved name stays the same.
|
|
347
|
+
;(local as any)._parentSchemeAuthored = parentState?.schemeAuthored
|
|
354
348
|
;(local as any)._propsKey = propsKey
|
|
355
349
|
states.set(id, next)
|
|
356
350
|
|
|
@@ -369,8 +363,10 @@ const getNextState = (
|
|
|
369
363
|
): [boolean, ThemeState] => {
|
|
370
364
|
const parentState = states.get(parentId)
|
|
371
365
|
|
|
366
|
+
// passThrough adds no theme of its own, so it mirrors the parent's current
|
|
367
|
+
// state. preferring lastState froze it, and every descendant, on its first theme
|
|
372
368
|
if (props.passThrough) {
|
|
373
|
-
return [false,
|
|
369
|
+
return [false, parentState || lastState || ({ name: '' } as any)]
|
|
374
370
|
}
|
|
375
371
|
|
|
376
372
|
themes ||= getConfig().themes
|
|
@@ -383,20 +379,39 @@ const getNextState = (
|
|
|
383
379
|
props,
|
|
384
380
|
pendingUpdate === 'force' ? true : !!needsUpdate
|
|
385
381
|
)
|
|
386
|
-
|
|
382
|
+
// explicit schemes pin even when resolution reuses the parent's theme name.
|
|
383
|
+
const authoredName = props.name
|
|
384
|
+
const parentSchemeAuthored = !!parentState?.schemeAuthored
|
|
385
|
+
const schemeAuthored = isRoot
|
|
386
|
+
? !!props.forceClassName
|
|
387
|
+
: parentSchemeAuthored ||
|
|
388
|
+
!!(authoredName && getScheme(authoredName) && authoredName in themes)
|
|
389
|
+
const intentChanged = schemeAuthored !== parentSchemeAuthored
|
|
390
|
+
const resolvedName = name || parentState?.name
|
|
391
|
+
const sameAsLast =
|
|
392
|
+
lastState &&
|
|
393
|
+
lastState.name === resolvedName &&
|
|
394
|
+
!!lastState.schemeAuthored === schemeAuthored
|
|
395
|
+
|
|
396
|
+
const isSameAsParent = Boolean(
|
|
397
|
+
parentState && resolvedName === parentState.name && !intentChanged
|
|
398
|
+
)
|
|
387
399
|
const shouldRerender = Boolean(
|
|
388
400
|
pendingUpdate === 'force' ||
|
|
389
|
-
(needsUpdate &&
|
|
401
|
+
(needsUpdate &&
|
|
402
|
+
(pendingUpdate ||
|
|
403
|
+
lastState?.name !== parentState?.name ||
|
|
404
|
+
!!lastState?.schemeAuthored !== schemeAuthored))
|
|
390
405
|
)
|
|
391
406
|
|
|
392
407
|
if (isSameAsParent) {
|
|
393
|
-
if (!shouldRerender &&
|
|
408
|
+
if (!shouldRerender && sameAsLast) {
|
|
394
409
|
return [false, lastState]
|
|
395
410
|
}
|
|
396
411
|
return [shouldRerender, { ...parentState!, isNew: false }]
|
|
397
412
|
}
|
|
398
413
|
|
|
399
|
-
if (!
|
|
414
|
+
if (!resolvedName) {
|
|
400
415
|
const next = lastState ??
|
|
401
416
|
parentState ??
|
|
402
417
|
rootThemeState ?? {
|
|
@@ -412,20 +427,22 @@ const getNextState = (
|
|
|
412
427
|
return [false, next]
|
|
413
428
|
}
|
|
414
429
|
|
|
415
|
-
|
|
430
|
+
// a same-name pin still introduces its own scope.
|
|
431
|
+
const scheme = getAuthoredThemeScheme(themes[resolvedName]) || getScheme(resolvedName)
|
|
416
432
|
const parentInverses = parentState?.inverses ?? 0
|
|
417
433
|
const isInverse = Boolean(parentState && scheme !== parentState.scheme)
|
|
418
434
|
const inverses = parentInverses + (isInverse ? 1 : 0)
|
|
419
435
|
|
|
420
436
|
const nextState: ThemeState = {
|
|
421
437
|
id,
|
|
422
|
-
name,
|
|
423
|
-
theme: themes[
|
|
438
|
+
name: resolvedName,
|
|
439
|
+
theme: themes[resolvedName],
|
|
424
440
|
scheme,
|
|
425
441
|
parentId,
|
|
426
442
|
parentName: parentState?.name,
|
|
427
443
|
inverses,
|
|
428
444
|
isInverse,
|
|
445
|
+
schemeAuthored,
|
|
429
446
|
isNew: true,
|
|
430
447
|
}
|
|
431
448
|
|
|
@@ -433,17 +450,7 @@ const getNextState = (
|
|
|
433
450
|
rootThemeState = nextState
|
|
434
451
|
}
|
|
435
452
|
|
|
436
|
-
|
|
437
|
-
return [false, nextState]
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
const shouldAvoidRerender =
|
|
441
|
-
pendingUpdate !== 'force' &&
|
|
442
|
-
lastState &&
|
|
443
|
-
!needsUpdate &&
|
|
444
|
-
nextState.name === lastState.name
|
|
445
|
-
|
|
446
|
-
return [!shouldAvoidRerender, nextState]
|
|
453
|
+
return [pendingUpdate === 'force' || !sameAsLast, nextState]
|
|
447
454
|
}
|
|
448
455
|
|
|
449
456
|
function scheduleUpdate(id: string) {
|
|
@@ -468,15 +475,6 @@ function scheduleUpdate(id: string) {
|
|
|
468
475
|
})
|
|
469
476
|
}
|
|
470
477
|
|
|
471
|
-
const validSchemes = {
|
|
472
|
-
light: 'light',
|
|
473
|
-
dark: 'dark',
|
|
474
|
-
} as const
|
|
475
|
-
|
|
476
|
-
function getScheme(name: string) {
|
|
477
|
-
return validSchemes[name.split('_')[0]]
|
|
478
|
-
}
|
|
479
|
-
|
|
480
478
|
export function getNewThemeName(
|
|
481
479
|
parentName = '',
|
|
482
480
|
props: UseThemeWithStateProps,
|
|
@@ -534,15 +532,12 @@ export function resolveThemeName(
|
|
|
534
532
|
}
|
|
535
533
|
}
|
|
536
534
|
|
|
537
|
-
if (!forceUpdate && found === parentName &&
|
|
535
|
+
if (!forceUpdate && found === parentName && found !== 'light' && found !== 'dark') {
|
|
538
536
|
return null
|
|
539
537
|
}
|
|
540
538
|
|
|
541
539
|
return found
|
|
542
540
|
}
|
|
543
541
|
|
|
544
|
-
const getPropsKey = ({ name, forceClassName, _themeUpdate }: UseThemeWithStateProps) =>
|
|
545
|
-
`${name || ''}${forceClassName || ''}${_themeUpdate?.key || ''}`
|
|
546
|
-
|
|
547
542
|
export const hasThemeUpdatingProps = (props: UseThemeWithStateProps) =>
|
|
548
543
|
'name' in props || 'forceClassName' in props || '_themeUpdate' in props
|
package/src/index.ts
CHANGED
|
@@ -50,10 +50,18 @@ export {
|
|
|
50
50
|
} from './helpers/splitStyleProps'
|
|
51
51
|
export { normalizeColor } from './helpers/normalizeColor'
|
|
52
52
|
export { normalizeStyle } from './helpers/normalizeStyle'
|
|
53
|
+
export { resolveTextMetrics } from './helpers/nativeTextMetrics'
|
|
54
|
+
export {
|
|
55
|
+
defaultSizing,
|
|
56
|
+
resolveSizing,
|
|
57
|
+
type ResolvedSizing,
|
|
58
|
+
type SizingEnv,
|
|
59
|
+
} from './helpers/resolveSizing'
|
|
53
60
|
export { containsThemeRef, themeRefKey } from './helpers/themeRef'
|
|
54
61
|
export { getStyleTags } from './helpers/wrapStyleTags'
|
|
55
62
|
|
|
56
63
|
export { createFont } from './createFont'
|
|
64
|
+
export { fluid, type FluidOptions } from './helpers/fluid'
|
|
57
65
|
export {
|
|
58
66
|
createChangeEventDetails,
|
|
59
67
|
type TamaguiChangeEventDetails,
|
|
@@ -86,12 +94,15 @@ export type {
|
|
|
86
94
|
AnimationDriver,
|
|
87
95
|
AnimationDriverStub,
|
|
88
96
|
AnimationDriverWithAnimatedNumbers,
|
|
97
|
+
AnimatedTextChannel,
|
|
98
|
+
NativeTextMetrics,
|
|
89
99
|
AnimationsConfig,
|
|
90
100
|
BorderValue,
|
|
91
101
|
BoxShadowValue,
|
|
92
102
|
Color,
|
|
93
103
|
ColorScheme,
|
|
94
104
|
ColorTokens,
|
|
105
|
+
ComponentSize,
|
|
95
106
|
CreateTamaguiConfig,
|
|
96
107
|
CreateTamaguiProps,
|
|
97
108
|
DebugProp,
|
|
@@ -113,6 +124,7 @@ export type {
|
|
|
113
124
|
FontWeightTokens,
|
|
114
125
|
Fonts,
|
|
115
126
|
GenericFont,
|
|
127
|
+
GenericSizing,
|
|
116
128
|
GenericStackVariants,
|
|
117
129
|
GenericTamaguiConfig,
|
|
118
130
|
GenericTextVariants,
|
|
@@ -153,6 +165,7 @@ export type {
|
|
|
153
165
|
Shorthands,
|
|
154
166
|
Size,
|
|
155
167
|
SizeKeys,
|
|
168
|
+
SizeRecipe,
|
|
156
169
|
SizeTokens,
|
|
157
170
|
Space,
|
|
158
171
|
SpaceTokens,
|
|
@@ -3,7 +3,7 @@ import type {
|
|
|
3
3
|
LayoutChangeEvent,
|
|
4
4
|
TextLayoutEventData,
|
|
5
5
|
NativeSyntheticEvent,
|
|
6
|
-
} from 'react-native'
|
|
6
|
+
} from '@tamagui/react-native-types'
|
|
7
7
|
|
|
8
8
|
type OnLayout = ((event: LayoutChangeEvent) => void) | undefined
|
|
9
9
|
type OnTextLayout =
|
|
@@ -16,7 +16,6 @@ export interface RNExtraProps {
|
|
|
16
16
|
onSelectionChangeShouldSetResponder?: unknown
|
|
17
17
|
onSelectionChangeShouldSetResponderCapture?: unknown
|
|
18
18
|
onLayout?: OnLayout
|
|
19
|
-
elevationAndroid?: number | string
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
export interface RNViewProps extends GestureResponderHandlers, RNExtraProps {
|
|
@@ -40,7 +39,6 @@ export type RNOnlyProps =
|
|
|
40
39
|
| 'onTextLayout'
|
|
41
40
|
| 'href'
|
|
42
41
|
| 'hrefAttrs'
|
|
43
|
-
| 'elevationAndroid'
|
|
44
42
|
| 'rel'
|
|
45
43
|
| 'download'
|
|
46
44
|
| 'dir'
|
package/src/internal-runtime.ts
CHANGED
|
@@ -9,15 +9,20 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import type { FunctionComponent } from 'react'
|
|
11
11
|
import { stylePropsUnitless } from '@tamagui/helpers'
|
|
12
|
+
import type { TagName } from '@tamagui/dom'
|
|
12
13
|
import { createComponent } from './createComponent'
|
|
13
14
|
import { createVariables as createVariablesImpl } from './createVariables'
|
|
15
|
+
import { html } from './dom/html'
|
|
14
16
|
import { fixStyles as fixStylesImpl } from './helpers/expandStyles'
|
|
15
17
|
import { styleToCSS as styleToCSSImpl } from './helpers/styleToCSS'
|
|
16
18
|
import { getThemeCSSRules as getThemeCSSRulesImpl } from './helpers/getThemeCSSRules'
|
|
17
19
|
import { normalizeValueWithProperty as normalizeValueWithPropertyImpl } from './helpers/normalizeValueWithProperty'
|
|
18
20
|
import { proxyThemeToParents as proxyThemeToParentsImpl } from './helpers/proxyThemeToParents'
|
|
19
21
|
import type { FrontendComponent, StyleFrontend } from './helpers/styleFrontend'
|
|
20
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
copyAuthoredThemeScheme as copyAuthoredThemeSchemeImpl,
|
|
24
|
+
ensureThemeVariable as ensureThemeVariableImpl,
|
|
25
|
+
} from './helpers/themes'
|
|
21
26
|
import { transformsToString as transformsToStringImpl } from './helpers/transformsToString'
|
|
22
27
|
import {
|
|
23
28
|
parseFont as parseFontImpl,
|
|
@@ -31,7 +36,7 @@ import { TamaguiProvider as TamaguiProviderImpl } from './views/TamaguiProvider'
|
|
|
31
36
|
import { textStaticConfig } from './views/Text'
|
|
32
37
|
import { viewStaticConfig } from './views/View'
|
|
33
38
|
|
|
34
|
-
export { regularStyleFrontend } from './helpers/styleFrontend'
|
|
39
|
+
export { mergeFrontendCondition, regularStyleFrontend } from './helpers/styleFrontend'
|
|
35
40
|
export type * from './internalRuntimeTypes'
|
|
36
41
|
|
|
37
42
|
export const createVariables: (
|
|
@@ -57,6 +62,8 @@ export const proxyThemeToParents: (themeName: string, theme: any) => any =
|
|
|
57
62
|
proxyThemeToParentsImpl
|
|
58
63
|
export const ensureThemeVariable: (theme: any, key: string) => void =
|
|
59
64
|
ensureThemeVariableImpl
|
|
65
|
+
export const copyAuthoredThemeScheme: <T>(target: T, source: any) => T =
|
|
66
|
+
copyAuthoredThemeSchemeImpl
|
|
60
67
|
export const transformsToString: (transforms: object[]) => string = transformsToStringImpl
|
|
61
68
|
export const styleToCSS: (style: Record<string, any>) => void = styleToCSSImpl
|
|
62
69
|
export const useThemeWithState: (
|
|
@@ -131,3 +138,37 @@ export function createFrontendViews(frontend: StyleFrontend): {
|
|
|
131
138
|
}),
|
|
132
139
|
}
|
|
133
140
|
}
|
|
141
|
+
|
|
142
|
+
/** the tags `createFrontendHTML` builds, which is every tag of the DOM contract */
|
|
143
|
+
export type FrontendHTMLTag = TagName
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* The DOM contract's elements rebuilt on another style frontend: same tags, same
|
|
147
|
+
* element defaults, same runtime, only the authoring syntax differs. Mirrors
|
|
148
|
+
* `createFrontendViews`, and is safe for the same reason: the regular singletons
|
|
149
|
+
* keep their own config objects and `createComponent` never mutates one.
|
|
150
|
+
*/
|
|
151
|
+
export function createFrontendHTML(
|
|
152
|
+
frontend: StyleFrontend
|
|
153
|
+
): Record<FrontendHTMLTag, FrontendComponent> {
|
|
154
|
+
const out = {} as Record<FrontendHTMLTag, FrontendComponent>
|
|
155
|
+
for (const tag in html) {
|
|
156
|
+
const source = html[tag] as FrontendComponent & {
|
|
157
|
+
rebindDOMTag?: (next: FrontendComponent) => FrontendComponent
|
|
158
|
+
}
|
|
159
|
+
// a tag native does not support is a thrower with nothing to rebuild
|
|
160
|
+
if (!source.staticConfig) {
|
|
161
|
+
out[tag] = source
|
|
162
|
+
continue
|
|
163
|
+
}
|
|
164
|
+
const rebuilt = createComponent({
|
|
165
|
+
...source.staticConfig,
|
|
166
|
+
styleFrontend: frontend,
|
|
167
|
+
displayName: tag,
|
|
168
|
+
})
|
|
169
|
+
// on native the styling component is wrapped in the dom prop mapping, which
|
|
170
|
+
// the rebuild has to keep
|
|
171
|
+
out[tag] = source.rebindDOMTag ? source.rebindDOMTag(rebuilt) : rebuilt
|
|
172
|
+
}
|
|
173
|
+
return out
|
|
174
|
+
}
|
package/src/style.ts
CHANGED
|
@@ -75,9 +75,12 @@ export function createStylePiece(
|
|
|
75
75
|
*/
|
|
76
76
|
export function style(definition: StaticShapeStyle): StylePiece {
|
|
77
77
|
if (process.env.NODE_ENV === 'development') {
|
|
78
|
+
// the owner is the component rendering right now. the hooks dispatcher
|
|
79
|
+
// (`H`) stays set between renders, so it flags module-scope pieces in any
|
|
80
|
+
// module loaded after the first render
|
|
78
81
|
const internals = (React as any)
|
|
79
82
|
.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE
|
|
80
|
-
if (internals?.
|
|
83
|
+
if (internals?.A?.getOwner?.()) {
|
|
81
84
|
warnOnce(
|
|
82
85
|
'[tamagui] style() was called during render. Define style pieces at module scope so their rules compile once.'
|
|
83
86
|
)
|