@tamagui/web 3.0.0-beta.831.1 → 3.0.0-beta.889.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 +12 -1
- package/dist/cjs/createComponent.native.cjs +12 -1
- package/dist/cjs/createComponent.native.js +12 -1
- package/dist/cjs/createComponent.native.js.map +1 -1
- package/dist/cjs/createStyledHOC.cjs +1 -1
- package/dist/cjs/createStyledHOC.native.cjs +1 -1
- package/dist/cjs/createStyledHOC.native.js +1 -1
- package/dist/cjs/createStyledHOC.native.js.map +1 -1
- package/dist/cjs/createVariable.cjs +0 -10
- package/dist/cjs/createVariable.native.cjs +0 -10
- package/dist/cjs/createVariable.native.js +0 -10
- package/dist/cjs/createVariable.native.js.map +1 -1
- package/dist/cjs/helpers/borderComponents.cjs +62 -0
- package/dist/cjs/helpers/borderComponents.native.cjs +82 -0
- package/dist/cjs/helpers/borderComponents.native.js +84 -0
- package/dist/cjs/helpers/borderComponents.native.js.map +1 -0
- package/dist/cjs/helpers/createDesignSystem.cjs +0 -2
- package/dist/cjs/helpers/createStyledContext.cjs +10 -18
- package/dist/cjs/helpers/createStyledContext.native.cjs +14 -18
- package/dist/cjs/helpers/createStyledContext.native.js +14 -18
- package/dist/cjs/helpers/createStyledContext.native.js.map +1 -1
- package/dist/cjs/helpers/formatDiagnostic.cjs +6 -6
- package/dist/cjs/helpers/formatDiagnostic.native.cjs +6 -6
- package/dist/cjs/helpers/formatDiagnostic.native.js +6 -6
- package/dist/cjs/helpers/formatDiagnostic.native.js.map +1 -1
- package/dist/cjs/helpers/getCSSStylesAtomic.cjs +128 -109
- package/dist/cjs/helpers/getCSSStylesAtomic.native.cjs +11 -3
- package/dist/cjs/helpers/getCSSStylesAtomic.native.js +11 -3
- package/dist/cjs/helpers/getCSSStylesAtomic.native.js.map +1 -1
- package/dist/cjs/helpers/getCSSStylesAtomicCompiled.cjs +13 -1
- package/dist/cjs/helpers/getCSSStylesAtomicCompiled.native.cjs +15 -1
- package/dist/cjs/helpers/getCSSStylesAtomicCompiled.native.js +15 -1
- package/dist/cjs/helpers/getCSSStylesAtomicCompiled.native.js.map +1 -1
- package/dist/cjs/helpers/getDynamicVal.cjs +5 -1
- package/dist/cjs/helpers/getDynamicVal.native.cjs +5 -1
- package/dist/cjs/helpers/getDynamicVal.native.js +5 -1
- package/dist/cjs/helpers/getDynamicVal.native.js.map +1 -1
- package/dist/cjs/helpers/getSplitStyles.cjs +1042 -1715
- package/dist/cjs/helpers/getSplitStyles.native.cjs +1081 -1887
- package/dist/cjs/helpers/getSplitStyles.native.js +1081 -1887
- package/dist/cjs/helpers/getSplitStyles.native.js.map +1 -1
- package/dist/cjs/helpers/grammarConfig.cjs +163 -1
- package/dist/cjs/helpers/grammarConfig.native.cjs +186 -1
- package/dist/cjs/helpers/grammarConfig.native.js +186 -1
- package/dist/cjs/helpers/grammarConfig.native.js.map +1 -1
- package/dist/cjs/helpers/insertStyleRule.cjs +5 -1
- package/dist/cjs/helpers/insertStyleRule.native.cjs +7 -1
- package/dist/cjs/helpers/insertStyleRule.native.js +7 -1
- package/dist/cjs/helpers/insertStyleRule.native.js.map +1 -1
- package/dist/cjs/helpers/log.cjs +9 -8
- package/dist/cjs/helpers/log.native.cjs +9 -8
- package/dist/cjs/helpers/log.native.js +9 -8
- package/dist/cjs/helpers/log.native.js.map +1 -1
- package/dist/cjs/helpers/mergeVariants.cjs +44 -13
- package/dist/cjs/helpers/mergeVariants.native.cjs +79 -14
- package/dist/cjs/helpers/mergeVariants.native.js +79 -14
- package/dist/cjs/helpers/mergeVariants.native.js.map +1 -1
- package/dist/cjs/helpers/nativeOnlyProps.cjs +0 -1
- package/dist/cjs/helpers/nativeOnlyProps.native.cjs +0 -1
- package/dist/cjs/helpers/nativeOnlyProps.native.js +0 -1
- package/dist/cjs/helpers/nativeOnlyProps.native.js.map +1 -1
- package/dist/cjs/helpers/nativeStyleEngine.cjs +34 -14
- package/dist/cjs/helpers/nativeStyleEngine.native.cjs +36 -14
- package/dist/cjs/helpers/nativeStyleEngine.native.js +36 -14
- package/dist/cjs/helpers/nativeStyleEngine.native.js.map +1 -1
- package/dist/cjs/helpers/normalizeValueWithProperty.cjs +7 -8
- package/dist/cjs/helpers/normalizeValueWithProperty.native.cjs +9 -8
- package/dist/cjs/helpers/normalizeValueWithProperty.native.js +9 -8
- package/dist/cjs/helpers/normalizeValueWithProperty.native.js.map +1 -1
- package/dist/cjs/helpers/parseBorderShorthand.native.cjs +25 -56
- package/dist/cjs/helpers/parseBorderShorthand.native.js +25 -56
- package/dist/cjs/helpers/parseBorderShorthand.native.js.map +1 -1
- package/dist/cjs/helpers/parseOutlineShorthand.native.cjs +9 -49
- package/dist/cjs/helpers/parseOutlineShorthand.native.js +9 -49
- package/dist/cjs/helpers/parseOutlineShorthand.native.js.map +1 -1
- package/dist/cjs/helpers/resolveSafeArea.cjs +35 -100
- package/dist/cjs/helpers/resolveVariantStyle.cjs +57 -0
- package/dist/cjs/helpers/resolveVariantStyle.native.cjs +67 -0
- package/dist/cjs/helpers/resolveVariantStyle.native.js +69 -0
- package/dist/cjs/helpers/resolveVariantStyle.native.js.map +1 -0
- package/dist/cjs/helpers/styleStaticConfig.cjs +1 -50
- package/dist/cjs/helpers/styleStaticConfig.native.cjs +1 -51
- package/dist/cjs/helpers/styleStaticConfig.native.js +1 -51
- package/dist/cjs/helpers/styleStaticConfig.native.js.map +1 -1
- package/dist/cjs/helpers/styleStaticConfigCore.cjs +107 -0
- package/dist/cjs/helpers/styleStaticConfigCore.native.cjs +127 -0
- package/dist/cjs/helpers/styleStaticConfigCore.native.js +129 -0
- package/dist/cjs/helpers/styleStaticConfigCore.native.js.map +1 -0
- package/dist/cjs/helpers/styledDynamic.cjs +160 -0
- package/dist/cjs/helpers/styledDynamic.native.cjs +195 -0
- package/dist/cjs/helpers/styledDynamic.native.js +197 -0
- package/dist/cjs/helpers/styledDynamic.native.js.map +1 -0
- package/dist/cjs/helpers/tokenCategories.cjs +15 -38
- package/dist/cjs/helpers/tokenCategories.native.cjs +15 -40
- package/dist/cjs/helpers/tokenCategories.native.js +15 -40
- package/dist/cjs/helpers/tokenCategories.native.js.map +1 -1
- package/dist/cjs/helpers/variableValue.cjs +17 -12
- package/dist/cjs/helpers/variableValue.native.cjs +46 -23
- package/dist/cjs/helpers/variableValue.native.js +46 -23
- package/dist/cjs/helpers/variableValue.native.js.map +1 -1
- package/dist/cjs/helpers/warnOnce.cjs +5 -4
- package/dist/cjs/helpers/warnOnce.native.cjs +6 -4
- package/dist/cjs/helpers/warnOnce.native.js +6 -4
- package/dist/cjs/helpers/warnOnce.native.js.map +1 -1
- package/dist/cjs/hooks/useAnimationDriver.cjs +2 -2
- package/dist/cjs/hooks/useAnimationDriver.native.cjs +2 -2
- package/dist/cjs/hooks/useAnimationDriver.native.js +2 -2
- package/dist/cjs/hooks/useAnimationDriver.native.js.map +1 -1
- package/dist/cjs/hooks/useComponentState.cjs +41 -82
- package/dist/cjs/hooks/useComponentState.native.cjs +45 -84
- package/dist/cjs/hooks/useComponentState.native.js +45 -84
- package/dist/cjs/hooks/useComponentState.native.js.map +1 -1
- package/dist/cjs/hooks/useMedia.cjs +2 -2
- package/dist/cjs/hooks/useMedia.native.cjs +2 -2
- package/dist/cjs/hooks/useMedia.native.js +2 -2
- package/dist/cjs/hooks/useMedia.native.js.map +1 -1
- package/dist/cjs/{helpers/directStyleCSS.native.js → hooks/useStyle.cjs} +16 -8
- package/dist/cjs/{helpers/directStyleCSS.native.cjs → hooks/useStyle.native.cjs} +16 -4
- package/dist/cjs/hooks/useStyle.native.js +34 -0
- package/dist/cjs/hooks/useStyle.native.js.map +1 -0
- package/dist/cjs/hooks/useThemeState.cjs +25 -90
- package/dist/cjs/hooks/useThemeState.native.cjs +34 -94
- package/dist/cjs/hooks/useThemeState.native.js +34 -94
- package/dist/cjs/hooks/useThemeState.native.js.map +1 -1
- package/dist/cjs/index.cjs +6 -3
- package/dist/cjs/index.native.cjs +6 -3
- package/dist/cjs/index.native.js +6 -3
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/static-resolve.cjs +2 -2
- package/dist/cjs/static-resolve.native.cjs +2 -2
- package/dist/cjs/static-resolve.native.js +2 -2
- package/dist/cjs/static-resolve.native.js.map +1 -1
- package/dist/cjs/style.cjs +91 -0
- package/dist/cjs/style.native.cjs +98 -0
- package/dist/cjs/style.native.js +100 -0
- package/dist/cjs/style.native.js.map +1 -0
- package/dist/cjs/styled.cjs +11 -6
- package/dist/cjs/styled.native.cjs +11 -6
- package/dist/cjs/styled.native.js +11 -6
- package/dist/cjs/styled.native.js.map +1 -1
- package/dist/cjs/types.cjs +6 -4
- package/dist/cjs/types.native.cjs +6 -4
- package/dist/cjs/types.native.js +6 -4
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/cjs/views/TamaguiProvider.cjs +1 -2
- package/dist/cjs/views/TamaguiProvider.native.cjs +1 -2
- package/dist/cjs/views/TamaguiProvider.native.js +1 -2
- package/dist/cjs/views/TamaguiProvider.native.js.map +1 -1
- package/dist/cjs/views/Text.cjs +17 -12
- package/dist/cjs/views/Text.native.cjs +1 -0
- package/dist/cjs/views/Text.native.js +1 -0
- package/dist/cjs/views/Text.native.js.map +1 -1
- package/dist/cjs/views/Theme.cjs +3 -3
- package/dist/cjs/views/Theme.native.cjs +3 -3
- package/dist/cjs/views/Theme.native.js +3 -3
- package/dist/cjs/views/Theme.native.js.map +1 -1
- package/dist/cjs/views/ThemeDebug.cjs +1 -4
- package/dist/esm/createComponent.mjs +12 -1
- package/dist/esm/createComponent.mjs.map +1 -1
- package/dist/esm/createComponent.native.js +12 -1
- package/dist/esm/createComponent.native.js.map +1 -1
- package/dist/esm/createStyledHOC.mjs +1 -1
- package/dist/esm/createStyledHOC.mjs.map +1 -1
- package/dist/esm/createStyledHOC.native.js +1 -1
- package/dist/esm/createStyledHOC.native.js.map +1 -1
- package/dist/esm/createVariable.mjs +1 -9
- package/dist/esm/createVariable.mjs.map +1 -1
- package/dist/esm/createVariable.native.js +1 -9
- package/dist/esm/createVariable.native.js.map +1 -1
- package/dist/esm/helpers/borderComponents.mjs +37 -0
- package/dist/esm/helpers/borderComponents.mjs.map +1 -0
- package/dist/esm/helpers/borderComponents.native.js +55 -0
- package/dist/esm/helpers/borderComponents.native.js.map +1 -0
- package/dist/esm/helpers/createDesignSystem.mjs +0 -2
- package/dist/esm/helpers/createDesignSystem.mjs.map +1 -1
- package/dist/esm/helpers/createStyledContext.mjs +10 -18
- package/dist/esm/helpers/createStyledContext.mjs.map +1 -1
- package/dist/esm/helpers/createStyledContext.native.js +14 -18
- package/dist/esm/helpers/createStyledContext.native.js.map +1 -1
- package/dist/esm/helpers/formatDiagnostic.mjs +6 -6
- package/dist/esm/helpers/formatDiagnostic.mjs.map +1 -1
- package/dist/esm/helpers/formatDiagnostic.native.js +6 -6
- package/dist/esm/helpers/formatDiagnostic.native.js.map +1 -1
- package/dist/esm/helpers/getCSSStylesAtomic.mjs +126 -109
- package/dist/esm/helpers/getCSSStylesAtomic.mjs.map +1 -1
- package/dist/esm/helpers/getCSSStylesAtomic.native.js +7 -4
- package/dist/esm/helpers/getCSSStylesAtomic.native.js.map +1 -1
- package/dist/esm/helpers/getCSSStylesAtomicCompiled.mjs +8 -1
- package/dist/esm/helpers/getCSSStylesAtomicCompiled.mjs.map +1 -1
- package/dist/esm/helpers/getCSSStylesAtomicCompiled.native.js +10 -1
- package/dist/esm/helpers/getCSSStylesAtomicCompiled.native.js.map +1 -1
- package/dist/esm/helpers/getDynamicVal.mjs +5 -1
- package/dist/esm/helpers/getDynamicVal.mjs.map +1 -1
- package/dist/esm/helpers/getDynamicVal.native.js +5 -1
- package/dist/esm/helpers/getDynamicVal.native.js.map +1 -1
- package/dist/esm/helpers/getSplitStyles.mjs +1034 -1705
- package/dist/esm/helpers/getSplitStyles.mjs.map +1 -1
- package/dist/esm/helpers/getSplitStyles.native.js +1071 -1871
- package/dist/esm/helpers/getSplitStyles.native.js.map +1 -1
- package/dist/esm/helpers/grammarConfig.mjs +164 -2
- package/dist/esm/helpers/grammarConfig.mjs.map +1 -1
- package/dist/esm/helpers/grammarConfig.native.js +187 -2
- package/dist/esm/helpers/grammarConfig.native.js.map +1 -1
- package/dist/esm/helpers/insertStyleRule.mjs +5 -2
- package/dist/esm/helpers/insertStyleRule.mjs.map +1 -1
- package/dist/esm/helpers/insertStyleRule.native.js +7 -2
- package/dist/esm/helpers/insertStyleRule.native.js.map +1 -1
- package/dist/esm/helpers/log.mjs +9 -8
- package/dist/esm/helpers/log.mjs.map +1 -1
- package/dist/esm/helpers/log.native.js +9 -8
- package/dist/esm/helpers/log.native.js.map +1 -1
- package/dist/esm/helpers/mergeVariants.mjs +44 -13
- package/dist/esm/helpers/mergeVariants.mjs.map +1 -1
- package/dist/esm/helpers/mergeVariants.native.js +79 -14
- package/dist/esm/helpers/mergeVariants.native.js.map +1 -1
- package/dist/esm/helpers/nativeOnlyProps.mjs +0 -1
- package/dist/esm/helpers/nativeOnlyProps.mjs.map +1 -1
- package/dist/esm/helpers/nativeOnlyProps.native.js +0 -1
- package/dist/esm/helpers/nativeOnlyProps.native.js.map +1 -1
- package/dist/esm/helpers/nativeStyleEngine.mjs +34 -15
- package/dist/esm/helpers/nativeStyleEngine.mjs.map +1 -1
- package/dist/esm/helpers/nativeStyleEngine.native.js +36 -15
- package/dist/esm/helpers/nativeStyleEngine.native.js.map +1 -1
- package/dist/esm/helpers/normalizeValueWithProperty.mjs +7 -8
- package/dist/esm/helpers/normalizeValueWithProperty.mjs.map +1 -1
- package/dist/esm/helpers/normalizeValueWithProperty.native.js +9 -8
- package/dist/esm/helpers/normalizeValueWithProperty.native.js.map +1 -1
- package/dist/esm/helpers/parseBorderShorthand.native.js +23 -56
- package/dist/esm/helpers/parseBorderShorthand.native.js.map +1 -1
- package/dist/esm/helpers/parseOutlineShorthand.native.js +10 -49
- package/dist/esm/helpers/parseOutlineShorthand.native.js.map +1 -1
- package/dist/esm/helpers/resolveSafeArea.mjs +35 -97
- package/dist/esm/helpers/resolveSafeArea.mjs.map +1 -1
- package/dist/esm/helpers/resolveVariantStyle.mjs +38 -0
- package/dist/esm/helpers/resolveVariantStyle.mjs.map +1 -0
- package/dist/esm/helpers/resolveVariantStyle.native.js +46 -0
- package/dist/esm/helpers/resolveVariantStyle.native.js.map +1 -0
- package/dist/esm/helpers/styleStaticConfig.mjs +1 -50
- package/dist/esm/helpers/styleStaticConfig.mjs.map +1 -1
- package/dist/esm/helpers/styleStaticConfig.native.js +1 -51
- package/dist/esm/helpers/styleStaticConfig.native.js.map +1 -1
- package/dist/esm/helpers/styleStaticConfigCore.mjs +88 -0
- package/dist/esm/helpers/styleStaticConfigCore.mjs.map +1 -0
- package/dist/esm/helpers/styleStaticConfigCore.native.js +106 -0
- package/dist/esm/helpers/styleStaticConfigCore.native.js.map +1 -0
- package/dist/esm/helpers/styledDynamic.mjs +136 -0
- package/dist/esm/helpers/styledDynamic.mjs.map +1 -0
- package/dist/esm/helpers/styledDynamic.native.js +169 -0
- package/dist/esm/helpers/styledDynamic.native.js.map +1 -0
- package/dist/esm/helpers/tokenCategories.mjs +15 -36
- package/dist/esm/helpers/tokenCategories.mjs.map +1 -1
- package/dist/esm/helpers/tokenCategories.native.js +15 -38
- package/dist/esm/helpers/tokenCategories.native.js.map +1 -1
- package/dist/esm/helpers/variableValue.mjs +17 -12
- package/dist/esm/helpers/variableValue.mjs.map +1 -1
- package/dist/esm/helpers/variableValue.native.js +46 -23
- package/dist/esm/helpers/variableValue.native.js.map +1 -1
- package/dist/esm/helpers/warnOnce.mjs +5 -4
- package/dist/esm/helpers/warnOnce.mjs.map +1 -1
- package/dist/esm/helpers/warnOnce.native.js +6 -4
- package/dist/esm/helpers/warnOnce.native.js.map +1 -1
- package/dist/esm/hooks/useAnimationDriver.mjs +2 -2
- package/dist/esm/hooks/useAnimationDriver.mjs.map +1 -1
- package/dist/esm/hooks/useAnimationDriver.native.js +2 -2
- package/dist/esm/hooks/useAnimationDriver.native.js.map +1 -1
- package/dist/esm/hooks/useComponentState.mjs +41 -82
- package/dist/esm/hooks/useComponentState.mjs.map +1 -1
- package/dist/esm/hooks/useComponentState.native.js +45 -84
- package/dist/esm/hooks/useComponentState.native.js.map +1 -1
- package/dist/esm/hooks/useMedia.mjs +2 -2
- package/dist/esm/hooks/useMedia.mjs.map +1 -1
- package/dist/esm/hooks/useMedia.native.js +2 -2
- package/dist/esm/hooks/useMedia.native.js.map +1 -1
- package/dist/esm/hooks/useStyle.mjs +11 -0
- package/dist/esm/hooks/useStyle.mjs.map +1 -0
- package/dist/esm/hooks/useStyle.native.js +11 -0
- package/dist/esm/hooks/useStyle.native.js.map +1 -0
- package/dist/esm/hooks/useThemeState.mjs +25 -90
- package/dist/esm/hooks/useThemeState.mjs.map +1 -1
- package/dist/esm/hooks/useThemeState.native.js +34 -94
- package/dist/esm/hooks/useThemeState.native.js.map +1 -1
- package/dist/esm/index.js +6 -4
- package/dist/esm/index.mjs +6 -4
- package/dist/esm/index.native.js +6 -4
- package/dist/esm/static-resolve.mjs +3 -3
- package/dist/esm/static-resolve.mjs.map +1 -1
- package/dist/esm/static-resolve.native.js +3 -3
- package/dist/esm/static-resolve.native.js.map +1 -1
- package/dist/esm/style.mjs +58 -0
- package/dist/esm/style.mjs.map +1 -0
- package/dist/esm/style.native.js +63 -0
- package/dist/esm/style.native.js.map +1 -0
- package/dist/esm/styled.mjs +12 -6
- package/dist/esm/styled.mjs.map +1 -1
- package/dist/esm/styled.native.js +12 -6
- package/dist/esm/styled.native.js.map +1 -1
- package/dist/esm/types.mjs +3 -4
- package/dist/esm/types.mjs.map +1 -1
- package/dist/esm/types.native.js +3 -4
- package/dist/esm/types.native.js.map +1 -1
- package/dist/esm/views/TamaguiProvider.mjs +1 -2
- package/dist/esm/views/TamaguiProvider.mjs.map +1 -1
- package/dist/esm/views/TamaguiProvider.native.js +1 -2
- package/dist/esm/views/TamaguiProvider.native.js.map +1 -1
- package/dist/esm/views/Text.mjs +17 -12
- package/dist/esm/views/Text.mjs.map +1 -1
- package/dist/esm/views/Theme.mjs +3 -3
- package/dist/esm/views/Theme.mjs.map +1 -1
- package/dist/esm/views/Theme.native.js +3 -3
- package/dist/esm/views/Theme.native.js.map +1 -1
- package/dist/esm/views/ThemeDebug.mjs +1 -4
- package/dist/esm/views/ThemeDebug.mjs.map +1 -1
- package/package.json +15 -15
- package/src/createComponent.tsx +21 -1
- package/src/createStyledHOC.tsx +4 -2
- package/src/createVariable.ts +0 -10
- package/src/helpers/borderComponents.ts +62 -0
- package/src/helpers/createDesignSystem.ts +0 -2
- package/src/helpers/createStyledContext.tsx +15 -53
- package/src/helpers/formatDiagnostic.ts +9 -9
- package/src/helpers/getCSSStylesAtomic.native.ts +6 -3
- package/src/helpers/getCSSStylesAtomic.ts +192 -207
- package/src/helpers/getCSSStylesAtomicCompiled.ts +13 -1
- package/src/helpers/getDynamicVal.ts +4 -0
- package/src/helpers/getSplitStyles.tsx +2080 -3270
- package/src/helpers/grammarConfig.ts +218 -1
- package/src/helpers/insertStyleRule.tsx +4 -2
- package/src/helpers/log.ts +12 -11
- package/src/helpers/mergeVariants.ts +55 -18
- package/src/helpers/nativeOnlyProps.ts +0 -1
- package/src/helpers/nativeStyleEngine.ts +55 -14
- package/src/helpers/normalizeValueWithProperty.ts +10 -12
- package/src/helpers/parseBorderShorthand.native.ts +23 -45
- package/src/helpers/parseOutlineShorthand.native.ts +9 -40
- package/src/helpers/resolveSafeArea.ts +34 -101
- package/src/helpers/resolveVariantStyle.ts +77 -0
- package/src/helpers/styleFrontend.ts +8 -5
- package/src/helpers/styleStaticConfig.ts +5 -72
- package/src/helpers/styleStaticConfigCore.ts +110 -0
- package/src/helpers/styledDynamic.ts +191 -0
- package/src/helpers/tokenCategories.ts +40 -65
- package/src/helpers/variableValue.ts +20 -15
- package/src/helpers/warnOnce.ts +5 -4
- package/src/hooks/useAnimationDriver.ts +6 -2
- package/src/hooks/useComponentState.ts +55 -183
- package/src/hooks/useMedia.tsx +10 -8
- package/src/hooks/useStyle.ts +10 -0
- package/src/hooks/useThemeState.ts +51 -264
- package/src/index.ts +6 -6
- package/src/internalRuntimeTypes.ts +1 -0
- package/src/static-resolve.ts +7 -4
- package/src/style.ts +97 -0
- package/src/styled.tsx +39 -68
- package/src/types.tsx +105 -169
- package/src/views/TamaguiProvider.tsx +0 -2
- package/src/views/Text.tsx +20 -14
- package/src/views/Theme.tsx +13 -9
- package/src/views/ThemeDebug.tsx +0 -1
- package/types/createComponent.d.ts.map +1 -1
- package/types/createStyledHOC.d.ts +1 -1
- package/types/createStyledHOC.d.ts.map +1 -1
- package/types/createVariable.d.ts +0 -2
- package/types/createVariable.d.ts.map +1 -1
- package/types/helpers/borderComponents.d.ts +10 -0
- package/types/helpers/borderComponents.d.ts.map +1 -0
- package/types/helpers/createDesignSystem.d.ts.map +1 -1
- package/types/helpers/createStyledContext.d.ts.map +1 -1
- package/types/helpers/getCSSStylesAtomic.d.ts +20 -19
- package/types/helpers/getCSSStylesAtomic.d.ts.map +1 -1
- package/types/helpers/getCSSStylesAtomic.native.d.ts +5 -0
- package/types/helpers/getCSSStylesAtomic.native.d.ts.map +1 -1
- package/types/helpers/getCSSStylesAtomicCompiled.d.ts +6 -1
- package/types/helpers/getCSSStylesAtomicCompiled.d.ts.map +1 -1
- package/types/helpers/getDynamicVal.d.ts.map +1 -1
- package/types/helpers/getSplitStyles.d.ts +3 -5
- package/types/helpers/getSplitStyles.d.ts.map +1 -1
- package/types/helpers/grammarConfig.d.ts +25 -2
- package/types/helpers/grammarConfig.d.ts.map +1 -1
- package/types/helpers/insertStyleRule.d.ts +1 -0
- package/types/helpers/insertStyleRule.d.ts.map +1 -1
- package/types/helpers/log.d.ts.map +1 -1
- package/types/helpers/mergeVariants.d.ts.map +1 -1
- package/types/helpers/nativeOnlyProps.d.ts +0 -1
- package/types/helpers/nativeOnlyProps.d.ts.map +1 -1
- package/types/helpers/nativeStyleEngine.d.ts +6 -0
- package/types/helpers/nativeStyleEngine.d.ts.map +1 -1
- package/types/helpers/normalizeValueWithProperty.d.ts.map +1 -1
- package/types/helpers/parseBorderShorthand.native.d.ts +1 -0
- package/types/helpers/parseBorderShorthand.native.d.ts.map +1 -1
- package/types/helpers/parseOutlineShorthand.native.d.ts.map +1 -1
- package/types/helpers/resolveSafeArea.d.ts +0 -1
- package/types/helpers/resolveSafeArea.d.ts.map +1 -1
- package/types/helpers/resolveVariantStyle.d.ts +3 -0
- package/types/helpers/resolveVariantStyle.d.ts.map +1 -0
- package/types/helpers/styleFrontend.d.ts +3 -5
- package/types/helpers/styleFrontend.d.ts.map +1 -1
- package/types/helpers/styleStaticConfig.d.ts +4 -9
- package/types/helpers/styleStaticConfig.d.ts.map +1 -1
- package/types/helpers/styleStaticConfigCore.d.ts +4 -0
- package/types/helpers/styleStaticConfigCore.d.ts.map +1 -0
- package/types/helpers/styledDynamic.d.ts +18 -0
- package/types/helpers/styledDynamic.d.ts.map +1 -0
- package/types/helpers/tokenCategories.d.ts +0 -1
- package/types/helpers/tokenCategories.d.ts.map +1 -1
- package/types/helpers/variableValue.d.ts.map +1 -1
- package/types/helpers/warnOnce.d.ts.map +1 -1
- package/types/helpers/webPropsToSkip.native.d.ts +68 -68
- package/types/hooks/useAnimationDriver.d.ts.map +1 -1
- package/types/hooks/useComponentState.d.ts.map +1 -1
- package/types/hooks/useMedia.d.ts.map +1 -1
- package/types/hooks/useStyle.d.ts +4 -0
- package/types/hooks/useStyle.d.ts.map +1 -0
- package/types/hooks/useThemeState.d.ts +1 -11
- package/types/hooks/useThemeState.d.ts.map +1 -1
- package/types/index.d.ts +6 -4
- package/types/index.d.ts.map +1 -1
- package/types/internalRuntimeTypes.d.ts +1 -1
- package/types/internalRuntimeTypes.d.ts.map +1 -1
- package/types/static-resolve.d.ts.map +1 -1
- package/types/style.d.ts +18 -0
- package/types/style.d.ts.map +1 -0
- package/types/styled.d.ts +10 -10
- package/types/styled.d.ts.map +1 -1
- package/types/types.d.ts +74 -49
- package/types/types.d.ts.map +1 -1
- package/types/views/TamaguiProvider.d.ts +1 -1
- package/types/views/TamaguiProvider.d.ts.map +1 -1
- package/types/views/Text.d.ts.map +1 -1
- package/types/views/Theme.d.ts.map +1 -1
- package/types/views/ThemeDebug.d.ts.map +1 -1
- package/dist/cjs/helpers/directStyleCSS.cjs +0 -345
- package/dist/cjs/helpers/directStyleCSS.native.js.map +0 -1
- package/dist/cjs/helpers/directStyleCSSCompiled.cjs +0 -40
- package/dist/cjs/helpers/directStyleCSSCompiled.native.cjs +0 -46
- package/dist/cjs/helpers/directStyleCSSCompiled.native.js +0 -48
- package/dist/cjs/helpers/directStyleCSSCompiled.native.js.map +0 -1
- package/dist/cjs/helpers/getVariantExtras.cjs +0 -91
- package/dist/cjs/helpers/getVariantExtras.native.cjs +0 -94
- package/dist/cjs/helpers/getVariantExtras.native.js +0 -96
- package/dist/cjs/helpers/getVariantExtras.native.js.map +0 -1
- package/dist/cjs/helpers/variantResolvers.cjs +0 -87
- package/dist/cjs/helpers/variantResolvers.native.cjs +0 -140
- package/dist/cjs/helpers/variantResolvers.native.js +0 -142
- package/dist/cjs/helpers/variantResolvers.native.js.map +0 -1
- package/dist/esm/helpers/directStyleCSS.mjs +0 -317
- package/dist/esm/helpers/directStyleCSS.mjs.map +0 -1
- package/dist/esm/helpers/directStyleCSS.native.js +0 -1
- package/dist/esm/helpers/directStyleCSSCompiled.mjs +0 -11
- package/dist/esm/helpers/directStyleCSSCompiled.mjs.map +0 -1
- package/dist/esm/helpers/directStyleCSSCompiled.native.js +0 -15
- package/dist/esm/helpers/directStyleCSSCompiled.native.js.map +0 -1
- package/dist/esm/helpers/getVariantExtras.mjs +0 -69
- package/dist/esm/helpers/getVariantExtras.mjs.map +0 -1
- package/dist/esm/helpers/getVariantExtras.native.js +0 -70
- package/dist/esm/helpers/getVariantExtras.native.js.map +0 -1
- package/dist/esm/helpers/variantResolvers.mjs +0 -65
- package/dist/esm/helpers/variantResolvers.mjs.map +0 -1
- package/dist/esm/helpers/variantResolvers.native.js +0 -116
- package/dist/esm/helpers/variantResolvers.native.js.map +0 -1
- package/src/helpers/directStyleCSS.native.ts +0 -1
- package/src/helpers/directStyleCSS.ts +0 -513
- package/src/helpers/directStyleCSSCompiled.ts +0 -32
- package/src/helpers/getVariantExtras.tsx +0 -95
- package/src/helpers/variantResolvers.ts +0 -121
- package/types/helpers/directStyleCSS.d.ts +0 -28
- package/types/helpers/directStyleCSS.d.ts.map +0 -1
- package/types/helpers/directStyleCSS.native.d.ts +0 -2
- package/types/helpers/directStyleCSS.native.d.ts.map +0 -1
- package/types/helpers/directStyleCSSCompiled.d.ts +0 -10
- package/types/helpers/directStyleCSSCompiled.d.ts.map +0 -1
- package/types/helpers/getVariantExtras.d.ts +0 -4
- package/types/helpers/getVariantExtras.d.ts.map +0 -1
- package/types/helpers/variantResolvers.d.ts +0 -9
- package/types/helpers/variantResolvers.d.ts.map +0 -1
|
@@ -1,12 +1,26 @@
|
|
|
1
|
+
import { platformMatches } from '@tamagui/constants'
|
|
1
2
|
import { simpleHash } from '@tamagui/helpers'
|
|
2
3
|
import {
|
|
4
|
+
canonicalStateModifierNames,
|
|
3
5
|
compileModifierVocabulary,
|
|
4
6
|
configRevisionSymbol,
|
|
7
|
+
isContainerSizeQueryText,
|
|
8
|
+
modifierKindMedia,
|
|
9
|
+
modifierKindPlatform,
|
|
10
|
+
modifierKindState,
|
|
11
|
+
parseFlatValue,
|
|
12
|
+
stateModifierSelectors,
|
|
5
13
|
type CompiledModifierVocabulary,
|
|
6
14
|
} from '@tamagui/style-grammar/runtime'
|
|
7
15
|
|
|
8
|
-
import type { TamaguiInternalConfig } from '../types'
|
|
16
|
+
import type { StaticConfig, TamaguiInternalConfig } from '../types'
|
|
17
|
+
import { classifyBorderComponents, splitComponents } from './borderComponents'
|
|
9
18
|
import { mediaObjectToString } from './mediaObjectToString'
|
|
19
|
+
import { getTokenCategoryForProperty, type RuntimeTokenCategory } from './tokenCategories'
|
|
20
|
+
import { expandSafeAreaValue } from './resolveSafeArea'
|
|
21
|
+
import { resolveSafeAreaVariable } from './resolveSafeAreaVariable'
|
|
22
|
+
import { resolveStyleStaticConfig } from './styleStaticConfigCore'
|
|
23
|
+
import type { StyleStaticConfig } from './styleStaticConfig'
|
|
10
24
|
|
|
11
25
|
export type ConfigRevisionPart =
|
|
12
26
|
| 'media'
|
|
@@ -27,9 +41,37 @@ export interface ConfigRevisionState {
|
|
|
27
41
|
revision: number
|
|
28
42
|
modifiers: CompiledModifierVocabulary
|
|
29
43
|
mediaQueries: Readonly<Record<string, string>>
|
|
44
|
+
resolveCondition(name: string): ConditionModifier | null
|
|
45
|
+
tokenCategory(property: string): RuntimeTokenCategory | undefined
|
|
46
|
+
expandSafeArea: typeof expandSafeAreaValue
|
|
47
|
+
safeAreaVariable: typeof resolveSafeAreaVariable
|
|
48
|
+
parseFlatValue: typeof parseFlatValue
|
|
49
|
+
styleStaticConfig(
|
|
50
|
+
staticConfig: StaticConfig,
|
|
51
|
+
conf: TamaguiInternalConfig
|
|
52
|
+
): StyleStaticConfig
|
|
53
|
+
propertyKind(property: string): number
|
|
54
|
+
compositeValue(
|
|
55
|
+
property: string,
|
|
56
|
+
raw: string,
|
|
57
|
+
context: any,
|
|
58
|
+
resolve: (context: any, property: string, raw: string) => any
|
|
59
|
+
): string | undefined
|
|
60
|
+
normalizeTransition(value: string): string
|
|
61
|
+
embeddedTokens(value: string, resolve: (token: string) => any): string
|
|
30
62
|
snapshot?: ConfigRevisionSnapshot
|
|
31
63
|
}
|
|
32
64
|
|
|
65
|
+
export type ConditionModifier = [
|
|
66
|
+
name: string,
|
|
67
|
+
kind: number,
|
|
68
|
+
rank: number,
|
|
69
|
+
selectorOrQuery?: string,
|
|
70
|
+
groupOrSize?: string,
|
|
71
|
+
containerName?: string,
|
|
72
|
+
platformActive?: boolean,
|
|
73
|
+
]
|
|
74
|
+
|
|
33
75
|
type ConfigWithRevision = TamaguiInternalConfig & {
|
|
34
76
|
[configRevisionSymbol]?: ConfigRevisionState
|
|
35
77
|
}
|
|
@@ -64,10 +106,185 @@ export function prepareConfigRevision(
|
|
|
64
106
|
for (const name of mediaNames) {
|
|
65
107
|
mediaQueries[name] = mediaObjectToString(media[name])
|
|
66
108
|
}
|
|
109
|
+
const conditionModifiers = Object.create(null) as Record<
|
|
110
|
+
string,
|
|
111
|
+
ConditionModifier | null
|
|
112
|
+
>
|
|
113
|
+
for (const name in modifiers) {
|
|
114
|
+
const code = modifiers[name]
|
|
115
|
+
const kind = code & 7
|
|
116
|
+
const rank = code >> 3
|
|
117
|
+
conditionModifiers[name] =
|
|
118
|
+
kind === modifierKindState
|
|
119
|
+
? [canonicalStateModifierNames[rank], kind, rank, stateModifierSelectors[rank]]
|
|
120
|
+
: kind === modifierKindMedia
|
|
121
|
+
? [name, kind, rank, mediaQueries[name]]
|
|
122
|
+
: kind === modifierKindPlatform
|
|
123
|
+
? [name, kind, rank, undefined, undefined, undefined, platformMatches(name)]
|
|
124
|
+
: [name, kind, rank]
|
|
125
|
+
}
|
|
126
|
+
const resolveCondition = (authored: string): ConditionModifier | null => {
|
|
127
|
+
const cached = conditionModifiers[authored]
|
|
128
|
+
if (cached !== undefined) return cached
|
|
129
|
+
let result: ConditionModifier | null = null
|
|
130
|
+
if (authored.startsWith('group-')) {
|
|
131
|
+
const slash = authored.indexOf('/')
|
|
132
|
+
const state = authored.slice(6, slash === -1 ? undefined : slash)
|
|
133
|
+
const code = modifiers[state] || 0
|
|
134
|
+
const rank = code >> 3
|
|
135
|
+
const groupName = slash === -1 ? 'true' : authored.slice(slash + 1)
|
|
136
|
+
if (
|
|
137
|
+
(code & 7) === modifierKindState &&
|
|
138
|
+
rank !== 6 &&
|
|
139
|
+
rank !== 7 &&
|
|
140
|
+
(slash === -1 || /^[\w-]+$/.test(groupName))
|
|
141
|
+
) {
|
|
142
|
+
result = [
|
|
143
|
+
`group-${canonicalStateModifierNames[rank]}${slash === -1 ? '' : authored.slice(slash)}`,
|
|
144
|
+
5,
|
|
145
|
+
rank,
|
|
146
|
+
stateModifierSelectors[rank],
|
|
147
|
+
groupName,
|
|
148
|
+
canonicalStateModifierNames[rank],
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
} else if (authored.charCodeAt(0) === 64) {
|
|
152
|
+
const slash = authored.indexOf('/')
|
|
153
|
+
const size = authored.slice(1, slash === -1 ? undefined : slash)
|
|
154
|
+
const containerName = slash === -1 ? '' : authored.slice(slash + 1)
|
|
155
|
+
const code = modifiers[size] || 0
|
|
156
|
+
const query = mediaQueries[size]
|
|
157
|
+
if (
|
|
158
|
+
/^[\w-]+$/.test(size) &&
|
|
159
|
+
(slash === -1 || /^[\w-]+$/.test(containerName)) &&
|
|
160
|
+
(code & 7) === modifierKindMedia &&
|
|
161
|
+
isContainerSizeQueryText(query)
|
|
162
|
+
) {
|
|
163
|
+
result = [authored, 6, code >> 3, query, size, containerName]
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return (conditionModifiers[authored] = result)
|
|
167
|
+
}
|
|
168
|
+
const propertyKinds: Record<string, number> = {
|
|
169
|
+
shadowColor: 1,
|
|
170
|
+
shadowOffset: 2,
|
|
171
|
+
shadowOpacity: 3,
|
|
172
|
+
shadowRadius: 4,
|
|
173
|
+
matrix: 5,
|
|
174
|
+
perspective: 5,
|
|
175
|
+
rotateX: 5,
|
|
176
|
+
rotateY: 5,
|
|
177
|
+
rotateZ: 5,
|
|
178
|
+
scaleZ: 5,
|
|
179
|
+
skewX: 5,
|
|
180
|
+
skewY: 5,
|
|
181
|
+
textShadowColor: 6,
|
|
182
|
+
textShadowOffset: 6,
|
|
183
|
+
textShadowRadius: 6,
|
|
184
|
+
border: 7,
|
|
185
|
+
borderTop: 7,
|
|
186
|
+
borderRight: 7,
|
|
187
|
+
borderBottom: 7,
|
|
188
|
+
borderLeft: 7,
|
|
189
|
+
borderBlock: 7,
|
|
190
|
+
borderInline: 7,
|
|
191
|
+
outline: 7,
|
|
192
|
+
padding: 8,
|
|
193
|
+
paddingBlock: 8,
|
|
194
|
+
paddingInline: 8,
|
|
195
|
+
margin: 8,
|
|
196
|
+
marginBlock: 8,
|
|
197
|
+
marginInline: 8,
|
|
198
|
+
inset: 8,
|
|
199
|
+
insetBlock: 8,
|
|
200
|
+
insetInline: 8,
|
|
201
|
+
borderRadius: 8,
|
|
202
|
+
}
|
|
203
|
+
const propertyKind = (property: string) => propertyKinds[property] || 0
|
|
204
|
+
// transition strings are re-normalized on every render of every animated
|
|
205
|
+
// element; the result only depends on this revision's shorthands
|
|
206
|
+
const normalizedTransitions = new Map<string, string>()
|
|
67
207
|
const next: ConfigRevisionState = {
|
|
68
208
|
revision: captured.revision,
|
|
69
209
|
modifiers,
|
|
70
210
|
mediaQueries,
|
|
211
|
+
resolveCondition,
|
|
212
|
+
tokenCategory: getTokenCategoryForProperty,
|
|
213
|
+
expandSafeArea: expandSafeAreaValue,
|
|
214
|
+
safeAreaVariable: resolveSafeAreaVariable,
|
|
215
|
+
parseFlatValue,
|
|
216
|
+
styleStaticConfig: (staticConfig, conf) =>
|
|
217
|
+
resolveStyleStaticConfig(staticConfig, conf, captured.revision),
|
|
218
|
+
propertyKind,
|
|
219
|
+
compositeValue: (property, raw, context, resolve) => {
|
|
220
|
+
const kind = propertyKinds[property]
|
|
221
|
+
if (kind < 7) return
|
|
222
|
+
if (kind === 7) {
|
|
223
|
+
const { width, style, color } = classifyBorderComponents(
|
|
224
|
+
raw,
|
|
225
|
+
property === 'outline'
|
|
226
|
+
)
|
|
227
|
+
if (style === 'none' && !color) return 'none'
|
|
228
|
+
const prefix = property === 'outline' ? 'outline' : 'border'
|
|
229
|
+
return [
|
|
230
|
+
width && resolve(context, `${prefix}Width`, width),
|
|
231
|
+
style,
|
|
232
|
+
color && resolve(context, `${prefix}Color`, color),
|
|
233
|
+
]
|
|
234
|
+
.filter(Boolean)
|
|
235
|
+
.join(' ')
|
|
236
|
+
}
|
|
237
|
+
// a one-component shorthand (margin="4px") has nothing to distribute;
|
|
238
|
+
// the split is on whitespace, so without any there is nothing to match out
|
|
239
|
+
if (!/\s/.test(raw)) return
|
|
240
|
+
const parts = splitComponents(raw)
|
|
241
|
+
if (parts.length > 1) {
|
|
242
|
+
let value = ''
|
|
243
|
+
for (const part of parts) {
|
|
244
|
+
value += `${value ? ' ' : ''}${resolve(context, property, part)}`
|
|
245
|
+
}
|
|
246
|
+
return value
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
normalizeTransition: (raw) => {
|
|
250
|
+
const known = normalizedTransitions.get(raw)
|
|
251
|
+
if (known !== undefined) return known
|
|
252
|
+
const out = raw.replace(
|
|
253
|
+
/\/\*[\s\S]*?\*\/|(["'])(?:\\.|(?!\1)[^\\])*\1|[A-Za-z_][\w-]*/g,
|
|
254
|
+
(authored, quote, offset) => {
|
|
255
|
+
if (
|
|
256
|
+
quote ||
|
|
257
|
+
raw.charCodeAt(offset + authored.length) === 40 ||
|
|
258
|
+
(raw.charCodeAt(offset - 1) === 45 && raw.charCodeAt(offset - 2) === 45)
|
|
259
|
+
) {
|
|
260
|
+
return authored
|
|
261
|
+
}
|
|
262
|
+
let property = config.shorthands[authored] || authored
|
|
263
|
+
if (property === 'x' || property === 'y') property = 'translate'
|
|
264
|
+
else if (property === 'scaleX' || property === 'scaleY') property = 'scale'
|
|
265
|
+
else if (propertyKind(property) === 5) property = 'transform'
|
|
266
|
+
return property.replace(/[A-Z]/g, '-$&').toLowerCase()
|
|
267
|
+
}
|
|
268
|
+
)
|
|
269
|
+
if (normalizedTransitions.size > 2048) normalizedTransitions.clear()
|
|
270
|
+
normalizedTransitions.set(raw, out)
|
|
271
|
+
return out
|
|
272
|
+
},
|
|
273
|
+
embeddedTokens: (raw, resolve) =>
|
|
274
|
+
raw.replace(
|
|
275
|
+
/\/\*[\s\S]*?\*\/|(["'])(?:\\.|(?!\1)[^\\])*\1|[$A-Za-z_][\w.$-]*(?:\/\d+)?/g,
|
|
276
|
+
(word, quote, offset) => {
|
|
277
|
+
const before = raw.charCodeAt(offset - 1)
|
|
278
|
+
return quote ||
|
|
279
|
+
(word[0] !== '$' &&
|
|
280
|
+
((before >= 48 && before <= 57) ||
|
|
281
|
+
before === 35 ||
|
|
282
|
+
(before === 45 && raw.charCodeAt(offset - 2) === 45) ||
|
|
283
|
+
raw.charCodeAt(offset + word.length) === 40))
|
|
284
|
+
? word
|
|
285
|
+
: resolve(word)
|
|
286
|
+
}
|
|
287
|
+
),
|
|
71
288
|
}
|
|
72
289
|
|
|
73
290
|
// a getter above may have synchronously mutated and rebuilt this config.
|
|
@@ -15,8 +15,10 @@ const scannedCache = new WeakMap<CSSStyleSheet, string>()
|
|
|
15
15
|
const totalSelectorsInserted = new Map<string, number>()
|
|
16
16
|
const allSelectors: Record<string, string> = {}
|
|
17
17
|
const allRules: Record<string, string> = {}
|
|
18
|
+
const allRuleSets: Record<string, string[]> = {}
|
|
18
19
|
|
|
19
20
|
export const getAllSelectors = () => allSelectors
|
|
21
|
+
export const getRulesForIdentifier = (identifier: string) => allRuleSets[identifier]
|
|
20
22
|
|
|
21
23
|
// updateRules is the only writer, so one flag there covers every change
|
|
22
24
|
let sortedRules: string[] = []
|
|
@@ -341,6 +343,7 @@ export function stopAccumulatingRules() {
|
|
|
341
343
|
export function updateRules(identifier: string, rules: string[]) {
|
|
342
344
|
if (!process.env.TAMAGUI_DID_OUTPUT_CSS && trackAllRules) {
|
|
343
345
|
allRules[identifier] = rules.join(' ')
|
|
346
|
+
allRuleSets[identifier] = rules
|
|
344
347
|
sortedRulesStale = true
|
|
345
348
|
}
|
|
346
349
|
return true
|
|
@@ -396,7 +399,7 @@ export function insertStyleRules(rulesToInsert: RulesToInsert) {
|
|
|
396
399
|
sheet.insertRule(rule, sheet.cssRules.length)
|
|
397
400
|
}
|
|
398
401
|
} catch (err) {
|
|
399
|
-
if (process.env.NODE_ENV === '
|
|
402
|
+
if (process.env.NODE_ENV === 'development') {
|
|
400
403
|
const rule = rules[0] || ''
|
|
401
404
|
const selectorEnd = rule.indexOf('{')
|
|
402
405
|
const owner =
|
|
@@ -418,7 +421,6 @@ export function insertStyleRules(rulesToInsert: RulesToInsert) {
|
|
|
418
421
|
)
|
|
419
422
|
)
|
|
420
423
|
}
|
|
421
|
-
// in dev throw to show error clearly
|
|
422
424
|
}
|
|
423
425
|
}
|
|
424
426
|
}
|
package/src/helpers/log.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { _disableMediaTouch } from '../hooks/useMedia'
|
|
2
2
|
|
|
3
3
|
export function log(...args: any[]) {
|
|
4
|
-
if (process.env.NODE_ENV === '
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
if (process.env.NODE_ENV === 'development') {
|
|
5
|
+
_disableMediaTouch(true)
|
|
6
|
+
try {
|
|
7
|
+
if (process.env.TAMAGUI_TARGET === 'web') {
|
|
8
|
+
return console.info(...args)
|
|
9
|
+
}
|
|
10
|
+
// react native doesn't log in the cli unless it's log
|
|
11
|
+
return console.log(...args)
|
|
12
|
+
} catch (err) {
|
|
13
|
+
console.error(err)
|
|
14
|
+
} finally {
|
|
15
|
+
_disableMediaTouch(false)
|
|
9
16
|
}
|
|
10
|
-
// react native doesn't log in the cli unless it's log
|
|
11
|
-
return console.log(...args)
|
|
12
|
-
} catch (err) {
|
|
13
|
-
console.error(err)
|
|
14
|
-
} finally {
|
|
15
|
-
_disableMediaTouch(false)
|
|
16
17
|
}
|
|
17
18
|
}
|
|
@@ -1,23 +1,59 @@
|
|
|
1
|
-
import { mergeFlatValues } from '@tamagui/style-grammar/runtime'
|
|
2
|
-
|
|
3
1
|
import type { GenericVariantDefinitions } from '../types'
|
|
2
|
+
import { styledDynamicSymbol } from '../types'
|
|
4
3
|
import { isPlainObject } from './isObj'
|
|
5
4
|
|
|
5
|
+
function mergeVariantValues(earlier: unknown, later: unknown): unknown {
|
|
6
|
+
if (typeof earlier !== 'string' || typeof later !== 'string') return later
|
|
7
|
+
if (!earlier.includes(':') && !later.includes(':')) return later
|
|
8
|
+
|
|
9
|
+
const getSlot = (token: string, colon: number) => {
|
|
10
|
+
const slot: string[] = []
|
|
11
|
+
for (let modifier of token.slice(0, colon).split(':')) {
|
|
12
|
+
if (modifier === 'active') modifier = 'press'
|
|
13
|
+
else if (modifier.startsWith('group-active')) {
|
|
14
|
+
modifier = modifier.replace('group-active', 'group-press')
|
|
15
|
+
}
|
|
16
|
+
let index = 0
|
|
17
|
+
while (index < slot.length && slot[index] < modifier) index++
|
|
18
|
+
if (slot[index] !== modifier) slot.splice(index, 0, modifier)
|
|
19
|
+
}
|
|
20
|
+
return slot.join(':')
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const clauses = new Map<string, string>()
|
|
24
|
+
let base: string | undefined
|
|
25
|
+
const add = (source: string, reject: boolean) => {
|
|
26
|
+
for (const token of source.trim().split(/\s+/)) {
|
|
27
|
+
const colon = token.lastIndexOf(':')
|
|
28
|
+
if (colon === -1) base = token
|
|
29
|
+
else {
|
|
30
|
+
if (colon === token.length - 1) {
|
|
31
|
+
if (reject) return false
|
|
32
|
+
continue
|
|
33
|
+
}
|
|
34
|
+
const slot = getSlot(token, colon)
|
|
35
|
+
clauses.delete(slot)
|
|
36
|
+
clauses.set(slot, token)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return true
|
|
40
|
+
}
|
|
41
|
+
add(earlier, false)
|
|
42
|
+
if (!add(later, true)) return later
|
|
43
|
+
return [base, ...clauses.values()].filter(Boolean).join(' ')
|
|
44
|
+
}
|
|
45
|
+
|
|
6
46
|
// same key ordering as mergeProps (parent keys first, then ours), but a key
|
|
7
47
|
// present on both sides merges its clauses instead of being replaced outright
|
|
8
48
|
function mergeStyleBranch(
|
|
9
49
|
parentBranch: Record<string, any>,
|
|
10
50
|
ourBranch: Record<string, any>
|
|
11
51
|
) {
|
|
12
|
-
const out: Record<string, any> = {}
|
|
13
|
-
for (const key in parentBranch) {
|
|
14
|
-
if (key in ourBranch) continue
|
|
15
|
-
out[key] = parentBranch[key]
|
|
16
|
-
}
|
|
52
|
+
const out: Record<string, any> = { ...parentBranch }
|
|
17
53
|
for (const key in ourBranch) {
|
|
18
54
|
out[key] =
|
|
19
55
|
key in parentBranch
|
|
20
|
-
?
|
|
56
|
+
? mergeVariantValues(parentBranch[key], ourBranch[key])
|
|
21
57
|
: ourBranch[key]
|
|
22
58
|
}
|
|
23
59
|
return out
|
|
@@ -35,28 +71,29 @@ export const mergeVariants = (
|
|
|
35
71
|
return ourVariants || {}
|
|
36
72
|
}
|
|
37
73
|
|
|
38
|
-
const variants: Record<string, any> = {}
|
|
74
|
+
const variants: Record<string, any> = { ...parentVariants }
|
|
39
75
|
|
|
40
76
|
for (const key in ourVariants) {
|
|
41
77
|
const parentVariant = parentVariants?.[key]
|
|
42
78
|
const ourVariant = ourVariants[key]
|
|
43
|
-
if (
|
|
79
|
+
if (
|
|
80
|
+
!isPlainObject(parentVariant) ||
|
|
81
|
+
!isPlainObject(ourVariant) ||
|
|
82
|
+
// styled.dynamic carriers are atomic: a child redefinition replaces the
|
|
83
|
+
// parent's outright, never merges (spreading a bare marker's brand into
|
|
84
|
+
// an enumerated child would turn it into a consumed no-op)
|
|
85
|
+
styledDynamicSymbol in parentVariant ||
|
|
86
|
+
styledDynamicSymbol in ourVariant
|
|
87
|
+
) {
|
|
44
88
|
variants[key] = ourVariant
|
|
45
89
|
} else {
|
|
46
90
|
if (level === 0) {
|
|
47
91
|
variants[key] = mergeVariants(parentVariant, ourVariant, level + 1)
|
|
48
92
|
} else {
|
|
49
|
-
// A branch is a style object. Merge per property, and per clause within
|
|
50
|
-
// a property: a child restating `borderColor="green"` overrides the
|
|
51
|
-
// parent's base without erasing the parent's `press:transparent`, which
|
|
52
|
-
// a plain key-level override silently dropped.
|
|
53
93
|
variants[key] = mergeStyleBranch(parentVariant, ourVariant)
|
|
54
94
|
}
|
|
55
95
|
}
|
|
56
96
|
}
|
|
57
97
|
|
|
58
|
-
return
|
|
59
|
-
...parentVariants,
|
|
60
|
-
...variants,
|
|
61
|
-
}
|
|
98
|
+
return variants
|
|
62
99
|
}
|
|
@@ -14,6 +14,18 @@
|
|
|
14
14
|
|
|
15
15
|
import { getVariableValue } from '../createVariable'
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* CSS-shaped Input color styles lower back to React Native TextInput props.
|
|
19
|
+
* Keeping this table beside native color processing makes the runtime and
|
|
20
|
+
* compiler use one RN compatibility boundary after token resolution.
|
|
21
|
+
*/
|
|
22
|
+
export const nativeTextInputColorProps: Readonly<Record<string, string>> = {
|
|
23
|
+
placeholderTextColor: 'placeholderTextColor',
|
|
24
|
+
selectionColor: 'selectionColor',
|
|
25
|
+
cursorColor: 'cursorColor',
|
|
26
|
+
selectionHandleColor: 'selectionHandleColor',
|
|
27
|
+
}
|
|
28
|
+
|
|
17
29
|
export interface NativeStyleEngineLinkHandle {
|
|
18
30
|
id: number
|
|
19
31
|
unlink: () => void
|
|
@@ -60,9 +72,17 @@ interface CompiledMappingLink {
|
|
|
60
72
|
stateThemes: Map<string, object>
|
|
61
73
|
}
|
|
62
74
|
|
|
75
|
+
interface ResolvedMappingState {
|
|
76
|
+
theme: object
|
|
77
|
+
/** raw resolved values, what React renders through RN's own style normalizer */
|
|
78
|
+
renderProps: Record<string, unknown>
|
|
79
|
+
/** engine transport form after processStyleColors, never handed back to React */
|
|
80
|
+
nativeProps: Record<string, unknown>
|
|
81
|
+
}
|
|
82
|
+
|
|
63
83
|
interface CompiledMapping {
|
|
64
84
|
mapping: NativeStyleThemeMapping
|
|
65
|
-
states: Map<string,
|
|
85
|
+
states: Map<string, ResolvedMappingState>
|
|
66
86
|
links: Set<CompiledMappingLink>
|
|
67
87
|
}
|
|
68
88
|
|
|
@@ -100,24 +120,27 @@ function resolveCompiledMapping(
|
|
|
100
120
|
compiled: CompiledMapping,
|
|
101
121
|
stateName: string,
|
|
102
122
|
theme: Record<string, unknown>
|
|
103
|
-
):
|
|
123
|
+
): ResolvedMappingState {
|
|
104
124
|
const cached = compiled.states.get(stateName)
|
|
105
|
-
if (cached?.theme === theme) return cached
|
|
125
|
+
if (cached?.theme === theme) return cached
|
|
106
126
|
|
|
107
|
-
const
|
|
127
|
+
const renderProps: Record<string, unknown> = {}
|
|
108
128
|
for (const styleKey in compiled.mapping) {
|
|
109
129
|
const value = theme[compiled.mapping[styleKey]]
|
|
110
|
-
|
|
130
|
+
renderProps[styleKey] = value === undefined ? null : getVariableValue(value)
|
|
111
131
|
}
|
|
112
|
-
|
|
132
|
+
// the engine's color form (srgb maps for Fabric's C++ parser) must not flow
|
|
133
|
+
// back through React: RN's JS style normalizer misreads it
|
|
134
|
+
const nativeProps = engine?.processStyleColors(renderProps) ?? renderProps
|
|
113
135
|
if (compiled.states.size >= 10_000) {
|
|
114
136
|
compiled.states.clear()
|
|
115
137
|
for (const link of compiled.links) {
|
|
116
138
|
link.stateThemes.clear()
|
|
117
139
|
}
|
|
118
140
|
}
|
|
119
|
-
|
|
120
|
-
|
|
141
|
+
const resolved: ResolvedMappingState = { theme, renderProps, nativeProps }
|
|
142
|
+
compiled.states.set(stateName, resolved)
|
|
143
|
+
return resolved
|
|
121
144
|
}
|
|
122
145
|
|
|
123
146
|
export function setNativeStyleEngine(next: NativeStyleEngine | null): void {
|
|
@@ -158,7 +181,7 @@ export function updateNativeStyleScope(
|
|
|
158
181
|
compiled,
|
|
159
182
|
stateName,
|
|
160
183
|
theme as Record<string, unknown>
|
|
161
|
-
)
|
|
184
|
+
).nativeProps
|
|
162
185
|
entries.push({ id: link.handle.id, state: stateName, props })
|
|
163
186
|
link.stateThemes.set(stateName, theme)
|
|
164
187
|
}
|
|
@@ -178,7 +201,7 @@ export function resolveNativeStyleMapping(
|
|
|
178
201
|
stateName: string,
|
|
179
202
|
theme: Record<string, unknown>
|
|
180
203
|
): Record<string, unknown> {
|
|
181
|
-
return resolveCompiledMapping(getCompiledMapping(mapping), stateName, theme)
|
|
204
|
+
return resolveCompiledMapping(getCompiledMapping(mapping), stateName, theme).renderProps
|
|
182
205
|
}
|
|
183
206
|
|
|
184
207
|
export function linkNativeStyleMapping(
|
|
@@ -192,7 +215,19 @@ export function linkNativeStyleMapping(
|
|
|
192
215
|
if (!engine) return null
|
|
193
216
|
|
|
194
217
|
const compiled = getCompiledMapping(mapping)
|
|
195
|
-
|
|
218
|
+
// a scope can advance (layout effect) after a concurrent render captured its
|
|
219
|
+
// theme but before that render's host ref links. the engine's link() only
|
|
220
|
+
// stores tables, it never commits, so link against the live scope state and
|
|
221
|
+
// commit that table once to correct the stale React commit.
|
|
222
|
+
const scopeState = scopeStates.get(scopeId)
|
|
223
|
+
const currentStateName = scopeState?.name ?? stateName
|
|
224
|
+
const currentTheme = (scopeState?.theme ?? theme) as Record<string, unknown>
|
|
225
|
+
const stale = currentStateName !== stateName || currentTheme !== theme
|
|
226
|
+
const stateProps = resolveCompiledMapping(
|
|
227
|
+
compiled,
|
|
228
|
+
currentStateName,
|
|
229
|
+
currentTheme
|
|
230
|
+
).nativeProps
|
|
196
231
|
let base = processedBases.get(baseStyle)
|
|
197
232
|
if (!base || base.engine !== engine) {
|
|
198
233
|
base = { engine, props: engine.processStyleColors(baseStyle) }
|
|
@@ -201,14 +236,20 @@ export function linkNativeStyleMapping(
|
|
|
201
236
|
const state: Record<string, Record<string, unknown>> = {}
|
|
202
237
|
const stateThemes = new Map<string, object>()
|
|
203
238
|
for (const [name, cached] of compiled.states) {
|
|
204
|
-
state[name] = cached.
|
|
239
|
+
state[name] = cached.nativeProps
|
|
205
240
|
stateThemes.set(name, cached.theme)
|
|
206
241
|
}
|
|
207
|
-
state[
|
|
208
|
-
stateThemes.set(
|
|
242
|
+
state[currentStateName] = stateProps
|
|
243
|
+
stateThemes.set(currentStateName, currentTheme)
|
|
209
244
|
const handle = engine.link(ref, { base: base.props, state }, scopeId)
|
|
210
245
|
if (!handle) return null
|
|
211
246
|
|
|
247
|
+
if (stale) {
|
|
248
|
+
engine.updateViewStateTables([
|
|
249
|
+
{ id: handle.id, state: currentStateName, props: stateProps },
|
|
250
|
+
])
|
|
251
|
+
}
|
|
252
|
+
|
|
212
253
|
const link: CompiledMappingLink = {
|
|
213
254
|
handle,
|
|
214
255
|
scopeId,
|
|
@@ -8,11 +8,14 @@ import { stylePropsAll, stylePropsUnitless } from '@tamagui/helpers'
|
|
|
8
8
|
|
|
9
9
|
// only doing this on web on native it accepts pixel values
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
// the properties that take a unit: everything normalize can append `px` to.
|
|
12
|
+
// a Set beats a spread object here, which lands in dictionary mode and makes
|
|
13
|
+
// every lookup on this hot path a slow one
|
|
14
|
+
const unitfulProps = new Set(
|
|
15
|
+
[...Object.keys(stylePropsAll), 'translateX', 'translateY'].filter(
|
|
16
|
+
(key) => !stylePropsUnitless[key]
|
|
17
|
+
)
|
|
18
|
+
)
|
|
16
19
|
|
|
17
20
|
// literal "Npx" values (e.g. fontSize="17px"). react native only accepts
|
|
18
21
|
// numbers, so parse them there; web keeps the string and outputs it as css.
|
|
@@ -25,13 +28,8 @@ export function normalizeValueWithProperty(value: any, property = ''): any {
|
|
|
25
28
|
}
|
|
26
29
|
return value
|
|
27
30
|
}
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
(property && !stylePropsAllPlusTransforms[property]) ||
|
|
31
|
-
typeof value === 'boolean'
|
|
32
|
-
) {
|
|
33
|
-
return value
|
|
34
|
-
}
|
|
31
|
+
if (property !== '' && !unitfulProps.has(property)) return value
|
|
32
|
+
if (typeof value === 'boolean') return value
|
|
35
33
|
if (value && typeof value === 'object') {
|
|
36
34
|
if (typeof value.__getValue === 'function') {
|
|
37
35
|
// resolve Animated.Value objects
|