@tamagui/style-grammar 3.0.0-beta.924.1 → 3.0.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 (246) hide show
  1. package/dist/cjs/ast/payloadShape.cjs +45 -17
  2. package/dist/cjs/ast/payloadShape.native.cjs +45 -17
  3. package/dist/cjs/ast/payloadShape.native.js +45 -17
  4. package/dist/cjs/ast/payloadShape.native.js.map +1 -1
  5. package/dist/cjs/ast/resolvePayload.cjs +16 -9
  6. package/dist/cjs/ast/resolvePayload.native.cjs +16 -9
  7. package/dist/cjs/ast/resolvePayload.native.js +16 -9
  8. package/dist/cjs/ast/resolvePayload.native.js.map +1 -1
  9. package/dist/cjs/programs/lowerProgram.cjs +2 -2
  10. package/dist/cjs/programs/lowerProgram.native.cjs +2 -2
  11. package/dist/cjs/programs/lowerProgram.native.js +2 -2
  12. package/dist/cjs/programs/lowerProgram.native.js.map +1 -1
  13. package/dist/cjs/runtime/clauseIdentity.cjs +9 -28
  14. package/dist/cjs/runtime/clauseIdentity.native.cjs +9 -28
  15. package/dist/cjs/runtime/clauseIdentity.native.js +9 -28
  16. package/dist/cjs/runtime/clauseIdentity.native.js.map +1 -1
  17. package/dist/cjs/runtime/clausePrecedence.cjs +2 -2
  18. package/dist/cjs/runtime/clausePrecedence.native.cjs +3 -10
  19. package/dist/cjs/runtime/clausePrecedence.native.js +3 -10
  20. package/dist/cjs/runtime/clausePrecedence.native.js.map +1 -1
  21. package/dist/cjs/runtime/modifierVocabulary.native.cjs +1 -8
  22. package/dist/cjs/runtime/modifierVocabulary.native.js +1 -8
  23. package/dist/cjs/runtime/modifierVocabulary.native.js.map +1 -1
  24. package/dist/cjs/runtime/scanFlatValue.cjs +58 -7
  25. package/dist/cjs/runtime/scanFlatValue.native.cjs +58 -7
  26. package/dist/cjs/runtime/scanFlatValue.native.js +58 -7
  27. package/dist/cjs/runtime/scanFlatValue.native.js.map +1 -1
  28. package/dist/cjs/runtime/spring.cjs +123 -0
  29. package/dist/cjs/runtime/spring.native.cjs +131 -0
  30. package/dist/cjs/runtime/spring.native.js +133 -0
  31. package/dist/cjs/runtime/spring.native.js.map +1 -0
  32. package/dist/cjs/runtime/stateModifiers.cjs +23 -1
  33. package/dist/cjs/runtime/stateModifiers.native.cjs +23 -1
  34. package/dist/cjs/runtime/stateModifiers.native.js +23 -1
  35. package/dist/cjs/runtime/stateModifiers.native.js.map +1 -1
  36. package/dist/cjs/runtime/tokenCategories.cjs +3 -0
  37. package/dist/cjs/runtime/tokenCategories.native.cjs +3 -0
  38. package/dist/cjs/runtime/tokenCategories.native.js +3 -0
  39. package/dist/cjs/runtime/tokenCategories.native.js.map +1 -1
  40. package/dist/cjs/runtime/unitlessNumbers.cjs +0 -5
  41. package/dist/cjs/runtime/unitlessNumbers.native.cjs +0 -5
  42. package/dist/cjs/runtime/unitlessNumbers.native.js +0 -5
  43. package/dist/cjs/runtime/unitlessNumbers.native.js.map +1 -1
  44. package/dist/cjs/runtime.cjs +11 -0
  45. package/dist/cjs/runtime.native.cjs +11 -0
  46. package/dist/cjs/runtime.native.js +11 -0
  47. package/dist/cjs/runtime.native.js.map +1 -1
  48. package/dist/cjs/shorthands/transition.cjs +111 -36
  49. package/dist/cjs/shorthands/transition.native.cjs +113 -36
  50. package/dist/cjs/shorthands/transition.native.js +113 -36
  51. package/dist/cjs/shorthands/transition.native.js.map +1 -1
  52. package/dist/cjs/shorthands/transitionAlign.cjs +13 -10
  53. package/dist/cjs/shorthands/transitionAlign.native.cjs +14 -11
  54. package/dist/cjs/shorthands/transitionAlign.native.js +14 -11
  55. package/dist/cjs/shorthands/transitionAlign.native.js.map +1 -1
  56. package/dist/cjs/shorthands/transitionLegacy.cjs +263 -126
  57. package/dist/cjs/shorthands/transitionLegacy.native.cjs +333 -155
  58. package/dist/cjs/shorthands/transitionLegacy.native.js +333 -155
  59. package/dist/cjs/shorthands/transitionLegacy.native.js.map +1 -1
  60. package/dist/cjs/shorthands/transitionNative.cjs +5 -5
  61. package/dist/cjs/shorthands/transitionNative.native.cjs +8 -7
  62. package/dist/cjs/shorthands/transitionNative.native.js +8 -7
  63. package/dist/cjs/shorthands/transitionNative.native.js.map +1 -1
  64. package/dist/cjs/shorthands/transitionObject.cjs +302 -0
  65. package/dist/cjs/shorthands/transitionObject.native.cjs +347 -0
  66. package/dist/cjs/shorthands/transitionObject.native.js +349 -0
  67. package/dist/cjs/shorthands/transitionObject.native.js.map +1 -0
  68. package/dist/cjs/tooling/candidate.cjs +254 -15
  69. package/dist/cjs/tooling/candidate.native.cjs +314 -62
  70. package/dist/cjs/tooling/candidate.native.js +314 -62
  71. package/dist/cjs/tooling/candidate.native.js.map +1 -1
  72. package/dist/cjs/tooling/config.cjs +19 -9
  73. package/dist/cjs/tooling/config.native.cjs +25 -26
  74. package/dist/cjs/tooling/config.native.js +25 -26
  75. package/dist/cjs/tooling/config.native.js.map +1 -1
  76. package/dist/cjs/tooling/registry.cjs +579 -11
  77. package/dist/cjs/tooling/registry.native.cjs +579 -11
  78. package/dist/cjs/tooling/registry.native.js +579 -11
  79. package/dist/cjs/tooling/registry.native.js.map +1 -1
  80. package/dist/cjs/tooling/toolingDiagnostics.cjs +306 -10
  81. package/dist/cjs/tooling/toolingDiagnostics.native.cjs +408 -48
  82. package/dist/cjs/tooling/toolingDiagnostics.native.js +408 -48
  83. package/dist/cjs/tooling/toolingDiagnostics.native.js.map +1 -1
  84. package/dist/cjs/tooling/toolingRegistry.cjs +6 -1
  85. package/dist/cjs/tooling/toolingRegistry.native.cjs +9 -1
  86. package/dist/cjs/tooling/toolingRegistry.native.js +9 -1
  87. package/dist/cjs/tooling/toolingRegistry.native.js.map +1 -1
  88. package/dist/cjs/tooling.cjs +1 -0
  89. package/dist/cjs/tooling.native.cjs +1 -0
  90. package/dist/cjs/tooling.native.js +1 -0
  91. package/dist/cjs/tooling.native.js.map +1 -1
  92. package/dist/cjs/transitions.cjs +38 -0
  93. package/dist/cjs/transitions.native.cjs +40 -0
  94. package/dist/cjs/transitions.native.js +42 -0
  95. package/dist/cjs/transitions.native.js.map +1 -0
  96. package/dist/esm/ast/payloadShape.mjs +45 -17
  97. package/dist/esm/ast/payloadShape.mjs.map +1 -1
  98. package/dist/esm/ast/payloadShape.native.js +45 -17
  99. package/dist/esm/ast/payloadShape.native.js.map +1 -1
  100. package/dist/esm/ast/resolvePayload.mjs +16 -9
  101. package/dist/esm/ast/resolvePayload.mjs.map +1 -1
  102. package/dist/esm/ast/resolvePayload.native.js +16 -9
  103. package/dist/esm/ast/resolvePayload.native.js.map +1 -1
  104. package/dist/esm/programs/lowerProgram.mjs +2 -2
  105. package/dist/esm/programs/lowerProgram.mjs.map +1 -1
  106. package/dist/esm/programs/lowerProgram.native.js +2 -2
  107. package/dist/esm/programs/lowerProgram.native.js.map +1 -1
  108. package/dist/esm/runtime/clauseIdentity.mjs +2 -22
  109. package/dist/esm/runtime/clauseIdentity.mjs.map +1 -1
  110. package/dist/esm/runtime/clauseIdentity.native.js +2 -22
  111. package/dist/esm/runtime/clauseIdentity.native.js.map +1 -1
  112. package/dist/esm/runtime/clausePrecedence.mjs +2 -2
  113. package/dist/esm/runtime/clausePrecedence.mjs.map +1 -1
  114. package/dist/esm/runtime/clausePrecedence.native.js +3 -10
  115. package/dist/esm/runtime/clausePrecedence.native.js.map +1 -1
  116. package/dist/esm/runtime/modifierVocabulary.native.js +1 -8
  117. package/dist/esm/runtime/modifierVocabulary.native.js.map +1 -1
  118. package/dist/esm/runtime/scanFlatValue.mjs +59 -7
  119. package/dist/esm/runtime/scanFlatValue.mjs.map +1 -1
  120. package/dist/esm/runtime/scanFlatValue.native.js +59 -7
  121. package/dist/esm/runtime/scanFlatValue.native.js.map +1 -1
  122. package/dist/esm/runtime/spring.mjs +93 -0
  123. package/dist/esm/runtime/spring.mjs.map +1 -0
  124. package/dist/esm/runtime/spring.native.js +99 -0
  125. package/dist/esm/runtime/spring.native.js.map +1 -0
  126. package/dist/esm/runtime/stateModifiers.mjs +22 -2
  127. package/dist/esm/runtime/stateModifiers.mjs.map +1 -1
  128. package/dist/esm/runtime/stateModifiers.native.js +22 -2
  129. package/dist/esm/runtime/stateModifiers.native.js.map +1 -1
  130. package/dist/esm/runtime/tokenCategories.mjs +3 -0
  131. package/dist/esm/runtime/tokenCategories.mjs.map +1 -1
  132. package/dist/esm/runtime/tokenCategories.native.js +3 -0
  133. package/dist/esm/runtime/tokenCategories.native.js.map +1 -1
  134. package/dist/esm/runtime/unitlessNumbers.mjs +0 -5
  135. package/dist/esm/runtime/unitlessNumbers.mjs.map +1 -1
  136. package/dist/esm/runtime/unitlessNumbers.native.js +0 -5
  137. package/dist/esm/runtime/unitlessNumbers.native.js.map +1 -1
  138. package/dist/esm/runtime.mjs +4 -2
  139. package/dist/esm/runtime.native.js +4 -2
  140. package/dist/esm/shorthands/transition.mjs +111 -36
  141. package/dist/esm/shorthands/transition.mjs.map +1 -1
  142. package/dist/esm/shorthands/transition.native.js +113 -36
  143. package/dist/esm/shorthands/transition.native.js.map +1 -1
  144. package/dist/esm/shorthands/transitionAlign.mjs +13 -10
  145. package/dist/esm/shorthands/transitionAlign.mjs.map +1 -1
  146. package/dist/esm/shorthands/transitionAlign.native.js +14 -11
  147. package/dist/esm/shorthands/transitionAlign.native.js.map +1 -1
  148. package/dist/esm/shorthands/transitionLegacy.mjs +260 -126
  149. package/dist/esm/shorthands/transitionLegacy.mjs.map +1 -1
  150. package/dist/esm/shorthands/transitionLegacy.native.js +330 -155
  151. package/dist/esm/shorthands/transitionLegacy.native.js.map +1 -1
  152. package/dist/esm/shorthands/transitionNative.mjs +5 -5
  153. package/dist/esm/shorthands/transitionNative.mjs.map +1 -1
  154. package/dist/esm/shorthands/transitionNative.native.js +8 -7
  155. package/dist/esm/shorthands/transitionNative.native.js.map +1 -1
  156. package/dist/esm/shorthands/transitionObject.mjs +280 -0
  157. package/dist/esm/shorthands/transitionObject.mjs.map +1 -0
  158. package/dist/esm/shorthands/transitionObject.native.js +323 -0
  159. package/dist/esm/shorthands/transitionObject.native.js.map +1 -0
  160. package/dist/esm/tooling/candidate.mjs +250 -16
  161. package/dist/esm/tooling/candidate.mjs.map +1 -1
  162. package/dist/esm/tooling/candidate.native.js +310 -63
  163. package/dist/esm/tooling/candidate.native.js.map +1 -1
  164. package/dist/esm/tooling/config.mjs +18 -9
  165. package/dist/esm/tooling/config.mjs.map +1 -1
  166. package/dist/esm/tooling/config.native.js +24 -26
  167. package/dist/esm/tooling/config.native.js.map +1 -1
  168. package/dist/esm/tooling/registry.mjs +579 -11
  169. package/dist/esm/tooling/registry.mjs.map +1 -1
  170. package/dist/esm/tooling/registry.native.js +579 -11
  171. package/dist/esm/tooling/registry.native.js.map +1 -1
  172. package/dist/esm/tooling/toolingDiagnostics.mjs +306 -11
  173. package/dist/esm/tooling/toolingDiagnostics.mjs.map +1 -1
  174. package/dist/esm/tooling/toolingDiagnostics.native.js +408 -49
  175. package/dist/esm/tooling/toolingDiagnostics.native.js.map +1 -1
  176. package/dist/esm/tooling/toolingRegistry.mjs +6 -1
  177. package/dist/esm/tooling/toolingRegistry.mjs.map +1 -1
  178. package/dist/esm/tooling/toolingRegistry.native.js +9 -1
  179. package/dist/esm/tooling/toolingRegistry.native.js.map +1 -1
  180. package/dist/esm/tooling.mjs +2 -0
  181. package/dist/esm/tooling.native.js +2 -0
  182. package/dist/esm/transitions.mjs +5 -0
  183. package/dist/esm/transitions.native.js +5 -0
  184. package/package.json +21 -3
  185. package/src/ast/payloadShape.ts +44 -16
  186. package/src/ast/resolvePayload.ts +28 -13
  187. package/src/programs/lowerProgram.ts +9 -4
  188. package/src/runtime/clauseIdentity.ts +8 -31
  189. package/src/runtime/clausePrecedence.ts +2 -10
  190. package/src/runtime/scanFlatValue.ts +81 -9
  191. package/src/runtime/spring.ts +208 -0
  192. package/src/runtime/stateModifiers.ts +31 -1
  193. package/src/runtime/tokenCategories.ts +3 -0
  194. package/src/runtime/unitlessNumbers.ts +0 -5
  195. package/src/runtime.ts +13 -0
  196. package/src/shorthands/transition.ts +159 -44
  197. package/src/shorthands/transitionAlign.ts +22 -12
  198. package/src/shorthands/transitionLegacy.ts +376 -156
  199. package/src/shorthands/transitionNative.ts +8 -11
  200. package/src/shorthands/transitionObject.ts +369 -0
  201. package/src/tooling/candidate.ts +269 -14
  202. package/src/tooling/config.ts +25 -9
  203. package/src/tooling/registry.ts +339 -12
  204. package/src/tooling/toolingDiagnostics.ts +474 -9
  205. package/src/tooling/toolingRegistry.ts +6 -1
  206. package/src/tooling.ts +1 -0
  207. package/src/transitions.ts +42 -0
  208. package/types/ast/payloadShape.d.ts.map +2 -2
  209. package/types/ast/resolvePayload.d.ts +5 -4
  210. package/types/ast/resolvePayload.d.ts.map +2 -2
  211. package/types/programs/lowerProgram.d.ts +4 -2
  212. package/types/programs/lowerProgram.d.ts.map +2 -2
  213. package/types/runtime/clauseIdentity.d.ts +1 -4
  214. package/types/runtime/clauseIdentity.d.ts.map +2 -2
  215. package/types/runtime/clausePrecedence.d.ts.map +2 -2
  216. package/types/runtime/scanFlatValue.d.ts +1 -1
  217. package/types/runtime/scanFlatValue.d.ts.map +2 -2
  218. package/types/runtime/spring.d.ts +61 -0
  219. package/types/runtime/spring.d.ts.map +11 -0
  220. package/types/runtime/stateModifiers.d.ts +4 -0
  221. package/types/runtime/stateModifiers.d.ts.map +2 -2
  222. package/types/runtime/tokenCategories.d.ts.map +2 -2
  223. package/types/runtime/unitlessNumbers.d.ts.map +2 -2
  224. package/types/runtime.d.ts +3 -1
  225. package/types/runtime.d.ts.map +2 -2
  226. package/types/shorthands/transition.d.ts +26 -5
  227. package/types/shorthands/transition.d.ts.map +2 -2
  228. package/types/shorthands/transitionAlign.d.ts.map +2 -2
  229. package/types/shorthands/transitionLegacy.d.ts +19 -4
  230. package/types/shorthands/transitionLegacy.d.ts.map +2 -2
  231. package/types/shorthands/transitionNative.d.ts.map +1 -1
  232. package/types/shorthands/transitionObject.d.ts +49 -0
  233. package/types/shorthands/transitionObject.d.ts.map +11 -0
  234. package/types/tooling/candidate.d.ts +13 -0
  235. package/types/tooling/candidate.d.ts.map +2 -2
  236. package/types/tooling/config.d.ts +8 -1
  237. package/types/tooling/config.d.ts.map +2 -2
  238. package/types/tooling/registry.d.ts +4 -2
  239. package/types/tooling/registry.d.ts.map +2 -2
  240. package/types/tooling/toolingDiagnostics.d.ts +3 -1
  241. package/types/tooling/toolingDiagnostics.d.ts.map +2 -2
  242. package/types/tooling/toolingRegistry.d.ts.map +2 -2
  243. package/types/tooling.d.ts +1 -0
  244. package/types/tooling.d.ts.map +2 -2
  245. package/types/transitions.d.ts +5 -0
  246. package/types/transitions.d.ts.map +11 -0
@@ -1,9 +1,11 @@
1
1
  import { namedCssColors } from '../runtime/namedCssColors'
2
+ import { propTokenGroupFallbacks } from './config'
2
3
  import {
3
4
  grammarEntries,
4
5
  fontWeightNames,
5
6
  insetAxisProps,
6
7
  prefixToEntries,
8
+ propToGrammarEntry,
7
9
  radiusCornerProps,
8
10
  sizeUtilityProps,
9
11
  standaloneValueProps,
@@ -62,9 +64,42 @@ export type CandidateClassification =
62
64
  | { kind: 'tamagui'; parsed: ParsedCandidate }
63
65
  | { kind: 'passthrough'; reason: string }
64
66
 
65
- const sizingConveniences = new Set(['full', 'auto', 'screen', 'min', 'max', 'fit'])
67
+ const sizingConveniences = new Set([
68
+ 'full',
69
+ 'auto',
70
+ 'screen',
71
+ 'dvh',
72
+ 'lvh',
73
+ 'svh',
74
+ 'dvw',
75
+ 'lvw',
76
+ 'svw',
77
+ 'min',
78
+ 'max',
79
+ 'fit',
80
+ ])
66
81
  const fontGenerics = new Set(['sans', 'serif', 'mono'])
67
82
  const numericPattern = /^\d+(?:\.\d+)?$/
83
+
84
+ // tailwind v4's named leading scale, as unitless line-height ratios
85
+ export const tailwindLeadingRatios: Record<string, number> = {
86
+ none: 1,
87
+ tight: 1.25,
88
+ snug: 1.375,
89
+ normal: 1.5,
90
+ relaxed: 1.625,
91
+ loose: 2,
92
+ }
93
+
94
+ // tailwind v4's named tracking scale, in em of the element's font size
95
+ export const tailwindTrackingEms: Record<string, number> = {
96
+ tighter: -0.05,
97
+ tight: -0.025,
98
+ normal: 0,
99
+ wide: 0.025,
100
+ wider: 0.05,
101
+ widest: 0.1,
102
+ }
68
103
  const extraPrefixes = [
69
104
  'border-x',
70
105
  'border-y',
@@ -72,9 +107,12 @@ const extraPrefixes = [
72
107
  'rounded-r',
73
108
  'rounded-b',
74
109
  'rounded-l',
110
+ 'rounded-s',
111
+ 'rounded-e',
75
112
  'inset-x',
76
113
  'inset-y',
77
114
  'size',
115
+ 'translate',
78
116
  ]
79
117
  const negativeTokenProps = new Set([
80
118
  'margin',
@@ -82,6 +120,10 @@ const negativeTokenProps = new Set([
82
120
  'marginRight',
83
121
  'marginBottom',
84
122
  'marginLeft',
123
+ 'marginInlineStart',
124
+ 'marginInlineEnd',
125
+ 'marginBlockStart',
126
+ 'marginBlockEnd',
85
127
  'marginHorizontal',
86
128
  'marginVertical',
87
129
  'top',
@@ -89,9 +131,53 @@ const negativeTokenProps = new Set([
89
131
  'bottom',
90
132
  'left',
91
133
  'inset',
134
+ 'insetInlineStart',
135
+ 'insetInlineEnd',
136
+ 'insetBlockStart',
137
+ 'insetBlockEnd',
138
+ 'start',
139
+ 'end',
140
+ 'zIndex',
92
141
  'x',
93
142
  'y',
143
+ 'rotate',
144
+ 'rotateX',
145
+ 'rotateY',
146
+ 'rotateZ',
147
+ 'skewX',
148
+ 'skewY',
149
+ 'order',
150
+ 'scale',
151
+ 'scaleX',
152
+ 'scaleY',
94
153
  'letterSpacing',
154
+ 'outlineOffset',
155
+ ])
156
+ const positionSpaceProps = new Set([
157
+ 'top',
158
+ 'right',
159
+ 'bottom',
160
+ 'left',
161
+ 'inset',
162
+ 'insetInlineStart',
163
+ 'insetInlineEnd',
164
+ 'insetBlockStart',
165
+ 'insetBlockEnd',
166
+ 'start',
167
+ 'end',
168
+ ])
169
+ const marginSpaceProps = new Set([
170
+ 'margin',
171
+ 'marginTop',
172
+ 'marginRight',
173
+ 'marginBottom',
174
+ 'marginLeft',
175
+ 'marginInlineStart',
176
+ 'marginInlineEnd',
177
+ 'marginBlockStart',
178
+ 'marginBlockEnd',
179
+ 'marginHorizontal',
180
+ 'marginVertical',
95
181
  ])
96
182
  const borderWidthKeywords = new Set(['thin', 'medium', 'thick'])
97
183
  const ambiguousCssKeywords = new Set([
@@ -123,7 +209,14 @@ function hasName(names: Names | undefined, name: string): boolean {
123
209
  return name in names
124
210
  }
125
211
 
126
- function splitCandidate(candidate: string): { modifiers: string[]; base: string } | null {
212
+ /**
213
+ * Split a candidate on its unbracketed colons: everything before the last one is a
214
+ * raw modifier, the remainder is the base. `null` for unbalanced brackets or an
215
+ * empty base, which are not candidates at all.
216
+ */
217
+ export function splitCandidate(
218
+ candidate: string
219
+ ): { modifiers: string[]; base: string } | null {
127
220
  const parts: string[] = []
128
221
  let current = ''
129
222
  let bracketDepth = 0
@@ -198,8 +291,19 @@ function normalizeModifiers(
198
291
  return normalized
199
292
  }
200
293
 
294
+ function tokenDomain(
295
+ config: GrammarConfigView,
296
+ category: TokenCategory
297
+ ): Names | undefined {
298
+ const fallback = propTokenGroupFallbacks[category]
299
+ return (
300
+ config.tokenNames?.[category] ||
301
+ (fallback ? config.tokenNames?.[fallback] : undefined)
302
+ )
303
+ }
304
+
201
305
  function hasTokenDomain(config: GrammarConfigView, category: TokenCategory): boolean {
202
- return config.tokenNames?.[category] !== undefined
306
+ return tokenDomain(config, category) !== undefined
203
307
  }
204
308
 
205
309
  export function hasTokenName(
@@ -207,7 +311,24 @@ export function hasTokenName(
207
311
  category: TokenCategory,
208
312
  name: string
209
313
  ): boolean {
210
- return hasName(config.tokenNames?.[category], name)
314
+ return resolveTokenName(config, category, name) !== null
315
+ }
316
+
317
+ // Tailwind spells half-steps as `0.5`; some Tamagui configs use `0-5`.
318
+ export function decimalHalfTokenAlias(name: string): string | null {
319
+ const match = /^(-?\d+)\.5$/.exec(name)
320
+ return match ? `${match[1]}-5` : null
321
+ }
322
+
323
+ export function resolveTokenName(
324
+ config: GrammarConfigView,
325
+ category: TokenCategory,
326
+ name: string
327
+ ): string | null {
328
+ const names = tokenDomain(config, category)
329
+ if (hasName(names, name)) return name
330
+ const alias = decimalHalfTokenAlias(name)
331
+ return alias !== null && hasName(names, alias) ? alias : null
211
332
  }
212
333
 
213
334
  function entriesForProps(props: readonly string[]): GrammarEntry[] {
@@ -236,11 +357,17 @@ function resolveEntries(
236
357
  )
237
358
  }
238
359
  if (prefix === 'size') {
239
- return entriesForProps(sizeUtilityProps)
360
+ return entriesForProps(sizeUtilityProps).map((entry) => ({
361
+ ...entry,
362
+ tokenCategory: 'size',
363
+ }))
240
364
  }
241
365
  if (prefix === 'inset-x' || prefix === 'inset-y') {
242
366
  return entriesForProps(insetAxisProps[prefix.slice('inset-'.length)])
243
367
  }
368
+ if (prefix === 'translate') {
369
+ return entriesForProps(['x', 'y'])
370
+ }
244
371
  if (prefix.startsWith('rounded-')) {
245
372
  const props = radiusCornerProps[prefix.slice('rounded-'.length)]
246
373
  return props ? entriesForProps(props) : []
@@ -329,6 +456,10 @@ function arbitraryTextKind(value: string): 'fontSize' | 'color' | null {
329
456
  return null
330
457
  }
331
458
 
459
+ function isWidthColorPrefix(prefix: string): boolean {
460
+ return prefix.startsWith('border') || prefix === 'outline'
461
+ }
462
+
332
463
  function arbitraryBorderKind(value: string): 'width' | 'color' | null {
333
464
  if (/^-?(?:\d+|\d*\.\d+)$/.test(value)) return 'width'
334
465
  if (cssLengthPattern.test(value) || borderWidthKeywords.has(value)) return 'width'
@@ -379,7 +510,7 @@ function chooseEntry(
379
510
  const arbitrary = arbitraryInner(rawValue)
380
511
  if (arbitrary !== null) {
381
512
  if (!arbitrary) return null
382
- if (prefix.startsWith('border')) {
513
+ if (isWidthColorPrefix(prefix)) {
383
514
  const width = entries.find((entry) => entry.prop.endsWith('Width'))
384
515
  const color = entries.find((entry) => entry.prop.endsWith('Color'))
385
516
  const kind = arbitraryBorderKind(decodeArbitrary(arbitrary))
@@ -422,6 +553,9 @@ function chooseEntry(
422
553
  }
423
554
  }
424
555
  const color = entries.find((entry) => entry.prop === 'color')
556
+ if (color && rawValue === 'transparent') {
557
+ return { entry: color, valueKind: 'enum' }
558
+ }
425
559
  const colorName = tokenLookupName('color', rawValue)
426
560
  if (color && hasTokenName(config, 'color', colorName)) {
427
561
  return { entry: color, valueKind: 'token' }
@@ -449,11 +583,12 @@ function chooseEntry(
449
583
  : null
450
584
  }
451
585
 
452
- if (prefix.startsWith('border')) {
586
+ if (isWidthColorPrefix(prefix)) {
453
587
  const width = entries.find((entry) => entry.prop.endsWith('Width'))
454
588
  const color = entries.find((entry) => entry.prop.endsWith('Color'))
455
589
  const token = negative ? `-${rawValue}` : rawValue
456
- const matchesWidth = width && hasTokenName(config, 'space', token)
590
+ const widthCategory = width?.tokenCategory || 'space'
591
+ const matchesWidth = width && hasTokenName(config, widthCategory, token)
457
592
  const colorName = tokenLookupName('color', rawValue)
458
593
  const matchesColor = color && hasTokenName(config, 'color', colorName)
459
594
  if (matchesWidth && matchesColor) return null
@@ -463,28 +598,134 @@ function chooseEntry(
463
598
  if (matchesColor) {
464
599
  return { entry: color, valueKind: 'token' }
465
600
  }
601
+ if (color && rawValue === 'transparent') {
602
+ return { entry: color, valueKind: 'enum' }
603
+ }
466
604
  return null
467
605
  }
468
606
 
607
+ if (prefix === 'flex' && fractionIsValid(rawValue)) {
608
+ const flex = entries.find((entry) => entry.prop === 'flex')
609
+ if (flex) {
610
+ return { entry: flex, valueKind: 'convenience', convenience: 'flex-bundle' }
611
+ }
612
+ }
613
+
614
+ if (prefix === 'tracking' && Object.hasOwn(tailwindTrackingEms, rawValue)) {
615
+ const letterSpacing = entries.find((entry) => entry.prop === 'letterSpacing')
616
+ if (letterSpacing) {
617
+ return {
618
+ entry: letterSpacing,
619
+ valueKind: 'convenience',
620
+ convenience: 'tracking-keyword',
621
+ }
622
+ }
623
+ }
624
+
625
+ if (prefix === 'leading' && Object.hasOwn(tailwindLeadingRatios, rawValue)) {
626
+ const lineHeight = entries.find((entry) => entry.prop === 'lineHeight')
627
+ if (lineHeight) {
628
+ return {
629
+ entry: lineHeight,
630
+ valueKind: 'convenience',
631
+ convenience: 'leading-keyword',
632
+ }
633
+ }
634
+ }
635
+
636
+ if (numericPattern.test(rawValue)) {
637
+ const angle = entries.find((entry) => entry.conveniences?.includes('angle'))
638
+ if (angle) {
639
+ return { entry: angle, valueKind: 'convenience', convenience: 'angle' }
640
+ }
641
+ if (prefix === 'flex') {
642
+ const flex = entries.find((entry) => entry.prop === 'flex')
643
+ if (flex)
644
+ return { entry: flex, valueKind: 'convenience', convenience: 'flex-bundle' }
645
+ }
646
+ if (prefix === 'grow') {
647
+ const grow = entries.find((entry) => entry.prop === 'flexGrow')
648
+ if (grow) return { entry: grow, valueKind: 'convenience', convenience: 'integer' }
649
+ }
650
+ if (prefix === 'shrink') {
651
+ const shrink = entries.find((entry) => entry.prop === 'flexShrink')
652
+ if (shrink)
653
+ return { entry: shrink, valueKind: 'convenience', convenience: 'integer' }
654
+ }
655
+ if (prefix === 'line-clamp') {
656
+ const clamp = entries.find((entry) => entry.prop === 'numberOfLines')
657
+ if (clamp) return { entry: clamp, valueKind: 'convenience', convenience: 'integer' }
658
+ }
659
+ if (prefix === 'leading') {
660
+ const lineHeight = entries.find((entry) => entry.prop === 'lineHeight')
661
+ if (
662
+ lineHeight &&
663
+ (!lineHeight.tokenCategory ||
664
+ !hasTokenName(config, lineHeight.tokenCategory, rawValue))
665
+ ) {
666
+ return {
667
+ entry: lineHeight,
668
+ valueKind: 'convenience',
669
+ convenience: 'integer',
670
+ }
671
+ }
672
+ }
673
+ // grid utilities: grid-cols-3, col-span-2, col-start-1, row-span-3, etc.
674
+ if (
675
+ prefix === 'grid-cols' ||
676
+ prefix === 'col-span' ||
677
+ prefix === 'col-start' ||
678
+ prefix === 'col-end' ||
679
+ prefix === 'row-span' ||
680
+ prefix === 'row-start' ||
681
+ prefix === 'row-end'
682
+ ) {
683
+ const entry = entries[0]
684
+ if (entry) return { entry, valueKind: 'convenience', convenience: 'integer' }
685
+ }
686
+ }
687
+
469
688
  for (const entry of entries) {
470
689
  if (entry.tokenCategory) {
471
- const name = negative ? `-${rawValue}` : rawValue
690
+ if (entry.tokenCategory === 'color' && rawValue === 'transparent') {
691
+ return { entry, valueKind: 'enum' }
692
+ }
693
+ if (entry.tokenCategory === 'radius' && rawValue === 'none') {
694
+ return { entry, valueKind: 'convenience', convenience: 'zero' }
695
+ }
696
+ // Negative zero has the same runtime value as zero. Tailwind emits these
697
+ // candidates, while token maps intentionally do not duplicate a `-0` key.
698
+ const name = negative && rawValue !== '0' ? `-${rawValue}` : rawValue
472
699
  const tokenName = tokenLookupName(entry.tokenCategory, name)
473
700
  if (hasTokenName(config, entry.tokenCategory, tokenName)) {
474
701
  return { entry, valueKind: 'token' }
475
702
  }
476
703
  if (
477
- entry.tokenCategory === 'size' &&
704
+ entry.conveniences?.includes('sizing-keyword') &&
478
705
  (sizingConveniences.has(rawValue) || fractionIsValid(rawValue))
479
706
  ) {
480
707
  return { entry, valueKind: 'convenience', convenience: 'sizing-keyword' }
481
708
  }
709
+ if (
710
+ positionSpaceProps.has(entry.prop) &&
711
+ (rawValue === 'full' || rawValue === 'auto' || fractionIsValid(rawValue))
712
+ ) {
713
+ return { entry, valueKind: 'convenience', convenience: 'sizing-keyword' }
714
+ }
715
+ if (marginSpaceProps.has(entry.prop) && rawValue === 'auto') {
716
+ return { entry, valueKind: 'convenience', convenience: 'sizing-keyword' }
717
+ }
482
718
  if (entry.tokenCategory === 'zIndex' && numericPattern.test(rawValue)) {
483
719
  return { entry, valueKind: 'convenience', convenience: 'integer' }
484
720
  }
485
721
  continue
486
722
  }
487
- if (prefix === 'opacity' || prefix === 'scale') {
723
+ if (
724
+ prefix === 'opacity' ||
725
+ prefix === 'scale' ||
726
+ prefix === 'scale-x' ||
727
+ prefix === 'scale-y'
728
+ ) {
488
729
  if (numericPattern.test(rawValue)) {
489
730
  return { entry, valueKind: 'convenience', convenience: 'percentage' }
490
731
  }
@@ -493,6 +734,9 @@ function chooseEntry(
493
734
  if (entry.prop === 'zIndex' && numericPattern.test(rawValue)) {
494
735
  return { entry, valueKind: 'convenience', convenience: 'integer' }
495
736
  }
737
+ if (entry.conveniences?.includes('integer') && numericPattern.test(rawValue)) {
738
+ return { entry, valueKind: 'convenience', convenience: 'integer' }
739
+ }
496
740
  }
497
741
  return null
498
742
  }
@@ -524,7 +768,14 @@ export function parseCandidate(
524
768
  if (
525
769
  selected &&
526
770
  (!negative ||
527
- (selected.valueKind === 'token' && negativeTokenProps.has(selected.entry.prop)))
771
+ selected.convenience === 'tracking-keyword' ||
772
+ (negativeTokenProps.has(selected.entry.prop) &&
773
+ (selected.valueKind === 'token' ||
774
+ (selected.valueKind === 'arbitrary' && selected.entry.prop === 'order') ||
775
+ selected.convenience === 'angle' ||
776
+ selected.convenience === 'percentage' ||
777
+ selected.convenience === 'sizing-keyword' ||
778
+ selected.convenience === 'integer')))
528
779
  ) {
529
780
  dynamic = { prefix, rawValue, selected }
530
781
  // An exact configured token owns its spelling before a reserved whole utility. Other
@@ -549,7 +800,11 @@ export function parseCandidate(
549
800
  }
550
801
 
551
802
  const direct = wholeClassUtilities[split.base]
552
- if (!negative && direct) {
803
+ if (
804
+ !negative &&
805
+ direct &&
806
+ (split.base !== 'shadow' || hasTokenName(config, 'boxShadow', 'sm'))
807
+ ) {
553
808
  const convenience = wholeClassConveniences[split.base]
554
809
  return {
555
810
  candidate,
@@ -621,7 +876,7 @@ export function formatCandidate(
621
876
  { prop, value, valueKind, modifiers = [] }: FormatCandidateInput,
622
877
  config?: GrammarConfigView
623
878
  ): string | null {
624
- const entry = grammarEntries.find((candidate) => candidate.prop === prop)
879
+ const entry = propToGrammarEntry[prop]
625
880
  if (!entry) return null
626
881
  if (valueKind === 'arbitrary' && value === '') return null
627
882
  const normalizedModifiers = normalizeModifiers(modifiers, config || {})
@@ -14,12 +14,7 @@ export type GrammarSourceConfig = {
14
14
  shorthands?: Readonly<Record<string, string>>
15
15
  media?: Names
16
16
  themes?: Readonly<Record<string, unknown>>
17
- tokensParsed?: Partial<
18
- Record<
19
- 'space' | 'size' | 'radius' | 'zIndex' | 'color',
20
- Readonly<Record<string, unknown>>
21
- >
22
- >
17
+ tokensParsed?: Partial<Record<string, Readonly<Record<string, unknown>>>>
23
18
  fontsParsed?: Readonly<Record<string, GrammarFontConfig | undefined>>
24
19
  }
25
20
 
@@ -98,6 +93,24 @@ function addNames(target: Set<string>, source: Names | undefined): void {
98
93
  for (const key in source) target.add(key)
99
94
  }
100
95
 
96
+ /**
97
+ * Token groups named after one property. A config that defines the group binds
98
+ * the property to it; one that does not resolves the property through the
99
+ * fallback category, so legacy configs keep their classes.
100
+ */
101
+ export const propTokenGroupFallbacks: Readonly<Record<string, TokenCategory>> = {
102
+ borderWidth: 'space',
103
+ outlineWidth: 'space',
104
+ outlineOffset: 'space',
105
+ width: 'size',
106
+ minWidth: 'size',
107
+ maxWidth: 'size',
108
+ inlineSize: 'size',
109
+ minInlineSize: 'size',
110
+ maxInlineSize: 'size',
111
+ flexBasis: 'size',
112
+ }
113
+
101
114
  /**
102
115
  * Creates the dependency-free config projection consumed by the shared style grammar.
103
116
  * Runtime and compiler integrations must classify candidates through this same view so
@@ -107,7 +120,7 @@ export function createGrammarConfigView(
107
120
  config: GrammarSourceConfig,
108
121
  options: CreateGrammarConfigViewOptions = {}
109
122
  ): GrammarConfigView {
110
- const tokenNames: Record<TokenCategory, Set<string>> = {
123
+ const tokenNames: Record<string, Set<string>> = {
111
124
  space: new Set(),
112
125
  size: new Set(),
113
126
  radius: new Set(),
@@ -120,8 +133,11 @@ export function createGrammarConfigView(
120
133
  letterSpacing: new Set(),
121
134
  }
122
135
 
123
- for (const category of ['space', 'size', 'radius', 'zIndex', 'color'] as const) {
124
- addNames(tokenNames[category], config.tokensParsed?.[category])
136
+ for (const category in config.tokensParsed) {
137
+ addNames((tokenNames[category] ||= new Set()), config.tokensParsed[category])
138
+ }
139
+ for (const group in propTokenGroupFallbacks) {
140
+ tokenNames[group] ||= tokenNames[propTokenGroupFallbacks[group]]
125
141
  }
126
142
 
127
143
  for (const themeName in config.themes) {