@cwcss/crosswind 0.1.5 → 0.1.6

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 (86) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +390 -0
  3. package/dist/build.d.ts +24 -0
  4. package/dist/config.d.ts +5 -0
  5. package/dist/generator.d.ts +31 -0
  6. package/dist/index.d.ts +10 -0
  7. package/dist/index.js +12798 -0
  8. package/dist/parser.d.ts +42 -0
  9. package/dist/plugin.d.ts +22 -0
  10. package/dist/preflight-forms.d.ts +5 -0
  11. package/dist/preflight.d.ts +2 -0
  12. package/dist/rules-advanced.d.ts +27 -0
  13. package/dist/rules-effects.d.ts +25 -0
  14. package/dist/rules-forms.d.ts +7 -0
  15. package/dist/rules-grid.d.ts +13 -0
  16. package/dist/rules-interactivity.d.ts +41 -0
  17. package/dist/rules-layout.d.ts +26 -0
  18. package/dist/rules-transforms.d.ts +33 -0
  19. package/dist/rules-typography.d.ts +41 -0
  20. package/dist/rules.d.ts +39 -0
  21. package/dist/scanner.d.ts +18 -0
  22. package/dist/transformer-compile-class.d.ts +37 -0
  23. package/{src/types.ts → dist/types.d.ts} +17 -86
  24. package/package.json +1 -1
  25. package/PLUGIN.md +0 -235
  26. package/benchmark/framework-comparison.bench.ts +0 -850
  27. package/bin/cli.ts +0 -365
  28. package/bin/crosswind +0 -0
  29. package/bin/headwind +0 -0
  30. package/build.ts +0 -8
  31. package/crosswind.config.ts +0 -9
  32. package/example/comprehensive.html +0 -70
  33. package/example/index.html +0 -21
  34. package/example/output.css +0 -236
  35. package/examples/plugin/README.md +0 -112
  36. package/examples/plugin/build.ts +0 -32
  37. package/examples/plugin/src/index.html +0 -34
  38. package/examples/plugin/src/index.ts +0 -7
  39. package/headwind +0 -2
  40. package/src/build.ts +0 -101
  41. package/src/config.ts +0 -529
  42. package/src/generator.ts +0 -2173
  43. package/src/index.ts +0 -10
  44. package/src/parser.ts +0 -1471
  45. package/src/plugin.ts +0 -118
  46. package/src/preflight-forms.ts +0 -229
  47. package/src/preflight.ts +0 -388
  48. package/src/rules-advanced.ts +0 -477
  49. package/src/rules-effects.ts +0 -461
  50. package/src/rules-forms.ts +0 -103
  51. package/src/rules-grid.ts +0 -241
  52. package/src/rules-interactivity.ts +0 -525
  53. package/src/rules-layout.ts +0 -385
  54. package/src/rules-transforms.ts +0 -412
  55. package/src/rules-typography.ts +0 -486
  56. package/src/rules.ts +0 -809
  57. package/src/scanner.ts +0 -84
  58. package/src/transformer-compile-class.ts +0 -275
  59. package/test/advanced-features.test.ts +0 -911
  60. package/test/arbitrary.test.ts +0 -396
  61. package/test/attributify.test.ts +0 -592
  62. package/test/bracket-syntax.test.ts +0 -1133
  63. package/test/build.test.ts +0 -99
  64. package/test/colors.test.ts +0 -934
  65. package/test/flexbox.test.ts +0 -669
  66. package/test/generator.test.ts +0 -597
  67. package/test/grid.test.ts +0 -584
  68. package/test/layout.test.ts +0 -404
  69. package/test/modifiers.test.ts +0 -417
  70. package/test/parser.test.ts +0 -564
  71. package/test/performance-regression.test.ts +0 -376
  72. package/test/performance.test.ts +0 -568
  73. package/test/plugin.test.ts +0 -160
  74. package/test/scanner.test.ts +0 -94
  75. package/test/sizing.test.ts +0 -481
  76. package/test/spacing.test.ts +0 -394
  77. package/test/transformer-compile-class.test.ts +0 -287
  78. package/test/transforms.test.ts +0 -448
  79. package/test/typography.test.ts +0 -632
  80. package/test/variants-form-states.test.ts +0 -225
  81. package/test/variants-group-peer.test.ts +0 -66
  82. package/test/variants-media.test.ts +0 -213
  83. package/test/variants-positional.test.ts +0 -58
  84. package/test/variants-pseudo-elements.test.ts +0 -47
  85. package/test/variants-state.test.ts +0 -62
  86. package/tsconfig.json +0 -18
@@ -1,1133 +0,0 @@
1
- import { describe, expect, it } from 'bun:test'
2
- import { expandBracketSyntax, extractClasses } from '../src/parser'
3
-
4
- describe('Bracket Syntax', () => {
5
- describe('expandBracketSyntax', () => {
6
- describe('flex utilities', () => {
7
- it('should expand flex[col] to flex-col', () => {
8
- const result = expandBracketSyntax('flex[col]', { enabled: true })
9
- expect(result).toEqual(['flex-col'])
10
- })
11
-
12
- it('should expand flex[row] to flex-row', () => {
13
- const result = expandBracketSyntax('flex[row]', { enabled: true })
14
- expect(result).toEqual(['flex-row'])
15
- })
16
-
17
- it('should expand flex[col-reverse] to flex-col-reverse', () => {
18
- const result = expandBracketSyntax('flex[col-reverse]', { enabled: true })
19
- expect(result).toEqual(['flex-col-reverse'])
20
- })
21
-
22
- it('should expand flex[row-reverse] to flex-row-reverse', () => {
23
- const result = expandBracketSyntax('flex[row-reverse]', { enabled: true })
24
- expect(result).toEqual(['flex-row-reverse'])
25
- })
26
-
27
- it('should expand multiple flex values', () => {
28
- const result = expandBracketSyntax('flex[col row]', { enabled: true })
29
- expect(result).toEqual(['flex-col', 'flex-row'])
30
- })
31
-
32
- it('should expand flex with justify-center alias', () => {
33
- const result = expandBracketSyntax('flex[jc-center]', { enabled: true })
34
- expect(result).toEqual(['justify-center'])
35
- })
36
-
37
- it('should expand flex with items-center alias', () => {
38
- const result = expandBracketSyntax('flex[ai-center]', { enabled: true })
39
- expect(result).toEqual(['items-center'])
40
- })
41
-
42
- it('should expand flex with multiple aliases', () => {
43
- const result = expandBracketSyntax('flex[col jc-center ai-center]', { enabled: true })
44
- expect(result).toEqual(['flex-col', 'justify-center', 'items-center'])
45
- })
46
-
47
- it('should expand flex[wrap] to flex-wrap', () => {
48
- const result = expandBracketSyntax('flex[wrap]', { enabled: true })
49
- expect(result).toEqual(['flex-wrap'])
50
- })
51
-
52
- it('should expand flex[nowrap] to flex-nowrap', () => {
53
- const result = expandBracketSyntax('flex[nowrap]', { enabled: true })
54
- expect(result).toEqual(['flex-nowrap'])
55
- })
56
-
57
- it('should expand flex[wrap-reverse] to flex-wrap-reverse', () => {
58
- const result = expandBracketSyntax('flex[wrap-reverse]', { enabled: true })
59
- expect(result).toEqual(['flex-wrap-reverse'])
60
- })
61
-
62
- it('should expand flex[1] to flex-1', () => {
63
- const result = expandBracketSyntax('flex[1]', { enabled: true })
64
- expect(result).toEqual(['flex-1'])
65
- })
66
-
67
- it('should expand flex[grow] to flex-grow', () => {
68
- const result = expandBracketSyntax('flex[grow]', { enabled: true })
69
- expect(result).toEqual(['flex-grow'])
70
- })
71
-
72
- it('should expand flex[shrink] to flex-shrink', () => {
73
- const result = expandBracketSyntax('flex[shrink]', { enabled: true })
74
- expect(result).toEqual(['flex-shrink'])
75
- })
76
-
77
- it('should expand flex[auto] to flex-auto', () => {
78
- const result = expandBracketSyntax('flex[auto]', { enabled: true })
79
- expect(result).toEqual(['flex-auto'])
80
- })
81
-
82
- it('should expand flex[initial] to flex-initial', () => {
83
- const result = expandBracketSyntax('flex[initial]', { enabled: true })
84
- expect(result).toEqual(['flex-initial'])
85
- })
86
-
87
- it('should expand flex[none] to flex-none', () => {
88
- const result = expandBracketSyntax('flex[none]', { enabled: true })
89
- expect(result).toEqual(['flex-none'])
90
- })
91
-
92
- it('should expand complex flex grouping', () => {
93
- const result = expandBracketSyntax('flex[col wrap jc-between ai-start]', { enabled: true })
94
- expect(result).toContain('flex-col')
95
- expect(result).toContain('flex-wrap')
96
- expect(result).toContain('justify-between')
97
- expect(result).toContain('items-start')
98
- })
99
-
100
- it('should use custom aliases', () => {
101
- const result = expandBracketSyntax('flex[jc-c]', {
102
- enabled: true,
103
- aliases: { 'c': 'center' },
104
- })
105
- expect(result).toEqual(['justify-center'])
106
- })
107
- })
108
-
109
- describe('text utilities', () => {
110
- it('should expand text[white] to text-white', () => {
111
- const result = expandBracketSyntax('text[white]', { enabled: true })
112
- expect(result).toEqual(['text-white'])
113
- })
114
-
115
- it('should expand text[black] to text-black', () => {
116
- const result = expandBracketSyntax('text[black]', { enabled: true })
117
- expect(result).toEqual(['text-black'])
118
- })
119
-
120
- it('should expand text[red] to text-red', () => {
121
- const result = expandBracketSyntax('text[red]', { enabled: true })
122
- expect(result).toEqual(['text-red'])
123
- })
124
-
125
- it('should expand text[2rem] to text-[2rem]', () => {
126
- const result = expandBracketSyntax('text[2rem]', { enabled: true })
127
- expect(result).toEqual(['text-[2rem]'])
128
- })
129
-
130
- it('should expand text[16px] to text-[16px]', () => {
131
- const result = expandBracketSyntax('text[16px]', { enabled: true })
132
- expect(result).toEqual(['text-[16px]'])
133
- })
134
-
135
- it('should expand text[1.5em] to text-[1.5em]', () => {
136
- const result = expandBracketSyntax('text[1.5em]', { enabled: true })
137
- expect(result).toEqual(['text-[1.5em]'])
138
- })
139
-
140
- it('should expand text[100] to font-thin', () => {
141
- const result = expandBracketSyntax('text[100]', { enabled: true })
142
- expect(result).toEqual(['font-thin'])
143
- })
144
-
145
- it('should expand text[200] to font-extralight', () => {
146
- const result = expandBracketSyntax('text[200]', { enabled: true })
147
- expect(result).toEqual(['font-extralight'])
148
- })
149
-
150
- it('should expand text[300] to font-light', () => {
151
- const result = expandBracketSyntax('text[300]', { enabled: true })
152
- expect(result).toEqual(['font-light'])
153
- })
154
-
155
- it('should expand text[400] to font-normal', () => {
156
- const result = expandBracketSyntax('text[400]', { enabled: true })
157
- expect(result).toEqual(['font-normal'])
158
- })
159
-
160
- it('should expand text[500] to font-medium', () => {
161
- const result = expandBracketSyntax('text[500]', { enabled: true })
162
- expect(result).toEqual(['font-medium'])
163
- })
164
-
165
- it('should expand text[600] to font-semibold', () => {
166
- const result = expandBracketSyntax('text[600]', { enabled: true })
167
- expect(result).toEqual(['font-semibold'])
168
- })
169
-
170
- it('should expand text[700] to font-bold', () => {
171
- const result = expandBracketSyntax('text[700]', { enabled: true })
172
- expect(result).toEqual(['font-bold'])
173
- })
174
-
175
- it('should expand text[800] to font-extrabold', () => {
176
- const result = expandBracketSyntax('text[800]', { enabled: true })
177
- expect(result).toEqual(['font-extrabold'])
178
- })
179
-
180
- it('should expand text[900] to font-black', () => {
181
- const result = expandBracketSyntax('text[900]', { enabled: true })
182
- expect(result).toEqual(['font-black'])
183
- })
184
-
185
- it('should expand text[arial] to font-[arial]', () => {
186
- const result = expandBracketSyntax('text[arial]', { enabled: true })
187
- expect(result).toEqual(['font-[arial]'])
188
- })
189
-
190
- it('should expand text[helvetica] to font-[helvetica]', () => {
191
- const result = expandBracketSyntax('text[helvetica]', { enabled: true })
192
- expect(result).toEqual(['font-[helvetica]'])
193
- })
194
-
195
- it('should expand complex text grouping', () => {
196
- const result = expandBracketSyntax('text[arial white 2rem 700]', { enabled: true })
197
- expect(result).toContain('font-[arial]')
198
- expect(result).toContain('text-white')
199
- expect(result).toContain('text-[2rem]')
200
- expect(result).toContain('font-bold')
201
- })
202
-
203
- it('should expand text[sm] to text-sm', () => {
204
- const result = expandBracketSyntax('text[sm]', { enabled: true })
205
- expect(result).toEqual(['text-sm'])
206
- })
207
-
208
- it('should expand text[lg] to text-lg', () => {
209
- const result = expandBracketSyntax('text[lg]', { enabled: true })
210
- expect(result).toEqual(['text-lg'])
211
- })
212
-
213
- it('should expand text[xl] to text-xl', () => {
214
- const result = expandBracketSyntax('text[xl]', { enabled: true })
215
- expect(result).toEqual(['text-xl'])
216
- })
217
-
218
- it('should expand text[2xl] to text-2xl', () => {
219
- const result = expandBracketSyntax('text[2xl]', { enabled: true })
220
- expect(result).toEqual(['text-2xl'])
221
- })
222
- })
223
-
224
- describe('width utilities', () => {
225
- it('should expand w[full] to w-full', () => {
226
- const result = expandBracketSyntax('w[full]', { enabled: true })
227
- expect(result).toEqual(['w-full'])
228
- })
229
-
230
- it('should expand w[screen] to w-screen', () => {
231
- const result = expandBracketSyntax('w[screen]', { enabled: true })
232
- expect(result).toEqual(['w-screen'])
233
- })
234
-
235
- it('should expand w[auto] to w-auto', () => {
236
- const result = expandBracketSyntax('w[auto]', { enabled: true })
237
- expect(result).toEqual(['w-auto'])
238
- })
239
-
240
- it('should expand w[100%] to w-[100%]', () => {
241
- const result = expandBracketSyntax('w[100%]', { enabled: true })
242
- expect(result).toEqual(['w-[100%]'])
243
- })
244
-
245
- it('should expand w[50%] to w-[50%]', () => {
246
- const result = expandBracketSyntax('w[50%]', { enabled: true })
247
- expect(result).toEqual(['w-[50%]'])
248
- })
249
-
250
- it('should expand w[200px] to w-[200px]', () => {
251
- const result = expandBracketSyntax('w[200px]', { enabled: true })
252
- expect(result).toEqual(['w-[200px]'])
253
- })
254
-
255
- it('should expand w[min 200px] to min-w-[200px]', () => {
256
- const result = expandBracketSyntax('w[min 200px]', { enabled: true })
257
- expect(result).toEqual(['min-w-[200px]'])
258
- })
259
-
260
- it('should expand w[max 500px] to max-w-[500px]', () => {
261
- const result = expandBracketSyntax('w[max 500px]', { enabled: true })
262
- expect(result).toEqual(['max-w-[500px]'])
263
- })
264
-
265
- it('should expand w[min full] to min-w-full', () => {
266
- const result = expandBracketSyntax('w[min full]', { enabled: true })
267
- expect(result).toEqual(['min-w-full'])
268
- })
269
-
270
- it('should expand w[max screen] to max-w-screen', () => {
271
- const result = expandBracketSyntax('w[max screen]', { enabled: true })
272
- expect(result).toEqual(['max-w-screen'])
273
- })
274
- })
275
-
276
- describe('height utilities', () => {
277
- it('should expand h[full] to h-full', () => {
278
- const result = expandBracketSyntax('h[full]', { enabled: true })
279
- expect(result).toEqual(['h-full'])
280
- })
281
-
282
- it('should expand h[screen] to h-screen', () => {
283
- const result = expandBracketSyntax('h[screen]', { enabled: true })
284
- expect(result).toEqual(['h-screen'])
285
- })
286
-
287
- it('should expand h[100vh] to h-[100vh]', () => {
288
- const result = expandBracketSyntax('h[100vh]', { enabled: true })
289
- expect(result).toEqual(['h-[100vh]'])
290
- })
291
-
292
- it('should expand h[min 100vh] to min-h-[100vh]', () => {
293
- const result = expandBracketSyntax('h[min 100vh]', { enabled: true })
294
- expect(result).toEqual(['min-h-[100vh]'])
295
- })
296
-
297
- it('should expand h[max 500px] to max-h-[500px]', () => {
298
- const result = expandBracketSyntax('h[max 500px]', { enabled: true })
299
- expect(result).toEqual(['max-h-[500px]'])
300
- })
301
-
302
- it('should expand h[min screen] to min-h-screen', () => {
303
- const result = expandBracketSyntax('h[min screen]', { enabled: true })
304
- expect(result).toEqual(['min-h-screen'])
305
- })
306
-
307
- it('should expand h[max full] to max-h-full', () => {
308
- const result = expandBracketSyntax('h[max full]', { enabled: true })
309
- expect(result).toEqual(['max-h-full'])
310
- })
311
- })
312
-
313
- describe('scroll utilities', () => {
314
- it('should expand scroll[y auto] to overflow-y-auto', () => {
315
- const result = expandBracketSyntax('scroll[y auto]', { enabled: true })
316
- expect(result).toEqual(['overflow-y-auto'])
317
- })
318
-
319
- it('should expand scroll[x auto] to overflow-x-auto', () => {
320
- const result = expandBracketSyntax('scroll[x auto]', { enabled: true })
321
- expect(result).toEqual(['overflow-x-auto'])
322
- })
323
-
324
- it('should expand scroll[y hidden] to overflow-y-hidden', () => {
325
- const result = expandBracketSyntax('scroll[y hidden]', { enabled: true })
326
- expect(result).toEqual(['overflow-y-hidden'])
327
- })
328
-
329
- it('should expand scroll[x hidden] to overflow-x-hidden', () => {
330
- const result = expandBracketSyntax('scroll[x hidden]', { enabled: true })
331
- expect(result).toEqual(['overflow-x-hidden'])
332
- })
333
-
334
- it('should expand scroll[y scroll] to overflow-y-scroll', () => {
335
- const result = expandBracketSyntax('scroll[y scroll]', { enabled: true })
336
- expect(result).toEqual(['overflow-y-scroll'])
337
- })
338
-
339
- it('should expand scroll[y visible] to overflow-y-visible', () => {
340
- const result = expandBracketSyntax('scroll[y visible]', { enabled: true })
341
- expect(result).toEqual(['overflow-y-visible'])
342
- })
343
- })
344
-
345
- describe('background utilities', () => {
346
- it('should expand bg[black] to bg-black', () => {
347
- const result = expandBracketSyntax('bg[black]', { enabled: true })
348
- expect(result).toEqual(['bg-black'])
349
- })
350
-
351
- it('should expand bg[white] to bg-white', () => {
352
- const result = expandBracketSyntax('bg[white]', { enabled: true })
353
- expect(result).toEqual(['bg-white'])
354
- })
355
-
356
- it('should expand bg[blue-500] to bg-blue-500', () => {
357
- const result = expandBracketSyntax('bg[blue-500]', { enabled: true })
358
- expect(result).toEqual(['bg-blue-500'])
359
- })
360
-
361
- it('should expand bg[red-500] to bg-red-500', () => {
362
- const result = expandBracketSyntax('bg[red-500]', { enabled: true })
363
- expect(result).toEqual(['bg-red-500'])
364
- })
365
-
366
- it('should expand bg[transparent] to bg-transparent', () => {
367
- const result = expandBracketSyntax('bg[transparent]', { enabled: true })
368
- expect(result).toEqual(['bg-transparent'])
369
- })
370
- })
371
-
372
- describe('grid utilities', () => {
373
- it('should expand grid[cols-3] to grid-cols-3', () => {
374
- const result = expandBracketSyntax('grid[cols-3]', { enabled: true })
375
- expect(result).toEqual(['grid-cols-3'])
376
- })
377
-
378
- it('should expand grid[cols-12] to grid-cols-12', () => {
379
- const result = expandBracketSyntax('grid[cols-12]', { enabled: true })
380
- expect(result).toEqual(['grid-cols-12'])
381
- })
382
-
383
- it('should expand grid[rows-2] to grid-rows-2', () => {
384
- const result = expandBracketSyntax('grid[rows-2]', { enabled: true })
385
- expect(result).toEqual(['grid-rows-2'])
386
- })
387
-
388
- it('should expand grid[rows-6] to grid-rows-6', () => {
389
- const result = expandBracketSyntax('grid[rows-6]', { enabled: true })
390
- expect(result).toEqual(['grid-rows-6'])
391
- })
392
-
393
- it('should expand grid[flow-row] to grid-flow-row', () => {
394
- const result = expandBracketSyntax('grid[flow-row]', { enabled: true })
395
- expect(result).toEqual(['grid-flow-row'])
396
- })
397
-
398
- it('should expand grid[flow-col] to grid-flow-col', () => {
399
- const result = expandBracketSyntax('grid[flow-col]', { enabled: true })
400
- expect(result).toEqual(['grid-flow-col'])
401
- })
402
-
403
- it('should expand grid[flow-dense] to grid-flow-dense', () => {
404
- const result = expandBracketSyntax('grid[flow-dense]', { enabled: true })
405
- expect(result).toEqual(['grid-flow-dense'])
406
- })
407
- })
408
-
409
- describe('padding utilities', () => {
410
- it('should expand p[4] to p-4', () => {
411
- const result = expandBracketSyntax('p[4]', { enabled: true })
412
- expect(result).toEqual(['p-4'])
413
- })
414
-
415
- it('should expand p[8] to p-8', () => {
416
- const result = expandBracketSyntax('p[8]', { enabled: true })
417
- expect(result).toEqual(['p-8'])
418
- })
419
-
420
- it('should expand p[2 4] to p-2 p-4', () => {
421
- const result = expandBracketSyntax('p[2 4]', { enabled: true })
422
- expect(result).toEqual(['p-2', 'p-4'])
423
- })
424
- })
425
-
426
- describe('margin utilities', () => {
427
- it('should expand m[4] to m-4', () => {
428
- const result = expandBracketSyntax('m[4]', { enabled: true })
429
- expect(result).toEqual(['m-4'])
430
- })
431
-
432
- it('should expand m[auto] to m-auto', () => {
433
- const result = expandBracketSyntax('m[auto]', { enabled: true })
434
- expect(result).toEqual(['m-auto'])
435
- })
436
- })
437
-
438
- describe('other utilities', () => {
439
- it('should expand border[2] to border-2', () => {
440
- const result = expandBracketSyntax('border[2]', { enabled: true })
441
- expect(result).toEqual(['border-2'])
442
- })
443
-
444
- it('should expand rounded[lg] to rounded-lg', () => {
445
- const result = expandBracketSyntax('rounded[lg]', { enabled: true })
446
- expect(result).toEqual(['rounded-lg'])
447
- })
448
-
449
- it('should expand shadow[md] to shadow-md', () => {
450
- const result = expandBracketSyntax('shadow[md]', { enabled: true })
451
- expect(result).toEqual(['shadow-md'])
452
- })
453
-
454
- it('should expand gap[4] to gap-4', () => {
455
- const result = expandBracketSyntax('gap[4]', { enabled: true })
456
- expect(result).toEqual(['gap-4'])
457
- })
458
-
459
- it('should expand space[x-4] to space-x-4', () => {
460
- const result = expandBracketSyntax('space[x-4]', { enabled: true })
461
- expect(result).toEqual(['space-x-4'])
462
- })
463
- })
464
-
465
- describe('colon syntax', () => {
466
- it('should expand bg:black to bg-black when colonSyntax is enabled', () => {
467
- const result = expandBracketSyntax('bg:black', { enabled: true, colonSyntax: true })
468
- expect(result).toEqual(['bg-black'])
469
- })
470
-
471
- it('should expand w:100% to w-[100%] when colonSyntax is enabled', () => {
472
- const result = expandBracketSyntax('w:100%', { enabled: true, colonSyntax: true })
473
- expect(result).toEqual(['w-[100%]'])
474
- })
475
-
476
- it('should expand text:white to text-white when colonSyntax is enabled', () => {
477
- const result = expandBracketSyntax('text:white', { enabled: true, colonSyntax: true })
478
- expect(result).toEqual(['text-white'])
479
- })
480
-
481
- it('should expand p:4 to p-4 when colonSyntax is enabled', () => {
482
- const result = expandBracketSyntax('p:4', { enabled: true, colonSyntax: true })
483
- expect(result).toEqual(['p-4'])
484
- })
485
-
486
- it('should expand m:auto to m-auto when colonSyntax is enabled', () => {
487
- const result = expandBracketSyntax('m:auto', { enabled: true, colonSyntax: true })
488
- expect(result).toEqual(['m-auto'])
489
- })
490
-
491
- it('should expand h:100vh to h-[100vh] when colonSyntax is enabled', () => {
492
- const result = expandBracketSyntax('h:100vh', { enabled: true, colonSyntax: true })
493
- expect(result).toEqual(['h-[100vh]'])
494
- })
495
-
496
- it('should NOT expand bg:black when colonSyntax is disabled', () => {
497
- const result = expandBracketSyntax('bg:black', { enabled: true, colonSyntax: false })
498
- expect(result).toEqual(['bg:black'])
499
- })
500
-
501
- it('should NOT expand bg:black when colonSyntax is undefined', () => {
502
- const result = expandBracketSyntax('bg:black', { enabled: true })
503
- expect(result).toEqual(['bg:black'])
504
- })
505
- })
506
-
507
- describe('generic utilities', () => {
508
- it('should expand unknown prefix with generic pattern', () => {
509
- const result = expandBracketSyntax('custom[a b c]', { enabled: true })
510
- expect(result).toEqual(['custom-a', 'custom-b', 'custom-c'])
511
- })
512
-
513
- it('should handle arbitrary values in generic pattern', () => {
514
- const result = expandBracketSyntax('custom[10px 20%]', { enabled: true })
515
- expect(result).toEqual(['custom-[10px]', 'custom-[20%]'])
516
- })
517
-
518
- it('should handle mixed values in generic pattern', () => {
519
- const result = expandBracketSyntax('custom[solid 2px]', { enabled: true })
520
- expect(result).toEqual(['custom-solid', 'custom-[2px]'])
521
- })
522
- })
523
-
524
- describe('no expansion needed', () => {
525
- it('should return class as-is when no bracket syntax', () => {
526
- const result = expandBracketSyntax('flex', { enabled: true })
527
- expect(result).toEqual(['flex'])
528
- })
529
-
530
- it('should return class as-is for standard tailwind classes', () => {
531
- const result = expandBracketSyntax('bg-blue-500', { enabled: true })
532
- expect(result).toEqual(['bg-blue-500'])
533
- })
534
-
535
- it('should return class as-is for arbitrary value syntax', () => {
536
- const result = expandBracketSyntax('w-[100px]', { enabled: true })
537
- expect(result).toEqual(['w-[100px]'])
538
- })
539
-
540
- it('should return class as-is for variant classes', () => {
541
- const result = expandBracketSyntax('hover:bg-blue-500', { enabled: true })
542
- expect(result).toEqual(['hover:bg-blue-500'])
543
- })
544
- })
545
-
546
- describe('edge cases', () => {
547
- it('should handle empty brackets', () => {
548
- const result = expandBracketSyntax('flex[]', { enabled: true })
549
- expect(result).toEqual([])
550
- })
551
-
552
- it('should handle single space in brackets', () => {
553
- const result = expandBracketSyntax('flex[ ]', { enabled: true })
554
- expect(result).toEqual([])
555
- })
556
-
557
- it('should handle multiple spaces between values', () => {
558
- const result = expandBracketSyntax('flex[col row]', { enabled: true })
559
- expect(result).toEqual(['flex-col', 'flex-row'])
560
- })
561
-
562
- it('should handle leading/trailing spaces in brackets', () => {
563
- const result = expandBracketSyntax('flex[ col row ]', { enabled: true })
564
- expect(result).toEqual(['flex-col', 'flex-row'])
565
- })
566
- })
567
-
568
- describe('new utility mappings', () => {
569
- it('should expand font[bold] to font-bold', () => {
570
- const result = expandBracketSyntax('font[bold]', { enabled: true })
571
- expect(result).toEqual(['font-bold'])
572
- })
573
-
574
- it('should expand font[sans serif mono] to multiple font utilities', () => {
575
- const result = expandBracketSyntax('font[sans serif mono]', { enabled: true })
576
- expect(result).toEqual(['font-sans', 'font-serif', 'font-mono'])
577
- })
578
-
579
- it('should expand font[700] to font-bold', () => {
580
- const result = expandBracketSyntax('font[700]', { enabled: true })
581
- expect(result).toEqual(['font-bold'])
582
- })
583
-
584
- it('should expand opacity[50] to opacity-50', () => {
585
- const result = expandBracketSyntax('opacity[50]', { enabled: true })
586
- expect(result).toEqual(['opacity-50'])
587
- })
588
-
589
- it('should expand z[10] to z-10', () => {
590
- const result = expandBracketSyntax('z[10]', { enabled: true })
591
- expect(result).toEqual(['z-10'])
592
- })
593
-
594
- it('should expand inset[0] to inset-0', () => {
595
- const result = expandBracketSyntax('inset[0]', { enabled: true })
596
- expect(result).toEqual(['inset-0'])
597
- })
598
-
599
- it('should expand inset[x-0 y-auto] to inset-x-0 and inset-y-auto', () => {
600
- const result = expandBracketSyntax('inset[x-0 y-auto]', { enabled: true })
601
- expect(result).toEqual(['inset-x-0', 'inset-y-auto'])
602
- })
603
-
604
- it('should expand top[0] to top-0', () => {
605
- const result = expandBracketSyntax('top[0]', { enabled: true })
606
- expect(result).toEqual(['top-0'])
607
- })
608
-
609
- it('should expand top[50%] to top-[50%]', () => {
610
- const result = expandBracketSyntax('top[50%]', { enabled: true })
611
- expect(result).toEqual(['top-[50%]'])
612
- })
613
-
614
- it('should expand duration[300] to duration-300', () => {
615
- const result = expandBracketSyntax('duration[300]', { enabled: true })
616
- expect(result).toEqual(['duration-300'])
617
- })
618
-
619
- it('should expand delay[150] to delay-150', () => {
620
- const result = expandBracketSyntax('delay[150]', { enabled: true })
621
- expect(result).toEqual(['delay-150'])
622
- })
623
-
624
- it('should expand ease[in-out] to ease-in-out', () => {
625
- const result = expandBracketSyntax('ease[in-out]', { enabled: true })
626
- expect(result).toEqual(['ease-in-out'])
627
- })
628
-
629
- it('should expand translate[x-4] to translate-x-4', () => {
630
- const result = expandBracketSyntax('translate[x-4]', { enabled: true })
631
- expect(result).toEqual(['translate-x-4'])
632
- })
633
-
634
- it('should expand translate[x-4 y-2] to translate-x-4 and translate-y-2', () => {
635
- const result = expandBracketSyntax('translate[x-4 y-2]', { enabled: true })
636
- expect(result).toEqual(['translate-x-4', 'translate-y-2'])
637
- })
638
-
639
- it('should expand rotate[45] to rotate-45', () => {
640
- const result = expandBracketSyntax('rotate[45]', { enabled: true })
641
- expect(result).toEqual(['rotate-45'])
642
- })
643
-
644
- it('should expand scale[75] to scale-75', () => {
645
- const result = expandBracketSyntax('scale[75]', { enabled: true })
646
- expect(result).toEqual(['scale-75'])
647
- })
648
-
649
- it('should expand scale[x-50 y-100] to scale-x-50 and scale-y-100', () => {
650
- const result = expandBracketSyntax('scale[x-50 y-100]', { enabled: true })
651
- expect(result).toEqual(['scale-x-50', 'scale-y-100'])
652
- })
653
-
654
- it('should expand cursor[pointer] to cursor-pointer', () => {
655
- const result = expandBracketSyntax('cursor[pointer]', { enabled: true })
656
- expect(result).toEqual(['cursor-pointer'])
657
- })
658
-
659
- it('should expand ring[2] to ring-2', () => {
660
- const result = expandBracketSyntax('ring[2]', { enabled: true })
661
- expect(result).toEqual(['ring-2'])
662
- })
663
-
664
- it('should expand blur[md] to blur-md', () => {
665
- const result = expandBracketSyntax('blur[md]', { enabled: true })
666
- expect(result).toEqual(['blur-md'])
667
- })
668
-
669
- it('should expand aspect[video] to aspect-video', () => {
670
- const result = expandBracketSyntax('aspect[video]', { enabled: true })
671
- expect(result).toEqual(['aspect-video'])
672
- })
673
-
674
- it('should expand tracking[wide] to tracking-wide', () => {
675
- const result = expandBracketSyntax('tracking[wide]', { enabled: true })
676
- expect(result).toEqual(['tracking-wide'])
677
- })
678
-
679
- it('should expand leading[loose] to leading-loose', () => {
680
- const result = expandBracketSyntax('leading[loose]', { enabled: true })
681
- expect(result).toEqual(['leading-loose'])
682
- })
683
- })
684
-
685
- describe('variant support in bracket syntax', () => {
686
- it('should expand hover:flex[col] to hover:flex-col', () => {
687
- const result = expandBracketSyntax('hover:flex[col]', { enabled: true })
688
- expect(result).toEqual(['hover:flex-col'])
689
- })
690
-
691
- it('should expand hover:bg[blue-500] to hover:bg-blue-500', () => {
692
- const result = expandBracketSyntax('hover:bg[blue-500]', { enabled: true })
693
- expect(result).toEqual(['hover:bg-blue-500'])
694
- })
695
-
696
- it('should expand dark:text[white] to dark:text-white', () => {
697
- const result = expandBracketSyntax('dark:text[white]', { enabled: true })
698
- expect(result).toEqual(['dark:text-white'])
699
- })
700
-
701
- it('should expand focus:ring[2] to focus:ring-2', () => {
702
- const result = expandBracketSyntax('focus:ring[2]', { enabled: true })
703
- expect(result).toEqual(['focus:ring-2'])
704
- })
705
-
706
- it('should expand dark:hover:bg[gray-800] to dark:hover:bg-gray-800', () => {
707
- const result = expandBracketSyntax('dark:hover:bg[gray-800]', { enabled: true })
708
- expect(result).toEqual(['dark:hover:bg-gray-800'])
709
- })
710
-
711
- it('should expand sm:flex[col] to sm:flex-col', () => {
712
- const result = expandBracketSyntax('sm:flex[col]', { enabled: true })
713
- expect(result).toEqual(['sm:flex-col'])
714
- })
715
-
716
- it('should expand md:lg:flex[row] to md:lg:flex-row', () => {
717
- const result = expandBracketSyntax('md:lg:flex[row]', { enabled: true })
718
- expect(result).toEqual(['md:lg:flex-row'])
719
- })
720
-
721
- it('should expand hover:flex[col jc-center] to multiple hover classes', () => {
722
- const result = expandBracketSyntax('hover:flex[col jc-center]', { enabled: true })
723
- expect(result).toEqual(['hover:flex-col', 'hover:justify-center'])
724
- })
725
- })
726
-
727
- describe('responsive variants inside brackets', () => {
728
- it('should expand flex[md:col] to md:flex-col', () => {
729
- const result = expandBracketSyntax('flex[md:col]', { enabled: true })
730
- expect(result).toEqual(['md:flex-col'])
731
- })
732
-
733
- it('should expand flex[col md:row] to flex-col and md:flex-row', () => {
734
- const result = expandBracketSyntax('flex[col md:row]', { enabled: true })
735
- expect(result).toEqual(['flex-col', 'md:flex-row'])
736
- })
737
-
738
- it('should expand flex[sm:col md:row lg:col-reverse] to multiple', () => {
739
- const result = expandBracketSyntax('flex[sm:col md:row lg:col-reverse]', { enabled: true })
740
- expect(result).toEqual(['sm:flex-col', 'md:flex-row', 'lg:flex-col-reverse'])
741
- })
742
-
743
- it('should expand text[sm md:lg lg:xl] with responsive variants', () => {
744
- const result = expandBracketSyntax('text[sm md:lg lg:xl]', { enabled: true })
745
- expect(result).toEqual(['text-sm', 'md:text-lg', 'lg:text-xl'])
746
- })
747
-
748
- it('should expand bg[gray-100 dark:gray-900] with dark mode', () => {
749
- const result = expandBracketSyntax('bg[gray-100 dark:gray-900]', { enabled: true })
750
- expect(result).toEqual(['bg-gray-100', 'dark:bg-gray-900'])
751
- })
752
-
753
- it('should expand p[4 hover:6] with state variant', () => {
754
- const result = expandBracketSyntax('p[4 hover:6]', { enabled: true })
755
- expect(result).toEqual(['p-4', 'hover:p-6'])
756
- })
757
- })
758
-
759
- describe('negative value support', () => {
760
- it('should expand -m[4] to -m-4', () => {
761
- const result = expandBracketSyntax('-m[4]', { enabled: true })
762
- expect(result).toEqual(['-m-4'])
763
- })
764
-
765
- it('should expand m[-4] to -m-4', () => {
766
- const result = expandBracketSyntax('m[-4]', { enabled: true })
767
- expect(result).toEqual(['-m-4'])
768
- })
769
-
770
- it('should expand -mt[2] to -mt-2', () => {
771
- const result = expandBracketSyntax('-mt[2]', { enabled: true })
772
- expect(result).toEqual(['-mt-2'])
773
- })
774
-
775
- it('should expand translate[-x-4] to -translate-x-4', () => {
776
- const result = expandBracketSyntax('translate[-x-4]', { enabled: true })
777
- expect(result).toEqual(['-translate-x-4'])
778
- })
779
-
780
- it('should expand -translate[x-4] to -translate-x-4', () => {
781
- const result = expandBracketSyntax('-translate[x-4]', { enabled: true })
782
- expect(result).toEqual(['-translate-x-4'])
783
- })
784
-
785
- it('should expand top[-4] to -top-4', () => {
786
- const result = expandBracketSyntax('top[-4]', { enabled: true })
787
- expect(result).toEqual(['-top-4'])
788
- })
789
-
790
- it('should expand inset[-2] to -inset-2', () => {
791
- const result = expandBracketSyntax('inset[-2]', { enabled: true })
792
- expect(result).toEqual(['-inset-2'])
793
- })
794
-
795
- it('should expand m[4 -2] to m-4 and -m-2', () => {
796
- const result = expandBracketSyntax('m[4 -2]', { enabled: true })
797
- expect(result).toEqual(['m-4', '-m-2'])
798
- })
799
- })
800
-
801
- describe('directional padding/margin utilities', () => {
802
- it('should expand px[4] to px-4', () => {
803
- const result = expandBracketSyntax('px[4]', { enabled: true })
804
- expect(result).toEqual(['px-4'])
805
- })
806
-
807
- it('should expand py[2 4] to py-2 and py-4', () => {
808
- const result = expandBracketSyntax('py[2 4]', { enabled: true })
809
- expect(result).toEqual(['py-2', 'py-4'])
810
- })
811
-
812
- it('should expand mx[auto] to mx-auto', () => {
813
- const result = expandBracketSyntax('mx[auto]', { enabled: true })
814
- expect(result).toEqual(['mx-auto'])
815
- })
816
-
817
- it('should expand mt[4] to mt-4', () => {
818
- const result = expandBracketSyntax('mt[4]', { enabled: true })
819
- expect(result).toEqual(['mt-4'])
820
- })
821
-
822
- it('should expand mb[8] to mb-8', () => {
823
- const result = expandBracketSyntax('mb[8]', { enabled: true })
824
- expect(result).toEqual(['mb-8'])
825
- })
826
- })
827
-
828
- describe('overflow utilities', () => {
829
- it('should expand overflow[hidden] to overflow-hidden', () => {
830
- const result = expandBracketSyntax('overflow[hidden]', { enabled: true })
831
- expect(result).toEqual(['overflow-hidden'])
832
- })
833
-
834
- it('should expand overflow[x auto] to overflow-x-auto', () => {
835
- const result = expandBracketSyntax('overflow[x auto]', { enabled: true })
836
- expect(result).toEqual(['overflow-x-auto'])
837
- })
838
-
839
- it('should expand overflow[y scroll] to overflow-y-scroll', () => {
840
- const result = expandBracketSyntax('overflow[y scroll]', { enabled: true })
841
- expect(result).toEqual(['overflow-y-scroll'])
842
- })
843
- })
844
- })
845
-
846
- describe('extractClasses with bracket syntax', () => {
847
- it('should extract and expand bracket syntax classes', () => {
848
- const html = '<div class="flex[col jc-center] bg:black"></div>'
849
- const result = extractClasses(html, {
850
- bracketSyntax: { enabled: true, colonSyntax: true },
851
- })
852
- expect(result.has('flex-col')).toBe(true)
853
- expect(result.has('justify-center')).toBe(true)
854
- expect(result.has('bg-black')).toBe(true)
855
- })
856
-
857
- it('should handle complex example correctly', () => {
858
- const html = `
859
- <main class="reset:meyer">
860
- <div class="flex[col jc-center ai-center] bg:black w:100% h[min 100vh] scroll[y auto]">
861
- <p class="text[arial white 2rem 700]">Hello Crosswind!</p>
862
- </div>
863
- </main>
864
- `
865
- const result = extractClasses(html, {
866
- bracketSyntax: { enabled: true, colonSyntax: true },
867
- })
868
-
869
- // flex[col jc-center ai-center]
870
- expect(result.has('flex-col')).toBe(true)
871
- expect(result.has('justify-center')).toBe(true)
872
- expect(result.has('items-center')).toBe(true)
873
-
874
- // bg:black
875
- expect(result.has('bg-black')).toBe(true)
876
-
877
- // w:100%
878
- expect(result.has('w-[100%]')).toBe(true)
879
-
880
- // h[min 100vh]
881
- expect(result.has('min-h-[100vh]')).toBe(true)
882
-
883
- // scroll[y auto]
884
- expect(result.has('overflow-y-auto')).toBe(true)
885
-
886
- // text[arial white 2rem 700]
887
- expect(result.has('font-[arial]')).toBe(true)
888
- expect(result.has('text-white')).toBe(true)
889
- expect(result.has('text-[2rem]')).toBe(true)
890
- expect(result.has('font-bold')).toBe(true)
891
-
892
- // reset:meyer (colon syntax)
893
- expect(result.has('reset-meyer')).toBe(true)
894
- })
895
-
896
- it('should work with mixed regular and bracket syntax', () => {
897
- const html = '<div class="flex items-center flex[col] p-4"></div>'
898
- const result = extractClasses(html, {
899
- bracketSyntax: { enabled: true },
900
- })
901
- expect(result.has('flex')).toBe(true)
902
- expect(result.has('items-center')).toBe(true)
903
- expect(result.has('flex-col')).toBe(true)
904
- expect(result.has('p-4')).toBe(true)
905
- })
906
-
907
- it('should work with className in JSX', () => {
908
- const jsx = '<div className="flex[col jc-center] p-4"></div>'
909
- const result = extractClasses(jsx, {
910
- bracketSyntax: { enabled: true },
911
- })
912
- expect(result.has('flex-col')).toBe(true)
913
- expect(result.has('justify-center')).toBe(true)
914
- expect(result.has('p-4')).toBe(true)
915
- })
916
-
917
- it('should work with template literals', () => {
918
- const jsx = '<div className={`flex[col] p-4`}></div>'
919
- const result = extractClasses(jsx, {
920
- bracketSyntax: { enabled: true },
921
- })
922
- expect(result.has('flex-col')).toBe(true)
923
- expect(result.has('p-4')).toBe(true)
924
- })
925
-
926
- it('should not expand bracket syntax when disabled', () => {
927
- const html = '<div class="flex[col]"></div>'
928
- const result = extractClasses(html)
929
- // When disabled, it should not extract the bracket syntax as valid class
930
- expect(result.has('flex-col')).toBe(false)
931
- })
932
-
933
- it('should handle multiple elements with bracket syntax', () => {
934
- const html = `
935
- <div class="flex[col] p-4">
936
- <span class="text[white 2rem]">Title</span>
937
- <p class="bg[gray-100] m[4]">Content</p>
938
- </div>
939
- `
940
- const result = extractClasses(html, {
941
- bracketSyntax: { enabled: true },
942
- })
943
- expect(result.has('flex-col')).toBe(true)
944
- expect(result.has('p-4')).toBe(true)
945
- expect(result.has('text-white')).toBe(true)
946
- expect(result.has('text-[2rem]')).toBe(true)
947
- expect(result.has('bg-gray-100')).toBe(true)
948
- expect(result.has('m-4')).toBe(true)
949
- })
950
-
951
- it('should preserve arbitrary values alongside bracket syntax', () => {
952
- const html = '<div class="w-[calc(100%-20px)] flex[col]"></div>'
953
- const result = extractClasses(html, {
954
- bracketSyntax: { enabled: true },
955
- })
956
- expect(result.has('w-[calc(100%-20px)]')).toBe(true)
957
- expect(result.has('flex-col')).toBe(true)
958
- })
959
-
960
- it('should preserve variants with bracket syntax', () => {
961
- const html = '<div class="hover:bg-blue-500 flex[col]"></div>'
962
- const result = extractClasses(html, {
963
- bracketSyntax: { enabled: true },
964
- })
965
- expect(result.has('hover:bg-blue-500')).toBe(true)
966
- expect(result.has('flex-col')).toBe(true)
967
- })
968
- })
969
-
970
- describe('filter utility mappings', () => {
971
- it('should expand invert[0] to invert-0', () => {
972
- const result = expandBracketSyntax('invert[0]', { enabled: true })
973
- expect(result).toEqual(['invert-0'])
974
- })
975
-
976
- it('should expand invert[100] to invert-100', () => {
977
- const result = expandBracketSyntax('invert[100]', { enabled: true })
978
- expect(result).toEqual(['invert-100'])
979
- })
980
-
981
- it('should expand hue-rotate[90] to hue-rotate-90', () => {
982
- const result = expandBracketSyntax('hue-rotate[90]', { enabled: true })
983
- expect(result).toEqual(['hue-rotate-90'])
984
- })
985
-
986
- it('should expand hue-rotate[45deg] to hue-rotate-45deg', () => {
987
- const result = expandBracketSyntax('hue-rotate[45deg]', { enabled: true })
988
- expect(result).toEqual(['hue-rotate-45deg'])
989
- })
990
-
991
- it('should expand drop-shadow[lg] to drop-shadow-lg', () => {
992
- const result = expandBracketSyntax('drop-shadow[lg]', { enabled: true })
993
- expect(result).toEqual(['drop-shadow-lg'])
994
- })
995
-
996
- it('should expand drop-shadow[md xl] to multiple', () => {
997
- const result = expandBracketSyntax('drop-shadow[md xl]', { enabled: true })
998
- expect(result).toEqual(['drop-shadow-md', 'drop-shadow-xl'])
999
- })
1000
-
1001
- it('should expand backdrop-invert[0] to backdrop-invert-0', () => {
1002
- const result = expandBracketSyntax('backdrop-invert[0]', { enabled: true })
1003
- expect(result).toEqual(['backdrop-invert-0'])
1004
- })
1005
-
1006
- it('should expand backdrop-hue-rotate[180deg] to backdrop-hue-rotate-180deg', () => {
1007
- const result = expandBracketSyntax('backdrop-hue-rotate[180deg]', { enabled: true })
1008
- expect(result).toEqual(['backdrop-hue-rotate-180deg'])
1009
- })
1010
-
1011
- it('should expand animate[spin] to animate-spin', () => {
1012
- const result = expandBracketSyntax('animate[spin]', { enabled: true })
1013
- expect(result).toEqual(['animate-spin'])
1014
- })
1015
-
1016
- it('should expand animate[bounce ping] to multiple', () => {
1017
- const result = expandBracketSyntax('animate[bounce ping]', { enabled: true })
1018
- expect(result).toEqual(['animate-bounce', 'animate-ping'])
1019
- })
1020
- })
1021
-
1022
- describe('transition utilities', () => {
1023
- it('should expand transition[all 300 ease-in-out] correctly', () => {
1024
- const result = expandBracketSyntax('transition[all 300 ease-in-out]', { enabled: true })
1025
- expect(result).toEqual(['transition-all', 'duration-300', 'ease-in-out'])
1026
- })
1027
-
1028
- it('should expand transition[colors 150 linear]', () => {
1029
- const result = expandBracketSyntax('transition[colors 150 linear]', { enabled: true })
1030
- expect(result).toEqual(['transition-colors', 'duration-150', 'ease-linear'])
1031
- })
1032
-
1033
- it('should expand transition[opacity] to transition-opacity', () => {
1034
- const result = expandBracketSyntax('transition[opacity]', { enabled: true })
1035
- expect(result).toEqual(['transition-opacity'])
1036
- })
1037
-
1038
- it('should expand transition[transform 200] correctly', () => {
1039
- const result = expandBracketSyntax('transition[transform 200]', { enabled: true })
1040
- expect(result).toEqual(['transition-transform', 'duration-200'])
1041
- })
1042
- })
1043
-
1044
- describe('important modifier', () => {
1045
- it('should expand p[4!] to !p-4', () => {
1046
- const result = expandBracketSyntax('p[4!]', { enabled: true })
1047
- expect(result).toEqual(['!p-4'])
1048
- })
1049
-
1050
- it('should expand m[2! 4] to !m-2 and m-4', () => {
1051
- const result = expandBracketSyntax('m[2! 4]', { enabled: true })
1052
- expect(result).toEqual(['!m-2', 'm-4'])
1053
- })
1054
-
1055
- it('should expand bg[blue-500!] to !bg-blue-500', () => {
1056
- const result = expandBracketSyntax('bg[blue-500!]', { enabled: true })
1057
- expect(result).toEqual(['!bg-blue-500'])
1058
- })
1059
-
1060
- it('should handle important with variant hover:p[4!]', () => {
1061
- const result = expandBracketSyntax('hover:p[4!]', { enabled: true })
1062
- expect(result).toEqual(['hover:!p-4'])
1063
- })
1064
-
1065
- it('should handle important with negative m[-4!]', () => {
1066
- const result = expandBracketSyntax('m[-4!]', { enabled: true })
1067
- expect(result).toEqual(['!-m-4'])
1068
- })
1069
-
1070
- it('should handle important with variant and negative hover:m[-2!]', () => {
1071
- const result = expandBracketSyntax('hover:m[-2!]', { enabled: true })
1072
- expect(result).toEqual(['hover:!-m-2'])
1073
- })
1074
- })
1075
-
1076
- describe('opacity modifier in grouped syntax', () => {
1077
- it('should expand bg[blue-500/50] to bg-blue-500/50', () => {
1078
- const result = expandBracketSyntax('bg[blue-500/50]', { enabled: true })
1079
- expect(result).toEqual(['bg-blue-500/50'])
1080
- })
1081
-
1082
- it('should expand text[white/80] to text-white/80', () => {
1083
- const result = expandBracketSyntax('text[white/80]', { enabled: true })
1084
- expect(result).toEqual(['text-white/80'])
1085
- })
1086
-
1087
- it('should expand border[gray-300/50] to border-gray-300/50', () => {
1088
- const result = expandBracketSyntax('border[gray-300/50]', { enabled: true })
1089
- expect(result).toEqual(['border-gray-300/50'])
1090
- })
1091
- })
1092
-
1093
- describe('space and gap utilities', () => {
1094
- it('should expand space[x-4 y-2] correctly', () => {
1095
- const result = expandBracketSyntax('space[x-4 y-2]', { enabled: true })
1096
- expect(result).toEqual(['space-x-4', 'space-y-2'])
1097
- })
1098
-
1099
- it('should expand gap[x-4 y-2] correctly', () => {
1100
- const result = expandBracketSyntax('gap[x-4 y-2]', { enabled: true })
1101
- expect(result).toEqual(['gap-x-4', 'gap-y-2'])
1102
- })
1103
-
1104
- it('should expand gap[4] to gap-4', () => {
1105
- const result = expandBracketSyntax('gap[4]', { enabled: true })
1106
- expect(result).toEqual(['gap-4'])
1107
- })
1108
- })
1109
-
1110
- describe('inset utilities', () => {
1111
- it('should expand inset[x-0 y-auto] correctly', () => {
1112
- const result = expandBracketSyntax('inset[x-0 y-auto]', { enabled: true })
1113
- expect(result).toEqual(['inset-x-0', 'inset-y-auto'])
1114
- })
1115
-
1116
- it('should expand inset[0] to inset-0', () => {
1117
- const result = expandBracketSyntax('inset[0]', { enabled: true })
1118
- expect(result).toEqual(['inset-0'])
1119
- })
1120
- })
1121
-
1122
- describe('ring utilities', () => {
1123
- it('should expand ring[2 blue-500 offset-2] correctly', () => {
1124
- const result = expandBracketSyntax('ring[2 blue-500 offset-2]', { enabled: true })
1125
- expect(result).toEqual(['ring-2', 'ring-blue-500', 'ring-offset-2'])
1126
- })
1127
-
1128
- it('should expand ring[4 inset] correctly', () => {
1129
- const result = expandBracketSyntax('ring[4 inset]', { enabled: true })
1130
- expect(result).toEqual(['ring-4', 'ring-inset'])
1131
- })
1132
- })
1133
- })