@tamagui/web 3.0.0-beta.765.1 → 3.0.0-beta.804.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (411) hide show
  1. package/dist/cjs/createComponent.cjs +83 -86
  2. package/dist/cjs/createComponent.native.cjs +96 -103
  3. package/dist/cjs/createComponent.native.js +96 -103
  4. package/dist/cjs/createComponent.native.js.map +1 -1
  5. package/dist/cjs/createTamagui.cjs +9 -7
  6. package/dist/cjs/createTamagui.native.cjs +9 -7
  7. package/dist/cjs/createTamagui.native.js +9 -7
  8. package/dist/cjs/createTamagui.native.js.map +1 -1
  9. package/dist/cjs/helpers/defaultAnimationDriver.cjs +0 -1
  10. package/dist/cjs/helpers/defaultAnimationDriver.native.cjs +0 -1
  11. package/dist/cjs/helpers/defaultAnimationDriver.native.js +0 -1
  12. package/dist/cjs/helpers/defaultAnimationDriver.native.js.map +1 -1
  13. package/dist/cjs/helpers/directStyleCSS.cjs +348 -0
  14. package/dist/cjs/helpers/directStyleCSS.native.cjs +20 -0
  15. package/dist/cjs/helpers/directStyleCSS.native.js +22 -0
  16. package/dist/cjs/helpers/directStyleCSS.native.js.map +1 -0
  17. package/dist/cjs/helpers/directStyleCSSCompiled.cjs +40 -0
  18. package/dist/cjs/helpers/directStyleCSSCompiled.native.cjs +46 -0
  19. package/dist/cjs/helpers/directStyleCSSCompiled.native.js +48 -0
  20. package/dist/cjs/helpers/directStyleCSSCompiled.native.js.map +1 -0
  21. package/dist/cjs/helpers/getCSSStylesAtomic.cjs +92 -74
  22. package/dist/cjs/helpers/{getFontLanguage.native.cjs → getCSSStylesAtomicCompiled.cjs} +12 -8
  23. package/dist/cjs/helpers/{getFontLanguage.native.js → getCSSStylesAtomicCompiled.native.cjs} +12 -8
  24. package/dist/cjs/helpers/getCSSStylesAtomicCompiled.native.js +36 -0
  25. package/dist/cjs/helpers/getCSSStylesAtomicCompiled.native.js.map +1 -0
  26. package/dist/cjs/helpers/getSplitStyles.cjs +2417 -548
  27. package/dist/cjs/helpers/getSplitStyles.native.cjs +2758 -621
  28. package/dist/cjs/helpers/getSplitStyles.native.js +2758 -621
  29. package/dist/cjs/helpers/getSplitStyles.native.js.map +1 -1
  30. package/dist/cjs/helpers/getVariantExtras.cjs +8 -3
  31. package/dist/cjs/helpers/getVariantExtras.native.cjs +8 -3
  32. package/dist/cjs/helpers/getVariantExtras.native.js +8 -3
  33. package/dist/cjs/helpers/getVariantExtras.native.js.map +1 -1
  34. package/dist/cjs/helpers/insertStyleRule.cjs +2 -1
  35. package/dist/cjs/helpers/insertStyleRule.native.cjs +68 -5
  36. package/dist/cjs/helpers/insertStyleRule.native.js +68 -5
  37. package/dist/cjs/helpers/insertStyleRule.native.js.map +1 -1
  38. package/dist/cjs/helpers/mediaState.cjs +12 -0
  39. package/dist/cjs/helpers/mediaState.native.cjs +12 -0
  40. package/dist/cjs/helpers/mediaState.native.js +12 -0
  41. package/dist/cjs/helpers/mediaState.native.js.map +1 -1
  42. package/dist/cjs/helpers/normalizeStyle.cjs +16 -2
  43. package/dist/cjs/helpers/normalizeStyle.native.cjs +16 -2
  44. package/dist/cjs/helpers/normalizeStyle.native.js +16 -2
  45. package/dist/cjs/helpers/normalizeStyle.native.js.map +1 -1
  46. package/dist/cjs/helpers/resolveRem.cjs +1 -1
  47. package/dist/cjs/helpers/skipProps.cjs +6 -1
  48. package/dist/cjs/helpers/skipProps.native.cjs +6 -1
  49. package/dist/cjs/helpers/skipProps.native.js +6 -1
  50. package/dist/cjs/helpers/skipProps.native.js.map +1 -1
  51. package/dist/cjs/helpers/styleFrontend.cjs +2 -8
  52. package/dist/cjs/helpers/styleFrontend.native.cjs +2 -10
  53. package/dist/cjs/helpers/styleFrontend.native.js +2 -10
  54. package/dist/cjs/helpers/styleFrontend.native.js.map +1 -1
  55. package/dist/cjs/helpers/styleToCSS.cjs +59 -0
  56. package/dist/cjs/helpers/{normalizeStylePropKeys.cjs → styleToCSS.native.cjs} +6 -4
  57. package/dist/cjs/helpers/{getFontLanguage.cjs → styleToCSS.native.js} +8 -4
  58. package/dist/cjs/helpers/styleToCSS.native.js.map +1 -0
  59. package/dist/cjs/helpers/subscribeToContextGroup.cjs +28 -1
  60. package/dist/cjs/helpers/subscribeToContextGroup.native.cjs +45 -1
  61. package/dist/cjs/helpers/subscribeToContextGroup.native.js +45 -1
  62. package/dist/cjs/helpers/subscribeToContextGroup.native.js.map +1 -1
  63. package/dist/cjs/helpers/variables.cjs +3 -2
  64. package/dist/cjs/helpers/variables.native.cjs +3 -2
  65. package/dist/cjs/helpers/variables.native.js +3 -2
  66. package/dist/cjs/helpers/variables.native.js.map +1 -1
  67. package/dist/cjs/helpers/wrapStyleTags.cjs +5 -3
  68. package/dist/cjs/helpers/wrapStyleTags.native.cjs +3 -1
  69. package/dist/cjs/helpers/wrapStyleTags.native.js +3 -1
  70. package/dist/cjs/helpers/wrapStyleTags.native.js.map +1 -1
  71. package/dist/cjs/hooks/useComponentState.cjs +70 -89
  72. package/dist/cjs/hooks/useComponentState.native.cjs +70 -88
  73. package/dist/cjs/hooks/useComponentState.native.js +70 -88
  74. package/dist/cjs/hooks/useComponentState.native.js.map +1 -1
  75. package/dist/cjs/hooks/useMedia.cjs +3 -15
  76. package/dist/cjs/hooks/useMedia.native.cjs +3 -15
  77. package/dist/cjs/hooks/useMedia.native.js +3 -15
  78. package/dist/cjs/hooks/useMedia.native.js.map +1 -1
  79. package/dist/cjs/hooks/useProps.cjs +7 -5
  80. package/dist/cjs/hooks/useProps.native.cjs +7 -5
  81. package/dist/cjs/hooks/useProps.native.js +7 -5
  82. package/dist/cjs/hooks/useProps.native.js.map +1 -1
  83. package/dist/cjs/hooks/useSplitStyles.cjs +42 -0
  84. package/dist/cjs/hooks/useSplitStyles.native.cjs +42 -0
  85. package/dist/cjs/hooks/useSplitStyles.native.js +44 -0
  86. package/dist/cjs/hooks/useSplitStyles.native.js.map +1 -0
  87. package/dist/cjs/index.cjs +184 -70
  88. package/dist/cjs/index.native.cjs +184 -70
  89. package/dist/cjs/index.native.js +184 -70
  90. package/dist/cjs/index.native.js.map +1 -1
  91. package/dist/cjs/insertFont.cjs +1 -1
  92. package/dist/cjs/insertFont.native.cjs +1 -0
  93. package/dist/cjs/insertFont.native.js +1 -0
  94. package/dist/cjs/insertFont.native.js.map +1 -1
  95. package/dist/cjs/internal-runtime.cjs +33 -6
  96. package/dist/cjs/internal-runtime.native.cjs +33 -6
  97. package/dist/cjs/internal-runtime.native.js +33 -6
  98. package/dist/cjs/internal-runtime.native.js.map +1 -1
  99. package/dist/cjs/setupReactNative.cjs +1 -29
  100. package/dist/cjs/setupReactNative.native.cjs +1 -3
  101. package/dist/cjs/setupReactNative.native.js +1 -3
  102. package/dist/cjs/setupReactNative.native.js.map +1 -1
  103. package/dist/cjs/static-resolve.cjs +229 -0
  104. package/dist/cjs/static-resolve.native.cjs +242 -0
  105. package/dist/cjs/static-resolve.native.js +244 -0
  106. package/dist/cjs/static-resolve.native.js.map +1 -0
  107. package/dist/cjs/styled.cjs +23 -37
  108. package/dist/cjs/styled.native.cjs +22 -37
  109. package/dist/cjs/styled.native.js +22 -37
  110. package/dist/cjs/styled.native.js.map +1 -1
  111. package/dist/cjs/views/TamaguiProvider.cjs +4 -8
  112. package/dist/cjs/views/TamaguiProvider.native.cjs +4 -8
  113. package/dist/cjs/views/TamaguiProvider.native.js +4 -8
  114. package/dist/cjs/views/TamaguiProvider.native.js.map +1 -1
  115. package/dist/cjs/views/ThemeUpdate.cjs +1 -1
  116. package/dist/cjs/views/ThemeUpdate.native.cjs +1 -1
  117. package/dist/cjs/views/ThemeUpdate.native.js +1 -1
  118. package/dist/cjs/views/ThemeUpdate.native.js.map +1 -1
  119. package/dist/esm/createComponent.mjs +85 -88
  120. package/dist/esm/createComponent.mjs.map +1 -1
  121. package/dist/esm/createComponent.native.js +98 -105
  122. package/dist/esm/createComponent.native.js.map +1 -1
  123. package/dist/esm/createTamagui.mjs +9 -7
  124. package/dist/esm/createTamagui.mjs.map +1 -1
  125. package/dist/esm/createTamagui.native.js +9 -7
  126. package/dist/esm/createTamagui.native.js.map +1 -1
  127. package/dist/esm/helpers/defaultAnimationDriver.mjs +0 -1
  128. package/dist/esm/helpers/defaultAnimationDriver.mjs.map +1 -1
  129. package/dist/esm/helpers/defaultAnimationDriver.native.js +0 -1
  130. package/dist/esm/helpers/defaultAnimationDriver.native.js.map +1 -1
  131. package/dist/esm/helpers/directStyleCSS.mjs +320 -0
  132. package/dist/esm/helpers/directStyleCSS.mjs.map +1 -0
  133. package/dist/esm/helpers/directStyleCSS.native.js +1 -0
  134. package/dist/esm/helpers/directStyleCSSCompiled.mjs +11 -0
  135. package/dist/esm/helpers/directStyleCSSCompiled.mjs.map +1 -0
  136. package/dist/esm/helpers/directStyleCSSCompiled.native.js +15 -0
  137. package/dist/esm/helpers/directStyleCSSCompiled.native.js.map +1 -0
  138. package/dist/esm/helpers/getCSSStylesAtomic.mjs +86 -72
  139. package/dist/esm/helpers/getCSSStylesAtomic.mjs.map +1 -1
  140. package/dist/esm/helpers/getCSSStylesAtomicCompiled.mjs +9 -0
  141. package/dist/esm/helpers/getCSSStylesAtomicCompiled.mjs.map +1 -0
  142. package/dist/esm/helpers/getCSSStylesAtomicCompiled.native.js +9 -0
  143. package/dist/esm/helpers/getCSSStylesAtomicCompiled.native.js.map +1 -0
  144. package/dist/esm/helpers/getSplitStyles.mjs +2406 -545
  145. package/dist/esm/helpers/getSplitStyles.mjs.map +1 -1
  146. package/dist/esm/helpers/getSplitStyles.native.js +2751 -618
  147. package/dist/esm/helpers/getSplitStyles.native.js.map +1 -1
  148. package/dist/esm/helpers/getVariantExtras.mjs +8 -3
  149. package/dist/esm/helpers/getVariantExtras.mjs.map +1 -1
  150. package/dist/esm/helpers/getVariantExtras.native.js +8 -3
  151. package/dist/esm/helpers/getVariantExtras.native.js.map +1 -1
  152. package/dist/esm/helpers/insertStyleRule.mjs +2 -1
  153. package/dist/esm/helpers/insertStyleRule.mjs.map +1 -1
  154. package/dist/esm/helpers/insertStyleRule.native.js +69 -3
  155. package/dist/esm/helpers/insertStyleRule.native.js.map +1 -1
  156. package/dist/esm/helpers/mediaState.mjs +12 -1
  157. package/dist/esm/helpers/mediaState.mjs.map +1 -1
  158. package/dist/esm/helpers/mediaState.native.js +12 -1
  159. package/dist/esm/helpers/mediaState.native.js.map +1 -1
  160. package/dist/esm/helpers/normalizeStyle.mjs +16 -2
  161. package/dist/esm/helpers/normalizeStyle.mjs.map +1 -1
  162. package/dist/esm/helpers/normalizeStyle.native.js +16 -2
  163. package/dist/esm/helpers/normalizeStyle.native.js.map +1 -1
  164. package/dist/esm/helpers/resolveRem.mjs +1 -1
  165. package/dist/esm/helpers/resolveRem.mjs.map +1 -1
  166. package/dist/esm/helpers/skipProps.mjs +3 -1
  167. package/dist/esm/helpers/skipProps.mjs.map +1 -1
  168. package/dist/esm/helpers/skipProps.native.js +3 -1
  169. package/dist/esm/helpers/skipProps.native.js.map +1 -1
  170. package/dist/esm/helpers/styleFrontend.mjs +2 -4
  171. package/dist/esm/helpers/styleFrontend.mjs.map +1 -1
  172. package/dist/esm/helpers/styleFrontend.native.js +2 -6
  173. package/dist/esm/helpers/styleFrontend.native.js.map +1 -1
  174. package/dist/esm/helpers/styleToCSS.mjs +40 -0
  175. package/dist/esm/helpers/styleToCSS.mjs.map +1 -0
  176. package/dist/esm/helpers/styleToCSS.native.js +4 -0
  177. package/dist/esm/helpers/styleToCSS.native.js.map +1 -0
  178. package/dist/esm/helpers/subscribeToContextGroup.mjs +25 -1
  179. package/dist/esm/helpers/subscribeToContextGroup.mjs.map +1 -1
  180. package/dist/esm/helpers/subscribeToContextGroup.native.js +42 -1
  181. package/dist/esm/helpers/subscribeToContextGroup.native.js.map +1 -1
  182. package/dist/esm/helpers/variables.mjs +2 -1
  183. package/dist/esm/helpers/variables.mjs.map +1 -1
  184. package/dist/esm/helpers/variables.native.js +2 -1
  185. package/dist/esm/helpers/variables.native.js.map +1 -1
  186. package/dist/esm/helpers/wrapStyleTags.mjs +5 -3
  187. package/dist/esm/helpers/wrapStyleTags.mjs.map +1 -1
  188. package/dist/esm/helpers/wrapStyleTags.native.js +3 -1
  189. package/dist/esm/helpers/wrapStyleTags.native.js.map +1 -1
  190. package/dist/esm/hooks/useComponentState.mjs +71 -90
  191. package/dist/esm/hooks/useComponentState.mjs.map +1 -1
  192. package/dist/esm/hooks/useComponentState.native.js +71 -89
  193. package/dist/esm/hooks/useComponentState.native.js.map +1 -1
  194. package/dist/esm/hooks/useMedia.mjs +2 -15
  195. package/dist/esm/hooks/useMedia.mjs.map +1 -1
  196. package/dist/esm/hooks/useMedia.native.js +2 -15
  197. package/dist/esm/hooks/useMedia.native.js.map +1 -1
  198. package/dist/esm/hooks/useProps.mjs +7 -5
  199. package/dist/esm/hooks/useProps.mjs.map +1 -1
  200. package/dist/esm/hooks/useProps.native.js +7 -5
  201. package/dist/esm/hooks/useProps.native.js.map +1 -1
  202. package/dist/esm/hooks/useSplitStyles.mjs +17 -0
  203. package/dist/esm/hooks/useSplitStyles.mjs.map +1 -0
  204. package/dist/esm/hooks/useSplitStyles.native.js +14 -0
  205. package/dist/esm/hooks/useSplitStyles.native.js.map +1 -0
  206. package/dist/esm/index.js +57 -137
  207. package/dist/esm/index.mjs +57 -137
  208. package/dist/esm/index.native.js +57 -137
  209. package/dist/esm/insertFont.mjs +1 -1
  210. package/dist/esm/insertFont.mjs.map +1 -1
  211. package/dist/esm/insertFont.native.js +1 -0
  212. package/dist/esm/insertFont.native.js.map +1 -1
  213. package/dist/esm/internal-runtime.mjs +23 -4
  214. package/dist/esm/internal-runtime.mjs.map +1 -1
  215. package/dist/esm/internal-runtime.native.js +23 -4
  216. package/dist/esm/internal-runtime.native.js.map +1 -1
  217. package/dist/esm/setupReactNative.mjs +1 -29
  218. package/dist/esm/setupReactNative.mjs.map +1 -1
  219. package/dist/esm/setupReactNative.native.js +1 -3
  220. package/dist/esm/setupReactNative.native.js.map +1 -1
  221. package/dist/esm/static-resolve.mjs +194 -0
  222. package/dist/esm/static-resolve.mjs.map +1 -0
  223. package/dist/esm/static-resolve.native.js +205 -0
  224. package/dist/esm/static-resolve.native.js.map +1 -0
  225. package/dist/esm/styled.mjs +24 -40
  226. package/dist/esm/styled.mjs.map +1 -1
  227. package/dist/esm/styled.native.js +23 -40
  228. package/dist/esm/styled.native.js.map +1 -1
  229. package/dist/esm/views/TamaguiProvider.mjs +4 -8
  230. package/dist/esm/views/TamaguiProvider.mjs.map +1 -1
  231. package/dist/esm/views/TamaguiProvider.native.js +4 -8
  232. package/dist/esm/views/TamaguiProvider.native.js.map +1 -1
  233. package/dist/esm/views/ThemeUpdate.mjs +1 -1
  234. package/dist/esm/views/ThemeUpdate.mjs.map +1 -1
  235. package/dist/esm/views/ThemeUpdate.native.js +1 -1
  236. package/dist/esm/views/ThemeUpdate.native.js.map +1 -1
  237. package/package.json +25 -15
  238. package/reset.css +3 -3
  239. package/src/createComponent.tsx +175 -192
  240. package/src/createTamagui.ts +10 -9
  241. package/src/helpers/defaultAnimationDriver.tsx +0 -1
  242. package/src/helpers/directStyleCSS.native.ts +1 -0
  243. package/src/helpers/directStyleCSS.ts +534 -0
  244. package/src/helpers/directStyleCSSCompiled.ts +32 -0
  245. package/src/helpers/getCSSStylesAtomic.ts +168 -88
  246. package/src/helpers/getCSSStylesAtomicCompiled.ts +9 -0
  247. package/src/helpers/getSplitStyles.tsx +4653 -1003
  248. package/src/helpers/getVariantExtras.tsx +15 -3
  249. package/src/helpers/insertStyleRule.tsx +4 -2
  250. package/src/helpers/mediaState.ts +15 -0
  251. package/src/helpers/normalizeStyle.ts +27 -2
  252. package/src/helpers/resolveRem.ts +1 -1
  253. package/src/helpers/skipProps.ts +3 -0
  254. package/src/helpers/styleFrontend.ts +20 -27
  255. package/src/helpers/styleToCSS.native.ts +1 -0
  256. package/src/helpers/styleToCSS.ts +43 -0
  257. package/src/helpers/subscribeToContextGroup.tsx +30 -0
  258. package/src/helpers/variables.ts +2 -1
  259. package/src/helpers/warnOnce.ts +3 -4
  260. package/src/helpers/wrapStyleTags.tsx +1 -1
  261. package/src/hooks/useComponentState.ts +118 -158
  262. package/src/hooks/useMedia.tsx +2 -18
  263. package/src/hooks/useProps.tsx +19 -15
  264. package/src/hooks/useSplitStyles.tsx +26 -0
  265. package/src/index.ts +298 -73
  266. package/src/insertFont.ts +5 -1
  267. package/src/internal-runtime.ts +49 -24
  268. package/src/internalRuntimeTypes.ts +2 -7
  269. package/src/setupReactNative.ts +7 -30
  270. package/src/static-resolve.ts +396 -0
  271. package/src/styled.tsx +34 -11
  272. package/src/types.tsx +40 -30
  273. package/src/views/TamaguiProvider.tsx +23 -22
  274. package/src/views/ThemeUpdate.tsx +3 -1
  275. package/types/createComponent.d.ts.map +1 -1
  276. package/types/createTamagui.d.ts.map +1 -1
  277. package/types/helpers/defaultAnimationDriver.d.ts.map +1 -1
  278. package/types/helpers/directStyleCSS.d.ts +28 -0
  279. package/types/helpers/directStyleCSS.d.ts.map +1 -0
  280. package/types/helpers/directStyleCSS.native.d.ts +2 -0
  281. package/types/helpers/directStyleCSS.native.d.ts.map +1 -0
  282. package/types/helpers/directStyleCSSCompiled.d.ts +10 -0
  283. package/types/helpers/directStyleCSSCompiled.d.ts.map +1 -0
  284. package/types/helpers/getCSSStylesAtomic.d.ts +22 -1
  285. package/types/helpers/getCSSStylesAtomic.d.ts.map +1 -1
  286. package/types/helpers/getCSSStylesAtomicCompiled.d.ts +4 -0
  287. package/types/helpers/getCSSStylesAtomicCompiled.d.ts.map +1 -0
  288. package/types/helpers/getSplitStyles.d.ts +11 -4
  289. package/types/helpers/getSplitStyles.d.ts.map +1 -1
  290. package/types/helpers/getVariantExtras.d.ts.map +1 -1
  291. package/types/helpers/insertStyleRule.d.ts.map +1 -1
  292. package/types/helpers/mediaState.d.ts +4 -0
  293. package/types/helpers/mediaState.d.ts.map +1 -1
  294. package/types/helpers/normalizeStyle.d.ts +1 -1
  295. package/types/helpers/normalizeStyle.d.ts.map +1 -1
  296. package/types/helpers/skipProps.d.ts +2 -0
  297. package/types/helpers/skipProps.d.ts.map +1 -1
  298. package/types/helpers/styleFrontend.d.ts +13 -17
  299. package/types/helpers/styleFrontend.d.ts.map +1 -1
  300. package/types/helpers/styleToCSS.d.ts +2 -0
  301. package/types/helpers/styleToCSS.d.ts.map +1 -0
  302. package/types/helpers/styleToCSS.native.d.ts +2 -0
  303. package/types/helpers/styleToCSS.native.d.ts.map +1 -0
  304. package/types/helpers/subscribeToContextGroup.d.ts +1 -0
  305. package/types/helpers/subscribeToContextGroup.d.ts.map +1 -1
  306. package/types/helpers/variables.d.ts.map +1 -1
  307. package/types/helpers/warnOnce.d.ts.map +1 -1
  308. package/types/helpers/webPropsToSkip.native.d.ts +5 -0
  309. package/types/helpers/webPropsToSkip.native.d.ts.map +1 -1
  310. package/types/hooks/useComponentState.d.ts +3 -2
  311. package/types/hooks/useComponentState.d.ts.map +1 -1
  312. package/types/hooks/useMedia.d.ts +1 -5
  313. package/types/hooks/useMedia.d.ts.map +1 -1
  314. package/types/hooks/useProps.d.ts.map +1 -1
  315. package/types/hooks/useSplitStyles.d.ts +3 -0
  316. package/types/hooks/useSplitStyles.d.ts.map +1 -0
  317. package/types/index.d.ts +58 -72
  318. package/types/index.d.ts.map +1 -1
  319. package/types/insertFont.d.ts.map +1 -1
  320. package/types/internal-runtime.d.ts +24 -11
  321. package/types/internal-runtime.d.ts.map +1 -1
  322. package/types/internalRuntimeTypes.d.ts +1 -6
  323. package/types/internalRuntimeTypes.d.ts.map +1 -1
  324. package/types/setupReactNative.d.ts +2 -3
  325. package/types/setupReactNative.d.ts.map +1 -1
  326. package/types/static-resolve.d.ts +79 -0
  327. package/types/static-resolve.d.ts.map +1 -0
  328. package/types/styled.d.ts.map +1 -1
  329. package/types/types.d.ts +29 -22
  330. package/types/types.d.ts.map +1 -1
  331. package/types/views/TamaguiProvider.d.ts.map +1 -1
  332. package/types/views/ThemeUpdate.d.ts.map +1 -1
  333. package/dist/cjs/constants/accessibilityDirectMap.cjs +0 -34
  334. package/dist/cjs/constants/accessibilityDirectMap.native.cjs +0 -36
  335. package/dist/cjs/constants/accessibilityDirectMap.native.js +0 -38
  336. package/dist/cjs/constants/accessibilityDirectMap.native.js.map +0 -1
  337. package/dist/cjs/helpers/directStyle.cjs +0 -962
  338. package/dist/cjs/helpers/directStyle.native.cjs +0 -1165
  339. package/dist/cjs/helpers/directStyle.native.js +0 -1167
  340. package/dist/cjs/helpers/directStyle.native.js.map +0 -1
  341. package/dist/cjs/helpers/frontendProgram.cjs +0 -43
  342. package/dist/cjs/helpers/frontendProgram.native.cjs +0 -49
  343. package/dist/cjs/helpers/frontendProgram.native.js +0 -51
  344. package/dist/cjs/helpers/frontendProgram.native.js.map +0 -1
  345. package/dist/cjs/helpers/getFontLanguage.native.js.map +0 -1
  346. package/dist/cjs/helpers/normalizeStylePropKeys.native.cjs +0 -37
  347. package/dist/cjs/helpers/normalizeStylePropKeys.native.js +0 -39
  348. package/dist/cjs/helpers/normalizeStylePropKeys.native.js.map +0 -1
  349. package/dist/cjs/helpers/propMapper.cjs +0 -384
  350. package/dist/cjs/helpers/propMapper.native.cjs +0 -536
  351. package/dist/cjs/helpers/propMapper.native.js +0 -538
  352. package/dist/cjs/helpers/propMapper.native.js.map +0 -1
  353. package/dist/cjs/helpers/useRenderElement.cjs +0 -47
  354. package/dist/cjs/helpers/useRenderElement.native.cjs +0 -53
  355. package/dist/cjs/helpers/useRenderElement.native.js +0 -55
  356. package/dist/cjs/helpers/useRenderElement.native.js.map +0 -1
  357. package/dist/esm/constants/accessibilityDirectMap.mjs +0 -8
  358. package/dist/esm/constants/accessibilityDirectMap.mjs.map +0 -1
  359. package/dist/esm/constants/accessibilityDirectMap.native.js +0 -8
  360. package/dist/esm/constants/accessibilityDirectMap.native.js.map +0 -1
  361. package/dist/esm/helpers/directStyle.mjs +0 -929
  362. package/dist/esm/helpers/directStyle.mjs.map +0 -1
  363. package/dist/esm/helpers/directStyle.native.js +0 -1132
  364. package/dist/esm/helpers/directStyle.native.js.map +0 -1
  365. package/dist/esm/helpers/frontendProgram.mjs +0 -20
  366. package/dist/esm/helpers/frontendProgram.mjs.map +0 -1
  367. package/dist/esm/helpers/frontendProgram.native.js +0 -24
  368. package/dist/esm/helpers/frontendProgram.native.js.map +0 -1
  369. package/dist/esm/helpers/getFontLanguage.mjs +0 -4
  370. package/dist/esm/helpers/getFontLanguage.mjs.map +0 -1
  371. package/dist/esm/helpers/getFontLanguage.native.js +0 -6
  372. package/dist/esm/helpers/getFontLanguage.native.js.map +0 -1
  373. package/dist/esm/helpers/normalizeStylePropKeys.mjs +0 -4
  374. package/dist/esm/helpers/normalizeStylePropKeys.mjs.map +0 -1
  375. package/dist/esm/helpers/normalizeStylePropKeys.native.js +0 -15
  376. package/dist/esm/helpers/normalizeStylePropKeys.native.js.map +0 -1
  377. package/dist/esm/helpers/propMapper.mjs +0 -360
  378. package/dist/esm/helpers/propMapper.mjs.map +0 -1
  379. package/dist/esm/helpers/propMapper.native.js +0 -511
  380. package/dist/esm/helpers/propMapper.native.js.map +0 -1
  381. package/dist/esm/helpers/useRenderElement.mjs +0 -26
  382. package/dist/esm/helpers/useRenderElement.mjs.map +0 -1
  383. package/dist/esm/helpers/useRenderElement.native.js +0 -31
  384. package/dist/esm/helpers/useRenderElement.native.js.map +0 -1
  385. package/src/constants/accessibilityDirectMap.native.tsx +0 -10
  386. package/src/constants/accessibilityDirectMap.tsx +0 -11
  387. package/src/helpers/directStyle.ts +0 -2294
  388. package/src/helpers/frontendProgram.ts +0 -48
  389. package/src/helpers/getFontLanguage.ts +0 -2
  390. package/src/helpers/normalizeStylePropKeys.native.ts +0 -12
  391. package/src/helpers/normalizeStylePropKeys.ts +0 -3
  392. package/src/helpers/propMapper.ts +0 -721
  393. package/src/helpers/useRenderElement.tsx +0 -73
  394. package/types/constants/accessibilityDirectMap.d.ts +0 -6
  395. package/types/constants/accessibilityDirectMap.d.ts.map +0 -1
  396. package/types/constants/accessibilityDirectMap.native.d.ts +0 -6
  397. package/types/constants/accessibilityDirectMap.native.d.ts.map +0 -1
  398. package/types/helpers/directStyle.d.ts +0 -15
  399. package/types/helpers/directStyle.d.ts.map +0 -1
  400. package/types/helpers/frontendProgram.d.ts +0 -10
  401. package/types/helpers/frontendProgram.d.ts.map +0 -1
  402. package/types/helpers/getFontLanguage.d.ts +0 -2
  403. package/types/helpers/getFontLanguage.d.ts.map +0 -1
  404. package/types/helpers/normalizeStylePropKeys.d.ts +0 -2
  405. package/types/helpers/normalizeStylePropKeys.d.ts.map +0 -1
  406. package/types/helpers/normalizeStylePropKeys.native.d.ts +0 -13
  407. package/types/helpers/normalizeStylePropKeys.native.d.ts.map +0 -1
  408. package/types/helpers/propMapper.d.ts +0 -6
  409. package/types/helpers/propMapper.d.ts.map +0 -1
  410. package/types/helpers/useRenderElement.d.ts +0 -13
  411. package/types/helpers/useRenderElement.d.ts.map +0 -1
@@ -1,2294 +0,0 @@
1
- import {
2
- isAndroid,
3
- isIos,
4
- isTV,
5
- isWeb,
6
- supportsDynamicColorIOS,
7
- } from '@tamagui/constants'
8
- import {
9
- StyleObjectIdentifier,
10
- StyleObjectRules,
11
- nonAnimatableStyleProps,
12
- tokenCategories,
13
- type StyleObject,
14
- } from '@tamagui/helpers'
15
- import {
16
- canonicalStateModifierNames,
17
- isContainerSizeQueryText,
18
- isModifierName,
19
- modifierKindMedia,
20
- modifierKindPlatform,
21
- modifierKindState,
22
- modifierKindTheme,
23
- scanFlatValue,
24
- stateModifierSelectors,
25
- type ClausePrecedenceKey,
26
- type FlatValueHandler,
27
- type ParsedValue,
28
- } from '@tamagui/style-grammar/runtime'
29
-
30
- import { isVariable } from '../createVariable'
31
- import { mediaKeyMatch } from '../hooks/useMedia'
32
- import type { GetStyleState } from '../types'
33
- import { warnOnce, warnRefusedValue } from './warnOnce'
34
- import { expandStyle } from './expandStyle'
35
- import { getCSSStyleAtomic } from './getCSSStylesAtomic'
36
- import { getConfigRevisionState } from './grammarConfig'
37
- import { isColorStyleKey } from './getDynamicVal'
38
- import { shouldInsertStyleRules, updateRules } from './insertStyleRule'
39
- import { normalizeColor } from './normalizeColor'
40
- import { parseNativeStyle } from './parseNativeStyle.native'
41
- import { parseNativeTransform } from './parseNativeTransform.native'
42
- import { getTokenCategoryForProperty, tokenCategoryByProperty } from './tokenCategories'
43
- import { resolveSafeAreaVariable } from './resolveSafeAreaVariable'
44
- import { expandSafeAreaValue, isSafeAreaKey } from './resolveSafeArea'
45
- import { resolveVariableValue } from './resolveVariableValue'
46
- import { THEME_REF_PREFIX } from './themeRef'
47
- import { transformsToString } from './transformsToString'
48
-
49
- export type MergeStyle = (
50
- state: GetStyleState,
51
- key: string,
52
- value: any,
53
- importance: number,
54
- disableNormalize?: boolean,
55
- originalValue?: any
56
- ) => void
57
-
58
- type DirectAtomic = {
59
- baseRules: number
60
- conditions?: Record<
61
- string,
62
- {
63
- count: number
64
- index: number
65
- precedence: ClausePrecedenceKey
66
- default?: boolean
67
- }
68
- >
69
- signature: string
70
- styleObject: StyleObject
71
- }
72
-
73
- type DirectState = GetStyleState & {
74
- flatAtomics?: Record<string, DirectAtomic>
75
- flatBoxShadow?: any
76
- flatDynamicColors?: Record<string, Record<string, any>>
77
- flatDynamicThemeAccess?: boolean
78
- flatLegacyTransforms?: Record<string, any>
79
- flatPrecedence?: Record<string, ClausePrecedenceKey>
80
- flatTextShadow?: Record<string, any>
81
- flatWebShadow?: Record<string, any>
82
- }
83
-
84
- const directStyleHandler: FlatValueHandler<GetStyleState> = {
85
- segment(
86
- state,
87
- start,
88
- end,
89
- isBase,
90
- valid,
91
- source,
92
- chainStart,
93
- chainEnd,
94
- chainValid,
95
- chainCount,
96
- _result,
97
- failure,
98
- failureIndex,
99
- property,
100
- merge,
101
- originalValue,
102
- contextOnly
103
- ) {
104
- if (isBase) {
105
- if (start === end) return
106
- if (!valid) {
107
- if (process.env.NODE_ENV === 'development') {
108
- warnRefusedValue(
109
- property,
110
- source,
111
- failure === 'invalid-character'
112
- ? `"${source[failureIndex]}" would end the declaration or rule`
113
- : failure === 'unterminated-string'
114
- ? 'an unterminated string'
115
- : failure === 'unterminated-comment'
116
- ? 'an unterminated "/*" comment'
117
- : failure === 'stray-comment-close'
118
- ? 'a stray "*/"'
119
- : 'an unterminated "("'
120
- )
121
- }
122
- return
123
- }
124
- const value = source.slice(start, end)
125
- emitValue(
126
- state,
127
- property,
128
- value,
129
- 0,
130
- '',
131
- undefined,
132
- '',
133
- '',
134
- merge,
135
- value,
136
- contextOnly
137
- )
138
- return 5
139
- }
140
- if (!chainValid) {
141
- if (process.env.NODE_ENV === 'development') {
142
- warnRefusedValue(
143
- property,
144
- source,
145
- failure === 'invalid-character'
146
- ? `"${source[failureIndex]}" would end the declaration or rule`
147
- : failure === 'unterminated-string'
148
- ? 'an unterminated string'
149
- : failure === 'unterminated-comment'
150
- ? 'an unterminated "/*" comment'
151
- : failure === 'stray-comment-close'
152
- ? 'a stray "*/"'
153
- : 'an unterminated "("'
154
- )
155
- }
156
- return
157
- }
158
- if (start === end) {
159
- if (process.env.NODE_ENV === 'development') {
160
- warnRefusedValue(property, source, 'a conditional clause has no value')
161
- }
162
- return
163
- }
164
- if (property === 'aspectRatio' && chainCount === 1) {
165
- const left = Number(source.slice(chainStart, chainEnd))
166
- const right = Number(source.slice(start, end))
167
- if (
168
- chainStart < chainEnd &&
169
- Number.isFinite(left) &&
170
- left > 0 &&
171
- Number.isFinite(right) &&
172
- right > 0
173
- ) {
174
- return 12
175
- }
176
- }
177
- const condition = resolveClauseChain(
178
- state,
179
- source,
180
- chainStart,
181
- chainEnd,
182
- property,
183
- undefined,
184
- valid ? merge : undefined,
185
- undefined,
186
- contextOnly,
187
- start,
188
- end,
189
- 1
190
- )
191
- if (!condition) return
192
- if (!valid) {
193
- if (process.env.NODE_ENV === 'development') {
194
- warnRefusedValue(
195
- property,
196
- source,
197
- failure === 'invalid-character'
198
- ? `"${source[failureIndex]}" would end the declaration or rule`
199
- : failure === 'unterminated-string'
200
- ? 'an unterminated string'
201
- : failure === 'unterminated-comment'
202
- ? 'an unterminated "/*" comment'
203
- : failure === 'stray-comment-close'
204
- ? 'a stray "*/"'
205
- : 'an unterminated "("'
206
- )
207
- }
208
- return
209
- }
210
- return 4 | (condition & 12 ? 2 : 0)
211
- },
212
- chain() {
213
- return true
214
- },
215
- end(
216
- state,
217
- source,
218
- result,
219
- lastPayloadStart,
220
- chainCount,
221
- property,
222
- merge,
223
- originalValue,
224
- contextOnly
225
- ) {
226
- let hasBase = !!(result & 1)
227
- if (result & 8 && chainCount === 1) {
228
- emitValue(
229
- state,
230
- property,
231
- source,
232
- 0,
233
- '',
234
- undefined,
235
- '',
236
- '',
237
- merge,
238
- originalValue ?? source,
239
- contextOnly
240
- )
241
- hasBase = true
242
- }
243
- if (
244
- process.env.NODE_ENV === 'development' &&
245
- !hasBase &&
246
- result & 4 &&
247
- (property in tokenCategories.color || property in tokenCategoryByProperty) &&
248
- splitComponents(source.slice(lastPayloadStart)).length > 1
249
- ) {
250
- warnOnce(
251
- `${property}="${source}" has multiple values after its first conditional. Write the base value before the first conditional.`
252
- )
253
- }
254
- if ((!isWeb || !state.flatShouldDoClasses) && result & 2 && !hasBase) {
255
- const value = implicitLifecycleBase(property)
256
- if (value !== null) {
257
- emitValue(
258
- state,
259
- property,
260
- value,
261
- 0,
262
- '',
263
- undefined,
264
- '',
265
- '',
266
- merge,
267
- value,
268
- contextOnly
269
- )
270
- }
271
- }
272
- },
273
- }
274
-
275
- // enter/exit clauses with no authored base animate from the property's natural
276
- // resting value on the inline-style path (the class path reads it from the
277
- // cascade instead)
278
- function implicitLifecycleBase(property: string): string | number | null {
279
- return property === 'opacity' ||
280
- property === 'scale' ||
281
- property === 'scaleX' ||
282
- property === 'scaleY'
283
- ? 1
284
- : property === 'rotate'
285
- ? '0deg'
286
- : property === 'x' || property === 'y'
287
- ? 0
288
- : null
289
- }
290
-
291
- const legacyTransformParts = new Set([
292
- 'matrix',
293
- 'perspective',
294
- 'rotateX',
295
- 'rotateY',
296
- 'rotateZ',
297
- 'scaleZ',
298
- 'skewX',
299
- 'skewY',
300
- ])
301
-
302
- const webShadowParts = new Set([
303
- 'shadowColor',
304
- 'shadowOffset',
305
- 'shadowOpacity',
306
- 'shadowRadius',
307
- ])
308
-
309
- const webTextShadowParts = new Set([
310
- 'textShadowColor',
311
- 'textShadowOffset',
312
- 'textShadowRadius',
313
- ])
314
-
315
- const lineStyles = new Set([
316
- 'none',
317
- 'hidden',
318
- 'dotted',
319
- 'dashed',
320
- 'solid',
321
- 'double',
322
- 'groove',
323
- 'ridge',
324
- 'inset',
325
- 'outset',
326
- ])
327
-
328
- const borderTargets: Record<
329
- string,
330
- { width: string[]; style: string[]; color: string[] }
331
- > = {
332
- border: {
333
- width: ['borderTopWidth', 'borderRightWidth', 'borderBottomWidth', 'borderLeftWidth'],
334
- style: ['borderTopStyle', 'borderRightStyle', 'borderBottomStyle', 'borderLeftStyle'],
335
- color: ['borderTopColor', 'borderRightColor', 'borderBottomColor', 'borderLeftColor'],
336
- },
337
- borderTop: {
338
- width: ['borderTopWidth'],
339
- style: ['borderTopStyle'],
340
- color: ['borderTopColor'],
341
- },
342
- borderRight: {
343
- width: ['borderRightWidth'],
344
- style: ['borderRightStyle'],
345
- color: ['borderRightColor'],
346
- },
347
- borderBottom: {
348
- width: ['borderBottomWidth'],
349
- style: ['borderBottomStyle'],
350
- color: ['borderBottomColor'],
351
- },
352
- borderLeft: {
353
- width: ['borderLeftWidth'],
354
- style: ['borderLeftStyle'],
355
- color: ['borderLeftColor'],
356
- },
357
- outline: {
358
- width: ['outlineWidth'],
359
- style: ['outlineStyle'],
360
- color: ['outlineColor'],
361
- },
362
- borderBlock: {
363
- width: ['borderBlockStartWidth', 'borderBlockEndWidth'],
364
- style: ['borderBlockStartStyle', 'borderBlockEndStyle'],
365
- color: ['borderBlockStartColor', 'borderBlockEndColor'],
366
- },
367
- borderInline: {
368
- width: ['borderInlineStartWidth', 'borderInlineEndWidth'],
369
- style: ['borderInlineStartStyle', 'borderInlineEndStyle'],
370
- color: ['borderInlineStartColor', 'borderInlineEndColor'],
371
- },
372
- }
373
-
374
- const borderStyleDefaults: Record<string, string> = {
375
- borderWidth: 'borderStyle',
376
- borderTopWidth: 'borderTopStyle',
377
- borderRightWidth: 'borderRightStyle',
378
- borderBottomWidth: 'borderBottomStyle',
379
- borderLeftWidth: 'borderLeftStyle',
380
- }
381
-
382
- export function platformMatches(name: string): boolean {
383
- if (name === 'web') return isWeb
384
- if (name === 'native') return !isWeb
385
- if (name === 'ios') return isIos
386
- if (name === 'android') return isAndroid
387
- if (name === 'tvos') return isIos && isTV
388
- if (name === 'androidtv') return isAndroid && isTV
389
- return name === 'tv' && isTV
390
- }
391
-
392
- export function resolveClauseChain(
393
- state: GetStyleState,
394
- source: string,
395
- start: number,
396
- end: number,
397
- property?: string,
398
- raw?: any,
399
- merge?: MergeStyle,
400
- originalValue?: any,
401
- contextOnly = false,
402
- payloadStart = -1,
403
- payloadEnd = -1,
404
- warning = 0
405
- ): number {
406
- const compiled = getConfigRevisionState(state.conf)
407
- const sourceStart = start
408
- let key = ''
409
- let active = true
410
- let emit = true
411
- let selector = ''
412
- let wrappers: string[] | undefined
413
- let theme = ''
414
- let enter = false
415
- let exit = false
416
- let unsupportedState = ''
417
- let platformRank = 0
418
- let depth = 0
419
- let categoryRank = 0
420
- let withinRank = 0
421
- let selfStateSpecificity = 0
422
- for (let index = start; index <= end; index++) {
423
- if (index !== end && source.charCodeAt(index) !== 58) continue
424
- let modifier = source.slice(start, index)
425
- start = index + 1
426
- let code = compiled.modifiers[modifier]
427
- let kind = code & 7
428
- let rank = code >> 3
429
- let stateSelector = ''
430
- let conditionStateName = ''
431
- let groupName = ''
432
- let containerSize = ''
433
- let containerName = ''
434
- let containerQuery = ''
435
- if (kind === modifierKindState) {
436
- modifier = canonicalStateModifierNames[rank]
437
- stateSelector = stateModifierSelectors[rank]
438
- } else if (!kind && modifier.startsWith('group-')) {
439
- const slash = modifier.indexOf('/')
440
- const authoredState = modifier.slice(6, slash === -1 ? undefined : slash)
441
- code = compiled.modifiers[authoredState]
442
- if ((code & 7) !== modifierKindState) kind = 0
443
- else {
444
- rank = code >> 3
445
- groupName = slash === -1 ? 'true' : modifier.slice(slash + 1)
446
- if (
447
- rank === 6 ||
448
- rank === 7 ||
449
- (slash !== -1 && !isModifierName(groupName, 0, groupName.length))
450
- ) {
451
- kind = 0
452
- } else {
453
- kind = 5
454
- const stateName = canonicalStateModifierNames[rank]
455
- conditionStateName = stateName
456
- stateSelector = stateModifierSelectors[rank]
457
- modifier = `group-${stateName}${slash === -1 ? '' : modifier.slice(slash)}`
458
- }
459
- }
460
- } else if (!kind && modifier.charCodeAt(0) === 64) {
461
- const slash = modifier.indexOf('/')
462
- containerSize = modifier.slice(1, slash === -1 ? undefined : slash)
463
- containerName = slash === -1 ? '' : modifier.slice(slash + 1)
464
- if (
465
- isModifierName(containerSize, 0, containerSize.length) &&
466
- (slash === -1 || isModifierName(containerName, 0, containerName.length)) &&
467
- ((code = compiled.modifiers[containerSize]) & 7) === modifierKindMedia &&
468
- (containerQuery = compiled.mediaQueries[containerSize]) &&
469
- isContainerSizeQueryText(containerQuery)
470
- ) {
471
- kind = 6
472
- rank = code >> 3
473
- }
474
- }
475
- if (!kind) {
476
- if (warning && process.env.NODE_ENV === 'development') {
477
- warnRefusedValue(
478
- property!,
479
- warning === 1 ? source : raw,
480
- `unknown modifier "${source.slice(sourceStart, end)}"`
481
- )
482
- }
483
- return 0
484
- }
485
-
486
- let slotStart = 0
487
- let duplicate = false
488
- let inserted = !key
489
- if (!key) key = modifier
490
- else {
491
- while (slotStart <= key.length) {
492
- let slotEnd = key.indexOf(':', slotStart)
493
- if (slotEnd === -1) slotEnd = key.length
494
- let order = 0
495
- const compareLength = Math.min(modifier.length, slotEnd - slotStart)
496
- for (let offset = 0; offset < compareLength; offset++) {
497
- order = modifier.charCodeAt(offset) - key.charCodeAt(slotStart + offset)
498
- if (order) break
499
- }
500
- order ||= modifier.length - (slotEnd - slotStart)
501
- if (!order) {
502
- duplicate = true
503
- break
504
- }
505
- if (order < 0) {
506
- key = `${key.slice(0, slotStart)}${modifier}:${key.slice(slotStart)}`
507
- inserted = true
508
- break
509
- }
510
- if (slotEnd === key.length) break
511
- slotStart = slotEnd + 1
512
- }
513
- if (!duplicate && !inserted) key += `:${modifier}`
514
- }
515
- if (duplicate) continue
516
-
517
- if (kind === modifierKindPlatform) {
518
- if (rank > platformRank) platformRank = rank
519
- const matches = platformMatches(modifier)
520
- active &&= matches
521
- emit &&= matches
522
- continue
523
- }
524
- depth++
525
- const nextCategory =
526
- kind === modifierKindMedia
527
- ? 0
528
- : kind === 6
529
- ? 1
530
- : kind === modifierKindTheme
531
- ? 2
532
- : kind === 5
533
- ? 3
534
- : 4
535
- if (nextCategory > categoryRank) {
536
- categoryRank = nextCategory
537
- withinRank = rank
538
- } else if (nextCategory === categoryRank && rank > withinRank) {
539
- withinRank = rank
540
- }
541
-
542
- if (kind === modifierKindMedia) {
543
- const query = compiled.mediaQueries[modifier]
544
- if (!query) return 0
545
- ;(wrappers ||= []).push(`@media ${query}`)
546
- active &&= !!state.flatMediaState?.[modifier]
547
- ;(state.flatMediaKeys ||= new Set()).add(modifier)
548
- } else if (kind === modifierKindTheme) {
549
- theme = modifier
550
- selector += `:where(.t_${modifier}, .t_${modifier} *)`
551
- active &&=
552
- state.flatThemeName === modifier ||
553
- state.flatThemeName?.startsWith(`${modifier}_`) === true
554
- } else if (kind === 5) {
555
- selector += `:where(.t_group_${groupName}${stateSelector} *)`
556
- if (rank === 0) (wrappers ||= []).push('@media (hover: hover)')
557
- const component = state.componentState.group?.[groupName]
558
- const context = state.flatGroupContext?.[groupName]
559
- active &&= !!(component?.pseudo ?? context?.state.pseudo)?.[conditionStateName]
560
- ;(state.flatGroupKeys ||= new Set()).add(groupName)
561
- } else if (kind === 6) {
562
- const groupKey = `@${containerName}`
563
- ;(wrappers ||= []).push(
564
- containerName
565
- ? `@container ${containerName} ${containerQuery}`
566
- : `@container ${containerQuery}`
567
- )
568
- const component = state.componentState.group?.[groupKey]
569
- const context = state.flatGroupContext?.[groupKey]
570
- const match = component?.media?.[containerSize]
571
- active &&=
572
- match === undefined
573
- ? !!(
574
- context?.state.layout && mediaKeyMatch(containerSize, context.state.layout)
575
- )
576
- : !!match
577
- ;(state.flatGroupKeys ||= new Set()).add(groupKey)
578
- ;(state.flatGroupMedia ||= new Set()).add(containerSize)
579
- } else {
580
- selfStateSpecificity++
581
- if (!isWeb && stateSelector[0] === '[' && modifier !== 'disabled') {
582
- unsupportedState = modifier
583
- }
584
- if (stateSelector[0] === '.') {
585
- selector += `:is(${stateSelector}, ${stateSelector} *)`
586
- if (rank === 6) enter = true
587
- else exit = true
588
- } else {
589
- selector += stateSelector
590
- }
591
- if (rank === 0) (wrappers ||= []).push('@media (hover: hover)')
592
- const component = state.componentState
593
- active &&=
594
- rank === 0
595
- ? !!component.hover
596
- : rank === 4
597
- ? !!(component.press || component.pressIn)
598
- : rank === 2
599
- ? !!component.focus
600
- : rank === 3
601
- ? !!component.focusVisible
602
- : rank === 1
603
- ? !!component.focusWithin
604
- : rank === 5
605
- ? !!(component.disabled || state.props.disabled)
606
- : rank === 6
607
- ? !!component.unmounted
608
- : rank === 7
609
- ? !!state.styleProps.isExiting
610
- : false
611
- if (stateSelector[0] === ':') {
612
- ;(state.flatStateKeys ||= new Set()).add(modifier)
613
- }
614
- }
615
- }
616
- if (depth > 5) {
617
- throw new Error(
618
- `a flat value clause supports at most 5 non-platform conditions; received ${depth} in "${source.slice(sourceStart, end)}:"`
619
- )
620
- }
621
- const precedence =
622
- (platformRank << 26) | (depth << 23) | (categoryRank << 20) | withinRank
623
- const condition =
624
- precedence * 256 +
625
- selfStateSpecificity * 32 +
626
- 16 +
627
- (active ? 1 : 0) +
628
- (emit ? 2 : 0) +
629
- (enter ? 4 : 0) +
630
- (exit ? 8 : 0)
631
- if (warning && unsupportedState && process.env.NODE_ENV === 'development') {
632
- warnOnce(
633
- `${property}: "${unsupportedState}:" has no native component-state source; dropping the clause`
634
- )
635
- }
636
- if (
637
- merge &&
638
- property &&
639
- condition & 2 &&
640
- (condition & 1 ||
641
- (isWeb && state.flatShouldDoClasses) ||
642
- (warning === 1 &&
643
- !isWeb &&
644
- theme &&
645
- supportsDynamicColorIOS &&
646
- isColorStyleKey(property)))
647
- ) {
648
- const value = payloadStart === -1 ? raw : source.slice(payloadStart, payloadEnd)
649
- emitValue(
650
- state,
651
- property,
652
- value,
653
- condition,
654
- key,
655
- wrappers,
656
- selector,
657
- theme,
658
- merge,
659
- warning === 2 ? originalValue : (originalValue ?? value),
660
- contextOnly
661
- )
662
- }
663
- return condition
664
- }
665
-
666
- interface TokenLookup {
667
- value: any
668
- /** The value resolved through the active theme, so it changes when the theme does. */
669
- fromTheme: boolean
670
- /** The normalized key the runtime theme object is indexed by. */
671
- themeKey: string
672
- }
673
-
674
- // single reused result object: tokenVariable runs on the style hot path and its
675
- // one caller consumes the result before any re-entry, so this avoids allocating
676
- // per token lookup
677
- const tokenLookup: TokenLookup = { value: undefined, fromTheme: false, themeKey: '' }
678
-
679
- function fillTokenLookup(value: any, fromTheme: boolean, themeKey: string): TokenLookup {
680
- tokenLookup.value = value
681
- tokenLookup.fromTheme = fromTheme
682
- tokenLookup.themeKey = themeKey
683
- return tokenLookup
684
- }
685
-
686
- function tokenVariable(
687
- state: GetStyleState,
688
- property: string,
689
- name: string
690
- ): TokenLookup | undefined {
691
- // v3's canonical token representation is unprefixed, but classic `$token`
692
- // values are still valid input: normalize here so `$background` and
693
- // `background` resolve identically (themes, tokens, and fonts are all
694
- // keyed unprefixed)
695
- let lookupName = name.charCodeAt(0) === 36 ? name.slice(1) : name
696
- if (property === 'fontFamily') {
697
- const family = state.conf.fontsParsed[lookupName]?.family
698
- return family ? fillTokenLookup(family, false, lookupName) : undefined
699
- }
700
- const fontKey =
701
- property === 'fontSize'
702
- ? 'size'
703
- : property === 'fontWeight'
704
- ? 'weight'
705
- : property === 'lineHeight' || property === 'letterSpacing'
706
- ? property
707
- : undefined
708
- if (fontKey) {
709
- const font =
710
- state.conf.fontsParsed[state.fontFamily || state.conf.defaultFontToken] ||
711
- state.conf.fontsParsed[state.conf.defaultFontToken]
712
- const value = font?.[fontKey]?.[lookupName]
713
- return value ? fillTokenLookup(value, false, lookupName) : undefined
714
- }
715
- const category = getTokenCategoryForProperty(property)
716
- const dot = lookupName.indexOf('.')
717
- if (dot !== -1) {
718
- const prefix = lookupName.slice(0, dot)
719
- if (!category || prefix === category || prefix === 'color') {
720
- lookupName = lookupName.slice(dot + 1)
721
- }
722
- }
723
- if (category) {
724
- const own = state.conf.tokensParsed[category]?.[lookupName]
725
- if (own) return fillTokenLookup(own, false, lookupName)
726
- for (const sibling of ['color', 'space', 'size', 'radius', 'zIndex'] as const) {
727
- if (sibling !== category && state.conf.tokensParsed[sibling]?.[lookupName]) return
728
- }
729
- } else {
730
- const first = lookupName.charCodeAt(0)
731
- if ((first >= 48 && first <= 57) || first === 43 || first === 45 || first === 46) {
732
- return
733
- }
734
- }
735
- const theme =
736
- state.theme?.[lookupName] ||
737
- state.conf.themes?.[state.flatThemeName || '']?.[lookupName]
738
- if (theme) return fillTokenLookup(theme, true, lookupName)
739
- if (category) return
740
- const token =
741
- state.conf.tokensParsed.space?.[lookupName] ||
742
- state.conf.tokensParsed.color?.[lookupName]
743
- return token ? fillTokenLookup(token, false, lookupName) : undefined
744
- }
745
-
746
- function configuredValue(state: GetStyleState, property: string, raw: string): any {
747
- let name = raw
748
- let opacity: number | undefined
749
- const slash = raw.lastIndexOf('/')
750
- if (slash > 0) {
751
- const amount = Number(raw.slice(slash + 1))
752
- if (Number.isInteger(amount) && amount >= 0 && amount <= 100) {
753
- name = raw.slice(0, slash)
754
- opacity = amount
755
- }
756
- }
757
-
758
- const safeArea = resolveSafeAreaVariable(name)
759
- if (safeArea !== undefined) {
760
- state.flatUsesSafeArea = true
761
- return safeArea
762
- }
763
-
764
- const lookup = tokenVariable(state, property, name)
765
- if (!lookup || !isVariable(lookup.value)) {
766
- if (
767
- process.env.NODE_ENV === 'development' &&
768
- tokenCategoryByProperty[property] &&
769
- state.conf.tokensParsed.color?.[name]
770
- ) {
771
- warnOnce(`"${name}" contributes to "color", not "${property}"; keeping it literal`)
772
- }
773
- return raw
774
- }
775
- const resolveValues =
776
- isWeb && !state.flatShouldDoClasses && state.styleProps.resolveValues === 'auto'
777
- ? 'value'
778
- : state.styleProps.resolveValues
779
- // the static compiler resolves tokens but keeps theme-backed values symbolic
780
- // so compiled output can read them through the live theme instead of freezing
781
- // the build machine's first theme. an opacity modifier stays in the sentinel,
782
- // which the compiler cannot represent and treats as a runtime-path bailout.
783
- if (resolveValues === 'except-theme' && lookup.fromTheme) {
784
- return `${THEME_REF_PREFIX}${lookup.themeKey}${opacity !== undefined ? `/${opacity}` : ''}`
785
- }
786
- let value = resolveVariableValue(property, lookup.value, resolveValues)
787
- if (opacity !== undefined) {
788
- value = isWeb
789
- ? `color-mix(in srgb, ${value} ${opacity}%, transparent)`
790
- : normalizeColor(value, opacity / 100)
791
- }
792
- return value
793
- }
794
-
795
- // a single function-call literal whose arguments contain no letters
796
- // (rgb(99,102,241), hsl(0,100%,50%)) cannot hold token words; color literals
797
- // like these are common enough on hot paths to be worth skipping the word scan
798
- const letterFreeCallPattern = /^[A-Za-z-]+\([^A-Za-z]*\)$/
799
-
800
- function resolveEmbeddedTokens(state: GetStyleState, property: string, raw: string) {
801
- if (letterFreeCallPattern.test(raw)) return raw
802
- return raw.replace(/[$A-Za-z_][\w.$-]*(?:\/\d+)?/g, (word, index) => {
803
- if (word.charCodeAt(0) !== 36) {
804
- const before = raw.charCodeAt(index - 1)
805
- if (
806
- (before >= 48 && before <= 57) ||
807
- before === 35 ||
808
- (before === 45 && raw.charCodeAt(index - 2) === 45) ||
809
- raw.charCodeAt(index + word.length) === 40
810
- ) {
811
- return word
812
- }
813
- }
814
- const value = configuredValue(state, property, word)
815
- return value === word ? word : String(value)
816
- })
817
- }
818
-
819
- function normalizeTransitionNames(state: GetStyleState, raw: string) {
820
- let quote = 0
821
- let depth = 0
822
- let copyFrom = 0
823
- let out = ''
824
- for (let index = 0; index < raw.length; index++) {
825
- const code = raw.charCodeAt(index)
826
- if (quote) {
827
- if (code === 92) index++
828
- else if (code === quote) quote = 0
829
- continue
830
- }
831
- if (code === 34 || code === 39) {
832
- quote = code
833
- continue
834
- }
835
- if (code === 40) {
836
- depth++
837
- continue
838
- }
839
- if (code === 41) {
840
- depth--
841
- continue
842
- }
843
- if (
844
- depth ||
845
- !((code >= 65 && code <= 90) || (code >= 97 && code <= 122) || code === 95) ||
846
- (index > 1 && raw.charCodeAt(index - 1) === 45 && raw.charCodeAt(index - 2) === 45)
847
- ) {
848
- continue
849
- }
850
- let end = index + 1
851
- while (end < raw.length) {
852
- const next = raw.charCodeAt(end)
853
- if (
854
- (next >= 48 && next <= 57) ||
855
- (next >= 65 && next <= 90) ||
856
- (next >= 97 && next <= 122) ||
857
- next === 45 ||
858
- next === 95
859
- ) {
860
- end++
861
- } else {
862
- break
863
- }
864
- }
865
- if (raw.charCodeAt(end) !== 40) {
866
- const authored = raw.slice(index, end)
867
- let property = state.conf.shorthands[authored] || authored
868
- if (property === 'x' || property === 'y') property = 'translate'
869
- else if (property === 'scaleX' || property === 'scaleY') property = 'scale'
870
- else if (legacyTransformParts.has(property)) property = 'transform'
871
- if (property !== authored || /[A-Z]/.test(property)) {
872
- out += raw.slice(copyFrom, index)
873
- out += property.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)
874
- copyFrom = end
875
- }
876
- }
877
- index = end - 1
878
- }
879
- return copyFrom ? out + raw.slice(copyFrom) : raw
880
- }
881
-
882
- // one contribution's slice of an atomic identity, accumulated per atomicKey
883
- export function directStyleSignature(
884
- property: string,
885
- value: unknown,
886
- conditionKey = ''
887
- ) {
888
- return `\u001f${property}\u001f${conditionKey}\u001e${String(value)}`
889
- }
890
-
891
- function directAtomic(
892
- state: DirectState,
893
- property: string,
894
- value: any,
895
- condition: number,
896
- conditionKey: string,
897
- conditionWrappers: string[] | undefined,
898
- conditionSelector: string,
899
- isDefault = false
900
- ) {
901
- const atomics = (state.flatAtomics ||= {})
902
- const atomicKey = property.startsWith('transition') ? 'transition' : property
903
- const existing = atomics[atomicKey]
904
- const contribution = directStyleSignature(property, value, conditionKey)
905
- const signature = existing ? existing.signature + contribution : contribution
906
- const next = getCSSStyleAtomic(
907
- property,
908
- value,
909
- conditionSelector,
910
- conditionWrappers,
911
- signature,
912
- 2 as any,
913
- atomicKey,
914
- condition
915
- ? 1 +
916
- ((Math.floor(condition / 256) >>> 23) & 7) +
917
- (Math.floor(condition / 256) >>> 26) * 6 -
918
- ((condition >>> 5) & 7)
919
- : undefined
920
- )
921
- if (!next) return
922
- const identifier = next[StyleObjectIdentifier]
923
- const nextRules = next[StyleObjectRules]
924
-
925
- const slotted = condition || atomicKey === 'transition'
926
-
927
- if (!existing) {
928
- // one shape for every DirectAtomic: a conditional object spread here gives
929
- // conditioned and unconditioned atomics different hidden classes, and every
930
- // read of the record downstream goes polymorphic
931
- const atomic: DirectAtomic = {
932
- baseRules: slotted ? 0 : nextRules.length,
933
- conditions: undefined,
934
- signature,
935
- styleObject: next,
936
- }
937
- if (slotted) {
938
- atomic.conditions = {
939
- [atomicKey === 'transition' ? `${conditionKey}\0${property}` : conditionKey]: {
940
- count: nextRules.length,
941
- index: 0,
942
- precedence: condition ? Math.floor(condition / 256) : 0,
943
- default: isDefault,
944
- },
945
- }
946
- }
947
- atomics[atomicKey] = atomic
948
- } else {
949
- const previousIdentifier = existing.styleObject[StyleObjectIdentifier]
950
- // cached rules stay immutable until a same-property contribution needs to
951
- // splice or rewrite them.
952
- const rules = existing.styleObject[StyleObjectRules].slice()
953
- existing.styleObject[StyleObjectRules] = rules
954
- if (!condition && !isDefault && existing.conditions) {
955
- for (const key in existing.conditions) {
956
- const entry = existing.conditions[key]
957
- if (!entry.default) continue
958
- rules.splice(entry.index, entry.count)
959
- delete existing.conditions[key]
960
- for (const otherKey in existing.conditions) {
961
- const other = existing.conditions[otherKey]
962
- if (other.index > entry.index) other.index -= entry.count
963
- }
964
- }
965
- }
966
- if (previousIdentifier !== identifier) {
967
- const oldSelector = `.${previousIdentifier}`
968
- const newSelector = `.${identifier}`
969
- for (let index = 0; index < rules.length; index++) {
970
- rules[index] = rules[index].replaceAll(oldSelector, newSelector)
971
- }
972
- }
973
- if (slotted) {
974
- const slot =
975
- atomicKey === 'transition' ? `${conditionKey}\0${property}` : conditionKey
976
- const previous = existing.conditions?.[slot]
977
- if (previous) {
978
- rules.splice(previous.index, previous.count)
979
- if (existing.conditions) {
980
- for (const key in existing.conditions) {
981
- const entry = existing.conditions[key]
982
- if (entry !== previous && entry.index > previous.index) {
983
- entry.index -= previous.count
984
- }
985
- }
986
- }
987
- delete existing.conditions![slot]
988
- }
989
- const precedence = condition ? Math.floor(condition / 256) : 0
990
- let insertionIndex = rules.length
991
- if (existing.conditions) {
992
- for (const key in existing.conditions) {
993
- const entry = existing.conditions[key]
994
- if (entry.precedence > precedence && entry.index < insertionIndex) {
995
- insertionIndex = entry.index
996
- }
997
- }
998
- for (const key in existing.conditions) {
999
- const entry = existing.conditions[key]
1000
- if (entry.index >= insertionIndex) entry.index += nextRules.length
1001
- }
1002
- }
1003
- ;(existing.conditions ||= {})[slot] = {
1004
- count: nextRules.length,
1005
- index: insertionIndex,
1006
- precedence,
1007
- default: isDefault,
1008
- }
1009
- rules.splice(insertionIndex, 0, ...nextRules)
1010
- } else {
1011
- const difference = nextRules.length - existing.baseRules
1012
- rules.splice(0, existing.baseRules, ...nextRules)
1013
- if (difference && existing.conditions) {
1014
- for (const key in existing.conditions)
1015
- existing.conditions[key].index += difference
1016
- }
1017
- existing.baseRules = nextRules.length
1018
- }
1019
- existing.signature = signature
1020
- existing.styleObject[StyleObjectIdentifier] = identifier
1021
- existing.styleObject[1] = next[1]
1022
- }
1023
- state.classNames[atomicKey] = identifier
1024
- }
1025
-
1026
- function emitBorderStyleDefault(
1027
- state: GetStyleState,
1028
- property: string,
1029
- condition: number,
1030
- conditionKey: string,
1031
- conditionWrappers: string[] | undefined,
1032
- conditionSelector: string
1033
- ) {
1034
- if (!isWeb || !state.flatShouldDoClasses || state.styleProps.noNormalize === false) {
1035
- return
1036
- }
1037
- const target = borderStyleDefaults[property]
1038
- if (!target) return
1039
- const atomic = (state as DirectState).flatAtomics?.[target]
1040
- if (
1041
- atomic?.baseRules ||
1042
- (state.classNames[target] && !atomic) ||
1043
- (condition && atomic?.conditions?.[conditionKey])
1044
- ) {
1045
- return
1046
- }
1047
- directAtomic(
1048
- state as DirectState,
1049
- target,
1050
- 'solid',
1051
- condition,
1052
- conditionKey,
1053
- conditionWrappers,
1054
- conditionSelector,
1055
- true
1056
- )
1057
- }
1058
-
1059
- export function flushDirectStyles(state: GetStyleState, clear = false) {
1060
- const direct = state as DirectState
1061
- const atomics = direct.flatAtomics
1062
- if (!atomics) return
1063
- for (const property in atomics) {
1064
- const styleObject = atomics[property].styleObject
1065
- const identifier = styleObject[StyleObjectIdentifier]
1066
- if (shouldInsertStyleRules(identifier)) {
1067
- // rulesToInsert owns its array; never expose the cache's borrowed copy.
1068
- const rules = styleObject[StyleObjectRules].slice()
1069
- styleObject[StyleObjectRules] = rules
1070
- updateRules(identifier, rules)
1071
- state.flatRulesToInsert![identifier] = styleObject
1072
- }
1073
- }
1074
- if (clear) direct.flatAtomics = undefined
1075
- }
1076
-
1077
- export function getDirectDynamicThemeAccess(state: GetStyleState) {
1078
- return (state as DirectState).flatDynamicThemeAccess
1079
- }
1080
-
1081
- function emitProperty(
1082
- state: GetStyleState,
1083
- property: string,
1084
- value: any,
1085
- condition: number,
1086
- conditionKey: string,
1087
- conditionWrappers: string[] | undefined,
1088
- conditionSelector: string,
1089
- conditionTheme: string,
1090
- merge: MergeStyle,
1091
- originalValue: any,
1092
- contextOnly: boolean
1093
- ) {
1094
- const direct = state as DirectState
1095
- if (condition & 4) (state.flatEnterKeys ||= new Set()).add(property)
1096
- if (condition & 8) (state.flatExitKeys ||= new Set()).add(property)
1097
-
1098
- if (!isWeb && conditionTheme) {
1099
- if (supportsDynamicColorIOS && isColorStyleKey(property)) {
1100
- const schemes = ((direct.flatDynamicColors ||= {})[property] ||= {})
1101
- schemes[conditionTheme] =
1102
- typeof originalValue === 'string' && /^[a-z]+$/i.test(originalValue)
1103
- ? originalValue
1104
- : value
1105
- merge(state, property, { dynamic: { ...schemes } }, 1, false, originalValue)
1106
- return
1107
- }
1108
- direct.flatDynamicThemeAccess = true
1109
- }
1110
-
1111
- if (contextOnly) {
1112
- if (!condition || condition & 1) {
1113
- ;(state.overriddenContextProps ||= {})[property] = originalValue
1114
- }
1115
- return
1116
- }
1117
-
1118
- const shouldPromoteAnimatedStyle =
1119
- isWeb &&
1120
- !condition &&
1121
- !state.flatShouldDoClasses &&
1122
- !state.styleProps.noMergeStyle &&
1123
- state.styleProps.isAnimated &&
1124
- !state.animationDriver?.isReactNative &&
1125
- property in nonAnimatableStyleProps
1126
-
1127
- if (isWeb && (state.flatShouldDoClasses || shouldPromoteAnimatedStyle)) {
1128
- if (!condition) {
1129
- if (state.style) delete state.style[property]
1130
- }
1131
- directAtomic(
1132
- state as DirectState,
1133
- property,
1134
- value,
1135
- condition,
1136
- conditionKey,
1137
- conditionWrappers,
1138
- conditionSelector
1139
- )
1140
- return
1141
- }
1142
-
1143
- if (condition) {
1144
- if (!(condition & 1)) return
1145
- const precedence = Math.floor(condition / 256)
1146
- const previous = direct.flatPrecedence?.[property]
1147
- if (previous !== undefined && precedence < previous) return
1148
- ;(direct.flatPrecedence ||= {})[property] = precedence
1149
- ;(state.flatActiveConditions ||= {})[property] = true
1150
- } else if (state.flatActiveConditions?.[property]) {
1151
- return
1152
- }
1153
- merge(state, property, value, 1, true, originalValue)
1154
- }
1155
-
1156
- function splitComponents(value: string) {
1157
- const parts: string[] = []
1158
- let start = 0
1159
- let quote = 0
1160
- let depth = 0
1161
- for (let index = 0; index <= value.length; index++) {
1162
- const code = index === value.length ? 32 : value.charCodeAt(index)
1163
- if (quote) {
1164
- if (code === 92) index++
1165
- else if (code === quote) quote = 0
1166
- continue
1167
- }
1168
- if (code === 34 || code === 39) quote = code
1169
- else if (code === 40) depth++
1170
- else if (code === 41) depth--
1171
- else if (!depth && code <= 32) {
1172
- if (index > start) parts.push(value.slice(start, index))
1173
- start = index + 1
1174
- }
1175
- }
1176
- return parts
1177
- }
1178
-
1179
- function emitBorder(
1180
- state: GetStyleState,
1181
- property: string,
1182
- raw: string,
1183
- condition: number,
1184
- conditionKey: string,
1185
- conditionWrappers: string[] | undefined,
1186
- conditionSelector: string,
1187
- conditionTheme: string,
1188
- merge: MergeStyle,
1189
- originalValue: any,
1190
- contextOnly: boolean
1191
- ) {
1192
- if (!isWeb && (property === 'borderBlock' || property === 'borderInline')) {
1193
- if (process.env.NODE_ENV === 'development') {
1194
- warnOnce(`RN has no logical border shorthand "${property}"; dropping it`)
1195
- }
1196
- return
1197
- }
1198
- const targets = borderTargets[property]
1199
- let width: string | undefined
1200
- let style: string | undefined
1201
- let color: string | undefined
1202
- for (const part of splitComponents(raw)) {
1203
- const lower = part.toLowerCase()
1204
- if (lineStyles.has(lower) || (property === 'outline' && lower === 'auto')) {
1205
- style = part
1206
- } else if (
1207
- lower === 'thin' ||
1208
- lower === 'medium' ||
1209
- lower === 'thick' ||
1210
- /^-?(?:\d+\.?\d*|\.\d+)(?:[a-z%]+)?$/i.test(part) ||
1211
- /^(?:calc|var|min|max|clamp)\(/i.test(part)
1212
- ) {
1213
- width = part
1214
- } else {
1215
- color = part
1216
- }
1217
- }
1218
- if (style === 'none' && width === undefined) width = '0'
1219
- if (width !== undefined) {
1220
- for (const target of targets.width) {
1221
- emitResolved(
1222
- state,
1223
- target,
1224
- width,
1225
- condition,
1226
- conditionKey,
1227
- conditionWrappers,
1228
- conditionSelector,
1229
- conditionTheme,
1230
- merge,
1231
- originalValue,
1232
- contextOnly
1233
- )
1234
- }
1235
- }
1236
- if (style !== undefined) {
1237
- const styleTargets = !isWeb && property === 'border' ? ['borderStyle'] : targets.style
1238
- for (const target of styleTargets) {
1239
- emitProperty(
1240
- state,
1241
- target,
1242
- style,
1243
- condition,
1244
- conditionKey,
1245
- conditionWrappers,
1246
- conditionSelector,
1247
- conditionTheme,
1248
- merge,
1249
- originalValue,
1250
- contextOnly
1251
- )
1252
- }
1253
- }
1254
- if (color !== undefined) {
1255
- for (const target of targets.color) {
1256
- emitResolved(
1257
- state,
1258
- target,
1259
- color,
1260
- condition,
1261
- conditionKey,
1262
- conditionWrappers,
1263
- conditionSelector,
1264
- conditionTheme,
1265
- merge,
1266
- originalValue,
1267
- contextOnly
1268
- )
1269
- }
1270
- }
1271
- }
1272
-
1273
- function emitTextDecoration(
1274
- state: GetStyleState,
1275
- raw: string,
1276
- condition: number,
1277
- conditionKey: string,
1278
- conditionWrappers: string[] | undefined,
1279
- conditionSelector: string,
1280
- conditionTheme: string,
1281
- merge: MergeStyle,
1282
- originalValue: any,
1283
- contextOnly: boolean
1284
- ) {
1285
- for (const part of splitComponents(raw)) {
1286
- const property =
1287
- part === 'solid' ||
1288
- part === 'double' ||
1289
- part === 'dotted' ||
1290
- part === 'dashed' ||
1291
- part === 'wavy'
1292
- ? 'textDecorationStyle'
1293
- : part === 'underline' ||
1294
- part === 'overline' ||
1295
- part === 'line-through' ||
1296
- part === 'none'
1297
- ? 'textDecorationLine'
1298
- : 'textDecorationColor'
1299
- emitResolved(
1300
- state,
1301
- property,
1302
- part,
1303
- condition,
1304
- conditionKey,
1305
- conditionWrappers,
1306
- conditionSelector,
1307
- conditionTheme,
1308
- merge,
1309
- originalValue,
1310
- contextOnly
1311
- )
1312
- }
1313
- }
1314
-
1315
- function addComposition(state: GetStyleState, property: 'translate' | 'scale') {
1316
- if (state.classNames[property]) return
1317
- const value =
1318
- property === 'translate'
1319
- ? 'var(--t-x, 0px) var(--t-y, 0px)'
1320
- : 'var(--t-scale-x, 1) var(--t-scale-y, 1)'
1321
- const defaults =
1322
- property === 'translate' ? '--t-x:0px;--t-y:0px' : '--t-scale-x:1;--t-scale-y:1'
1323
- const styleObject = getCSSStyleAtomic(property, value, '', undefined, undefined, true)!
1324
- const identifier = styleObject[StyleObjectIdentifier]
1325
- styleObject[StyleObjectRules].unshift(`:where(.${identifier}){${defaults}}`)
1326
- if (shouldInsertStyleRules(identifier)) {
1327
- updateRules(identifier, styleObject[StyleObjectRules])
1328
- state.flatRulesToInsert![identifier] = styleObject
1329
- }
1330
- state.classNames[property] = identifier
1331
- }
1332
-
1333
- function emitTransform(
1334
- state: GetStyleState,
1335
- property: string,
1336
- value: any,
1337
- condition: number,
1338
- conditionKey: string,
1339
- conditionWrappers: string[] | undefined,
1340
- conditionSelector: string,
1341
- conditionTheme: string,
1342
- merge: MergeStyle,
1343
- originalValue: any,
1344
- contextOnly: boolean
1345
- ) {
1346
- if (!isWeb || !state.flatShouldDoClasses) {
1347
- if (!isWeb && property === 'scale') {
1348
- emitProperty(
1349
- state,
1350
- 'scaleX',
1351
- value,
1352
- condition,
1353
- conditionKey,
1354
- conditionWrappers,
1355
- conditionSelector,
1356
- conditionTheme,
1357
- merge,
1358
- originalValue,
1359
- contextOnly
1360
- )
1361
- emitProperty(
1362
- state,
1363
- 'scaleY',
1364
- value,
1365
- condition,
1366
- conditionKey,
1367
- conditionWrappers,
1368
- conditionSelector,
1369
- conditionTheme,
1370
- merge,
1371
- originalValue,
1372
- contextOnly
1373
- )
1374
- } else {
1375
- emitProperty(
1376
- state,
1377
- property,
1378
- value,
1379
- condition,
1380
- conditionKey,
1381
- conditionWrappers,
1382
- conditionSelector,
1383
- conditionTheme,
1384
- merge,
1385
- originalValue,
1386
- contextOnly
1387
- )
1388
- }
1389
- return
1390
- }
1391
-
1392
- const targets =
1393
- property === 'scale'
1394
- ? ['--t-scale-x', '--t-scale-y']
1395
- : [
1396
- property === 'x'
1397
- ? '--t-x'
1398
- : property === 'y'
1399
- ? '--t-y'
1400
- : property === 'scaleX'
1401
- ? '--t-scale-x'
1402
- : property === 'scaleY'
1403
- ? '--t-scale-y'
1404
- : 'rotate',
1405
- ]
1406
- for (const target of targets) {
1407
- let targetValue = value
1408
- if (typeof targetValue === 'number') {
1409
- if (target === '--t-x' || target === '--t-y') targetValue = `${targetValue}px`
1410
- else if (target === 'rotate') targetValue = `${targetValue}deg`
1411
- }
1412
- emitProperty(
1413
- state,
1414
- target,
1415
- targetValue,
1416
- condition,
1417
- conditionKey,
1418
- conditionWrappers,
1419
- conditionSelector,
1420
- conditionTheme,
1421
- merge,
1422
- originalValue,
1423
- contextOnly
1424
- )
1425
- if (target === '--t-x' || target === '--t-y') addComposition(state, 'translate')
1426
- else if (target.startsWith('--t-scale')) addComposition(state, 'scale')
1427
- }
1428
- }
1429
-
1430
- function emitResolved(
1431
- state: GetStyleState,
1432
- property: string,
1433
- raw: string,
1434
- condition: number,
1435
- conditionKey: string,
1436
- conditionWrappers: string[] | undefined,
1437
- conditionSelector: string,
1438
- conditionTheme: string,
1439
- merge: MergeStyle,
1440
- originalValue: any,
1441
- contextOnly: boolean
1442
- ) {
1443
- let value = configuredValue(state, property, raw)
1444
- if (value === raw && /[\s,(]/.test(raw)) {
1445
- value = resolveEmbeddedTokens(state, property, raw)
1446
- }
1447
- if ((!isWeb || !state.flatShouldDoClasses) && typeof value === 'string') {
1448
- if (/^-?(?:\d+\.?\d*|\.\d+)(?:px|dp)$/i.test(value)) {
1449
- value = Number.parseFloat(value)
1450
- } else if (value !== '' && Number.isFinite(Number(value))) {
1451
- value = Number(value)
1452
- }
1453
- }
1454
- emitProperty(
1455
- state,
1456
- property,
1457
- value,
1458
- condition,
1459
- conditionKey,
1460
- conditionWrappers,
1461
- conditionSelector,
1462
- conditionTheme,
1463
- merge,
1464
- originalValue,
1465
- contextOnly
1466
- )
1467
- }
1468
-
1469
- function shadowUnit(part: any) {
1470
- return typeof part === 'number' ? `${part}px` : part || '0px'
1471
- }
1472
-
1473
- function emitWebShadow(
1474
- state: DirectState,
1475
- property: string,
1476
- value: any,
1477
- merge: MergeStyle,
1478
- originalValue: any,
1479
- contextOnly: boolean
1480
- ) {
1481
- const shadow = (state.flatWebShadow ||= {})
1482
- shadow[property] = value
1483
- const offset = shadow.shadowOffset || { width: 0, height: 0 }
1484
- const color = normalizeColor(shadow.shadowColor, shadow.shadowOpacity ?? 1)
1485
- if (!color) return
1486
- const next = `${shadowUnit(offset.width)} ${shadowUnit(offset.height)} ${shadowUnit(shadow.shadowRadius)} ${color}`
1487
- emitProperty(
1488
- state,
1489
- 'boxShadow',
1490
- state.flatBoxShadow ? `${state.flatBoxShadow}, ${next}` : next,
1491
- 0,
1492
- '',
1493
- undefined,
1494
- '',
1495
- '',
1496
- merge,
1497
- originalValue,
1498
- contextOnly
1499
- )
1500
- }
1501
-
1502
- function emitWebTextShadow(
1503
- state: DirectState,
1504
- property: string,
1505
- value: any,
1506
- merge: MergeStyle,
1507
- originalValue: any,
1508
- contextOnly: boolean
1509
- ) {
1510
- const shadow = (state.flatTextShadow ||= {})
1511
- shadow[property] = value
1512
- const offset = shadow.textShadowOffset || { width: 0, height: 0 }
1513
- if (!shadow.textShadowColor) return
1514
- emitProperty(
1515
- state,
1516
- 'textShadow',
1517
- `${shadowUnit(offset.width)} ${shadowUnit(offset.height)} ${shadowUnit(shadow.textShadowRadius)} ${shadow.textShadowColor}`,
1518
- 0,
1519
- '',
1520
- undefined,
1521
- '',
1522
- '',
1523
- merge,
1524
- originalValue,
1525
- contextOnly
1526
- )
1527
- }
1528
-
1529
- function emitValue(
1530
- state: GetStyleState,
1531
- property: string,
1532
- raw: any,
1533
- condition: number,
1534
- conditionKey: string,
1535
- conditionWrappers: string[] | undefined,
1536
- conditionSelector: string,
1537
- conditionTheme: string,
1538
- merge: MergeStyle,
1539
- originalValue: any,
1540
- contextOnly: boolean
1541
- ) {
1542
- if (typeof raw === 'string') {
1543
- raw = raw.trim()
1544
- }
1545
-
1546
- if (isVariable(raw)) {
1547
- raw = resolveVariableValue(
1548
- property,
1549
- raw,
1550
- isWeb && !state.flatShouldDoClasses && state.styleProps.resolveValues === 'auto'
1551
- ? 'value'
1552
- : state.styleProps.resolveValues
1553
- )
1554
- }
1555
-
1556
- emitBorderStyleDefault(
1557
- state,
1558
- property,
1559
- condition,
1560
- conditionKey,
1561
- conditionWrappers,
1562
- conditionSelector
1563
- )
1564
-
1565
- if (
1566
- typeof raw === 'string' &&
1567
- (property === 'transition' || property === 'transitionProperty')
1568
- ) {
1569
- raw = normalizeTransitionNames(state, raw)
1570
- }
1571
-
1572
- if (legacyTransformParts.has(property)) {
1573
- if (isWeb && state.flatShouldDoClasses && state.classNames.transform) {
1574
- if (process.env.NODE_ENV === 'development') {
1575
- warnOnce(
1576
- `legacy transform part "${property}" is dropped because "transform" owns the property`
1577
- )
1578
- }
1579
- return
1580
- }
1581
- const value = typeof raw === 'string' ? configuredValue(state, property, raw) : raw
1582
- if (isWeb && state.flatShouldDoClasses && !condition) {
1583
- const direct = state as DirectState
1584
- ;(direct.flatLegacyTransforms ||= {})[property] = value
1585
- emitProperty(
1586
- state,
1587
- 'transform',
1588
- transformsToString(
1589
- Object.keys(direct.flatLegacyTransforms)
1590
- .sort()
1591
- .map((key) => ({ [key]: direct.flatLegacyTransforms![key] }))
1592
- ),
1593
- 0,
1594
- '',
1595
- undefined,
1596
- '',
1597
- '',
1598
- merge,
1599
- originalValue,
1600
- contextOnly
1601
- )
1602
- } else if (condition && isWeb && state.flatShouldDoClasses) {
1603
- emitProperty(
1604
- state,
1605
- 'transform',
1606
- `${property}(${value})`,
1607
- condition,
1608
- conditionKey,
1609
- conditionWrappers,
1610
- conditionSelector,
1611
- conditionTheme,
1612
- merge,
1613
- originalValue,
1614
- contextOnly
1615
- )
1616
- } else {
1617
- merge(state, property, value, 1, false, originalValue)
1618
- }
1619
- return
1620
- }
1621
-
1622
- if (isWeb && webShadowParts.has(property)) {
1623
- const value = typeof raw === 'string' ? configuredValue(state, property, raw) : raw
1624
- if (state.flatShouldDoClasses) {
1625
- emitWebShadow(
1626
- state as DirectState,
1627
- property,
1628
- value,
1629
- merge,
1630
- originalValue,
1631
- contextOnly
1632
- )
1633
- } else {
1634
- merge(state, property, value, 1, false, originalValue)
1635
- }
1636
- return
1637
- }
1638
-
1639
- if (isWeb && webTextShadowParts.has(property)) {
1640
- const value = typeof raw === 'string' ? configuredValue(state, property, raw) : raw
1641
- if (state.flatShouldDoClasses) {
1642
- emitWebTextShadow(
1643
- state as DirectState,
1644
- property,
1645
- value,
1646
- merge,
1647
- originalValue,
1648
- contextOnly
1649
- )
1650
- } else {
1651
- merge(state, property, value, 1, false, originalValue)
1652
- }
1653
- return
1654
- }
1655
-
1656
- if (isWeb && state.flatShouldDoClasses) {
1657
- if (property === 'transform') {
1658
- const direct = state as DirectState
1659
- if (process.env.NODE_ENV === 'development' && direct.flatLegacyTransforms) {
1660
- for (const part in direct.flatLegacyTransforms) {
1661
- warnOnce(
1662
- `legacy transform part "${part}" is dropped because "transform" owns the property`
1663
- )
1664
- }
1665
- }
1666
- direct.flatLegacyTransforms = undefined
1667
- if (state.flatTransforms) {
1668
- if (process.env.NODE_ENV === 'development') {
1669
- for (const part in state.flatTransforms) {
1670
- warnOnce(
1671
- `legacy transform part "${part}" is dropped because "transform" owns the property`
1672
- )
1673
- }
1674
- }
1675
- state.flatTransforms = undefined
1676
- }
1677
- }
1678
- }
1679
-
1680
- if (
1681
- isWeb &&
1682
- state.flatShouldDoClasses &&
1683
- property === 'transform' &&
1684
- Array.isArray(raw)
1685
- ) {
1686
- raw = transformsToString(raw)
1687
- }
1688
-
1689
- if (typeof raw === 'string' && property in borderTargets) {
1690
- emitBorder(
1691
- state,
1692
- property,
1693
- raw,
1694
- condition,
1695
- conditionKey,
1696
- conditionWrappers,
1697
- conditionSelector,
1698
- conditionTheme,
1699
- merge,
1700
- originalValue,
1701
- contextOnly
1702
- )
1703
- return
1704
- }
1705
- if (typeof raw === 'string' && property === 'textDecoration') {
1706
- emitTextDecoration(
1707
- state,
1708
- raw,
1709
- condition,
1710
- conditionKey,
1711
- conditionWrappers,
1712
- conditionSelector,
1713
- conditionTheme,
1714
- merge,
1715
- originalValue,
1716
- contextOnly
1717
- )
1718
- return
1719
- }
1720
- if (typeof raw === 'string' && property === 'background') {
1721
- const parts = splitComponents(raw)
1722
- if (parts.length === 1 && !/^(?:url|image-set|.*gradient)\(/i.test(parts[0])) {
1723
- emitResolved(
1724
- state,
1725
- 'backgroundColor',
1726
- parts[0],
1727
- condition,
1728
- conditionKey,
1729
- conditionWrappers,
1730
- conditionSelector,
1731
- conditionTheme,
1732
- merge,
1733
- originalValue,
1734
- contextOnly
1735
- )
1736
- return
1737
- }
1738
- if (!isWeb) {
1739
- if (process.env.NODE_ENV === 'development') {
1740
- warnOnce(`native background cannot represent "${raw}"; dropping it`)
1741
- }
1742
- return
1743
- }
1744
- }
1745
-
1746
- if (
1747
- property === 'x' ||
1748
- property === 'y' ||
1749
- property === 'scale' ||
1750
- property === 'scaleX' ||
1751
- property === 'scaleY' ||
1752
- property === 'rotate'
1753
- ) {
1754
- let value = typeof raw === 'string' ? configuredValue(state, property, raw) : raw
1755
- // a transform going into a real style object rather than a CSS class has to
1756
- // carry numbers: that is every native render and every web render an
1757
- // animation driver drives inline. strings survive only on the class path.
1758
- // a theme-ref sentinel is not a number and must pass through untouched.
1759
- if (
1760
- (!isWeb || !state.flatShouldDoClasses) &&
1761
- typeof value === 'string' &&
1762
- !value.startsWith(THEME_REF_PREFIX)
1763
- ) {
1764
- if (property === 'rotate' && !/^-?(?:\d+\.?\d*|\.\d+)(?:deg|rad)$/i.test(value)) {
1765
- if (process.env.NODE_ENV === 'development') {
1766
- warnOnce(
1767
- `native transform "${property}" cannot represent "${value}"; dropping it`
1768
- )
1769
- }
1770
- if (condition & 1 && state.flatTransforms) {
1771
- delete state.flatTransforms[property]
1772
- }
1773
- return
1774
- }
1775
- if (/^-?(?:\d+\.?\d*|\.\d+)(?:px|dp)$/i.test(value)) {
1776
- value = Number.parseFloat(value)
1777
- } else if (Number.isFinite(Number(value))) {
1778
- value = Number(value)
1779
- }
1780
- }
1781
- emitTransform(
1782
- state,
1783
- property,
1784
- value,
1785
- condition,
1786
- conditionKey,
1787
- conditionWrappers,
1788
- conditionSelector,
1789
- conditionTheme,
1790
- merge,
1791
- originalValue,
1792
- contextOnly
1793
- )
1794
- return
1795
- }
1796
-
1797
- if (isWeb && !state.flatShouldDoClasses && !condition && property === 'borderRadius') {
1798
- // css reads the shorthand, so skip the four-corner expansion here. a string
1799
- // value still needs its token resolved, which is what emitResolved does.
1800
- if (typeof raw === 'string') {
1801
- emitResolved(
1802
- state,
1803
- property,
1804
- raw,
1805
- condition,
1806
- conditionKey,
1807
- conditionWrappers,
1808
- conditionSelector,
1809
- conditionTheme,
1810
- merge,
1811
- originalValue,
1812
- contextOnly
1813
- )
1814
- } else {
1815
- emitProperty(
1816
- state,
1817
- property,
1818
- raw,
1819
- condition,
1820
- conditionKey,
1821
- conditionWrappers,
1822
- conditionSelector,
1823
- conditionTheme,
1824
- merge,
1825
- originalValue,
1826
- contextOnly
1827
- )
1828
- }
1829
- return
1830
- }
1831
-
1832
- if (
1833
- process.env.TAMAGUI_TARGET === 'native' &&
1834
- property === 'transform' &&
1835
- typeof raw === 'string'
1836
- ) {
1837
- const transform = parseNativeTransform(raw)
1838
- if (transform) {
1839
- emitProperty(
1840
- state,
1841
- property,
1842
- transform,
1843
- condition,
1844
- conditionKey,
1845
- conditionWrappers,
1846
- conditionSelector,
1847
- conditionTheme,
1848
- merge,
1849
- originalValue,
1850
- contextOnly
1851
- )
1852
- return
1853
- }
1854
- }
1855
-
1856
- let value: any = raw
1857
- if (typeof raw === 'string') {
1858
- value = configuredValue(state, property, raw)
1859
- if (value === raw && /[\s,(]/.test(raw)) {
1860
- value = resolveEmbeddedTokens(state, property, raw)
1861
- }
1862
- }
1863
-
1864
- if ((!isWeb || !state.flatShouldDoClasses) && typeof value === 'string') {
1865
- if (/^-?(?:\d+\.?\d*|\.\d+)(?:px|dp)$/i.test(value)) {
1866
- value = Number.parseFloat(value)
1867
- } else if (value !== '' && Number.isFinite(Number(value))) {
1868
- value = Number(value)
1869
- }
1870
- }
1871
- if (isWeb && state.flatShouldDoClasses && property === 'boxShadow' && !condition) {
1872
- ;(state as DirectState).flatBoxShadow = value
1873
- }
1874
-
1875
- if (
1876
- process.env.TAMAGUI_TARGET === 'native' &&
1877
- typeof value === 'string' &&
1878
- (property === 'backgroundImage' ||
1879
- property === 'boxShadow' ||
1880
- property === 'textShadow')
1881
- ) {
1882
- const parsed = parseNativeStyle(property, value)
1883
- if (parsed) {
1884
- if (property === 'textShadow') {
1885
- for (const [key, parsedValue] of parsed) {
1886
- emitProperty(
1887
- state,
1888
- key,
1889
- parsedValue,
1890
- condition,
1891
- conditionKey,
1892
- conditionWrappers,
1893
- conditionSelector,
1894
- conditionTheme,
1895
- merge,
1896
- originalValue,
1897
- contextOnly
1898
- )
1899
- }
1900
- } else {
1901
- emitProperty(
1902
- state,
1903
- property === 'backgroundImage' ? 'experimental_backgroundImage' : property,
1904
- parsed,
1905
- condition,
1906
- conditionKey,
1907
- conditionWrappers,
1908
- conditionSelector,
1909
- conditionTheme,
1910
- merge,
1911
- originalValue,
1912
- contextOnly
1913
- )
1914
- }
1915
- return
1916
- }
1917
- }
1918
-
1919
- if (!isWeb && property === 'fontVariant' && typeof value === 'string') {
1920
- value = value.split(/[,\s]+/).filter(Boolean)
1921
- }
1922
-
1923
- const expanded = state.styleProps.noExpand
1924
- ? null
1925
- : expandStyle(property, value, state.conf.settings.styleCompat || 'web')
1926
- if (!expanded) {
1927
- emitProperty(
1928
- state,
1929
- property,
1930
- value,
1931
- condition,
1932
- conditionKey,
1933
- conditionWrappers,
1934
- conditionSelector,
1935
- conditionTheme,
1936
- merge,
1937
- originalValue,
1938
- contextOnly
1939
- )
1940
- return
1941
- }
1942
-
1943
- if (typeof raw === 'string' && expanded.length > 1) {
1944
- const parts = splitComponents(raw)
1945
- if (parts.length > 0 && parts.length <= (expanded.length === 4 ? 4 : 2)) {
1946
- for (let index = 0; index < expanded.length; index++) {
1947
- const partIndex =
1948
- index === 0 || parts.length === 1
1949
- ? 0
1950
- : index === 1 || (index === 3 && parts.length < 4)
1951
- ? 1
1952
- : index === 2 && parts.length < 3
1953
- ? 0
1954
- : index
1955
- emitResolved(
1956
- state,
1957
- expanded[index][0],
1958
- parts[partIndex],
1959
- condition,
1960
- conditionKey,
1961
- conditionWrappers,
1962
- conditionSelector,
1963
- conditionTheme,
1964
- merge,
1965
- originalValue,
1966
- contextOnly
1967
- )
1968
- }
1969
- return
1970
- }
1971
- }
1972
- for (let index = 0; index < expanded.length; index++) {
1973
- emitProperty(
1974
- state,
1975
- expanded[index][0],
1976
- expanded[index][1],
1977
- condition,
1978
- conditionKey,
1979
- conditionWrappers,
1980
- conditionSelector,
1981
- conditionTheme,
1982
- merge,
1983
- originalValue,
1984
- contextOnly
1985
- )
1986
- }
1987
- }
1988
-
1989
- export function contributeStyleString(
1990
- state: GetStyleState,
1991
- property: string,
1992
- source: string,
1993
- merge: MergeStyle,
1994
- originalValue?: any,
1995
- contextOnly = false
1996
- ) {
1997
- if (
1998
- isWeb &&
1999
- source.indexOf(':') !== -1 &&
2000
- (webShadowParts.has(property) || legacyTransformParts.has(property))
2001
- ) {
2002
- if (process.env.NODE_ENV === 'development') {
2003
- warnOnce(`conditional "${property}" needs its composite property; dropping it`)
2004
- }
2005
- return true
2006
- }
2007
- // no clause to cut, so the scanner below never runs on this value. nothing
2008
- // validates it either: the `carriesTopLevelInjection` guard that used to
2009
- // refuse a rule-breaking value here was dropped by owner decision, so a value
2010
- // with no colon is emitted verbatim by contract. Keep the two paths in mind
2011
- // together when reading a bug report about one of them.
2012
- if (source.indexOf(':') === -1) {
2013
- emitValue(
2014
- state,
2015
- property,
2016
- source,
2017
- 0,
2018
- '',
2019
- undefined,
2020
- '',
2021
- '',
2022
- merge,
2023
- originalValue ?? source,
2024
- contextOnly
2025
- )
2026
- return true
2027
- }
2028
-
2029
- scanFlatValue(
2030
- source,
2031
- directStyleHandler,
2032
- state,
2033
- property,
2034
- merge,
2035
- originalValue,
2036
- contextOnly
2037
- )
2038
- return true
2039
- }
2040
-
2041
- export function contributeFrontendValue(
2042
- state: GetStyleState,
2043
- property: string,
2044
- value: ParsedValue,
2045
- merge: MergeStyle,
2046
- contextOnly = false
2047
- ) {
2048
- if (value.base !== null) {
2049
- emitValue(
2050
- state,
2051
- property,
2052
- value.base,
2053
- 0,
2054
- '',
2055
- undefined,
2056
- '',
2057
- '',
2058
- merge,
2059
- value.base,
2060
- contextOnly
2061
- )
2062
- }
2063
- for (const clause of value.clauses) {
2064
- const source = clause.modifiers.join(':')
2065
- resolveClauseChain(
2066
- state,
2067
- source,
2068
- 0,
2069
- source.length,
2070
- property,
2071
- clause.payload,
2072
- merge,
2073
- clause.payload,
2074
- contextOnly
2075
- )
2076
- }
2077
- return true
2078
- }
2079
-
2080
- // a flat conditional object either names a `default` or opens with a
2081
- // resolvable modifier chain; anything else is a structured leaf value
2082
- // (shadowOffset) and stays whole. only the first key is probed, the same way
2083
- // the string scanner commits at its first clause
2084
- export function isConditionalStyleObject(
2085
- state: GetStyleState,
2086
- value: Record<string, any>
2087
- ): boolean {
2088
- if (Object.prototype.hasOwnProperty.call(value, 'default')) return true
2089
- for (const key in value) {
2090
- return key.length > 0 && !!resolveClauseChain(state, key, 0, key.length)
2091
- }
2092
- return false
2093
- }
2094
-
2095
- export function contributeVariantClauseValue(
2096
- state: GetStyleState,
2097
- property: string,
2098
- value: any,
2099
- conditionSource: string,
2100
- merge: MergeStyle,
2101
- originalValue?: any,
2102
- contextOnly = false
2103
- ) {
2104
- if (
2105
- value &&
2106
- typeof value === 'object' &&
2107
- !Array.isArray(value) &&
2108
- !isVariable(value) &&
2109
- isConditionalStyleObject(state, value)
2110
- ) {
2111
- // a flat conditional object inside a clause-valued variant: the outer
2112
- // condition prefixes every inner chain (`sm` + `hover` -> `sm:hover`)
2113
- for (const key in value) {
2114
- const payload = value[key]
2115
- if (payload == null) continue
2116
- const source = key === 'default' ? conditionSource : `${conditionSource}:${key}`
2117
- resolveClauseChain(
2118
- state,
2119
- source,
2120
- 0,
2121
- source.length,
2122
- property,
2123
- payload,
2124
- merge,
2125
- payload,
2126
- contextOnly,
2127
- -1,
2128
- -1,
2129
- 2
2130
- )
2131
- }
2132
- return
2133
- }
2134
- resolveClauseChain(
2135
- state,
2136
- conditionSource,
2137
- 0,
2138
- conditionSource.length,
2139
- property,
2140
- value,
2141
- merge,
2142
- originalValue,
2143
- contextOnly,
2144
- -1,
2145
- -1,
2146
- 2
2147
- )
2148
- }
2149
-
2150
- function contributeStyleObject(
2151
- state: GetStyleState,
2152
- property: string,
2153
- value: Record<string, any>,
2154
- merge: MergeStyle,
2155
- contextOnly: boolean
2156
- ) {
2157
- if (!isConditionalStyleObject(state, value)) return false
2158
- // parity with conditional strings: shadow and legacy transform parts on web
2159
- // cannot carry conditions of their own — the composite property owns them
2160
- if (isWeb && (webShadowParts.has(property) || legacyTransformParts.has(property))) {
2161
- if (process.env.NODE_ENV === 'development') {
2162
- warnOnce(`conditional "${property}" needs its composite property; dropping it`)
2163
- }
2164
- return true
2165
- }
2166
- let hasBase = false
2167
- const base = value.default
2168
- if (base != null) {
2169
- emitValue(state, property, base, 0, '', undefined, '', '', merge, base, contextOnly)
2170
- hasBase = true
2171
- }
2172
- let conditions = 0
2173
- for (const key in value) {
2174
- if (key === 'default') continue
2175
- const payload = value[key]
2176
- if (payload == null) continue
2177
- conditions |= resolveClauseChain(
2178
- state,
2179
- key,
2180
- 0,
2181
- key.length,
2182
- property,
2183
- payload,
2184
- merge,
2185
- payload,
2186
- contextOnly,
2187
- -1,
2188
- -1,
2189
- 1
2190
- )
2191
- }
2192
- if ((!isWeb || !state.flatShouldDoClasses) && conditions & 12 && !hasBase) {
2193
- const resting = implicitLifecycleBase(property)
2194
- if (resting !== null) {
2195
- emitValue(
2196
- state,
2197
- property,
2198
- resting,
2199
- 0,
2200
- '',
2201
- undefined,
2202
- '',
2203
- '',
2204
- merge,
2205
- resting,
2206
- contextOnly
2207
- )
2208
- }
2209
- }
2210
- return true
2211
- }
2212
-
2213
- export function contributeStyleValue(
2214
- state: GetStyleState,
2215
- property: string,
2216
- value: any,
2217
- merge: MergeStyle,
2218
- originalValue?: any,
2219
- contextOnly = false
2220
- ) {
2221
- if (value === 'safe' && isSafeAreaKey(property)) {
2222
- const expanded = expandSafeAreaValue(property)
2223
- if (expanded) {
2224
- state.flatUsesSafeArea = true
2225
- for (const [key, resolved] of expanded) {
2226
- emitValue(
2227
- state,
2228
- key,
2229
- resolved,
2230
- 0,
2231
- '',
2232
- undefined,
2233
- '',
2234
- '',
2235
- merge,
2236
- originalValue ?? value,
2237
- contextOnly
2238
- )
2239
- }
2240
- return true
2241
- }
2242
- }
2243
- if (typeof value === 'string') {
2244
- return contributeStyleString(
2245
- state,
2246
- property,
2247
- value,
2248
- merge,
2249
- originalValue,
2250
- contextOnly
2251
- )
2252
- }
2253
- if (
2254
- value &&
2255
- typeof value === 'object' &&
2256
- !Array.isArray(value) &&
2257
- !isVariable(value) &&
2258
- contributeStyleObject(state, property, value, merge, contextOnly)
2259
- ) {
2260
- return true
2261
- }
2262
- if (value != null) {
2263
- emitValue(
2264
- state,
2265
- property,
2266
- value,
2267
- 0,
2268
- '',
2269
- undefined,
2270
- '',
2271
- '',
2272
- merge,
2273
- originalValue ?? value,
2274
- contextOnly
2275
- )
2276
- return true
2277
- }
2278
- return false
2279
- }
2280
-
2281
- export function clearDirectStyle(state: GetStyleState, property: string) {
2282
- const direct = state as DirectState
2283
- const atomicKey = property.startsWith('transition')
2284
- ? 'transition'
2285
- : webShadowParts.has(property)
2286
- ? 'boxShadow'
2287
- : webTextShadowParts.has(property)
2288
- ? 'textShadow'
2289
- : legacyTransformParts.has(property)
2290
- ? 'transform'
2291
- : property
2292
- if (direct.flatAtomics) delete direct.flatAtomics[atomicKey]
2293
- delete state.classNames[atomicKey]
2294
- }