@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,296 +1,740 @@
|
|
|
1
|
-
import { isClient,
|
|
2
|
-
import {
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { STYLE_FRONTEND_PASSTHROUGH_PREFIX, STYLE_FRONTEND_PREPROCESSED } from "./styleFrontend.mjs";
|
|
1
|
+
import { isClient, platformMatches } from "@tamagui/constants";
|
|
2
|
+
import { nonAnimatableStyleProps, stylePropsAll, stylePropsText, stylePropsTransform, tokenCategories, validStyles } from "@tamagui/helpers";
|
|
5
3
|
import { getConfig } from "../config.mjs";
|
|
6
4
|
import { isVariable } from "../createVariable.mjs";
|
|
7
5
|
import { isDevTools } from "../constants/isDevTools.mjs";
|
|
8
|
-
import { mediaState } from "./mediaState.mjs";
|
|
9
|
-
import {
|
|
6
|
+
import { mediaKeyMatch, mediaState } from "./mediaState.mjs";
|
|
7
|
+
import { variantResolverNames } from "../types.mjs";
|
|
8
|
+
import { addTransformValue, canonicalStateModifierNames, createTransformAccumulator, finalizeTransformAccumulator, getTransformPartKeys, isContainerSizeQueryText, isModifierName, modifierKindMedia, modifierKindPlatform, modifierKindState, modifierKindTheme, removeTransformValue, scanFlatValue, stateModifierSelectors } from "@tamagui/style-grammar/runtime";
|
|
9
|
+
import { warnOnce, warnRefusedValue } from "./warnOnce.mjs";
|
|
10
|
+
import { expandStyle } from "./expandStyle.mjs";
|
|
10
11
|
import { fixStyles } from "./expandStyles.mjs";
|
|
11
|
-
import { styleToCSS } from "./
|
|
12
|
+
import { styleToCSS } from "./styleToCSS.mjs";
|
|
13
|
+
import { addComposition, canGenerateCSS, clearFrameAtomic, completeStreamingCSS, directStyleSignature, flushDirectStyles, flushDirectStyles as flushDirectStyles2, requestBorderStyleDefault, streamAtomic } from "./directStyleCSS.mjs";
|
|
14
|
+
import { getConfigRevisionState } from "./grammarConfig.mjs";
|
|
12
15
|
import { getDefaultProps } from "./getDefaultProps.mjs";
|
|
13
|
-
import {
|
|
14
|
-
import { isPlainObject } from "./isObj.mjs";
|
|
16
|
+
import { isObj, isPlainObject } from "./isObj.mjs";
|
|
15
17
|
import { log } from "./log.mjs";
|
|
18
|
+
import { normalizeStyle } from "./normalizeStyle.mjs";
|
|
19
|
+
import { normalizeColor } from "./normalizeColor.mjs";
|
|
16
20
|
import { normalizeValueWithProperty } from "./normalizeValueWithProperty.mjs";
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
21
|
+
import { getVariantExtras } from "./getVariantExtras.mjs";
|
|
22
|
+
import { isRemValue, resolveRem } from "./resolveRem.mjs";
|
|
23
|
+
import { expandSafeAreaValue, isSafeAreaKey } from "./resolveSafeArea.mjs";
|
|
24
|
+
import { resolveSafeAreaVariable } from "./resolveSafeAreaVariable.mjs";
|
|
25
|
+
import { resolveVariableValue } from "./resolveVariableValue.mjs";
|
|
26
|
+
import { THEME_REF_PREFIX } from "./themeRef.mjs";
|
|
27
|
+
import { getTokenCategoryForProperty, tokenCategoryByProperty } from "./tokenCategories.mjs";
|
|
28
|
+
import { HOC_CLASSNAME_MARKER, skipProps } from "./skipProps.mjs";
|
|
22
29
|
import { styleOriginalValues } from "./styleOriginalValues.mjs";
|
|
23
30
|
import { STYLE_TOKEN_PROVENANCE_KEY, getStyleTokenProvenance, setStyleTokenProvenance } from "./styleProvenance.mjs";
|
|
24
31
|
import { transformsToString } from "./transformsToString.mjs";
|
|
25
32
|
|
|
33
|
+
export * from "./tokenCategories.mjs"
|
|
34
|
+
|
|
35
|
+
const TAMAGUI_CLASS_PROPS = "$$tamaguiClassProps";
|
|
26
36
|
const shouldTrackStyleTokenProvenance = process.env.NODE_ENV === "development" && process.env.TAMAGUI_ENABLE_STYLE_TOKEN_PROVENANCE === "1";
|
|
27
|
-
const validComponentClassName = /^[A-Za-z_][A-Za-z0-9_-]*$/;
|
|
28
37
|
function compoundMatcherMatches(expected, actual) {
|
|
29
|
-
if (Array.isArray(expected))
|
|
30
|
-
|
|
38
|
+
if (Array.isArray(expected)) {
|
|
39
|
+
for (let index = 0; index < expected.length; index++) if (expected[index] === actual) return true;
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
return expected === actual;
|
|
31
43
|
}
|
|
32
|
-
function compoundMatcherMatchesPayload(expected,
|
|
33
|
-
if (Array.isArray(expected))
|
|
34
|
-
|
|
44
|
+
function compoundMatcherMatchesPayload(expected, source, start, end) {
|
|
45
|
+
if (Array.isArray(expected)) {
|
|
46
|
+
for (let index = 0; index < expected.length; index++) if (compoundMatcherMatchesPayload(expected[index], source, start, end)) return true;
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
const expectedValue = typeof expected === "string" ? expected : String(expected);
|
|
50
|
+
if (expectedValue.length !== end - start) return false;
|
|
51
|
+
for (let index = 0; index < expectedValue.length; index++) if (expectedValue.charCodeAt(index) !== source.charCodeAt(start + index)) return false;
|
|
52
|
+
return true;
|
|
35
53
|
}
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
54
|
+
const preparedCompoundsKey = /* @__PURE__ */ Symbol();
|
|
55
|
+
function prepareStaticConfigCompounds(staticConfig) {
|
|
56
|
+
const compoundVariants = staticConfig.compoundVariants;
|
|
57
|
+
const preparedConfig = staticConfig;
|
|
58
|
+
if (!compoundVariants?.length) {
|
|
59
|
+
preparedConfig[preparedCompoundsKey] = null;
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const selectorCounts = [];
|
|
63
|
+
const indexesByKey = /* @__PURE__ */ Object.create(null);
|
|
64
|
+
indexesByKey[preparedCompoundsKey] = selectorCounts;
|
|
65
|
+
for (let index = 0; index < compoundVariants.length; index++) {
|
|
66
|
+
const compoundVariant = compoundVariants[index];
|
|
67
|
+
let selectorCount = 0;
|
|
68
|
+
for (const key in compoundVariant) {
|
|
69
|
+
if (key === "style") continue;
|
|
70
|
+
selectorCount++;
|
|
71
|
+
(indexesByKey[key] ||= []).push(index);
|
|
72
|
+
}
|
|
73
|
+
selectorCounts[index] = selectorCount;
|
|
74
|
+
}
|
|
75
|
+
preparedConfig[preparedCompoundsKey] = indexesByKey;
|
|
76
|
+
}
|
|
77
|
+
const conditionWidth = 4;
|
|
78
|
+
const conditionValueOffset = 0;
|
|
79
|
+
const conditionFlagsOffset = 1;
|
|
80
|
+
const conditionPrecedenceOffset = 2;
|
|
81
|
+
const conditionWrapperOffset = 3;
|
|
82
|
+
const conditionActiveFlag = 1;
|
|
83
|
+
const conditionEmitFlag = 2;
|
|
84
|
+
const conditionResolvedFlag = 4;
|
|
85
|
+
const conditionEnterFlag = 8;
|
|
86
|
+
const conditionExitFlag = 16;
|
|
87
|
+
const conditionPlatformPseudoFlag = 32;
|
|
88
|
+
const conditionInitialFlags = 7;
|
|
89
|
+
const conditionTextWidth = 5;
|
|
90
|
+
const conditionKeyOffset = 0;
|
|
91
|
+
const conditionSelectorOffset = 1;
|
|
92
|
+
const conditionThemeOffset = 2;
|
|
93
|
+
const conditionUnsupportedStateOffset = 3;
|
|
94
|
+
const conditionUnresolvedNameOffset = 4;
|
|
95
|
+
let conditionNumbers = /* @__PURE__ */ new Float64Array(2048);
|
|
96
|
+
const conditionTexts = [];
|
|
97
|
+
const conditionWrappers = [];
|
|
98
|
+
let conditionWrapperTop = 0;
|
|
99
|
+
let conditionCursorTop = conditionWidth;
|
|
100
|
+
function reserveConditionCursor(cursor) {
|
|
101
|
+
const required = cursor + conditionWidth;
|
|
102
|
+
if (required > conditionTexts.length) {
|
|
103
|
+
const previous2 = conditionTexts.length;
|
|
104
|
+
conditionTexts.length = required;
|
|
105
|
+
conditionTexts.fill("", previous2);
|
|
106
|
+
}
|
|
107
|
+
if (required <= conditionNumbers.length) return;
|
|
108
|
+
let length = conditionNumbers.length * 2;
|
|
109
|
+
while (length < required) length *= 2;
|
|
110
|
+
const previous = conditionNumbers;
|
|
111
|
+
conditionNumbers = new Float64Array(length);
|
|
112
|
+
conditionNumbers.set(previous);
|
|
113
|
+
}
|
|
114
|
+
function conditionWrapperCopy(cursor) {
|
|
115
|
+
const wrapper = conditionNumbers[cursor + conditionWrapperOffset];
|
|
116
|
+
const count = wrapper & 7;
|
|
117
|
+
if (!count) return void 0;
|
|
118
|
+
const start = wrapper >> 3;
|
|
119
|
+
const wrappers = new Array(count);
|
|
120
|
+
for (let index = 0; index < count; index++) wrappers[index] = conditionWrappers[start + index];
|
|
121
|
+
return wrappers;
|
|
122
|
+
}
|
|
123
|
+
function setConditionUnresolved(cursor, name = "") {
|
|
124
|
+
conditionNumbers[cursor + conditionFlagsOffset] &= -5;
|
|
125
|
+
if (name) {
|
|
126
|
+
const text = cursor + conditionUnresolvedNameOffset;
|
|
127
|
+
conditionTexts[text] ||= name;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function appendConditionWrapper(cursor, wrapper) {
|
|
131
|
+
conditionWrappers[conditionWrapperTop++] = wrapper;
|
|
132
|
+
conditionNumbers[cursor + conditionWrapperOffset]++;
|
|
133
|
+
}
|
|
134
|
+
function copyConditionCursor(target, source) {
|
|
135
|
+
for (let offset = 0; offset <= conditionPrecedenceOffset; offset++) conditionNumbers[target + offset] = conditionNumbers[source + offset];
|
|
136
|
+
for (let offset = 0; offset < conditionTextWidth; offset++) conditionTexts[target + offset] = conditionTexts[source + offset] || "";
|
|
137
|
+
const wrapper = conditionNumbers[source + conditionWrapperOffset];
|
|
138
|
+
const wrapperStart = wrapper >> 3;
|
|
139
|
+
const wrapperCount = wrapper & 7;
|
|
140
|
+
for (let index = 0; index < wrapperCount; index++) conditionWrappers[conditionWrapperTop++] = conditionWrappers[wrapperStart + index];
|
|
141
|
+
conditionNumbers[target + conditionWrapperOffset] += wrapperCount;
|
|
142
|
+
}
|
|
143
|
+
function resetConditionCursor(cursor, parent) {
|
|
144
|
+
conditionNumbers[cursor + conditionValueOffset] = 0;
|
|
145
|
+
conditionNumbers[cursor + conditionFlagsOffset] = conditionInitialFlags;
|
|
146
|
+
conditionNumbers[cursor + conditionPrecedenceOffset] = 0;
|
|
147
|
+
conditionNumbers[cursor + conditionWrapperOffset] = conditionWrapperTop << 3;
|
|
148
|
+
conditionTexts.fill("", cursor, cursor + conditionTextWidth);
|
|
149
|
+
if (parent) copyConditionCursor(cursor, parent);
|
|
150
|
+
}
|
|
151
|
+
function acquireConditionCursor(parent = 0) {
|
|
152
|
+
const cursor = conditionCursorTop;
|
|
153
|
+
conditionCursorTop += conditionWidth;
|
|
154
|
+
reserveConditionCursor(cursor);
|
|
155
|
+
resetConditionCursor(cursor, parent);
|
|
156
|
+
return cursor;
|
|
157
|
+
}
|
|
158
|
+
function releaseConditionCursors(watermark) {
|
|
159
|
+
if (watermark >= conditionCursorTop) return;
|
|
160
|
+
conditionTexts.fill("", watermark, conditionCursorTop);
|
|
161
|
+
conditionCursorTop = watermark;
|
|
162
|
+
}
|
|
163
|
+
function releaseConditionPayloads(wrapperBase) {
|
|
164
|
+
conditionWrappers.fill("", wrapperBase, conditionWrapperTop);
|
|
165
|
+
conditionWrapperTop = wrapperBase;
|
|
166
|
+
}
|
|
167
|
+
function accumulateConditionAtom(state, cursor, kind, rank, name) {
|
|
168
|
+
const keySlot = cursor + conditionKeyOffset;
|
|
169
|
+
const key = conditionTexts[keySlot];
|
|
170
|
+
if (!key) conditionTexts[keySlot] = name;
|
|
171
|
+
else {
|
|
172
|
+
let slotStart = 0;
|
|
173
|
+
let inserted = false;
|
|
174
|
+
while (slotStart <= key.length) {
|
|
175
|
+
let slotEnd = key.indexOf(":", slotStart);
|
|
176
|
+
if (slotEnd === -1) slotEnd = key.length;
|
|
177
|
+
let order = 0;
|
|
178
|
+
const compareLength = Math.min(name.length, slotEnd - slotStart);
|
|
179
|
+
for (let offset = 0; offset < compareLength; offset++) {
|
|
180
|
+
order = name.charCodeAt(offset) - key.charCodeAt(slotStart + offset);
|
|
181
|
+
if (order) break;
|
|
182
|
+
}
|
|
183
|
+
order ||= name.length - (slotEnd - slotStart);
|
|
184
|
+
if (!order) return;
|
|
185
|
+
if (order < 0) {
|
|
186
|
+
conditionTexts[keySlot] = `${key.slice(0, slotStart)}${name}:${key.slice(slotStart)}`;
|
|
187
|
+
inserted = true;
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
if (slotEnd === key.length) break;
|
|
191
|
+
slotStart = slotEnd + 1;
|
|
192
|
+
}
|
|
193
|
+
if (!inserted) conditionTexts[keySlot] = `${key}:${name}`;
|
|
194
|
+
}
|
|
195
|
+
if (kind === modifierKindPlatform) {
|
|
196
|
+
const precedence2 = conditionNumbers[cursor + conditionPrecedenceOffset];
|
|
197
|
+
if (rank > precedence2 >>> 26) conditionNumbers[cursor + conditionPrecedenceOffset] = precedence2 & 67108863 | rank << 26;
|
|
198
|
+
if (!platformMatches(name)) conditionNumbers[cursor + conditionFlagsOffset] &= -4;
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
let precedence = conditionNumbers[cursor + conditionPrecedenceOffset];
|
|
202
|
+
const depth = Math.min((precedence >> 23 & 7) + 1, 7);
|
|
203
|
+
const nextCategory = kind === modifierKindMedia ? 0 : kind === 6 ? 1 : kind === modifierKindTheme ? 2 : kind === 5 ? 3 : 4;
|
|
204
|
+
let categoryRank = precedence >> 20 & 7;
|
|
205
|
+
let withinRank = precedence & 1048575;
|
|
206
|
+
if (nextCategory > categoryRank) {
|
|
207
|
+
categoryRank = nextCategory;
|
|
208
|
+
withinRank = rank;
|
|
209
|
+
} else if (nextCategory === categoryRank && rank > withinRank) withinRank = rank;
|
|
210
|
+
precedence = precedence & -67108864 | depth << 23 | categoryRank << 20 | withinRank;
|
|
211
|
+
conditionNumbers[cursor + conditionPrecedenceOffset] = precedence;
|
|
212
|
+
const buildCSS = canGenerateCSS && state.flatShouldDoClasses;
|
|
213
|
+
if (kind === modifierKindMedia) {
|
|
214
|
+
const query = getConfigRevisionState(state.conf).mediaQueries[name];
|
|
215
|
+
if (!query) {
|
|
216
|
+
setConditionUnresolved(cursor, name);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
if (buildCSS) appendConditionWrapper(cursor, `@media ${query}`);
|
|
220
|
+
if (!state.flatMediaState?.[name]) conditionNumbers[cursor + conditionFlagsOffset] &= -2;
|
|
221
|
+
(state.flatMediaKeys ||= /* @__PURE__ */ new Set()).add(name);
|
|
222
|
+
} else if (kind === modifierKindTheme) {
|
|
223
|
+
conditionTexts[cursor + conditionThemeOffset] = name;
|
|
224
|
+
if (buildCSS) {
|
|
225
|
+
const selector = cursor + conditionSelectorOffset;
|
|
226
|
+
conditionTexts[selector] += `:where(.t_${name}, .t_${name} *)`;
|
|
227
|
+
}
|
|
228
|
+
if (state.flatThemeName !== name && state.flatThemeName?.startsWith(`${name}_`) !== true) conditionNumbers[cursor + conditionFlagsOffset] &= -2;
|
|
229
|
+
} else if (kind === 5) {
|
|
230
|
+
const slash = name.indexOf("/");
|
|
231
|
+
const groupName = slash === -1 ? "true" : name.slice(slash + 1);
|
|
232
|
+
const stateSelector = stateModifierSelectors[rank];
|
|
233
|
+
const conditionStateName = canonicalStateModifierNames[rank];
|
|
234
|
+
if (buildCSS) {
|
|
235
|
+
const selector = cursor + conditionSelectorOffset;
|
|
236
|
+
conditionTexts[selector] += `:where(.t_group_${groupName}${stateSelector} *)`;
|
|
237
|
+
if (rank === 0) appendConditionWrapper(cursor, "@media (hover: hover)");
|
|
238
|
+
}
|
|
239
|
+
const component = state.componentState.group?.[groupName];
|
|
240
|
+
const context = state.flatGroupContext?.[groupName];
|
|
241
|
+
if (!(component?.pseudo ?? context?.state.pseudo)?.[conditionStateName]) conditionNumbers[cursor + conditionFlagsOffset] &= -2;
|
|
242
|
+
(state.flatGroupKeys ||= /* @__PURE__ */ new Set()).add(groupName);
|
|
243
|
+
} else if (kind === 6) {
|
|
244
|
+
const slash = name.indexOf("/");
|
|
245
|
+
const containerSize = name.slice(1, slash === -1 ? name.length : slash);
|
|
246
|
+
const containerName = slash === -1 ? "" : name.slice(slash + 1);
|
|
247
|
+
const containerQuery = getConfigRevisionState(state.conf).mediaQueries[containerSize];
|
|
248
|
+
const groupKey = `@${containerName}`;
|
|
249
|
+
if (buildCSS) appendConditionWrapper(cursor, containerName ? `@container ${containerName} ${containerQuery}` : `@container ${containerQuery}`);
|
|
250
|
+
const component = state.componentState.group?.[groupKey];
|
|
251
|
+
const context = state.flatGroupContext?.[groupKey];
|
|
252
|
+
if (process.env.NODE_ENV === "development" && containerName && !component && !context && state.flatGroupContext?.[containerName]) warnOnce(`group-container:${containerName}`, `@${containerSize}/${containerName}: targets group="${containerName}", but groups no longer establish query containers. Add container="${containerName}" to that group.`);
|
|
253
|
+
const match = component?.media?.[containerSize];
|
|
254
|
+
if (!(match === void 0 ? context?.state.layout && mediaKeyMatch(containerSize, context.state.layout) : match)) conditionNumbers[cursor + conditionFlagsOffset] &= -2;
|
|
255
|
+
(state.flatGroupKeys ||= /* @__PURE__ */ new Set()).add(groupKey);
|
|
256
|
+
(state.flatGroupMedia ||= /* @__PURE__ */ new Set()).add(containerSize);
|
|
257
|
+
} else {
|
|
258
|
+
const stateSelector = stateModifierSelectors[rank];
|
|
259
|
+
conditionNumbers[cursor + conditionFlagsOffset] += 64;
|
|
260
|
+
if (rank === 6) conditionNumbers[cursor + conditionFlagsOffset] |= conditionEnterFlag;
|
|
261
|
+
else if (rank === 7) conditionNumbers[cursor + conditionFlagsOffset] |= conditionExitFlag;
|
|
262
|
+
else if (rank === 0 || rank === 2 || rank === 4) conditionNumbers[cursor + conditionFlagsOffset] |= conditionPlatformPseudoFlag;
|
|
263
|
+
if (buildCSS) {
|
|
264
|
+
const selector = cursor + conditionSelectorOffset;
|
|
265
|
+
if (stateSelector[0] === ".") conditionTexts[selector] += `:is(${stateSelector}, ${stateSelector} *)`;
|
|
266
|
+
else conditionTexts[selector] += stateSelector;
|
|
267
|
+
if (rank === 0) appendConditionWrapper(cursor, "@media (hover: hover)");
|
|
268
|
+
}
|
|
269
|
+
const component = state.componentState;
|
|
270
|
+
if (!(rank === 0 ? !!component.hover : rank === 4 ? !!(component.press || component.pressIn) : rank === 2 ? !!component.focus : rank === 3 ? !!component.focusVisible : rank === 1 ? !!component.focusWithin : rank === 5 ? !!(component.disabled || state.props.disabled) : rank === 6 ? !!component.unmounted : rank === 7 ? !!state.styleProps.isExiting : false)) conditionNumbers[cursor + conditionFlagsOffset] &= -2;
|
|
271
|
+
if (stateSelector[0] === ":") (state.flatStateKeys ||= /* @__PURE__ */ new Set()).add(name);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
function resolveConditionModifier(state, cursor, modifier) {
|
|
275
|
+
const compiled = getConfigRevisionState(state.conf);
|
|
276
|
+
let code = compiled.modifiers[modifier];
|
|
277
|
+
let kind = code & 7;
|
|
278
|
+
let rank = code >> 3;
|
|
279
|
+
if (kind === modifierKindState) {
|
|
280
|
+
accumulateConditionAtom(state, cursor, kind, rank, canonicalStateModifierNames[rank]);
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
if (!kind && modifier.startsWith("group-")) {
|
|
284
|
+
const slash = modifier.indexOf("/");
|
|
285
|
+
const authoredState = modifier.slice(6, slash === -1 ? void 0 : slash);
|
|
286
|
+
code = compiled.modifiers[authoredState];
|
|
287
|
+
if ((code & 7) === modifierKindState) {
|
|
288
|
+
rank = code >> 3;
|
|
289
|
+
const groupName = slash === -1 ? "true" : modifier.slice(slash + 1);
|
|
290
|
+
if (rank !== 6 && rank !== 7 && (slash === -1 || isModifierName(groupName, 0, groupName.length))) {
|
|
291
|
+
const stateName = canonicalStateModifierNames[rank];
|
|
292
|
+
accumulateConditionAtom(state, cursor, 5, rank, `group-${stateName}${slash === -1 ? "" : modifier.slice(slash)}`);
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
} else if (!kind && modifier.charCodeAt(0) === 64) {
|
|
297
|
+
const slash = modifier.indexOf("/");
|
|
298
|
+
const containerSize = modifier.slice(1, slash === -1 ? void 0 : slash);
|
|
299
|
+
const containerName = slash === -1 ? "" : modifier.slice(slash + 1);
|
|
300
|
+
let containerQuery = "";
|
|
301
|
+
if (isModifierName(containerSize, 0, containerSize.length) && (slash === -1 || isModifierName(containerName, 0, containerName.length)) && ((code = compiled.modifiers[containerSize]) & 7) === modifierKindMedia && (containerQuery = compiled.mediaQueries[containerSize]) && isContainerSizeQueryText(containerQuery)) {
|
|
302
|
+
accumulateConditionAtom(state, cursor, 6, code >> 3, modifier);
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
} else if (kind) {
|
|
306
|
+
accumulateConditionAtom(state, cursor, kind, rank, modifier);
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
setConditionUnresolved(cursor, modifier);
|
|
310
|
+
}
|
|
311
|
+
function resolveConditionText(state, cursor, text) {
|
|
312
|
+
let start = 0;
|
|
313
|
+
for (let index = 0; index <= text.length; index++) {
|
|
314
|
+
if (index !== text.length && text.charCodeAt(index) !== 58) continue;
|
|
315
|
+
if (index === start) {
|
|
316
|
+
setConditionUnresolved(cursor);
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
if (!(conditionNumbers[cursor + conditionFlagsOffset] & conditionResolvedFlag)) return;
|
|
320
|
+
resolveConditionModifier(state, cursor, text.slice(start, index));
|
|
321
|
+
start = index + 1;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
function commitConditionCursor(state, cursor) {
|
|
325
|
+
if (!(conditionNumbers[cursor + conditionFlagsOffset] & conditionResolvedFlag)) {
|
|
326
|
+
conditionNumbers[cursor + conditionValueOffset] = 0;
|
|
327
|
+
return 0;
|
|
328
|
+
}
|
|
329
|
+
const key = conditionTexts[cursor + conditionKeyOffset] || "";
|
|
330
|
+
const precedence = conditionNumbers[cursor + conditionPrecedenceOffset];
|
|
331
|
+
const depth = precedence >> 23 & 7;
|
|
332
|
+
if (depth > 5) throw new Error(`a flat value clause supports at most 5 non-platform conditions; received ${depth} in "${key}:"`);
|
|
333
|
+
const flags = conditionNumbers[cursor + conditionFlagsOffset];
|
|
334
|
+
const condition = precedence * 256 + (flags >> 6) * 32 + 16 + (flags & conditionActiveFlag ? 1 : 0) + (flags & conditionEmitFlag ? 2 : 0) + (flags & conditionEnterFlag ? 4 : 0) + (flags & conditionExitFlag ? 8 : 0);
|
|
335
|
+
conditionNumbers[cursor + conditionValueOffset] = condition;
|
|
336
|
+
return condition;
|
|
337
|
+
}
|
|
338
|
+
function acquireConditionKeyCursor(state, key) {
|
|
339
|
+
const cursor = acquireConditionCursor();
|
|
340
|
+
if (key) {
|
|
341
|
+
resolveConditionText(state, cursor, key);
|
|
342
|
+
commitConditionCursor(state, cursor);
|
|
343
|
+
}
|
|
344
|
+
return cursor;
|
|
345
|
+
}
|
|
346
|
+
function combineConditionKeys(state, first, second) {
|
|
347
|
+
if (!first) return second;
|
|
348
|
+
if (!second || first === second) return first;
|
|
349
|
+
const watermark = conditionCursorTop;
|
|
350
|
+
const target = acquireConditionKeyCursor(state, first);
|
|
351
|
+
resolveConditionText(state, target, second);
|
|
352
|
+
commitConditionCursor(state, target);
|
|
353
|
+
const key = conditionTexts[target + conditionKeyOffset] || "";
|
|
354
|
+
releaseConditionCursors(watermark);
|
|
355
|
+
return key;
|
|
356
|
+
}
|
|
357
|
+
function freshCompoundState() {
|
|
358
|
+
return {
|
|
359
|
+
seen: 0,
|
|
360
|
+
failed: false,
|
|
361
|
+
matchedBase: false,
|
|
362
|
+
scanned: false,
|
|
363
|
+
pending: null,
|
|
364
|
+
combinations: null
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
function beginCompoundEdges(indexes, states) {
|
|
368
|
+
if (!indexes) return;
|
|
369
|
+
for (let index = 0; index < indexes.length; index++) {
|
|
370
|
+
const state = states[indexes[index]] ||= freshCompoundState();
|
|
371
|
+
state.pending = null;
|
|
372
|
+
state.matchedBase = false;
|
|
373
|
+
state.scanned = false;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
function feedCompoundSegment(state, source, start, end, isBase, valid, conditionKey) {
|
|
377
|
+
if (state.flatCompoundOutputDepth) return;
|
|
378
|
+
const pass = state.flatPass;
|
|
379
|
+
const indexes = pass[passCompoundIndexes];
|
|
380
|
+
const states = pass[passCompoundStates];
|
|
381
|
+
const key = pass[passCompoundKey];
|
|
382
|
+
if (!indexes || !states || !key) return;
|
|
383
|
+
const compoundVariants = state.staticConfig.compoundVariants;
|
|
384
|
+
for (let index = 0; index < indexes.length; index++) {
|
|
385
|
+
const compoundIndex = indexes[index];
|
|
386
|
+
const compoundState = states[compoundIndex] ||= freshCompoundState();
|
|
387
|
+
compoundState.scanned = true;
|
|
388
|
+
if (!valid || start === end || !compoundMatcherMatchesPayload(compoundVariants[compoundIndex][key], source, start, end)) continue;
|
|
389
|
+
if (isBase) compoundState.matchedBase = true;
|
|
390
|
+
else if (!compoundState.matchedBase) (compoundState.pending ||= []).push(conditionKey);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
const compoundOnlyHandler = {
|
|
394
|
+
segment(state, start, end, isBase, valid, source, chainStart, chainEnd, chainValid) {
|
|
40
395
|
if (isBase) {
|
|
41
|
-
|
|
396
|
+
feedCompoundSegment(state, source, start, end, true, valid, "");
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
const cursor = state.flatScanCursor;
|
|
400
|
+
if (!chainValid || !cursor || !(conditionNumbers[cursor + conditionFlagsOffset] & conditionResolvedFlag) || !conditionNumbers[cursor + conditionValueOffset]) {
|
|
401
|
+
feedCompoundSegment(state, source, start, end, false, false, "");
|
|
42
402
|
return;
|
|
43
403
|
}
|
|
44
|
-
|
|
45
|
-
const chain = source.slice(chainStart, chainEnd);
|
|
46
|
-
if (ctx[2](chain)) ctx[3].push(chain);
|
|
404
|
+
feedCompoundSegment(state, source, start, end, false, valid, conditionTexts[cursor + conditionKeyOffset] || "");
|
|
47
405
|
},
|
|
48
|
-
|
|
49
|
-
|
|
406
|
+
modifier(state, start, end, valid, first, source) {
|
|
407
|
+
let cursor = state.flatScanCursor;
|
|
408
|
+
if (!cursor) cursor = state.flatScanCursor = acquireConditionCursor();
|
|
409
|
+
else if (first) resetConditionCursor(cursor, 0);
|
|
410
|
+
if (!valid) {
|
|
411
|
+
setConditionUnresolved(cursor);
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
if (conditionNumbers[cursor + conditionFlagsOffset] & conditionResolvedFlag) resolveConditionModifier(state, cursor, source.slice(start, end));
|
|
50
415
|
},
|
|
51
|
-
|
|
416
|
+
chain(state, _start, _end, valid) {
|
|
417
|
+
const cursor = state.flatScanCursor;
|
|
418
|
+
if (cursor) {
|
|
419
|
+
if (!valid) setConditionUnresolved(cursor);
|
|
420
|
+
if (conditionNumbers[cursor + conditionFlagsOffset] & conditionResolvedFlag) commitConditionCursor(state, cursor);
|
|
421
|
+
}
|
|
422
|
+
return true;
|
|
423
|
+
}
|
|
52
424
|
};
|
|
53
|
-
function
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
425
|
+
function finishCompoundEdges(pass, key, value, indexes, states) {
|
|
426
|
+
if (!indexes) return;
|
|
427
|
+
const state = pass[passStyleState];
|
|
428
|
+
pass[passCompoundIndexes] = indexes;
|
|
429
|
+
pass[passCompoundKey] = key;
|
|
430
|
+
pass[passCompoundStates] = states;
|
|
431
|
+
let needsScan = false;
|
|
432
|
+
for (let index = 0; index < indexes.length; index++) if (!(states[indexes[index]] ||= freshCompoundState()).scanned) {
|
|
433
|
+
needsScan = true;
|
|
434
|
+
break;
|
|
435
|
+
}
|
|
436
|
+
if (needsScan) if (typeof value === "string") {
|
|
437
|
+
const watermark = conditionCursorTop;
|
|
438
|
+
const previousCursor = state.flatScanCursor;
|
|
439
|
+
state.flatScanCursor = null;
|
|
440
|
+
try {
|
|
441
|
+
scanFlatValue(value, compoundOnlyHandler, state);
|
|
442
|
+
} finally {
|
|
443
|
+
state.flatScanCursor = previousCursor;
|
|
444
|
+
releaseConditionCursors(watermark);
|
|
445
|
+
}
|
|
446
|
+
} else if (value && typeof value === "object" && !Array.isArray(value) && !isVariable(value) && Object.prototype.hasOwnProperty.call(value, "default")) for (const conditionKey in value) {
|
|
447
|
+
const payload = value[conditionKey];
|
|
448
|
+
if (conditionKey === "default") {
|
|
449
|
+
const payloadString = String(payload);
|
|
450
|
+
feedCompoundSegment(state, payloadString, 0, payloadString.length, true, true, "");
|
|
451
|
+
} else {
|
|
452
|
+
const watermark = conditionCursorTop;
|
|
453
|
+
const cursor = acquireConditionCursor();
|
|
454
|
+
resolveConditionText(state, cursor, conditionKey);
|
|
455
|
+
const condition = commitConditionCursor(state, cursor);
|
|
456
|
+
const payloadString = String(payload);
|
|
457
|
+
feedCompoundSegment(state, payloadString, 0, payloadString.length, false, Boolean(condition), condition ? conditionTexts[cursor + conditionKeyOffset] || "" : "");
|
|
458
|
+
releaseConditionCursors(watermark);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
else {
|
|
462
|
+
const variants2 = state.staticConfig.compoundVariants;
|
|
463
|
+
for (let index = 0; index < indexes.length; index++) {
|
|
464
|
+
const compoundIndex = indexes[index];
|
|
465
|
+
const compoundState = states[compoundIndex] ||= freshCompoundState();
|
|
466
|
+
compoundState.scanned = true;
|
|
467
|
+
if (compoundMatcherMatches(variants2[compoundIndex][key], value)) compoundState.matchedBase = true;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
const variants = state.staticConfig.compoundVariants;
|
|
471
|
+
const selectorCounts = state.staticConfig[preparedCompoundsKey][preparedCompoundsKey];
|
|
472
|
+
for (let index = 0; index < indexes.length; index++) {
|
|
473
|
+
const compoundIndex = indexes[index];
|
|
474
|
+
const compoundState = states[compoundIndex];
|
|
475
|
+
if (compoundState.failed) continue;
|
|
476
|
+
const branches = compoundState.matchedBase ? [""] : compoundState.pending;
|
|
477
|
+
if (!branches || !branches.length) {
|
|
478
|
+
compoundState.failed = true;
|
|
479
|
+
continue;
|
|
71
480
|
}
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (
|
|
481
|
+
if (!compoundState.seen) compoundState.combinations = branches;
|
|
482
|
+
else {
|
|
483
|
+
const previous = compoundState.combinations;
|
|
484
|
+
const next = [];
|
|
485
|
+
for (let left = 0; left < previous.length; left++) for (let right = 0; right < branches.length; right++) {
|
|
486
|
+
const conditionKey = combineConditionKeys(state, previous[left], branches[right]);
|
|
487
|
+
if (!next.includes(conditionKey)) next.push(conditionKey);
|
|
79
488
|
}
|
|
80
|
-
|
|
489
|
+
compoundState.combinations = next;
|
|
81
490
|
}
|
|
491
|
+
compoundState.seen++;
|
|
492
|
+
if (compoundState.seen !== selectorCounts[compoundIndex]) continue;
|
|
493
|
+
const style = variants[compoundIndex].style;
|
|
494
|
+
if (!isPlainObject(style)) continue;
|
|
495
|
+
const combinations = compoundState.combinations;
|
|
496
|
+
for (let combination = 0; combination < combinations.length; combination++) for (const styleKey in style) contributeProp(pass, styleKey, style[styleKey], void 0, states, combinations[combination]);
|
|
82
497
|
}
|
|
83
|
-
return compoundMatcherMatches(expected, actual) ? [""] : null;
|
|
84
|
-
}
|
|
85
|
-
function isConditionalObjectValue(value, isChain) {
|
|
86
|
-
if (Object.prototype.hasOwnProperty.call(value, "default")) return true;
|
|
87
|
-
for (const key in value) return key.length > 0 && isChain(key);
|
|
88
|
-
return false;
|
|
89
498
|
}
|
|
90
|
-
|
|
91
|
-
if (
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (!keyChains) return null;
|
|
103
|
-
const next = [];
|
|
104
|
-
for (const a of chains) for (const b of keyChains) {
|
|
105
|
-
const joined = joinChains(a, b);
|
|
106
|
-
if (!next.includes(joined)) next.push(joined);
|
|
499
|
+
function classifyConditionalObject(value, state, isChain, firstCursor) {
|
|
500
|
+
if (Object.prototype.hasOwnProperty.call(value, "default")) return -1;
|
|
501
|
+
for (const key in value) {
|
|
502
|
+
if (!key.length) return 0;
|
|
503
|
+
if (!state) return isChain?.(key) ? 1 : 0;
|
|
504
|
+
const watermark = conditionCursorTop;
|
|
505
|
+
const cursor = firstCursor || acquireConditionCursor();
|
|
506
|
+
try {
|
|
507
|
+
resolveConditionText(state, cursor, key);
|
|
508
|
+
return commitConditionCursor(state, cursor);
|
|
509
|
+
} finally {
|
|
510
|
+
if (!firstCursor) releaseConditionCursors(watermark);
|
|
107
511
|
}
|
|
108
|
-
chains = next;
|
|
109
512
|
}
|
|
110
|
-
return
|
|
513
|
+
return 0;
|
|
111
514
|
}
|
|
515
|
+
const passStyleState = 0;
|
|
516
|
+
const passClassName = 21;
|
|
517
|
+
const passShouldDoClasses = 22;
|
|
518
|
+
const passContainerValue = 23;
|
|
519
|
+
const passContainerName = 24;
|
|
520
|
+
const passContainerType = 25;
|
|
521
|
+
const passFrontendGroup = 26;
|
|
522
|
+
const passFrontendContainer = 27;
|
|
523
|
+
const passFrontendContainerType = 28;
|
|
524
|
+
const passHocMappedProperties = 29;
|
|
525
|
+
const passHocMappedClasses = 30;
|
|
526
|
+
const passCompoundIndexes = 31;
|
|
527
|
+
const passCompoundKey = 32;
|
|
528
|
+
const passCompoundStates = 33;
|
|
529
|
+
const passParentCursor = 35;
|
|
530
|
+
const passMapSourceKey = 36;
|
|
531
|
+
const passMapFlags = 37;
|
|
532
|
+
const passNoSkipFlag = 1;
|
|
533
|
+
const passDisableShorthandsFlag = 2;
|
|
534
|
+
const passNoExpandFlag = 4;
|
|
535
|
+
const passNoMergeFlag = 8;
|
|
536
|
+
const passHocFlag = 16;
|
|
537
|
+
const passTextFlag = 32;
|
|
538
|
+
const passInputFlag = 64;
|
|
539
|
+
const passAsChildStyleFlag = 128;
|
|
112
540
|
const styledDefaultsCache = /* @__PURE__ */ new WeakMap();
|
|
113
|
-
function getStyledDefaults(staticConfig) {
|
|
114
|
-
let
|
|
115
|
-
if (
|
|
116
|
-
entries = null;
|
|
541
|
+
function getStyledDefaults(staticConfig, shorthands) {
|
|
542
|
+
let prepared = styledDefaultsCache.get(staticConfig);
|
|
543
|
+
if (prepared === void 0) {
|
|
544
|
+
let entries = null;
|
|
117
545
|
const defaults = staticConfig.defaultProps;
|
|
118
|
-
if (defaults) for (const key in defaults)
|
|
119
|
-
|
|
546
|
+
if (defaults) for (const key in defaults) {
|
|
547
|
+
if (!(key in stylePropsAll || key in shorthands)) continue;
|
|
548
|
+
const value = defaults[key];
|
|
549
|
+
if (maybeStyleProgram(value)) (entries ||= []).push(key, value);
|
|
550
|
+
}
|
|
551
|
+
prepared = entries;
|
|
552
|
+
styledDefaultsCache.set(staticConfig, prepared);
|
|
120
553
|
}
|
|
121
|
-
return
|
|
554
|
+
return prepared;
|
|
122
555
|
}
|
|
123
|
-
const maybeStyleProgram = (value) => typeof value === "string" ? value.
|
|
124
|
-
function contributeDisplacedStyledDefaults(styledDefaults, processedProps,
|
|
556
|
+
const maybeStyleProgram = (value) => typeof value === "string" ? value.indexOf(":") !== -1 : !!value && typeof value === "object" && !Array.isArray(value) && !isVariable(value);
|
|
557
|
+
function contributeDisplacedStyledDefaults(styledDefaults, processedProps, pass) {
|
|
125
558
|
if (!styledDefaults) return;
|
|
126
|
-
for (let
|
|
127
|
-
const key = styledDefaults[
|
|
128
|
-
const
|
|
559
|
+
for (let offset = 0; offset < styledDefaults.length; offset += 2) {
|
|
560
|
+
const key = styledDefaults[offset];
|
|
561
|
+
const value = styledDefaults[offset + 1];
|
|
129
562
|
const propValue = processedProps[key];
|
|
130
|
-
if (
|
|
131
|
-
|
|
563
|
+
if (propValue !== void 0 && propValue !== value) contributeProp(pass, key, value);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
function injectDisplacedStyledDefault(pass, key, value) {
|
|
567
|
+
const defaultValue = pass[4].defaultProps?.[key];
|
|
568
|
+
if (defaultValue === void 0 || value === void 0 || value === defaultValue || maybeStyleProgram(defaultValue)) return;
|
|
569
|
+
const state = pass[passStyleState];
|
|
570
|
+
state.flatWeakContribution = true;
|
|
571
|
+
try {
|
|
572
|
+
contributeProp(pass, key, defaultValue);
|
|
573
|
+
} finally {
|
|
574
|
+
state.flatWeakContribution = false;
|
|
132
575
|
}
|
|
133
576
|
}
|
|
134
|
-
function forEachPropInForwardOrder(
|
|
577
|
+
function forEachPropInForwardOrder(pass) {
|
|
578
|
+
const styleState = pass[passStyleState];
|
|
579
|
+
const staticConfig = styleState.staticConfig;
|
|
580
|
+
const processedProps = styleState.props;
|
|
581
|
+
const shorthands = styleState.conf.shorthands;
|
|
135
582
|
const processedBaseStyle = staticConfig.baseStyle;
|
|
136
|
-
const
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
583
|
+
const styledDefaults = getStyledDefaults(staticConfig, shorthands);
|
|
584
|
+
const directState = styleState;
|
|
585
|
+
const preparedCompounds = staticConfig[preparedCompoundsKey];
|
|
586
|
+
if (preparedCompounds === void 0 && staticConfig.compoundVariants?.length) throw new Error("A component with compoundVariants reached style resolution before its static config was prepared.");
|
|
587
|
+
const conditionWrapperBase = conditionWrapperTop;
|
|
588
|
+
if (!preparedCompounds) {
|
|
589
|
+
try {
|
|
590
|
+
if (processedBaseStyle) for (const key in processedBaseStyle) contributeProp(pass, key, processedBaseStyle[key]);
|
|
591
|
+
contributeDisplacedStyledDefaults(styledDefaults, processedProps, pass);
|
|
592
|
+
for (const key in processedProps) {
|
|
593
|
+
const value = processedProps[key];
|
|
594
|
+
directState.flatPropSawCondition = false;
|
|
595
|
+
contributeProp(pass, key, value);
|
|
596
|
+
if (directState.flatPropSawCondition) injectDisplacedStyledDefault(pass, key, value);
|
|
597
|
+
}
|
|
598
|
+
} finally {
|
|
599
|
+
releaseConditionPayloads(conditionWrapperBase);
|
|
600
|
+
}
|
|
142
601
|
return;
|
|
143
602
|
}
|
|
144
|
-
const
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (selectorKey === "style") continue;
|
|
156
|
-
for (let index = propEntries.length - 1; index >= 0; index--) if (propEntries[index][0] === selectorKey) {
|
|
157
|
-
anchor = Math.max(anchor, index);
|
|
158
|
-
break;
|
|
159
|
-
}
|
|
603
|
+
const compoundVariants = staticConfig.compoundVariants;
|
|
604
|
+
const compoundStates = new Array(compoundVariants.length);
|
|
605
|
+
try {
|
|
606
|
+
if (processedBaseStyle) for (const key in processedBaseStyle) contributeProp(pass, key, processedBaseStyle[key]);
|
|
607
|
+
contributeDisplacedStyledDefaults(styledDefaults, processedProps, pass);
|
|
608
|
+
const selectorCounts = preparedCompounds[preparedCompoundsKey];
|
|
609
|
+
for (let compoundIndex = 0; compoundIndex < compoundVariants.length; compoundIndex++) {
|
|
610
|
+
if (selectorCounts[compoundIndex]) continue;
|
|
611
|
+
const style = compoundVariants[compoundIndex].style;
|
|
612
|
+
if (!isPlainObject(style)) continue;
|
|
613
|
+
for (const key in style) contributeProp(pass, key, style[key]);
|
|
160
614
|
}
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
const value =
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
if (value && typeof value === "object" && !Array.isArray(value) && !isVariable(value) && isConditionalObjectValue(value, isChain)) {
|
|
170
|
-
const composed = {};
|
|
171
|
-
for (const inner in value) composed[inner === "default" ? chain : `${chain}:${inner}`] = value[inner];
|
|
172
|
-
entries.push([key, composed]);
|
|
173
|
-
continue;
|
|
174
|
-
}
|
|
175
|
-
if (typeof value === "string" && value.includes(":")) {
|
|
176
|
-
if (process.env.NODE_ENV === "development") console.warn(`[tamagui] compound variant "${key}" carries a clause string and matched conditionally; dropping it. use the object form in the compound style`);
|
|
177
|
-
continue;
|
|
178
|
-
}
|
|
179
|
-
entries.push([key, { [chain]: value }]);
|
|
180
|
-
}
|
|
615
|
+
for (const key in processedProps) {
|
|
616
|
+
const compoundIndexes = preparedCompounds[key];
|
|
617
|
+
const value = processedProps[key];
|
|
618
|
+
beginCompoundEdges(compoundIndexes, compoundStates);
|
|
619
|
+
directState.flatPropSawCondition = false;
|
|
620
|
+
contributeProp(pass, key, value, compoundIndexes, compoundStates);
|
|
621
|
+
if (directState.flatPropSawCondition) injectDisplacedStyledDefault(pass, key, value);
|
|
622
|
+
finishCompoundEdges(pass, key, value, compoundIndexes, compoundStates);
|
|
181
623
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
for (let index = 0; index < orderedEntries.length; index++) contribute(orderedEntries[index][0], orderedEntries[index][1]);
|
|
185
|
-
const beforeProps = compoundsByAnchor.get(-1);
|
|
186
|
-
if (beforeProps) for (let index = 0; index < beforeProps.length; index++) contribute(beforeProps[index][0], beforeProps[index][1]);
|
|
187
|
-
for (let index = 0; index < propEntries.length; index++) {
|
|
188
|
-
contribute(propEntries[index][0], propEntries[index][1]);
|
|
189
|
-
const compounds = compoundsByAnchor.get(index);
|
|
190
|
-
if (compounds) for (let i = 0; i < compounds.length; i++) contribute(compounds[i][0], compounds[i][1]);
|
|
624
|
+
} finally {
|
|
625
|
+
releaseConditionPayloads(conditionWrapperBase);
|
|
191
626
|
}
|
|
192
627
|
}
|
|
193
628
|
function isValidStyleKey(key, validStyles, accept) {
|
|
194
|
-
return Boolean(key in validStyles ||
|
|
629
|
+
return Boolean(key in validStyles || accept && key in accept);
|
|
195
630
|
}
|
|
196
|
-
|
|
197
|
-
const
|
|
198
|
-
if (
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
const
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
const
|
|
217
|
-
if (
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
631
|
+
function flushForwardStylesToClasses(pass) {
|
|
632
|
+
const styleState = pass[passStyleState];
|
|
633
|
+
if (!pass[passShouldDoClasses]) return;
|
|
634
|
+
completeStreamingCSS(styleState);
|
|
635
|
+
flushDirectStyles(styleState, true);
|
|
636
|
+
}
|
|
637
|
+
function effectiveLifecycleKeys(keys) {
|
|
638
|
+
if (!keys) return;
|
|
639
|
+
const out = /* @__PURE__ */ new Set();
|
|
640
|
+
for (const key of keys) out.add(key === "--t-x" || key === "--t-y" ? "translate" : key === "--t-scale-x" || key === "--t-scale-y" ? "scale" : key);
|
|
641
|
+
return out;
|
|
642
|
+
}
|
|
643
|
+
function mapContributedProp(styleState, key, val, originalVal, condition) {
|
|
644
|
+
const pass = styleState.flatPass;
|
|
645
|
+
const keyInit = pass[passMapSourceKey];
|
|
646
|
+
const disablePropMap = Boolean(pass[passMapFlags]);
|
|
647
|
+
const [, conf, props, viewProps, , validStyles, accept, , variants, inlineProps, parentVariants, , styledContext, styledContextKeys, flags, debug] = pass;
|
|
648
|
+
const isHOC = Boolean(flags & passHocFlag);
|
|
649
|
+
const hocParentVariants = isHOC ? parentVariants : void 0;
|
|
650
|
+
const canResolveContextPrograms = !isHOC;
|
|
651
|
+
const isStyledContextProp = styledContextKeys?.has(key) || styledContext && key in styledContext;
|
|
652
|
+
if (key === "className") {
|
|
653
|
+
if (typeof val === "string" && val) pass[passClassName] = `${pass[passClassName]} ${val}`.trim();
|
|
654
|
+
return;
|
|
655
|
+
}
|
|
656
|
+
if (canResolveContextPrograms && disablePropMap && !isStyledContextProp) {
|
|
657
|
+
if (key in stylePropsAll && !isValidStyleKey(key, validStyles, accept)) {
|
|
658
|
+
if (process.env.NODE_ENV === "development") console.warn(`[tamagui] "${key}" is a text style prop and this component is not text \u2014 it would render on neither platform. Use a Text-based component, or html.* for raw web elements.`);
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
viewProps[key] = val;
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
if (process.env.NODE_ENV === "development" && debug === "verbose") {
|
|
665
|
+
console.groupCollapsed(" 💠 expanded", keyInit, "=>", key);
|
|
666
|
+
log(val);
|
|
667
|
+
console.groupEnd();
|
|
668
|
+
}
|
|
669
|
+
if (val == null) return;
|
|
670
|
+
if (accept && key in accept) {
|
|
671
|
+
viewProps[key] = val;
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
const isHostStyleKey = isValidStyleKey(key, validStyles, accept) || false;
|
|
675
|
+
const isContextProgramKey = canResolveContextPrograms && Boolean(isStyledContextProp);
|
|
676
|
+
if (condition !== void 0) {
|
|
677
|
+
const conditionCursor = condition;
|
|
678
|
+
if (isHostStyleKey || isContextProgramKey) contributeValue(styleState, key, val, mergeStyle, originalVal, !isHostStyleKey, conditionCursor);
|
|
679
|
+
else if (isHOC) {
|
|
680
|
+
const structured = mergeConditionTransport(styleState, viewProps[key], conditionCursor, val);
|
|
681
|
+
if (key in viewProps) delete viewProps[key];
|
|
682
|
+
viewProps[key] = structured;
|
|
683
|
+
} else if (process.env.NODE_ENV === "development") console.warn(`[tamagui] "${key}" is not a valid style on this component; the conditional variant value is dropped.`);
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
if (isHostStyleKey || isContextProgramKey) {
|
|
687
|
+
contributeValue(styleState, key, val, mergeStyle, originalVal, !isHostStyleKey);
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
const isVariant = Boolean(variants && key in variants);
|
|
691
|
+
if (inlineProps?.has(key)) viewProps[key] = props[key] ?? val;
|
|
692
|
+
if (Boolean(hocParentVariants && hocParentVariants[keyInit])) {
|
|
693
|
+
passDownProp(viewProps, key, val);
|
|
694
|
+
if (process.env.NODE_ENV === "development" && debug === "verbose") {
|
|
695
|
+
console.groupCollapsed(` - passing down prop ${key}`);
|
|
241
696
|
log({
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
shouldDoClasses,
|
|
245
|
-
styleProps,
|
|
246
|
-
rulesToInsert,
|
|
247
|
-
componentState,
|
|
248
|
-
styleState,
|
|
249
|
-
theme: { ...theme }
|
|
697
|
+
val,
|
|
698
|
+
after: { ...viewProps[key] }
|
|
250
699
|
});
|
|
700
|
+
console.groupEnd();
|
|
251
701
|
}
|
|
702
|
+
return;
|
|
252
703
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
const styleFrontend = staticConfig.styleFrontend;
|
|
258
|
-
if (styleFrontend && !props[STYLE_FRONTEND_PREPROCESSED]) processedProps = styleFrontend.preprocessProps(props, conf);
|
|
259
|
-
else processedProps = props;
|
|
260
|
-
const { webContainerType } = conf.settings;
|
|
261
|
-
const parentVariants = parentStaticConfig?.variants;
|
|
262
|
-
const mergeStylePropAtCurrentPosition = (styleProp) => {
|
|
263
|
-
if (styleProps.noMergeStyle || !styleProp) return;
|
|
264
|
-
if (isHOC) {
|
|
265
|
-
viewProps.style = normalizeStyle(styleProp);
|
|
704
|
+
if (!isVariant) {
|
|
705
|
+
if (isStyledContextProp) return;
|
|
706
|
+
if (key in stylePropsAll && !isValidStyleKey(key, validStyles, accept)) {
|
|
707
|
+
if (process.env.NODE_ENV === "development") console.warn(`[tamagui] "${key}" is a text style prop and this component is not text \u2014 it would render on neither platform. Use a Text-based component, or html.* for raw web elements.`);
|
|
266
708
|
return;
|
|
267
709
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
710
|
+
viewProps[key] = val;
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
function contributeProp(pass, keyOg, valOg, compoundIndexes, compoundStates, parentConditionKey) {
|
|
714
|
+
const parentWatermark = conditionCursorTop;
|
|
715
|
+
if (compoundIndexes) {
|
|
716
|
+
pass[passCompoundIndexes] = compoundIndexes;
|
|
717
|
+
pass[passCompoundKey] = keyOg;
|
|
718
|
+
pass[passCompoundStates] = compoundStates;
|
|
719
|
+
} else if (pass[passCompoundIndexes]) pass[passCompoundIndexes] = void 0;
|
|
720
|
+
if (parentConditionKey) pass[passParentCursor] = acquireConditionKeyCursor(pass[passStyleState], parentConditionKey);
|
|
721
|
+
try {
|
|
722
|
+
const [styleState, conf, props, viewProps, staticConfig, validStyles, accept, neverSkipProps, variants, inlineProps, parentVariants, styleFrontend, styledContext, styledContextKeys, flags, debug, parentStaticConfig, defaultProps, driverAnimations, driverOutputStyle, elementType] = pass;
|
|
723
|
+
const noSkip = Boolean(flags & passNoSkipFlag);
|
|
724
|
+
const disableExpandShorthands = Boolean(flags & passDisableShorthandsFlag);
|
|
725
|
+
const noExpand = Boolean(flags & passNoExpandFlag);
|
|
726
|
+
const noMergeStyle = Boolean(flags & passNoMergeFlag);
|
|
727
|
+
const isHOC = Boolean(flags & passHocFlag);
|
|
728
|
+
const isText = Boolean(flags & passTextFlag);
|
|
729
|
+
const isInput = Boolean(flags & passInputFlag);
|
|
730
|
+
const shorthands = conf.shorthands;
|
|
731
|
+
const shouldSkipDirectProps = !noSkip && !isHOC;
|
|
732
|
+
const shouldCheckSkipProps = !noSkip;
|
|
733
|
+
const asChildExceptStyleLike = Boolean(flags & passAsChildStyleFlag);
|
|
734
|
+
const isTextOrInput = isText || isInput;
|
|
735
|
+
const hocParentVariants = isHOC ? parentVariants : void 0;
|
|
291
736
|
let keyInit = keyOg;
|
|
292
737
|
let valInit = valOg;
|
|
293
|
-
if (styleFrontend && keyInit.startsWith(STYLE_FRONTEND_PASSTHROUGH_PREFIX)) keyInit = "className";
|
|
294
738
|
if (keyInit === "children") {
|
|
295
739
|
viewProps[keyInit] = valInit;
|
|
296
740
|
return;
|
|
@@ -301,7 +745,7 @@ const getSplitStyles = (props, staticConfig, theme, themeName, componentState, s
|
|
|
301
745
|
if (accept) {
|
|
302
746
|
const accepted = accept[keyInit];
|
|
303
747
|
if ((accepted === "style" || accepted === "textStyle") && valInit && typeof valInit === "object") {
|
|
304
|
-
viewProps[keyInit] =
|
|
748
|
+
viewProps[keyInit] = resolveAcceptedStyle(styleState, valInit);
|
|
305
749
|
return;
|
|
306
750
|
}
|
|
307
751
|
}
|
|
@@ -309,69 +753,127 @@ const getSplitStyles = (props, staticConfig, theme, themeName, componentState, s
|
|
|
309
753
|
if (keyInit in shorthands) keyInit = shorthands[keyInit];
|
|
310
754
|
}
|
|
311
755
|
if (keyInit === "className") {
|
|
312
|
-
if (typeof valInit === "string" && valInit) {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
756
|
+
if (typeof valInit === "string" && valInit && true) {
|
|
757
|
+
if (noMergeStyle) {
|
|
758
|
+
viewProps.className = valInit;
|
|
759
|
+
return;
|
|
760
|
+
}
|
|
761
|
+
const hocClassNames = props[HOC_CLASSNAME_MARKER];
|
|
762
|
+
if (hocClassNames && typeof hocClassNames === "object") {
|
|
763
|
+
flushForwardStylesToClasses(pass);
|
|
764
|
+
for (const property in hocClassNames) {
|
|
765
|
+
const generatedClass = hocClassNames[property];
|
|
766
|
+
if (typeof generatedClass !== "string") continue;
|
|
767
|
+
clearDirectStyle(styleState, property);
|
|
768
|
+
styleState.classNames[property] = generatedClass;
|
|
769
|
+
(pass[passHocMappedProperties] ||= /* @__PURE__ */ new Set()).add(property);
|
|
770
|
+
(pass[passHocMappedClasses] ||= /* @__PURE__ */ new Set()).add(generatedClass);
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
const getClassPlan = styleFrontend?.getClassPlan;
|
|
774
|
+
let start = 0;
|
|
775
|
+
for (let index = 0; index <= valInit.length; index++) {
|
|
776
|
+
if (index !== valInit.length && valInit.charCodeAt(index) > 32) continue;
|
|
777
|
+
if (index === start) {
|
|
778
|
+
start = index + 1;
|
|
779
|
+
continue;
|
|
780
|
+
}
|
|
781
|
+
const candidate = valInit.slice(start, index);
|
|
782
|
+
if (pass[passHocMappedClasses]?.has(candidate)) {
|
|
783
|
+
start = index + 1;
|
|
784
|
+
continue;
|
|
785
|
+
}
|
|
786
|
+
const plan = getClassPlan ? getClassPlan(candidate, conf) : "raw";
|
|
787
|
+
if (plan === null) {
|
|
788
|
+
if (process.env.NODE_ENV === "development") warnOnce(`[tamagui] frontend candidate "${candidate}" is unavailable on this platform and was dropped.`);
|
|
789
|
+
} else if (plan === "raw") {
|
|
790
|
+
pass[passClassName] = pass[passClassName] ? `${pass[passClassName]} ${candidate}` : candidate;
|
|
791
|
+
if (getClassPlan) {
|
|
792
|
+
flushForwardStylesToClasses(pass);
|
|
793
|
+
pass[passShouldDoClasses] = false;
|
|
794
|
+
styleState.flatShouldDoClasses = false;
|
|
795
|
+
}
|
|
796
|
+
} else {
|
|
797
|
+
const parentPlan = plan;
|
|
798
|
+
if (!Array.isArray(plan) && parentPlan.preserveRawClass) {
|
|
799
|
+
pass[passClassName] = pass[passClassName] ? `${pass[passClassName]} ${candidate}` : candidate;
|
|
800
|
+
flushForwardStylesToClasses(pass);
|
|
801
|
+
pass[passShouldDoClasses] = false;
|
|
802
|
+
styleState.flatShouldDoClasses = false;
|
|
803
|
+
}
|
|
804
|
+
const entries = Array.isArray(plan) ? plan : parentPlan.entries;
|
|
805
|
+
for (let entryIndex = 0; entryIndex < entries.length; entryIndex++) {
|
|
806
|
+
const entry = entries[entryIndex];
|
|
807
|
+
if (entry[2] !== void 0) {
|
|
808
|
+
if (isValidStyleKey(entry[0], validStyles, accept)) contributeValue(styleState, entry[0], entry[1], mergeStyle, void 0, false, entry[2]);
|
|
809
|
+
else if (process.env.NODE_ENV === "development") console.warn(`[tamagui] "${entry[0]}" is not a valid style on this component; the frontend value is dropped.`);
|
|
810
|
+
} else {
|
|
811
|
+
if (entry[0] === "group") pass[passFrontendGroup] = entry[1];
|
|
812
|
+
else if (entry[0] === "container") pass[passFrontendContainer] = entry[1];
|
|
813
|
+
else if (entry[0] === "containerType") pass[passFrontendContainerType] = entry[1];
|
|
814
|
+
contributeProp(pass, entry[0], entry[1]);
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
start = index + 1;
|
|
819
|
+
}
|
|
820
|
+
if (props[HOC_CLASSNAME_MARKER] !== void 0) {
|
|
821
|
+
flushForwardStylesToClasses(pass);
|
|
822
|
+
pass[passShouldDoClasses] = false;
|
|
317
823
|
styleState.flatShouldDoClasses = false;
|
|
318
824
|
}
|
|
319
825
|
}
|
|
320
826
|
return;
|
|
321
827
|
}
|
|
322
828
|
if (keyInit === "style") {
|
|
323
|
-
|
|
829
|
+
if (!valInit) return;
|
|
830
|
+
if (noMergeStyle) {
|
|
831
|
+
viewProps.style = valInit;
|
|
832
|
+
return;
|
|
833
|
+
}
|
|
834
|
+
const isArray = Array.isArray(valInit);
|
|
835
|
+
const length = isArray ? valInit.length : 1;
|
|
836
|
+
for (let index = 0; index < length; index++) {
|
|
837
|
+
const style = isArray ? valInit[index] : valInit;
|
|
838
|
+
if (!style) continue;
|
|
839
|
+
const hocClassNames = style[TAMAGUI_CLASS_PROPS];
|
|
840
|
+
if (hocClassNames) {
|
|
841
|
+
for (const property in hocClassNames) {
|
|
842
|
+
clearDirectStyle(styleState, property);
|
|
843
|
+
styleState.classNames[property] = hocClassNames[property];
|
|
844
|
+
(pass[passHocMappedProperties] ||= /* @__PURE__ */ new Set()).add(property);
|
|
845
|
+
}
|
|
846
|
+
continue;
|
|
847
|
+
}
|
|
848
|
+
const normalized = normalizeStyle(style, false, true);
|
|
849
|
+
const styleOriginals = shouldTrackStyleTokenProvenance ? styleOriginalValues.get(style) : void 0;
|
|
850
|
+
for (const key in normalized) {
|
|
851
|
+
if (normalized[key] == null) continue;
|
|
852
|
+
if (pass[passHocMappedProperties]?.delete(key)) clearDirectStyle(styleState, key);
|
|
853
|
+
if (key === "containerName" && typeof normalized[key] === "string" && normalized[key].indexOf(":") === -1) pass[passContainerName] = normalized[key];
|
|
854
|
+
if (key === "containerType" && typeof normalized[key] === "string" && normalized[key].indexOf(":") === -1) pass[passContainerType] = normalized[key];
|
|
855
|
+
contributeValue(styleState, key, normalized[key], mergeStyle, styleOriginals?.[key]);
|
|
856
|
+
}
|
|
857
|
+
}
|
|
324
858
|
return;
|
|
325
859
|
}
|
|
326
|
-
if (
|
|
327
|
-
const
|
|
328
|
-
if (
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
}
|
|
333
|
-
if (keyInit in skipProps && !noSkip && !isHOC && !neverSkipProps?.[keyInit]) {
|
|
334
|
-
if (keyInit === "group") {
|
|
335
|
-
const identifier = `t_group_${valInit}`;
|
|
336
|
-
addStyleToInsertRules(rulesToInsert, [
|
|
337
|
-
"container",
|
|
338
|
-
void 0,
|
|
339
|
-
identifier,
|
|
340
|
-
void 0,
|
|
341
|
-
[`.${identifier} { container-name: ${valInit}; container-type: ${webContainerType || "inline-size"}; }`]
|
|
342
|
-
]);
|
|
343
|
-
}
|
|
344
|
-
if (keyInit === "container" && valInit) addStyleToInsertRules(rulesToInsert, [
|
|
345
|
-
"container",
|
|
346
|
-
void 0,
|
|
347
|
-
"t_container",
|
|
348
|
-
void 0,
|
|
349
|
-
[`.t_container { container-type: ${webContainerType || "inline-size"}; }`]
|
|
350
|
-
]);
|
|
860
|
+
if (defaultProps) {
|
|
861
|
+
const defaultVal = defaultProps[keyOg] ?? defaultProps[keyInit];
|
|
862
|
+
if (defaultVal !== void 0 && valInit === defaultVal) return;
|
|
863
|
+
}
|
|
864
|
+
if (keyInit in skipProps && shouldSkipDirectProps && !neverSkipProps?.[keyInit]) {
|
|
865
|
+
if (keyInit === "container") pass[passContainerValue] = valInit;
|
|
351
866
|
if (keyInit === "transition" && typeof valInit === "string") {
|
|
352
|
-
const animationConfig =
|
|
353
|
-
if (animationConfig &&
|
|
867
|
+
const animationConfig = driverAnimations?.[valInit];
|
|
868
|
+
if (animationConfig && driverOutputStyle === "css" && process.env.IS_STATIC === "is_static") valInit = `all ${animationConfig}`;
|
|
354
869
|
else if (animationConfig) return;
|
|
355
870
|
} else return;
|
|
356
871
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
872
|
+
let isValidStyleKeyInit = isValidStyleKey(keyInit, validStyles, accept);
|
|
873
|
+
if (keyInit.startsWith("data-")) {
|
|
874
|
+
viewProps[keyInit] = valInit;
|
|
360
875
|
return;
|
|
361
876
|
}
|
|
362
|
-
let isValidStyleKeyInit = isValidStyleKey(keyInit, validStyles$1, accept);
|
|
363
|
-
if (isWeb) {
|
|
364
|
-
if ((staticConfig.isReactNative || styleProps.isAnimated && driver?.isReactNative && !driver.View?.acceptRenderProp) && keyInit.startsWith("data-")) {
|
|
365
|
-
keyInit = keyInit.replace("data-", "");
|
|
366
|
-
viewProps["dataSet"] ||= {};
|
|
367
|
-
viewProps["dataSet"][keyInit] = valInit;
|
|
368
|
-
return;
|
|
369
|
-
}
|
|
370
|
-
if (keyInit.startsWith("data-")) {
|
|
371
|
-
viewProps[keyInit] = valInit;
|
|
372
|
-
return;
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
877
|
if (!noExpand) {
|
|
376
878
|
if (keyInit === "disabled" && valInit === true) {
|
|
377
879
|
viewProps["aria-disabled"] = true;
|
|
@@ -379,11 +881,7 @@ const getSplitStyles = (props, staticConfig, theme, themeName, componentState, s
|
|
|
379
881
|
if (!variants?.disabled) return;
|
|
380
882
|
}
|
|
381
883
|
if (keyInit === "testID") {
|
|
382
|
-
|
|
383
|
-
else {
|
|
384
|
-
viewProps["data-testid"] = valInit;
|
|
385
|
-
if ((styleProps.isAnimated || staticConfig.isHOC) && driver?.isReactNative) viewProps.testID = valInit;
|
|
386
|
-
}
|
|
884
|
+
viewProps["data-testid"] = valInit;
|
|
387
885
|
return;
|
|
388
886
|
}
|
|
389
887
|
if (keyInit === "id") {
|
|
@@ -394,10 +892,10 @@ const getSplitStyles = (props, staticConfig, theme, themeName, componentState, s
|
|
|
394
892
|
let isVariant = !isValidStyleKeyInit && variants && keyInit in variants;
|
|
395
893
|
const isStyleLikeKey = isValidStyleKeyInit || isVariant;
|
|
396
894
|
const isStyleProp = isValidStyleKeyInit || isVariant && !noExpand;
|
|
397
|
-
if (isStyleProp &&
|
|
398
|
-
const shouldPassProp = !isStyleProp && isHOC ||
|
|
895
|
+
if (isStyleProp && asChildExceptStyleLike) return;
|
|
896
|
+
const shouldPassProp = !isStyleProp && isHOC || hocParentVariants && keyInit in hocParentVariants || inlineProps?.has(keyInit);
|
|
399
897
|
const parentVariant = parentVariants?.[keyInit];
|
|
400
|
-
const isHOCShouldPassThrough = Boolean(isHOC && (
|
|
898
|
+
const isHOCShouldPassThrough = Boolean(isHOC && (parentVariant || keyInit in skipProps));
|
|
401
899
|
const shouldPassThrough = shouldPassProp || isHOCShouldPassThrough;
|
|
402
900
|
if (process.env.NODE_ENV === "development" && debug === "verbose") {
|
|
403
901
|
console.groupCollapsed(` \u{1F511} ${keyOg}${keyInit !== keyOg ? ` (shorthand for ${keyInit})` : ""} ${shouldPassThrough ? "(pass)" : ""}`);
|
|
@@ -419,121 +917,195 @@ const getSplitStyles = (props, staticConfig, theme, themeName, componentState, s
|
|
|
419
917
|
if (process.env.NODE_ENV === "development" && debug === "verbose") console.groupEnd();
|
|
420
918
|
if (!isVariant) return;
|
|
421
919
|
}
|
|
422
|
-
if (
|
|
423
|
-
if (keyInit in skipProps && !(keyInit === "transition" && typeof valInit === "string" && !
|
|
920
|
+
if (shouldCheckSkipProps && !neverSkipProps?.[keyInit]) {
|
|
921
|
+
if (keyInit in skipProps && !(keyInit === "transition" && typeof valInit === "string" && !driverAnimations?.[valInit])) {
|
|
424
922
|
if (process.env.NODE_ENV === "development" && debug === "verbose") console.groupEnd();
|
|
425
923
|
return;
|
|
426
924
|
}
|
|
427
925
|
}
|
|
428
|
-
if (
|
|
926
|
+
if (isTextOrInput) {
|
|
429
927
|
if (valInit && (keyInit === "fontFamily" || keyInit === shorthands["fontFamily"]) && valInit in conf.fontsParsed) styleState.fontFamily = valInit;
|
|
430
928
|
}
|
|
431
929
|
const disablePropMap = !isStyleLikeKey;
|
|
432
|
-
if (
|
|
433
|
-
|
|
930
|
+
if (isValidStyleKeyInit && valInit != null && !(variants && keyInit in variants) && !(accept && keyInit in accept) && !(styledContextKeys?.has(keyInit) || styledContext && keyInit in styledContext)) {
|
|
931
|
+
contributeValue(styleState, keyInit, valInit, mergeStyle);
|
|
434
932
|
return;
|
|
435
933
|
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
if (typeof val === "string" && val) className = `${className} ${val}`.trim();
|
|
440
|
-
return;
|
|
441
|
-
}
|
|
442
|
-
if (!isHOC && disablePropMap && !isStyledContextProp) {
|
|
443
|
-
if (key in stylePropsAll && !isValidStyleKey(key, validStyles$1, accept)) {
|
|
444
|
-
if (process.env.NODE_ENV === "development") console.warn(`[tamagui] "${key}" is a text style prop and this component is not text \u2014 it would render on neither platform. Use a Text-based component, or html.* for raw web elements.`);
|
|
445
|
-
return;
|
|
446
|
-
}
|
|
447
|
-
viewProps[key] = val;
|
|
448
|
-
return;
|
|
449
|
-
}
|
|
450
|
-
if (process.env.NODE_ENV === "development" && debug === "verbose") {
|
|
451
|
-
console.groupCollapsed(" 💠 expanded", keyInit, "=>", key);
|
|
452
|
-
log(val);
|
|
453
|
-
console.groupEnd();
|
|
454
|
-
}
|
|
455
|
-
if (val == null) return;
|
|
456
|
-
if (accept && key in accept) {
|
|
457
|
-
viewProps[key] = val;
|
|
458
|
-
return;
|
|
459
|
-
}
|
|
460
|
-
const isHostStyleKey = !isHOC && isValidStyleKey(key, validStyles$1, accept) || false;
|
|
461
|
-
const isContextProgramKey = !isHOC && Boolean(isStyledContextProp);
|
|
462
|
-
if (conditionSource !== void 0) {
|
|
463
|
-
if (isHostStyleKey || isContextProgramKey) contributeVariantClauseValue(styleState, key, val, conditionSource, mergeStyle, originalVal, !isHostStyleKey);
|
|
464
|
-
else if (isHOC) {
|
|
465
|
-
const appended = appendFlatClause(styleState, viewProps[key], conditionSource, val);
|
|
466
|
-
if (appended !== void 0) viewProps[key] = appended;
|
|
467
|
-
else if (process.env.NODE_ENV === "development") console.warn(`[tamagui] conditional variant value for "${key}" cannot join the existing clause string; dropping the clause`);
|
|
468
|
-
} else if (process.env.NODE_ENV === "development") console.warn(`[tamagui] "${key}" is not a valid style on this component; the conditional variant value is dropped.`);
|
|
469
|
-
return;
|
|
470
|
-
}
|
|
471
|
-
if (isHostStyleKey || isContextProgramKey) {
|
|
472
|
-
contributeStyleValue(styleState, key, val, mergeStyle, originalVal, !isHostStyleKey);
|
|
473
|
-
return;
|
|
474
|
-
}
|
|
475
|
-
isVariant = variants && key in variants;
|
|
476
|
-
if (inlineProps?.has(key)) viewProps[key] = props[key] ?? val;
|
|
477
|
-
if (isHOC && Boolean(parentStaticConfig?.variants?.[keyInit])) {
|
|
478
|
-
passDownProp(viewProps, key, val);
|
|
479
|
-
if (process.env.NODE_ENV === "development" && debug === "verbose") {
|
|
480
|
-
console.groupCollapsed(` - passing down prop ${key}`);
|
|
481
|
-
log({
|
|
482
|
-
val,
|
|
483
|
-
after: { ...viewProps[key] }
|
|
484
|
-
});
|
|
485
|
-
console.groupEnd();
|
|
486
|
-
}
|
|
487
|
-
return;
|
|
488
|
-
}
|
|
489
|
-
if (!isVariant) {
|
|
490
|
-
if (isStyledContextProp) return;
|
|
491
|
-
if (key in stylePropsAll && !isValidStyleKey(key, validStyles$1, accept)) {
|
|
492
|
-
if (process.env.NODE_ENV === "development") console.warn(`[tamagui] "${key}" is a text style prop and this component is not text \u2014 it would render on neither platform. Use a Text-based component, or html.* for raw web elements.`);
|
|
493
|
-
return;
|
|
494
|
-
}
|
|
495
|
-
viewProps[key] = val;
|
|
496
|
-
}
|
|
497
|
-
});
|
|
934
|
+
pass[passMapSourceKey] = keyInit;
|
|
935
|
+
pass[passMapFlags] = disablePropMap ? 1 : 0;
|
|
936
|
+
contributeMappedValue(keyInit, valInit, styleState, disablePropMap);
|
|
498
937
|
if (process.env.NODE_ENV === "development" && debug === "verbose") {
|
|
499
938
|
try {
|
|
500
939
|
log(` \u2714\uFE0F expand complete`, keyInit);
|
|
501
940
|
log("style", { ...styleState.style });
|
|
502
941
|
log("viewProps", { ...viewProps });
|
|
503
|
-
log("transforms",
|
|
942
|
+
log("transforms", styleState.transformAccumulator);
|
|
504
943
|
} catch {}
|
|
505
944
|
console.groupEnd();
|
|
506
945
|
}
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
const conditionalStates = styleState.flatStateKeys || null;
|
|
511
|
-
const usesSafeArea = !!styleState.flatUsesSafeArea;
|
|
512
|
-
if (styleState.flatMediaKeys?.size) {
|
|
513
|
-
if (!hasMedia) hasMedia = /* @__PURE__ */ new Set();
|
|
514
|
-
if (typeof hasMedia !== "boolean") for (const key of styleState.flatMediaKeys) hasMedia.add(key);
|
|
515
|
-
}
|
|
516
|
-
if (styleState.flatGroupKeys?.size) {
|
|
517
|
-
pseudoGroups ||= /* @__PURE__ */ new Set();
|
|
518
|
-
for (const key of styleState.flatGroupKeys) pseudoGroups.add(key);
|
|
519
|
-
}
|
|
520
|
-
if (styleState.flatGroupMedia?.size) {
|
|
521
|
-
mediaGroups ||= /* @__PURE__ */ new Set();
|
|
522
|
-
for (const key of styleState.flatGroupMedia) mediaGroups.add(key);
|
|
946
|
+
} finally {
|
|
947
|
+
if (parentConditionKey) pass[passParentCursor] = null;
|
|
948
|
+
releaseConditionCursors(parentWatermark);
|
|
523
949
|
}
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
if (
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
950
|
+
}
|
|
951
|
+
const getSplitStyles = (props, staticConfig, theme, themeName, componentState, styleProps, parentSplitStyles, componentContext, groupContext, elementType, startedUnhydrated, debug, animationDriver) => {
|
|
952
|
+
const conf = getConfig();
|
|
953
|
+
if (staticConfig.styleFrontend?.normalizeStaticConfig) staticConfig = staticConfig.styleFrontend.normalizeStaticConfig(staticConfig, conf);
|
|
954
|
+
const driver = animationDriver || componentContext?.animationDriver || conf.animations;
|
|
955
|
+
const driverAnimations = driver?.animations;
|
|
956
|
+
const driverInputStyle = driver?.inputStyle;
|
|
957
|
+
const driverOutputStyle = driver?.outputStyle;
|
|
958
|
+
const resolvedDriver = driver?.isStub ? null : driver;
|
|
959
|
+
if (props.passThrough) return null;
|
|
960
|
+
const { shorthands } = conf;
|
|
961
|
+
const { isHOC, isText, isInput, variants, inlineProps, parentStaticConfig, acceptsClassName } = staticConfig;
|
|
962
|
+
const viewProps = {};
|
|
963
|
+
const mediaState$1 = styleProps.mediaState || mediaState;
|
|
964
|
+
let shouldDoClasses = !process.env.TAMAGUI_DID_OUTPUT_CSS && acceptsClassName && !styleProps.noClass;
|
|
965
|
+
const rulesToInsert = {};
|
|
966
|
+
const classNames = {};
|
|
967
|
+
let hasMedia = false;
|
|
968
|
+
let pseudoGroups;
|
|
969
|
+
let mediaGroups;
|
|
970
|
+
const staticPassthroughClassName = staticConfig.passthroughClassName || "";
|
|
971
|
+
let className = staticPassthroughClassName;
|
|
972
|
+
if (staticPassthroughClassName) shouldDoClasses = false;
|
|
973
|
+
const validStyles$1 = staticConfig.validStyles || (staticConfig.isText || staticConfig.isInput ? stylePropsText : validStyles);
|
|
974
|
+
if (process.env.NODE_ENV === "development" && (debug === "profile" || globalThis.time)) time`split-styles-setup`;
|
|
975
|
+
const styleState = {
|
|
976
|
+
classNames,
|
|
977
|
+
conf,
|
|
978
|
+
props,
|
|
979
|
+
styleProps,
|
|
980
|
+
componentState,
|
|
981
|
+
staticConfig,
|
|
982
|
+
style: null,
|
|
983
|
+
theme,
|
|
984
|
+
viewProps,
|
|
985
|
+
context: componentContext,
|
|
986
|
+
debug,
|
|
987
|
+
flatRulesToInsert: rulesToInsert,
|
|
988
|
+
flatShouldDoClasses: shouldDoClasses,
|
|
989
|
+
flatThemeName: themeName,
|
|
990
|
+
flatMediaState: mediaState$1,
|
|
991
|
+
flatGroupContext: groupContext,
|
|
992
|
+
animationDriver: resolvedDriver
|
|
993
|
+
};
|
|
994
|
+
if (canGenerateCSS && shouldDoClasses && styleProps.canPlatformPseudo) styleState.flatDeferCSS = true;
|
|
995
|
+
if (process.env.NODE_ENV === "development" && (debug === "profile" || globalThis.time)) time`style-state`;
|
|
996
|
+
if (process.env.NODE_ENV === "development" && debug === "verbose" && isClient) {
|
|
997
|
+
if (isDevTools) {
|
|
998
|
+
console.groupCollapsed("🔹 getSplitStyles 👇");
|
|
999
|
+
log({
|
|
1000
|
+
props,
|
|
1001
|
+
staticConfig,
|
|
1002
|
+
shouldDoClasses,
|
|
1003
|
+
styleProps,
|
|
1004
|
+
rulesToInsert,
|
|
1005
|
+
componentState,
|
|
1006
|
+
styleState,
|
|
1007
|
+
theme: { ...theme }
|
|
1008
|
+
});
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
const { asChild } = props;
|
|
1012
|
+
const { accept, neverSkipProps } = staticConfig;
|
|
1013
|
+
const { noSkip, disableExpandShorthands, noExpand, noClass, noMergeStyle, noNormalize, isAnimated, styledContext, styledContextKeys } = styleProps;
|
|
1014
|
+
const styleFrontend = staticConfig.styleFrontend;
|
|
1015
|
+
let frontendGroup;
|
|
1016
|
+
let frontendContainer;
|
|
1017
|
+
let frontendContainerType;
|
|
1018
|
+
const processedProps = props;
|
|
1019
|
+
const parentVariants = parentStaticConfig?.variants;
|
|
1020
|
+
const defaultProps = asChild ? getDefaultProps(staticConfig) : void 0;
|
|
1021
|
+
const asChildExceptStyleLike = asChild === "except-style" || asChild === "except-style-web";
|
|
1022
|
+
let containerValue;
|
|
1023
|
+
let containerName;
|
|
1024
|
+
let containerType;
|
|
1025
|
+
{
|
|
1026
|
+
const authoredContainerName = processedProps.containerName;
|
|
1027
|
+
const authoredContainerType = processedProps.containerType;
|
|
1028
|
+
containerName = typeof authoredContainerName === "string" && authoredContainerName.indexOf(":") === -1 ? authoredContainerName : void 0;
|
|
1029
|
+
containerType = typeof authoredContainerType === "string" && authoredContainerType.indexOf(":") === -1 ? authoredContainerType : void 0;
|
|
1030
|
+
}
|
|
1031
|
+
let hocMappedClassProperties;
|
|
1032
|
+
let hocMappedClasses;
|
|
1033
|
+
const pass = [
|
|
1034
|
+
styleState,
|
|
1035
|
+
conf,
|
|
1036
|
+
props,
|
|
1037
|
+
viewProps,
|
|
1038
|
+
staticConfig,
|
|
1039
|
+
validStyles$1,
|
|
1040
|
+
accept,
|
|
1041
|
+
neverSkipProps,
|
|
1042
|
+
variants,
|
|
1043
|
+
inlineProps,
|
|
1044
|
+
parentVariants,
|
|
1045
|
+
styleFrontend,
|
|
1046
|
+
styledContext,
|
|
1047
|
+
styledContextKeys,
|
|
1048
|
+
(noSkip ? passNoSkipFlag : 0) | (disableExpandShorthands ? passDisableShorthandsFlag : 0) | (noExpand ? passNoExpandFlag : 0) | (noMergeStyle ? passNoMergeFlag : 0) | (isHOC ? passHocFlag : 0) | (isText ? passTextFlag : 0) | (isInput ? passInputFlag : 0) | (asChildExceptStyleLike ? passAsChildStyleFlag : 0),
|
|
1049
|
+
debug,
|
|
1050
|
+
parentStaticConfig,
|
|
1051
|
+
defaultProps,
|
|
1052
|
+
driverAnimations,
|
|
1053
|
+
driverOutputStyle,
|
|
1054
|
+
elementType,
|
|
1055
|
+
className,
|
|
1056
|
+
shouldDoClasses,
|
|
1057
|
+
containerValue,
|
|
1058
|
+
containerName,
|
|
1059
|
+
containerType,
|
|
1060
|
+
frontendGroup,
|
|
1061
|
+
frontendContainer,
|
|
1062
|
+
frontendContainerType,
|
|
1063
|
+
hocMappedClassProperties,
|
|
1064
|
+
hocMappedClasses
|
|
1065
|
+
];
|
|
1066
|
+
styleState.flatPass = pass;
|
|
1067
|
+
forEachPropInForwardOrder(pass);
|
|
1068
|
+
[, , , , , , , , , , , , , , , , , , , , , className, shouldDoClasses, containerValue, containerName, containerType, frontendGroup, frontendContainer, frontendContainerType, hocMappedClassProperties, hocMappedClasses] = pass;
|
|
1069
|
+
if (containerValue) {
|
|
1070
|
+
containerName ??= typeof containerValue === "string" ? containerValue : void 0;
|
|
1071
|
+
containerType ??= "inline-size";
|
|
1072
|
+
contributeValue(styleState, containerName ? "container" : "containerType", containerName ? `${containerName} / ${containerType}` : containerType, mergeStyle);
|
|
1073
|
+
}
|
|
1074
|
+
if (process.env.NODE_ENV === "development" && (debug === "profile" || globalThis.time)) time`split-styles-propsend`;
|
|
1075
|
+
const conditionalStates = styleState.flatStateKeys || null;
|
|
1076
|
+
const usesSafeArea = !!styleState.flatUsesSafeArea;
|
|
1077
|
+
if (styleState.flatMediaKeys?.size) {
|
|
1078
|
+
if (!hasMedia) hasMedia = /* @__PURE__ */ new Set();
|
|
1079
|
+
if (typeof hasMedia !== "boolean") for (const key of styleState.flatMediaKeys) hasMedia.add(key);
|
|
1080
|
+
}
|
|
1081
|
+
if (styleState.flatGroupKeys?.size) {
|
|
1082
|
+
pseudoGroups ||= /* @__PURE__ */ new Set();
|
|
1083
|
+
for (const key of styleState.flatGroupKeys) pseudoGroups.add(key);
|
|
1084
|
+
}
|
|
1085
|
+
if (styleState.flatGroupMedia?.size) {
|
|
1086
|
+
mediaGroups ||= /* @__PURE__ */ new Set();
|
|
1087
|
+
for (const key of styleState.flatGroupMedia) mediaGroups.add(key);
|
|
1088
|
+
}
|
|
1089
|
+
if (styleProps.canPlatformPseudo && styleState.flatHasPlatformPseudo) {
|
|
1090
|
+
shouldDoClasses = false;
|
|
1091
|
+
styleState.flatShouldDoClasses = false;
|
|
1092
|
+
if (styleState.transformAccumulator) {
|
|
1093
|
+
mergeStyle(styleState, "transform", finalizeTransformAccumulator(styleState.transformAccumulator), 1, true);
|
|
1094
|
+
styleState.transformAccumulator = void 0;
|
|
1095
|
+
}
|
|
1096
|
+
convertDeferredInline(styleState, mergeStyle);
|
|
1097
|
+
}
|
|
1098
|
+
completeStreaming(styleState, mergeStyle);
|
|
1099
|
+
const effectiveTransition = styleState.style?.transition;
|
|
1100
|
+
if (effectiveTransition != null && styleState.style && driverOutputStyle !== "css") delete styleState.style.transition;
|
|
1101
|
+
if (!(noNormalize === false)) {
|
|
1102
|
+
if (styleState.style) {
|
|
1103
|
+
fixStyles(styleState.style);
|
|
1104
|
+
if (!noExpand && !noMergeStyle) styleToCSS(styleState.style);
|
|
1105
|
+
}
|
|
1106
|
+
if (styleState.transformAccumulator && !styleState.flatShouldDoClasses) {
|
|
1107
|
+
styleState.style ||= {};
|
|
1108
|
+
styleState.style.transform = finalizeTransformAccumulator(styleState.transformAccumulator);
|
|
537
1109
|
}
|
|
538
1110
|
if (parentSplitStyles) {
|
|
539
1111
|
if (shouldDoClasses) for (const key in parentSplitStyles.classNames) {
|
|
@@ -548,7 +1120,7 @@ const getSplitStyles = (props, staticConfig, theme, themeName, componentState, s
|
|
|
548
1120
|
}
|
|
549
1121
|
}
|
|
550
1122
|
}
|
|
551
|
-
if (!
|
|
1123
|
+
if (!noNormalize && !isHOC && (!isAnimated || driverInputStyle === "css") && Array.isArray(styleState.style?.transform)) styleState.style.transform = transformsToString(styleState.style.transform);
|
|
552
1124
|
flushDirectStyles(styleState);
|
|
553
1125
|
if (process.env.NODE_ENV === "development" && (debug === "profile" || globalThis.time)) time`split-styles-pre-result`;
|
|
554
1126
|
if (shouldTrackStyleTokenProvenance && styleState.style && styleState.tokenProvenance) {
|
|
@@ -578,52 +1150,48 @@ const getSplitStyles = (props, staticConfig, theme, themeName, componentState, s
|
|
|
578
1150
|
if (conditionalStates) result.programStates = conditionalStates;
|
|
579
1151
|
if (usesSafeArea) result.usesSafeArea = true;
|
|
580
1152
|
if (getDirectDynamicThemeAccess(styleState)) result.dynamicThemeAccess = true;
|
|
581
|
-
if (styleState.flatEnterKeys || styleState.flatExitKeys) {
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
};
|
|
592
|
-
}
|
|
593
|
-
const asChildExceptStyleLike = asChild === "except-style" || asChild === "except-style-web";
|
|
594
|
-
if (!styleProps.noMergeStyle) {
|
|
1153
|
+
if (styleState.flatEnterKeys || styleState.flatExitKeys) result.programLifecycleStyleKeys = {
|
|
1154
|
+
enter: effectiveLifecycleKeys(styleState.flatEnterKeys),
|
|
1155
|
+
exit: effectiveLifecycleKeys(styleState.flatExitKeys)
|
|
1156
|
+
};
|
|
1157
|
+
if (styleState.flatHasEnterStyle) result.hasEnterStyle = true;
|
|
1158
|
+
if (styleState.flatHasPlatformPseudo) result.platformPseudo = true;
|
|
1159
|
+
if (frontendGroup !== void 0) result.frontendGroup = frontendGroup;
|
|
1160
|
+
if (frontendContainer !== void 0) result.frontendContainer = frontendContainer;
|
|
1161
|
+
if (frontendContainerType !== void 0) result.frontendContainerType = frontendContainerType;
|
|
1162
|
+
if (!noMergeStyle) {
|
|
595
1163
|
if (!asChildExceptStyleLike) {
|
|
596
1164
|
const style = styleState.style;
|
|
597
1165
|
{
|
|
598
1166
|
const fontFamily = isText || isInput ? styleState.fontFamily : null;
|
|
599
1167
|
const fontFamilyClassName = fontFamily ? `font_${fontFamily}` : "";
|
|
600
|
-
const
|
|
601
|
-
const
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
if (
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
if (groupClassName)
|
|
610
|
-
if (
|
|
611
|
-
if (
|
|
612
|
-
const finalClassName = classList.join(" ");
|
|
613
|
-
const needsCssStyles = isReactNative || styleProps.isAnimated && driver?.isReactNative;
|
|
614
|
-
if (styleProps.isAnimated && driver?.inputStyle === "css") {
|
|
1168
|
+
const group = props.group ?? frontendGroup;
|
|
1169
|
+
const groupClassName = group ? `t_group_${group}` : "";
|
|
1170
|
+
let finalClassName = isText ? "is_Text" : "is_View";
|
|
1171
|
+
if (fontFamilyClassName) finalClassName += ` ${fontFamilyClassName}`;
|
|
1172
|
+
let hasPropertyClassNames = false;
|
|
1173
|
+
if (classNames) for (const key in classNames) {
|
|
1174
|
+
hasPropertyClassNames = true;
|
|
1175
|
+
finalClassName += ` ${classNames[key]}`;
|
|
1176
|
+
}
|
|
1177
|
+
if (groupClassName) finalClassName += ` ${groupClassName}`;
|
|
1178
|
+
if (className) finalClassName += ` ${className}`;
|
|
1179
|
+
if (isAnimated && driverInputStyle === "css") {
|
|
615
1180
|
viewProps.className = finalClassName;
|
|
616
1181
|
if (style) viewProps.style = style;
|
|
617
|
-
} else if (needsCssStyles) {
|
|
618
|
-
let cnStyles;
|
|
619
|
-
for (const name of finalClassName.split(" ")) {
|
|
620
|
-
cnStyles ||= { $$css: true };
|
|
621
|
-
cnStyles[name] = name;
|
|
622
|
-
}
|
|
623
|
-
viewProps.style = cnStyles ? [...Array.isArray(style) ? style : [style], cnStyles] : [style];
|
|
624
1182
|
} else {
|
|
625
|
-
if (finalClassName)
|
|
626
|
-
|
|
1183
|
+
if (finalClassName) {
|
|
1184
|
+
if (isHOC) viewProps[HOC_CLASSNAME_MARKER] = classNames;
|
|
1185
|
+
viewProps.className = finalClassName;
|
|
1186
|
+
}
|
|
1187
|
+
if (isHOC && hasPropertyClassNames) {
|
|
1188
|
+
const classStyle = {};
|
|
1189
|
+
Object.defineProperty(classStyle, TAMAGUI_CLASS_PROPS, {
|
|
1190
|
+
value: classNames,
|
|
1191
|
+
enumerable: false
|
|
1192
|
+
});
|
|
1193
|
+
viewProps.style = style ? [classStyle, style] : classStyle;
|
|
1194
|
+
} else if (style) viewProps.style = style;
|
|
627
1195
|
}
|
|
628
1196
|
}
|
|
629
1197
|
}
|
|
@@ -650,46 +1218,22 @@ const getSplitStyles = (props, staticConfig, theme, themeName, componentState, s
|
|
|
650
1218
|
if (process.env.NODE_ENV === "development" && (debug === "profile" || globalThis.time)) time`split-styles-done`;
|
|
651
1219
|
return result;
|
|
652
1220
|
};
|
|
653
|
-
function mergeFlatTransforms(target, flatTransforms) {
|
|
654
|
-
const transform = [];
|
|
655
|
-
if ("x" in flatTransforms) transform.push({ translateX: flatTransforms.x });
|
|
656
|
-
if ("y" in flatTransforms) transform.push({ translateY: flatTransforms.y });
|
|
657
|
-
if ("rotate" in flatTransforms) transform.push({ rotate: flatTransforms.rotate });
|
|
658
|
-
const hasScaleX = "scaleX" in flatTransforms;
|
|
659
|
-
const hasScaleY = "scaleY" in flatTransforms;
|
|
660
|
-
if (hasScaleX && hasScaleY && Object.is(flatTransforms.scaleX, flatTransforms.scaleY)) transform.push({ scale: flatTransforms.scaleX });
|
|
661
|
-
else {
|
|
662
|
-
if (hasScaleX) transform.push({ scaleX: flatTransforms.scaleX });
|
|
663
|
-
if (hasScaleY) transform.push({ scaleY: flatTransforms.scaleY });
|
|
664
|
-
if (!hasScaleX && !hasScaleY && "scale" in flatTransforms) transform.push({ scale: flatTransforms.scale });
|
|
665
|
-
}
|
|
666
|
-
const keys = [];
|
|
667
|
-
for (const key in flatTransforms) if (key !== "x" && key !== "y" && key !== "rotate" && key !== "scale" && key !== "scaleX" && key !== "scaleY") keys.push(key);
|
|
668
|
-
keys.sort(sortString);
|
|
669
|
-
for (const key of keys) transform.push({ [mapTransformKeys[key] || key]: flatTransforms[key] });
|
|
670
|
-
if (Array.isArray(target.transform)) transform.push(...target.transform);
|
|
671
|
-
target.transform = transform;
|
|
672
|
-
}
|
|
673
1221
|
function mergeStyle(styleState, key, val, _importance, disableNormalize = false, originalVal) {
|
|
674
1222
|
const { viewProps, styleProps, staticConfig } = styleState;
|
|
675
|
-
|
|
676
|
-
const contextProps = contextConfig?.props;
|
|
677
|
-
const inheritedContextPropKeys = !staticConfig.context || staticConfig.context === staticConfig.parentStaticConfig?.context ? staticConfig.parentStaticConfig?.contextProps : void 0;
|
|
678
|
-
const contextPropKeys = staticConfig.contextProps || inheritedContextPropKeys;
|
|
679
|
-
if (contextProps && key in contextProps || contextPropKeys?.includes(key) || contextConfig?.propKeys?.includes(key)) {
|
|
1223
|
+
if (getContextPropSet(staticConfig)?.has(key)) {
|
|
680
1224
|
styleState.overriddenContextProps ||= {};
|
|
681
1225
|
const originalFromState = styleState.originalContextPropValues?.[key];
|
|
682
1226
|
styleState.overriddenContextProps[key] = originalVal ?? originalFromState ?? val;
|
|
683
1227
|
}
|
|
684
|
-
if (key in stylePropsTransform) {
|
|
685
|
-
styleState.
|
|
686
|
-
styleState.
|
|
1228
|
+
if (key === "transform" || key in stylePropsTransform) {
|
|
1229
|
+
styleState.transformAccumulator ||= createTransformAccumulator();
|
|
1230
|
+
addTransformValue(styleState.transformAccumulator, key, val);
|
|
687
1231
|
} else {
|
|
688
|
-
const out =
|
|
1232
|
+
const out = !disableNormalize && !styleProps.noNormalize ? normalizeValueWithProperty(val, key) : val;
|
|
689
1233
|
if (staticConfig.accept && key in staticConfig.accept) viewProps[key] = out;
|
|
690
1234
|
else {
|
|
691
1235
|
styleState.style ||= {};
|
|
692
|
-
styleState.style[key] =
|
|
1236
|
+
styleState.style[key] = out;
|
|
693
1237
|
if (shouldTrackStyleTokenProvenance) recordStyleTokenProvenance(styleState, key, originalVal);
|
|
694
1238
|
}
|
|
695
1239
|
}
|
|
@@ -704,108 +1248,1425 @@ function recordStyleTokenProvenance(styleState, key, originalVal) {
|
|
|
704
1248
|
if (tokenName !== "" && (Object.prototype.hasOwnProperty.call(styleState.theme, tokenName) || Object.prototype.hasOwnProperty.call(styleState.conf.themes?.[styleState.flatThemeName || ""] || {}, tokenName) || Object.values(styleState.conf.tokensParsed).some((category) => Object.prototype.hasOwnProperty.call(category, tokenName)))) (styleState.tokenProvenance ||= {})[key] = originalVal;
|
|
705
1249
|
else if (styleState.tokenProvenance && key in styleState.tokenProvenance) delete styleState.tokenProvenance[key];
|
|
706
1250
|
}
|
|
707
|
-
const
|
|
708
|
-
const {
|
|
1251
|
+
const resolveAcceptedStyle = (styleState, styleIn) => {
|
|
1252
|
+
const { conf, styleProps } = styleState;
|
|
709
1253
|
const styleOut = {};
|
|
710
1254
|
let originalValues;
|
|
711
1255
|
const styleInOriginalValues = styleOriginalValues.get(styleIn);
|
|
712
|
-
const
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
1256
|
+
const childState = {
|
|
1257
|
+
...styleState,
|
|
1258
|
+
classNames: {},
|
|
1259
|
+
flatShouldDoClasses: false,
|
|
1260
|
+
props: styleIn,
|
|
1261
|
+
style: styleOut,
|
|
1262
|
+
transformAccumulator: void 0
|
|
1263
|
+
};
|
|
1264
|
+
childState.flatUsed = void 0;
|
|
1265
|
+
childState.flatTransitions = void 0;
|
|
1266
|
+
childState.flatAtomics = void 0;
|
|
1267
|
+
childState.flatSingleEntries = void 0;
|
|
1268
|
+
childState.flatSlots = void 0;
|
|
1269
|
+
childState.flatBorderDefaultRequests = void 0;
|
|
1270
|
+
const mergeAccepted = (_state, key, value, _importance, disableNormalize, originalValue) => {
|
|
1271
|
+
styleOut[key] = disableNormalize || styleProps.noNormalize ? value : normalizeValueWithProperty(value, key);
|
|
1272
|
+
const trackedOriginal = styleInOriginalValues?.[key] ?? originalValue;
|
|
1273
|
+
if (trackedOriginal !== void 0) (originalValues ||= {})[key] = trackedOriginal;
|
|
1274
|
+
};
|
|
1275
|
+
for (let key in styleIn) {
|
|
1276
|
+
const value = styleIn[key];
|
|
1277
|
+
key = conf.shorthands[key] || key;
|
|
1278
|
+
if (key in skipProps || value == null) continue;
|
|
1279
|
+
contributeValue(childState, key, value, mergeAccepted);
|
|
1280
|
+
}
|
|
1281
|
+
completeStreaming(childState, mergeAccepted);
|
|
1282
|
+
if (childState.transformAccumulator) styleOut.transform = finalizeTransformAccumulator(childState.transformAccumulator);
|
|
1283
|
+
if (!styleProps.noNormalize) fixStyles(styleOut);
|
|
1284
|
+
if (originalValues) styleOriginalValues.set(styleOut, originalValues);
|
|
1285
|
+
return styleOut;
|
|
1286
|
+
};
|
|
1287
|
+
function passDownProp(viewProps, key, val) {
|
|
1288
|
+
if (key in viewProps) delete viewProps[key];
|
|
1289
|
+
viewProps[key] = val;
|
|
1290
|
+
}
|
|
1291
|
+
let frameSequence = 0;
|
|
1292
|
+
function streamWriteCSS(state, property, value, cursor, original, conditionOverride = -1) {
|
|
1293
|
+
const direct = state;
|
|
1294
|
+
const condition = conditionOverride !== -1 ? conditionOverride : cursor ? conditionNumbers[cursor + conditionValueOffset] : 0;
|
|
1295
|
+
const identity = cursor ? conditionTexts[cursor + conditionKeyOffset] || "" : "";
|
|
1296
|
+
if (property.charCodeAt(0) === 116 && property.startsWith("transition")) {
|
|
1297
|
+
const transitions = direct.flatTransitions ||= [];
|
|
1298
|
+
for (let index = 0; index < transitions.length; index++) if (transitions[index].property === property && transitions[index].identity === identity) {
|
|
1299
|
+
transitions[index].value = value;
|
|
1300
|
+
transitions[index].condition = condition;
|
|
1301
|
+
return;
|
|
1302
|
+
}
|
|
1303
|
+
transitions.push({
|
|
1304
|
+
property,
|
|
1305
|
+
value,
|
|
1306
|
+
condition,
|
|
1307
|
+
identity,
|
|
1308
|
+
selector: cursor ? conditionTexts[cursor + conditionSelectorOffset] || "" : "",
|
|
1309
|
+
wrappers: cursor ? conditionWrapperCopy(cursor) : void 0
|
|
1310
|
+
});
|
|
1311
|
+
return;
|
|
1312
|
+
}
|
|
1313
|
+
streamAtomic(state, property, value, condition, identity, cursor ? conditionTexts[cursor + conditionSelectorOffset] || "" : "", cursor ? conditionWrappers : void 0, cursor ? conditionNumbers[cursor + conditionWrapperOffset] >> 3 : 0, cursor ? conditionNumbers[cursor + conditionWrapperOffset] & 7 : 0, direct.flatWeakContribution === true, original);
|
|
1314
|
+
}
|
|
1315
|
+
function streamWriteInline(state, property, value, cursor, merge, original, normalize = false, conditionOverride = -1) {
|
|
1316
|
+
const direct = state;
|
|
1317
|
+
const condition = conditionOverride !== -1 ? conditionOverride : cursor ? conditionNumbers[cursor + conditionValueOffset] : 0;
|
|
1318
|
+
const importance = condition ? Math.floor(condition / 256) + 1 : 0;
|
|
1319
|
+
const used = direct.flatUsed ||= {};
|
|
1320
|
+
const previous = used[property];
|
|
1321
|
+
if (previous !== void 0) {
|
|
1322
|
+
if (previous > importance) return;
|
|
1323
|
+
if (direct.flatWeakContribution === true) return;
|
|
1324
|
+
}
|
|
1325
|
+
used[property] = importance;
|
|
1326
|
+
merge(state, property, value, 1, !normalize, original);
|
|
1327
|
+
}
|
|
1328
|
+
function streamRetractInline(state, property, cursor) {
|
|
1329
|
+
const direct = state;
|
|
1330
|
+
const condition = cursor ? conditionNumbers[cursor + conditionValueOffset] : 0;
|
|
1331
|
+
const importance = condition ? Math.floor(condition / 256) + 1 : 0;
|
|
1332
|
+
const used = direct.flatUsed ||= {};
|
|
1333
|
+
const previous = used[property];
|
|
1334
|
+
if (previous !== void 0 && previous > importance) return;
|
|
1335
|
+
used[property] = importance;
|
|
1336
|
+
if (state.style) delete state.style[property];
|
|
1337
|
+
}
|
|
1338
|
+
function convertDeferredInline(state, merge) {
|
|
1339
|
+
const direct = state;
|
|
1340
|
+
const used = direct.flatUsed ||= {};
|
|
1341
|
+
const consume = (entries) => {
|
|
1342
|
+
for (let index = 0; index < entries.length; index++) {
|
|
1343
|
+
const entry = entries[index];
|
|
1344
|
+
const condition = entry.condition;
|
|
1345
|
+
if (condition && !(condition & 1)) continue;
|
|
1346
|
+
const importance = condition ? Math.floor(condition / 256) + 1 : 0;
|
|
1347
|
+
const previous = used[entry.property];
|
|
1348
|
+
if (previous !== void 0 && previous > importance) continue;
|
|
1349
|
+
used[entry.property] = importance;
|
|
1350
|
+
merge(state, entry.property, entry.value, 1, true, entry.original !== void 0 ? entry.original : entry.value);
|
|
1351
|
+
}
|
|
1352
|
+
};
|
|
1353
|
+
const slots = direct.flatSlots;
|
|
1354
|
+
if (slots) {
|
|
1355
|
+
direct.flatSlots = void 0;
|
|
1356
|
+
for (const property in slots) consume(slots[property]);
|
|
1357
|
+
}
|
|
1358
|
+
const transitions = direct.flatTransitions;
|
|
1359
|
+
if (transitions) {
|
|
1360
|
+
direct.flatTransitions = void 0;
|
|
1361
|
+
consume(transitions);
|
|
1362
|
+
}
|
|
1363
|
+
direct.flatBorderDefaultRequests = void 0;
|
|
1364
|
+
}
|
|
1365
|
+
function completeStreaming(state, merge) {
|
|
1366
|
+
const direct = state;
|
|
1367
|
+
const shadow = direct.flatWebShadow;
|
|
1368
|
+
if (shadow && (direct.flatBoxShadowSequence || 0) <= shadow[4]) {
|
|
1369
|
+
const offset = shadow[1] || {
|
|
1370
|
+
width: 0,
|
|
1371
|
+
height: 0
|
|
1372
|
+
};
|
|
1373
|
+
const color = normalizeColor(shadow[0], shadow[2] ?? 1);
|
|
1374
|
+
if (color) {
|
|
1375
|
+
const next = `${shadowUnit(offset.width)} ${shadowUnit(offset.height)} ${shadowUnit(shadow[3])} ${color}`;
|
|
1376
|
+
emitProperty(state, "boxShadow", direct.flatBoxShadow ? `${direct.flatBoxShadow}, ${next}` : next, null, merge, shadow[5], shadow[6]);
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
completeStreamingCSS(state);
|
|
1380
|
+
}
|
|
1381
|
+
function emitAtParentCondition(state, property, value, merge, originalValue, contextOnly) {
|
|
1382
|
+
emitValue(state, property, value, state.flatPass?.[passParentCursor] || null, merge, originalValue, contextOnly);
|
|
1383
|
+
}
|
|
1384
|
+
function emitUnderCondition(state, property, value, cursor, merge, originalValue, contextOnly, warnMode, warnSource) {
|
|
1385
|
+
const condition = conditionNumbers[cursor + conditionValueOffset];
|
|
1386
|
+
if (merge && property && condition) state.flatPropSawCondition = true;
|
|
1387
|
+
if (!(conditionNumbers[cursor + conditionFlagsOffset] & conditionResolvedFlag)) {
|
|
1388
|
+
if (warnMode && process.env.NODE_ENV === "development") warnRefusedValue(property, warnSource, `unknown modifier "${conditionTexts[cursor + conditionUnresolvedNameOffset] || ""}"`);
|
|
1389
|
+
return 0;
|
|
1390
|
+
}
|
|
1391
|
+
const unsupportedState = conditionTexts[cursor + conditionUnsupportedStateOffset] || "";
|
|
1392
|
+
if (warnMode && unsupportedState && process.env.NODE_ENV === "development") warnOnce(`${property}: "${unsupportedState}:" has no native component-state source; dropping the clause`);
|
|
1393
|
+
if (merge && property && condition & 2 && (condition & 1 || canGenerateCSS && state.flatShouldDoClasses || warnMode === 1 && false)) {
|
|
1394
|
+
emitValue(state, property, value, cursor, merge, warnMode === 2 ? originalValue : originalValue ?? value, contextOnly);
|
|
1395
|
+
const flags = conditionNumbers[cursor + conditionFlagsOffset];
|
|
1396
|
+
if (flags & conditionEnterFlag) state.flatHasEnterStyle = true;
|
|
1397
|
+
if (flags & conditionPlatformPseudoFlag) state.flatHasPlatformPseudo = true;
|
|
1398
|
+
} else if (merge && property && condition & 2) {
|
|
1399
|
+
const flags = conditionNumbers[cursor + conditionFlagsOffset];
|
|
1400
|
+
if (flags & conditionEnterFlag) state.flatHasEnterStyle = true;
|
|
1401
|
+
if (flags & conditionPlatformPseudoFlag) state.flatHasPlatformPseudo = true;
|
|
1402
|
+
}
|
|
1403
|
+
return condition;
|
|
1404
|
+
}
|
|
1405
|
+
const directStyleHandler = {
|
|
1406
|
+
segment(state, start, end, isBase, valid, source, chainStart, chainEnd, chainValid, chainCount, _result, failure, failureIndex, property, merge, originalValue, contextOnly) {
|
|
1407
|
+
if (isBase) {
|
|
1408
|
+
if (start === end) return;
|
|
1409
|
+
feedCompoundSegment(state, source, start, end, true, valid || failure === "invalid-character" || failure === "stray-comment-close", "");
|
|
1410
|
+
if (!valid) {
|
|
1411
|
+
if (failure === "invalid-character" || failure === "stray-comment-close") return 16;
|
|
1412
|
+
if (process.env.NODE_ENV === "development") warnRefusedValue(property, source, failure === "unterminated-string" ? "an unterminated string" : failure === "unterminated-comment" ? "an unterminated \"/*\" comment" : "an unterminated \"(\"");
|
|
1413
|
+
return;
|
|
1414
|
+
}
|
|
1415
|
+
const value = source.slice(start, end);
|
|
1416
|
+
emitAtParentCondition(state, property, value, merge, value, contextOnly);
|
|
1417
|
+
return 5;
|
|
1418
|
+
}
|
|
1419
|
+
if (!chainValid) {
|
|
1420
|
+
if (process.env.NODE_ENV === "development") warnRefusedValue(property, source, failure === "invalid-character" ? `"${source[failureIndex]}" would end the declaration or rule` : failure === "unterminated-string" ? "an unterminated string" : failure === "unterminated-comment" ? "an unterminated \"/*\" comment" : failure === "stray-comment-close" ? "a stray \"*/\"" : "an unterminated \"(\"");
|
|
1421
|
+
return;
|
|
1422
|
+
}
|
|
1423
|
+
if (start === end) {
|
|
1424
|
+
if (process.env.NODE_ENV === "development") warnRefusedValue(property, source, "a conditional clause has no value");
|
|
1425
|
+
return;
|
|
1426
|
+
}
|
|
1427
|
+
if (property === "aspectRatio" && chainCount === 1) {
|
|
1428
|
+
const left = Number(source.slice(chainStart, chainEnd));
|
|
1429
|
+
const right = Number(source.slice(start, end));
|
|
1430
|
+
if (chainStart < chainEnd && Number.isFinite(left) && left > 0 && Number.isFinite(right) && right > 0) return 12;
|
|
1431
|
+
}
|
|
1432
|
+
const directState = state;
|
|
1433
|
+
const cursor = directState.flatScanCursor;
|
|
1434
|
+
const condition = valid ? emitUnderCondition(state, property, source.slice(start, end), cursor, merge, void 0, contextOnly, 1, source) : conditionNumbers[cursor + conditionFlagsOffset] & conditionResolvedFlag ? conditionNumbers[cursor + conditionValueOffset] : 0;
|
|
1435
|
+
feedCompoundSegment(directState, source, start, end, false, valid && Boolean(condition), condition && directState.flatPass?.[passCompoundIndexes] ? conditionTexts[cursor + conditionKeyOffset] || "" : "");
|
|
1436
|
+
if (!condition) return;
|
|
1437
|
+
if (!valid) {
|
|
1438
|
+
if (process.env.NODE_ENV === "development") warnRefusedValue(property, source, failure === "invalid-character" ? `"${source[failureIndex]}" would end the declaration or rule` : failure === "unterminated-string" ? "an unterminated string" : failure === "unterminated-comment" ? "an unterminated \"/*\" comment" : failure === "stray-comment-close" ? "a stray \"*/\"" : "an unterminated \"(\"");
|
|
1439
|
+
return;
|
|
1440
|
+
}
|
|
1441
|
+
return 4 | (condition & 12 ? 2 : 0);
|
|
1442
|
+
},
|
|
1443
|
+
modifier(state, start, end, valid, first, source) {
|
|
1444
|
+
const directState = state;
|
|
1445
|
+
let cursor = directState.flatScanCursor;
|
|
1446
|
+
if (!cursor) cursor = directState.flatScanCursor = acquireConditionCursor(directState.flatPass?.[passParentCursor] || null);
|
|
1447
|
+
else if (first) resetConditionCursor(cursor, directState.flatPass?.[passParentCursor] || null);
|
|
1448
|
+
if (!valid) {
|
|
1449
|
+
setConditionUnresolved(cursor);
|
|
1450
|
+
return;
|
|
1451
|
+
}
|
|
1452
|
+
if (conditionNumbers[cursor + conditionFlagsOffset] & conditionResolvedFlag) resolveConditionModifier(state, cursor, source.slice(start, end));
|
|
1453
|
+
},
|
|
1454
|
+
chain(state, _start, _end, valid) {
|
|
1455
|
+
const cursor = state.flatScanCursor;
|
|
1456
|
+
if (cursor) {
|
|
1457
|
+
if (!valid) setConditionUnresolved(cursor);
|
|
1458
|
+
if (conditionNumbers[cursor + conditionFlagsOffset] & conditionResolvedFlag) commitConditionCursor(state, cursor);
|
|
1459
|
+
}
|
|
1460
|
+
return true;
|
|
1461
|
+
},
|
|
1462
|
+
end(state, source, result, lastPayloadStart, chainCount, property, merge, originalValue, contextOnly, failure, failureIndex) {
|
|
1463
|
+
let hasBase = !!(result & 1);
|
|
1464
|
+
if (result & 16) {
|
|
1465
|
+
if (chainCount === 0) {
|
|
1466
|
+
emitAtParentCondition(state, property, source, merge, originalValue ?? source, contextOnly);
|
|
1467
|
+
hasBase = true;
|
|
1468
|
+
} else if (process.env.NODE_ENV === "development") warnRefusedValue(property, source, failure === "invalid-character" ? `"${source[failureIndex]}" would end the declaration or rule` : failure === "unterminated-string" ? "an unterminated string" : failure === "unterminated-comment" ? "an unterminated \"/*\" comment" : failure === "stray-comment-close" ? "a stray \"*/\"" : "an unterminated \"(\"");
|
|
1469
|
+
}
|
|
1470
|
+
if (result & 8 && chainCount === 1) {
|
|
1471
|
+
emitAtParentCondition(state, property, source, merge, originalValue ?? source, contextOnly);
|
|
1472
|
+
hasBase = true;
|
|
1473
|
+
}
|
|
1474
|
+
if (process.env.NODE_ENV === "development" && !hasBase && result & 4 && (property in tokenCategories.color || property in tokenCategoryByProperty) && splitComponents(source.slice(lastPayloadStart)).length > 1) warnOnce(`${property}="${source}" has multiple values after its first conditional. Write the base value before the first conditional.`);
|
|
1475
|
+
if ((!canGenerateCSS || !state.flatShouldDoClasses) && result & 2 && !hasBase) {
|
|
1476
|
+
const value = implicitLifecycleBase(property);
|
|
1477
|
+
if (value !== null) emitAtParentCondition(state, property, value, merge, value, contextOnly);
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
};
|
|
1481
|
+
function implicitLifecycleBase(property) {
|
|
1482
|
+
return property === "opacity" || property === "scale" || property === "scaleX" || property === "scaleY" ? 1 : property === "rotate" ? "0deg" : property === "x" || property === "y" ? 0 : null;
|
|
1483
|
+
}
|
|
1484
|
+
const legacyTransformParts = /* @__PURE__ */ new Set([
|
|
1485
|
+
"matrix",
|
|
1486
|
+
"perspective",
|
|
1487
|
+
"rotateX",
|
|
1488
|
+
"rotateY",
|
|
1489
|
+
"rotateZ",
|
|
1490
|
+
"scaleZ",
|
|
1491
|
+
"skewX",
|
|
1492
|
+
"skewY"
|
|
1493
|
+
]);
|
|
1494
|
+
const webShadowParts = {
|
|
1495
|
+
shadowColor: 1,
|
|
1496
|
+
shadowOffset: 2,
|
|
1497
|
+
shadowOpacity: 3,
|
|
1498
|
+
shadowRadius: 4
|
|
1499
|
+
};
|
|
1500
|
+
const webTextShadowParts = /* @__PURE__ */ new Set([
|
|
1501
|
+
"textShadowColor",
|
|
1502
|
+
"textShadowOffset",
|
|
1503
|
+
"textShadowRadius"
|
|
1504
|
+
]);
|
|
1505
|
+
const lineStyles = /* @__PURE__ */ new Set([
|
|
1506
|
+
"none",
|
|
1507
|
+
"hidden",
|
|
1508
|
+
"dotted",
|
|
1509
|
+
"dashed",
|
|
1510
|
+
"solid",
|
|
1511
|
+
"double",
|
|
1512
|
+
"groove",
|
|
1513
|
+
"ridge",
|
|
1514
|
+
"inset",
|
|
1515
|
+
"outset"
|
|
1516
|
+
]);
|
|
1517
|
+
const borderTargets = {
|
|
1518
|
+
border: {
|
|
1519
|
+
width: [
|
|
1520
|
+
"borderTopWidth",
|
|
1521
|
+
"borderRightWidth",
|
|
1522
|
+
"borderBottomWidth",
|
|
1523
|
+
"borderLeftWidth"
|
|
1524
|
+
],
|
|
1525
|
+
style: [
|
|
1526
|
+
"borderTopStyle",
|
|
1527
|
+
"borderRightStyle",
|
|
1528
|
+
"borderBottomStyle",
|
|
1529
|
+
"borderLeftStyle"
|
|
1530
|
+
],
|
|
1531
|
+
color: [
|
|
1532
|
+
"borderTopColor",
|
|
1533
|
+
"borderRightColor",
|
|
1534
|
+
"borderBottomColor",
|
|
1535
|
+
"borderLeftColor"
|
|
1536
|
+
]
|
|
1537
|
+
},
|
|
1538
|
+
borderTop: {
|
|
1539
|
+
width: ["borderTopWidth"],
|
|
1540
|
+
style: ["borderTopStyle"],
|
|
1541
|
+
color: ["borderTopColor"]
|
|
1542
|
+
},
|
|
1543
|
+
borderRight: {
|
|
1544
|
+
width: ["borderRightWidth"],
|
|
1545
|
+
style: ["borderRightStyle"],
|
|
1546
|
+
color: ["borderRightColor"]
|
|
1547
|
+
},
|
|
1548
|
+
borderBottom: {
|
|
1549
|
+
width: ["borderBottomWidth"],
|
|
1550
|
+
style: ["borderBottomStyle"],
|
|
1551
|
+
color: ["borderBottomColor"]
|
|
1552
|
+
},
|
|
1553
|
+
borderLeft: {
|
|
1554
|
+
width: ["borderLeftWidth"],
|
|
1555
|
+
style: ["borderLeftStyle"],
|
|
1556
|
+
color: ["borderLeftColor"]
|
|
1557
|
+
},
|
|
1558
|
+
outline: {
|
|
1559
|
+
width: ["outlineWidth"],
|
|
1560
|
+
style: ["outlineStyle"],
|
|
1561
|
+
color: ["outlineColor"]
|
|
1562
|
+
},
|
|
1563
|
+
borderBlock: {
|
|
1564
|
+
width: ["borderBlockStartWidth", "borderBlockEndWidth"],
|
|
1565
|
+
style: ["borderBlockStartStyle", "borderBlockEndStyle"],
|
|
1566
|
+
color: ["borderBlockStartColor", "borderBlockEndColor"]
|
|
1567
|
+
},
|
|
1568
|
+
borderInline: {
|
|
1569
|
+
width: ["borderInlineStartWidth", "borderInlineEndWidth"],
|
|
1570
|
+
style: ["borderInlineStartStyle", "borderInlineEndStyle"],
|
|
1571
|
+
color: ["borderInlineStartColor", "borderInlineEndColor"]
|
|
1572
|
+
}
|
|
1573
|
+
};
|
|
1574
|
+
const tokenLookup = {
|
|
1575
|
+
value: void 0,
|
|
1576
|
+
fromTheme: false,
|
|
1577
|
+
themeKey: ""
|
|
1578
|
+
};
|
|
1579
|
+
function fillTokenLookup(value, fromTheme, themeKey) {
|
|
1580
|
+
tokenLookup.value = value;
|
|
1581
|
+
tokenLookup.fromTheme = fromTheme;
|
|
1582
|
+
tokenLookup.themeKey = themeKey;
|
|
1583
|
+
return tokenLookup;
|
|
1584
|
+
}
|
|
1585
|
+
function tokenVariable(state, property, name) {
|
|
1586
|
+
let lookupName = name.charCodeAt(0) === 36 ? name.slice(1) : name;
|
|
1587
|
+
if (property === "fontFamily") {
|
|
1588
|
+
const family = state.conf.fontsParsed[lookupName]?.family;
|
|
1589
|
+
return family ? fillTokenLookup(family, false, lookupName) : void 0;
|
|
1590
|
+
}
|
|
1591
|
+
const fontKey = property === "fontSize" ? "size" : property === "fontWeight" ? "weight" : property === "lineHeight" || property === "letterSpacing" ? property : void 0;
|
|
1592
|
+
if (fontKey) {
|
|
1593
|
+
const value = (state.conf.fontsParsed[state.fontFamily || state.conf.defaultFontToken] || state.conf.fontsParsed[state.conf.defaultFontToken])?.[fontKey]?.[lookupName];
|
|
1594
|
+
return value ? fillTokenLookup(value, false, lookupName) : void 0;
|
|
1595
|
+
}
|
|
1596
|
+
const category = getTokenCategoryForProperty(property);
|
|
1597
|
+
const dot = lookupName.indexOf(".");
|
|
1598
|
+
if (dot !== -1) {
|
|
1599
|
+
const prefix = lookupName.slice(0, dot);
|
|
1600
|
+
if (!category || prefix === category || prefix === "color") lookupName = lookupName.slice(dot + 1);
|
|
1601
|
+
}
|
|
1602
|
+
if (category) {
|
|
1603
|
+
const own = state.conf.tokensParsed[category]?.[lookupName];
|
|
1604
|
+
if (own) return fillTokenLookup(own, false, lookupName);
|
|
1605
|
+
for (const sibling of [
|
|
1606
|
+
"color",
|
|
1607
|
+
"space",
|
|
1608
|
+
"size",
|
|
1609
|
+
"radius",
|
|
1610
|
+
"zIndex"
|
|
1611
|
+
]) if (sibling !== category && state.conf.tokensParsed[sibling]?.[lookupName]) return;
|
|
1612
|
+
} else {
|
|
1613
|
+
const first = lookupName.charCodeAt(0);
|
|
1614
|
+
if (first >= 48 && first <= 57 || first === 43 || first === 45 || first === 46) return;
|
|
1615
|
+
}
|
|
1616
|
+
const theme = state.theme?.[lookupName] || state.conf.themes?.[state.flatThemeName || ""]?.[lookupName];
|
|
1617
|
+
if (theme) return fillTokenLookup(theme, true, lookupName);
|
|
1618
|
+
if (category) return;
|
|
1619
|
+
const token = state.conf.tokensParsed.space?.[lookupName] || state.conf.tokensParsed.color?.[lookupName];
|
|
1620
|
+
return token ? fillTokenLookup(token, false, lookupName) : void 0;
|
|
1621
|
+
}
|
|
1622
|
+
let literalMissConf = null;
|
|
1623
|
+
let literalMissRevision = -1;
|
|
1624
|
+
let literalMisses = /* @__PURE__ */ new WeakMap();
|
|
1625
|
+
const literalMissRootTheme = {};
|
|
1626
|
+
function isFontKeyedProperty(property) {
|
|
1627
|
+
return property === "fontFamily" || property === "fontSize" || property === "fontWeight" || property === "lineHeight" || property === "letterSpacing";
|
|
1628
|
+
}
|
|
1629
|
+
function literalMissSet(state) {
|
|
1630
|
+
const revision = getConfigRevisionState(state.conf).revision;
|
|
1631
|
+
if (state.conf !== literalMissConf || revision !== literalMissRevision) {
|
|
1632
|
+
literalMissConf = state.conf;
|
|
1633
|
+
literalMissRevision = revision;
|
|
1634
|
+
literalMisses = /* @__PURE__ */ new WeakMap();
|
|
1635
|
+
}
|
|
1636
|
+
const themeKey = state.theme && typeof state.theme === "object" ? state.theme : literalMissRootTheme;
|
|
1637
|
+
let set = literalMisses.get(themeKey);
|
|
1638
|
+
if (!set) {
|
|
1639
|
+
set = /* @__PURE__ */ new Set();
|
|
1640
|
+
literalMisses.set(themeKey, set);
|
|
1641
|
+
}
|
|
1642
|
+
return set;
|
|
1643
|
+
}
|
|
1644
|
+
function configuredValue(state, property, raw) {
|
|
1645
|
+
let name = raw;
|
|
1646
|
+
let opacity;
|
|
1647
|
+
const slash = raw.lastIndexOf("/");
|
|
1648
|
+
if (slash > 0) {
|
|
1649
|
+
const amount = Number(raw.slice(slash + 1));
|
|
1650
|
+
if (Number.isInteger(amount) && amount >= 0 && amount <= 100) {
|
|
1651
|
+
name = raw.slice(0, slash);
|
|
1652
|
+
opacity = amount;
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
const safeArea = resolveSafeAreaVariable(name);
|
|
1656
|
+
if (safeArea !== void 0) {
|
|
1657
|
+
state.flatUsesSafeArea = true;
|
|
1658
|
+
return safeArea;
|
|
1659
|
+
}
|
|
1660
|
+
const cacheable = !isFontKeyedProperty(property);
|
|
1661
|
+
let misses;
|
|
1662
|
+
let missKey = "";
|
|
1663
|
+
if (cacheable) {
|
|
1664
|
+
misses = literalMissSet(state);
|
|
1665
|
+
missKey = `${state.flatThemeName || ""}${property}${name}`;
|
|
1666
|
+
if (misses.has(missKey)) return raw;
|
|
1667
|
+
}
|
|
1668
|
+
const lookup = tokenVariable(state, property, name);
|
|
1669
|
+
if (!lookup || !isVariable(lookup.value)) {
|
|
1670
|
+
if (misses) misses.add(missKey);
|
|
1671
|
+
if (process.env.NODE_ENV === "development" && tokenCategoryByProperty[property] && state.conf.tokensParsed.color?.[name]) warnOnce(`"${name}" contributes to "color", not "${property}"; keeping it literal`);
|
|
1672
|
+
return raw;
|
|
1673
|
+
}
|
|
1674
|
+
const resolveValues = !state.flatShouldDoClasses && state.styleProps.resolveValues === "auto" ? "value" : state.styleProps.resolveValues;
|
|
1675
|
+
if (resolveValues === "except-theme" && lookup.fromTheme) return `${THEME_REF_PREFIX}${lookup.themeKey}${opacity !== void 0 ? `/${opacity}` : ""}`;
|
|
1676
|
+
let value = resolveVariableValue(property, lookup.value, resolveValues);
|
|
1677
|
+
if (opacity !== void 0) value = `color-mix(in srgb, ${value} ${opacity}%, transparent)`;
|
|
1678
|
+
return value;
|
|
1679
|
+
}
|
|
1680
|
+
function resolveEmbeddedTokens(state, property, raw) {
|
|
1681
|
+
let copyFrom = 0;
|
|
1682
|
+
let out = "";
|
|
1683
|
+
let quote = 0;
|
|
1684
|
+
for (let index = 0; index < raw.length; index++) {
|
|
1685
|
+
const code = raw.charCodeAt(index);
|
|
1686
|
+
if (quote) {
|
|
1687
|
+
if (code === 92) index++;
|
|
1688
|
+
else if (code === quote) quote = 0;
|
|
1689
|
+
continue;
|
|
1690
|
+
}
|
|
1691
|
+
if (code === 34 || code === 39) {
|
|
1692
|
+
quote = code;
|
|
1693
|
+
continue;
|
|
1694
|
+
}
|
|
1695
|
+
if (!(code === 36 || code === 95 || code >= 65 && code <= 90 || code >= 97 && code <= 122)) continue;
|
|
1696
|
+
let end = index + 1;
|
|
1697
|
+
while (end < raw.length) {
|
|
1698
|
+
const next = raw.charCodeAt(end);
|
|
1699
|
+
if (next === 36 || next === 45 || next === 46 || next === 95 || next >= 48 && next <= 57 || next >= 65 && next <= 90 || next >= 97 && next <= 122) end++;
|
|
1700
|
+
else break;
|
|
1701
|
+
}
|
|
1702
|
+
if (raw.charCodeAt(end) === 47) {
|
|
1703
|
+
let suffix = end + 1;
|
|
1704
|
+
while (suffix < raw.length) {
|
|
1705
|
+
const next = raw.charCodeAt(suffix);
|
|
1706
|
+
if (next < 48 || next > 57) break;
|
|
1707
|
+
suffix++;
|
|
1708
|
+
}
|
|
1709
|
+
if (suffix > end + 1) end = suffix;
|
|
1710
|
+
}
|
|
1711
|
+
const before = raw.charCodeAt(index - 1);
|
|
1712
|
+
if (code !== 36 && (before >= 48 && before <= 57 || before === 35 || before === 45 && raw.charCodeAt(index - 2) === 45 || raw.charCodeAt(end) === 40)) {
|
|
1713
|
+
index = end - 1;
|
|
1714
|
+
continue;
|
|
1715
|
+
}
|
|
1716
|
+
const word = raw.slice(index, end);
|
|
1717
|
+
const value = configuredValue(state, property, word);
|
|
1718
|
+
if (value !== word) {
|
|
1719
|
+
out += raw.slice(copyFrom, index);
|
|
1720
|
+
out += String(value);
|
|
1721
|
+
copyFrom = end;
|
|
1722
|
+
}
|
|
1723
|
+
index = end - 1;
|
|
1724
|
+
}
|
|
1725
|
+
return copyFrom ? out + raw.slice(copyFrom) : raw;
|
|
1726
|
+
}
|
|
1727
|
+
function normalizeTransitionNames(state, raw) {
|
|
1728
|
+
let quote = 0;
|
|
1729
|
+
let depth = 0;
|
|
1730
|
+
let copyFrom = 0;
|
|
1731
|
+
let out = "";
|
|
1732
|
+
for (let index = 0; index < raw.length; index++) {
|
|
1733
|
+
const code = raw.charCodeAt(index);
|
|
1734
|
+
if (quote) {
|
|
1735
|
+
if (code === 92) index++;
|
|
1736
|
+
else if (code === quote) quote = 0;
|
|
1737
|
+
continue;
|
|
1738
|
+
}
|
|
1739
|
+
if (code === 34 || code === 39) {
|
|
1740
|
+
quote = code;
|
|
1741
|
+
continue;
|
|
1742
|
+
}
|
|
1743
|
+
if (code === 40) {
|
|
1744
|
+
depth++;
|
|
1745
|
+
continue;
|
|
1746
|
+
}
|
|
1747
|
+
if (code === 41) {
|
|
1748
|
+
depth--;
|
|
1749
|
+
continue;
|
|
1750
|
+
}
|
|
1751
|
+
if (depth || !(code >= 65 && code <= 90 || code >= 97 && code <= 122 || code === 95) || index > 1 && raw.charCodeAt(index - 1) === 45 && raw.charCodeAt(index - 2) === 45) continue;
|
|
1752
|
+
let end = index + 1;
|
|
1753
|
+
while (end < raw.length) {
|
|
1754
|
+
const next = raw.charCodeAt(end);
|
|
1755
|
+
if (next >= 48 && next <= 57 || next >= 65 && next <= 90 || next >= 97 && next <= 122 || next === 45 || next === 95) end++;
|
|
1756
|
+
else break;
|
|
1757
|
+
}
|
|
1758
|
+
if (raw.charCodeAt(end) !== 40) {
|
|
1759
|
+
const authored = raw.slice(index, end);
|
|
1760
|
+
let property = state.conf.shorthands[authored] || authored;
|
|
1761
|
+
if (property === "x" || property === "y") property = "translate";
|
|
1762
|
+
else if (property === "scaleX" || property === "scaleY") property = "scale";
|
|
1763
|
+
else if (legacyTransformParts.has(property)) property = "transform";
|
|
1764
|
+
let hasUpper = false;
|
|
1765
|
+
for (let offset = 0; offset < property.length; offset++) {
|
|
1766
|
+
const letter = property.charCodeAt(offset);
|
|
1767
|
+
if (letter >= 65 && letter <= 90) {
|
|
1768
|
+
hasUpper = true;
|
|
1769
|
+
break;
|
|
724
1770
|
}
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
1771
|
+
}
|
|
1772
|
+
if (property !== authored || hasUpper) {
|
|
1773
|
+
out += raw.slice(copyFrom, index);
|
|
1774
|
+
for (let offset = 0; offset < property.length; offset++) {
|
|
1775
|
+
const letter = property.charCodeAt(offset);
|
|
1776
|
+
out += letter >= 65 && letter <= 90 ? `-${String.fromCharCode(letter + 32)}` : property[offset];
|
|
1777
|
+
}
|
|
1778
|
+
copyFrom = end;
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
index = end - 1;
|
|
1782
|
+
}
|
|
1783
|
+
return copyFrom ? out + raw.slice(copyFrom) : raw;
|
|
1784
|
+
}
|
|
1785
|
+
function getDirectDynamicThemeAccess(state) {
|
|
1786
|
+
return state.flatDynamicThemeAccess;
|
|
1787
|
+
}
|
|
1788
|
+
function emitProperty(state, property, value, cursor, merge, originalValue, contextOnly) {
|
|
1789
|
+
const direct = state;
|
|
1790
|
+
const condition = cursor ? conditionNumbers[cursor + conditionValueOffset] : 0;
|
|
1791
|
+
if (condition & 4) (state.flatEnterKeys ||= /* @__PURE__ */ new Set()).add(property);
|
|
1792
|
+
if (condition & 8) (state.flatExitKeys ||= /* @__PURE__ */ new Set()).add(property);
|
|
1793
|
+
cursor && conditionTexts[cursor + conditionThemeOffset];
|
|
1794
|
+
if (contextOnly) {
|
|
1795
|
+
if (!condition || condition & 1) (state.overriddenContextProps ||= {})[property] = originalValue;
|
|
1796
|
+
return;
|
|
1797
|
+
}
|
|
1798
|
+
if (canGenerateCSS && state.flatShouldDoClasses && !condition && property === "transform") {
|
|
1799
|
+
if (process.env.NODE_ENV === "development" && state.transformAccumulator) for (const part of getTransformPartKeys(state.transformAccumulator)) warnOnce(`legacy transform part "${part}" is dropped because "transform" owns the property`);
|
|
1800
|
+
state.transformAccumulator ||= createTransformAccumulator();
|
|
1801
|
+
addTransformValue(state.transformAccumulator, property, value);
|
|
1802
|
+
return;
|
|
1803
|
+
}
|
|
1804
|
+
const shouldPromoteAnimatedStyle = canGenerateCSS && !condition && !state.flatShouldDoClasses && !state.styleProps.noMergeStyle && state.styleProps.isAnimated && state.animationDriver?.inputStyle === "css" && property in nonAnimatableStyleProps;
|
|
1805
|
+
if (canGenerateCSS && (state.flatShouldDoClasses || shouldPromoteAnimatedStyle)) {
|
|
1806
|
+
if (!condition && state.style && direct.flatWeakContribution !== true && !(direct.flatUsed && direct.flatUsed[property])) delete state.style[property];
|
|
1807
|
+
streamWriteCSS(state, property, value, cursor, originalValue);
|
|
1808
|
+
return;
|
|
1809
|
+
}
|
|
1810
|
+
if (condition && !(condition & 1)) return;
|
|
1811
|
+
streamWriteInline(state, property, value, cursor, merge, originalValue);
|
|
1812
|
+
}
|
|
1813
|
+
function splitComponents(value) {
|
|
1814
|
+
const parts = [];
|
|
1815
|
+
let start = 0;
|
|
1816
|
+
let quote = 0;
|
|
1817
|
+
let depth = 0;
|
|
1818
|
+
for (let index = 0; index <= value.length; index++) {
|
|
1819
|
+
const code = index === value.length ? 32 : value.charCodeAt(index);
|
|
1820
|
+
if (quote) {
|
|
1821
|
+
if (code === 92) index++;
|
|
1822
|
+
else if (code === quote) quote = 0;
|
|
1823
|
+
continue;
|
|
1824
|
+
}
|
|
1825
|
+
if (code === 34 || code === 39) quote = code;
|
|
1826
|
+
else if (code === 40) depth++;
|
|
1827
|
+
else if (code === 41) depth--;
|
|
1828
|
+
else if (!depth && code <= 32) {
|
|
1829
|
+
if (index > start) parts.push(value.slice(start, index));
|
|
1830
|
+
start = index + 1;
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
return parts;
|
|
1834
|
+
}
|
|
1835
|
+
function numericUnitValue(value, first, second) {
|
|
1836
|
+
const unitLength = value.endsWith(first) || second !== void 0 && value.endsWith(second) ? first.length : 0;
|
|
1837
|
+
if (!unitLength || value.length === unitLength) return NaN;
|
|
1838
|
+
const numeric = Number(value.slice(0, value.length - unitLength));
|
|
1839
|
+
return Number.isFinite(numeric) ? numeric : NaN;
|
|
1840
|
+
}
|
|
1841
|
+
function isNumericCSSComponent(value) {
|
|
1842
|
+
let index = 0;
|
|
1843
|
+
if (value.charCodeAt(index) === 43 || value.charCodeAt(index) === 45) index++;
|
|
1844
|
+
let digits = 0;
|
|
1845
|
+
let dot = false;
|
|
1846
|
+
for (; index < value.length; index++) {
|
|
1847
|
+
const code = value.charCodeAt(index);
|
|
1848
|
+
if (code >= 48 && code <= 57) {
|
|
1849
|
+
digits++;
|
|
1850
|
+
continue;
|
|
1851
|
+
}
|
|
1852
|
+
if (code === 46 && !dot) {
|
|
1853
|
+
dot = true;
|
|
1854
|
+
continue;
|
|
1855
|
+
}
|
|
1856
|
+
break;
|
|
1857
|
+
}
|
|
1858
|
+
if (!digits) return false;
|
|
1859
|
+
for (; index < value.length; index++) {
|
|
1860
|
+
const code = value.charCodeAt(index);
|
|
1861
|
+
if (code !== 37 && (code < 97 || code > 122)) return false;
|
|
1862
|
+
}
|
|
1863
|
+
return true;
|
|
1864
|
+
}
|
|
1865
|
+
function startsValueFunction(value) {
|
|
1866
|
+
let index = 0;
|
|
1867
|
+
while (index < value.length) {
|
|
1868
|
+
const code = value.charCodeAt(index);
|
|
1869
|
+
if (code === 45 || code >= 97 && code <= 122) {
|
|
1870
|
+
index++;
|
|
1871
|
+
continue;
|
|
1872
|
+
}
|
|
1873
|
+
break;
|
|
1874
|
+
}
|
|
1875
|
+
return index > 0 && value.charCodeAt(index) === 40;
|
|
1876
|
+
}
|
|
1877
|
+
function emitBorder(state, property, raw, cursor, merge, originalValue, contextOnly) {
|
|
1878
|
+
let width;
|
|
1879
|
+
let style;
|
|
1880
|
+
let color;
|
|
1881
|
+
for (const part of splitComponents(raw)) if (lineStyles.has(part) || property === "outline" && part === "auto") style = part;
|
|
1882
|
+
else if (part === "thin" || part === "medium" || part === "thick" || isNumericCSSComponent(part) || startsValueFunction(part)) width = part;
|
|
1883
|
+
else color = part;
|
|
1884
|
+
if (style === "none" && width === void 0) width = "0";
|
|
1885
|
+
const targets = borderTargets[property];
|
|
1886
|
+
if (width !== void 0) for (const target of targets.width) emitResolved(state, target, width, cursor, merge, originalValue, contextOnly);
|
|
1887
|
+
if (style !== void 0) {
|
|
1888
|
+
const styleTargets = targets.style;
|
|
1889
|
+
for (const target of styleTargets) emitProperty(state, target, style, cursor, merge, originalValue, contextOnly);
|
|
1890
|
+
}
|
|
1891
|
+
if (color !== void 0) for (const target of targets.color) emitResolved(state, target, color, cursor, merge, originalValue, contextOnly);
|
|
1892
|
+
}
|
|
1893
|
+
function emitTextDecoration(state, raw, cursor, merge, originalValue, contextOnly) {
|
|
1894
|
+
for (const part of splitComponents(raw)) emitResolved(state, part === "solid" || part === "double" || part === "dotted" || part === "dashed" || part === "wavy" ? "textDecorationStyle" : part === "underline" || part === "overline" || part === "line-through" || part === "none" ? "textDecorationLine" : "textDecorationColor", part, cursor, merge, originalValue, contextOnly);
|
|
1895
|
+
}
|
|
1896
|
+
function emitTransform(state, property, value, cursor, merge, originalValue, contextOnly) {
|
|
1897
|
+
if (!canGenerateCSS || !state.flatShouldDoClasses) {
|
|
1898
|
+
emitProperty(state, property, value, cursor, merge, originalValue, contextOnly);
|
|
1899
|
+
return;
|
|
1900
|
+
}
|
|
1901
|
+
const targets = property === "scale" ? ["--t-scale-x", "--t-scale-y"] : [property === "x" ? "--t-x" : property === "y" ? "--t-y" : property === "scaleX" ? "--t-scale-x" : property === "scaleY" ? "--t-scale-y" : "rotate"];
|
|
1902
|
+
for (const target of targets) {
|
|
1903
|
+
let targetValue = value;
|
|
1904
|
+
if (typeof targetValue === "number") {
|
|
1905
|
+
if (target === "--t-x" || target === "--t-y") targetValue = `${targetValue}px`;
|
|
1906
|
+
else if (target === "rotate") targetValue = `${targetValue}deg`;
|
|
1907
|
+
}
|
|
1908
|
+
emitProperty(state, target, targetValue, cursor, merge, originalValue, contextOnly);
|
|
1909
|
+
if (target === "--t-x" || target === "--t-y") addComposition(state, "translate");
|
|
1910
|
+
else if (target.startsWith("--t-scale")) addComposition(state, "scale");
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
function emitResolved(state, property, raw, cursor, merge, originalValue, contextOnly) {
|
|
1914
|
+
let value = configuredValue(state, property, raw);
|
|
1915
|
+
if (value === raw) value = resolveEmbeddedTokens(state, property, raw);
|
|
1916
|
+
if (!state.flatShouldDoClasses && typeof value === "string") {
|
|
1917
|
+
const unitValue = numericUnitValue(value, "px", "dp");
|
|
1918
|
+
if (Number.isFinite(unitValue)) value = unitValue;
|
|
1919
|
+
else if (value !== "" && Number.isFinite(Number(value))) value = Number(value);
|
|
1920
|
+
}
|
|
1921
|
+
emitProperty(state, property, value, cursor, merge, originalValue, contextOnly);
|
|
1922
|
+
}
|
|
1923
|
+
const emitKindTransition = 1;
|
|
1924
|
+
const emitKindTransformPart = 2;
|
|
1925
|
+
const emitKindWebShadow = 3;
|
|
1926
|
+
const emitKindWebTextShadow = 4;
|
|
1927
|
+
const emitKindTransform = 5;
|
|
1928
|
+
const emitKindBorder = 6;
|
|
1929
|
+
const emitKindTextDecoration = 7;
|
|
1930
|
+
const emitKindBackground = 8;
|
|
1931
|
+
const emitKindAxis = 9;
|
|
1932
|
+
const emitKindBorderRadius = 10;
|
|
1933
|
+
const emitKindBorderWidth = 11;
|
|
1934
|
+
const emitValueKinds = {
|
|
1935
|
+
transition: emitKindTransition,
|
|
1936
|
+
transitionProperty: emitKindTransition,
|
|
1937
|
+
transform: emitKindTransform,
|
|
1938
|
+
textDecoration: emitKindTextDecoration,
|
|
1939
|
+
background: emitKindBackground,
|
|
1940
|
+
x: emitKindAxis,
|
|
1941
|
+
y: emitKindAxis,
|
|
1942
|
+
scale: emitKindAxis,
|
|
1943
|
+
scaleX: emitKindAxis,
|
|
1944
|
+
scaleY: emitKindAxis,
|
|
1945
|
+
rotate: emitKindAxis,
|
|
1946
|
+
borderRadius: emitKindBorderRadius,
|
|
1947
|
+
borderWidth: emitKindBorderWidth,
|
|
1948
|
+
borderTopWidth: emitKindBorderWidth,
|
|
1949
|
+
borderRightWidth: emitKindBorderWidth,
|
|
1950
|
+
borderBottomWidth: emitKindBorderWidth,
|
|
1951
|
+
borderLeftWidth: emitKindBorderWidth
|
|
1952
|
+
};
|
|
1953
|
+
for (const part of legacyTransformParts) emitValueKinds[part] = emitKindTransformPart;
|
|
1954
|
+
for (const part in webShadowParts) emitValueKinds[part] = emitKindWebShadow;
|
|
1955
|
+
for (const part of webTextShadowParts) emitValueKinds[part] = emitKindWebTextShadow;
|
|
1956
|
+
for (const target in borderTargets) emitValueKinds[target] = emitKindBorder;
|
|
1957
|
+
function shadowUnit(part) {
|
|
1958
|
+
return typeof part === "number" ? `${part}px` : part || "0px";
|
|
1959
|
+
}
|
|
1960
|
+
function emitWebTextShadow(state, property, value, merge, originalValue, contextOnly) {
|
|
1961
|
+
const shadow = state.flatTextShadow ||= {};
|
|
1962
|
+
shadow[property] = value;
|
|
1963
|
+
const offset = shadow.textShadowOffset || {
|
|
1964
|
+
width: 0,
|
|
1965
|
+
height: 0
|
|
1966
|
+
};
|
|
1967
|
+
if (!shadow.textShadowColor) return;
|
|
1968
|
+
emitProperty(state, "textShadow", `${shadowUnit(offset.width)} ${shadowUnit(offset.height)} ${shadowUnit(shadow.textShadowRadius)} ${shadow.textShadowColor}`, null, merge, originalValue, contextOnly);
|
|
1969
|
+
}
|
|
1970
|
+
function emitValue(state, property, raw, cursor, merge, originalValue, contextOnly) {
|
|
1971
|
+
const condition = cursor ? conditionNumbers[cursor + conditionValueOffset] : 0;
|
|
1972
|
+
if (isVariable(raw)) raw = resolveVariableValue(property, raw, !state.flatShouldDoClasses && state.styleProps.resolveValues === "auto" ? "value" : state.styleProps.resolveValues);
|
|
1973
|
+
const emitKind = emitValueKinds[property];
|
|
1974
|
+
if (emitKind !== void 0) switch (emitKind) {
|
|
1975
|
+
case emitKindTransition:
|
|
1976
|
+
if (typeof raw === "string") raw = normalizeTransitionNames(state, raw);
|
|
1977
|
+
break;
|
|
1978
|
+
case emitKindBorderWidth:
|
|
1979
|
+
requestBorderStyleDefault(state, property, condition, cursor ? conditionTexts[cursor + conditionKeyOffset] || "" : "", cursor ? conditionTexts[cursor + conditionSelectorOffset] || "" : "", cursor ? conditionWrappers : void 0, cursor ? conditionNumbers[cursor + conditionWrapperOffset] >> 3 : 0, cursor ? conditionNumbers[cursor + conditionWrapperOffset] & 7 : 0);
|
|
1980
|
+
break;
|
|
1981
|
+
case emitKindTransformPart: {
|
|
1982
|
+
const value2 = typeof raw === "string" ? configuredValue(state, property, raw) : raw;
|
|
1983
|
+
if (canGenerateCSS && state.flatShouldDoClasses && !condition) {
|
|
1984
|
+
state.transformAccumulator ||= createTransformAccumulator();
|
|
1985
|
+
addTransformValue(state.transformAccumulator, property, value2);
|
|
1986
|
+
} else if (condition && canGenerateCSS && state.flatShouldDoClasses) emitProperty(state, "transform", `${property}(${value2})`, cursor, merge, originalValue, contextOnly);
|
|
1987
|
+
else streamWriteInline(state, property, value2, cursor, merge, originalValue, true);
|
|
1988
|
+
return;
|
|
1989
|
+
}
|
|
1990
|
+
case emitKindWebShadow: {
|
|
1991
|
+
const value2 = typeof raw === "string" ? configuredValue(state, property, raw) : raw;
|
|
1992
|
+
if (canGenerateCSS && state.flatShouldDoClasses) {
|
|
1993
|
+
const shadow = state.flatWebShadow ||= [];
|
|
1994
|
+
shadow[webShadowParts[property] - 1] = value2;
|
|
1995
|
+
shadow[4] = ++frameSequence;
|
|
1996
|
+
shadow[5] = originalValue;
|
|
1997
|
+
shadow[6] = contextOnly;
|
|
1998
|
+
} else streamWriteInline(state, property, value2, cursor, merge, originalValue, true);
|
|
1999
|
+
return;
|
|
2000
|
+
}
|
|
2001
|
+
case emitKindWebTextShadow: {
|
|
2002
|
+
const value2 = typeof raw === "string" ? configuredValue(state, property, raw) : raw;
|
|
2003
|
+
if (canGenerateCSS && state.flatShouldDoClasses) emitWebTextShadow(state, property, value2, merge, originalValue, contextOnly);
|
|
2004
|
+
else streamWriteInline(state, property, value2, cursor, merge, originalValue, true);
|
|
2005
|
+
return;
|
|
2006
|
+
}
|
|
2007
|
+
case emitKindTransform:
|
|
2008
|
+
if (canGenerateCSS && state.flatShouldDoClasses && Array.isArray(raw)) raw = transformsToString(raw);
|
|
2009
|
+
break;
|
|
2010
|
+
case emitKindBorder:
|
|
2011
|
+
if (typeof raw === "string") {
|
|
2012
|
+
emitBorder(state, property, raw, cursor, merge, originalValue, contextOnly);
|
|
2013
|
+
return;
|
|
2014
|
+
}
|
|
2015
|
+
break;
|
|
2016
|
+
case emitKindTextDecoration:
|
|
2017
|
+
if (typeof raw === "string") {
|
|
2018
|
+
emitTextDecoration(state, raw, cursor, merge, originalValue, contextOnly);
|
|
2019
|
+
return;
|
|
2020
|
+
}
|
|
2021
|
+
break;
|
|
2022
|
+
case emitKindBackground:
|
|
2023
|
+
if (typeof raw === "string") {
|
|
2024
|
+
const parts = splitComponents(raw);
|
|
2025
|
+
if (parts.length === 1 && !startsValueFunction(parts[0])) {
|
|
2026
|
+
emitResolved(state, "backgroundColor", parts[0], cursor, merge, originalValue, contextOnly);
|
|
2027
|
+
return;
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
break;
|
|
2031
|
+
case emitKindAxis: {
|
|
2032
|
+
let value2 = typeof raw === "string" ? configuredValue(state, property, raw) : raw;
|
|
2033
|
+
if (!state.flatShouldDoClasses && typeof value2 === "string" && !value2.startsWith(THEME_REF_PREFIX)) {
|
|
2034
|
+
if (property === "rotate" && !Number.isFinite(numericUnitValue(value2, "deg", "rad"))) {
|
|
2035
|
+
if (process.env.NODE_ENV === "development") warnOnce(`native transform "${property}" cannot represent "${value2}"; dropping it`);
|
|
2036
|
+
if (condition & 1) {
|
|
2037
|
+
removeTransformValue(state.transformAccumulator, property);
|
|
2038
|
+
streamRetractInline(state, property, cursor);
|
|
2039
|
+
}
|
|
2040
|
+
return;
|
|
2041
|
+
}
|
|
2042
|
+
const unitValue = numericUnitValue(value2, "px", "dp");
|
|
2043
|
+
if (Number.isFinite(unitValue)) value2 = unitValue;
|
|
2044
|
+
else if (Number.isFinite(Number(value2))) value2 = Number(value2);
|
|
2045
|
+
}
|
|
2046
|
+
emitTransform(state, property, value2, cursor, merge, originalValue, contextOnly);
|
|
2047
|
+
return;
|
|
2048
|
+
}
|
|
2049
|
+
case emitKindBorderRadius:
|
|
2050
|
+
if (!state.flatShouldDoClasses && !condition) {
|
|
2051
|
+
if (typeof raw === "string") emitResolved(state, property, raw, cursor, merge, originalValue, contextOnly);
|
|
2052
|
+
else emitProperty(state, property, raw, cursor, merge, originalValue, contextOnly);
|
|
2053
|
+
return;
|
|
2054
|
+
}
|
|
2055
|
+
break;
|
|
2056
|
+
}
|
|
2057
|
+
let value = raw;
|
|
2058
|
+
if (typeof raw === "string") {
|
|
2059
|
+
value = configuredValue(state, property, raw);
|
|
2060
|
+
if (value === raw) value = resolveEmbeddedTokens(state, property, raw);
|
|
2061
|
+
}
|
|
2062
|
+
if (!state.flatShouldDoClasses && typeof value === "string") {
|
|
2063
|
+
const unitValue = numericUnitValue(value, "px", "dp");
|
|
2064
|
+
if (Number.isFinite(unitValue)) value = unitValue;
|
|
2065
|
+
else if (value !== "" && Number.isFinite(Number(value))) value = Number(value);
|
|
2066
|
+
}
|
|
2067
|
+
if (canGenerateCSS && state.flatShouldDoClasses && property === "boxShadow" && !condition) {
|
|
2068
|
+
state.flatBoxShadow = value;
|
|
2069
|
+
state.flatBoxShadowSequence = frameSequence + 1;
|
|
2070
|
+
}
|
|
2071
|
+
const expanded = state.styleProps.noExpand ? null : expandStyle(property, value, state.conf.settings.styleCompat || "web");
|
|
2072
|
+
if (!expanded) {
|
|
2073
|
+
emitProperty(state, property, value, cursor, merge, originalValue, contextOnly);
|
|
2074
|
+
return;
|
|
2075
|
+
}
|
|
2076
|
+
if (typeof raw === "string" && expanded.length > 1) {
|
|
2077
|
+
const parts = splitComponents(raw);
|
|
2078
|
+
if (parts.length > 0 && parts.length <= (expanded.length === 4 ? 4 : 2)) {
|
|
2079
|
+
for (let index = 0; index < expanded.length; index++) {
|
|
2080
|
+
const partIndex = index === 0 || parts.length === 1 ? 0 : index === 1 || index === 3 && parts.length < 4 ? 1 : index === 2 && parts.length < 3 ? 0 : index;
|
|
2081
|
+
emitResolved(state, expanded[index][0], parts[partIndex], cursor, merge, originalValue, contextOnly);
|
|
2082
|
+
}
|
|
2083
|
+
return;
|
|
728
2084
|
}
|
|
2085
|
+
}
|
|
2086
|
+
for (let index = 0; index < expanded.length; index++) emitProperty(state, expanded[index][0], expanded[index][1], cursor, merge, originalValue, contextOnly);
|
|
2087
|
+
}
|
|
2088
|
+
function contributeStyleString(state, property, source, merge, originalValue, contextOnly = false) {
|
|
2089
|
+
const directState = state;
|
|
2090
|
+
const watermark = conditionCursorTop;
|
|
2091
|
+
const previousCursor = directState.flatScanCursor;
|
|
2092
|
+
const previousExpectMulti = directState.flatExpectMulti;
|
|
2093
|
+
directState.flatScanCursor = null;
|
|
2094
|
+
directState.flatExpectMulti = source.indexOf(":") !== -1;
|
|
2095
|
+
try {
|
|
2096
|
+
scanFlatValue(source, directStyleHandler, state, property, merge, originalValue, contextOnly);
|
|
2097
|
+
} finally {
|
|
2098
|
+
directState.flatScanCursor = previousCursor;
|
|
2099
|
+
directState.flatExpectMulti = previousExpectMulti;
|
|
2100
|
+
releaseConditionCursors(watermark);
|
|
2101
|
+
}
|
|
2102
|
+
return true;
|
|
2103
|
+
}
|
|
2104
|
+
function contributeStyleObject(state, property, value, merge, contextOnly) {
|
|
2105
|
+
const outerState = state;
|
|
2106
|
+
const previousExpectMulti = outerState.flatExpectMulti;
|
|
2107
|
+
outerState.flatExpectMulti = true;
|
|
2108
|
+
try {
|
|
2109
|
+
return contributeStyleObjectInner(state, property, value, merge, contextOnly);
|
|
729
2110
|
} finally {
|
|
730
|
-
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
2111
|
+
outerState.flatExpectMulti = previousExpectMulti;
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2114
|
+
function contributeStyleObjectInner(state, property, value, merge, contextOnly) {
|
|
2115
|
+
const directState = state;
|
|
2116
|
+
const parent = directState.flatPass?.[passParentCursor] || null;
|
|
2117
|
+
const hasDefault = Object.prototype.hasOwnProperty.call(value, "default");
|
|
2118
|
+
let hasBase = false;
|
|
2119
|
+
const base = hasDefault ? value.default : void 0;
|
|
2120
|
+
if (base != null) {
|
|
2121
|
+
const baseString = String(base);
|
|
2122
|
+
feedCompoundSegment(directState, baseString, 0, baseString.length, true, true, "");
|
|
2123
|
+
emitAtParentCondition(state, property, base, merge, base, contextOnly);
|
|
2124
|
+
hasBase = true;
|
|
2125
|
+
}
|
|
2126
|
+
let conditions = 0;
|
|
2127
|
+
let firstCondition = !hasDefault;
|
|
2128
|
+
for (const key in value) {
|
|
2129
|
+
if (key === "default") continue;
|
|
2130
|
+
const payload = value[key];
|
|
2131
|
+
const watermark = conditionCursorTop;
|
|
2132
|
+
const cursor = acquireConditionCursor(parent);
|
|
2133
|
+
resolveConditionText(state, cursor, key);
|
|
2134
|
+
const condition = commitConditionCursor(state, cursor);
|
|
2135
|
+
if (firstCondition) {
|
|
2136
|
+
firstCondition = false;
|
|
2137
|
+
if (!condition) {
|
|
2138
|
+
releaseConditionCursors(watermark);
|
|
2139
|
+
return false;
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
if (payload != null) {
|
|
2143
|
+
conditions |= emitUnderCondition(state, property, payload, cursor, merge, payload, contextOnly, 1, payload);
|
|
2144
|
+
const payloadString = String(payload);
|
|
2145
|
+
feedCompoundSegment(directState, payloadString, 0, payloadString.length, false, Boolean(condition), condition && directState.flatPass?.[passCompoundIndexes] ? conditionTexts[cursor + conditionKeyOffset] || "" : "");
|
|
2146
|
+
}
|
|
2147
|
+
releaseConditionCursors(watermark);
|
|
2148
|
+
}
|
|
2149
|
+
if (!hasDefault && firstCondition) return false;
|
|
2150
|
+
if ((!canGenerateCSS || !state.flatShouldDoClasses) && conditions & 12 && !hasBase) {
|
|
2151
|
+
const resting = implicitLifecycleBase(property);
|
|
2152
|
+
if (resting !== null) emitAtParentCondition(state, property, resting, merge, resting, contextOnly);
|
|
2153
|
+
}
|
|
2154
|
+
return true;
|
|
2155
|
+
}
|
|
2156
|
+
function contributeValue(state, property, value, merge, originalValue, contextOnly = false, condition) {
|
|
2157
|
+
if (isConditionTransport(value)) {
|
|
2158
|
+
if (value.hasBase) contributeValue(state, property, value.base, merge, value.base, contextOnly);
|
|
2159
|
+
for (let offset = 0; offset < value.entries.length;) {
|
|
2160
|
+
const entryValue = value.entries[offset];
|
|
2161
|
+
const watermark = conditionCursorTop;
|
|
2162
|
+
try {
|
|
2163
|
+
emitUnderCondition(state, property, entryValue, acquireTransportCursor(state, value.entries, offset, state.flatPass?.[passParentCursor] || null), merge, entryValue, contextOnly, 2, entryValue);
|
|
2164
|
+
} finally {
|
|
2165
|
+
releaseConditionCursors(watermark);
|
|
2166
|
+
}
|
|
2167
|
+
offset += transportEntryWidth;
|
|
2168
|
+
}
|
|
2169
|
+
return true;
|
|
2170
|
+
}
|
|
2171
|
+
if (condition !== void 0) {
|
|
2172
|
+
const parent = state.flatPass?.[passParentCursor] || null;
|
|
2173
|
+
const watermark = conditionCursorTop;
|
|
2174
|
+
try {
|
|
2175
|
+
let effective;
|
|
2176
|
+
if (typeof condition === "string") {
|
|
2177
|
+
effective = acquireConditionCursor(parent);
|
|
2178
|
+
resolveConditionText(state, effective, condition);
|
|
2179
|
+
commitConditionCursor(state, effective);
|
|
2180
|
+
} else if (parent) {
|
|
2181
|
+
effective = acquireConditionCursor(parent);
|
|
2182
|
+
const conditionKey = conditionTexts[condition + conditionKeyOffset] || "";
|
|
2183
|
+
if (conditionKey) resolveConditionText(state, effective, conditionKey);
|
|
2184
|
+
if (!(conditionNumbers[condition + conditionFlagsOffset] & conditionResolvedFlag)) setConditionUnresolved(effective);
|
|
2185
|
+
commitConditionCursor(state, effective);
|
|
2186
|
+
} else effective = condition;
|
|
2187
|
+
const isObjectValue = value && typeof value === "object" && !Array.isArray(value) && !isVariable(value);
|
|
2188
|
+
const objectHasDefault = isObjectValue && Object.prototype.hasOwnProperty.call(value, "default");
|
|
2189
|
+
const firstChild = isObjectValue && !objectHasDefault ? acquireConditionCursor(effective) : null;
|
|
2190
|
+
if (isObjectValue && classifyConditionalObject(value, state, void 0, firstChild || void 0)) {
|
|
2191
|
+
let useFirstChild = firstChild !== null;
|
|
2192
|
+
for (const key in value) {
|
|
2193
|
+
const payload = value[key];
|
|
2194
|
+
if (payload == null) continue;
|
|
2195
|
+
if (key === "default") emitUnderCondition(state, property, payload, effective, merge, payload, contextOnly, 2, payload);
|
|
2196
|
+
else {
|
|
2197
|
+
const keyWatermark = conditionCursorTop;
|
|
2198
|
+
const child = useFirstChild ? firstChild : acquireConditionCursor(effective);
|
|
2199
|
+
if (useFirstChild) useFirstChild = false;
|
|
2200
|
+
else {
|
|
2201
|
+
resolveConditionText(state, child, key);
|
|
2202
|
+
commitConditionCursor(state, child);
|
|
746
2203
|
}
|
|
747
|
-
|
|
748
|
-
|
|
2204
|
+
emitUnderCondition(state, property, payload, child, merge, payload, contextOnly, 2, payload);
|
|
2205
|
+
if (child !== firstChild) releaseConditionCursors(keyWatermark);
|
|
749
2206
|
}
|
|
750
2207
|
}
|
|
751
|
-
|
|
752
|
-
styleOut.transform = merged;
|
|
2208
|
+
return true;
|
|
753
2209
|
}
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
2210
|
+
emitUnderCondition(state, property, value, effective, merge, originalValue, contextOnly, 2, value);
|
|
2211
|
+
return true;
|
|
2212
|
+
} finally {
|
|
2213
|
+
releaseConditionCursors(watermark);
|
|
2214
|
+
}
|
|
2215
|
+
}
|
|
2216
|
+
if ((webShadowParts[property] || legacyTransformParts.has(property)) && (typeof value === "string" && value.indexOf(":") !== -1 || value && typeof value === "object" && !Array.isArray(value) && !isVariable(value) && classifyConditionalObject(value, state))) {
|
|
2217
|
+
if (process.env.NODE_ENV === "development") warnOnce(`conditional "${property}" needs its composite property; dropping it`);
|
|
2218
|
+
return true;
|
|
2219
|
+
}
|
|
2220
|
+
if (value === "safe" && isSafeAreaKey(property)) {
|
|
2221
|
+
const expanded = expandSafeAreaValue(property);
|
|
2222
|
+
if (expanded) {
|
|
2223
|
+
state.flatUsesSafeArea = true;
|
|
2224
|
+
for (const [key, resolved] of expanded) emitAtParentCondition(state, key, resolved, merge, originalValue ?? value, contextOnly);
|
|
2225
|
+
return true;
|
|
2226
|
+
}
|
|
2227
|
+
}
|
|
2228
|
+
if (typeof value === "string") return contributeStyleString(state, property, value, merge, originalValue, contextOnly);
|
|
2229
|
+
if (value && typeof value === "object" && !Array.isArray(value) && !isVariable(value) && contributeStyleObject(state, property, value, merge, contextOnly)) return true;
|
|
2230
|
+
if (value != null) {
|
|
2231
|
+
emitAtParentCondition(state, property, value, merge, originalValue ?? value, contextOnly);
|
|
2232
|
+
return true;
|
|
2233
|
+
}
|
|
2234
|
+
return false;
|
|
2235
|
+
}
|
|
2236
|
+
function clearDirectStyle(state, property) {
|
|
2237
|
+
const direct = state;
|
|
2238
|
+
const atomicKey = property.startsWith("transition") ? "transition" : webShadowParts[property] ? "boxShadow" : webTextShadowParts.has(property) ? "textShadow" : legacyTransformParts.has(property) ? "transform" : property;
|
|
2239
|
+
clearFrameAtomic(state, atomicKey);
|
|
2240
|
+
const used = direct.flatUsed;
|
|
2241
|
+
if (used) delete used[atomicKey];
|
|
2242
|
+
if (atomicKey === "transform") state.transformAccumulator = void 0;
|
|
2243
|
+
if (state.style) delete state.style[atomicKey];
|
|
2244
|
+
delete state.classNames[atomicKey];
|
|
2245
|
+
}
|
|
2246
|
+
const conditionTransports = /* @__PURE__ */ new WeakSet();
|
|
2247
|
+
function isConditionTransport(value) {
|
|
2248
|
+
return typeof value === "object" && value !== null && conditionTransports.has(value);
|
|
2249
|
+
}
|
|
2250
|
+
const transportEntryWidth = 2;
|
|
2251
|
+
function appendConditionEntry(entries, cursor, value) {
|
|
2252
|
+
entries.push(value, conditionTexts[cursor + conditionKeyOffset] || "");
|
|
2253
|
+
}
|
|
2254
|
+
function acquireTransportCursor(state, entries, offset, parent) {
|
|
2255
|
+
const cursor = acquireConditionCursor(parent);
|
|
2256
|
+
const key = entries[offset + 1];
|
|
2257
|
+
if (key) resolveConditionText(state, cursor, key);
|
|
2258
|
+
commitConditionCursor(state, cursor);
|
|
2259
|
+
return cursor;
|
|
2260
|
+
}
|
|
2261
|
+
function mergeConditionTransport(state, prev, cursor, value) {
|
|
2262
|
+
let transport;
|
|
2263
|
+
if (isConditionTransport(prev)) transport = prev;
|
|
2264
|
+
else {
|
|
2265
|
+
transport = {
|
|
2266
|
+
hasBase: false,
|
|
2267
|
+
base: void 0,
|
|
2268
|
+
entries: []
|
|
2269
|
+
};
|
|
2270
|
+
conditionTransports.add(transport);
|
|
2271
|
+
if (prev != null) {
|
|
2272
|
+
const isObjectValue = typeof prev === "object" && !Array.isArray(prev) && !isVariable(prev);
|
|
2273
|
+
const objectHasDefault = isObjectValue && Object.prototype.hasOwnProperty.call(prev, "default");
|
|
2274
|
+
const authoredWatermark = conditionCursorTop;
|
|
2275
|
+
try {
|
|
2276
|
+
const firstCursor = isObjectValue && !objectHasDefault ? acquireConditionCursor() : null;
|
|
2277
|
+
if (isObjectValue && classifyConditionalObject(prev, state, void 0, firstCursor || void 0)) {
|
|
2278
|
+
let useFirstCursor = firstCursor !== null;
|
|
2279
|
+
for (const key in prev) {
|
|
2280
|
+
const payload = prev[key];
|
|
2281
|
+
if (payload == null) continue;
|
|
2282
|
+
if (key === "default") {
|
|
2283
|
+
transport.hasBase = true;
|
|
2284
|
+
transport.base = payload;
|
|
2285
|
+
continue;
|
|
2286
|
+
}
|
|
2287
|
+
const watermark = conditionCursorTop;
|
|
2288
|
+
const keyCursor = useFirstCursor ? firstCursor : acquireConditionCursor();
|
|
2289
|
+
if (useFirstCursor) useFirstCursor = false;
|
|
2290
|
+
else {
|
|
2291
|
+
resolveConditionText(state, keyCursor, key);
|
|
2292
|
+
commitConditionCursor(state, keyCursor);
|
|
2293
|
+
}
|
|
2294
|
+
appendConditionEntry(transport.entries, keyCursor, payload);
|
|
2295
|
+
if (keyCursor !== firstCursor) releaseConditionCursors(watermark);
|
|
2296
|
+
}
|
|
2297
|
+
} else {
|
|
2298
|
+
transport.hasBase = true;
|
|
2299
|
+
transport.base = prev;
|
|
759
2300
|
}
|
|
760
|
-
|
|
2301
|
+
} finally {
|
|
2302
|
+
releaseConditionCursors(authoredWatermark);
|
|
761
2303
|
}
|
|
762
|
-
}
|
|
2304
|
+
}
|
|
2305
|
+
}
|
|
2306
|
+
const cursorKey = conditionTexts[cursor + conditionKeyOffset] || "";
|
|
2307
|
+
for (let offset = 0; offset < transport.entries.length; offset += transportEntryWidth) if (transport.entries[offset + 1] === cursorKey) {
|
|
2308
|
+
transport.entries.splice(offset, transportEntryWidth);
|
|
2309
|
+
break;
|
|
2310
|
+
}
|
|
2311
|
+
appendConditionEntry(transport.entries, cursor, value);
|
|
2312
|
+
return transport;
|
|
2313
|
+
}
|
|
2314
|
+
const variantValueHandler = {
|
|
2315
|
+
segment(ctx, start, end, isBase, valid, source, chainStart, chainEnd, chainValid) {
|
|
2316
|
+
const state = ctx[0];
|
|
2317
|
+
const directState = state;
|
|
2318
|
+
if (start === end) return;
|
|
2319
|
+
if (isBase) {
|
|
2320
|
+
feedCompoundSegment(directState, source, start, end, true, valid, "");
|
|
2321
|
+
if (!valid) return;
|
|
2322
|
+
emitResolvedVariant(ctx[1], source.slice(start, end), state, ctx[2], null);
|
|
2323
|
+
return;
|
|
2324
|
+
}
|
|
2325
|
+
if (!valid || !chainValid) return;
|
|
2326
|
+
const cursor = directState.flatScanCursor;
|
|
2327
|
+
const condition = cursor && conditionNumbers[cursor + conditionFlagsOffset] & conditionResolvedFlag ? conditionNumbers[cursor + conditionValueOffset] : 0;
|
|
2328
|
+
feedCompoundSegment(directState, source, start, end, false, Boolean(condition), condition && directState.flatPass?.[passCompoundIndexes] ? conditionTexts[cursor + conditionKeyOffset] || "" : "");
|
|
2329
|
+
if (!condition) return;
|
|
2330
|
+
emitResolvedVariant(ctx[1], source.slice(start, end), state, ctx[2], cursor);
|
|
2331
|
+
},
|
|
2332
|
+
modifier(ctx, start, end, valid, first, source) {
|
|
2333
|
+
const directState = ctx[0];
|
|
2334
|
+
let cursor = directState.flatScanCursor;
|
|
2335
|
+
if (!cursor) cursor = directState.flatScanCursor = acquireConditionCursor();
|
|
2336
|
+
else if (first) resetConditionCursor(cursor, 0);
|
|
2337
|
+
if (!valid) {
|
|
2338
|
+
setConditionUnresolved(cursor);
|
|
2339
|
+
return;
|
|
2340
|
+
}
|
|
2341
|
+
if (conditionNumbers[cursor + conditionFlagsOffset] & conditionResolvedFlag) resolveConditionModifier(ctx[0], cursor, source.slice(start, end));
|
|
2342
|
+
},
|
|
2343
|
+
chain(ctx, _start, _end, valid) {
|
|
2344
|
+
const cursor = ctx[0].flatScanCursor;
|
|
2345
|
+
if (cursor) {
|
|
2346
|
+
if (!valid) setConditionUnresolved(cursor);
|
|
2347
|
+
if (conditionNumbers[cursor + conditionFlagsOffset] & conditionResolvedFlag) commitConditionCursor(ctx[0], cursor);
|
|
2348
|
+
}
|
|
2349
|
+
return true;
|
|
763
2350
|
}
|
|
764
|
-
if (!styleProps.noNormalize) fixStyles(styleOut);
|
|
765
|
-
if (originalValues) styleOriginalValues.set(styleOut, originalValues);
|
|
766
|
-
return styleOut;
|
|
767
2351
|
};
|
|
768
|
-
const
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
2352
|
+
const contextPropSets = /* @__PURE__ */ new WeakMap();
|
|
2353
|
+
function getContextPropSet(staticConfig) {
|
|
2354
|
+
const cached = contextPropSets.get(staticConfig);
|
|
2355
|
+
if (cached !== void 0) return cached;
|
|
2356
|
+
const contextConfig = staticConfig.context || staticConfig.parentStaticConfig?.context;
|
|
2357
|
+
const inheritedContextPropKeys = !staticConfig.context || staticConfig.context === staticConfig.parentStaticConfig?.context ? staticConfig.parentStaticConfig?.contextProps : void 0;
|
|
2358
|
+
const contextPropKeys = staticConfig.contextProps || inheritedContextPropKeys;
|
|
2359
|
+
let set = null;
|
|
2360
|
+
if (contextConfig?.props) {
|
|
2361
|
+
set ||= /* @__PURE__ */ new Set();
|
|
2362
|
+
for (const key in contextConfig.props) set.add(key);
|
|
2363
|
+
}
|
|
2364
|
+
if (contextPropKeys) {
|
|
2365
|
+
set ||= /* @__PURE__ */ new Set();
|
|
2366
|
+
for (const key of contextPropKeys) set.add(key);
|
|
2367
|
+
}
|
|
2368
|
+
if (contextConfig?.propKeys) {
|
|
2369
|
+
set ||= /* @__PURE__ */ new Set();
|
|
2370
|
+
for (const key of contextConfig.propKeys) set.add(key);
|
|
2371
|
+
}
|
|
2372
|
+
const parentPropKeys = staticConfig.parentStaticConfig?.context?.propKeys;
|
|
2373
|
+
if (parentPropKeys) {
|
|
2374
|
+
set ||= /* @__PURE__ */ new Set();
|
|
2375
|
+
for (const key of parentPropKeys) set.add(key);
|
|
2376
|
+
}
|
|
2377
|
+
contextPropSets.set(staticConfig, set);
|
|
2378
|
+
return set;
|
|
2379
|
+
}
|
|
2380
|
+
function emitMappedValue(styleState, key, value, originalValue, nestedCondition, parentCondition, fallbackOriginal) {
|
|
2381
|
+
const nested = nestedCondition;
|
|
2382
|
+
const parent = parentCondition;
|
|
2383
|
+
let resolvedCondition = nested ?? parent;
|
|
2384
|
+
const watermark = conditionCursorTop;
|
|
2385
|
+
if (nested && parent) {
|
|
2386
|
+
const composed = acquireConditionCursor(parent);
|
|
2387
|
+
const nestedKey = conditionTexts[nested + conditionKeyOffset] || "";
|
|
2388
|
+
if (nestedKey) resolveConditionText(styleState, composed, nestedKey);
|
|
2389
|
+
if (!(conditionNumbers[nested + conditionFlagsOffset] & conditionResolvedFlag)) setConditionUnresolved(composed);
|
|
2390
|
+
commitConditionCursor(styleState, composed);
|
|
2391
|
+
resolvedCondition = composed;
|
|
2392
|
+
}
|
|
2393
|
+
const conf = styleState.conf;
|
|
2394
|
+
if (key === "fontFamily" || key === conf.inverseShorthands.fontFamily) styleState.fontFamily = getFontFamilyFromNameOrVariable(value, conf);
|
|
2395
|
+
mapContributedProp(styleState, key, value, originalValue ?? fallbackOriginal, resolvedCondition);
|
|
2396
|
+
releaseConditionCursors(watermark);
|
|
2397
|
+
}
|
|
2398
|
+
const contributeMappedValue = (key, value, styleState, disabled, parentCondition, fallbackOriginal) => {
|
|
2399
|
+
if (disabled) return emitMappedValue(styleState, key, value, void 0, void 0, parentCondition, fallbackOriginal);
|
|
2400
|
+
const { conf, styleProps, staticConfig } = styleState;
|
|
2401
|
+
const { variants } = staticConfig;
|
|
2402
|
+
const { disableExpandShorthands, noExpand, resolveValues } = styleProps;
|
|
2403
|
+
const shorthands = conf.shorthands;
|
|
2404
|
+
if (!noExpand) {
|
|
2405
|
+
if (variants && key in variants) {
|
|
2406
|
+
resolveVariants(key, value, styleProps, styleState, key);
|
|
2407
|
+
return;
|
|
2408
|
+
}
|
|
2409
|
+
}
|
|
2410
|
+
if (!disableExpandShorthands) {
|
|
2411
|
+
if (key in shorthands) key = shorthands[key];
|
|
2412
|
+
}
|
|
2413
|
+
const originalValue = value;
|
|
2414
|
+
if (value === "safe" && isSafeAreaKey(key)) {
|
|
2415
|
+
const expanded = expandSafeAreaValue(key);
|
|
2416
|
+
if (expanded) {
|
|
2417
|
+
for (let i = 0; i < expanded.length; i++) {
|
|
2418
|
+
const [nkey, nvalue] = expanded[i];
|
|
2419
|
+
emitMappedValue(styleState, nkey, nvalue, originalValue, void 0, parentCondition, fallbackOriginal);
|
|
2420
|
+
}
|
|
2421
|
+
return;
|
|
2422
|
+
}
|
|
2423
|
+
}
|
|
2424
|
+
if (value != null) {
|
|
2425
|
+
if (typeof value === "string") value = isRemValue(value) ? resolveRem(value) : value;
|
|
2426
|
+
else if (isVariable(value)) value = resolveVariableValue(key, value, resolveValues);
|
|
2427
|
+
else if (isRemValue(value)) value = resolveRem(value);
|
|
2428
|
+
}
|
|
2429
|
+
if (value != null) {
|
|
2430
|
+
if (key === "fontFamily" && typeof originalValue === "string") {
|
|
2431
|
+
if (originalValue in conf.fontsParsed) styleState.fontFamily = originalValue;
|
|
2432
|
+
}
|
|
2433
|
+
const expanded = noExpand || typeof value === "string" ? null : expandStyle(key, value, conf.settings.styleCompat || "web");
|
|
2434
|
+
if (expanded) {
|
|
2435
|
+
const max = expanded.length;
|
|
2436
|
+
for (let i = 0; i < max; i++) {
|
|
2437
|
+
const [nkey, nvalue, noriginalValue] = expanded[i];
|
|
2438
|
+
emitMappedValue(styleState, nkey, nvalue, noriginalValue ?? originalValue, void 0, parentCondition, fallbackOriginal);
|
|
2439
|
+
}
|
|
2440
|
+
} else emitMappedValue(styleState, key, value, originalValue, void 0, parentCondition, fallbackOriginal);
|
|
2441
|
+
}
|
|
776
2442
|
};
|
|
777
|
-
function
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
if (
|
|
781
|
-
|
|
782
|
-
|
|
2443
|
+
function resolveVariants(key, value, styleProps, styleState, parentVariantKey) {
|
|
2444
|
+
const variantDefinition = styleState.staticConfig.variants?.[key];
|
|
2445
|
+
if (isConditionTransport(value)) {
|
|
2446
|
+
if (value.hasBase) emitResolvedVariant(key, value.base, styleState, parentVariantKey, null);
|
|
2447
|
+
for (let offset = 0; offset < value.entries.length;) {
|
|
2448
|
+
const entryValue = value.entries[offset];
|
|
2449
|
+
const watermark = conditionCursorTop;
|
|
2450
|
+
try {
|
|
2451
|
+
emitResolvedVariant(key, entryValue, styleState, parentVariantKey, acquireTransportCursor(styleState, value.entries, offset, null));
|
|
2452
|
+
} finally {
|
|
2453
|
+
releaseConditionCursors(watermark);
|
|
2454
|
+
}
|
|
2455
|
+
offset += transportEntryWidth;
|
|
2456
|
+
}
|
|
2457
|
+
return;
|
|
2458
|
+
}
|
|
2459
|
+
if (typeof value === "string" && !(variantDefinition && typeof variantDefinition === "object" && value in variantDefinition)) {
|
|
2460
|
+
const directState = styleState;
|
|
2461
|
+
const watermark = conditionCursorTop;
|
|
2462
|
+
const previousCursor = directState.flatScanCursor;
|
|
2463
|
+
directState.flatScanCursor = null;
|
|
2464
|
+
try {
|
|
2465
|
+
scanFlatValue(value, variantValueHandler, [
|
|
2466
|
+
styleState,
|
|
2467
|
+
key,
|
|
2468
|
+
parentVariantKey
|
|
2469
|
+
]);
|
|
2470
|
+
} finally {
|
|
2471
|
+
directState.flatScanCursor = previousCursor;
|
|
2472
|
+
releaseConditionCursors(watermark);
|
|
2473
|
+
}
|
|
2474
|
+
return;
|
|
2475
|
+
}
|
|
2476
|
+
const isObjectValue = value && typeof value === "object" && !Array.isArray(value) && !isVariable(value);
|
|
2477
|
+
const objectHasDefault = isObjectValue && Object.prototype.hasOwnProperty.call(value, "default");
|
|
2478
|
+
const objectWatermark = conditionCursorTop;
|
|
2479
|
+
try {
|
|
2480
|
+
const firstCursor = isObjectValue && !objectHasDefault ? acquireConditionCursor() : null;
|
|
2481
|
+
if (isObjectValue && classifyConditionalObject(value, styleState, void 0, firstCursor || void 0)) {
|
|
2482
|
+
let useFirstCursor = firstCursor !== null;
|
|
2483
|
+
for (const objKey in value) {
|
|
2484
|
+
const payload = value[objKey];
|
|
2485
|
+
if (payload == null) continue;
|
|
2486
|
+
const directState = styleState;
|
|
2487
|
+
const payloadString = String(payload);
|
|
2488
|
+
if (objKey === "default") {
|
|
2489
|
+
feedCompoundSegment(directState, payloadString, 0, payloadString.length, true, true, "");
|
|
2490
|
+
emitResolvedVariant(key, payload, styleState, parentVariantKey, null);
|
|
2491
|
+
continue;
|
|
2492
|
+
}
|
|
2493
|
+
const watermark = conditionCursorTop;
|
|
2494
|
+
const cursor = useFirstCursor ? firstCursor : acquireConditionCursor();
|
|
2495
|
+
let condition = conditionNumbers[cursor + conditionValueOffset];
|
|
2496
|
+
if (useFirstCursor) useFirstCursor = false;
|
|
2497
|
+
else {
|
|
2498
|
+
resolveConditionText(styleState, cursor, objKey);
|
|
2499
|
+
condition = commitConditionCursor(styleState, cursor);
|
|
2500
|
+
}
|
|
2501
|
+
if (directState.flatPass?.[passCompoundIndexes]) feedCompoundSegment(directState, payloadString, 0, payloadString.length, false, Boolean(condition), condition ? conditionTexts[cursor + conditionKeyOffset] || "" : "");
|
|
2502
|
+
emitResolvedVariant(key, payload, styleState, parentVariantKey, cursor);
|
|
2503
|
+
if (cursor !== firstCursor) releaseConditionCursors(watermark);
|
|
2504
|
+
}
|
|
2505
|
+
return;
|
|
783
2506
|
}
|
|
2507
|
+
} finally {
|
|
2508
|
+
releaseConditionCursors(objectWatermark);
|
|
784
2509
|
}
|
|
2510
|
+
emitResolvedVariant(key, value, styleState, parentVariantKey, null);
|
|
785
2511
|
}
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
const
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
};
|
|
795
|
-
|
|
796
|
-
|
|
2512
|
+
function emitResolvedVariant(key, value, styleState, parentVariantKey, conditionCursor) {
|
|
2513
|
+
const { staticConfig, conf, debug } = styleState;
|
|
2514
|
+
const styleProps = styleState.styleProps;
|
|
2515
|
+
const { variants } = staticConfig;
|
|
2516
|
+
if (!variants) return;
|
|
2517
|
+
const variant = variants[key];
|
|
2518
|
+
let variantValue = getVariantDefinition(variant, value, conf, styleState);
|
|
2519
|
+
if (process.env.NODE_ENV === "development" && debug === "verbose") {
|
|
2520
|
+
console.groupCollapsed(`\u2666\uFE0F\u2666\uFE0F\u2666\uFE0F resolve variant ${key}`);
|
|
2521
|
+
console.info({
|
|
2522
|
+
key,
|
|
2523
|
+
value,
|
|
2524
|
+
variantValue,
|
|
2525
|
+
variants
|
|
2526
|
+
});
|
|
2527
|
+
console.groupEnd();
|
|
2528
|
+
}
|
|
2529
|
+
if (!variantValue) {
|
|
2530
|
+
if (process.env.TAMAGUI_WARN_ON_MISSING_VARIANT === "1") {
|
|
2531
|
+
if (typeof value !== "boolean") {
|
|
2532
|
+
const name = styleState.styleProps.displayName || "[UnnamedComponent]";
|
|
2533
|
+
console.warn(`No variant found: ${name} has variant "${key}", but no matching value "${value}"`);
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
return;
|
|
2537
|
+
}
|
|
2538
|
+
if (typeof variantValue === "function") {
|
|
2539
|
+
const fn = variantValue;
|
|
2540
|
+
const extras = getVariantExtras(styleState);
|
|
2541
|
+
variantValue = fn(value, extras);
|
|
2542
|
+
if (process.env.NODE_ENV === "development" && debug === "verbose" && true) {
|
|
2543
|
+
console.groupCollapsed(" expanded functional variant", key);
|
|
2544
|
+
console.info({
|
|
2545
|
+
fn,
|
|
2546
|
+
variantValue,
|
|
2547
|
+
extras
|
|
2548
|
+
});
|
|
2549
|
+
console.groupEnd();
|
|
2550
|
+
}
|
|
2551
|
+
}
|
|
2552
|
+
if (!isObj(variantValue)) return;
|
|
2553
|
+
if (process.env.NODE_ENV === "development" && debug === "verbose") console.info(` expanding styles from `, variantValue);
|
|
2554
|
+
const { noSkip } = styleProps;
|
|
2555
|
+
const originals = styleOriginalValues.get(variantValue);
|
|
2556
|
+
const directState = styleState;
|
|
2557
|
+
directState.flatCompoundOutputDepth = (directState.flatCompoundOutputDepth || 0) + 1;
|
|
2558
|
+
try {
|
|
2559
|
+
for (const outputKey in variantValue) {
|
|
2560
|
+
if (!noSkip && outputKey in skipProps) continue;
|
|
2561
|
+
const rawOutputValue = variantValue[outputKey];
|
|
2562
|
+
const outputValue = styleProps.noNormalize ? rawOutputValue : normalizeValueWithProperty(rawOutputValue, conf.shorthands[outputKey] || outputKey);
|
|
2563
|
+
const originalValue = originals?.[outputKey] ?? rawOutputValue;
|
|
2564
|
+
if (getContextPropSet(staticConfig)?.has(outputKey)) {
|
|
2565
|
+
styleState.overriddenContextProps ||= {};
|
|
2566
|
+
styleState.overriddenContextProps[outputKey] = originalValue;
|
|
2567
|
+
styleState.originalContextPropValues ||= {};
|
|
2568
|
+
styleState.originalContextPropValues[outputKey] = originalValue;
|
|
2569
|
+
}
|
|
2570
|
+
contributeMappedValue(outputKey, outputValue, styleState, parentVariantKey === key && outputKey === key, conditionCursor || void 0, originalValue);
|
|
2571
|
+
}
|
|
2572
|
+
} finally {
|
|
2573
|
+
directState.flatCompoundOutputDepth--;
|
|
2574
|
+
}
|
|
797
2575
|
}
|
|
798
|
-
function
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
2576
|
+
function getFontFamilyFromNameOrVariable(input, conf) {
|
|
2577
|
+
if (isVariable(input)) {
|
|
2578
|
+
const val = variableToFontNameCache.get(input);
|
|
2579
|
+
if (val) return val;
|
|
2580
|
+
for (const key in conf.fontsParsed) {
|
|
2581
|
+
const familyVariable = conf.fontsParsed[key].family;
|
|
2582
|
+
if (isVariable(familyVariable)) {
|
|
2583
|
+
variableToFontNameCache.set(familyVariable, key);
|
|
2584
|
+
if (familyVariable === input) return key;
|
|
2585
|
+
}
|
|
2586
|
+
}
|
|
2587
|
+
} else if (typeof input === "string" && input in conf.fontsParsed) return input;
|
|
2588
|
+
}
|
|
2589
|
+
const variableToFontNameCache = /* @__PURE__ */ new WeakMap();
|
|
2590
|
+
function getVariantDefinition(variant, value, conf, { theme }) {
|
|
2591
|
+
if (!variant) return;
|
|
2592
|
+
if (value === void 0) return;
|
|
2593
|
+
if (typeof variant === "function") return variant;
|
|
2594
|
+
if (Object.prototype.hasOwnProperty.call(variant, value)) return variant[value];
|
|
2595
|
+
for (const { key, parts } of getCompiledVariantResolvers(variant)) for (const part of parts) if (matchesVariantResolver(part, value, conf, theme)) return variant[key];
|
|
2596
|
+
}
|
|
2597
|
+
const variantResolverNameSet = new Set(variantResolverNames);
|
|
2598
|
+
const variantResolverCache = /* @__PURE__ */ new WeakMap();
|
|
2599
|
+
const preparedStyleStaticConfigs = /* @__PURE__ */ new WeakSet();
|
|
2600
|
+
function prepareStyleStaticConfig(staticConfig) {
|
|
2601
|
+
if (preparedStyleStaticConfigs.has(staticConfig)) return staticConfig;
|
|
2602
|
+
preparedStyleStaticConfigs.add(staticConfig);
|
|
2603
|
+
getContextPropSet(staticConfig);
|
|
2604
|
+
prepareStaticConfigCompounds(staticConfig);
|
|
2605
|
+
const variants = staticConfig.variants;
|
|
2606
|
+
if (variants) for (const key in variants) {
|
|
2607
|
+
const variant = variants[key];
|
|
2608
|
+
if (variant && typeof variant === "object") getCompiledVariantResolvers(variant);
|
|
2609
|
+
}
|
|
2610
|
+
return staticConfig;
|
|
2611
|
+
}
|
|
2612
|
+
function getCompiledVariantResolvers(variant) {
|
|
2613
|
+
let cached = variantResolverCache.get(variant);
|
|
2614
|
+
if (cached) return cached;
|
|
2615
|
+
const compiled = [];
|
|
2616
|
+
for (const key in variant) {
|
|
2617
|
+
const parts = parseVariantResolverKey(key);
|
|
2618
|
+
if (parts) compiled.push({
|
|
2619
|
+
key,
|
|
2620
|
+
parts
|
|
2621
|
+
});
|
|
2622
|
+
}
|
|
2623
|
+
variantResolverCache.set(variant, compiled);
|
|
2624
|
+
return compiled;
|
|
2625
|
+
}
|
|
2626
|
+
function parseVariantResolverKey(key) {
|
|
2627
|
+
if (!key) return null;
|
|
2628
|
+
const parts = [];
|
|
2629
|
+
let start = 0;
|
|
2630
|
+
for (let index = 0; index <= key.length; index++) {
|
|
2631
|
+
if (index !== key.length && key.charCodeAt(index) !== 124) continue;
|
|
2632
|
+
let partStart = start;
|
|
2633
|
+
let partEnd = index;
|
|
2634
|
+
while (partStart < partEnd && key.charCodeAt(partStart) <= 32) partStart++;
|
|
2635
|
+
while (partEnd > partStart && key.charCodeAt(partEnd - 1) <= 32) partEnd--;
|
|
2636
|
+
if (partStart === partEnd) return null;
|
|
2637
|
+
const part = key.slice(partStart, partEnd);
|
|
2638
|
+
if (!variantResolverNameSet.has(part)) return null;
|
|
2639
|
+
parts.push(part);
|
|
2640
|
+
start = index + 1;
|
|
2641
|
+
}
|
|
2642
|
+
return parts;
|
|
2643
|
+
}
|
|
2644
|
+
function hasNumericPrefix(value, suffixLength) {
|
|
2645
|
+
if (value.length <= suffixLength) return false;
|
|
2646
|
+
return Number.isFinite(Number(value.slice(0, value.length - suffixLength)));
|
|
2647
|
+
}
|
|
2648
|
+
function matchesVariantResolver(resolverName, value, conf, theme) {
|
|
2649
|
+
const string = typeof value === "string";
|
|
2650
|
+
const number = typeof value === "number";
|
|
2651
|
+
const rem = string && value.endsWith("rem") && hasNumericPrefix(value, 3);
|
|
2652
|
+
switch (resolverName) {
|
|
2653
|
+
case "Size":
|
|
2654
|
+
case "Space":
|
|
2655
|
+
case "Radius":
|
|
2656
|
+
case "ZIndex": return value === true || number || string || resolverName !== "Size" && isVariable(value);
|
|
2657
|
+
case "Color": return value != null && value in conf.tokensParsed.color || string;
|
|
2658
|
+
case "Theme": return string && !!theme && value in theme;
|
|
2659
|
+
case "FontSize": return value === true || !!conf.fontsParsed.body?.size?.[value] || number || rem;
|
|
2660
|
+
case "FontStyle": return !!conf.fontsParsed.body?.style?.[value] || value === "normal" || value === "italic";
|
|
2661
|
+
case "FontTransform": return !!conf.fontsParsed.body?.transform?.[value] || value === "none" || value === "capitalize" || value === "uppercase" || value === "lowercase";
|
|
2662
|
+
case "FontLineHeight": return !!conf.fontsParsed.body?.lineHeight?.[value] || number || rem;
|
|
2663
|
+
case "FontLetterSpacing": return !!conf.fontsParsed.body?.letterSpacing?.[value] || number || rem;
|
|
2664
|
+
case "number":
|
|
2665
|
+
case "string":
|
|
2666
|
+
case "boolean": return typeof value === resolverName;
|
|
2667
|
+
case "any": return true;
|
|
804
2668
|
}
|
|
805
|
-
if (isWeb && Array.isArray(out.transform)) out.transform = transformsToString(out.transform);
|
|
806
|
-
fixStyles(out);
|
|
807
|
-
return out;
|
|
808
2669
|
}
|
|
809
2670
|
|
|
810
|
-
export { STYLE_TOKEN_PROVENANCE_KEY, getSplitStyles, getStyleTokenProvenance,
|
|
2671
|
+
export { STYLE_TOKEN_PROVENANCE_KEY, clearDirectStyle, contributeStyleString, directStyleSignature, flushDirectStyles2 as flushDirectStyles, getContextPropSet, getDirectDynamicThemeAccess, getFontFamilyFromNameOrVariable, getSplitStyles, getStyleTokenProvenance, isValidStyleKey, prepareStyleStaticConfig, styleOriginalValues };
|
|
811
2672
|
//# sourceMappingURL=getSplitStyles.mjs.map
|