rnwind 0.0.1 → 0.0.2

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 (330) hide show
  1. package/lib/cjs/core/parser/animation.cjs +427 -0
  2. package/lib/cjs/core/parser/animation.cjs.map +1 -0
  3. package/lib/cjs/core/parser/animation.d.ts +126 -0
  4. package/lib/cjs/core/parser/border-dispatcher.cjs +180 -0
  5. package/lib/cjs/core/parser/border-dispatcher.cjs.map +1 -0
  6. package/lib/cjs/core/parser/border-dispatcher.d.ts +15 -0
  7. package/lib/cjs/core/parser/case-convert.cjs +15 -0
  8. package/lib/cjs/core/parser/case-convert.cjs.map +1 -0
  9. package/lib/cjs/core/parser/case-convert.d.ts +6 -0
  10. package/lib/cjs/core/parser/color-properties-dispatcher.cjs +84 -0
  11. package/lib/cjs/core/parser/color-properties-dispatcher.cjs.map +1 -0
  12. package/lib/cjs/core/parser/color-properties-dispatcher.d.ts +19 -0
  13. package/lib/cjs/core/parser/color.cjs +164 -0
  14. package/lib/cjs/core/parser/color.cjs.map +1 -0
  15. package/lib/cjs/core/parser/color.d.ts +12 -0
  16. package/lib/cjs/core/parser/constants.cjs +21 -0
  17. package/lib/cjs/core/parser/constants.cjs.map +1 -0
  18. package/lib/cjs/core/parser/constants.d.ts +8 -0
  19. package/lib/cjs/core/parser/declaration.cjs +347 -0
  20. package/lib/cjs/core/parser/declaration.cjs.map +1 -0
  21. package/lib/cjs/core/parser/declaration.d.ts +15 -0
  22. package/lib/cjs/core/parser/gradient.cjs +132 -0
  23. package/lib/cjs/core/parser/gradient.cjs.map +1 -0
  24. package/lib/cjs/core/parser/gradient.d.ts +59 -0
  25. package/lib/cjs/core/parser/haptics.cjs +73 -0
  26. package/lib/cjs/core/parser/haptics.cjs.map +1 -0
  27. package/lib/cjs/core/parser/haptics.d.ts +47 -0
  28. package/lib/cjs/core/parser/index.d.ts +8 -0
  29. package/lib/cjs/core/parser/keyframes.cjs +95 -0
  30. package/lib/cjs/core/parser/keyframes.cjs.map +1 -0
  31. package/lib/cjs/core/parser/keyframes.d.ts +26 -0
  32. package/lib/cjs/core/parser/layout-dispatcher.cjs +100 -0
  33. package/lib/cjs/core/parser/layout-dispatcher.cjs.map +1 -0
  34. package/lib/cjs/core/parser/layout-dispatcher.d.ts +14 -0
  35. package/lib/cjs/core/parser/length.cjs +96 -0
  36. package/lib/cjs/core/parser/length.cjs.map +1 -0
  37. package/lib/cjs/core/parser/length.d.ts +48 -0
  38. package/lib/cjs/core/parser/motion-dispatcher.cjs +77 -0
  39. package/lib/cjs/core/parser/motion-dispatcher.cjs.map +1 -0
  40. package/lib/cjs/core/parser/motion-dispatcher.d.ts +11 -0
  41. package/lib/cjs/core/parser/property.cjs +22 -0
  42. package/lib/cjs/core/parser/property.cjs.map +1 -0
  43. package/lib/cjs/core/parser/property.d.ts +8 -0
  44. package/lib/cjs/core/parser/safe-area.cjs +404 -0
  45. package/lib/cjs/core/parser/safe-area.cjs.map +1 -0
  46. package/lib/cjs/core/parser/safe-area.d.ts +39 -0
  47. package/lib/cjs/core/parser/selector.cjs +22 -0
  48. package/lib/cjs/core/parser/selector.cjs.map +1 -0
  49. package/lib/cjs/core/parser/selector.d.ts +11 -0
  50. package/lib/cjs/core/parser/shorthand.cjs +156 -0
  51. package/lib/cjs/core/parser/shorthand.cjs.map +1 -0
  52. package/lib/cjs/core/parser/shorthand.d.ts +61 -0
  53. package/lib/cjs/core/parser/text-truncate.cjs +78 -0
  54. package/lib/cjs/core/parser/text-truncate.cjs.map +1 -0
  55. package/lib/cjs/core/parser/text-truncate.d.ts +44 -0
  56. package/lib/cjs/core/parser/theme-vars.cjs +414 -0
  57. package/lib/cjs/core/parser/theme-vars.cjs.map +1 -0
  58. package/lib/cjs/core/parser/theme-vars.d.ts +61 -0
  59. package/lib/cjs/core/parser/tokens.cjs +304 -0
  60. package/lib/cjs/core/parser/tokens.cjs.map +1 -0
  61. package/lib/cjs/core/parser/tokens.d.ts +45 -0
  62. package/lib/cjs/core/parser/transform.cjs +198 -0
  63. package/lib/cjs/core/parser/transform.cjs.map +1 -0
  64. package/lib/cjs/core/parser/transform.d.ts +36 -0
  65. package/lib/cjs/core/parser/tw-parser.cjs +1567 -0
  66. package/lib/cjs/core/parser/tw-parser.cjs.map +1 -0
  67. package/lib/cjs/core/parser/tw-parser.d.ts +194 -0
  68. package/lib/cjs/core/parser/types.d.ts +37 -0
  69. package/lib/cjs/core/parser/typography-dispatcher.cjs +93 -0
  70. package/lib/cjs/core/parser/typography-dispatcher.cjs.map +1 -0
  71. package/lib/cjs/core/parser/typography-dispatcher.d.ts +11 -0
  72. package/lib/cjs/core/parser/typography.cjs +97 -0
  73. package/lib/cjs/core/parser/typography.cjs.map +1 -0
  74. package/lib/cjs/core/parser/typography.d.ts +43 -0
  75. package/lib/cjs/core/style-builder/build-style.cjs +397 -0
  76. package/lib/cjs/core/style-builder/build-style.cjs.map +1 -0
  77. package/lib/cjs/core/style-builder/build-style.d.ts +54 -0
  78. package/lib/cjs/core/style-builder/index.d.ts +3 -0
  79. package/lib/cjs/core/style-builder/union-builder.cjs +326 -0
  80. package/lib/cjs/core/style-builder/union-builder.cjs.map +1 -0
  81. package/lib/cjs/core/style-builder/union-builder.d.ts +128 -0
  82. package/lib/cjs/core/types.d.ts +14 -0
  83. package/lib/cjs/metro/dts.cjs +127 -0
  84. package/lib/cjs/metro/dts.cjs.map +1 -0
  85. package/lib/cjs/metro/dts.d.ts +16 -0
  86. package/lib/cjs/metro/index.cjs +19 -0
  87. package/lib/cjs/metro/index.cjs.map +1 -0
  88. package/lib/cjs/metro/index.d.ts +9 -0
  89. package/lib/cjs/metro/resolver.cjs +47 -0
  90. package/lib/cjs/metro/resolver.cjs.map +1 -0
  91. package/lib/cjs/metro/resolver.d.ts +22 -0
  92. package/lib/cjs/metro/state.cjs +251 -0
  93. package/lib/cjs/metro/state.cjs.map +1 -0
  94. package/lib/cjs/metro/state.d.ts +72 -0
  95. package/lib/cjs/metro/transform-ast.cjs +1255 -0
  96. package/lib/cjs/metro/transform-ast.cjs.map +1 -0
  97. package/lib/cjs/metro/transform-ast.d.ts +73 -0
  98. package/lib/cjs/metro/transformer.cjs +345 -0
  99. package/lib/cjs/metro/transformer.cjs.map +1 -0
  100. package/lib/cjs/metro/transformer.d.ts +47 -0
  101. package/lib/cjs/metro/warn-unknown-classes.cjs +86 -0
  102. package/lib/cjs/metro/warn-unknown-classes.cjs.map +1 -0
  103. package/lib/cjs/metro/warn-unknown-classes.d.ts +21 -0
  104. package/lib/cjs/metro/with-config.cjs +196 -0
  105. package/lib/cjs/metro/with-config.cjs.map +1 -0
  106. package/lib/cjs/metro/with-config.d.ts +57 -0
  107. package/lib/cjs/runtime/chain-handlers.cjs +37 -0
  108. package/lib/cjs/runtime/chain-handlers.cjs.map +1 -0
  109. package/lib/cjs/runtime/chain-handlers.d.ts +33 -0
  110. package/lib/cjs/runtime/components/rnwind-provider.cjs +98 -0
  111. package/lib/cjs/runtime/components/rnwind-provider.cjs.map +1 -0
  112. package/lib/cjs/runtime/components/rnwind-provider.d.ts +84 -0
  113. package/lib/cjs/runtime/gradient-types.d.ts +58 -0
  114. package/lib/cjs/runtime/haptics.cjs +113 -0
  115. package/lib/cjs/runtime/haptics.cjs.map +1 -0
  116. package/lib/cjs/runtime/haptics.d.ts +48 -0
  117. package/lib/cjs/runtime/hooks/use-css.cjs +21 -0
  118. package/lib/cjs/runtime/hooks/use-css.cjs.map +1 -0
  119. package/lib/cjs/runtime/hooks/use-css.d.ts +11 -0
  120. package/lib/cjs/runtime/hooks/use-interact.cjs +46 -0
  121. package/lib/cjs/runtime/hooks/use-interact.cjs.map +1 -0
  122. package/lib/cjs/runtime/hooks/use-interact.d.ts +42 -0
  123. package/lib/cjs/runtime/hooks/use-scheme.cjs +68 -0
  124. package/lib/cjs/runtime/hooks/use-scheme.cjs.map +1 -0
  125. package/lib/cjs/runtime/hooks/use-scheme.d.ts +34 -0
  126. package/lib/cjs/runtime/index.cjs +45 -0
  127. package/lib/cjs/runtime/index.cjs.map +1 -0
  128. package/lib/cjs/runtime/index.d.ts +27 -0
  129. package/lib/cjs/runtime/interactive-box.cjs +35 -0
  130. package/lib/cjs/runtime/interactive-box.cjs.map +1 -0
  131. package/lib/cjs/runtime/interactive-box.d.ts +40 -0
  132. package/lib/cjs/runtime/lookup-css.cjs +542 -0
  133. package/lib/cjs/runtime/lookup-css.cjs.map +1 -0
  134. package/lib/cjs/runtime/lookup-css.d.ts +164 -0
  135. package/lib/cjs/runtime/types.d.ts +29 -0
  136. package/lib/cjs/testing/index.cjs +367 -0
  137. package/lib/cjs/testing/index.cjs.map +1 -0
  138. package/lib/cjs/testing/index.d.ts +145 -0
  139. package/lib/esm/core/parser/animation.d.ts +126 -0
  140. package/lib/esm/core/parser/animation.mjs +408 -0
  141. package/lib/esm/core/parser/animation.mjs.map +1 -0
  142. package/lib/esm/core/parser/border-dispatcher.d.ts +15 -0
  143. package/lib/esm/core/parser/border-dispatcher.mjs +178 -0
  144. package/lib/esm/core/parser/border-dispatcher.mjs.map +1 -0
  145. package/lib/esm/core/parser/case-convert.d.ts +6 -0
  146. package/lib/esm/core/parser/case-convert.mjs +13 -0
  147. package/lib/esm/core/parser/case-convert.mjs.map +1 -0
  148. package/lib/esm/core/parser/color-properties-dispatcher.d.ts +19 -0
  149. package/lib/esm/core/parser/color-properties-dispatcher.mjs +82 -0
  150. package/lib/esm/core/parser/color-properties-dispatcher.mjs.map +1 -0
  151. package/lib/esm/core/parser/color.d.ts +12 -0
  152. package/lib/esm/core/parser/color.mjs +162 -0
  153. package/lib/esm/core/parser/color.mjs.map +1 -0
  154. package/lib/esm/core/parser/constants.d.ts +8 -0
  155. package/lib/esm/core/parser/constants.mjs +13 -0
  156. package/lib/esm/core/parser/constants.mjs.map +1 -0
  157. package/lib/esm/core/parser/declaration.d.ts +15 -0
  158. package/lib/esm/core/parser/declaration.mjs +345 -0
  159. package/lib/esm/core/parser/declaration.mjs.map +1 -0
  160. package/lib/esm/core/parser/gradient.d.ts +59 -0
  161. package/lib/esm/core/parser/gradient.mjs +130 -0
  162. package/lib/esm/core/parser/gradient.mjs.map +1 -0
  163. package/lib/esm/core/parser/haptics.d.ts +47 -0
  164. package/lib/esm/core/parser/haptics.mjs +71 -0
  165. package/lib/esm/core/parser/haptics.mjs.map +1 -0
  166. package/lib/esm/core/parser/index.d.ts +8 -0
  167. package/lib/esm/core/parser/keyframes.d.ts +26 -0
  168. package/lib/esm/core/parser/keyframes.mjs +91 -0
  169. package/lib/esm/core/parser/keyframes.mjs.map +1 -0
  170. package/lib/esm/core/parser/layout-dispatcher.d.ts +14 -0
  171. package/lib/esm/core/parser/layout-dispatcher.mjs +98 -0
  172. package/lib/esm/core/parser/layout-dispatcher.mjs.map +1 -0
  173. package/lib/esm/core/parser/length.d.ts +48 -0
  174. package/lib/esm/core/parser/length.mjs +90 -0
  175. package/lib/esm/core/parser/length.mjs.map +1 -0
  176. package/lib/esm/core/parser/motion-dispatcher.d.ts +11 -0
  177. package/lib/esm/core/parser/motion-dispatcher.mjs +75 -0
  178. package/lib/esm/core/parser/motion-dispatcher.mjs.map +1 -0
  179. package/lib/esm/core/parser/property.d.ts +8 -0
  180. package/lib/esm/core/parser/property.mjs +20 -0
  181. package/lib/esm/core/parser/property.mjs.map +1 -0
  182. package/lib/esm/core/parser/safe-area.d.ts +39 -0
  183. package/lib/esm/core/parser/safe-area.mjs +402 -0
  184. package/lib/esm/core/parser/safe-area.mjs.map +1 -0
  185. package/lib/esm/core/parser/selector.d.ts +11 -0
  186. package/lib/esm/core/parser/selector.mjs +20 -0
  187. package/lib/esm/core/parser/selector.mjs.map +1 -0
  188. package/lib/esm/core/parser/shorthand.d.ts +61 -0
  189. package/lib/esm/core/parser/shorthand.mjs +148 -0
  190. package/lib/esm/core/parser/shorthand.mjs.map +1 -0
  191. package/lib/esm/core/parser/text-truncate.d.ts +44 -0
  192. package/lib/esm/core/parser/text-truncate.mjs +75 -0
  193. package/lib/esm/core/parser/text-truncate.mjs.map +1 -0
  194. package/lib/esm/core/parser/theme-vars.d.ts +61 -0
  195. package/lib/esm/core/parser/theme-vars.mjs +409 -0
  196. package/lib/esm/core/parser/theme-vars.mjs.map +1 -0
  197. package/lib/esm/core/parser/tokens.d.ts +45 -0
  198. package/lib/esm/core/parser/tokens.mjs +298 -0
  199. package/lib/esm/core/parser/tokens.mjs.map +1 -0
  200. package/lib/esm/core/parser/transform.d.ts +36 -0
  201. package/lib/esm/core/parser/transform.mjs +193 -0
  202. package/lib/esm/core/parser/transform.mjs.map +1 -0
  203. package/lib/esm/core/parser/tw-parser.d.ts +194 -0
  204. package/lib/esm/core/parser/tw-parser.mjs +1565 -0
  205. package/lib/esm/core/parser/tw-parser.mjs.map +1 -0
  206. package/lib/esm/core/parser/types.d.ts +37 -0
  207. package/lib/esm/core/parser/typography-dispatcher.d.ts +11 -0
  208. package/lib/esm/core/parser/typography-dispatcher.mjs +91 -0
  209. package/lib/esm/core/parser/typography-dispatcher.mjs.map +1 -0
  210. package/lib/esm/core/parser/typography.d.ts +43 -0
  211. package/lib/esm/core/parser/typography.mjs +91 -0
  212. package/lib/esm/core/parser/typography.mjs.map +1 -0
  213. package/lib/esm/core/style-builder/build-style.d.ts +54 -0
  214. package/lib/esm/core/style-builder/build-style.mjs +395 -0
  215. package/lib/esm/core/style-builder/build-style.mjs.map +1 -0
  216. package/lib/esm/core/style-builder/index.d.ts +3 -0
  217. package/lib/esm/core/style-builder/union-builder.d.ts +128 -0
  218. package/lib/esm/core/style-builder/union-builder.mjs +324 -0
  219. package/lib/esm/core/style-builder/union-builder.mjs.map +1 -0
  220. package/lib/esm/core/types.d.ts +14 -0
  221. package/lib/esm/metro/dts.d.ts +16 -0
  222. package/lib/esm/metro/dts.mjs +125 -0
  223. package/lib/esm/metro/dts.mjs.map +1 -0
  224. package/lib/esm/metro/index.d.ts +9 -0
  225. package/lib/esm/metro/index.mjs +6 -0
  226. package/lib/esm/metro/index.mjs.map +1 -0
  227. package/lib/esm/metro/resolver.d.ts +22 -0
  228. package/lib/esm/metro/resolver.mjs +43 -0
  229. package/lib/esm/metro/resolver.mjs.map +1 -0
  230. package/lib/esm/metro/state.d.ts +72 -0
  231. package/lib/esm/metro/state.mjs +243 -0
  232. package/lib/esm/metro/state.mjs.map +1 -0
  233. package/lib/esm/metro/transform-ast.d.ts +73 -0
  234. package/lib/esm/metro/transform-ast.mjs +1234 -0
  235. package/lib/esm/metro/transform-ast.mjs.map +1 -0
  236. package/lib/esm/metro/transformer.d.ts +47 -0
  237. package/lib/esm/metro/transformer.mjs +322 -0
  238. package/lib/esm/metro/transformer.mjs.map +1 -0
  239. package/lib/esm/metro/warn-unknown-classes.d.ts +21 -0
  240. package/lib/esm/metro/warn-unknown-classes.mjs +84 -0
  241. package/lib/esm/metro/warn-unknown-classes.mjs.map +1 -0
  242. package/lib/esm/metro/with-config.d.ts +57 -0
  243. package/lib/esm/metro/with-config.mjs +194 -0
  244. package/lib/esm/metro/with-config.mjs.map +1 -0
  245. package/lib/esm/runtime/chain-handlers.d.ts +33 -0
  246. package/lib/esm/runtime/chain-handlers.mjs +34 -0
  247. package/lib/esm/runtime/chain-handlers.mjs.map +1 -0
  248. package/lib/esm/runtime/components/rnwind-provider.d.ts +84 -0
  249. package/lib/esm/runtime/components/rnwind-provider.mjs +94 -0
  250. package/lib/esm/runtime/components/rnwind-provider.mjs.map +1 -0
  251. package/lib/esm/runtime/gradient-types.d.ts +58 -0
  252. package/lib/esm/runtime/haptics.d.ts +48 -0
  253. package/lib/esm/runtime/haptics.mjs +110 -0
  254. package/lib/esm/runtime/haptics.mjs.map +1 -0
  255. package/lib/esm/runtime/hooks/use-css.d.ts +11 -0
  256. package/lib/esm/runtime/hooks/use-css.mjs +19 -0
  257. package/lib/esm/runtime/hooks/use-css.mjs.map +1 -0
  258. package/lib/esm/runtime/hooks/use-interact.d.ts +42 -0
  259. package/lib/esm/runtime/hooks/use-interact.mjs +44 -0
  260. package/lib/esm/runtime/hooks/use-interact.mjs.map +1 -0
  261. package/lib/esm/runtime/hooks/use-scheme.d.ts +34 -0
  262. package/lib/esm/runtime/hooks/use-scheme.mjs +63 -0
  263. package/lib/esm/runtime/hooks/use-scheme.mjs.map +1 -0
  264. package/lib/esm/runtime/index.d.ts +27 -0
  265. package/lib/esm/runtime/index.mjs +18 -0
  266. package/lib/esm/runtime/index.mjs.map +1 -0
  267. package/lib/esm/runtime/interactive-box.d.ts +40 -0
  268. package/lib/esm/runtime/interactive-box.mjs +33 -0
  269. package/lib/esm/runtime/interactive-box.mjs.map +1 -0
  270. package/lib/esm/runtime/lookup-css.d.ts +164 -0
  271. package/lib/esm/runtime/lookup-css.mjs +531 -0
  272. package/lib/esm/runtime/lookup-css.mjs.map +1 -0
  273. package/lib/esm/runtime/types.d.ts +29 -0
  274. package/lib/esm/testing/index.d.ts +145 -0
  275. package/lib/esm/testing/index.mjs +344 -0
  276. package/lib/esm/testing/index.mjs.map +1 -0
  277. package/package.json +79 -13
  278. package/preset.css +1171 -0
  279. package/src/core/parser/animation.ts +404 -0
  280. package/src/core/parser/border-dispatcher.ts +176 -0
  281. package/src/core/parser/case-convert.ts +10 -0
  282. package/src/core/parser/color-properties-dispatcher.ts +78 -0
  283. package/src/core/parser/color.ts +157 -0
  284. package/src/core/parser/constants.ts +11 -0
  285. package/src/core/parser/declaration.ts +340 -0
  286. package/src/core/parser/gradient.ts +148 -0
  287. package/src/core/parser/haptics.ts +88 -0
  288. package/src/core/parser/index.ts +8 -0
  289. package/src/core/parser/keyframes.ts +84 -0
  290. package/src/core/parser/layout-dispatcher.ts +92 -0
  291. package/src/core/parser/length.ts +100 -0
  292. package/src/core/parser/motion-dispatcher.ts +89 -0
  293. package/src/core/parser/property.ts +15 -0
  294. package/src/core/parser/safe-area.ts +404 -0
  295. package/src/core/parser/selector.ts +17 -0
  296. package/src/core/parser/shorthand.ts +152 -0
  297. package/src/core/parser/text-truncate.ts +79 -0
  298. package/src/core/parser/theme-vars.ts +412 -0
  299. package/src/core/parser/tokens.ts +286 -0
  300. package/src/core/parser/transform.ts +195 -0
  301. package/src/core/parser/tw-parser.ts +1709 -0
  302. package/src/core/parser/types.ts +45 -0
  303. package/src/core/parser/typography-dispatcher.ts +83 -0
  304. package/src/core/parser/typography.ts +83 -0
  305. package/src/core/style-builder/build-style.ts +442 -0
  306. package/src/core/style-builder/index.ts +3 -0
  307. package/src/core/style-builder/union-builder.ts +328 -0
  308. package/src/core/types.ts +15 -0
  309. package/src/metro/dts.ts +128 -0
  310. package/src/metro/index.ts +9 -0
  311. package/src/metro/resolver.ts +42 -0
  312. package/src/metro/state.ts +257 -0
  313. package/src/metro/transform-ast.ts +1498 -0
  314. package/src/metro/transformer.ts +347 -0
  315. package/src/metro/warn-unknown-classes.ts +79 -0
  316. package/src/metro/with-config.ts +229 -0
  317. package/src/runtime/chain-handlers.ts +47 -0
  318. package/src/runtime/components/rnwind-provider.tsx +144 -0
  319. package/src/runtime/gradient-types.ts +60 -0
  320. package/src/runtime/haptics.ts +120 -0
  321. package/src/runtime/hooks/use-css.ts +16 -0
  322. package/src/runtime/hooks/use-interact.ts +65 -0
  323. package/src/runtime/hooks/use-scheme.ts +63 -0
  324. package/src/runtime/index.ts +54 -0
  325. package/src/runtime/interactive-box.tsx +57 -0
  326. package/src/runtime/lookup-css.ts +628 -0
  327. package/src/runtime/types.ts +32 -0
  328. package/src/testing/index.ts +507 -0
  329. package/src/types/tailwindcss-node.d.ts +33 -0
  330. package/src/index.ts +0 -1
@@ -0,0 +1,156 @@
1
+ 'use strict';
2
+
3
+ var color = require('./color.cjs');
4
+ var length = require('./length.cjs');
5
+
6
+ /**
7
+ * Expand `margin` / `padding` shorthand (`{top, right, bottom, left}`) to
8
+ * RN entries. When all four sides share the same converted value, collapse
9
+ * to the single-key shorthand RN accepts; otherwise emit four longhands.
10
+ * @param property `'padding'` or `'margin'`.
11
+ * @param value Typed shorthand record.
12
+ * @returns RN entries.
13
+ */
14
+ function expandFourSided(property, value) {
15
+ const top = length.lengthPercentageOrAutoToValue(value.top);
16
+ const right = length.lengthPercentageOrAutoToValue(value.right);
17
+ const bottom = length.lengthPercentageOrAutoToValue(value.bottom);
18
+ const left = length.lengthPercentageOrAutoToValue(value.left);
19
+ if (top === null || right === null || bottom === null || left === null)
20
+ return [];
21
+ if (top === right && right === bottom && bottom === left)
22
+ return [[property, top]];
23
+ return [
24
+ [`${property}Top`, top],
25
+ [`${property}Right`, right],
26
+ [`${property}Bottom`, bottom],
27
+ [`${property}Left`, left],
28
+ ];
29
+ }
30
+ /**
31
+ * Expand `padding-inline` / `margin-inline` (logical property) into RN's
32
+ * physical left / right pair. RN has no RTL-aware logical props at the
33
+ * style-object level, so we lower at compile time.
34
+ * @param property `'padding'` or `'margin'`.
35
+ * @param value Typed inline shorthand.
36
+ * @returns RN entries.
37
+ */
38
+ function expandLogicalInline(property, value) {
39
+ const start = length.lengthPercentageOrAutoToValue(value.inlineStart);
40
+ const end = length.lengthPercentageOrAutoToValue(value.inlineEnd);
41
+ if (start === null || end === null)
42
+ return [];
43
+ return [
44
+ [`${property}Left`, start],
45
+ [`${property}Right`, end],
46
+ ];
47
+ }
48
+ /**
49
+ * Expand `padding-block` / `margin-block` (logical property) into RN's
50
+ * physical top / bottom pair.
51
+ * @param property `'padding'` or `'margin'`.
52
+ * @param value Typed block shorthand.
53
+ * @returns RN entries.
54
+ */
55
+ function expandLogicalBlock(property, value) {
56
+ const start = length.lengthPercentageOrAutoToValue(value.blockStart);
57
+ const end = length.lengthPercentageOrAutoToValue(value.blockEnd);
58
+ if (start === null || end === null)
59
+ return [];
60
+ return [
61
+ [`${property}Top`, start],
62
+ [`${property}Bottom`, end],
63
+ ];
64
+ }
65
+ /**
66
+ * Expand a `border-radius` shorthand into RN corner entries. Each corner
67
+ * is a 2-tuple `[x, y]` in lightningcss; RN exposes one radius per corner
68
+ * so we use the x-axis. When all four corners match, collapse to the
69
+ * single `borderRadius` key.
70
+ * @param value Typed `BorderRadius` record.
71
+ * @returns RN entries.
72
+ */
73
+ function expandBorderRadius(value) {
74
+ const corners = [
75
+ ['borderTopLeftRadius', length.dimensionPercentageToNumber(value.topLeft[0])],
76
+ ['borderTopRightRadius', length.dimensionPercentageToNumber(value.topRight[0])],
77
+ ['borderBottomRightRadius', length.dimensionPercentageToNumber(value.bottomRight[0])],
78
+ ['borderBottomLeftRadius', length.dimensionPercentageToNumber(value.bottomLeft[0])],
79
+ ];
80
+ const [first] = corners;
81
+ if (first?.[1] == null)
82
+ return [];
83
+ if (corners.every(([, v]) => v === first[1]))
84
+ return [['borderRadius', first[1]]];
85
+ return corners.filter((entry) => entry[1] !== null);
86
+ }
87
+ /**
88
+ * Expand a `border-color` shorthand into RN longhands. When all four
89
+ * sides match, collapse to a single `borderColor`; otherwise emit per-side
90
+ * props.
91
+ * @param value Typed `BorderColor` record.
92
+ * @returns RN entries.
93
+ */
94
+ function expandBorderColor(value) {
95
+ const top = color.cssColorToString(value.top);
96
+ const right = color.cssColorToString(value.right);
97
+ const bottom = color.cssColorToString(value.bottom);
98
+ const left = color.cssColorToString(value.left);
99
+ if (top === right && right === bottom && bottom === left)
100
+ return [['borderColor', top]];
101
+ return [
102
+ ['borderTopColor', top],
103
+ ['borderRightColor', right],
104
+ ['borderBottomColor', bottom],
105
+ ['borderLeftColor', left],
106
+ ];
107
+ }
108
+ /**
109
+ * Expand `gap` shorthand (`{row, column}`) into RN entries. When both
110
+ * axes equal the same value collapse to the single `gap` key; otherwise
111
+ * emit `rowGap` + `columnGap`.
112
+ * @param value Typed `Gap` record.
113
+ * @returns RN entries.
114
+ */
115
+ function expandGap(value) {
116
+ const row = length.gapValueToValue(value.row);
117
+ const column = length.gapValueToValue(value.column);
118
+ if (row === null || column === null)
119
+ return [];
120
+ if (row === column)
121
+ return [['gap', row]];
122
+ return [
123
+ ['rowGap', row],
124
+ ['columnGap', column],
125
+ ];
126
+ }
127
+ /**
128
+ * Convert `Flex` shorthand to RN entries. When the shape matches `flex:
129
+ * 1` (`{grow:1, shrink:1, basis: 0%}`), emit the single `flex` key RN
130
+ * understands. Otherwise expand to the three longhands.
131
+ * @param value Typed `Flex` record.
132
+ * @returns RN entries.
133
+ */
134
+ function flexToEntries(value) {
135
+ const basis = length.lengthPercentageOrAutoToValue(value.basis);
136
+ if (basis === null)
137
+ return [];
138
+ if (value.grow === 1 && value.shrink === 1 && basis === '0%')
139
+ return [['flex', 1]];
140
+ const entries = [
141
+ ['flexGrow', value.grow],
142
+ ['flexShrink', value.shrink],
143
+ ];
144
+ if (basis !== 'auto')
145
+ entries.push(['flexBasis', basis]);
146
+ return entries;
147
+ }
148
+
149
+ exports.expandBorderColor = expandBorderColor;
150
+ exports.expandBorderRadius = expandBorderRadius;
151
+ exports.expandFourSided = expandFourSided;
152
+ exports.expandGap = expandGap;
153
+ exports.expandLogicalBlock = expandLogicalBlock;
154
+ exports.expandLogicalInline = expandLogicalInline;
155
+ exports.flexToEntries = flexToEntries;
156
+ //# sourceMappingURL=shorthand.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shorthand.cjs","sources":["../../../../../src/core/parser/shorthand.ts"],"sourcesContent":["import type {\n BorderColor,\n BorderRadius,\n Flex,\n Gap,\n Margin,\n MarginBlock,\n MarginInline,\n Padding,\n PaddingBlock,\n PaddingInline,\n} from 'lightningcss'\nimport { cssColorToString } from './color'\nimport { dimensionPercentageToNumber, gapValueToValue, lengthPercentageOrAutoToValue } from './length'\nimport type { RNEntry } from './types'\n\n/**\n * Expand `margin` / `padding` shorthand (`{top, right, bottom, left}`) to\n * RN entries. When all four sides share the same converted value, collapse\n * to the single-key shorthand RN accepts; otherwise emit four longhands.\n * @param property `'padding'` or `'margin'`.\n * @param value Typed shorthand record.\n * @returns RN entries.\n */\nexport function expandFourSided(property: 'padding' | 'margin', value: Padding | Margin): readonly RNEntry[] {\n const top = lengthPercentageOrAutoToValue(value.top)\n const right = lengthPercentageOrAutoToValue(value.right)\n const bottom = lengthPercentageOrAutoToValue(value.bottom)\n const left = lengthPercentageOrAutoToValue(value.left)\n if (top === null || right === null || bottom === null || left === null) return []\n if (top === right && right === bottom && bottom === left) return [[property, top]]\n return [\n [`${property}Top`, top],\n [`${property}Right`, right],\n [`${property}Bottom`, bottom],\n [`${property}Left`, left],\n ]\n}\n\n/**\n * Expand `padding-inline` / `margin-inline` (logical property) into RN's\n * physical left / right pair. RN has no RTL-aware logical props at the\n * style-object level, so we lower at compile time.\n * @param property `'padding'` or `'margin'`.\n * @param value Typed inline shorthand.\n * @returns RN entries.\n */\nexport function expandLogicalInline(property: 'padding' | 'margin', value: PaddingInline | MarginInline): readonly RNEntry[] {\n const start = lengthPercentageOrAutoToValue(value.inlineStart)\n const end = lengthPercentageOrAutoToValue(value.inlineEnd)\n if (start === null || end === null) return []\n return [\n [`${property}Left`, start],\n [`${property}Right`, end],\n ]\n}\n\n/**\n * Expand `padding-block` / `margin-block` (logical property) into RN's\n * physical top / bottom pair.\n * @param property `'padding'` or `'margin'`.\n * @param value Typed block shorthand.\n * @returns RN entries.\n */\nexport function expandLogicalBlock(property: 'padding' | 'margin', value: PaddingBlock | MarginBlock): readonly RNEntry[] {\n const start = lengthPercentageOrAutoToValue(value.blockStart)\n const end = lengthPercentageOrAutoToValue(value.blockEnd)\n if (start === null || end === null) return []\n return [\n [`${property}Top`, start],\n [`${property}Bottom`, end],\n ]\n}\n\n/**\n * Expand a `border-radius` shorthand into RN corner entries. Each corner\n * is a 2-tuple `[x, y]` in lightningcss; RN exposes one radius per corner\n * so we use the x-axis. When all four corners match, collapse to the\n * single `borderRadius` key.\n * @param value Typed `BorderRadius` record.\n * @returns RN entries.\n */\nexport function expandBorderRadius(value: BorderRadius): readonly RNEntry[] {\n const corners: Array<[string, number | string | null]> = [\n ['borderTopLeftRadius', dimensionPercentageToNumber(value.topLeft[0])],\n ['borderTopRightRadius', dimensionPercentageToNumber(value.topRight[0])],\n ['borderBottomRightRadius', dimensionPercentageToNumber(value.bottomRight[0])],\n ['borderBottomLeftRadius', dimensionPercentageToNumber(value.bottomLeft[0])],\n ]\n const [first] = corners\n if (first?.[1] == null) return []\n if (corners.every(([, v]) => v === first[1])) return [['borderRadius', first[1]]]\n return corners.filter((entry): entry is [string, number | string] => entry[1] !== null)\n}\n\n/**\n * Expand a `border-color` shorthand into RN longhands. When all four\n * sides match, collapse to a single `borderColor`; otherwise emit per-side\n * props.\n * @param value Typed `BorderColor` record.\n * @returns RN entries.\n */\nexport function expandBorderColor(value: BorderColor): readonly RNEntry[] {\n const top = cssColorToString(value.top)\n const right = cssColorToString(value.right)\n const bottom = cssColorToString(value.bottom)\n const left = cssColorToString(value.left)\n if (top === right && right === bottom && bottom === left) return [['borderColor', top]]\n return [\n ['borderTopColor', top],\n ['borderRightColor', right],\n ['borderBottomColor', bottom],\n ['borderLeftColor', left],\n ]\n}\n\n/**\n * Expand `gap` shorthand (`{row, column}`) into RN entries. When both\n * axes equal the same value collapse to the single `gap` key; otherwise\n * emit `rowGap` + `columnGap`.\n * @param value Typed `Gap` record.\n * @returns RN entries.\n */\nexport function expandGap(value: Gap): readonly RNEntry[] {\n const row = gapValueToValue(value.row)\n const column = gapValueToValue(value.column)\n if (row === null || column === null) return []\n if (row === column) return [['gap', row]]\n return [\n ['rowGap', row],\n ['columnGap', column],\n ]\n}\n\n/**\n * Convert `Flex` shorthand to RN entries. When the shape matches `flex:\n * 1` (`{grow:1, shrink:1, basis: 0%}`), emit the single `flex` key RN\n * understands. Otherwise expand to the three longhands.\n * @param value Typed `Flex` record.\n * @returns RN entries.\n */\nexport function flexToEntries(value: Flex): readonly RNEntry[] {\n const basis = lengthPercentageOrAutoToValue(value.basis)\n if (basis === null) return []\n if (value.grow === 1 && value.shrink === 1 && basis === '0%') return [['flex', 1]]\n const entries: RNEntry[] = [\n ['flexGrow', value.grow],\n ['flexShrink', value.shrink],\n ]\n if (basis !== 'auto') entries.push(['flexBasis', basis])\n return entries\n}\n"],"names":["lengthPercentageOrAutoToValue","dimensionPercentageToNumber","cssColorToString","gapValueToValue"],"mappings":";;;;;A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;IACzC,OAAO;QACL,CAAC,QAAQ,EAAE,GAAG,CAAC;QACf,CAAC,WAAW,EAAE,MAAM,CAAC;KACtB;AACH;AAEA;;;;;;AAMG;AACG,SAAU,aAAa,CAAC,KAAW,EAAA;IACvC,MAAM,KAAK,GAAGH,oCAA6B,CAAC,KAAK,CAAC,KAAK,CAAC;IACxD,IAAI,KAAK,KAAK,IAAI;AAAE,QAAA,OAAO,EAAE;AAC7B,IAAA,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,KAAK,IAAI;AAAE,QAAA,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAClF,IAAA,MAAM,OAAO,GAAc;AACzB,QAAA,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC;AACxB,QAAA,CAAC,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC;KAC7B;IACD,IAAI,KAAK,KAAK,MAAM;QAAE,OAAO,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;AACxD,IAAA,OAAO,OAAO;AAChB;;;;;;;;;;"}
@@ -0,0 +1,61 @@
1
+ import type { BorderColor, BorderRadius, Flex, Gap, Margin, MarginBlock, MarginInline, Padding, PaddingBlock, PaddingInline } from 'lightningcss';
2
+ import type { RNEntry } from './types';
3
+ /**
4
+ * Expand `margin` / `padding` shorthand (`{top, right, bottom, left}`) to
5
+ * RN entries. When all four sides share the same converted value, collapse
6
+ * to the single-key shorthand RN accepts; otherwise emit four longhands.
7
+ * @param property `'padding'` or `'margin'`.
8
+ * @param value Typed shorthand record.
9
+ * @returns RN entries.
10
+ */
11
+ export declare function expandFourSided(property: 'padding' | 'margin', value: Padding | Margin): readonly RNEntry[];
12
+ /**
13
+ * Expand `padding-inline` / `margin-inline` (logical property) into RN's
14
+ * physical left / right pair. RN has no RTL-aware logical props at the
15
+ * style-object level, so we lower at compile time.
16
+ * @param property `'padding'` or `'margin'`.
17
+ * @param value Typed inline shorthand.
18
+ * @returns RN entries.
19
+ */
20
+ export declare function expandLogicalInline(property: 'padding' | 'margin', value: PaddingInline | MarginInline): readonly RNEntry[];
21
+ /**
22
+ * Expand `padding-block` / `margin-block` (logical property) into RN's
23
+ * physical top / bottom pair.
24
+ * @param property `'padding'` or `'margin'`.
25
+ * @param value Typed block shorthand.
26
+ * @returns RN entries.
27
+ */
28
+ export declare function expandLogicalBlock(property: 'padding' | 'margin', value: PaddingBlock | MarginBlock): readonly RNEntry[];
29
+ /**
30
+ * Expand a `border-radius` shorthand into RN corner entries. Each corner
31
+ * is a 2-tuple `[x, y]` in lightningcss; RN exposes one radius per corner
32
+ * so we use the x-axis. When all four corners match, collapse to the
33
+ * single `borderRadius` key.
34
+ * @param value Typed `BorderRadius` record.
35
+ * @returns RN entries.
36
+ */
37
+ export declare function expandBorderRadius(value: BorderRadius): readonly RNEntry[];
38
+ /**
39
+ * Expand a `border-color` shorthand into RN longhands. When all four
40
+ * sides match, collapse to a single `borderColor`; otherwise emit per-side
41
+ * props.
42
+ * @param value Typed `BorderColor` record.
43
+ * @returns RN entries.
44
+ */
45
+ export declare function expandBorderColor(value: BorderColor): readonly RNEntry[];
46
+ /**
47
+ * Expand `gap` shorthand (`{row, column}`) into RN entries. When both
48
+ * axes equal the same value collapse to the single `gap` key; otherwise
49
+ * emit `rowGap` + `columnGap`.
50
+ * @param value Typed `Gap` record.
51
+ * @returns RN entries.
52
+ */
53
+ export declare function expandGap(value: Gap): readonly RNEntry[];
54
+ /**
55
+ * Convert `Flex` shorthand to RN entries. When the shape matches `flex:
56
+ * 1` (`{grow:1, shrink:1, basis: 0%}`), emit the single `flex` key RN
57
+ * understands. Otherwise expand to the three longhands.
58
+ * @param value Typed `Flex` record.
59
+ * @returns RN entries.
60
+ */
61
+ export declare function flexToEntries(value: Flex): readonly RNEntry[];
@@ -0,0 +1,78 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Text-truncate atom detector.
5
+ *
6
+ * React Native's `<Text>` exposes two props that cover every case
7
+ * Tailwind's text-truncation utilities express:
8
+ *
9
+ * numberOfLines — clamp after N lines (1 for single-line ellipsis)
10
+ * ellipsizeMode — 'tail' (ellipsis) or 'clip' at the truncation point
11
+ *
12
+ * rnwind treats the Tailwind classes as **metadata**: the transformer
13
+ * strips the truncate atoms from the JSX site's className and emits
14
+ * `numberOfLines={N}` / `ellipsizeMode="tail"` props on the element.
15
+ *
16
+ * Covered atoms:
17
+ * truncate → { numberOfLines: 1, ellipsizeMode: 'tail' }
18
+ * text-ellipsis → { ellipsizeMode: 'tail' }
19
+ * text-clip → { ellipsizeMode: 'clip' }
20
+ * line-clamp-<N> → { numberOfLines: <N> }
21
+ * line-clamp-none → { numberOfLines: 0 } (reset — overrides prior)
22
+ *
23
+ * Detection is pure name matching — no CSS inspection — because every
24
+ * relevant piece of data lives in the class name itself.
25
+ */
26
+ /** Regex matching `line-clamp-<N>` with a positive-integer N. */
27
+ const LINE_CLAMP_RE = /^line-clamp-(\d+)$/;
28
+ /** Regex matching Tailwind v4's `line-clamp-[<value>]` arbitrary form. */
29
+ const LINE_CLAMP_ARBITRARY_RE = /^line-clamp-\[([^\]]+)\]$/;
30
+ /**
31
+ * Inspect one class-name token and return the text-truncate metadata it
32
+ * contributes, or `null` when the atom isn't a truncate utility.
33
+ * @param atom Single class-name token (no variant prefix).
34
+ * @returns The atom's contribution, or null.
35
+ */
36
+ function detectTextTruncate(atom) {
37
+ if (atom === 'truncate')
38
+ return { numberOfLines: 1, ellipsizeMode: 'tail' };
39
+ if (atom === 'text-ellipsis')
40
+ return { ellipsizeMode: 'tail' };
41
+ if (atom === 'text-clip')
42
+ return { ellipsizeMode: 'clip' };
43
+ if (atom === 'line-clamp-none')
44
+ return { numberOfLines: 0 };
45
+ const numeric = LINE_CLAMP_RE.exec(atom);
46
+ if (numeric)
47
+ return { numberOfLines: Number(numeric[1]) };
48
+ const arbitrary = LINE_CLAMP_ARBITRARY_RE.exec(atom);
49
+ if (arbitrary) {
50
+ const n = Number.parseInt(arbitrary[1], 10);
51
+ if (Number.isFinite(n) && n >= 0)
52
+ return { numberOfLines: n };
53
+ }
54
+ return null;
55
+ }
56
+ /**
57
+ * Fast pre-check — returns true when ANY atom in the list could be a
58
+ * truncate utility, false when none can. Lets callers skip the
59
+ * allocation of the merge pass for the common "no truncate" case.
60
+ * @param atoms Tokenised atom list from a literal className.
61
+ * @returns Whether to run the full per-atom detection.
62
+ */
63
+ function mayContainTextTruncate(atoms) {
64
+ for (const atom of atoms) {
65
+ if (atom === 'truncate' ||
66
+ atom === 'text-ellipsis' ||
67
+ atom === 'text-clip' ||
68
+ atom === 'line-clamp-none' ||
69
+ atom.startsWith('line-clamp-')) {
70
+ return true;
71
+ }
72
+ }
73
+ return false;
74
+ }
75
+
76
+ exports.detectTextTruncate = detectTextTruncate;
77
+ exports.mayContainTextTruncate = mayContainTextTruncate;
78
+ //# sourceMappingURL=text-truncate.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-truncate.cjs","sources":["../../../../../src/core/parser/text-truncate.ts"],"sourcesContent":["/**\n * Text-truncate atom detector.\n *\n * React Native's `<Text>` exposes two props that cover every case\n * Tailwind's text-truncation utilities express:\n *\n * numberOfLines — clamp after N lines (1 for single-line ellipsis)\n * ellipsizeMode — 'tail' (ellipsis) or 'clip' at the truncation point\n *\n * rnwind treats the Tailwind classes as **metadata**: the transformer\n * strips the truncate atoms from the JSX site's className and emits\n * `numberOfLines={N}` / `ellipsizeMode=\"tail\"` props on the element.\n *\n * Covered atoms:\n * truncate → { numberOfLines: 1, ellipsizeMode: 'tail' }\n * text-ellipsis → { ellipsizeMode: 'tail' }\n * text-clip → { ellipsizeMode: 'clip' }\n * line-clamp-<N> → { numberOfLines: <N> }\n * line-clamp-none → { numberOfLines: 0 } (reset — overrides prior)\n *\n * Detection is pure name matching — no CSS inspection — because every\n * relevant piece of data lives in the class name itself.\n */\n\n/** Text-truncate metadata produced by a single atom. */\nexport interface TextTruncateInfo {\n readonly numberOfLines?: number\n readonly ellipsizeMode?: 'tail' | 'clip'\n}\n\n/** Regex matching `line-clamp-<N>` with a positive-integer N. */\nconst LINE_CLAMP_RE = /^line-clamp-(\\d+)$/\n/** Regex matching Tailwind v4's `line-clamp-[<value>]` arbitrary form. */\nconst LINE_CLAMP_ARBITRARY_RE = /^line-clamp-\\[([^\\]]+)\\]$/\n\n/**\n * Inspect one class-name token and return the text-truncate metadata it\n * contributes, or `null` when the atom isn't a truncate utility.\n * @param atom Single class-name token (no variant prefix).\n * @returns The atom's contribution, or null.\n */\nfunction detectTextTruncate(atom: string): TextTruncateInfo | null {\n if (atom === 'truncate') return { numberOfLines: 1, ellipsizeMode: 'tail' }\n if (atom === 'text-ellipsis') return { ellipsizeMode: 'tail' }\n if (atom === 'text-clip') return { ellipsizeMode: 'clip' }\n if (atom === 'line-clamp-none') return { numberOfLines: 0 }\n const numeric = LINE_CLAMP_RE.exec(atom)\n if (numeric) return { numberOfLines: Number(numeric[1]) }\n const arbitrary = LINE_CLAMP_ARBITRARY_RE.exec(atom)\n if (arbitrary) {\n const n = Number.parseInt(arbitrary[1]!, 10)\n if (Number.isFinite(n) && n >= 0) return { numberOfLines: n }\n }\n return null\n}\n\n/**\n * Fast pre-check — returns true when ANY atom in the list could be a\n * truncate utility, false when none can. Lets callers skip the\n * allocation of the merge pass for the common \"no truncate\" case.\n * @param atoms Tokenised atom list from a literal className.\n * @returns Whether to run the full per-atom detection.\n */\nfunction mayContainTextTruncate(atoms: readonly string[]): boolean {\n for (const atom of atoms) {\n if (\n atom === 'truncate' ||\n atom === 'text-ellipsis' ||\n atom === 'text-clip' ||\n atom === 'line-clamp-none' ||\n atom.startsWith('line-clamp-')\n ) {\n return true\n }\n }\n return false\n}\n\nexport { detectTextTruncate, mayContainTextTruncate }\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;;;;;;;AAsBG;AAQH;AACA,MAAM,aAAa,GAAG,oBAAoB;AAC1C;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AI;QACb;IACF;AACA,IAAA,OAAO,KAAK;AACd;;;;;"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Text-truncate atom detector.
3
+ *
4
+ * React Native's `<Text>` exposes two props that cover every case
5
+ * Tailwind's text-truncation utilities express:
6
+ *
7
+ * numberOfLines — clamp after N lines (1 for single-line ellipsis)
8
+ * ellipsizeMode — 'tail' (ellipsis) or 'clip' at the truncation point
9
+ *
10
+ * rnwind treats the Tailwind classes as **metadata**: the transformer
11
+ * strips the truncate atoms from the JSX site's className and emits
12
+ * `numberOfLines={N}` / `ellipsizeMode="tail"` props on the element.
13
+ *
14
+ * Covered atoms:
15
+ * truncate → { numberOfLines: 1, ellipsizeMode: 'tail' }
16
+ * text-ellipsis → { ellipsizeMode: 'tail' }
17
+ * text-clip → { ellipsizeMode: 'clip' }
18
+ * line-clamp-<N> → { numberOfLines: <N> }
19
+ * line-clamp-none → { numberOfLines: 0 } (reset — overrides prior)
20
+ *
21
+ * Detection is pure name matching — no CSS inspection — because every
22
+ * relevant piece of data lives in the class name itself.
23
+ */
24
+ /** Text-truncate metadata produced by a single atom. */
25
+ export interface TextTruncateInfo {
26
+ readonly numberOfLines?: number;
27
+ readonly ellipsizeMode?: 'tail' | 'clip';
28
+ }
29
+ /**
30
+ * Inspect one class-name token and return the text-truncate metadata it
31
+ * contributes, or `null` when the atom isn't a truncate utility.
32
+ * @param atom Single class-name token (no variant prefix).
33
+ * @returns The atom's contribution, or null.
34
+ */
35
+ declare function detectTextTruncate(atom: string): TextTruncateInfo | null;
36
+ /**
37
+ * Fast pre-check — returns true when ANY atom in the list could be a
38
+ * truncate utility, false when none can. Lets callers skip the
39
+ * allocation of the merge pass for the common "no truncate" case.
40
+ * @param atoms Tokenised atom list from a literal className.
41
+ * @returns Whether to run the full per-atom detection.
42
+ */
43
+ declare function mayContainTextTruncate(atoms: readonly string[]): boolean;
44
+ export { detectTextTruncate, mayContainTextTruncate };