1
1
import plugin from 'tailwindcss/plugin'
2
2
import { normalize } from 'tailwindcss/lib/util/dataTypes'
3
3
4
- export default plugin ( function containerQueries ( { matchVariant, theme } ) {
5
- let values = theme ( 'containers' )
4
+ export = plugin ( function containerQueries ( { matchVariant, theme } ) {
5
+ let values = theme ( 'containers' ) ?? { }
6
6
7
- function parseValue ( value : string ) {
7
+ function parseValue ( value : string ) : {
8
+ raw : string
9
+ sortable : boolean
10
+ minX : number
11
+ maxX : number
12
+ minY : number
13
+ maxY : number
14
+ } | null {
8
15
// _ -> space
9
16
value = normalize ( value )
10
17
@@ -40,7 +47,7 @@ export default plugin(function containerQueries({ matchVariant, theme }) {
40
47
41
48
return {
42
49
raw : value ,
43
- parsable : minX !== null || maxX !== null || minY !== null || maxY !== null ,
50
+ sortable : minX !== null || maxX !== null || minY !== null || maxY !== null ,
44
51
minX : minXf ,
45
52
maxX : maxXf ,
46
53
minY : minYf ,
@@ -61,15 +68,17 @@ export default plugin(function containerQueries({ matchVariant, theme }) {
61
68
let a = parseValue ( aVariant . value )
62
69
let b = parseValue ( bVariant . value )
63
70
71
+ if ( a === null || b === null ) return 0
72
+
64
73
let aLabel = aVariant . modifier ?? ''
65
74
let bLabel = bVariant . modifier ?? ''
66
75
67
76
// Put "raw" values at the end
68
- if ( a . parsable === false && b . parsable === false ) {
77
+ if ( a . sortable === false && b . sortable === false ) {
69
78
return 0
70
- } else if ( a . parsable === false ) {
79
+ } else if ( a . sortable === false ) {
71
80
return 1
72
- } else if ( b . parsable === false ) {
81
+ } else if ( b . sortable === false ) {
73
82
return - 1
74
83
}
75
84
0 commit comments