@tamagui/web 3.0.0-beta.765.1 → 3.0.0-beta.804.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/createComponent.cjs +83 -86
- package/dist/cjs/createComponent.native.cjs +96 -103
- package/dist/cjs/createComponent.native.js +96 -103
- package/dist/cjs/createComponent.native.js.map +1 -1
- package/dist/cjs/createTamagui.cjs +9 -7
- package/dist/cjs/createTamagui.native.cjs +9 -7
- package/dist/cjs/createTamagui.native.js +9 -7
- package/dist/cjs/createTamagui.native.js.map +1 -1
- package/dist/cjs/helpers/defaultAnimationDriver.cjs +0 -1
- package/dist/cjs/helpers/defaultAnimationDriver.native.cjs +0 -1
- package/dist/cjs/helpers/defaultAnimationDriver.native.js +0 -1
- package/dist/cjs/helpers/defaultAnimationDriver.native.js.map +1 -1
- package/dist/cjs/helpers/directStyleCSS.cjs +348 -0
- package/dist/cjs/helpers/directStyleCSS.native.cjs +20 -0
- package/dist/cjs/helpers/directStyleCSS.native.js +22 -0
- package/dist/cjs/helpers/directStyleCSS.native.js.map +1 -0
- package/dist/cjs/helpers/directStyleCSSCompiled.cjs +40 -0
- package/dist/cjs/helpers/directStyleCSSCompiled.native.cjs +46 -0
- package/dist/cjs/helpers/directStyleCSSCompiled.native.js +48 -0
- package/dist/cjs/helpers/directStyleCSSCompiled.native.js.map +1 -0
- package/dist/cjs/helpers/getCSSStylesAtomic.cjs +92 -74
- package/dist/cjs/helpers/{getFontLanguage.native.cjs → getCSSStylesAtomicCompiled.cjs} +12 -8
- package/dist/cjs/helpers/{getFontLanguage.native.js → getCSSStylesAtomicCompiled.native.cjs} +12 -8
- package/dist/cjs/helpers/getCSSStylesAtomicCompiled.native.js +36 -0
- package/dist/cjs/helpers/getCSSStylesAtomicCompiled.native.js.map +1 -0
- package/dist/cjs/helpers/getSplitStyles.cjs +2417 -548
- package/dist/cjs/helpers/getSplitStyles.native.cjs +2758 -621
- package/dist/cjs/helpers/getSplitStyles.native.js +2758 -621
- package/dist/cjs/helpers/getSplitStyles.native.js.map +1 -1
- package/dist/cjs/helpers/getVariantExtras.cjs +8 -3
- package/dist/cjs/helpers/getVariantExtras.native.cjs +8 -3
- package/dist/cjs/helpers/getVariantExtras.native.js +8 -3
- package/dist/cjs/helpers/getVariantExtras.native.js.map +1 -1
- package/dist/cjs/helpers/insertStyleRule.cjs +2 -1
- package/dist/cjs/helpers/insertStyleRule.native.cjs +68 -5
- package/dist/cjs/helpers/insertStyleRule.native.js +68 -5
- package/dist/cjs/helpers/insertStyleRule.native.js.map +1 -1
- package/dist/cjs/helpers/mediaState.cjs +12 -0
- package/dist/cjs/helpers/mediaState.native.cjs +12 -0
- package/dist/cjs/helpers/mediaState.native.js +12 -0
- package/dist/cjs/helpers/mediaState.native.js.map +1 -1
- package/dist/cjs/helpers/normalizeStyle.cjs +16 -2
- package/dist/cjs/helpers/normalizeStyle.native.cjs +16 -2
- package/dist/cjs/helpers/normalizeStyle.native.js +16 -2
- package/dist/cjs/helpers/normalizeStyle.native.js.map +1 -1
- package/dist/cjs/helpers/resolveRem.cjs +1 -1
- package/dist/cjs/helpers/skipProps.cjs +6 -1
- package/dist/cjs/helpers/skipProps.native.cjs +6 -1
- package/dist/cjs/helpers/skipProps.native.js +6 -1
- package/dist/cjs/helpers/skipProps.native.js.map +1 -1
- package/dist/cjs/helpers/styleFrontend.cjs +2 -8
- package/dist/cjs/helpers/styleFrontend.native.cjs +2 -10
- package/dist/cjs/helpers/styleFrontend.native.js +2 -10
- package/dist/cjs/helpers/styleFrontend.native.js.map +1 -1
- package/dist/cjs/helpers/styleToCSS.cjs +59 -0
- package/dist/cjs/helpers/{normalizeStylePropKeys.cjs → styleToCSS.native.cjs} +6 -4
- package/dist/cjs/helpers/{getFontLanguage.cjs → styleToCSS.native.js} +8 -4
- package/dist/cjs/helpers/styleToCSS.native.js.map +1 -0
- package/dist/cjs/helpers/subscribeToContextGroup.cjs +28 -1
- package/dist/cjs/helpers/subscribeToContextGroup.native.cjs +45 -1
- package/dist/cjs/helpers/subscribeToContextGroup.native.js +45 -1
- package/dist/cjs/helpers/subscribeToContextGroup.native.js.map +1 -1
- package/dist/cjs/helpers/variables.cjs +3 -2
- package/dist/cjs/helpers/variables.native.cjs +3 -2
- package/dist/cjs/helpers/variables.native.js +3 -2
- package/dist/cjs/helpers/variables.native.js.map +1 -1
- package/dist/cjs/helpers/wrapStyleTags.cjs +5 -3
- package/dist/cjs/helpers/wrapStyleTags.native.cjs +3 -1
- package/dist/cjs/helpers/wrapStyleTags.native.js +3 -1
- package/dist/cjs/helpers/wrapStyleTags.native.js.map +1 -1
- package/dist/cjs/hooks/useComponentState.cjs +70 -89
- package/dist/cjs/hooks/useComponentState.native.cjs +70 -88
- package/dist/cjs/hooks/useComponentState.native.js +70 -88
- package/dist/cjs/hooks/useComponentState.native.js.map +1 -1
- package/dist/cjs/hooks/useMedia.cjs +3 -15
- package/dist/cjs/hooks/useMedia.native.cjs +3 -15
- package/dist/cjs/hooks/useMedia.native.js +3 -15
- package/dist/cjs/hooks/useMedia.native.js.map +1 -1
- package/dist/cjs/hooks/useProps.cjs +7 -5
- package/dist/cjs/hooks/useProps.native.cjs +7 -5
- package/dist/cjs/hooks/useProps.native.js +7 -5
- package/dist/cjs/hooks/useProps.native.js.map +1 -1
- package/dist/cjs/hooks/useSplitStyles.cjs +42 -0
- package/dist/cjs/hooks/useSplitStyles.native.cjs +42 -0
- package/dist/cjs/hooks/useSplitStyles.native.js +44 -0
- package/dist/cjs/hooks/useSplitStyles.native.js.map +1 -0
- package/dist/cjs/index.cjs +184 -70
- package/dist/cjs/index.native.cjs +184 -70
- package/dist/cjs/index.native.js +184 -70
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/insertFont.cjs +1 -1
- package/dist/cjs/insertFont.native.cjs +1 -0
- package/dist/cjs/insertFont.native.js +1 -0
- package/dist/cjs/insertFont.native.js.map +1 -1
- package/dist/cjs/internal-runtime.cjs +33 -6
- package/dist/cjs/internal-runtime.native.cjs +33 -6
- package/dist/cjs/internal-runtime.native.js +33 -6
- package/dist/cjs/internal-runtime.native.js.map +1 -1
- package/dist/cjs/setupReactNative.cjs +1 -29
- package/dist/cjs/setupReactNative.native.cjs +1 -3
- package/dist/cjs/setupReactNative.native.js +1 -3
- package/dist/cjs/setupReactNative.native.js.map +1 -1
- package/dist/cjs/static-resolve.cjs +229 -0
- package/dist/cjs/static-resolve.native.cjs +242 -0
- package/dist/cjs/static-resolve.native.js +244 -0
- package/dist/cjs/static-resolve.native.js.map +1 -0
- package/dist/cjs/styled.cjs +23 -37
- package/dist/cjs/styled.native.cjs +22 -37
- package/dist/cjs/styled.native.js +22 -37
- package/dist/cjs/styled.native.js.map +1 -1
- package/dist/cjs/views/TamaguiProvider.cjs +4 -8
- package/dist/cjs/views/TamaguiProvider.native.cjs +4 -8
- package/dist/cjs/views/TamaguiProvider.native.js +4 -8
- package/dist/cjs/views/TamaguiProvider.native.js.map +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/createComponent.mjs +85 -88
- package/dist/esm/createComponent.mjs.map +1 -1
- package/dist/esm/createComponent.native.js +98 -105
- package/dist/esm/createComponent.native.js.map +1 -1
- package/dist/esm/createTamagui.mjs +9 -7
- package/dist/esm/createTamagui.mjs.map +1 -1
- package/dist/esm/createTamagui.native.js +9 -7
- package/dist/esm/createTamagui.native.js.map +1 -1
- package/dist/esm/helpers/defaultAnimationDriver.mjs +0 -1
- package/dist/esm/helpers/defaultAnimationDriver.mjs.map +1 -1
- package/dist/esm/helpers/defaultAnimationDriver.native.js +0 -1
- package/dist/esm/helpers/defaultAnimationDriver.native.js.map +1 -1
- package/dist/esm/helpers/directStyleCSS.mjs +320 -0
- package/dist/esm/helpers/directStyleCSS.mjs.map +1 -0
- package/dist/esm/helpers/directStyleCSS.native.js +1 -0
- package/dist/esm/helpers/directStyleCSSCompiled.mjs +11 -0
- package/dist/esm/helpers/directStyleCSSCompiled.mjs.map +1 -0
- package/dist/esm/helpers/directStyleCSSCompiled.native.js +15 -0
- package/dist/esm/helpers/directStyleCSSCompiled.native.js.map +1 -0
- package/dist/esm/helpers/getCSSStylesAtomic.mjs +86 -72
- package/dist/esm/helpers/getCSSStylesAtomic.mjs.map +1 -1
- package/dist/esm/helpers/getCSSStylesAtomicCompiled.mjs +9 -0
- package/dist/esm/helpers/getCSSStylesAtomicCompiled.mjs.map +1 -0
- package/dist/esm/helpers/getCSSStylesAtomicCompiled.native.js +9 -0
- package/dist/esm/helpers/getCSSStylesAtomicCompiled.native.js.map +1 -0
- package/dist/esm/helpers/getSplitStyles.mjs +2406 -545
- package/dist/esm/helpers/getSplitStyles.mjs.map +1 -1
- package/dist/esm/helpers/getSplitStyles.native.js +2751 -618
- package/dist/esm/helpers/getSplitStyles.native.js.map +1 -1
- package/dist/esm/helpers/getVariantExtras.mjs +8 -3
- package/dist/esm/helpers/getVariantExtras.mjs.map +1 -1
- package/dist/esm/helpers/getVariantExtras.native.js +8 -3
- package/dist/esm/helpers/getVariantExtras.native.js.map +1 -1
- package/dist/esm/helpers/insertStyleRule.mjs +2 -1
- package/dist/esm/helpers/insertStyleRule.mjs.map +1 -1
- package/dist/esm/helpers/insertStyleRule.native.js +69 -3
- package/dist/esm/helpers/insertStyleRule.native.js.map +1 -1
- package/dist/esm/helpers/mediaState.mjs +12 -1
- package/dist/esm/helpers/mediaState.mjs.map +1 -1
- package/dist/esm/helpers/mediaState.native.js +12 -1
- package/dist/esm/helpers/mediaState.native.js.map +1 -1
- package/dist/esm/helpers/normalizeStyle.mjs +16 -2
- package/dist/esm/helpers/normalizeStyle.mjs.map +1 -1
- package/dist/esm/helpers/normalizeStyle.native.js +16 -2
- package/dist/esm/helpers/normalizeStyle.native.js.map +1 -1
- package/dist/esm/helpers/resolveRem.mjs +1 -1
- package/dist/esm/helpers/resolveRem.mjs.map +1 -1
- package/dist/esm/helpers/skipProps.mjs +3 -1
- package/dist/esm/helpers/skipProps.mjs.map +1 -1
- package/dist/esm/helpers/skipProps.native.js +3 -1
- package/dist/esm/helpers/skipProps.native.js.map +1 -1
- package/dist/esm/helpers/styleFrontend.mjs +2 -4
- package/dist/esm/helpers/styleFrontend.mjs.map +1 -1
- package/dist/esm/helpers/styleFrontend.native.js +2 -6
- package/dist/esm/helpers/styleFrontend.native.js.map +1 -1
- package/dist/esm/helpers/styleToCSS.mjs +40 -0
- package/dist/esm/helpers/styleToCSS.mjs.map +1 -0
- package/dist/esm/helpers/styleToCSS.native.js +4 -0
- package/dist/esm/helpers/styleToCSS.native.js.map +1 -0
- package/dist/esm/helpers/subscribeToContextGroup.mjs +25 -1
- package/dist/esm/helpers/subscribeToContextGroup.mjs.map +1 -1
- package/dist/esm/helpers/subscribeToContextGroup.native.js +42 -1
- package/dist/esm/helpers/subscribeToContextGroup.native.js.map +1 -1
- package/dist/esm/helpers/variables.mjs +2 -1
- package/dist/esm/helpers/variables.mjs.map +1 -1
- package/dist/esm/helpers/variables.native.js +2 -1
- package/dist/esm/helpers/variables.native.js.map +1 -1
- package/dist/esm/helpers/wrapStyleTags.mjs +5 -3
- package/dist/esm/helpers/wrapStyleTags.mjs.map +1 -1
- package/dist/esm/helpers/wrapStyleTags.native.js +3 -1
- package/dist/esm/helpers/wrapStyleTags.native.js.map +1 -1
- package/dist/esm/hooks/useComponentState.mjs +71 -90
- package/dist/esm/hooks/useComponentState.mjs.map +1 -1
- package/dist/esm/hooks/useComponentState.native.js +71 -89
- package/dist/esm/hooks/useComponentState.native.js.map +1 -1
- package/dist/esm/hooks/useMedia.mjs +2 -15
- package/dist/esm/hooks/useMedia.mjs.map +1 -1
- package/dist/esm/hooks/useMedia.native.js +2 -15
- package/dist/esm/hooks/useMedia.native.js.map +1 -1
- package/dist/esm/hooks/useProps.mjs +7 -5
- package/dist/esm/hooks/useProps.mjs.map +1 -1
- package/dist/esm/hooks/useProps.native.js +7 -5
- package/dist/esm/hooks/useProps.native.js.map +1 -1
- package/dist/esm/hooks/useSplitStyles.mjs +17 -0
- package/dist/esm/hooks/useSplitStyles.mjs.map +1 -0
- package/dist/esm/hooks/useSplitStyles.native.js +14 -0
- package/dist/esm/hooks/useSplitStyles.native.js.map +1 -0
- package/dist/esm/index.js +57 -137
- package/dist/esm/index.mjs +57 -137
- package/dist/esm/index.native.js +57 -137
- package/dist/esm/insertFont.mjs +1 -1
- package/dist/esm/insertFont.mjs.map +1 -1
- package/dist/esm/insertFont.native.js +1 -0
- package/dist/esm/insertFont.native.js.map +1 -1
- package/dist/esm/internal-runtime.mjs +23 -4
- package/dist/esm/internal-runtime.mjs.map +1 -1
- package/dist/esm/internal-runtime.native.js +23 -4
- package/dist/esm/internal-runtime.native.js.map +1 -1
- package/dist/esm/setupReactNative.mjs +1 -29
- package/dist/esm/setupReactNative.mjs.map +1 -1
- package/dist/esm/setupReactNative.native.js +1 -3
- package/dist/esm/setupReactNative.native.js.map +1 -1
- package/dist/esm/static-resolve.mjs +194 -0
- package/dist/esm/static-resolve.mjs.map +1 -0
- package/dist/esm/static-resolve.native.js +205 -0
- package/dist/esm/static-resolve.native.js.map +1 -0
- package/dist/esm/styled.mjs +24 -40
- package/dist/esm/styled.mjs.map +1 -1
- package/dist/esm/styled.native.js +23 -40
- package/dist/esm/styled.native.js.map +1 -1
- package/dist/esm/views/TamaguiProvider.mjs +4 -8
- package/dist/esm/views/TamaguiProvider.mjs.map +1 -1
- package/dist/esm/views/TamaguiProvider.native.js +4 -8
- package/dist/esm/views/TamaguiProvider.native.js.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 +25 -15
- package/reset.css +3 -3
- package/src/createComponent.tsx +175 -192
- package/src/createTamagui.ts +10 -9
- package/src/helpers/defaultAnimationDriver.tsx +0 -1
- package/src/helpers/directStyleCSS.native.ts +1 -0
- package/src/helpers/directStyleCSS.ts +534 -0
- package/src/helpers/directStyleCSSCompiled.ts +32 -0
- package/src/helpers/getCSSStylesAtomic.ts +168 -88
- package/src/helpers/getCSSStylesAtomicCompiled.ts +9 -0
- package/src/helpers/getSplitStyles.tsx +4653 -1003
- package/src/helpers/getVariantExtras.tsx +15 -3
- package/src/helpers/insertStyleRule.tsx +4 -2
- package/src/helpers/mediaState.ts +15 -0
- package/src/helpers/normalizeStyle.ts +27 -2
- package/src/helpers/resolveRem.ts +1 -1
- package/src/helpers/skipProps.ts +3 -0
- package/src/helpers/styleFrontend.ts +20 -27
- package/src/helpers/styleToCSS.native.ts +1 -0
- package/src/helpers/styleToCSS.ts +43 -0
- package/src/helpers/subscribeToContextGroup.tsx +30 -0
- package/src/helpers/variables.ts +2 -1
- package/src/helpers/warnOnce.ts +3 -4
- package/src/helpers/wrapStyleTags.tsx +1 -1
- package/src/hooks/useComponentState.ts +118 -158
- package/src/hooks/useMedia.tsx +2 -18
- package/src/hooks/useProps.tsx +19 -15
- package/src/hooks/useSplitStyles.tsx +26 -0
- package/src/index.ts +298 -73
- package/src/insertFont.ts +5 -1
- package/src/internal-runtime.ts +49 -24
- package/src/internalRuntimeTypes.ts +2 -7
- package/src/setupReactNative.ts +7 -30
- package/src/static-resolve.ts +396 -0
- package/src/styled.tsx +34 -11
- package/src/types.tsx +40 -30
- package/src/views/TamaguiProvider.tsx +23 -22
- package/src/views/ThemeUpdate.tsx +3 -1
- package/types/createComponent.d.ts.map +1 -1
- package/types/createTamagui.d.ts.map +1 -1
- package/types/helpers/defaultAnimationDriver.d.ts.map +1 -1
- package/types/helpers/directStyleCSS.d.ts +28 -0
- package/types/helpers/directStyleCSS.d.ts.map +1 -0
- package/types/helpers/directStyleCSS.native.d.ts +2 -0
- package/types/helpers/directStyleCSS.native.d.ts.map +1 -0
- package/types/helpers/directStyleCSSCompiled.d.ts +10 -0
- package/types/helpers/directStyleCSSCompiled.d.ts.map +1 -0
- package/types/helpers/getCSSStylesAtomic.d.ts +22 -1
- package/types/helpers/getCSSStylesAtomic.d.ts.map +1 -1
- package/types/helpers/getCSSStylesAtomicCompiled.d.ts +4 -0
- package/types/helpers/getCSSStylesAtomicCompiled.d.ts.map +1 -0
- package/types/helpers/getSplitStyles.d.ts +11 -4
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/helpers/getVariantExtras.d.ts.map +1 -1
- package/types/helpers/insertStyleRule.d.ts.map +1 -1
- package/types/helpers/mediaState.d.ts +4 -0
- package/types/helpers/mediaState.d.ts.map +1 -1
- package/types/helpers/normalizeStyle.d.ts +1 -1
- package/types/helpers/normalizeStyle.d.ts.map +1 -1
- package/types/helpers/skipProps.d.ts +2 -0
- package/types/helpers/skipProps.d.ts.map +1 -1
- package/types/helpers/styleFrontend.d.ts +13 -17
- package/types/helpers/styleFrontend.d.ts.map +1 -1
- package/types/helpers/styleToCSS.d.ts +2 -0
- package/types/helpers/styleToCSS.d.ts.map +1 -0
- package/types/helpers/styleToCSS.native.d.ts +2 -0
- package/types/helpers/styleToCSS.native.d.ts.map +1 -0
- package/types/helpers/subscribeToContextGroup.d.ts +1 -0
- package/types/helpers/subscribeToContextGroup.d.ts.map +1 -1
- package/types/helpers/variables.d.ts.map +1 -1
- package/types/helpers/warnOnce.d.ts.map +1 -1
- package/types/helpers/webPropsToSkip.native.d.ts +5 -0
- package/types/helpers/webPropsToSkip.native.d.ts.map +1 -1
- package/types/hooks/useComponentState.d.ts +3 -2
- package/types/hooks/useComponentState.d.ts.map +1 -1
- package/types/hooks/useMedia.d.ts +1 -5
- package/types/hooks/useMedia.d.ts.map +1 -1
- package/types/hooks/useProps.d.ts.map +1 -1
- package/types/hooks/useSplitStyles.d.ts +3 -0
- package/types/hooks/useSplitStyles.d.ts.map +1 -0
- package/types/index.d.ts +58 -72
- package/types/index.d.ts.map +1 -1
- package/types/insertFont.d.ts.map +1 -1
- package/types/internal-runtime.d.ts +24 -11
- package/types/internal-runtime.d.ts.map +1 -1
- package/types/internalRuntimeTypes.d.ts +1 -6
- package/types/internalRuntimeTypes.d.ts.map +1 -1
- package/types/setupReactNative.d.ts +2 -3
- package/types/setupReactNative.d.ts.map +1 -1
- package/types/static-resolve.d.ts +79 -0
- package/types/static-resolve.d.ts.map +1 -0
- package/types/styled.d.ts.map +1 -1
- package/types/types.d.ts +29 -22
- package/types/types.d.ts.map +1 -1
- package/types/views/TamaguiProvider.d.ts.map +1 -1
- package/types/views/ThemeUpdate.d.ts.map +1 -1
- package/dist/cjs/constants/accessibilityDirectMap.cjs +0 -34
- package/dist/cjs/constants/accessibilityDirectMap.native.cjs +0 -36
- package/dist/cjs/constants/accessibilityDirectMap.native.js +0 -38
- package/dist/cjs/constants/accessibilityDirectMap.native.js.map +0 -1
- package/dist/cjs/helpers/directStyle.cjs +0 -962
- package/dist/cjs/helpers/directStyle.native.cjs +0 -1165
- package/dist/cjs/helpers/directStyle.native.js +0 -1167
- package/dist/cjs/helpers/directStyle.native.js.map +0 -1
- package/dist/cjs/helpers/frontendProgram.cjs +0 -43
- package/dist/cjs/helpers/frontendProgram.native.cjs +0 -49
- package/dist/cjs/helpers/frontendProgram.native.js +0 -51
- package/dist/cjs/helpers/frontendProgram.native.js.map +0 -1
- package/dist/cjs/helpers/getFontLanguage.native.js.map +0 -1
- package/dist/cjs/helpers/normalizeStylePropKeys.native.cjs +0 -37
- package/dist/cjs/helpers/normalizeStylePropKeys.native.js +0 -39
- package/dist/cjs/helpers/normalizeStylePropKeys.native.js.map +0 -1
- package/dist/cjs/helpers/propMapper.cjs +0 -384
- package/dist/cjs/helpers/propMapper.native.cjs +0 -536
- package/dist/cjs/helpers/propMapper.native.js +0 -538
- package/dist/cjs/helpers/propMapper.native.js.map +0 -1
- package/dist/cjs/helpers/useRenderElement.cjs +0 -47
- package/dist/cjs/helpers/useRenderElement.native.cjs +0 -53
- package/dist/cjs/helpers/useRenderElement.native.js +0 -55
- package/dist/cjs/helpers/useRenderElement.native.js.map +0 -1
- package/dist/esm/constants/accessibilityDirectMap.mjs +0 -8
- package/dist/esm/constants/accessibilityDirectMap.mjs.map +0 -1
- package/dist/esm/constants/accessibilityDirectMap.native.js +0 -8
- package/dist/esm/constants/accessibilityDirectMap.native.js.map +0 -1
- package/dist/esm/helpers/directStyle.mjs +0 -929
- package/dist/esm/helpers/directStyle.mjs.map +0 -1
- package/dist/esm/helpers/directStyle.native.js +0 -1132
- package/dist/esm/helpers/directStyle.native.js.map +0 -1
- package/dist/esm/helpers/frontendProgram.mjs +0 -20
- package/dist/esm/helpers/frontendProgram.mjs.map +0 -1
- package/dist/esm/helpers/frontendProgram.native.js +0 -24
- package/dist/esm/helpers/frontendProgram.native.js.map +0 -1
- package/dist/esm/helpers/getFontLanguage.mjs +0 -4
- package/dist/esm/helpers/getFontLanguage.mjs.map +0 -1
- package/dist/esm/helpers/getFontLanguage.native.js +0 -6
- package/dist/esm/helpers/getFontLanguage.native.js.map +0 -1
- package/dist/esm/helpers/normalizeStylePropKeys.mjs +0 -4
- package/dist/esm/helpers/normalizeStylePropKeys.mjs.map +0 -1
- package/dist/esm/helpers/normalizeStylePropKeys.native.js +0 -15
- package/dist/esm/helpers/normalizeStylePropKeys.native.js.map +0 -1
- package/dist/esm/helpers/propMapper.mjs +0 -360
- package/dist/esm/helpers/propMapper.mjs.map +0 -1
- package/dist/esm/helpers/propMapper.native.js +0 -511
- package/dist/esm/helpers/propMapper.native.js.map +0 -1
- package/dist/esm/helpers/useRenderElement.mjs +0 -26
- package/dist/esm/helpers/useRenderElement.mjs.map +0 -1
- package/dist/esm/helpers/useRenderElement.native.js +0 -31
- package/dist/esm/helpers/useRenderElement.native.js.map +0 -1
- package/src/constants/accessibilityDirectMap.native.tsx +0 -10
- package/src/constants/accessibilityDirectMap.tsx +0 -11
- package/src/helpers/directStyle.ts +0 -2294
- package/src/helpers/frontendProgram.ts +0 -48
- package/src/helpers/getFontLanguage.ts +0 -2
- package/src/helpers/normalizeStylePropKeys.native.ts +0 -12
- package/src/helpers/normalizeStylePropKeys.ts +0 -3
- package/src/helpers/propMapper.ts +0 -721
- package/src/helpers/useRenderElement.tsx +0 -73
- package/types/constants/accessibilityDirectMap.d.ts +0 -6
- package/types/constants/accessibilityDirectMap.d.ts.map +0 -1
- package/types/constants/accessibilityDirectMap.native.d.ts +0 -6
- package/types/constants/accessibilityDirectMap.native.d.ts.map +0 -1
- package/types/helpers/directStyle.d.ts +0 -15
- package/types/helpers/directStyle.d.ts.map +0 -1
- package/types/helpers/frontendProgram.d.ts +0 -10
- package/types/helpers/frontendProgram.d.ts.map +0 -1
- package/types/helpers/getFontLanguage.d.ts +0 -2
- package/types/helpers/getFontLanguage.d.ts.map +0 -1
- package/types/helpers/normalizeStylePropKeys.d.ts +0 -2
- package/types/helpers/normalizeStylePropKeys.d.ts.map +0 -1
- package/types/helpers/normalizeStylePropKeys.native.d.ts +0 -13
- package/types/helpers/normalizeStylePropKeys.native.d.ts.map +0 -1
- package/types/helpers/propMapper.d.ts +0 -6
- package/types/helpers/propMapper.d.ts.map +0 -1
- package/types/helpers/useRenderElement.d.ts +0 -13
- package/types/helpers/useRenderElement.d.ts.map +0 -1
|
@@ -1,721 +0,0 @@
|
|
|
1
|
-
import { isAndroid } from '@tamagui/constants'
|
|
2
|
-
import { scanFlatValue, type FlatValueHandler } from '@tamagui/style-grammar/runtime'
|
|
3
|
-
import { isVariable } from '../createVariable'
|
|
4
|
-
import type {
|
|
5
|
-
GetStyleState,
|
|
6
|
-
PropMapper,
|
|
7
|
-
SplitStyleProps,
|
|
8
|
-
StyleResolver,
|
|
9
|
-
TamaguiInternalConfig,
|
|
10
|
-
Variable,
|
|
11
|
-
VariantSpreadFunction,
|
|
12
|
-
} from '../types'
|
|
13
|
-
import { variantResolverNames } from '../types'
|
|
14
|
-
import { isConditionalStyleObject, resolveClauseChain } from './directStyle'
|
|
15
|
-
import { expandStyle } from './expandStyle'
|
|
16
|
-
import { resolveVariableValue } from './resolveVariableValue'
|
|
17
|
-
import { getFontsForLanguage, getVariantExtras } from './getVariantExtras'
|
|
18
|
-
import { isObj } from './isObj'
|
|
19
|
-
import { normalizeStyle } from './normalizeStyle'
|
|
20
|
-
import { isRemValue, resolveRem } from './resolveRem'
|
|
21
|
-
import { expandSafeAreaValue, isSafeAreaKey } from './resolveSafeArea'
|
|
22
|
-
import { skipProps } from './skipProps'
|
|
23
|
-
import { styleOriginalValues } from './styleOriginalValues'
|
|
24
|
-
|
|
25
|
-
// reduces a conditional variant clause back to a flat value the downstream
|
|
26
|
-
// parser applies: string form (`"20 sm:40"`) when both sides are
|
|
27
|
-
// string-representable, otherwise the flat object form, which carries array
|
|
28
|
-
// and structured payloads faithfully. returns undefined only for the one
|
|
29
|
-
// unrepresentable mix: a clause-bearing string joined by a structured payload
|
|
30
|
-
export function appendFlatClause(
|
|
31
|
-
state: GetStyleState,
|
|
32
|
-
prev: unknown,
|
|
33
|
-
conditionSource: string,
|
|
34
|
-
value: unknown
|
|
35
|
-
): string | Record<string, any> | undefined {
|
|
36
|
-
if (typeof value === 'string' || typeof value === 'number') {
|
|
37
|
-
if (prev == null) return `${conditionSource}:${value}`
|
|
38
|
-
if (typeof prev === 'string' || typeof prev === 'number') {
|
|
39
|
-
return `${prev} ${conditionSource}:${value}`
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
if (prev == null) return { [conditionSource]: value }
|
|
43
|
-
if (typeof prev === 'string' && prev.includes(':')) return
|
|
44
|
-
if (
|
|
45
|
-
typeof prev === 'object' &&
|
|
46
|
-
!Array.isArray(prev) &&
|
|
47
|
-
!isVariable(prev) &&
|
|
48
|
-
isConditionalStyleObject(state, prev as Record<string, any>)
|
|
49
|
-
) {
|
|
50
|
-
return { ...(prev as Record<string, any>), [conditionSource]: value }
|
|
51
|
-
}
|
|
52
|
-
return { default: prev, [conditionSource]: value }
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// pass state, source, saw chain, then payload/chain offset quadruples. only
|
|
56
|
-
// numeric offsets survive while authored variant code runs.
|
|
57
|
-
type VariantScanContext = any[]
|
|
58
|
-
|
|
59
|
-
const propMapperHandler: FlatValueHandler<VariantScanContext> = {
|
|
60
|
-
segment(ctx, start, end, isBase, valid, source, chainStart, chainEnd, chainValid) {
|
|
61
|
-
if (isBase) {
|
|
62
|
-
if (valid && start < end) ctx.push(start, end, -1, -1)
|
|
63
|
-
return
|
|
64
|
-
}
|
|
65
|
-
if (!chainValid) return
|
|
66
|
-
const condition = resolveClauseChain(ctx[0], source, chainStart, chainEnd)
|
|
67
|
-
if (condition && valid && start < end) {
|
|
68
|
-
ctx.push(start, end, chainStart, chainEnd)
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
chain(ctx) {
|
|
72
|
-
ctx[2] = true
|
|
73
|
-
return true
|
|
74
|
-
},
|
|
75
|
-
error(ctx) {
|
|
76
|
-
ctx[2] = true
|
|
77
|
-
},
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export const propMapper: PropMapper = (key, value, styleState, disabled, map) => {
|
|
81
|
-
if (disabled) {
|
|
82
|
-
return map(key, value)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (!(process.env.TAMAGUI_TARGET === 'native' && isAndroid)) {
|
|
86
|
-
// this shouldnt be necessary and handled in the outer loop
|
|
87
|
-
if (key === 'elevationAndroid') return
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const { conf, styleProps, staticConfig } = styleState
|
|
91
|
-
const { variants } = staticConfig
|
|
92
|
-
|
|
93
|
-
// "unset" is a CSS-wide keyword: valid CSS on web, but React Native
|
|
94
|
-
// style props reject it (e.g. aspectRatio throws "must be a number, a
|
|
95
|
-
// ratio string or `auto`"). On native, clear anything an earlier prop or
|
|
96
|
-
// styled default already merged for this key — matching web, where unset
|
|
97
|
-
// resets toward initial — then drop the value so RN never sees it.
|
|
98
|
-
if (process.env.TAMAGUI_TARGET === 'native' && value === 'unset') {
|
|
99
|
-
const expandedKey =
|
|
100
|
-
(!styleProps.disableExpandShorthands && conf.shorthands[key]) || key
|
|
101
|
-
const expanded = styleProps.noExpand
|
|
102
|
-
? null
|
|
103
|
-
: expandStyle(expandedKey, value, conf.settings.styleCompat || 'web')
|
|
104
|
-
if (styleState.style) {
|
|
105
|
-
if (expanded) {
|
|
106
|
-
for (const [nkey] of expanded) {
|
|
107
|
-
delete styleState.style[nkey]
|
|
108
|
-
}
|
|
109
|
-
} else {
|
|
110
|
-
delete styleState.style[expandedKey]
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (!styleProps.noExpand) {
|
|
117
|
-
if (variants && key in variants) {
|
|
118
|
-
const variantValue = resolveVariants(key, value, styleProps, styleState, '')
|
|
119
|
-
if (variantValue) {
|
|
120
|
-
for (const entry of variantValue) {
|
|
121
|
-
map(entry[0], entry[1], entry[2], entry[3])
|
|
122
|
-
}
|
|
123
|
-
return
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// handle shorthands
|
|
129
|
-
if (!styleProps.disableExpandShorthands) {
|
|
130
|
-
if (key in conf.shorthands) {
|
|
131
|
-
key = conf.shorthands[key]
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// Capture original value before resolution (for context prop tracking)
|
|
136
|
-
const originalValue = value
|
|
137
|
-
|
|
138
|
-
// "safe" value -> env(safe-area-inset-*) on web, numeric inset on native.
|
|
139
|
-
// expands multi-edge props (padding, inset, marginHorizontal, ...) into
|
|
140
|
-
// per-side keys so each side gets its own edge value.
|
|
141
|
-
if (value === 'safe' && isSafeAreaKey(key)) {
|
|
142
|
-
const expanded = expandSafeAreaValue(key)
|
|
143
|
-
if (expanded) {
|
|
144
|
-
for (let i = 0; i < expanded.length; i++) {
|
|
145
|
-
const [nkey, nvalue] = expanded[i]
|
|
146
|
-
map(nkey, nvalue, originalValue)
|
|
147
|
-
}
|
|
148
|
-
return
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if (value != null) {
|
|
153
|
-
if (typeof value === 'string') {
|
|
154
|
-
value = isRemValue(value) ? resolveRem(value) : value
|
|
155
|
-
} else if (isVariable(value)) {
|
|
156
|
-
value = resolveVariableValue(key, value, styleProps.resolveValues)
|
|
157
|
-
} else if (isRemValue(value)) {
|
|
158
|
-
value = resolveRem(value)
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// strings stay whole so the direct scanner can distinguish CSS components
|
|
163
|
-
// from modifier clauses before it emits them.
|
|
164
|
-
|
|
165
|
-
if (value != null) {
|
|
166
|
-
if (key === 'fontFamily' && typeof originalValue === 'string') {
|
|
167
|
-
if (originalValue in conf.fontsParsed) {
|
|
168
|
-
styleState.fontFamily = originalValue
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// strings stay whole for the direct flat-value scanner
|
|
173
|
-
const expanded =
|
|
174
|
-
styleProps.noExpand || typeof value === 'string'
|
|
175
|
-
? null
|
|
176
|
-
: expandStyle(key, value, conf.settings.styleCompat || 'web')
|
|
177
|
-
|
|
178
|
-
if (expanded) {
|
|
179
|
-
const max = expanded.length
|
|
180
|
-
for (let i = 0; i < max; i++) {
|
|
181
|
-
const [nkey, nvalue, noriginalValue] = expanded[i]
|
|
182
|
-
map(nkey, nvalue, noriginalValue ?? originalValue)
|
|
183
|
-
}
|
|
184
|
-
} else {
|
|
185
|
-
map(key, value, originalValue)
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
const resolveVariants: StyleResolver = (
|
|
191
|
-
key,
|
|
192
|
-
value,
|
|
193
|
-
styleProps,
|
|
194
|
-
styleState,
|
|
195
|
-
parentVariantKey
|
|
196
|
-
) => {
|
|
197
|
-
const variantDefinition = styleState.staticConfig.variants?.[key]
|
|
198
|
-
if (
|
|
199
|
-
typeof value === 'string' &&
|
|
200
|
-
value.indexOf(':') !== -1 &&
|
|
201
|
-
// a variant can define a literal colon key like "16:9" — an exact match
|
|
202
|
-
// wins over clause parsing
|
|
203
|
-
!(
|
|
204
|
-
variantDefinition &&
|
|
205
|
-
typeof variantDefinition === 'object' &&
|
|
206
|
-
value in variantDefinition
|
|
207
|
-
)
|
|
208
|
-
) {
|
|
209
|
-
// `scanFlatValue` is the same lexer `contributeStyleString` and the
|
|
210
|
-
// canonical `parseValue` run, and `resolveClauseChain` is the same modifier
|
|
211
|
-
// resolver the style path uses. A refused chain invalidates only its own
|
|
212
|
-
// payload, and the shared lexer continues to later clauses.
|
|
213
|
-
const scan: VariantScanContext = [styleState, value, false]
|
|
214
|
-
|
|
215
|
-
scanFlatValue(value, propMapperHandler, scan)
|
|
216
|
-
|
|
217
|
-
if (scan[2]) {
|
|
218
|
-
let entries: [string, any, any?, string?][] | undefined
|
|
219
|
-
for (let index = 3; index < scan.length; index += 4) {
|
|
220
|
-
const resolved = resolveVariantValue(
|
|
221
|
-
key,
|
|
222
|
-
value.slice(scan[index] as number, scan[index + 1] as number),
|
|
223
|
-
styleProps,
|
|
224
|
-
styleState,
|
|
225
|
-
parentVariantKey
|
|
226
|
-
)
|
|
227
|
-
if (!resolved) continue
|
|
228
|
-
entries ||= []
|
|
229
|
-
const chainStart = scan[index + 2] as number
|
|
230
|
-
const modifier =
|
|
231
|
-
chainStart === -1
|
|
232
|
-
? undefined
|
|
233
|
-
: value.slice(chainStart, scan[index + 3] as number)
|
|
234
|
-
for (const entry of resolved) {
|
|
235
|
-
if (modifier !== undefined) entry[3] = modifier
|
|
236
|
-
entries.push(entry)
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
return entries || []
|
|
240
|
-
}
|
|
241
|
-
// no clause structure found: the colon belongs to the value itself
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
// the object spelling of a conditional variant prop mirrors the clause
|
|
245
|
-
// string: density={{ default: 'compact', sm: 'roomy' }}. a payload object
|
|
246
|
-
// with no default and no modifier first key (a functional variant's own
|
|
247
|
-
// argument shape) falls through whole
|
|
248
|
-
if (
|
|
249
|
-
value &&
|
|
250
|
-
typeof value === 'object' &&
|
|
251
|
-
!Array.isArray(value) &&
|
|
252
|
-
!isVariable(value) &&
|
|
253
|
-
isConditionalStyleObject(styleState, value)
|
|
254
|
-
) {
|
|
255
|
-
let entries: [string, any, any?, string?][] | undefined
|
|
256
|
-
for (const objKey in value) {
|
|
257
|
-
const payload = value[objKey]
|
|
258
|
-
if (payload == null) continue
|
|
259
|
-
const resolved = resolveVariantValue(
|
|
260
|
-
key,
|
|
261
|
-
payload,
|
|
262
|
-
styleProps,
|
|
263
|
-
styleState,
|
|
264
|
-
parentVariantKey
|
|
265
|
-
)
|
|
266
|
-
if (!resolved) continue
|
|
267
|
-
entries ||= []
|
|
268
|
-
for (const entry of resolved) {
|
|
269
|
-
if (objKey !== 'default') entry[3] = objKey
|
|
270
|
-
entries.push(entry)
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
return entries || []
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
return resolveVariantValue(key, value, styleProps, styleState, parentVariantKey)
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
const resolveVariantValue: StyleResolver = (
|
|
280
|
-
key,
|
|
281
|
-
value,
|
|
282
|
-
styleProps,
|
|
283
|
-
styleState,
|
|
284
|
-
parentVariantKey
|
|
285
|
-
) => {
|
|
286
|
-
const { staticConfig, conf, debug } = styleState
|
|
287
|
-
const { variants } = staticConfig
|
|
288
|
-
if (!variants) return
|
|
289
|
-
|
|
290
|
-
const variant = variants[key]
|
|
291
|
-
let variantValue = getVariantDefinition(variant, value, conf, styleState)
|
|
292
|
-
|
|
293
|
-
if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
|
|
294
|
-
console.groupCollapsed(`♦️♦️♦️ resolve variant ${key}`)
|
|
295
|
-
console.info({
|
|
296
|
-
key,
|
|
297
|
-
value,
|
|
298
|
-
variantValue,
|
|
299
|
-
variants,
|
|
300
|
-
})
|
|
301
|
-
console.groupEnd()
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
if (!variantValue) {
|
|
305
|
-
// variant at key exists, but no matching variant
|
|
306
|
-
// disabling warnings, its fine to pass through, could re-enable later somehoiw
|
|
307
|
-
if (process.env.TAMAGUI_WARN_ON_MISSING_VARIANT === '1') {
|
|
308
|
-
// don't warn on missing booleans
|
|
309
|
-
if (typeof value !== 'boolean') {
|
|
310
|
-
const name = styleState.styleProps.displayName || '[UnnamedComponent]'
|
|
311
|
-
console.warn(
|
|
312
|
-
`No variant found: ${name} has variant "${key}", but no matching value "${value}"`
|
|
313
|
-
)
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
return
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
if (typeof variantValue === 'function') {
|
|
320
|
-
const fn = variantValue as VariantSpreadFunction<any>
|
|
321
|
-
const extras = getVariantExtras(styleState)
|
|
322
|
-
variantValue = fn(value, extras)
|
|
323
|
-
|
|
324
|
-
if (
|
|
325
|
-
process.env.NODE_ENV === 'development' &&
|
|
326
|
-
debug === 'verbose' &&
|
|
327
|
-
process.env.TAMAGUI_TARGET !== 'native'
|
|
328
|
-
) {
|
|
329
|
-
console.groupCollapsed(' expanded functional variant', key)
|
|
330
|
-
console.info({ fn, variantValue, extras })
|
|
331
|
-
console.groupEnd()
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
let fontFamilyResult: any
|
|
336
|
-
|
|
337
|
-
if (isObj(variantValue)) {
|
|
338
|
-
const fontFamilyUpdate =
|
|
339
|
-
variantValue.fontFamily || variantValue[conf.inverseShorthands.fontFamily]
|
|
340
|
-
|
|
341
|
-
if (fontFamilyUpdate) {
|
|
342
|
-
fontFamilyResult = getFontFamilyFromNameOrVariable(fontFamilyUpdate, conf)
|
|
343
|
-
styleState.fontFamily = fontFamilyResult
|
|
344
|
-
|
|
345
|
-
if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
|
|
346
|
-
console.info(` updating font family`, fontFamilyResult)
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
variantValue = resolveTokensAndVariants(
|
|
351
|
-
key,
|
|
352
|
-
variantValue,
|
|
353
|
-
styleProps,
|
|
354
|
-
styleState,
|
|
355
|
-
parentVariantKey
|
|
356
|
-
)
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
if (variantValue) {
|
|
360
|
-
const expanded = normalizeStyle(variantValue, !!styleProps.noNormalize)
|
|
361
|
-
|
|
362
|
-
if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
|
|
363
|
-
console.info(` expanding styles from `, variantValue, `to`, expanded)
|
|
364
|
-
}
|
|
365
|
-
const originalValues = styleOriginalValues.get(expanded)
|
|
366
|
-
|
|
367
|
-
// store any changed font family (only support variables for now)
|
|
368
|
-
const next: [string, any, any, string?][] = []
|
|
369
|
-
for (const key in expanded) {
|
|
370
|
-
next.push([key, expanded[key], originalValues?.[key]])
|
|
371
|
-
}
|
|
372
|
-
return next
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
// handles finding and resolving the fontFamily to the token name
|
|
377
|
-
// this is used as `font_[name]` in className for nice css variable support
|
|
378
|
-
export function getFontFamilyFromNameOrVariable(input: any, conf: TamaguiInternalConfig) {
|
|
379
|
-
if (isVariable(input)) {
|
|
380
|
-
const val = variableToFontNameCache.get(input)
|
|
381
|
-
if (val) return val
|
|
382
|
-
for (const key in conf.fontsParsed) {
|
|
383
|
-
const familyVariable = conf.fontsParsed[key].family
|
|
384
|
-
if (isVariable(familyVariable)) {
|
|
385
|
-
variableToFontNameCache.set(familyVariable, key)
|
|
386
|
-
if (familyVariable === input) {
|
|
387
|
-
return key
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
} else if (typeof input === 'string' && input in conf.fontsParsed) {
|
|
392
|
-
return input
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
const variableToFontNameCache = new WeakMap<Variable, string>()
|
|
397
|
-
|
|
398
|
-
const resolveTokensAndVariants: StyleResolver<object> = (
|
|
399
|
-
key, // we dont use key assume value is object instead
|
|
400
|
-
value,
|
|
401
|
-
styleProps,
|
|
402
|
-
styleState,
|
|
403
|
-
parentVariantKey
|
|
404
|
-
) => {
|
|
405
|
-
const { conf, staticConfig, debug } = styleState
|
|
406
|
-
const { variants } = staticConfig
|
|
407
|
-
const res = {}
|
|
408
|
-
let originalValues: Record<string, any> | undefined
|
|
409
|
-
|
|
410
|
-
if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
|
|
411
|
-
console.info(` - resolveTokensAndVariants`, key, value)
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
for (const _key in value) {
|
|
415
|
-
const subKey = conf.shorthands[_key] || _key
|
|
416
|
-
const val = value[_key]
|
|
417
|
-
|
|
418
|
-
if (!styleProps.noSkip && subKey in skipProps) {
|
|
419
|
-
continue
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
originalValues ||= {}
|
|
423
|
-
originalValues[subKey] = val
|
|
424
|
-
|
|
425
|
-
// Track context overrides for any key that's in context props (issues #3670, #3676)
|
|
426
|
-
// Store the ORIGINAL token value (like '8') before resolution so that
|
|
427
|
-
// children's functional variants can look up token values
|
|
428
|
-
if (staticConfig) {
|
|
429
|
-
const contextProps =
|
|
430
|
-
staticConfig.context?.props || staticConfig.parentStaticConfig?.context?.props
|
|
431
|
-
const inheritedContextPropKeys =
|
|
432
|
-
!staticConfig.context ||
|
|
433
|
-
staticConfig.context === staticConfig.parentStaticConfig?.context
|
|
434
|
-
? staticConfig.parentStaticConfig?.contextProps
|
|
435
|
-
: undefined
|
|
436
|
-
const contextPropKeys = staticConfig.contextProps || inheritedContextPropKeys
|
|
437
|
-
const isContextProp =
|
|
438
|
-
(contextProps && subKey in contextProps) ||
|
|
439
|
-
contextPropKeys?.includes(subKey) ||
|
|
440
|
-
staticConfig.context?.propKeys?.includes(subKey) ||
|
|
441
|
-
staticConfig.parentStaticConfig?.context?.propKeys?.includes(subKey)
|
|
442
|
-
if (isContextProp) {
|
|
443
|
-
styleState.overriddenContextProps ||= {}
|
|
444
|
-
styleState.overriddenContextProps[subKey] = val
|
|
445
|
-
// Also track the original token value separately
|
|
446
|
-
styleState.originalContextPropValues ||= {}
|
|
447
|
-
styleState.originalContextPropValues[subKey] = val
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
if (styleProps.noExpand) {
|
|
452
|
-
res[subKey] = val
|
|
453
|
-
} else {
|
|
454
|
-
if (variants && subKey in variants) {
|
|
455
|
-
// avoids infinite loop if variant is matching a style prop
|
|
456
|
-
// eg: { variants: { flex: { true: { flex: 2 } } } }
|
|
457
|
-
if (parentVariantKey && parentVariantKey === key) {
|
|
458
|
-
res[subKey] = val
|
|
459
|
-
} else {
|
|
460
|
-
const variantOut = resolveVariants(subKey, val, styleProps, styleState, key)
|
|
461
|
-
|
|
462
|
-
// apply variant output in authored order
|
|
463
|
-
if (variantOut) {
|
|
464
|
-
for (const [key, val, originalVal, conditionSource] of variantOut) {
|
|
465
|
-
if (val == null) continue
|
|
466
|
-
if (conditionSource !== undefined) {
|
|
467
|
-
const appended = appendFlatClause(
|
|
468
|
-
styleState,
|
|
469
|
-
res[key],
|
|
470
|
-
conditionSource,
|
|
471
|
-
val
|
|
472
|
-
)
|
|
473
|
-
if (appended === undefined) {
|
|
474
|
-
if (process.env.NODE_ENV === 'development') {
|
|
475
|
-
console.warn(
|
|
476
|
-
`[tamagui] conditional variant value for "${key}" cannot join the existing clause string; dropping the clause`
|
|
477
|
-
)
|
|
478
|
-
}
|
|
479
|
-
continue
|
|
480
|
-
}
|
|
481
|
-
res[key] = appended
|
|
482
|
-
continue
|
|
483
|
-
}
|
|
484
|
-
res[key] = val
|
|
485
|
-
if (originalVal !== undefined) {
|
|
486
|
-
originalValues ||= {}
|
|
487
|
-
originalValues[key] = originalVal
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
continue
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
if (isVariable(val)) {
|
|
497
|
-
res[subKey] = resolveVariableValue(subKey, val, styleProps.resolveValues)
|
|
498
|
-
|
|
499
|
-
if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
|
|
500
|
-
console.info(`variable`, subKey, res[subKey])
|
|
501
|
-
}
|
|
502
|
-
continue
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
if (typeof val === 'string') {
|
|
506
|
-
res[subKey] = isRemValue(val) ? resolveRem(val) : val
|
|
507
|
-
continue
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
if (isObj(val)) {
|
|
511
|
-
const subObject = resolveTokensAndVariants(subKey, val, styleProps, styleState, key)
|
|
512
|
-
|
|
513
|
-
if (process.env.NODE_ENV === 'development' && debug === 'verbose') {
|
|
514
|
-
console.info(`object`, subKey, subObject)
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
// structured style values such as shadowOffset
|
|
518
|
-
res[subKey] ??= {}
|
|
519
|
-
Object.assign(res[subKey], subObject)
|
|
520
|
-
const subOriginalValues = styleOriginalValues.get(subObject)
|
|
521
|
-
if (subOriginalValues) {
|
|
522
|
-
const existing = styleOriginalValues.get(res[subKey])
|
|
523
|
-
if (existing) {
|
|
524
|
-
Object.assign(existing, subOriginalValues)
|
|
525
|
-
} else {
|
|
526
|
-
styleOriginalValues.set(res[subKey], { ...subOriginalValues })
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
} else {
|
|
530
|
-
// nullish values cant be tokens, need no extra parsing
|
|
531
|
-
res[subKey] = val
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
if (originalValues) {
|
|
536
|
-
styleOriginalValues.set(res, originalValues)
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
return res
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
// the prop -> token-category tables live in their own module; re-exported
|
|
543
|
-
// here because they have always been part of this module's public surface
|
|
544
|
-
export * from './tokenCategories'
|
|
545
|
-
|
|
546
|
-
// goes through specificity finding best matching variant function
|
|
547
|
-
function getVariantDefinition(
|
|
548
|
-
variant: any,
|
|
549
|
-
value: any,
|
|
550
|
-
conf: TamaguiInternalConfig,
|
|
551
|
-
{ theme }: Partial<GetStyleState>
|
|
552
|
-
): any {
|
|
553
|
-
if (!variant) return
|
|
554
|
-
if (value === undefined) return
|
|
555
|
-
if (typeof variant === 'function') {
|
|
556
|
-
return variant
|
|
557
|
-
}
|
|
558
|
-
if (Object.prototype.hasOwnProperty.call(variant, value)) {
|
|
559
|
-
return variant[value]
|
|
560
|
-
}
|
|
561
|
-
for (const { key, parts } of getCompiledVariantResolvers(variant)) {
|
|
562
|
-
for (const part of parts) {
|
|
563
|
-
if (matchesVariantResolver(part, value, conf, theme)) {
|
|
564
|
-
return variant[key]
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
return
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
type VariantResolverName = (typeof variantResolverNames)[number]
|
|
573
|
-
|
|
574
|
-
const variantResolverNameSet = new Set<string>(variantResolverNames)
|
|
575
|
-
|
|
576
|
-
type CompiledVariantResolver = {
|
|
577
|
-
key: string
|
|
578
|
-
parts: VariantResolverName[]
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
const variantResolverCache = new WeakMap<object, readonly CompiledVariantResolver[]>()
|
|
582
|
-
|
|
583
|
-
function getCompiledVariantResolvers(variant: object) {
|
|
584
|
-
let cached = variantResolverCache.get(variant)
|
|
585
|
-
if (cached) {
|
|
586
|
-
return cached
|
|
587
|
-
}
|
|
588
|
-
const compiled: CompiledVariantResolver[] = []
|
|
589
|
-
for (const key of Object.keys(variant)) {
|
|
590
|
-
const parts = parseVariantResolverKey(key)
|
|
591
|
-
if (parts) {
|
|
592
|
-
compiled.push({ key, parts })
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
variantResolverCache.set(variant, compiled)
|
|
596
|
-
return compiled
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
function parseVariantResolverKey(key: string): VariantResolverName[] | null {
|
|
600
|
-
if (!key) return null
|
|
601
|
-
const parts = key.split('|').map((part) => part.trim())
|
|
602
|
-
if (!parts.length) return null
|
|
603
|
-
for (const part of parts) {
|
|
604
|
-
if (!variantResolverNameSet.has(part)) {
|
|
605
|
-
return null
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
return parts as VariantResolverName[]
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
const numberStringPattern =
|
|
612
|
-
/[+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))(?:[eE][+-]?\d+)?|[+-]?0[xX][\da-fA-F]+|[+-]?0[bB][01]+|[+-]?0[oO][0-7]+/
|
|
613
|
-
const remStringPattern = new RegExp(`^(?:${numberStringPattern.source})rem$`)
|
|
614
|
-
const viewportValuePattern = new RegExp(
|
|
615
|
-
`^(?:${numberStringPattern.source})(vw|dvw|lvw|svw|vh|dvh|lvh|svh)$`
|
|
616
|
-
)
|
|
617
|
-
|
|
618
|
-
function isAllowedStyleValue(
|
|
619
|
-
category: 'size' | 'space' | 'radius' | 'zIndex',
|
|
620
|
-
value: any,
|
|
621
|
-
conf: TamaguiInternalConfig,
|
|
622
|
-
string: boolean,
|
|
623
|
-
number: boolean,
|
|
624
|
-
rem: boolean
|
|
625
|
-
) {
|
|
626
|
-
const hasSetting = Object.prototype.hasOwnProperty.call(
|
|
627
|
-
conf.settings,
|
|
628
|
-
'allowedStyleValues'
|
|
629
|
-
)
|
|
630
|
-
const configured = conf.settings.allowedStyleValues
|
|
631
|
-
const setting =
|
|
632
|
-
configured && typeof configured === 'object' ? configured[category] : configured
|
|
633
|
-
const web =
|
|
634
|
-
value === 'unset' ||
|
|
635
|
-
value === 'inherit' ||
|
|
636
|
-
(string && /^var\(.*\)$/.test(value)) ||
|
|
637
|
-
((category === 'size' || category === 'space') &&
|
|
638
|
-
(value === 'max-content' ||
|
|
639
|
-
value === 'min-content' ||
|
|
640
|
-
(string &&
|
|
641
|
-
(viewportValuePattern.test(value) || /^(calc|min|max)\(.*\)$/.test(value)))))
|
|
642
|
-
const somewhat =
|
|
643
|
-
category === 'size' || category === 'space'
|
|
644
|
-
? value === 'auto' || number || rem || (string && value.endsWith('%'))
|
|
645
|
-
: number
|
|
646
|
-
if (setting === 'strict') return false
|
|
647
|
-
if (setting === 'strict-web') return web
|
|
648
|
-
if (setting === 'somewhat-strict') return somewhat
|
|
649
|
-
if (setting === 'somewhat-strict-web') return somewhat || web
|
|
650
|
-
return (
|
|
651
|
-
number || (string && (category === 'size' || category === 'space' || !hasSetting))
|
|
652
|
-
)
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
function matchesVariantResolver(
|
|
656
|
-
resolverName: VariantResolverName,
|
|
657
|
-
value: any,
|
|
658
|
-
conf: TamaguiInternalConfig,
|
|
659
|
-
theme: Partial<GetStyleState>['theme']
|
|
660
|
-
) {
|
|
661
|
-
const string = typeof value === 'string'
|
|
662
|
-
const number = typeof value === 'number'
|
|
663
|
-
const rem = string && remStringPattern.test(value)
|
|
664
|
-
|
|
665
|
-
switch (resolverName) {
|
|
666
|
-
case 'Size':
|
|
667
|
-
case 'Space':
|
|
668
|
-
case 'Radius':
|
|
669
|
-
case 'ZIndex': {
|
|
670
|
-
const category =
|
|
671
|
-
resolverName === 'ZIndex'
|
|
672
|
-
? 'zIndex'
|
|
673
|
-
: (resolverName.toLowerCase() as 'size' | 'space' | 'radius')
|
|
674
|
-
return (
|
|
675
|
-
value === true ||
|
|
676
|
-
(value != null && value in conf.tokensParsed[category]) ||
|
|
677
|
-
((resolverName === 'Space' ||
|
|
678
|
-
resolverName === 'Radius' ||
|
|
679
|
-
resolverName === 'ZIndex') &&
|
|
680
|
-
isVariable(value)) ||
|
|
681
|
-
((resolverName === 'Radius' || resolverName === 'ZIndex') && (number || rem)) ||
|
|
682
|
-
isAllowedStyleValue(category, value, conf, string, number, rem)
|
|
683
|
-
)
|
|
684
|
-
}
|
|
685
|
-
// a token or theme color, otherwise any string is taken to be a raw CSS
|
|
686
|
-
// color and left for the browser to resolve. checking that against a CSS
|
|
687
|
-
// color-name table costs 2.3KB gzip to reject values that were never valid
|
|
688
|
-
// anyway. `red/50` opacity modifiers stay limited to token and theme
|
|
689
|
-
// colors, which the branches above already covered.
|
|
690
|
-
case 'Color':
|
|
691
|
-
return (value != null && value in conf.tokensParsed.color) || string
|
|
692
|
-
case 'Theme':
|
|
693
|
-
return string && !!theme && value in theme
|
|
694
|
-
case 'FontSize':
|
|
695
|
-
return value === true || !!conf.fontsParsed.body?.size?.[value] || number || rem
|
|
696
|
-
case 'FontStyle':
|
|
697
|
-
return (
|
|
698
|
-
!!conf.fontsParsed.body?.style?.[value] ||
|
|
699
|
-
value === 'normal' ||
|
|
700
|
-
value === 'italic'
|
|
701
|
-
)
|
|
702
|
-
case 'FontTransform':
|
|
703
|
-
return (
|
|
704
|
-
!!conf.fontsParsed.body?.transform?.[value] ||
|
|
705
|
-
value === 'none' ||
|
|
706
|
-
value === 'capitalize' ||
|
|
707
|
-
value === 'uppercase' ||
|
|
708
|
-
value === 'lowercase'
|
|
709
|
-
)
|
|
710
|
-
case 'FontLineHeight':
|
|
711
|
-
return !!conf.fontsParsed.body?.lineHeight?.[value] || number || rem
|
|
712
|
-
case 'FontLetterSpacing':
|
|
713
|
-
return !!conf.fontsParsed.body?.letterSpacing?.[value] || number || rem
|
|
714
|
-
case 'number':
|
|
715
|
-
case 'string':
|
|
716
|
-
case 'boolean':
|
|
717
|
-
return typeof value === resolverName
|
|
718
|
-
case 'any':
|
|
719
|
-
return true
|
|
720
|
-
}
|
|
721
|
-
}
|