@@ -238,22 +238,32 @@ export function parseClass(className: string): ParsedClass {
238
238
}
239
239
240
240
// Regular negative value
241
- const match = positiveUtility . match ( / ^ ( [ a - z ] + (?: - [ a - z ] + ) * ) (?: - ( .+ ) ) ? $ / )
241
+ const match = positiveUtility . match ( / ^ ( [ a - z ] + (?: - [ a - z ] + ) * ? ) - ( .+ ) $ / )
242
242
if ( match ) {
243
243
return {
244
244
raw : className ,
245
245
variants,
246
246
utility : match [ 1 ] ,
247
- value : match [ 2 ] ? `-${ match [ 2 ] } ` : undefined ,
247
+ value : `-${ match [ 2 ] } ` ,
248
248
important,
249
249
arbitrary : false ,
250
250
}
251
251
}
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
+ }
252
262
}
253
263
254
264
// Check for color opacity modifiers: bg-blue-500/50, text-red-500/75
255
265
// 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 + ) $ / )
257
267
if ( opacityMatch && [ 'bg' , 'text' , 'border' , 'ring' , 'placeholder' , 'divide' ] . includes ( opacityMatch [ 1 ] ) ) {
258
268
return {
259
269
raw : className ,
@@ -266,7 +276,7 @@ export function parseClass(className: string): ParsedClass {
266
276
}
267
277
268
278
// 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 + ) $ / )
270
280
if ( fractionMatch ) {
271
281
return {
272
282
raw : className ,
@@ -279,22 +289,25 @@ export function parseClass(className: string): ParsedClass {
279
289
}
280
290
281
291
// 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 ) {
284
295
return {
285
296
raw : className ,
286
297
variants,
287
- utility,
298
+ utility : matchWithValue [ 1 ] ,
299
+ value : matchWithValue [ 2 ] ,
288
300
important,
289
301
arbitrary : false ,
290
302
}
291
303
}
292
304
305
+ // If no dash, treat entire string as utility with no value (e.g., flex, block)
293
306
return {
294
307
raw : className ,
295
308
variants,
296
- utility : match [ 1 ] ,
297
- value : match [ 2 ] ,
309
+ utility,
310
+ value : undefined ,
298
311
important,
299
312
arbitrary : false ,
300
313
}
0 commit comments