@@ -238,22 +238,32 @@ export function parseClass(className: string): ParsedClass {
238238 }
239239
240240 // Regular negative value
241- const match = positiveUtility . match ( / ^ ( [ a - z ] + (?: - [ a - z ] + ) * ) (?: - ( .+ ) ) ? $ / )
241+ const match = positiveUtility . match ( / ^ ( [ a - z ] + (?: - [ a - z ] + ) * ? ) - ( .+ ) $ / )
242242 if ( match ) {
243243 return {
244244 raw : className ,
245245 variants,
246246 utility : match [ 1 ] ,
247- value : match [ 2 ] ? `-${ match [ 2 ] } ` : undefined ,
247+ value : `-${ match [ 2 ] } ` ,
248248 important,
249249 arbitrary : false ,
250250 }
251251 }
252+ // If no match, it's a standalone utility with just a negative sign (e.g., -flex doesn't make sense)
253+ // Return as-is
254+ return {
255+ raw : className ,
256+ variants,
257+ utility : positiveUtility ,
258+ value : undefined ,
259+ important,
260+ arbitrary : false ,
261+ }
252262 }
253263
254264 // Check for color opacity modifiers: bg-blue-500/50, text-red-500/75
255265 // Must come before fractional values to avoid conflict
256- const opacityMatch = utility . match ( / ^ ( [ a - z ] + (?: - [ a - z ] + ) * ) - ( .+ ?) \/ ( \d + ) $ / )
266+ const opacityMatch = utility . match ( / ^ ( [ a - z ] + (?: - [ a - z ] + ) * ? ) - ( .+ ?) \/ ( \d + ) $ / )
257267 if ( opacityMatch && [ 'bg' , 'text' , 'border' , 'ring' , 'placeholder' , 'divide' ] . includes ( opacityMatch [ 1 ] ) ) {
258268 return {
259269 raw : className ,
@@ -266,7 +276,7 @@ export function parseClass(className: string): ParsedClass {
266276 }
267277
268278 // Check for fractional values: w-1/2, h-3/4
269- const fractionMatch = utility . match ( / ^ ( [ a - z - ] + ) - ( \d + ) \/ ( \d + ) $ / )
279+ const fractionMatch = utility . match ( / ^ ( [ a - z ] + (?: - [ a - z ] + ) * ? ) - ( \d + ) \/ ( \d + ) $ / )
270280 if ( fractionMatch ) {
271281 return {
272282 raw : className ,
@@ -279,22 +289,25 @@ export function parseClass(className: string): ParsedClass {
279289 }
280290
281291 // Regular parsing - split on last dash
282- const match = utility . match ( / ^ ( [ a - z ] + (?: - [ a - z ] + ) * ) (?: - ( .+ ) ) ? $ / )
283- if ( ! match ) {
292+ // First try: utility-value pattern (e.g., text-current, p-4)
293+ const matchWithValue = utility . match ( / ^ ( [ a - z ] + (?: - [ a - z ] + ) * ?) - ( .+ ) $ / )
294+ if ( matchWithValue ) {
284295 return {
285296 raw : className ,
286297 variants,
287- utility,
298+ utility : matchWithValue [ 1 ] ,
299+ value : matchWithValue [ 2 ] ,
288300 important,
289301 arbitrary : false ,
290302 }
291303 }
292304
305+ // If no dash, treat entire string as utility with no value (e.g., flex, block)
293306 return {
294307 raw : className ,
295308 variants,
296- utility : match [ 1 ] ,
297- value : match [ 2 ] ,
309+ utility,
310+ value : undefined ,
298311 important,
299312 arbitrary : false ,
300313 }
0 commit comments