@tamagui/web 3.0.0-beta.922.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
|
@@ -5,6 +5,7 @@ import { variableToString } from '../createVariable'
|
|
|
5
5
|
import type { CreateTamaguiProps, ThemeParsed, Variable } from '../types'
|
|
6
6
|
import { getOrCreateVariable, getOrCreateMutatedVariable } from './registerCSSVariable'
|
|
7
7
|
import { sortString } from './sortString'
|
|
8
|
+
import { getAuthoredThemeScheme, themeSchemeSelectorPrefix } from './themes'
|
|
8
9
|
|
|
9
10
|
const darkLight = ['dark', 'light']
|
|
10
11
|
const lightDark = ['light', 'dark']
|
|
@@ -29,6 +30,9 @@ export function getThemeCSSRules(props: {
|
|
|
29
30
|
) {
|
|
30
31
|
const cssRuleSets: string[] = []
|
|
31
32
|
const { config, themeName, theme, names } = props
|
|
33
|
+
const whitespace = process.env.NODE_ENV === 'development' ? ' ' : ''
|
|
34
|
+
const mediaIndent = process.env.NODE_ENV === 'development' ? '\n ' : ''
|
|
35
|
+
const mediaClose = process.env.NODE_ENV === 'development' ? '\n ' : ''
|
|
32
36
|
|
|
33
37
|
// special case for SSR
|
|
34
38
|
const hasDarkLight =
|
|
@@ -60,6 +64,7 @@ export function getThemeCSSRules(props: {
|
|
|
60
64
|
const isLightBase = themeName === 'light'
|
|
61
65
|
const baseSelectors = names.map((name) => `${CNP}${name}`)
|
|
62
66
|
const selectorsSet = new Set(isDarkBase || isLightBase ? baseSelectors : [])
|
|
67
|
+
const selectorScheme = new Map<string, 'light' | 'dark'>()
|
|
63
68
|
|
|
64
69
|
// The full resolved name is authoritative. `:not(#t_theme_full_name)` is
|
|
65
70
|
// an always-matching specificity anchor: a bounded relative selector for
|
|
@@ -78,8 +83,16 @@ export function getThemeCSSRules(props: {
|
|
|
78
83
|
const maxDepth = 2
|
|
79
84
|
|
|
80
85
|
for (const subName of names) {
|
|
81
|
-
|
|
82
|
-
|
|
86
|
+
// identical themes dedupe into one canonical name, and an alias can carry
|
|
87
|
+
// the opposite scheme to the name it deduped into: light_inverse IS dark,
|
|
88
|
+
// so it arrives here under themeName "dark". its own prefix therefore
|
|
89
|
+
// decides its scheme, and the base only answers for an unprefixed name.
|
|
90
|
+
// reading the base first pointed every cross-scheme alias at the wrong
|
|
91
|
+
// parent, which silently made <Theme name="inverse"> a no-op.
|
|
92
|
+
const hasDarkPrefix = subName === 'dark' || subName.startsWith('dark_')
|
|
93
|
+
const hasLightPrefix = subName === 'light' || subName.startsWith('light_')
|
|
94
|
+
const isDark = hasDarkPrefix || (!hasLightPrefix && isDarkBase)
|
|
95
|
+
const isLight = hasLightPrefix || (!hasDarkPrefix && isLightBase)
|
|
83
96
|
|
|
84
97
|
if (!(isDark || isLight)) {
|
|
85
98
|
// neither light nor dark subtheme, just generate one selector with :root:root which
|
|
@@ -117,12 +130,18 @@ export function getThemeCSSRules(props: {
|
|
|
117
130
|
|
|
118
131
|
// for light/dark/light:
|
|
119
132
|
const parentSelectorString = parentSelectors.join(' ')
|
|
120
|
-
|
|
133
|
+
const selector = `${parentSelectorString} ${nextChildSelector}`
|
|
134
|
+
selectorsSet.add(selector)
|
|
135
|
+
// remember which scheme's root this selector was built for, so the
|
|
136
|
+
// prefers-color-scheme pass below can route it. a theme carrying
|
|
137
|
+
// aliases from both schemes has to reach both media blocks.
|
|
138
|
+
selectorScheme.set(selector, isDark ? 'dark' : 'light')
|
|
121
139
|
}
|
|
122
140
|
}
|
|
123
141
|
}
|
|
124
142
|
|
|
125
143
|
const selectors = [...selectorsSet].sort(sortString)
|
|
144
|
+
const authoredScheme = getAuthoredThemeScheme(theme)
|
|
126
145
|
|
|
127
146
|
// only do our :root attach if it's not light/dark - not support sub themes on root saves a lot of effort/size
|
|
128
147
|
const selectorsString =
|
|
@@ -133,44 +152,63 @@ export function getThemeCSSRules(props: {
|
|
|
133
152
|
if (!isOnRoot) return `:root ${x}`
|
|
134
153
|
return `${addTo === 'body' ? 'body' : ':root'}${x}`
|
|
135
154
|
})
|
|
136
|
-
.join(', ') +
|
|
155
|
+
.join(', ') +
|
|
156
|
+
`, .tm_xxt` +
|
|
157
|
+
(authoredScheme ? `, ${themeSchemeSelectorPrefix}${authoredScheme}` : '')
|
|
137
158
|
|
|
138
|
-
const css = `${selectorsString}
|
|
159
|
+
const css = `${selectorsString}${whitespace}{${vars}}`
|
|
139
160
|
cssRuleSets.push(css)
|
|
140
161
|
|
|
141
162
|
if (getSetting('shouldAddPrefersColorThemes')) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
})
|
|
155
|
-
.filter(Boolean)
|
|
156
|
-
.join(', ')
|
|
157
|
-
|
|
158
|
-
// only emit body background/color for base themes, not every sub-theme
|
|
159
|
-
const isBase = !themeName.includes('_')
|
|
160
|
-
let bodyRulesString = ''
|
|
161
|
-
if (isBase) {
|
|
162
|
-
const bgString = theme.background
|
|
163
|
-
? `background:${variableToString(theme.background)};`
|
|
164
|
-
: ''
|
|
165
|
-
const fgString = theme.color ? `color:${variableToString(theme.color)}` : ''
|
|
166
|
-
bodyRulesString = bgString || fgString ? `body{${bgString}${fgString}}\n ` : ''
|
|
163
|
+
// inside a media block the root carries no theme class, so the leading
|
|
164
|
+
// `.t_light `/`.t_dark ` is stripped and the block itself stands in for it.
|
|
165
|
+
// a theme reached under BOTH roots therefore has to emit into both blocks:
|
|
166
|
+
// light_inverse dedupes into dark, so the dark values it holds are what an
|
|
167
|
+
// implicitly-light root must serve, while dark's own values serve the dark
|
|
168
|
+
// one. keying the whole set off themeName dropped one of the two.
|
|
169
|
+
const schemeOf = (x: string) => {
|
|
170
|
+
if (x === darkSelector) return 'dark'
|
|
171
|
+
if (x === lightSelector) return 'light'
|
|
172
|
+
if (x.startsWith(`${darkSelector} `)) return 'dark'
|
|
173
|
+
if (x.startsWith(`${lightSelector} `)) return 'light'
|
|
174
|
+
return selectorScheme.get(x)
|
|
167
175
|
}
|
|
168
176
|
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
177
|
+
for (const baseName of lightDark) {
|
|
178
|
+
const lessSpecificSelectors = selectors
|
|
179
|
+
.map((x) => {
|
|
180
|
+
if (x === darkSelector || x === lightSelector) {
|
|
181
|
+
return schemeOf(x) === baseName ? ':root' : undefined
|
|
182
|
+
}
|
|
183
|
+
// a selector rooted in the other scheme is unreachable here: that
|
|
184
|
+
// root would have to carry an explicit class, which the non-media
|
|
185
|
+
// rules above already cover at higher specificity.
|
|
186
|
+
const scheme = schemeOf(x)
|
|
187
|
+
if (scheme && scheme !== baseName) return
|
|
188
|
+
return x.replace(/^\.t_(dark|light) /, '').trim()
|
|
189
|
+
})
|
|
190
|
+
.filter(Boolean)
|
|
191
|
+
.join(', ')
|
|
192
|
+
|
|
193
|
+
if (!lessSpecificSelectors) continue
|
|
194
|
+
|
|
195
|
+
// only emit body background/color for base themes, not every sub-theme,
|
|
196
|
+
// and only for the scheme this theme actually grounds
|
|
197
|
+
const isBase = !themeName.includes('_')
|
|
198
|
+
let bodyRulesString = ''
|
|
199
|
+
if (isBase && themeName === baseName) {
|
|
200
|
+
const bgString = theme.background
|
|
201
|
+
? `background:${variableToString(theme.background)};`
|
|
202
|
+
: ''
|
|
203
|
+
const fgString = theme.color ? `color:${variableToString(theme.color)}` : ''
|
|
204
|
+
bodyRulesString =
|
|
205
|
+
bgString || fgString ? `body{${bgString}${fgString}}${mediaIndent}` : ''
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
cssRuleSets.push(
|
|
209
|
+
`@media(prefers-color-scheme:${baseName}){${mediaIndent}${bodyRulesString}${lessSpecificSelectors}${whitespace}{${vars}}${mediaClose}}`
|
|
210
|
+
)
|
|
211
|
+
}
|
|
174
212
|
}
|
|
175
213
|
|
|
176
214
|
const selectionStyles = getSetting('selectionStyles')
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// leaf subpath on purpose: the barrel pulls in the transition parser, which
|
|
2
|
+
// belongs to drivers and the compiler, not to every app that imports core
|
|
3
|
+
import { canonicalTransitionProperty } from '@tamagui/animation-helpers/propertyNames'
|
|
1
4
|
import { platformMatches } from '@tamagui/constants'
|
|
2
5
|
import { simpleHash } from '@tamagui/helpers'
|
|
3
6
|
import {
|
|
@@ -201,6 +204,15 @@ export function prepareConfigRevision(
|
|
|
201
204
|
borderRadius: 8,
|
|
202
205
|
}
|
|
203
206
|
const propertyKind = (property: string) => propertyKinds[property] || 0
|
|
207
|
+
// every border side width reads the one borderWidth group, as css does
|
|
208
|
+
const tokenCategory = (property: string): RuntimeTokenCategory | undefined =>
|
|
209
|
+
config.tokensParsed[property]
|
|
210
|
+
? property
|
|
211
|
+
: config.tokensParsed.borderWidth &&
|
|
212
|
+
property.startsWith('border') &&
|
|
213
|
+
property.endsWith('Width')
|
|
214
|
+
? 'borderWidth'
|
|
215
|
+
: getTokenCategoryForProperty(property)
|
|
204
216
|
// transition strings are re-normalized on every render of every animated
|
|
205
217
|
// element; the result only depends on this revision's shorthands
|
|
206
218
|
const normalizedTransitions = new Map<string, string>()
|
|
@@ -209,7 +221,7 @@ export function prepareConfigRevision(
|
|
|
209
221
|
modifiers,
|
|
210
222
|
mediaQueries,
|
|
211
223
|
resolveCondition,
|
|
212
|
-
tokenCategory
|
|
224
|
+
tokenCategory,
|
|
213
225
|
expandSafeArea: expandSafeAreaValue,
|
|
214
226
|
safeAreaVariable: resolveSafeAreaVariable,
|
|
215
227
|
parseFlatValue,
|
|
@@ -259,11 +271,10 @@ export function prepareConfigRevision(
|
|
|
259
271
|
) {
|
|
260
272
|
return authored
|
|
261
273
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
return property.replace(/[A-Z]/g, '-$&').toLowerCase()
|
|
274
|
+
// the drivers file entries under the same names through
|
|
275
|
+
// canonicalTransitionProperty, so a raw css string and a resolved
|
|
276
|
+
// transition cannot disagree about what `y` or `rotateX` targets
|
|
277
|
+
return canonicalTransitionProperty(config.shorthands[authored] || authored)
|
|
267
278
|
}
|
|
268
279
|
)
|
|
269
280
|
if (normalizedTransitions.size > 2048) normalizedTransitions.clear()
|
|
@@ -272,7 +283,11 @@ export function prepareConfigRevision(
|
|
|
272
283
|
},
|
|
273
284
|
embeddedTokens: (raw, resolve) =>
|
|
274
285
|
raw.replace(
|
|
275
|
-
|
|
286
|
+
// the alpha suffix matches decimals too, so `$color/0.7` is handed to
|
|
287
|
+
// resolve() whole and rejected as one token. matching only `\d+` split it
|
|
288
|
+
// into `$color/0` plus a stray `.7`, which left the `.7` glued onto the
|
|
289
|
+
// resolved value.
|
|
290
|
+
/\/\*[\s\S]*?\*\/|(["'])(?:\\.|(?!\1)[^\\])*\1|[$A-Za-z_][\w.$-]*(?:\/\d*\.?\d+)?/g,
|
|
276
291
|
(word, quote, offset) => {
|
|
277
292
|
const before = raw.charCodeAt(offset - 1)
|
|
278
293
|
return quote ||
|
|
@@ -332,7 +347,7 @@ export function getConfigRevisionSnapshot(
|
|
|
332
347
|
for (const key of Object.keys(themes[name] || {})) themeKeys.add(key)
|
|
333
348
|
}
|
|
334
349
|
sections.themeVariables.push(`v:${[...themeKeys].sort().join(',')}`)
|
|
335
|
-
for (const category of
|
|
350
|
+
for (const category of Object.keys(tokensParsed).sort()) {
|
|
336
351
|
const tokens = tokensParsed[category]
|
|
337
352
|
sections.tokens.push(
|
|
338
353
|
`${category}:${tokens ? Object.keys(tokens).sort().join(',') : ''}`
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { StyleObjectIdentifier, StyleObjectRules } from '@tamagui/helpers'
|
|
2
2
|
import { createVariable } from '../createVariable'
|
|
3
3
|
import { formatDiagnostic } from './formatDiagnostic'
|
|
4
|
+
import { setAuthoredThemeScheme, themeSchemeSelectorPrefix } from './themes'
|
|
4
5
|
import type {
|
|
5
6
|
DedupedTheme,
|
|
6
7
|
DedupedThemes,
|
|
@@ -10,7 +11,7 @@ import type {
|
|
|
10
11
|
} from '../types'
|
|
11
12
|
|
|
12
13
|
// only cache tamagui styles
|
|
13
|
-
//
|
|
14
|
+
// kept separate: allSelectors stores rule text for inspection, totalSelectorsInserted counts stylesheet insertions
|
|
14
15
|
const scannedCache = new WeakMap<CSSStyleSheet, string>()
|
|
15
16
|
const totalSelectorsInserted = new Map<string, number>()
|
|
16
17
|
const allSelectors: Record<string, string> = {}
|
|
@@ -25,7 +26,7 @@ let sortedRules: string[] = []
|
|
|
25
26
|
let sortedRulesStale = true
|
|
26
27
|
|
|
27
28
|
export const getAllRules = () => {
|
|
28
|
-
if (
|
|
29
|
+
if (process.env.TAMAGUI_RUNTIME !== 'island') {
|
|
29
30
|
if (sortedRulesStale) {
|
|
30
31
|
// Sort by identifier to ensure deterministic CSS output order
|
|
31
32
|
const sortedKeys = Object.keys(allRules).sort()
|
|
@@ -58,10 +59,9 @@ export function scanAllSheets(
|
|
|
58
59
|
collectThemes = false,
|
|
59
60
|
tokens?: TokensParsed
|
|
60
61
|
): DedupedThemes | undefined {
|
|
61
|
-
//
|
|
62
|
-
//
|
|
63
|
-
|
|
64
|
-
if (!process.env.TAMAGUI_DID_OUTPUT_CSS || collectThemes) {
|
|
62
|
+
// runtime components still emit styles alongside the config CSS artifact.
|
|
63
|
+
// an island only scans when rebuilding empty client themes from that artifact
|
|
64
|
+
if (process.env.TAMAGUI_RUNTIME !== 'island' || collectThemes) {
|
|
65
65
|
if (process.env.NODE_ENV === 'test') return
|
|
66
66
|
if (process.env.TAMAGUI_TARGET !== 'web') return
|
|
67
67
|
if (typeof document === 'undefined') return
|
|
@@ -267,6 +267,12 @@ function addThemesFromCSS(cssStyleRule: CSSStyleRule, tokens?: TokensParsed) {
|
|
|
267
267
|
|
|
268
268
|
// loop selectors and build deduped
|
|
269
269
|
for (const selector of selectors) {
|
|
270
|
+
const marker = selector.trim()
|
|
271
|
+
if (marker.startsWith(themeSchemeSelectorPrefix)) {
|
|
272
|
+
const scheme = marker.slice(themeSchemeSelectorPrefix.length)
|
|
273
|
+
if (scheme === 'light' || scheme === 'dark') setAuthoredThemeScheme(values, scheme)
|
|
274
|
+
continue
|
|
275
|
+
}
|
|
270
276
|
const themeName = getThemeNameFromSelector(selector)
|
|
271
277
|
if (themeName) names.add(themeName)
|
|
272
278
|
}
|
|
@@ -341,7 +347,7 @@ export function stopAccumulatingRules() {
|
|
|
341
347
|
}
|
|
342
348
|
|
|
343
349
|
export function updateRules(identifier: string, rules: string[]) {
|
|
344
|
-
if (
|
|
350
|
+
if (process.env.TAMAGUI_RUNTIME !== 'island' && trackAllRules) {
|
|
345
351
|
allRules[identifier] = rules.join(' ')
|
|
346
352
|
allRuleSets[identifier] = rules
|
|
347
353
|
sortedRulesStale = true
|
|
@@ -355,7 +361,7 @@ export function setNonce(_: string) {
|
|
|
355
361
|
}
|
|
356
362
|
|
|
357
363
|
export function insertStyleRules(rulesToInsert: RulesToInsert) {
|
|
358
|
-
if (process.env.
|
|
364
|
+
if (process.env.TAMAGUI_RUNTIME === 'island' || process.env.TAMAGUI_TARGET !== 'web') {
|
|
359
365
|
return
|
|
360
366
|
}
|
|
361
367
|
|
|
@@ -1,31 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fallback press handling when RNGH is not available.
|
|
3
|
-
*
|
|
4
|
-
* Implements the responder-based press detection that usePressability provides,
|
|
5
|
-
* without the deep RN internal import. Supports pressIn/pressOut delays,
|
|
6
|
-
* long press, cancellation, and min press duration.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
1
|
import { unstable_hasExternalPressOwnership } from '@tamagui/native'
|
|
10
2
|
import { useRef } from 'react'
|
|
11
|
-
|
|
12
|
-
type
|
|
13
|
-
| 'idle'
|
|
14
|
-
| 'pressing' // responder granted, waiting for delay
|
|
15
|
-
| 'active' // pressIn fired
|
|
16
|
-
| 'longPressed' // long press detected
|
|
17
|
-
|
|
18
|
-
interface PressRef {
|
|
19
|
-
state: PressState
|
|
20
|
-
pressInTimer: ReturnType<typeof setTimeout> | null
|
|
21
|
-
pressOutTimer: ReturnType<typeof setTimeout> | null
|
|
22
|
-
longPressTimer: ReturnType<typeof setTimeout> | null
|
|
23
|
-
activateTime: number
|
|
24
|
-
blockedByExternalOwnership: boolean
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const DEFAULT_LONG_PRESS_DELAY = 500
|
|
28
|
-
const DEFAULT_MIN_PRESS_DURATION = 130
|
|
3
|
+
import type { GestureResponderEvent } from 'react-native'
|
|
4
|
+
import type { usePressability as usePressabilityType } from 'react-native'
|
|
29
5
|
|
|
30
6
|
export function useMainThreadPressEvents(
|
|
31
7
|
events: any,
|
|
@@ -33,145 +9,93 @@ export function useMainThreadPressEvents(
|
|
|
33
9
|
enabled = true,
|
|
34
10
|
debugName?: string | null
|
|
35
11
|
) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
12
|
+
// static config evaluation does not render; load native code at render time.
|
|
13
|
+
const usePressability: typeof usePressabilityType =
|
|
14
|
+
require('react-native').usePressability
|
|
15
|
+
const initialized = useRef(false)
|
|
16
|
+
const ownsResponder = useRef(false)
|
|
17
|
+
const pressActive = useRef(false)
|
|
18
|
+
const active = enabled && Boolean(events)
|
|
19
|
+
if (active) initialized.current = true
|
|
20
|
+
|
|
21
|
+
function endPress(e: GestureResponderEvent) {
|
|
22
|
+
if (!pressActive.current) return
|
|
23
|
+
pressActive.current = false
|
|
24
|
+
events?.onPressOut?.(e)
|
|
46
25
|
}
|
|
47
26
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
27
|
+
// react native owns press geometry, timing and cancellation; initialize only
|
|
28
|
+
// for pressable components and remove callbacks when the responder path stops.
|
|
29
|
+
const handlers = usePressability(
|
|
30
|
+
initialized.current
|
|
31
|
+
? {
|
|
32
|
+
...(active ? events : {}),
|
|
33
|
+
disabled: !active || events?.disabled,
|
|
34
|
+
android_disableSound: true,
|
|
35
|
+
onPressIn: active
|
|
36
|
+
? (e: GestureResponderEvent) => {
|
|
37
|
+
endPress(e)
|
|
38
|
+
pressActive.current = true
|
|
39
|
+
events.onPressIn?.(e)
|
|
40
|
+
}
|
|
41
|
+
: undefined,
|
|
42
|
+
onPressOut: active ? endPress : undefined,
|
|
43
|
+
hitSlop: viewProps.hitSlop,
|
|
44
|
+
pressRectOffset: viewProps.pressRetentionOffset,
|
|
45
|
+
}
|
|
46
|
+
: null
|
|
56
47
|
)
|
|
48
|
+
if (!active || !handlers) return
|
|
57
49
|
|
|
58
|
-
function activate(e: any) {
|
|
59
|
-
ref.current.state = 'active'
|
|
60
|
-
ref.current.activateTime = Date.now()
|
|
61
|
-
events.onPressIn?.(e)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function deactivate(e: any) {
|
|
65
|
-
const pressDuration = Date.now() - ref.current.activateTime
|
|
66
|
-
const remaining = Math.max(minPressDuration - pressDuration, delayPressOut)
|
|
67
|
-
|
|
68
|
-
if (remaining > 0) {
|
|
69
|
-
ref.current.pressOutTimer = setTimeout(() => {
|
|
70
|
-
events.onPressOut?.(e)
|
|
71
|
-
}, remaining)
|
|
72
|
-
} else {
|
|
73
|
-
events.onPressOut?.(e)
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function cleanup() {
|
|
78
|
-
if (ref.current.pressInTimer) clearTimeout(ref.current.pressInTimer)
|
|
79
|
-
if (ref.current.pressOutTimer) clearTimeout(ref.current.pressOutTimer)
|
|
80
|
-
if (ref.current.longPressTimer) clearTimeout(ref.current.longPressTimer)
|
|
81
|
-
ref.current.pressInTimer = null
|
|
82
|
-
ref.current.pressOutTimer = null
|
|
83
|
-
ref.current.longPressTimer = null
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// user-supplied responder props (the View's raw RN gesture API) must keep
|
|
87
|
-
// working: blindly overwriting them here silently killed any press-hold-drag
|
|
88
|
-
// gesture built on onResponderMove/onResponderRelease whenever the element
|
|
89
|
-
// also had hover/press events. compose instead — user handler first, then
|
|
90
|
-
// the press synthesis.
|
|
91
50
|
const userStartShouldSet = viewProps.onStartShouldSetResponder
|
|
92
51
|
const userGrant = viewProps.onResponderGrant
|
|
93
52
|
const userRelease = viewProps.onResponderRelease
|
|
94
53
|
const userTerminate = viewProps.onResponderTerminate
|
|
95
54
|
const userTerminationRequest = viewProps.onResponderTerminationRequest
|
|
96
55
|
const userMove = viewProps.onResponderMove
|
|
56
|
+
const userClick = viewProps.onClick
|
|
97
57
|
|
|
98
|
-
viewProps.onStartShouldSetResponder = (e:
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
viewProps.onResponderGrant = (e: any) => {
|
|
104
|
-
cleanup()
|
|
105
|
-
|
|
106
|
-
if (unstable_hasExternalPressOwnership()) {
|
|
107
|
-
ref.current.state = 'idle'
|
|
108
|
-
ref.current.blockedByExternalOwnership = true
|
|
109
|
-
return
|
|
110
|
-
}
|
|
58
|
+
viewProps.onStartShouldSetResponder = (e: GestureResponderEvent) =>
|
|
59
|
+
userStartShouldSet?.(e) ||
|
|
60
|
+
(!unstable_hasExternalPressOwnership() && handlers.onStartShouldSetResponder())
|
|
111
61
|
|
|
62
|
+
viewProps.onResponderGrant = (e: GestureResponderEvent) => {
|
|
63
|
+
endPress(e)
|
|
64
|
+
if (unstable_hasExternalPressOwnership()) return
|
|
112
65
|
userGrant?.(e)
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
if (delayPressIn > 0) {
|
|
117
|
-
ref.current.pressInTimer = setTimeout(() => activate(e), delayPressIn)
|
|
118
|
-
} else {
|
|
119
|
-
activate(e)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (events.onLongPress) {
|
|
123
|
-
ref.current.longPressTimer = setTimeout(() => {
|
|
124
|
-
if (ref.current.state === 'active') {
|
|
125
|
-
ref.current.state = 'longPressed'
|
|
126
|
-
events.onLongPress?.(e)
|
|
127
|
-
}
|
|
128
|
-
}, delayLongPress + delayPressIn)
|
|
129
|
-
}
|
|
66
|
+
ownsResponder.current = true
|
|
67
|
+
return handlers.onResponderGrant(e)
|
|
130
68
|
}
|
|
131
69
|
|
|
132
|
-
viewProps.onResponderRelease = (e:
|
|
133
|
-
if (
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
70
|
+
viewProps.onResponderRelease = (e: GestureResponderEvent) => {
|
|
71
|
+
if (!ownsResponder.current) return
|
|
72
|
+
ownsResponder.current = false
|
|
73
|
+
if (unstable_hasExternalPressOwnership()) {
|
|
74
|
+
handlers.onResponderTerminate(e)
|
|
75
|
+
endPress(e)
|
|
137
76
|
return
|
|
138
77
|
}
|
|
139
|
-
|
|
140
78
|
userRelease?.(e)
|
|
141
|
-
|
|
142
|
-
cleanup()
|
|
143
|
-
|
|
144
|
-
// if pressIn hasn't fired yet (was in delay), fire it now then immediately deactivate
|
|
145
|
-
if (ref.current.state === 'pressing') {
|
|
146
|
-
activate(e)
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (!wasLongPressed) {
|
|
150
|
-
events.onPress?.(e)
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
deactivate(e)
|
|
154
|
-
ref.current.state = 'idle'
|
|
155
|
-
ref.current.blockedByExternalOwnership = false
|
|
79
|
+
handlers.onResponderRelease(e)
|
|
156
80
|
}
|
|
157
81
|
|
|
158
|
-
viewProps.onResponderTerminate = (e:
|
|
82
|
+
viewProps.onResponderTerminate = (e: GestureResponderEvent) => {
|
|
159
83
|
userTerminate?.(e)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
ref.current.state = 'idle'
|
|
165
|
-
ref.current.blockedByExternalOwnership = false
|
|
84
|
+
if (ownsResponder.current) handlers.onResponderTerminate(e)
|
|
85
|
+
endPress(e)
|
|
86
|
+
ownsResponder.current = false
|
|
166
87
|
}
|
|
167
88
|
|
|
168
|
-
viewProps.onResponderTerminationRequest = (e:
|
|
169
|
-
|
|
170
|
-
return events.cancelable !== false
|
|
171
|
-
}
|
|
89
|
+
viewProps.onResponderTerminationRequest = (e: GestureResponderEvent) =>
|
|
90
|
+
userTerminationRequest?.(e) ?? handlers.onResponderTerminationRequest()
|
|
172
91
|
|
|
173
|
-
viewProps.onResponderMove = (e:
|
|
92
|
+
viewProps.onResponderMove = (e: GestureResponderEvent) => {
|
|
174
93
|
userMove?.(e)
|
|
175
|
-
|
|
94
|
+
if (ownsResponder.current) handlers.onResponderMove(e)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
viewProps.onClick = (e: GestureResponderEvent) => {
|
|
98
|
+
userClick?.(e)
|
|
99
|
+
if (!unstable_hasExternalPressOwnership()) handlers.onClick(e)
|
|
176
100
|
}
|
|
177
101
|
}
|
|
@@ -1,49 +1,31 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Preserves prop ordering, so that the order most closely matches the last spread objects
|
|
3
|
-
* Useful for having { ...defaultProps, ...props } that ensure props ordering is always kept
|
|
4
|
-
*
|
|
5
|
-
* Honestly this is somehwat backwards logically from Object.assign, reason was that we typically
|
|
6
|
-
* are merging defaultProps, givenProps, but we started using it elsewhere and now its a bit confusing
|
|
7
|
-
* Should look into refactoring this to match common usage
|
|
8
|
-
*
|
|
9
|
-
* Given:
|
|
10
|
-
* mergeProps({ a: 1, b: 2 }, { b: 1, a: 2 })
|
|
11
|
-
* The final key order will be:
|
|
12
|
-
* b, a
|
|
13
|
-
*
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
1
|
export type GenericProps = Record<string, any>
|
|
17
2
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
for (const key in defaultProps) {
|
|
30
|
-
if (key in props) continue
|
|
31
|
-
out[key] = defaultProps[key]
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
for (const key in props) {
|
|
35
|
-
out[key] = props[key]
|
|
3
|
+
// layers merge in order (defaults, styled context, the caller's props), so key
|
|
4
|
+
// order in the result follows that order. one rule for every layer: an
|
|
5
|
+
// undefined value never replaces what a lower layer set (React defaultProps
|
|
6
|
+
// semantics); it lands only when nothing set the key, which keeps `key in
|
|
7
|
+
// props` true for a caller who passed the key.
|
|
8
|
+
const mergeLayer = (out: GenericProps, layer: object) => {
|
|
9
|
+
for (const key in layer) {
|
|
10
|
+
const value = layer[key]
|
|
11
|
+
if (value === undefined && key in out) continue
|
|
12
|
+
out[key] = value
|
|
36
13
|
}
|
|
14
|
+
}
|
|
37
15
|
|
|
16
|
+
export const mergeProps = (defaultProps: object, props: object) => {
|
|
17
|
+
const out: GenericProps = {}
|
|
18
|
+
mergeLayer(out, defaultProps)
|
|
19
|
+
mergeLayer(out, props)
|
|
38
20
|
return out
|
|
39
21
|
}
|
|
40
22
|
|
|
41
|
-
// merge
|
|
23
|
+
// same merge with a styled-context layer between defaults and props. also
|
|
24
|
+
// reports which context keys the caller's props overrode, in prop order, so
|
|
25
|
+
// the component can stop publishing those to its own descendants.
|
|
42
26
|
export const mergeComponentProps = (
|
|
43
|
-
// this is "a" in mergeProps
|
|
44
27
|
defaultProps: object | null | undefined,
|
|
45
|
-
contextProps: object | undefined,
|
|
46
|
-
// this is "b" in mergeProps
|
|
28
|
+
contextProps: object | null | undefined,
|
|
47
29
|
props: object
|
|
48
30
|
) => {
|
|
49
31
|
let overriddenContext: GenericProps | null = null
|
|
@@ -52,38 +34,23 @@ export const mergeComponentProps = (
|
|
|
52
34
|
return [props, overriddenContext] as const
|
|
53
35
|
}
|
|
54
36
|
|
|
55
|
-
if (defaultProps && !contextProps) {
|
|
56
|
-
return [mergeProps(defaultProps, props), overriddenContext] as const
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// the only unique case is contextProps, we need to track overrides and do something a bit tricky
|
|
60
|
-
// since we respect prop order for styles, we want to preserve the object key order in overriddenContext
|
|
61
|
-
|
|
62
37
|
const out: GenericProps = {}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
out[key] = defaultProps[key]
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// styled context props go after defaultProps but before props
|
|
73
|
-
for (const key in contextProps) {
|
|
74
|
-
if (key in props) continue
|
|
75
|
-
const contextValue = contextProps[key]
|
|
76
|
-
// don't merge undefined context values to preserve inheritance
|
|
77
|
-
if (contextValue !== undefined) {
|
|
78
|
-
out[key] = contextValue
|
|
38
|
+
if (defaultProps) mergeLayer(out, defaultProps)
|
|
39
|
+
if (contextProps) {
|
|
40
|
+
// undefined context defaults declare a key without overriding styled values.
|
|
41
|
+
for (const key in contextProps) {
|
|
42
|
+
const value = contextProps[key]
|
|
43
|
+
if (value !== undefined) out[key] = value
|
|
79
44
|
}
|
|
80
45
|
}
|
|
81
46
|
|
|
82
47
|
for (const key in props) {
|
|
83
|
-
|
|
48
|
+
const value = props[key]
|
|
49
|
+
if (value === undefined && key in out) continue
|
|
50
|
+
out[key] = value
|
|
84
51
|
if (contextProps && key in contextProps) {
|
|
85
52
|
overriddenContext ||= {}
|
|
86
|
-
overriddenContext[key] =
|
|
53
|
+
overriddenContext[key] = value
|
|
87
54
|
}
|
|
88
55
|
}
|
|
89
56
|
|