@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.
Files changed (474) hide show
  1. package/dist/cjs/createComponent.cjs +12 -1
  2. package/dist/cjs/createComponent.native.cjs +12 -1
  3. package/dist/cjs/createComponent.native.js +12 -1
  4. package/dist/cjs/createComponent.native.js.map +1 -1
  5. package/dist/cjs/createStyledHOC.cjs +1 -1
  6. package/dist/cjs/createStyledHOC.native.cjs +1 -1
  7. package/dist/cjs/createStyledHOC.native.js +1 -1
  8. package/dist/cjs/createStyledHOC.native.js.map +1 -1
  9. package/dist/cjs/createVariable.cjs +0 -10
  10. package/dist/cjs/createVariable.native.cjs +0 -10
  11. package/dist/cjs/createVariable.native.js +0 -10
  12. package/dist/cjs/createVariable.native.js.map +1 -1
  13. package/dist/cjs/helpers/borderComponents.cjs +62 -0
  14. package/dist/cjs/helpers/borderComponents.native.cjs +82 -0
  15. package/dist/cjs/helpers/borderComponents.native.js +84 -0
  16. package/dist/cjs/helpers/borderComponents.native.js.map +1 -0
  17. package/dist/cjs/helpers/createDesignSystem.cjs +0 -2
  18. package/dist/cjs/helpers/createStyledContext.cjs +10 -18
  19. package/dist/cjs/helpers/createStyledContext.native.cjs +14 -18
  20. package/dist/cjs/helpers/createStyledContext.native.js +14 -18
  21. package/dist/cjs/helpers/createStyledContext.native.js.map +1 -1
  22. package/dist/cjs/helpers/formatDiagnostic.cjs +6 -6
  23. package/dist/cjs/helpers/formatDiagnostic.native.cjs +6 -6
  24. package/dist/cjs/helpers/formatDiagnostic.native.js +6 -6
  25. package/dist/cjs/helpers/formatDiagnostic.native.js.map +1 -1
  26. package/dist/cjs/helpers/getCSSStylesAtomic.cjs +128 -109
  27. package/dist/cjs/helpers/getCSSStylesAtomic.native.cjs +11 -3
  28. package/dist/cjs/helpers/getCSSStylesAtomic.native.js +11 -3
  29. package/dist/cjs/helpers/getCSSStylesAtomic.native.js.map +1 -1
  30. package/dist/cjs/helpers/getCSSStylesAtomicCompiled.cjs +13 -1
  31. package/dist/cjs/helpers/getCSSStylesAtomicCompiled.native.cjs +15 -1
  32. package/dist/cjs/helpers/getCSSStylesAtomicCompiled.native.js +15 -1
  33. package/dist/cjs/helpers/getCSSStylesAtomicCompiled.native.js.map +1 -1
  34. package/dist/cjs/helpers/getDynamicVal.cjs +5 -1
  35. package/dist/cjs/helpers/getDynamicVal.native.cjs +5 -1
  36. package/dist/cjs/helpers/getDynamicVal.native.js +5 -1
  37. package/dist/cjs/helpers/getDynamicVal.native.js.map +1 -1
  38. package/dist/cjs/helpers/getSplitStyles.cjs +1042 -1715
  39. package/dist/cjs/helpers/getSplitStyles.native.cjs +1081 -1887
  40. package/dist/cjs/helpers/getSplitStyles.native.js +1081 -1887
  41. package/dist/cjs/helpers/getSplitStyles.native.js.map +1 -1
  42. package/dist/cjs/helpers/grammarConfig.cjs +163 -1
  43. package/dist/cjs/helpers/grammarConfig.native.cjs +186 -1
  44. package/dist/cjs/helpers/grammarConfig.native.js +186 -1
  45. package/dist/cjs/helpers/grammarConfig.native.js.map +1 -1
  46. package/dist/cjs/helpers/insertStyleRule.cjs +5 -1
  47. package/dist/cjs/helpers/insertStyleRule.native.cjs +7 -1
  48. package/dist/cjs/helpers/insertStyleRule.native.js +7 -1
  49. package/dist/cjs/helpers/insertStyleRule.native.js.map +1 -1
  50. package/dist/cjs/helpers/log.cjs +9 -8
  51. package/dist/cjs/helpers/log.native.cjs +9 -8
  52. package/dist/cjs/helpers/log.native.js +9 -8
  53. package/dist/cjs/helpers/log.native.js.map +1 -1
  54. package/dist/cjs/helpers/mergeVariants.cjs +44 -13
  55. package/dist/cjs/helpers/mergeVariants.native.cjs +79 -14
  56. package/dist/cjs/helpers/mergeVariants.native.js +79 -14
  57. package/dist/cjs/helpers/mergeVariants.native.js.map +1 -1
  58. package/dist/cjs/helpers/nativeOnlyProps.cjs +0 -1
  59. package/dist/cjs/helpers/nativeOnlyProps.native.cjs +0 -1
  60. package/dist/cjs/helpers/nativeOnlyProps.native.js +0 -1
  61. package/dist/cjs/helpers/nativeOnlyProps.native.js.map +1 -1
  62. package/dist/cjs/helpers/nativeStyleEngine.cjs +34 -14
  63. package/dist/cjs/helpers/nativeStyleEngine.native.cjs +36 -14
  64. package/dist/cjs/helpers/nativeStyleEngine.native.js +36 -14
  65. package/dist/cjs/helpers/nativeStyleEngine.native.js.map +1 -1
  66. package/dist/cjs/helpers/normalizeValueWithProperty.cjs +7 -8
  67. package/dist/cjs/helpers/normalizeValueWithProperty.native.cjs +9 -8
  68. package/dist/cjs/helpers/normalizeValueWithProperty.native.js +9 -8
  69. package/dist/cjs/helpers/normalizeValueWithProperty.native.js.map +1 -1
  70. package/dist/cjs/helpers/parseBorderShorthand.native.cjs +25 -56
  71. package/dist/cjs/helpers/parseBorderShorthand.native.js +25 -56
  72. package/dist/cjs/helpers/parseBorderShorthand.native.js.map +1 -1
  73. package/dist/cjs/helpers/parseOutlineShorthand.native.cjs +9 -49
  74. package/dist/cjs/helpers/parseOutlineShorthand.native.js +9 -49
  75. package/dist/cjs/helpers/parseOutlineShorthand.native.js.map +1 -1
  76. package/dist/cjs/helpers/resolveSafeArea.cjs +35 -100
  77. package/dist/cjs/helpers/resolveVariantStyle.cjs +57 -0
  78. package/dist/cjs/helpers/resolveVariantStyle.native.cjs +67 -0
  79. package/dist/cjs/helpers/resolveVariantStyle.native.js +69 -0
  80. package/dist/cjs/helpers/resolveVariantStyle.native.js.map +1 -0
  81. package/dist/cjs/helpers/styleStaticConfig.cjs +1 -50
  82. package/dist/cjs/helpers/styleStaticConfig.native.cjs +1 -51
  83. package/dist/cjs/helpers/styleStaticConfig.native.js +1 -51
  84. package/dist/cjs/helpers/styleStaticConfig.native.js.map +1 -1
  85. package/dist/cjs/helpers/styleStaticConfigCore.cjs +107 -0
  86. package/dist/cjs/helpers/styleStaticConfigCore.native.cjs +127 -0
  87. package/dist/cjs/helpers/styleStaticConfigCore.native.js +129 -0
  88. package/dist/cjs/helpers/styleStaticConfigCore.native.js.map +1 -0
  89. package/dist/cjs/helpers/styledDynamic.cjs +160 -0
  90. package/dist/cjs/helpers/styledDynamic.native.cjs +195 -0
  91. package/dist/cjs/helpers/styledDynamic.native.js +197 -0
  92. package/dist/cjs/helpers/styledDynamic.native.js.map +1 -0
  93. package/dist/cjs/helpers/tokenCategories.cjs +15 -38
  94. package/dist/cjs/helpers/tokenCategories.native.cjs +15 -40
  95. package/dist/cjs/helpers/tokenCategories.native.js +15 -40
  96. package/dist/cjs/helpers/tokenCategories.native.js.map +1 -1
  97. package/dist/cjs/helpers/variableValue.cjs +17 -12
  98. package/dist/cjs/helpers/variableValue.native.cjs +46 -23
  99. package/dist/cjs/helpers/variableValue.native.js +46 -23
  100. package/dist/cjs/helpers/variableValue.native.js.map +1 -1
  101. package/dist/cjs/helpers/warnOnce.cjs +5 -4
  102. package/dist/cjs/helpers/warnOnce.native.cjs +6 -4
  103. package/dist/cjs/helpers/warnOnce.native.js +6 -4
  104. package/dist/cjs/helpers/warnOnce.native.js.map +1 -1
  105. package/dist/cjs/hooks/useAnimationDriver.cjs +2 -2
  106. package/dist/cjs/hooks/useAnimationDriver.native.cjs +2 -2
  107. package/dist/cjs/hooks/useAnimationDriver.native.js +2 -2
  108. package/dist/cjs/hooks/useAnimationDriver.native.js.map +1 -1
  109. package/dist/cjs/hooks/useComponentState.cjs +41 -82
  110. package/dist/cjs/hooks/useComponentState.native.cjs +45 -84
  111. package/dist/cjs/hooks/useComponentState.native.js +45 -84
  112. package/dist/cjs/hooks/useComponentState.native.js.map +1 -1
  113. package/dist/cjs/hooks/useMedia.cjs +2 -2
  114. package/dist/cjs/hooks/useMedia.native.cjs +2 -2
  115. package/dist/cjs/hooks/useMedia.native.js +2 -2
  116. package/dist/cjs/hooks/useMedia.native.js.map +1 -1
  117. package/dist/cjs/{helpers/directStyleCSS.native.js → hooks/useStyle.cjs} +16 -8
  118. package/dist/cjs/{helpers/directStyleCSS.native.cjs → hooks/useStyle.native.cjs} +16 -4
  119. package/dist/cjs/hooks/useStyle.native.js +34 -0
  120. package/dist/cjs/hooks/useStyle.native.js.map +1 -0
  121. package/dist/cjs/hooks/useThemeState.cjs +25 -90
  122. package/dist/cjs/hooks/useThemeState.native.cjs +34 -94
  123. package/dist/cjs/hooks/useThemeState.native.js +34 -94
  124. package/dist/cjs/hooks/useThemeState.native.js.map +1 -1
  125. package/dist/cjs/index.cjs +6 -3
  126. package/dist/cjs/index.native.cjs +6 -3
  127. package/dist/cjs/index.native.js +6 -3
  128. package/dist/cjs/index.native.js.map +1 -1
  129. package/dist/cjs/static-resolve.cjs +2 -2
  130. package/dist/cjs/static-resolve.native.cjs +2 -2
  131. package/dist/cjs/static-resolve.native.js +2 -2
  132. package/dist/cjs/static-resolve.native.js.map +1 -1
  133. package/dist/cjs/style.cjs +91 -0
  134. package/dist/cjs/style.native.cjs +98 -0
  135. package/dist/cjs/style.native.js +100 -0
  136. package/dist/cjs/style.native.js.map +1 -0
  137. package/dist/cjs/styled.cjs +11 -6
  138. package/dist/cjs/styled.native.cjs +11 -6
  139. package/dist/cjs/styled.native.js +11 -6
  140. package/dist/cjs/styled.native.js.map +1 -1
  141. package/dist/cjs/types.cjs +6 -4
  142. package/dist/cjs/types.native.cjs +6 -4
  143. package/dist/cjs/types.native.js +6 -4
  144. package/dist/cjs/types.native.js.map +1 -1
  145. package/dist/cjs/views/TamaguiProvider.cjs +1 -2
  146. package/dist/cjs/views/TamaguiProvider.native.cjs +1 -2
  147. package/dist/cjs/views/TamaguiProvider.native.js +1 -2
  148. package/dist/cjs/views/TamaguiProvider.native.js.map +1 -1
  149. package/dist/cjs/views/Text.cjs +17 -12
  150. package/dist/cjs/views/Text.native.cjs +1 -0
  151. package/dist/cjs/views/Text.native.js +1 -0
  152. package/dist/cjs/views/Text.native.js.map +1 -1
  153. package/dist/cjs/views/Theme.cjs +3 -3
  154. package/dist/cjs/views/Theme.native.cjs +3 -3
  155. package/dist/cjs/views/Theme.native.js +3 -3
  156. package/dist/cjs/views/Theme.native.js.map +1 -1
  157. package/dist/cjs/views/ThemeDebug.cjs +1 -4
  158. package/dist/esm/createComponent.mjs +12 -1
  159. package/dist/esm/createComponent.mjs.map +1 -1
  160. package/dist/esm/createComponent.native.js +12 -1
  161. package/dist/esm/createComponent.native.js.map +1 -1
  162. package/dist/esm/createStyledHOC.mjs +1 -1
  163. package/dist/esm/createStyledHOC.mjs.map +1 -1
  164. package/dist/esm/createStyledHOC.native.js +1 -1
  165. package/dist/esm/createStyledHOC.native.js.map +1 -1
  166. package/dist/esm/createVariable.mjs +1 -9
  167. package/dist/esm/createVariable.mjs.map +1 -1
  168. package/dist/esm/createVariable.native.js +1 -9
  169. package/dist/esm/createVariable.native.js.map +1 -1
  170. package/dist/esm/helpers/borderComponents.mjs +37 -0
  171. package/dist/esm/helpers/borderComponents.mjs.map +1 -0
  172. package/dist/esm/helpers/borderComponents.native.js +55 -0
  173. package/dist/esm/helpers/borderComponents.native.js.map +1 -0
  174. package/dist/esm/helpers/createDesignSystem.mjs +0 -2
  175. package/dist/esm/helpers/createDesignSystem.mjs.map +1 -1
  176. package/dist/esm/helpers/createStyledContext.mjs +10 -18
  177. package/dist/esm/helpers/createStyledContext.mjs.map +1 -1
  178. package/dist/esm/helpers/createStyledContext.native.js +14 -18
  179. package/dist/esm/helpers/createStyledContext.native.js.map +1 -1
  180. package/dist/esm/helpers/formatDiagnostic.mjs +6 -6
  181. package/dist/esm/helpers/formatDiagnostic.mjs.map +1 -1
  182. package/dist/esm/helpers/formatDiagnostic.native.js +6 -6
  183. package/dist/esm/helpers/formatDiagnostic.native.js.map +1 -1
  184. package/dist/esm/helpers/getCSSStylesAtomic.mjs +126 -109
  185. package/dist/esm/helpers/getCSSStylesAtomic.mjs.map +1 -1
  186. package/dist/esm/helpers/getCSSStylesAtomic.native.js +7 -4
  187. package/dist/esm/helpers/getCSSStylesAtomic.native.js.map +1 -1
  188. package/dist/esm/helpers/getCSSStylesAtomicCompiled.mjs +8 -1
  189. package/dist/esm/helpers/getCSSStylesAtomicCompiled.mjs.map +1 -1
  190. package/dist/esm/helpers/getCSSStylesAtomicCompiled.native.js +10 -1
  191. package/dist/esm/helpers/getCSSStylesAtomicCompiled.native.js.map +1 -1
  192. package/dist/esm/helpers/getDynamicVal.mjs +5 -1
  193. package/dist/esm/helpers/getDynamicVal.mjs.map +1 -1
  194. package/dist/esm/helpers/getDynamicVal.native.js +5 -1
  195. package/dist/esm/helpers/getDynamicVal.native.js.map +1 -1
  196. package/dist/esm/helpers/getSplitStyles.mjs +1034 -1705
  197. package/dist/esm/helpers/getSplitStyles.mjs.map +1 -1
  198. package/dist/esm/helpers/getSplitStyles.native.js +1071 -1871
  199. package/dist/esm/helpers/getSplitStyles.native.js.map +1 -1
  200. package/dist/esm/helpers/grammarConfig.mjs +164 -2
  201. package/dist/esm/helpers/grammarConfig.mjs.map +1 -1
  202. package/dist/esm/helpers/grammarConfig.native.js +187 -2
  203. package/dist/esm/helpers/grammarConfig.native.js.map +1 -1
  204. package/dist/esm/helpers/insertStyleRule.mjs +5 -2
  205. package/dist/esm/helpers/insertStyleRule.mjs.map +1 -1
  206. package/dist/esm/helpers/insertStyleRule.native.js +7 -2
  207. package/dist/esm/helpers/insertStyleRule.native.js.map +1 -1
  208. package/dist/esm/helpers/log.mjs +9 -8
  209. package/dist/esm/helpers/log.mjs.map +1 -1
  210. package/dist/esm/helpers/log.native.js +9 -8
  211. package/dist/esm/helpers/log.native.js.map +1 -1
  212. package/dist/esm/helpers/mergeVariants.mjs +44 -13
  213. package/dist/esm/helpers/mergeVariants.mjs.map +1 -1
  214. package/dist/esm/helpers/mergeVariants.native.js +79 -14
  215. package/dist/esm/helpers/mergeVariants.native.js.map +1 -1
  216. package/dist/esm/helpers/nativeOnlyProps.mjs +0 -1
  217. package/dist/esm/helpers/nativeOnlyProps.mjs.map +1 -1
  218. package/dist/esm/helpers/nativeOnlyProps.native.js +0 -1
  219. package/dist/esm/helpers/nativeOnlyProps.native.js.map +1 -1
  220. package/dist/esm/helpers/nativeStyleEngine.mjs +34 -15
  221. package/dist/esm/helpers/nativeStyleEngine.mjs.map +1 -1
  222. package/dist/esm/helpers/nativeStyleEngine.native.js +36 -15
  223. package/dist/esm/helpers/nativeStyleEngine.native.js.map +1 -1
  224. package/dist/esm/helpers/normalizeValueWithProperty.mjs +7 -8
  225. package/dist/esm/helpers/normalizeValueWithProperty.mjs.map +1 -1
  226. package/dist/esm/helpers/normalizeValueWithProperty.native.js +9 -8
  227. package/dist/esm/helpers/normalizeValueWithProperty.native.js.map +1 -1
  228. package/dist/esm/helpers/parseBorderShorthand.native.js +23 -56
  229. package/dist/esm/helpers/parseBorderShorthand.native.js.map +1 -1
  230. package/dist/esm/helpers/parseOutlineShorthand.native.js +10 -49
  231. package/dist/esm/helpers/parseOutlineShorthand.native.js.map +1 -1
  232. package/dist/esm/helpers/resolveSafeArea.mjs +35 -97
  233. package/dist/esm/helpers/resolveSafeArea.mjs.map +1 -1
  234. package/dist/esm/helpers/resolveVariantStyle.mjs +38 -0
  235. package/dist/esm/helpers/resolveVariantStyle.mjs.map +1 -0
  236. package/dist/esm/helpers/resolveVariantStyle.native.js +46 -0
  237. package/dist/esm/helpers/resolveVariantStyle.native.js.map +1 -0
  238. package/dist/esm/helpers/styleStaticConfig.mjs +1 -50
  239. package/dist/esm/helpers/styleStaticConfig.mjs.map +1 -1
  240. package/dist/esm/helpers/styleStaticConfig.native.js +1 -51
  241. package/dist/esm/helpers/styleStaticConfig.native.js.map +1 -1
  242. package/dist/esm/helpers/styleStaticConfigCore.mjs +88 -0
  243. package/dist/esm/helpers/styleStaticConfigCore.mjs.map +1 -0
  244. package/dist/esm/helpers/styleStaticConfigCore.native.js +106 -0
  245. package/dist/esm/helpers/styleStaticConfigCore.native.js.map +1 -0
  246. package/dist/esm/helpers/styledDynamic.mjs +136 -0
  247. package/dist/esm/helpers/styledDynamic.mjs.map +1 -0
  248. package/dist/esm/helpers/styledDynamic.native.js +169 -0
  249. package/dist/esm/helpers/styledDynamic.native.js.map +1 -0
  250. package/dist/esm/helpers/tokenCategories.mjs +15 -36
  251. package/dist/esm/helpers/tokenCategories.mjs.map +1 -1
  252. package/dist/esm/helpers/tokenCategories.native.js +15 -38
  253. package/dist/esm/helpers/tokenCategories.native.js.map +1 -1
  254. package/dist/esm/helpers/variableValue.mjs +17 -12
  255. package/dist/esm/helpers/variableValue.mjs.map +1 -1
  256. package/dist/esm/helpers/variableValue.native.js +46 -23
  257. package/dist/esm/helpers/variableValue.native.js.map +1 -1
  258. package/dist/esm/helpers/warnOnce.mjs +5 -4
  259. package/dist/esm/helpers/warnOnce.mjs.map +1 -1
  260. package/dist/esm/helpers/warnOnce.native.js +6 -4
  261. package/dist/esm/helpers/warnOnce.native.js.map +1 -1
  262. package/dist/esm/hooks/useAnimationDriver.mjs +2 -2
  263. package/dist/esm/hooks/useAnimationDriver.mjs.map +1 -1
  264. package/dist/esm/hooks/useAnimationDriver.native.js +2 -2
  265. package/dist/esm/hooks/useAnimationDriver.native.js.map +1 -1
  266. package/dist/esm/hooks/useComponentState.mjs +41 -82
  267. package/dist/esm/hooks/useComponentState.mjs.map +1 -1
  268. package/dist/esm/hooks/useComponentState.native.js +45 -84
  269. package/dist/esm/hooks/useComponentState.native.js.map +1 -1
  270. package/dist/esm/hooks/useMedia.mjs +2 -2
  271. package/dist/esm/hooks/useMedia.mjs.map +1 -1
  272. package/dist/esm/hooks/useMedia.native.js +2 -2
  273. package/dist/esm/hooks/useMedia.native.js.map +1 -1
  274. package/dist/esm/hooks/useStyle.mjs +11 -0
  275. package/dist/esm/hooks/useStyle.mjs.map +1 -0
  276. package/dist/esm/hooks/useStyle.native.js +11 -0
  277. package/dist/esm/hooks/useStyle.native.js.map +1 -0
  278. package/dist/esm/hooks/useThemeState.mjs +25 -90
  279. package/dist/esm/hooks/useThemeState.mjs.map +1 -1
  280. package/dist/esm/hooks/useThemeState.native.js +34 -94
  281. package/dist/esm/hooks/useThemeState.native.js.map +1 -1
  282. package/dist/esm/index.js +6 -4
  283. package/dist/esm/index.mjs +6 -4
  284. package/dist/esm/index.native.js +6 -4
  285. package/dist/esm/static-resolve.mjs +3 -3
  286. package/dist/esm/static-resolve.mjs.map +1 -1
  287. package/dist/esm/static-resolve.native.js +3 -3
  288. package/dist/esm/static-resolve.native.js.map +1 -1
  289. package/dist/esm/style.mjs +58 -0
  290. package/dist/esm/style.mjs.map +1 -0
  291. package/dist/esm/style.native.js +63 -0
  292. package/dist/esm/style.native.js.map +1 -0
  293. package/dist/esm/styled.mjs +12 -6
  294. package/dist/esm/styled.mjs.map +1 -1
  295. package/dist/esm/styled.native.js +12 -6
  296. package/dist/esm/styled.native.js.map +1 -1
  297. package/dist/esm/types.mjs +3 -4
  298. package/dist/esm/types.mjs.map +1 -1
  299. package/dist/esm/types.native.js +3 -4
  300. package/dist/esm/types.native.js.map +1 -1
  301. package/dist/esm/views/TamaguiProvider.mjs +1 -2
  302. package/dist/esm/views/TamaguiProvider.mjs.map +1 -1
  303. package/dist/esm/views/TamaguiProvider.native.js +1 -2
  304. package/dist/esm/views/TamaguiProvider.native.js.map +1 -1
  305. package/dist/esm/views/Text.mjs +17 -12
  306. package/dist/esm/views/Text.mjs.map +1 -1
  307. package/dist/esm/views/Theme.mjs +3 -3
  308. package/dist/esm/views/Theme.mjs.map +1 -1
  309. package/dist/esm/views/Theme.native.js +3 -3
  310. package/dist/esm/views/Theme.native.js.map +1 -1
  311. package/dist/esm/views/ThemeDebug.mjs +1 -4
  312. package/dist/esm/views/ThemeDebug.mjs.map +1 -1
  313. package/package.json +15 -15
  314. package/src/createComponent.tsx +21 -1
  315. package/src/createStyledHOC.tsx +4 -2
  316. package/src/createVariable.ts +0 -10
  317. package/src/helpers/borderComponents.ts +62 -0
  318. package/src/helpers/createDesignSystem.ts +0 -2
  319. package/src/helpers/createStyledContext.tsx +15 -53
  320. package/src/helpers/formatDiagnostic.ts +9 -9
  321. package/src/helpers/getCSSStylesAtomic.native.ts +6 -3
  322. package/src/helpers/getCSSStylesAtomic.ts +192 -207
  323. package/src/helpers/getCSSStylesAtomicCompiled.ts +13 -1
  324. package/src/helpers/getDynamicVal.ts +4 -0
  325. package/src/helpers/getSplitStyles.tsx +2080 -3270
  326. package/src/helpers/grammarConfig.ts +218 -1
  327. package/src/helpers/insertStyleRule.tsx +4 -2
  328. package/src/helpers/log.ts +12 -11
  329. package/src/helpers/mergeVariants.ts +55 -18
  330. package/src/helpers/nativeOnlyProps.ts +0 -1
  331. package/src/helpers/nativeStyleEngine.ts +55 -14
  332. package/src/helpers/normalizeValueWithProperty.ts +10 -12
  333. package/src/helpers/parseBorderShorthand.native.ts +23 -45
  334. package/src/helpers/parseOutlineShorthand.native.ts +9 -40
  335. package/src/helpers/resolveSafeArea.ts +34 -101
  336. package/src/helpers/resolveVariantStyle.ts +77 -0
  337. package/src/helpers/styleFrontend.ts +8 -5
  338. package/src/helpers/styleStaticConfig.ts +5 -72
  339. package/src/helpers/styleStaticConfigCore.ts +110 -0
  340. package/src/helpers/styledDynamic.ts +191 -0
  341. package/src/helpers/tokenCategories.ts +40 -65
  342. package/src/helpers/variableValue.ts +20 -15
  343. package/src/helpers/warnOnce.ts +5 -4
  344. package/src/hooks/useAnimationDriver.ts +6 -2
  345. package/src/hooks/useComponentState.ts +55 -183
  346. package/src/hooks/useMedia.tsx +10 -8
  347. package/src/hooks/useStyle.ts +10 -0
  348. package/src/hooks/useThemeState.ts +51 -264
  349. package/src/index.ts +6 -6
  350. package/src/internalRuntimeTypes.ts +1 -0
  351. package/src/static-resolve.ts +7 -4
  352. package/src/style.ts +97 -0
  353. package/src/styled.tsx +39 -68
  354. package/src/types.tsx +105 -169
  355. package/src/views/TamaguiProvider.tsx +0 -2
  356. package/src/views/Text.tsx +20 -14
  357. package/src/views/Theme.tsx +13 -9
  358. package/src/views/ThemeDebug.tsx +0 -1
  359. package/types/createComponent.d.ts.map +1 -1
  360. package/types/createStyledHOC.d.ts +1 -1
  361. package/types/createStyledHOC.d.ts.map +1 -1
  362. package/types/createVariable.d.ts +0 -2
  363. package/types/createVariable.d.ts.map +1 -1
  364. package/types/helpers/borderComponents.d.ts +10 -0
  365. package/types/helpers/borderComponents.d.ts.map +1 -0
  366. package/types/helpers/createDesignSystem.d.ts.map +1 -1
  367. package/types/helpers/createStyledContext.d.ts.map +1 -1
  368. package/types/helpers/getCSSStylesAtomic.d.ts +20 -19
  369. package/types/helpers/getCSSStylesAtomic.d.ts.map +1 -1
  370. package/types/helpers/getCSSStylesAtomic.native.d.ts +5 -0
  371. package/types/helpers/getCSSStylesAtomic.native.d.ts.map +1 -1
  372. package/types/helpers/getCSSStylesAtomicCompiled.d.ts +6 -1
  373. package/types/helpers/getCSSStylesAtomicCompiled.d.ts.map +1 -1
  374. package/types/helpers/getDynamicVal.d.ts.map +1 -1
  375. package/types/helpers/getSplitStyles.d.ts +3 -5
  376. package/types/helpers/getSplitStyles.d.ts.map +1 -1
  377. package/types/helpers/grammarConfig.d.ts +25 -2
  378. package/types/helpers/grammarConfig.d.ts.map +1 -1
  379. package/types/helpers/insertStyleRule.d.ts +1 -0
  380. package/types/helpers/insertStyleRule.d.ts.map +1 -1
  381. package/types/helpers/log.d.ts.map +1 -1
  382. package/types/helpers/mergeVariants.d.ts.map +1 -1
  383. package/types/helpers/nativeOnlyProps.d.ts +0 -1
  384. package/types/helpers/nativeOnlyProps.d.ts.map +1 -1
  385. package/types/helpers/nativeStyleEngine.d.ts +6 -0
  386. package/types/helpers/nativeStyleEngine.d.ts.map +1 -1
  387. package/types/helpers/normalizeValueWithProperty.d.ts.map +1 -1
  388. package/types/helpers/parseBorderShorthand.native.d.ts +1 -0
  389. package/types/helpers/parseBorderShorthand.native.d.ts.map +1 -1
  390. package/types/helpers/parseOutlineShorthand.native.d.ts.map +1 -1
  391. package/types/helpers/resolveSafeArea.d.ts +0 -1
  392. package/types/helpers/resolveSafeArea.d.ts.map +1 -1
  393. package/types/helpers/resolveVariantStyle.d.ts +3 -0
  394. package/types/helpers/resolveVariantStyle.d.ts.map +1 -0
  395. package/types/helpers/styleFrontend.d.ts +3 -5
  396. package/types/helpers/styleFrontend.d.ts.map +1 -1
  397. package/types/helpers/styleStaticConfig.d.ts +4 -9
  398. package/types/helpers/styleStaticConfig.d.ts.map +1 -1
  399. package/types/helpers/styleStaticConfigCore.d.ts +4 -0
  400. package/types/helpers/styleStaticConfigCore.d.ts.map +1 -0
  401. package/types/helpers/styledDynamic.d.ts +18 -0
  402. package/types/helpers/styledDynamic.d.ts.map +1 -0
  403. package/types/helpers/tokenCategories.d.ts +0 -1
  404. package/types/helpers/tokenCategories.d.ts.map +1 -1
  405. package/types/helpers/variableValue.d.ts.map +1 -1
  406. package/types/helpers/warnOnce.d.ts.map +1 -1
  407. package/types/helpers/webPropsToSkip.native.d.ts +68 -68
  408. package/types/hooks/useAnimationDriver.d.ts.map +1 -1
  409. package/types/hooks/useComponentState.d.ts.map +1 -1
  410. package/types/hooks/useMedia.d.ts.map +1 -1
  411. package/types/hooks/useStyle.d.ts +4 -0
  412. package/types/hooks/useStyle.d.ts.map +1 -0
  413. package/types/hooks/useThemeState.d.ts +1 -11
  414. package/types/hooks/useThemeState.d.ts.map +1 -1
  415. package/types/index.d.ts +6 -4
  416. package/types/index.d.ts.map +1 -1
  417. package/types/internalRuntimeTypes.d.ts +1 -1
  418. package/types/internalRuntimeTypes.d.ts.map +1 -1
  419. package/types/static-resolve.d.ts.map +1 -1
  420. package/types/style.d.ts +18 -0
  421. package/types/style.d.ts.map +1 -0
  422. package/types/styled.d.ts +10 -10
  423. package/types/styled.d.ts.map +1 -1
  424. package/types/types.d.ts +74 -49
  425. package/types/types.d.ts.map +1 -1
  426. package/types/views/TamaguiProvider.d.ts +1 -1
  427. package/types/views/TamaguiProvider.d.ts.map +1 -1
  428. package/types/views/Text.d.ts.map +1 -1
  429. package/types/views/Theme.d.ts.map +1 -1
  430. package/types/views/ThemeDebug.d.ts.map +1 -1
  431. package/dist/cjs/helpers/directStyleCSS.cjs +0 -345
  432. package/dist/cjs/helpers/directStyleCSS.native.js.map +0 -1
  433. package/dist/cjs/helpers/directStyleCSSCompiled.cjs +0 -40
  434. package/dist/cjs/helpers/directStyleCSSCompiled.native.cjs +0 -46
  435. package/dist/cjs/helpers/directStyleCSSCompiled.native.js +0 -48
  436. package/dist/cjs/helpers/directStyleCSSCompiled.native.js.map +0 -1
  437. package/dist/cjs/helpers/getVariantExtras.cjs +0 -91
  438. package/dist/cjs/helpers/getVariantExtras.native.cjs +0 -94
  439. package/dist/cjs/helpers/getVariantExtras.native.js +0 -96
  440. package/dist/cjs/helpers/getVariantExtras.native.js.map +0 -1
  441. package/dist/cjs/helpers/variantResolvers.cjs +0 -87
  442. package/dist/cjs/helpers/variantResolvers.native.cjs +0 -140
  443. package/dist/cjs/helpers/variantResolvers.native.js +0 -142
  444. package/dist/cjs/helpers/variantResolvers.native.js.map +0 -1
  445. package/dist/esm/helpers/directStyleCSS.mjs +0 -317
  446. package/dist/esm/helpers/directStyleCSS.mjs.map +0 -1
  447. package/dist/esm/helpers/directStyleCSS.native.js +0 -1
  448. package/dist/esm/helpers/directStyleCSSCompiled.mjs +0 -11
  449. package/dist/esm/helpers/directStyleCSSCompiled.mjs.map +0 -1
  450. package/dist/esm/helpers/directStyleCSSCompiled.native.js +0 -15
  451. package/dist/esm/helpers/directStyleCSSCompiled.native.js.map +0 -1
  452. package/dist/esm/helpers/getVariantExtras.mjs +0 -69
  453. package/dist/esm/helpers/getVariantExtras.mjs.map +0 -1
  454. package/dist/esm/helpers/getVariantExtras.native.js +0 -70
  455. package/dist/esm/helpers/getVariantExtras.native.js.map +0 -1
  456. package/dist/esm/helpers/variantResolvers.mjs +0 -65
  457. package/dist/esm/helpers/variantResolvers.mjs.map +0 -1
  458. package/dist/esm/helpers/variantResolvers.native.js +0 -116
  459. package/dist/esm/helpers/variantResolvers.native.js.map +0 -1
  460. package/src/helpers/directStyleCSS.native.ts +0 -1
  461. package/src/helpers/directStyleCSS.ts +0 -513
  462. package/src/helpers/directStyleCSSCompiled.ts +0 -32
  463. package/src/helpers/getVariantExtras.tsx +0 -95
  464. package/src/helpers/variantResolvers.ts +0 -121
  465. package/types/helpers/directStyleCSS.d.ts +0 -28
  466. package/types/helpers/directStyleCSS.d.ts.map +0 -1
  467. package/types/helpers/directStyleCSS.native.d.ts +0 -2
  468. package/types/helpers/directStyleCSS.native.d.ts.map +0 -1
  469. package/types/helpers/directStyleCSSCompiled.d.ts +0 -10
  470. package/types/helpers/directStyleCSSCompiled.d.ts.map +0 -1
  471. package/types/helpers/getVariantExtras.d.ts +0 -4
  472. package/types/helpers/getVariantExtras.d.ts.map +0 -1
  473. package/types/helpers/variantResolvers.d.ts +0 -9
  474. package/types/helpers/variantResolvers.d.ts.map +0 -1
@@ -1,18 +1,14 @@
1
1
  import type { PropMappedValue } from '../types'
2
+ import { classifyBorderComponents } from './borderComponents'
2
3
 
3
- // border style keywords
4
- const borderStyles = new Set([
5
- 'solid',
6
- 'dashed',
7
- 'dotted',
8
- 'double',
9
- 'groove',
10
- 'ridge',
11
- 'inset',
12
- 'outset',
13
- 'none',
14
- 'hidden',
15
- ])
4
+ // native width props want numbers: px and unitless become numbers, the CSS
5
+ // width keywords map to their user-agent px values, anything else passes as-is
6
+ export function toNativeBorderWidth(width: string): string | number {
7
+ if (width === 'thin') return 1
8
+ if (width === 'medium') return 3
9
+ if (width === 'thick') return 5
10
+ return width.endsWith('px') || !/[a-z%]/i.test(width) ? Number.parseFloat(width) : width
11
+ }
16
12
 
17
13
  // parses CSS border shorthand: "<width> <style> <color>"
18
14
  // components can appear in any order, all are optional
@@ -28,46 +24,28 @@ export function parseBorderShorthand(value: string): PropMappedValue | undefined
28
24
  ]
29
25
  }
30
26
 
31
- const parts = value.trim().split(/\s+/)
32
- let borderWidth: string | number | undefined
33
- let borderStyle: string | undefined
34
- let borderColor: string | undefined
35
-
36
- for (const part of parts) {
37
- // check if it's a border style keyword
38
- if (borderStyles.has(part)) {
39
- borderStyle = part
40
- }
41
- // check if it's a length (number or ends with px/em/rem/etc)
42
- else if (/^[\d.]+(?:px|em|rem|%|pt|vw|vh)?$/.test(part)) {
43
- const num = parseFloat(part)
44
- borderWidth = part.endsWith('px') || !part.match(/[a-z%]/i) ? num : part
45
- }
46
- // otherwise assume it's a color
47
- else {
48
- borderColor = part
49
- }
50
- }
27
+ const { width, style, color } = classifyBorderComponents(value)
51
28
 
52
29
  const result: PropMappedValue = []
53
30
 
54
31
  // expand to individual width props (RN doesn't support borderWidth shorthand)
55
- if (borderWidth !== undefined) {
56
- result.push(['borderTopWidth', borderWidth])
57
- result.push(['borderRightWidth', borderWidth])
58
- result.push(['borderBottomWidth', borderWidth])
59
- result.push(['borderLeftWidth', borderWidth])
32
+ if (width !== undefined) {
33
+ const nativeWidth = toNativeBorderWidth(width)
34
+ result.push(['borderTopWidth', nativeWidth])
35
+ result.push(['borderRightWidth', nativeWidth])
36
+ result.push(['borderBottomWidth', nativeWidth])
37
+ result.push(['borderLeftWidth', nativeWidth])
60
38
  }
61
39
  // borderStyle is supported as-is on native
62
- if (borderStyle !== undefined) {
63
- result.push(['borderStyle', borderStyle])
40
+ if (style !== undefined) {
41
+ result.push(['borderStyle', style])
64
42
  }
65
43
  // expand to individual color props (RN doesn't support borderColor shorthand)
66
- if (borderColor !== undefined) {
67
- result.push(['borderTopColor', borderColor])
68
- result.push(['borderRightColor', borderColor])
69
- result.push(['borderBottomColor', borderColor])
70
- result.push(['borderLeftColor', borderColor])
44
+ if (color !== undefined) {
45
+ result.push(['borderTopColor', color])
46
+ result.push(['borderRightColor', color])
47
+ result.push(['borderBottomColor', color])
48
+ result.push(['borderLeftColor', color])
71
49
  }
72
50
 
73
51
  return result.length > 0 ? result : undefined
@@ -1,18 +1,6 @@
1
1
  import type { PropMappedValue } from '../types'
2
-
3
- // outline style keywords
4
- const outlineStyles = new Set([
5
- 'solid',
6
- 'dashed',
7
- 'dotted',
8
- 'double',
9
- 'groove',
10
- 'ridge',
11
- 'inset',
12
- 'outset',
13
- 'none',
14
- 'hidden',
15
- ])
2
+ import { classifyBorderComponents } from './borderComponents'
3
+ import { toNativeBorderWidth } from './parseBorderShorthand.native'
16
4
 
17
5
  // parses CSS outline shorthand: "<width> <style> <color>"
18
6
  // components can appear in any order, all are optional
@@ -25,37 +13,18 @@ export function parseOutlineShorthand(value: string): PropMappedValue | undefine
25
13
  ]
26
14
  }
27
15
 
28
- const parts = value.trim().split(/\s+/)
29
- let outlineWidth: string | number | undefined
30
- let outlineStyle: string | undefined
31
- let outlineColor: string | undefined
32
-
33
- for (const part of parts) {
34
- // check if it's an outline style keyword
35
- if (outlineStyles.has(part)) {
36
- outlineStyle = part
37
- }
38
- // check if it's a length (number or ends with px/em/rem/etc)
39
- else if (/^[\d.]+(?:px|em|rem|%|pt|vw|vh)?$/.test(part)) {
40
- const num = parseFloat(part)
41
- outlineWidth = part.endsWith('px') || !part.match(/[a-z%]/i) ? num : part
42
- }
43
- // otherwise assume it's a color
44
- else {
45
- outlineColor = part
46
- }
47
- }
16
+ const { width, style, color } = classifyBorderComponents(value, true)
48
17
 
49
18
  const result: PropMappedValue = []
50
19
 
51
- if (outlineWidth !== undefined) {
52
- result.push(['outlineWidth', outlineWidth])
20
+ if (width !== undefined) {
21
+ result.push(['outlineWidth', toNativeBorderWidth(width)])
53
22
  }
54
- if (outlineStyle !== undefined) {
55
- result.push(['outlineStyle', outlineStyle])
23
+ if (style !== undefined) {
24
+ result.push(['outlineStyle', style])
56
25
  }
57
- if (outlineColor !== undefined) {
58
- result.push(['outlineColor', outlineColor])
26
+ if (color !== undefined) {
27
+ result.push(['outlineColor', color])
59
28
  }
60
29
 
61
30
  return result.length > 0 ? result : undefined
@@ -5,112 +5,45 @@
5
5
  // insets on native (see resolveSafeArea.native.ts).
6
6
  //
7
7
 
8
- type Edge = 'top' | 'bottom' | 'left' | 'right'
9
-
10
- // map prop name -> which edge(s) it covers.
11
- // single-edge props map to one edge; multi-edge props (padding, inset, ...)
12
- // map to multiple edges and get expanded.
13
- //
14
- // keys here are AFTER shorthand expansion (pt -> paddingTop, etc).
15
- const propEdges: Record<string, Edge | Edge[]> = {
16
- // padding
17
- padding: ['top', 'right', 'bottom', 'left'],
18
- paddingTop: 'top',
19
- paddingBottom: 'bottom',
20
- paddingLeft: 'left',
21
- paddingRight: 'right',
22
- paddingHorizontal: ['left', 'right'],
23
- paddingVertical: ['top', 'bottom'],
24
- paddingStart: 'left',
25
- paddingEnd: 'right',
26
- paddingBlock: ['top', 'bottom'],
27
- paddingInline: ['left', 'right'],
28
- paddingBlockStart: 'top',
29
- paddingBlockEnd: 'bottom',
30
- paddingInlineStart: 'left',
31
- paddingInlineEnd: 'right',
32
- // margin
33
- margin: ['top', 'right', 'bottom', 'left'],
34
- marginTop: 'top',
35
- marginBottom: 'bottom',
36
- marginLeft: 'left',
37
- marginRight: 'right',
38
- marginHorizontal: ['left', 'right'],
39
- marginVertical: ['top', 'bottom'],
40
- marginStart: 'left',
41
- marginEnd: 'right',
42
- marginBlock: ['top', 'bottom'],
43
- marginInline: ['left', 'right'],
44
- marginBlockStart: 'top',
45
- marginBlockEnd: 'bottom',
46
- marginInlineStart: 'left',
47
- marginInlineEnd: 'right',
48
- // inset
49
- inset: ['top', 'right', 'bottom', 'left'],
50
- top: 'top',
51
- bottom: 'bottom',
52
- left: 'left',
53
- right: 'right',
54
- start: 'left',
55
- end: 'right',
8
+ type Edge = 'top' | 'right' | 'bottom' | 'left'
9
+
10
+ const allEdges: Edge[] = ['top', 'right', 'bottom', 'left']
11
+ const suffixEdges: Record<string, Edge[]> = {
12
+ Horizontal: ['left', 'right'],
13
+ Inline: ['left', 'right'],
14
+ Vertical: ['top', 'bottom'],
15
+ Block: ['top', 'bottom'],
16
+ Start: ['left'],
17
+ InlineStart: ['left'],
18
+ End: ['right'],
19
+ InlineEnd: ['right'],
20
+ Top: ['top'],
21
+ BlockStart: ['top'],
22
+ Bottom: ['bottom'],
23
+ BlockEnd: ['bottom'],
24
+ Left: ['left'],
25
+ Right: ['right'],
56
26
  }
57
27
 
58
- const envForEdge: Record<Edge, string> = {
59
- top: 'env(safe-area-inset-top)',
60
- bottom: 'env(safe-area-inset-bottom)',
61
- left: 'env(safe-area-inset-left)',
62
- right: 'env(safe-area-inset-right)',
63
- }
64
-
65
- // is this prop key safe-area-aware?
66
- export function isSafeAreaKey(key: string): boolean {
67
- return key in propEdges
28
+ function safeAreaEdges(key: string): [string, Edge[]] | undefined {
29
+ if (key === 'inset') return ['', allEdges]
30
+ if (/^(top|right|bottom|left)$/.test(key)) return ['', [key as Edge]]
31
+ if (key === 'start') return ['', ['left']]
32
+ if (key === 'end') return ['', ['right']]
33
+ const match = /^(padding|margin)(.*)$/.exec(key)
34
+ if (!match) return
35
+ const edges = match[2] ? suffixEdges[match[2]] : allEdges
36
+ return edges && [match[1], edges]
68
37
  }
69
38
 
70
39
  // resolve key="safe" -> array of [edge-key, value] pairs.
71
40
  // returns undefined if key isn't safe-area-aware.
72
41
  export function expandSafeAreaValue(key: string): Array<[string, string]> | undefined {
73
- const edges = propEdges[key]
74
- if (!edges) return undefined
75
- if (typeof edges === 'string') {
76
- return [[key, envForEdge[edges]]]
77
- }
78
- // multi-edge: expand to per-side keys.
79
- // for padding/margin: padding + edgePascal = paddingTop etc.
80
- // for inset: emit bare top/right/bottom/left (the actual CSS sides).
81
- const base = baseKeyForExpansion[key]
82
- if (base === '') {
83
- return edges.map((e) => [edgeToSideKey[e], envForEdge[e]])
84
- }
85
- return edges.map((e) => [`${base}${edgeToPascal[e]}`, envForEdge[e]])
86
- }
87
-
88
- const edgeToPascal: Record<Edge, string> = {
89
- top: 'Top',
90
- bottom: 'Bottom',
91
- left: 'Left',
92
- right: 'Right',
93
- }
94
-
95
- const edgeToSideKey: Record<Edge, string> = {
96
- top: 'top',
97
- bottom: 'bottom',
98
- left: 'left',
99
- right: 'right',
100
- }
101
-
102
- // for each multi-edge prop, what's the base name to prepend Top/Bottom/etc?
103
- // '' = no prefix (use bare edge names like 'top', 'left')
104
- const baseKeyForExpansion: Record<string, string> = {
105
- padding: 'padding',
106
- paddingHorizontal: 'padding',
107
- paddingVertical: 'padding',
108
- paddingBlock: 'padding',
109
- paddingInline: 'padding',
110
- margin: 'margin',
111
- marginHorizontal: 'margin',
112
- marginVertical: 'margin',
113
- marginBlock: 'margin',
114
- marginInline: 'margin',
115
- inset: '',
42
+ const match = safeAreaEdges(key)
43
+ if (!match) return
44
+ const [base, edges] = match
45
+ return edges.map((edge) => [
46
+ base ? `${base}${edge[0].toUpperCase()}${edge.slice(1)}` : edge,
47
+ `env(safe-area-inset-${edge})`,
48
+ ])
116
49
  }
@@ -0,0 +1,77 @@
1
+ import type { GetStyleState } from '../types'
2
+ import { emitVariantStyle, walkConditionalValue } from './getSplitStyles'
3
+ import { isObj } from './isObj'
4
+ import { skipProps } from './skipProps'
5
+ import { styleOriginalValues } from './styleOriginalValues'
6
+ import { normalizeValueWithProperty } from './normalizeValueWithProperty'
7
+ import { getDynamicEnv, isStyledDynamic } from './styledDynamic'
8
+
9
+ export function resolveVariantStyle(
10
+ state: GetStyleState,
11
+ variants: Record<string, any>,
12
+ key: string,
13
+ value: any,
14
+ parentKey = key,
15
+ parentCondition?: unknown
16
+ ) {
17
+ const definition = variants[key]
18
+ // bare styled.dynamic<T>(): the prop is typed and consumed here; its style
19
+ // comes from a component resolver reading it off props
20
+ if (typeof definition !== 'function' && isStyledDynamic(definition)) {
21
+ return
22
+ }
23
+ if (
24
+ !(
25
+ typeof value === 'string' &&
26
+ definition &&
27
+ typeof definition === 'object' &&
28
+ value in definition
29
+ ) &&
30
+ walkConditionalValue(state, key, value, parentCondition, (payload, condition) =>
31
+ resolveSelection(state, variants, key, payload, parentKey, condition || undefined)
32
+ )
33
+ ) {
34
+ return
35
+ }
36
+ resolveSelection(state, variants, key, value, parentKey, parentCondition)
37
+ }
38
+
39
+ function resolveSelection(
40
+ state: GetStyleState,
41
+ variants: Record<string, any>,
42
+ key: string,
43
+ value: any,
44
+ parentKey: string,
45
+ condition?: unknown
46
+ ) {
47
+ const definition = variants[key]
48
+ let output
49
+ if (isStyledDynamic(definition) && typeof definition === 'function') {
50
+ // styled.dynamic(fn): pure function of the (per-clause) value + env
51
+ output = definition(value, getDynamicEnv(state))
52
+ } else if (definition && typeof definition === 'object' && value !== undefined) {
53
+ output = definition[value]
54
+ }
55
+ if (!isObj(output)) return
56
+
57
+ const originals = styleOriginalValues.get(output)
58
+ for (const outputKey in output) {
59
+ if (!state.styleProps.noSkip && outputKey in skipProps) continue
60
+ const raw = output[outputKey]
61
+ // A dynamic's static shape is allowed to use undefined values for
62
+ // conditionals. They are absent, matching resolver output semantics, and
63
+ // must not normalize into an "undefined" atomic rule.
64
+ if (raw == null) continue
65
+ const value = state.styleProps.noNormalize
66
+ ? raw
67
+ : normalizeValueWithProperty(raw, state.conf.shorthands[outputKey] || outputKey)
68
+ emitVariantStyle(
69
+ state,
70
+ outputKey,
71
+ value,
72
+ originals?.[outputKey] ?? raw,
73
+ condition,
74
+ parentKey === key && outputKey === key
75
+ )
76
+ }
77
+ }
@@ -64,6 +64,8 @@ export type FrontendClassPlan =
64
64
  preserveRawClass: boolean
65
65
  }
66
66
 
67
+ export type FrontendClassSink = (entry: FrontendClassPlanEntry) => void
68
+
67
69
  /**
68
70
  * A component's authoring syntax. It is chosen by the package the component was
69
71
  * imported from and frozen onto its static config when the component is created:
@@ -77,11 +79,12 @@ export type FrontendClassPlan =
77
79
  * contribution, merging, web lowering, and native evaluation all stay in core.
78
80
  */
79
81
  export type StyleFrontend = {
80
- /**
81
- * Classifies one class candidate. The shared style cursor owns the className
82
- * character walk and feeds every returned entry through its one property sink.
83
- */
84
- getClassPlan?: (candidate: string, config: StyleFrontendConfig) => FrontendClassPlan
82
+ /** resolves one class candidate and sends claimed entries to the shared cursor */
83
+ resolveClassName?: (
84
+ candidate: string,
85
+ config: StyleFrontendConfig,
86
+ sink: FrontendClassSink
87
+ ) => boolean | null
85
88
 
86
89
  /**
87
90
  * Resolves frontend-specific static style input (a class-string base, string
@@ -1,88 +1,21 @@
1
- import { stylePropsText, validStyles as validStylesView } from '@tamagui/helpers'
2
- import type { StaticConfig, TamaguiInternalConfig } from '../types'
1
+ import type { StaticConfig, StylePiece, TamaguiInternalConfig } from '../types'
3
2
  import { getConfigRevisionState } from './grammarConfig'
4
3
 
5
4
  export type StyleStaticConfig = {
6
5
  baseStyle: Record<string, any> | undefined
7
6
  baseVariantProps: Record<string, any> | undefined
7
+ baseStylePiece: StylePiece | undefined
8
+ baseStylePieces: Record<string, StylePiece> | undefined
8
9
  defaultProps: Record<string, any> | undefined
9
10
  styledContextKeys: Set<string> | null
10
11
  variants: StaticConfig['variants']
12
+ variantStyleResolver: any
11
13
  passthroughClassName: string | undefined
12
14
  }
13
15
 
14
- const styleStaticConfigCache = new WeakMap<
15
- StaticConfig,
16
- WeakMap<TamaguiInternalConfig, { revision: number; value: StyleStaticConfig }>
17
- >()
18
-
19
- /**
20
- * styled() takes styles and props in one options object. The styles belong to the
21
- * base layer the style pass writes before any prop, so call-site props and
22
- * variants always land on top of them; everything else stays a prop.
23
- *
24
- * Split lazily rather than in styled(), because classifying a key needs
25
- * `conf.shorthands` and styled() runs at module scope before createTamagui.
26
- */
27
16
  export function getStyleStaticConfig(
28
17
  staticConfig: StaticConfig,
29
18
  conf: TamaguiInternalConfig
30
19
  ): StyleStaticConfig {
31
- let configCache = styleStaticConfigCache.get(staticConfig)
32
- const revision = getConfigRevisionState(conf).revision
33
- const cached = configCache?.get(conf)
34
- if (cached?.revision === revision) return cached.value
35
-
36
- const normalized = staticConfig.styleFrontend?.normalizeStaticConfig?.(
37
- staticConfig,
38
- conf
39
- )
40
- const variants = normalized ? normalized.variants : staticConfig.variants
41
- const authoredBaseStyle = normalized ? normalized.baseStyle : staticConfig.baseStyle
42
- const authoredDefaultProps = staticConfig.defaultProps
43
- let baseStyle: Record<string, any> | undefined
44
- let baseVariantProps: Record<string, any> | undefined
45
- let defaultProps: Record<string, any> | undefined
46
- if (authoredDefaultProps) {
47
- const validStyles =
48
- staticConfig.validStyles ||
49
- (staticConfig.isText || staticConfig.isInput ? stylePropsText : validStylesView)
50
- for (const key in authoredDefaultProps) {
51
- const isVariant = Boolean(variants?.[key])
52
- // transition selects an animation driver preset. It stays a prop even
53
- // though the web style table recognizes the CSS property spelling.
54
- const isStyle =
55
- key !== 'transition' && (key in validStyles || key in conf.shorthands)
56
- if (isVariant || isStyle) {
57
- ;(baseStyle ||= authoredBaseStyle ? { ...authoredBaseStyle } : {})[key] =
58
- authoredDefaultProps[key]
59
- }
60
- // variants also stay in the merged props for context and HOC forwarding,
61
- // while their style contribution runs at its authored base position
62
- if (isVariant || !isStyle) {
63
- ;(defaultProps ||= {})[key] = authoredDefaultProps[key]
64
- }
65
- if (isVariant) {
66
- ;(baseVariantProps ||= {})[key] = authoredDefaultProps[key]
67
- }
68
- }
69
- }
70
- const keys = staticConfig.contextProps || staticConfig.context?.propKeys
71
- const value: StyleStaticConfig = {
72
- baseStyle: baseStyle || authoredBaseStyle,
73
- baseVariantProps,
74
- defaultProps,
75
- styledContextKeys: keys ? new Set(keys) : null,
76
- variants,
77
- passthroughClassName: normalized
78
- ? normalized.passthroughClassName
79
- : staticConfig.passthroughClassName,
80
- }
81
-
82
- if (!configCache) {
83
- configCache = new WeakMap()
84
- styleStaticConfigCache.set(staticConfig, configCache)
85
- }
86
- configCache.set(conf, { revision, value })
87
- return value
20
+ return getConfigRevisionState(conf).styleStaticConfig(staticConfig, conf)
88
21
  }
@@ -0,0 +1,110 @@
1
+ import {
2
+ stylePropsInput,
3
+ stylePropsText,
4
+ validStyles as validStylesView,
5
+ } from '@tamagui/helpers'
6
+ import type { StaticConfig, StylePiece, TamaguiInternalConfig } from '../types'
7
+ import { createStylePiece } from '../style'
8
+ import type { StyleStaticConfig } from './styleStaticConfig'
9
+
10
+ const styleStaticConfigCache = new WeakMap<
11
+ StaticConfig,
12
+ WeakMap<TamaguiInternalConfig, { revision: number; value: StyleStaticConfig }>
13
+ >()
14
+
15
+ export function resolveStyleStaticConfig(
16
+ staticConfig: StaticConfig,
17
+ conf: TamaguiInternalConfig,
18
+ revision: number
19
+ ): StyleStaticConfig {
20
+ let configCache = styleStaticConfigCache.get(staticConfig)
21
+ const cached = configCache?.get(conf)
22
+ if (cached?.revision === revision) return cached.value
23
+
24
+ const normalized = staticConfig.styleFrontend?.normalizeStaticConfig?.(
25
+ staticConfig,
26
+ conf
27
+ )
28
+ const variants = normalized ? normalized.variants : staticConfig.variants
29
+ const authoredBaseStyle = normalized ? normalized.baseStyle : staticConfig.baseStyle
30
+ const authoredDefaultProps = staticConfig.defaultProps
31
+ let baseStyle: Record<string, any> | undefined
32
+ let baseVariantProps: Record<string, any> | undefined
33
+ let defaultProps: Record<string, any> | undefined
34
+ const validStyles =
35
+ staticConfig.validStyles ||
36
+ (staticConfig.isInput
37
+ ? stylePropsInput
38
+ : staticConfig.isText
39
+ ? stylePropsText
40
+ : validStylesView)
41
+ if (authoredDefaultProps) {
42
+ for (const key in authoredDefaultProps) {
43
+ const isVariant = Boolean(variants?.[key])
44
+ const isStyle =
45
+ key !== 'transition' && (key in validStyles || key in conf.shorthands)
46
+ if (isVariant || isStyle) {
47
+ ;(baseStyle ||= authoredBaseStyle ? { ...authoredBaseStyle } : {})[key] =
48
+ authoredDefaultProps[key]
49
+ }
50
+ if (isVariant || !isStyle) {
51
+ ;(defaultProps ||= {})[key] = authoredDefaultProps[key]
52
+ }
53
+ if (isVariant) {
54
+ ;(baseVariantProps ||= {})[key] = authoredDefaultProps[key]
55
+ }
56
+ }
57
+ }
58
+ const resolvedBaseStyle = baseStyle || authoredBaseStyle
59
+ let baseStylePiece
60
+ let baseStylePieces: Record<string, StylePiece> | undefined
61
+ if (resolvedBaseStyle && !(staticConfig as any).disableBaseStylePiece) {
62
+ let directBaseStyle: Record<string, any> | undefined
63
+ let directBaseKeys: string[] | undefined
64
+ const flushDirectBaseStyle = () => {
65
+ if (!directBaseStyle || !directBaseKeys) return
66
+ const piece = createStylePiece(directBaseStyle, 'base')
67
+ baseStylePiece ||= piece
68
+ baseStylePieces ||= {}
69
+ for (const key of directBaseKeys) {
70
+ baseStylePieces[key] = piece
71
+ }
72
+ directBaseStyle = undefined
73
+ directBaseKeys = undefined
74
+ }
75
+ for (const key in resolvedBaseStyle) {
76
+ const expanded = conf.shorthands[key] || key
77
+ if (key !== 'transition' && !variants?.[key] && expanded in validStyles) {
78
+ ;(directBaseStyle ||= {})[key] = resolvedBaseStyle[key]
79
+ ;(directBaseKeys ||= []).push(key)
80
+ } else {
81
+ // A default variant between direct declarations must run at that exact
82
+ // authored position. Keeping separate contiguous pieces preserves the
83
+ // base layer's ordinary last-write order while still precompiling it.
84
+ flushDirectBaseStyle()
85
+ }
86
+ }
87
+ flushDirectBaseStyle()
88
+ }
89
+ const keys = staticConfig.contextProps || staticConfig.context?.propKeys
90
+ const value: StyleStaticConfig = {
91
+ baseStyle: resolvedBaseStyle,
92
+ baseVariantProps,
93
+ baseStylePiece,
94
+ baseStylePieces,
95
+ defaultProps,
96
+ styledContextKeys: keys ? new Set(keys) : null,
97
+ variants,
98
+ variantStyleResolver: (staticConfig as any).variantStyleResolver,
99
+ passthroughClassName: normalized
100
+ ? normalized.passthroughClassName
101
+ : staticConfig.passthroughClassName,
102
+ }
103
+
104
+ if (!configCache) {
105
+ configCache = new WeakMap()
106
+ styleStaticConfigCache.set(staticConfig, configCache)
107
+ }
108
+ configCache.set(conf, { revision, value })
109
+ return value
110
+ }