mancha 0.16.7 → 0.17.3

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 (85) hide show
  1. package/.github/workflows/ci.yml +8 -7
  2. package/README.md +88 -25
  3. package/dist/browser.d.ts +42 -3
  4. package/dist/browser.js +1 -1
  5. package/dist/browser.js.map +1 -1
  6. package/dist/css_gen_utils.js +323 -412
  7. package/dist/css_gen_utils.js.map +1 -1
  8. package/dist/dome.d.ts +2 -2
  9. package/dist/dome.js +17 -0
  10. package/dist/dome.js.map +1 -1
  11. package/dist/expressions/ast.d.ts +79 -0
  12. package/dist/expressions/ast.js +6 -0
  13. package/dist/expressions/ast.js.map +1 -0
  14. package/dist/expressions/ast.test.d.ts +1 -0
  15. package/dist/expressions/ast.test.js +122 -0
  16. package/dist/expressions/ast.test.js.map +1 -0
  17. package/dist/expressions/ast_factory.d.ts +37 -0
  18. package/dist/expressions/ast_factory.js +119 -0
  19. package/dist/expressions/ast_factory.js.map +1 -0
  20. package/dist/expressions/ast_factory.test.d.ts +1 -0
  21. package/dist/expressions/ast_factory.test.js +88 -0
  22. package/dist/expressions/ast_factory.test.js.map +1 -0
  23. package/dist/expressions/constants.d.ts +6 -0
  24. package/dist/expressions/constants.js +72 -0
  25. package/dist/expressions/constants.js.map +1 -0
  26. package/dist/expressions/constants.test.d.ts +1 -0
  27. package/dist/expressions/constants.test.js +84 -0
  28. package/dist/expressions/constants.test.js.map +1 -0
  29. package/dist/expressions/eval.d.ts +101 -0
  30. package/dist/expressions/eval.js +375 -0
  31. package/dist/expressions/eval.js.map +1 -0
  32. package/dist/expressions/eval.test.d.ts +1 -0
  33. package/dist/expressions/eval.test.js +141 -0
  34. package/dist/expressions/eval.test.js.map +1 -0
  35. package/dist/expressions/expressions.test.d.ts +6 -0
  36. package/dist/expressions/expressions.test.js +7 -0
  37. package/dist/expressions/expressions.test.js.map +1 -0
  38. package/dist/expressions/index.d.ts +6 -0
  39. package/dist/expressions/index.js +7 -0
  40. package/dist/expressions/index.js.map +1 -0
  41. package/dist/expressions/parser.d.ts +32 -0
  42. package/dist/expressions/parser.js +341 -0
  43. package/dist/expressions/parser.js.map +1 -0
  44. package/dist/expressions/parser.test.d.ts +1 -0
  45. package/dist/expressions/parser.test.js +176 -0
  46. package/dist/expressions/parser.test.js.map +1 -0
  47. package/dist/expressions/tokenizer.d.ts +49 -0
  48. package/dist/expressions/tokenizer.js +253 -0
  49. package/dist/expressions/tokenizer.js.map +1 -0
  50. package/dist/expressions/tokenizer.test.d.ts +1 -0
  51. package/dist/expressions/tokenizer.test.js +99 -0
  52. package/dist/expressions/tokenizer.test.js.map +1 -0
  53. package/dist/index.d.ts +2 -0
  54. package/dist/index.js +1 -0
  55. package/dist/index.js.map +1 -1
  56. package/dist/interfaces.d.ts +1 -1
  57. package/dist/mancha.d.ts +1 -1
  58. package/dist/mancha.js +1 -1
  59. package/dist/mancha.js.map +1 -1
  60. package/dist/plugins.js +94 -23
  61. package/dist/plugins.js.map +1 -1
  62. package/dist/renderer.d.ts +5 -2
  63. package/dist/renderer.js +6 -2
  64. package/dist/renderer.js.map +1 -1
  65. package/dist/safe_browser.d.ts +4 -3
  66. package/dist/safe_browser.js +1 -1
  67. package/dist/safe_browser.js.map +1 -1
  68. package/dist/store.d.ts +59 -13
  69. package/dist/store.js +112 -38
  70. package/dist/store.js.map +1 -1
  71. package/dist/test_utils.d.ts +2 -0
  72. package/dist/test_utils.js +14 -1
  73. package/dist/test_utils.js.map +1 -1
  74. package/dist/trusted_attributes.js +2 -0
  75. package/dist/trusted_attributes.js.map +1 -1
  76. package/dist/type_checker.d.ts +1 -0
  77. package/dist/type_checker.js +113 -41
  78. package/dist/type_checker.js.map +1 -1
  79. package/dist/worker.d.ts +2 -0
  80. package/dist/worker.js +1 -0
  81. package/dist/worker.js.map +1 -1
  82. package/docs/quickstart.md +200 -0
  83. package/gulpfile.js +5 -1
  84. package/package.json +19 -6
  85. package/tsec_exemptions.json +1 -1
@@ -1,16 +1,11 @@
1
- const MEDIA_BREAKPOINTS = {
2
- sm: 640,
3
- md: 768,
4
- lg: 1024,
5
- xl: 1280,
6
- };
1
+ const MEDIA_BREAKPOINTS = { sm: 640, md: 768, lg: 1024, xl: 1280 };
2
+ const MEDIA_ENTRIES = Object.entries(MEDIA_BREAKPOINTS);
7
3
  const REM_UNIT = 0.25;
8
- const UNITS_SM = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];
4
+ // Generate 1-15
5
+ const UNITS_SM = [...Array(15)].map((_, i) => i + 1);
6
+ // Common larger values
9
7
  const UNITS_LG = [16, 20, 24, 25, 28, 30, 32, 36, 40, 44, 48, 50, 52, 56, 60];
10
- const UNITS_XL = [
11
- 64, 72, 80, 96, 100, 112, 128, 144, 160, 192, 200, 224, 256, 288, 300, 320, 384, 400, 448, 500,
12
- 512,
13
- ];
8
+ const UNITS_XL = [64, 72, 80, 96, 100, 112, 128, 144, 160, 192, 200, 224, 256, 288, 300, 320, 384, 400, 448, 500, 512];
14
9
  const UNITS_ALL = [...UNITS_SM, ...UNITS_LG, ...UNITS_XL, ...Object.values(MEDIA_BREAKPOINTS)];
15
10
  const PERCENTS = [1, 2, 5, 10, 20, 25, 30, 40, 50, 60, 70, 75, 80, 90, 95, 98, 99, 100];
16
11
  const DURATIONS = [75, 100, 150, 200, 300, 500, 700, 1000];
@@ -270,6 +265,71 @@ const PROPS_CUSTOM = {
270
265
  "bg-fixed": { "background-attachment": "fixed" },
271
266
  "bg-local": { "background-attachment": "local" },
272
267
  "bg-scroll": { "background-attachment": "scroll" },
268
+ // Screen/viewport sizing.
269
+ "min-h-screen": { "min-height": "100vh" },
270
+ "max-h-screen": { "max-height": "100vh" },
271
+ "min-w-screen": { "min-width": "100vw" },
272
+ "h-dvh": { height: "100dvh" },
273
+ "h-svh": { height: "100svh" },
274
+ "h-lvh": { height: "100lvh" },
275
+ "w-dvw": { width: "100dvw" },
276
+ "w-svw": { width: "100svw" },
277
+ "w-lvw": { width: "100lvw" },
278
+ "min-h-dvh": { "min-height": "100dvh" },
279
+ "min-h-svh": { "min-height": "100svh" },
280
+ "min-h-lvh": { "min-height": "100lvh" },
281
+ // Flexbox enhancements.
282
+ "flex-none": { flex: "none" },
283
+ "flex-auto": { flex: "1 1 auto" },
284
+ "flex-initial": { flex: "0 1 auto" },
285
+ grow: { "flex-grow": "1" },
286
+ "grow-0": { "flex-grow": "0" },
287
+ shrink: { "flex-shrink": "1" },
288
+ "shrink-0": { "flex-shrink": "0" },
289
+ "self-auto": { "align-self": "auto" },
290
+ "self-start": { "align-self": "flex-start" },
291
+ "self-end": { "align-self": "flex-end" },
292
+ "self-center": { "align-self": "center" },
293
+ "self-stretch": { "align-self": "stretch" },
294
+ "self-baseline": { "align-self": "baseline" },
295
+ "content-normal": { "align-content": "normal" },
296
+ "content-start": { "align-content": "flex-start" },
297
+ "content-end": { "align-content": "flex-end" },
298
+ "content-center": { "align-content": "center" },
299
+ "content-between": { "align-content": "space-between" },
300
+ "content-around": { "align-content": "space-around" },
301
+ "content-evenly": { "align-content": "space-evenly" },
302
+ "content-stretch": { "align-content": "stretch" },
303
+ "items-baseline": { "align-items": "baseline" },
304
+ // Inset utilities.
305
+ "inset-0": { inset: "0" },
306
+ "inset-auto": { inset: "auto" },
307
+ "inset-x-0": { left: "0", right: "0" },
308
+ "inset-y-0": { top: "0", bottom: "0" },
309
+ "inset-x-auto": { left: "auto", right: "auto" },
310
+ "inset-y-auto": { top: "auto", bottom: "auto" },
311
+ // Accessibility.
312
+ "sr-only": {
313
+ position: "absolute",
314
+ width: "1px",
315
+ height: "1px",
316
+ padding: "0",
317
+ margin: "-1px",
318
+ overflow: "hidden",
319
+ clip: "rect(0, 0, 0, 0)",
320
+ "white-space": "nowrap",
321
+ "border-width": "0",
322
+ },
323
+ "not-sr-only": {
324
+ position: "static",
325
+ width: "auto",
326
+ height: "auto",
327
+ padding: "0",
328
+ margin: "0",
329
+ overflow: "visible",
330
+ clip: "auto",
331
+ "white-space": "normal",
332
+ },
273
333
  };
274
334
  const PROPS_AS_IS = [
275
335
  `@keyframes spin {
@@ -289,542 +349,392 @@ const PROPS_AS_IS = [
289
349
  ];
290
350
  const PROPS_COLORS = {
291
351
  red: {
292
- 50: 0xffebee,
293
- 100: 0xffcdd2,
294
- 200: 0xef9a9a,
295
- 300: 0xe57373,
296
- 400: 0xef5350,
297
- 500: 0xf44336,
298
- 600: 0xe53935,
299
- 700: 0xd32f2f,
300
- 800: 0xc62828,
301
- 900: 0xb71c1c,
352
+ 50: "#ffebee",
353
+ 100: "#ffcdd2",
354
+ 200: "#ef9a9a",
355
+ 300: "#e57373",
356
+ 400: "#ef5350",
357
+ 500: "#f44336",
358
+ 600: "#e53935",
359
+ 700: "#d32f2f",
360
+ 800: "#c62828",
361
+ 900: "#b71c1c",
302
362
  },
303
363
  pink: {
304
- 50: 0xfce4ec,
305
- 100: 0xf8bbd0,
306
- 200: 0xf48fb1,
307
- 300: 0xf06292,
308
- 400: 0xec407a,
309
- 500: 0xe91e63,
310
- 600: 0xd81b60,
311
- 700: 0xc2185b,
312
- 800: 0xad1457,
313
- 900: 0x880e4f,
364
+ 50: "#fce4ec",
365
+ 100: "#f8bbd0",
366
+ 200: "#f48fb1",
367
+ 300: "#f06292",
368
+ 400: "#ec407a",
369
+ 500: "#e91e63",
370
+ 600: "#d81b60",
371
+ 700: "#c2185b",
372
+ 800: "#ad1457",
373
+ 900: "#880e4f",
314
374
  },
315
375
  purple: {
316
- 50: 0xf3e5f5,
317
- 100: 0xe1bee7,
318
- 200: 0xce93d8,
319
- 300: 0xba68c8,
320
- 400: 0xab47bc,
321
- 500: 0x9c27b0,
322
- 600: 0x8e24aa,
323
- 700: 0x7b1fa2,
324
- 800: 0x6a1b9a,
325
- 900: 0x4a148c,
376
+ 50: "#f3e5f5",
377
+ 100: "#e1bee7",
378
+ 200: "#ce93d8",
379
+ 300: "#ba68c8",
380
+ 400: "#ab47bc",
381
+ 500: "#9c27b0",
382
+ 600: "#8e24aa",
383
+ 700: "#7b1fa2",
384
+ 800: "#6a1b9a",
385
+ 900: "#4a148c",
326
386
  },
327
387
  "deep-purple": {
328
- 50: 0xede7f6,
329
- 100: 0xd1c4e9,
330
- 200: 0xb39ddb,
331
- 300: 0x9575cd,
332
- 400: 0x7e57c2,
333
- 500: 0x673ab7,
334
- 600: 0x5e35b1,
335
- 700: 0x512da8,
336
- 800: 0x4527a0,
337
- 900: 0x311b92,
388
+ 50: "#ede7f6",
389
+ 100: "#d1c4e9",
390
+ 200: "#b39ddb",
391
+ 300: "#9575cd",
392
+ 400: "#7e57c2",
393
+ 500: "#673ab7",
394
+ 600: "#5e35b1",
395
+ 700: "#512da8",
396
+ 800: "#4527a0",
397
+ 900: "#311b92",
338
398
  },
339
399
  indigo: {
340
- 50: 0xe8eaf6,
341
- 100: 0xc5cae9,
342
- 200: 0x9fa8da,
343
- 300: 0x7986cb,
344
- 400: 0x5c6bc0,
345
- 500: 0x3f51b5,
346
- 600: 0x3949ab,
347
- 700: 0x303f9f,
348
- 800: 0x283593,
349
- 900: 0x1a237e,
400
+ 50: "#e8eaf6",
401
+ 100: "#c5cae9",
402
+ 200: "#9fa8da",
403
+ 300: "#7986cb",
404
+ 400: "#5c6bc0",
405
+ 500: "#3f51b5",
406
+ 600: "#3949ab",
407
+ 700: "#303f9f",
408
+ 800: "#283593",
409
+ 900: "#1a237e",
350
410
  },
351
411
  blue: {
352
- 50: 0xe3f2fd,
353
- 100: 0xbbdefb,
354
- 200: 0x90caf9,
355
- 300: 0x64b5f6,
356
- 400: 0x42a5f5,
357
- 500: 0x2196f3,
358
- 600: 0x1e88e5,
359
- 700: 0x1976d2,
360
- 800: 0x1565c0,
361
- 900: 0x0d47a1,
412
+ 50: "#e3f2fd",
413
+ 100: "#bbdefb",
414
+ 200: "#90caf9",
415
+ 300: "#64b5f6",
416
+ 400: "#42a5f5",
417
+ 500: "#2196f3",
418
+ 600: "#1e88e5",
419
+ 700: "#1976d2",
420
+ 800: "#1565c0",
421
+ 900: "#0d47a1",
362
422
  },
363
423
  "light-blue": {
364
- 50: 0xe1f5fe,
365
- 100: 0xb3e5fc,
366
- 200: 0x81d4fa,
367
- 300: 0x4fc3f7,
368
- 400: 0x29b6f6,
369
- 500: 0x03a9f4,
370
- 600: 0x039be5,
371
- 700: 0x0288d1,
372
- 800: 0x0277bd,
373
- 900: 0x01579b,
424
+ 50: "#e1f5fe",
425
+ 100: "#b3e5fc",
426
+ 200: "#81d4fa",
427
+ 300: "#4fc3f7",
428
+ 400: "#29b6f6",
429
+ 500: "#03a9f4",
430
+ 600: "#039be5",
431
+ 700: "#0288d1",
432
+ 800: "#0277bd",
433
+ 900: "#01579b",
374
434
  },
375
435
  cyan: {
376
- 50: 0xe0f7fa,
377
- 100: 0xb2ebf2,
378
- 200: 0x80deea,
379
- 300: 0x4dd0e1,
380
- 400: 0x26c6da,
381
- 500: 0x00bcd4,
382
- 600: 0x00acc1,
383
- 700: 0x0097a7,
384
- 800: 0x00838f,
385
- 900: 0x006064,
436
+ 50: "#e0f7fa",
437
+ 100: "#b2ebf2",
438
+ 200: "#80deea",
439
+ 300: "#4dd0e1",
440
+ 400: "#26c6da",
441
+ 500: "#00bcd4",
442
+ 600: "#00acc1",
443
+ 700: "#0097a7",
444
+ 800: "#00838f",
445
+ 900: "#006064",
386
446
  },
387
447
  teal: {
388
- 50: 0xe0f2f1,
389
- 100: 0xb2dfdb,
390
- 200: 0x80cbc4,
391
- 300: 0x4db6ac,
392
- 400: 0x26a69a,
393
- 500: 0x009688,
394
- 600: 0x00897b,
395
- 700: 0x00796b,
396
- 800: 0x00695c,
397
- 900: 0x004d40,
448
+ 50: "#e0f2f1",
449
+ 100: "#b2dfdb",
450
+ 200: "#80cbc4",
451
+ 300: "#4db6ac",
452
+ 400: "#26a69a",
453
+ 500: "#009688",
454
+ 600: "#00897b",
455
+ 700: "#00796b",
456
+ 800: "#00695c",
457
+ 900: "#004d40",
398
458
  },
399
459
  green: {
400
- 50: 0xe8f5e9,
401
- 100: 0xc8e6c9,
402
- 200: 0xa5d6a7,
403
- 300: 0x81c784,
404
- 400: 0x66bb6a,
405
- 500: 0x4caf50,
406
- 600: 0x43a047,
407
- 700: 0x388e3c,
408
- 800: 0x2e7d32,
409
- 900: 0x1b5e20,
460
+ 50: "#e8f5e9",
461
+ 100: "#c8e6c9",
462
+ 200: "#a5d6a7",
463
+ 300: "#81c784",
464
+ 400: "#66bb6a",
465
+ 500: "#4caf50",
466
+ 600: "#43a047",
467
+ 700: "#388e3c",
468
+ 800: "#2e7d32",
469
+ 900: "#1b5e20",
410
470
  },
411
471
  "light-green": {
412
- 50: 0xf1f8e9,
413
- 100: 0xdcedc8,
414
- 200: 0xc5e1a5,
415
- 300: 0xaed581,
416
- 400: 0x9ccc65,
417
- 500: 0x8bc34a,
418
- 600: 0x7cb342,
419
- 700: 0x689f38,
420
- 800: 0x558b2f,
421
- 900: 0x33691e,
472
+ 50: "#f1f8e9",
473
+ 100: "#dcedc8",
474
+ 200: "#c5e1a5",
475
+ 300: "#aed581",
476
+ 400: "#9ccc65",
477
+ 500: "#8bc34a",
478
+ 600: "#7cb342",
479
+ 700: "#689f38",
480
+ 800: "#558b2f",
481
+ 900: "#33691e",
422
482
  },
423
483
  lime: {
424
- 50: 0xf9fbe7,
425
- 100: 0xf0f4c3,
426
- 200: 0xe6ee9c,
427
- 300: 0xdce775,
428
- 400: 0xd4e157,
429
- 500: 0xcddc39,
430
- 600: 0xc0ca33,
431
- 700: 0xafb42b,
432
- 800: 0x9e9d24,
433
- 900: 0x827717,
484
+ 50: "#f9fbe7",
485
+ 100: "#f0f4c3",
486
+ 200: "#e6ee9c",
487
+ 300: "#dce775",
488
+ 400: "#d4e157",
489
+ 500: "#cddc39",
490
+ 600: "#c0ca33",
491
+ 700: "#afb42b",
492
+ 800: "#9e9d24",
493
+ 900: "#827717",
434
494
  },
435
495
  yellow: {
436
- 50: 0xfffde7,
437
- 100: 0xfff9c4,
438
- 200: 0xfff59d,
439
- 300: 0xfff176,
440
- 400: 0xffee58,
441
- 500: 0xffeb3b,
442
- 600: 0xfdd835,
443
- 700: 0xfbc02d,
444
- 800: 0xf9a825,
445
- 900: 0xf57f17,
496
+ 50: "#fffde7",
497
+ 100: "#fff9c4",
498
+ 200: "#fff59d",
499
+ 300: "#fff176",
500
+ 400: "#ffee58",
501
+ 500: "#ffeb3b",
502
+ 600: "#fdd835",
503
+ 700: "#fbc02d",
504
+ 800: "#f9a825",
505
+ 900: "#f57f17",
446
506
  },
447
507
  amber: {
448
- 50: 0xfff8e1,
449
- 100: 0xffecb3,
450
- 200: 0xffe082,
451
- 300: 0xffd54f,
452
- 400: 0xffca28,
453
- 500: 0xffc107,
454
- 600: 0xffb300,
455
- 700: 0xffa000,
456
- 800: 0xff8f00,
457
- 900: 0xff6f00,
508
+ 50: "#fff8e1",
509
+ 100: "#ffecb3",
510
+ 200: "#ffe082",
511
+ 300: "#ffd54f",
512
+ 400: "#ffca28",
513
+ 500: "#ffc107",
514
+ 600: "#ffb300",
515
+ 700: "#ffa000",
516
+ 800: "#ff8f00",
517
+ 900: "#ff6f00",
458
518
  },
459
519
  orange: {
460
- 50: 0xfff3e0,
461
- 100: 0xffe0b2,
462
- 200: 0xffcc80,
463
- 300: 0xffb74d,
464
- 400: 0xffa726,
465
- 500: 0xff9800,
466
- 600: 0xfb8c00,
467
- 700: 0xf57c00,
468
- 800: 0xef6c00,
469
- 900: 0xe65100,
520
+ 50: "#fff3e0",
521
+ 100: "#ffe0b2",
522
+ 200: "#ffcc80",
523
+ 300: "#ffb74d",
524
+ 400: "#ffa726",
525
+ 500: "#ff9800",
526
+ 600: "#fb8c00",
527
+ 700: "#f57c00",
528
+ 800: "#ef6c00",
529
+ 900: "#e65100",
470
530
  },
471
531
  "deep-orange": {
472
- 50: 0xfbe9e7,
473
- 100: 0xffccbc,
474
- 200: 0xffab91,
475
- 300: 0xff8a65,
476
- 400: 0xff7043,
477
- 500: 0xff5722,
478
- 600: 0xf4511e,
479
- 700: 0xe64a19,
480
- 800: 0xd84315,
481
- 900: 0xbf360c,
532
+ 50: "#fbe9e7",
533
+ 100: "#ffccbc",
534
+ 200: "#ffab91",
535
+ 300: "#ff8a65",
536
+ 400: "#ff7043",
537
+ 500: "#ff5722",
538
+ 600: "#f4511e",
539
+ 700: "#e64a19",
540
+ 800: "#d84315",
541
+ 900: "#bf360c",
482
542
  },
483
543
  brown: {
484
- 50: 0xefebe9,
485
- 100: 0xd7ccc8,
486
- 200: 0xbcaaa4,
487
- 300: 0xa1887f,
488
- 400: 0x8d6e63,
489
- 500: 0x795548,
490
- 600: 0x6d4c41,
491
- 700: 0x5d4037,
492
- 800: 0x4e342e,
493
- 900: 0x3e2723,
544
+ 50: "#efebe9",
545
+ 100: "#d7ccc8",
546
+ 200: "#bcaaa4",
547
+ 300: "#a1887f",
548
+ 400: "#8d6e63",
549
+ 500: "#795548",
550
+ 600: "#6d4c41",
551
+ 700: "#5d4037",
552
+ 800: "#4e342e",
553
+ 900: "#3e2723",
494
554
  },
495
555
  gray: {
496
- 50: 0xfafafa,
497
- 100: 0xf5f5f5,
498
- 200: 0xeeeeee,
499
- 300: 0xe0e0e0,
500
- 400: 0xbdbdbd,
501
- 500: 0x9e9e9e,
502
- 600: 0x757575,
503
- 700: 0x616161,
504
- 800: 0x424242,
505
- 900: 0x212121,
556
+ 50: "#fafafa",
557
+ 100: "#f5f5f5",
558
+ 200: "#eeeeee",
559
+ 300: "#e0e0e0",
560
+ 400: "#bdbdbd",
561
+ 500: "#9e9e9e",
562
+ 600: "#757575",
563
+ 700: "#616161",
564
+ 800: "#424242",
565
+ 900: "#212121",
506
566
  },
507
567
  "blue-gray": {
508
- 50: 0xeceff1,
509
- 100: 0xcfd8dc,
510
- 200: 0xb0bec5,
511
- 300: 0x90a4ae,
512
- 400: 0x78909c,
513
- 500: 0x607d8b,
514
- 600: 0x546e7a,
515
- 700: 0x455a64,
516
- 800: 0x37474f,
517
- 900: 0x263238,
568
+ 50: "#eceff1",
569
+ 100: "#cfd8dc",
570
+ 200: "#b0bec5",
571
+ 300: "#90a4ae",
572
+ 400: "#78909c",
573
+ 500: "#607d8b",
574
+ 600: "#546e7a",
575
+ 700: "#455a64",
576
+ 800: "#37474f",
577
+ 900: "#263238",
518
578
  },
519
579
  };
520
- function hexColor(color) {
521
- return `#${color.toString(16).padStart(6, "0")}`;
522
- }
523
580
  function wrapPseudoStates(klass) {
524
581
  return PSEUDO_STATES.map((state) => `.${state}\\:${klass}:${state}`);
525
582
  }
526
583
  function wrapMediaQueries(klass, rule) {
527
- return Object.entries(MEDIA_BREAKPOINTS).map(([bp, width]) => `@media (min-width: ${width}px) { .${bp}\\:${klass} { ${rule} } }`);
584
+ return MEDIA_ENTRIES.map(([bp, width]) => `@media (min-width: ${width}px) { .${bp}\\:${klass} { ${rule} } }`);
585
+ }
586
+ function wrapAll(pairs) {
587
+ return pairs.flatMap(([klass, rule]) => [
588
+ `.${klass} { ${rule} }`,
589
+ `${wrapPseudoStates(klass).join(",")} { ${rule} }`,
590
+ ...wrapMediaQueries(klass, rule),
591
+ ]);
528
592
  }
529
593
  function ruleSorter(a, b) {
530
- // If one rule is a media query, it goes after the base rules.
531
- if (a.includes("@media") && !b.includes("@media")) {
594
+ // Media queries start with '@', regular rules start with '.'
595
+ const aMedia = a[0] === "@";
596
+ const bMedia = b[0] === "@";
597
+ if (aMedia && !bMedia)
532
598
  return 1;
533
- }
534
- else if (!a.includes("@media") && b.includes("@media")) {
599
+ if (!aMedia && bMedia)
535
600
  return -1;
536
- }
537
- // Otherwise, fall back to a lexicographical sort.
538
601
  return a.localeCompare(b);
539
602
  }
540
603
  function posneg(props) {
541
- return Object.entries(props)
542
- .flatMap(([prop, klass]) => [
543
- // Zero.
604
+ return wrapAll(Object.entries(props).flatMap(([prop, klass]) => [
544
605
  [`${klass}-0`, `${prop}: 0`],
545
- // Screen.
546
- [`${klass}-screen`, `${prop}: 100v${prop.includes('height') ? 'h' : 'w'}`],
547
- // Full.
606
+ [`${klass}-screen`, `${prop}: 100v${prop.includes("height") ? "h" : "w"}`],
548
607
  [`${klass}-full`, `${prop}: 100%`],
549
- // Positive REM units.
550
608
  ...UNITS_ALL.map((v) => [`${klass}-${v}`, `${prop}: ${v * REM_UNIT}rem`]),
551
- // Negative REM units.
552
609
  ...UNITS_ALL.map((v) => [`-${klass}-${v}`, `${prop}: -${v * REM_UNIT}rem`]),
553
- // Positive PX units.
554
610
  ...UNITS_ALL.map((v) => [`${klass}-${v}px`, `${prop}: ${v}px`]),
555
- // Negative PX units.
556
611
  ...UNITS_ALL.map((v) => [`-${klass}-${v}px`, `${prop}: -${v}px`]),
557
- // Positive percent units.
558
612
  ...PERCENTS.map((v) => [`${klass}-${v}\\%`, `${prop}: ${v}%`]),
559
- // Negative percent units.
560
613
  ...PERCENTS.map((v) => [`-${klass}-${v}\\%`, `${prop}: -${v}%`]),
561
- ])
562
- .flatMap(([klass, rule]) => [
563
- `.${klass} { ${rule} }`,
564
- `${wrapPseudoStates(klass).join(",")} { ${rule} }`,
565
- ...wrapMediaQueries(klass, rule),
566
- ]);
614
+ ]));
567
615
  }
568
616
  function autoxy(props) {
569
- return Object.entries(props)
570
- .flatMap(([prop, klass]) => [
571
- // Auto.
617
+ return wrapAll(Object.entries(props).flatMap(([prop, klass]) => [
572
618
  [`${klass}-auto`, `${prop}: auto`],
573
- // Auto x-axis.
574
619
  [`${klass}x-auto`, `${prop}-left: auto; ${prop}-right: auto;`],
575
- // Auto y-axis.
576
620
  [`${klass}y-auto`, `${prop}-top: auto; ${prop}-bottom: auto;`],
577
- // Zero x-axis.
578
621
  [`${klass}x-0`, `${prop}-left: 0; ${prop}-right: 0;`],
579
- // Zero y-axis.
580
622
  [`${klass}y-0`, `${prop}-top: 0; ${prop}-bottom: 0;`],
581
- // Positive REM units x-axis.
582
- ...UNITS_ALL.map((v) => [v, v * REM_UNIT]).map(([k, v]) => [
583
- `${klass}x-${k}`,
584
- `${prop}-left: ${v}rem; ${prop}-right: ${v}rem;`,
585
- ]),
586
- // Positive REM units y-axis.
587
- ...UNITS_ALL.map((v) => [v, v * REM_UNIT]).map(([k, v]) => [
588
- `${klass}y-${k}`,
589
- `${prop}-top: ${v}rem; ${prop}-bottom: ${v}rem;`,
590
- ]),
591
- // Positive PX units x-axis.
623
+ ...UNITS_ALL.map((v) => [`${klass}x-${v}`, `${prop}-left: ${v * REM_UNIT}rem; ${prop}-right: ${v * REM_UNIT}rem;`]),
624
+ ...UNITS_ALL.map((v) => [`${klass}y-${v}`, `${prop}-top: ${v * REM_UNIT}rem; ${prop}-bottom: ${v * REM_UNIT}rem;`]),
592
625
  ...UNITS_ALL.map((v) => [`${klass}x-${v}px`, `${prop}-left: ${v}px; ${prop}-right: ${v}px;`]),
593
- // Positive PX units y-axis.
594
626
  ...UNITS_ALL.map((v) => [`${klass}y-${v}px`, `${prop}-top: ${v}px; ${prop}-bottom: ${v}px;`]),
595
- // Positive percent units x-axis.
596
627
  ...PERCENTS.map((v) => [`${klass}x-${v}\\%`, `${prop}-left: ${v}%; ${prop}-right: ${v}%;`]),
597
- // Positive percent units y-axis.
598
628
  ...PERCENTS.map((v) => [`${klass}y-${v}\\%`, `${prop}-top: ${v}%; ${prop}-bottom: ${v}%;`]),
599
- ])
600
- .flatMap(([klass, rule]) => [
601
- `.${klass} { ${rule} }`,
602
- `${wrapPseudoStates(klass).join(",")} { ${rule} }`,
603
- ...wrapMediaQueries(klass, rule),
604
- ]);
629
+ ]));
605
630
  }
606
631
  function tblr(props) {
607
- return Object.entries(props)
608
- .flatMap(([prop, klass]) => [
609
- // Zero top.
632
+ return wrapAll(Object.entries(props).flatMap(([prop, klass]) => [
610
633
  [`${klass}t-0`, `${prop}-top: 0`],
611
- // Zero bottom.
612
634
  [`${klass}b-0`, `${prop}-bottom: 0`],
613
- // Zero left.
614
635
  [`${klass}l-0`, `${prop}-left: 0`],
615
- // Zero right.
616
636
  [`${klass}r-0`, `${prop}-right: 0`],
617
- // Auto top.
618
637
  [`${klass}t-auto`, `${prop}-top: auto`],
619
- // Auto bottom.
620
638
  [`${klass}b-auto`, `${prop}-bottom: auto`],
621
- // Auto left.
622
639
  [`${klass}l-auto`, `${prop}-left: auto`],
623
- // Auto right.
624
640
  [`${klass}r-auto`, `${prop}-right: auto`],
625
- // Positive / Negative.
626
641
  ...["", "-"].flatMap((sign) => [
627
- // REM units top.
628
- ...UNITS_ALL.map((v) => [v, v * REM_UNIT]).map(([k, v]) => [
629
- `${sign}${klass}t-${k}`,
630
- `${prop}-top: ${sign}${v}rem`,
631
- ]),
632
- // REM units bottom.
633
- ...UNITS_ALL.map((v) => [v, v * REM_UNIT]).map(([k, v]) => [
634
- `${sign}${klass}b-${k}`,
635
- `${prop}-bottom: ${sign}${v}rem`,
636
- ]),
637
- // REM units left.
638
- ...UNITS_ALL.map((v) => [v, v * REM_UNIT]).map(([k, v]) => [
639
- `${sign}${klass}l-${k}`,
640
- `${prop}-left: ${sign}${v}rem`,
641
- ]),
642
- // REM units right.
643
- ...UNITS_ALL.map((v) => [v, v * REM_UNIT]).map(([k, v]) => [
644
- `${sign}${klass}r-${k}`,
645
- `${prop}-right: ${sign}${v}rem`,
646
- ]),
647
- // PX units top.
642
+ ...UNITS_ALL.map((v) => [`${sign}${klass}t-${v}`, `${prop}-top: ${sign}${v * REM_UNIT}rem`]),
643
+ ...UNITS_ALL.map((v) => [`${sign}${klass}b-${v}`, `${prop}-bottom: ${sign}${v * REM_UNIT}rem`]),
644
+ ...UNITS_ALL.map((v) => [`${sign}${klass}l-${v}`, `${prop}-left: ${sign}${v * REM_UNIT}rem`]),
645
+ ...UNITS_ALL.map((v) => [`${sign}${klass}r-${v}`, `${prop}-right: ${sign}${v * REM_UNIT}rem`]),
648
646
  ...UNITS_ALL.map((v) => [`${sign}${klass}t-${v}px`, `${prop}-top: ${sign}${v}px`]),
649
- // PX units bottom.
650
647
  ...UNITS_ALL.map((v) => [`${sign}${klass}b-${v}px`, `${prop}-bottom: ${sign}${v}px`]),
651
- // PX units left.
652
648
  ...UNITS_ALL.map((v) => [`${sign}${klass}l-${v}px`, `${prop}-left: ${sign}${v}px`]),
653
- // PX units right.
654
649
  ...UNITS_ALL.map((v) => [`${sign}${klass}r-${v}px`, `${prop}-right: ${sign}${v}px`]),
655
- // Percent units top.
656
650
  ...PERCENTS.map((v) => [`${sign}${klass}t-${v}\\%`, `${prop}-top: ${sign}${v}%`]),
657
- // Percent units bottom.
658
- ...PERCENTS.map((v) => [`${sign}${klass}b-${v}\\%`, `${prop}-bottom: ${sign}${v}%;`]),
659
- // Percent units left.
651
+ ...PERCENTS.map((v) => [`${sign}${klass}b-${v}\\%`, `${prop}-bottom: ${sign}${v}%`]),
660
652
  ...PERCENTS.map((v) => [`${sign}${klass}l-${v}\\%`, `${prop}-left: ${sign}${v}%`]),
661
- // Percent units right.
662
653
  ...PERCENTS.map((v) => [`${sign}${klass}r-${v}\\%`, `${prop}-right: ${sign}${v}%`]),
663
654
  ]),
664
- ])
665
- .flatMap(([klass, rule]) => [
666
- `.${klass} { ${rule} }`,
667
- `${wrapPseudoStates(klass).join(",")} { ${rule} }`,
668
- ...wrapMediaQueries(klass, rule),
669
- ]);
655
+ ]));
670
656
  }
671
657
  function border() {
672
- return [
673
- // Single pixel border.
658
+ return wrapAll([
674
659
  [`border`, `border: 1px`],
675
- // Single pixel border x and y.
676
660
  [`border-x`, `border-inline-width: 1px`],
677
661
  [`border-y`, `border-block-width: 1px`],
678
- // Pixel units for border width.
679
662
  ...[0, ...UNITS_SM].map((v) => [`border-${v}`, `border-width: ${v}px`]),
680
- // Pixel units for border x and y.
681
663
  ...[0, ...UNITS_SM].map((v) => [`border-x-${v}`, `border-inline-width: ${v}px;`]),
682
664
  ...[0, ...UNITS_SM].map((v) => [`border-y-${v}`, `border-block-width: ${v}px;`]),
683
- // TBLR border.
684
665
  ...["top", "bottom", "left", "right"].flatMap((dir) => [
685
- // Single pixel border.
686
666
  [`border-${dir.slice(0, 1)}`, `border-${dir}: 1px`],
687
- // Pixel units for border width.
688
- ...[0, ...UNITS_SM].map((v) => [
689
- `border-${dir.slice(0, 1)}-${v}`,
690
- `border-${dir}-width: ${v}px`,
691
- ]),
667
+ ...[0, ...UNITS_SM].map((v) => [`border-${dir.slice(0, 1)}-${v}`, `border-${dir}-width: ${v}px`]),
692
668
  ]),
693
- ].flatMap(([klass, rule]) => [
694
- `.${klass} { ${rule} }`,
695
- `${wrapPseudoStates(klass).join(",")} { ${rule} }`,
696
- ...wrapMediaQueries(klass, rule),
697
669
  ]);
698
670
  }
699
671
  function zIndex() {
700
- return [
701
- // Percent units reused as values for z-index.
702
- ...PERCENTS.map((v) => [`z-${v}`, `z-index: ${v}`]),
703
- ].flatMap(([klass, rule]) => [
704
- `.${klass} { ${rule} }`,
705
- `${wrapPseudoStates(klass).join(",")} { ${rule} }`,
706
- ...wrapMediaQueries(klass, rule),
707
- ]);
672
+ return wrapAll(PERCENTS.map((v) => [`z-${v}`, `z-index: ${v}`]));
708
673
  }
709
674
  function transitions() {
710
- return [
711
- // Positive milliseconds for transition.
712
- ...DURATIONS.map((v) => [`duration-${v}`, `transition-duration: ${v}ms`]),
713
- ].flatMap(([klass, rule]) => [
714
- `.${klass} { ${rule} }`,
715
- `${wrapPseudoStates(klass).join(",")} { ${rule} }`,
716
- ...wrapMediaQueries(klass, rule),
717
- ]);
675
+ return wrapAll(DURATIONS.map((v) => [`duration-${v}`, `transition-duration: ${v}ms`]));
718
676
  }
719
677
  function between() {
720
- return [
721
- // Zero for x margin.
678
+ return wrapAll([
722
679
  [`space-x-0 > *`, `margin-left: 0`],
723
- // Zero for y margin.
724
680
  [`space-y-0 > *`, `margin-top: 0`],
725
- // Positive REM units for x margin.
726
- ...UNITS_ALL.map((v) => [
727
- `space-x-${v} > :not(:first-child)`,
728
- `margin-left: ${v * REM_UNIT}rem`,
729
- ]),
730
- // Positive REM units for y margin.
731
- ...UNITS_ALL.map((v) => [
732
- `space-y-${v} > :not(:first-child)`,
733
- `margin-top: ${v * REM_UNIT}rem`,
734
- ]),
735
- // Positive PX units for x margin.
681
+ ...UNITS_ALL.map((v) => [`space-x-${v} > :not(:first-child)`, `margin-left: ${v * REM_UNIT}rem`]),
682
+ ...UNITS_ALL.map((v) => [`space-y-${v} > :not(:first-child)`, `margin-top: ${v * REM_UNIT}rem`]),
736
683
  ...UNITS_ALL.map((v) => [`space-x-${v}px > :not(:first-child)`, `margin-left: ${v}px`]),
737
- // Positive PX units for y margin.
738
684
  ...UNITS_ALL.map((v) => [`space-y-${v}px > :not(:first-child)`, `margin-top: ${v}px`]),
739
- // Zero for gap.
740
685
  [`gap-0`, `gap: 0`],
741
- // Positive REM units for gap.
742
686
  ...UNITS_ALL.map((v) => [`gap-${v}`, `gap: ${v * REM_UNIT}rem`]),
743
- // Positive PX units for gap.
744
687
  ...UNITS_ALL.map((v) => [`gap-${v}px`, `gap: ${v}px`]),
745
- // Positive REM units for col gap.
746
688
  ...UNITS_ALL.map((v) => [`gap-x-${v}`, `column-gap: ${v * REM_UNIT}rem`]),
747
- // Positive REM units for row gap.
748
689
  ...UNITS_ALL.map((v) => [`gap-y-${v}`, `row-gap: ${v * REM_UNIT}rem`]),
749
- // Positive PX units for col gap.
750
690
  ...UNITS_ALL.map((v) => [`gap-x-${v}px`, `column-gap: ${v}px`]),
751
- // Positive PX units for row gap.
752
691
  ...UNITS_ALL.map((v) => [`gap-y-${v}px`, `row-gap: ${v}px`]),
753
- ].flatMap(([klass, rule]) => [
754
- `.${klass} { ${rule} }`,
755
- `${wrapPseudoStates(klass).join(",")} { ${rule} }`,
756
- ...wrapMediaQueries(klass, rule),
757
692
  ]);
758
693
  }
759
694
  function textSizes() {
760
- return [
761
- // 100 font sizes in single pixel increments.
762
- ...Array.from({ length: 100 }, (_, i) => i).map((v) => [`text-${v}px`, `font-size: ${v}px`]),
763
- // 100 font sizes in REM_UNIT (0.25) increments.
764
- ...Array.from({ length: 100 }, (_, i) => i * REM_UNIT).map((v) => [
765
- `text-${v}rem`,
766
- `font-size: ${v}rem`,
767
- ]),
768
- ].flatMap(([klass, rule]) => [
769
- `.${klass} { ${rule} }`,
770
- `${wrapPseudoStates(klass).join(",")} { ${rule} }`,
771
- ...wrapMediaQueries(klass, rule),
695
+ return wrapAll([
696
+ ...Array.from({ length: 100 }, (_, i) => [`text-${i}px`, `font-size: ${i}px`]),
697
+ ...Array.from({ length: 100 }, (_, i) => [`text-${i * REM_UNIT}rem`, `font-size: ${i * REM_UNIT}rem`]),
772
698
  ]);
773
699
  }
774
700
  function custom() {
775
- return Object.entries(PROPS_CUSTOM).flatMap(([klass, props]) => Object.entries(props).flatMap(([propkey, propval]) => [
776
- `.${klass} { ${propkey}: ${propval} }`,
777
- `${wrapPseudoStates(klass).join(",")} { ${propkey}: ${propval} }`,
778
- ...wrapMediaQueries(klass, `${propkey}: ${propval}`),
779
- ]));
701
+ return Object.entries(PROPS_CUSTOM).flatMap(([klass, props]) => {
702
+ const rules = Object.entries(props).map(([k, v]) => `${k}: ${v}`).join("; ");
703
+ return [
704
+ `.${klass} { ${rules} }`,
705
+ `${wrapPseudoStates(klass).join(",")} { ${rules} }`,
706
+ ...wrapMediaQueries(klass, rules),
707
+ ];
708
+ });
780
709
  }
781
710
  function colors() {
782
- const bw = [
783
- ["white", "#fff"],
784
- ["black", "#000"],
785
- ["transparent", "transparent"],
786
- ].flatMap(([color, value]) => [
711
+ const colorVariants = (color, value) => [
787
712
  [`text-${color}`, `color: ${value}`],
788
713
  [`fill-${color}`, `fill: ${value}`],
789
714
  [`bg-${color}`, `background-color: ${value}`],
790
715
  [`border-${color}`, `border-color: ${value}`],
791
- ]);
792
- const mains = Object.entries(PROPS_COLORS).flatMap(([color, shades]) => [
793
- [`text-${color}`, `color: ${hexColor(shades[500])}`],
794
- [`fill-${color}`, `fill: ${hexColor(shades[500])}`],
795
- [`bg-${color}`, `background-color: ${hexColor(shades[500])}`],
796
- [`border-${color}`, `border-color: ${hexColor(shades[500])}`],
797
- ]);
798
- const shades = Object.entries(PROPS_COLORS).flatMap(([color, shades]) => Object.entries(shades).flatMap(([shade, hex]) => [
799
- [`text-${color}-${shade}`, `color: ${hexColor(hex)}`],
800
- [`fill-${color}-${shade}`, `fill: ${hexColor(hex)}`],
801
- [`bg-${color}-${shade}`, `background-color: ${hexColor(hex)}`],
802
- [`border-${color}-${shade}`, `border-color: ${hexColor(hex)}`],
803
- ]));
804
- return []
805
- .concat(bw)
806
- .concat(mains)
807
- .concat(shades)
808
- .flatMap(([klass, rule]) => [
809
- `.${klass} { ${rule} }`,
810
- `${wrapPseudoStates(klass).join(",")} { ${rule} }`,
811
- ...wrapMediaQueries(klass, rule),
716
+ ];
717
+ return wrapAll([
718
+ ...colorVariants("white", "#fff"),
719
+ ...colorVariants("black", "#000"),
720
+ ...colorVariants("transparent", "transparent"),
721
+ ...Object.entries(PROPS_COLORS).flatMap(([color, shades]) => [
722
+ ...colorVariants(color, shades[500]),
723
+ ...Object.entries(shades).flatMap(([shade, hex]) => colorVariants(`${color}-${shade}`, hex)),
724
+ ]),
812
725
  ]);
813
726
  }
814
727
  function opacity() {
815
- return [
816
- // Zero for opacity.
728
+ return wrapAll([
817
729
  [`opacity-0`, `opacity: 0`],
818
- // Positive percent units for opacity.
819
730
  ...PERCENTS.map((v) => [`opacity-${v}`, `opacity: ${v / 100}`]),
820
- ].flatMap(([klass, rule]) => [
821
- `.${klass} { ${rule} }`,
822
- `${wrapPseudoStates(klass).join(",")} { ${rule} }`,
823
- ...wrapMediaQueries(klass, rule),
824
731
  ]);
825
732
  }
733
+ let cachedRules = null;
826
734
  export default function rules() {
827
- return ([
735
+ if (cachedRules !== null)
736
+ return cachedRules;
737
+ cachedRules = [
828
738
  // As-is.
829
739
  ...PROPS_AS_IS,
830
740
  // Custom.
@@ -856,6 +766,7 @@ export default function rules() {
856
766
  ]
857
767
  // Sort lexicographical to ensure media queries appear after their base rules.
858
768
  .sort(ruleSorter)
859
- .join("\n"));
769
+ .join("\n");
770
+ return cachedRules;
860
771
  }
861
772
  //# sourceMappingURL=css_gen_utils.js.map