@decantr/css 1.0.4 → 1.0.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.
- package/dist/index.js +501 -7
- package/package.json +4 -1
package/dist/index.js
CHANGED
|
@@ -440,6 +440,498 @@ var GRID_SPAN = {
|
|
|
440
440
|
rowspan6: "grid-row:span 6/span 6",
|
|
441
441
|
rowspanfull: "grid-row:1/-1"
|
|
442
442
|
};
|
|
443
|
+
var TAILWIND_DIRECT = {
|
|
444
|
+
relative: "position:relative",
|
|
445
|
+
absolute: "position:absolute",
|
|
446
|
+
"gap-auto": "gap:var(--d-gap,1rem)",
|
|
447
|
+
"inline-flex": "display:inline-flex",
|
|
448
|
+
"inline-grid": "display:inline-grid",
|
|
449
|
+
center: "align-items:center;justify-content:center",
|
|
450
|
+
"align-center": "align-items:center",
|
|
451
|
+
"align-start": "align-items:flex-start",
|
|
452
|
+
"flex-col": "flex-direction:column",
|
|
453
|
+
"flex-row": "flex-direction:row",
|
|
454
|
+
"col-reverse": "flex-direction:column-reverse",
|
|
455
|
+
"flex-col-reverse": "flex-direction:column-reverse",
|
|
456
|
+
"flex-row-reverse": "flex-direction:row-reverse",
|
|
457
|
+
"flex-wrap": "flex-wrap:wrap",
|
|
458
|
+
flexwrap: "flex-wrap:wrap",
|
|
459
|
+
"flex-nowrap": "flex-wrap:nowrap",
|
|
460
|
+
"flex-wrap-nowrap": "flex-wrap:nowrap",
|
|
461
|
+
"flex-1": "flex:1",
|
|
462
|
+
"flex-auto": "flex:auto",
|
|
463
|
+
"flex-none": "flex:none",
|
|
464
|
+
"grow-0": "flex-grow:0",
|
|
465
|
+
"shrink-0": "flex-shrink:0",
|
|
466
|
+
"items-center": "align-items:center",
|
|
467
|
+
"items-start": "align-items:flex-start",
|
|
468
|
+
"items-end": "align-items:flex-end",
|
|
469
|
+
"items-stretch": "align-items:stretch",
|
|
470
|
+
"items-baseline": "align-items:baseline",
|
|
471
|
+
"justify-center": "justify-content:center",
|
|
472
|
+
"justify-start": "justify-content:flex-start",
|
|
473
|
+
"justify-end": "justify-content:flex-end",
|
|
474
|
+
"justify-between": "justify-content:space-between",
|
|
475
|
+
"justify-around": "justify-content:space-around",
|
|
476
|
+
"justify-evenly": "justify-content:space-evenly",
|
|
477
|
+
"place-items-center": "place-items:center",
|
|
478
|
+
"place-content-center": "place-content:center",
|
|
479
|
+
"self-center": "align-self:center",
|
|
480
|
+
"self-start": "align-self:flex-start",
|
|
481
|
+
"self-end": "align-self:flex-end",
|
|
482
|
+
"overflow-hidden": "overflow:hidden",
|
|
483
|
+
"overflow-auto": "overflow:auto",
|
|
484
|
+
"overflow-visible": "overflow:visible",
|
|
485
|
+
overflowhidden: "overflow:hidden",
|
|
486
|
+
"overflow-x-hidden": "overflow-x:hidden",
|
|
487
|
+
"overflow-x-auto": "overflow-x:auto",
|
|
488
|
+
"overflow-y-hidden": "overflow-y:hidden",
|
|
489
|
+
"overflow-y-auto": "overflow-y:auto",
|
|
490
|
+
"scrollbar-thin": "scrollbar-width:thin",
|
|
491
|
+
"pointer-events-none": "pointer-events:none",
|
|
492
|
+
"pointer-events-auto": "pointer-events:auto",
|
|
493
|
+
"pointer-events-restricted": "pointer-events:none",
|
|
494
|
+
"cursor-pointer": "cursor:pointer",
|
|
495
|
+
"cursor-grab": "cursor:grab",
|
|
496
|
+
"select-none": "user-select:none",
|
|
497
|
+
"whitespace-nowrap": "white-space:nowrap",
|
|
498
|
+
"whitespace-pre": "white-space:pre",
|
|
499
|
+
"whitespace-pre-wrap": "white-space:pre-wrap",
|
|
500
|
+
"break-words": "overflow-wrap:break-word",
|
|
501
|
+
"break-all": "word-break:break-all",
|
|
502
|
+
"sr-only": "position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0",
|
|
503
|
+
"not-sr-only": "position:static;width:auto;height:auto;padding:0;margin:0;overflow:visible;clip:auto;white-space:normal",
|
|
504
|
+
"object-cover": "object-fit:cover",
|
|
505
|
+
"object-contain": "object-fit:contain",
|
|
506
|
+
"object-center": "object-position:center",
|
|
507
|
+
"list-none": "list-style:none",
|
|
508
|
+
mono: "font-family:var(--d-font-mono,ui-monospace,monospace)",
|
|
509
|
+
"aspect-video": "aspect-ratio:16/9",
|
|
510
|
+
"aspect-square": "aspect-ratio:1/1",
|
|
511
|
+
full: "width:100%;height:100%",
|
|
512
|
+
"w-full": "width:100%",
|
|
513
|
+
"h-full": "height:100%",
|
|
514
|
+
"w-screen": "width:100vw",
|
|
515
|
+
"h-screen": "height:100vh",
|
|
516
|
+
"w-auto": "width:auto",
|
|
517
|
+
"h-auto": "height:auto",
|
|
518
|
+
"w-fit": "width:fit-content",
|
|
519
|
+
"h-fit": "height:fit-content",
|
|
520
|
+
"min-w-0": "min-width:0",
|
|
521
|
+
"min-h-0": "min-height:0",
|
|
522
|
+
"min-h-screen": "min-height:100vh",
|
|
523
|
+
"min-h-dvh": "min-height:100dvh",
|
|
524
|
+
"max-w-full": "max-width:100%",
|
|
525
|
+
"max-w-none": "max-width:none",
|
|
526
|
+
"mx-auto": "margin-inline:auto",
|
|
527
|
+
"my-auto": "margin-block:auto",
|
|
528
|
+
"mt-auto": "margin-top:auto",
|
|
529
|
+
"mb-auto": "margin-bottom:auto",
|
|
530
|
+
"ml-auto": "margin-left:auto",
|
|
531
|
+
"mr-auto": "margin-right:auto",
|
|
532
|
+
"inset-0": "inset:0",
|
|
533
|
+
"inset-x-0": "left:0;right:0",
|
|
534
|
+
"inset-y-0": "top:0;bottom:0",
|
|
535
|
+
"top-0": "top:0",
|
|
536
|
+
"right-0": "right:0",
|
|
537
|
+
"bottom-0": "bottom:0",
|
|
538
|
+
"left-0": "left:0",
|
|
539
|
+
"left-1/2": "left:50%",
|
|
540
|
+
"top-1/2": "top:50%",
|
|
541
|
+
"-translate-x-1/2": "translate:-50% 0",
|
|
542
|
+
"-translate-y-1/2": "translate:0 -50%",
|
|
543
|
+
jcs: "justify-content:flex-start",
|
|
544
|
+
jce: "justify-content:flex-end",
|
|
545
|
+
"border": "border:1px solid var(--d-border)",
|
|
546
|
+
"border-t": "border-top:1px solid var(--d-border)",
|
|
547
|
+
"border-r": "border-right:1px solid var(--d-border)",
|
|
548
|
+
"border-b": "border-bottom:1px solid var(--d-border)",
|
|
549
|
+
"border-l": "border-left:1px solid var(--d-border)",
|
|
550
|
+
"border-0": "border:0",
|
|
551
|
+
border2: "border:2px solid var(--d-border)",
|
|
552
|
+
"border-dashed": "border-style:dashed",
|
|
553
|
+
borderb: "border-bottom:1px solid var(--d-border)",
|
|
554
|
+
borderB: "border-bottom:1px solid var(--d-border)",
|
|
555
|
+
borderT: "border-top:1px solid var(--d-border)",
|
|
556
|
+
borderR: "border-right:1px solid var(--d-border)",
|
|
557
|
+
borderL: "border-left:1px solid var(--d-border)",
|
|
558
|
+
bbsolid: "border-bottom:1px solid var(--d-border)",
|
|
559
|
+
rfull: "border-radius:9999px",
|
|
560
|
+
"rounded-full": "border-radius:9999px",
|
|
561
|
+
"rounded-none": "border-radius:0",
|
|
562
|
+
"rounded-sm": "border-radius:0.25rem",
|
|
563
|
+
"rounded-md": "border-radius:0.375rem",
|
|
564
|
+
"rounded-lg": "border-radius:0.5rem",
|
|
565
|
+
"rounded-xl": "border-radius:0.75rem",
|
|
566
|
+
"rounded-2xl": "border-radius:1rem",
|
|
567
|
+
"rounded-3xl": "border-radius:1.5rem",
|
|
568
|
+
"shadow-sm": "box-shadow:0 1px 2px rgba(0,0,0,0.05)",
|
|
569
|
+
"shadow-md": "box-shadow:0 4px 6px rgba(0,0,0,0.1)",
|
|
570
|
+
"shadow-lg": "box-shadow:0 10px 15px rgba(0,0,0,0.1)",
|
|
571
|
+
"shadow-xl": "box-shadow:0 20px 25px rgba(0,0,0,0.1)",
|
|
572
|
+
"shadow-none": "box-shadow:none",
|
|
573
|
+
"backdrop-blur": "backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px)",
|
|
574
|
+
"backdrop-blur-sm": "backdrop-filter:blur(4px);-webkit-backdrop-filter:blur(4px)",
|
|
575
|
+
"backdrop-blur-md": "backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px)",
|
|
576
|
+
"backdrop-blur-lg": "backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px)",
|
|
577
|
+
"transition": "transition:all 0.15s ease",
|
|
578
|
+
"transition-all": "transition:all 0.15s ease",
|
|
579
|
+
"transition-colors": "transition:color,background-color,border-color 0.15s ease",
|
|
580
|
+
"scroll-smooth": "scroll-behavior:smooth",
|
|
581
|
+
"duration-150": "transition-duration:150ms",
|
|
582
|
+
"duration-200": "transition-duration:200ms",
|
|
583
|
+
"duration-300": "transition-duration:300ms",
|
|
584
|
+
"ease-out": "transition-timing-function:cubic-bezier(0,0,0.2,1)",
|
|
585
|
+
"ease-in-out": "transition-timing-function:cubic-bezier(0.4,0,0.2,1)",
|
|
586
|
+
tc: "text-align:center",
|
|
587
|
+
textCenter: "text-align:center",
|
|
588
|
+
fggreen: "color:#22c55e",
|
|
589
|
+
compact: "gap:0.5rem",
|
|
590
|
+
"auto-rows-fr": "grid-auto-rows:minmax(0,1fr)"
|
|
591
|
+
};
|
|
592
|
+
var TAILWIND_MAX_WIDTH = {
|
|
593
|
+
xs: "20rem",
|
|
594
|
+
sm: "24rem",
|
|
595
|
+
md: "28rem",
|
|
596
|
+
lg: "32rem",
|
|
597
|
+
xl: "36rem",
|
|
598
|
+
"2xl": "42rem",
|
|
599
|
+
"3xl": "48rem",
|
|
600
|
+
"4xl": "56rem",
|
|
601
|
+
"5xl": "64rem",
|
|
602
|
+
"6xl": "72rem",
|
|
603
|
+
"7xl": "80rem",
|
|
604
|
+
full: "100%",
|
|
605
|
+
none: "none",
|
|
606
|
+
"screen-sm": "640px",
|
|
607
|
+
"screen-md": "768px",
|
|
608
|
+
"screen-lg": "1024px",
|
|
609
|
+
"screen-xl": "1280px",
|
|
610
|
+
"screen-2xl": "1536px"
|
|
611
|
+
};
|
|
612
|
+
var TAILWIND_ARBITRARY_PROPS = {
|
|
613
|
+
w: "width",
|
|
614
|
+
h: "height",
|
|
615
|
+
mw: "max-width",
|
|
616
|
+
mh: "max-height",
|
|
617
|
+
maxw: "max-width",
|
|
618
|
+
maxh: "max-height",
|
|
619
|
+
minw: "min-width",
|
|
620
|
+
minh: "min-height",
|
|
621
|
+
"min-w": "min-width",
|
|
622
|
+
"min-h": "min-height",
|
|
623
|
+
"max-w": "max-width",
|
|
624
|
+
"max-h": "max-height",
|
|
625
|
+
p: "padding",
|
|
626
|
+
px: "padding-inline",
|
|
627
|
+
py: "padding-block",
|
|
628
|
+
pt: "padding-top",
|
|
629
|
+
pr: "padding-right",
|
|
630
|
+
pb: "padding-bottom",
|
|
631
|
+
pl: "padding-left",
|
|
632
|
+
m: "margin",
|
|
633
|
+
mx: "margin-inline",
|
|
634
|
+
my: "margin-block",
|
|
635
|
+
mt: "margin-top",
|
|
636
|
+
mr: "margin-right",
|
|
637
|
+
mb: "margin-bottom",
|
|
638
|
+
ml: "margin-left",
|
|
639
|
+
gap: "gap",
|
|
640
|
+
"gap-x": "column-gap",
|
|
641
|
+
"gap-y": "row-gap",
|
|
642
|
+
"grid-cols": "grid-template-columns",
|
|
643
|
+
"grid-rows": "grid-template-rows",
|
|
644
|
+
gc: "grid-template-columns",
|
|
645
|
+
gr: "grid-template-rows",
|
|
646
|
+
"border": "border",
|
|
647
|
+
bb: "border-bottom",
|
|
648
|
+
bt: "border-top",
|
|
649
|
+
"rounded": "border-radius",
|
|
650
|
+
"text": "text-align",
|
|
651
|
+
"bg": "background",
|
|
652
|
+
"z": "z-index",
|
|
653
|
+
"top": "top",
|
|
654
|
+
"right": "right",
|
|
655
|
+
"bottom": "bottom",
|
|
656
|
+
"left": "left",
|
|
657
|
+
"inset": "inset",
|
|
658
|
+
"aspect": "aspect-ratio"
|
|
659
|
+
};
|
|
660
|
+
var TAILWIND_SPACING_PROPS = {
|
|
661
|
+
p: "padding",
|
|
662
|
+
px: "padding-inline",
|
|
663
|
+
py: "padding-block",
|
|
664
|
+
pt: "padding-top",
|
|
665
|
+
pr: "padding-right",
|
|
666
|
+
pb: "padding-bottom",
|
|
667
|
+
pl: "padding-left",
|
|
668
|
+
m: "margin",
|
|
669
|
+
mx: "margin-inline",
|
|
670
|
+
my: "margin-block",
|
|
671
|
+
mt: "margin-top",
|
|
672
|
+
mr: "margin-right",
|
|
673
|
+
mb: "margin-bottom",
|
|
674
|
+
ml: "margin-left",
|
|
675
|
+
gap: "gap",
|
|
676
|
+
"gap-x": "column-gap",
|
|
677
|
+
"gap-y": "row-gap",
|
|
678
|
+
top: "top",
|
|
679
|
+
right: "right",
|
|
680
|
+
bottom: "bottom",
|
|
681
|
+
left: "left",
|
|
682
|
+
inset: "inset"
|
|
683
|
+
};
|
|
684
|
+
var FONT_WEIGHTS = {
|
|
685
|
+
light: "300",
|
|
686
|
+
normal: "400",
|
|
687
|
+
medium: "500",
|
|
688
|
+
semibold: "600",
|
|
689
|
+
bold: "700",
|
|
690
|
+
extrabold: "800"
|
|
691
|
+
};
|
|
692
|
+
var LINE_HEIGHTS = {
|
|
693
|
+
none: "1",
|
|
694
|
+
tight: "1.25",
|
|
695
|
+
snug: "1.375",
|
|
696
|
+
normal: "1.5",
|
|
697
|
+
relaxed: "1.625",
|
|
698
|
+
loose: "2"
|
|
699
|
+
};
|
|
700
|
+
var LETTER_SPACING = {
|
|
701
|
+
tight: "-0.025em",
|
|
702
|
+
normal: "0",
|
|
703
|
+
wide: "0.025em",
|
|
704
|
+
wider: "0.05em",
|
|
705
|
+
widest: "0.1em"
|
|
706
|
+
};
|
|
707
|
+
function spacingValue(token) {
|
|
708
|
+
if (token === "px") return "1px";
|
|
709
|
+
const n = Number(token);
|
|
710
|
+
if (!Number.isFinite(n)) return null;
|
|
711
|
+
return SPACING_SCALE[n] ?? null;
|
|
712
|
+
}
|
|
713
|
+
function fractionValue(token) {
|
|
714
|
+
const match = token.match(/^(\d+)\/(\d+)$/);
|
|
715
|
+
if (!match) return null;
|
|
716
|
+
const numerator = Number(match[1]);
|
|
717
|
+
const denominator = Number(match[2]);
|
|
718
|
+
if (!denominator) return null;
|
|
719
|
+
return `${numerator / denominator * 100}%`;
|
|
720
|
+
}
|
|
721
|
+
function dimensionValue(prop, token) {
|
|
722
|
+
if (token === "full") return "100%";
|
|
723
|
+
if (token === "auto") return "auto";
|
|
724
|
+
if (token === "fit") return "fit-content";
|
|
725
|
+
if (token === "min") return "min-content";
|
|
726
|
+
if (token === "max") return "max-content";
|
|
727
|
+
if (token === "screen") return prop.includes("h") ? "100vh" : "100vw";
|
|
728
|
+
if (token === "dvh" && prop.includes("h")) return "100dvh";
|
|
729
|
+
if (prop === "max-w" && TAILWIND_MAX_WIDTH[token]) return TAILWIND_MAX_WIDTH[token];
|
|
730
|
+
const spacing = spacingValue(token);
|
|
731
|
+
if (spacing) return spacing;
|
|
732
|
+
const fraction = fractionValue(token);
|
|
733
|
+
if (fraction) return fraction;
|
|
734
|
+
if (/^\d+(?:\.\d+)?$/.test(token)) return `${token}px`;
|
|
735
|
+
return null;
|
|
736
|
+
}
|
|
737
|
+
function sanitizeTailwindValue(value) {
|
|
738
|
+
let safe = value.replace(/[{}<>;]/g, "");
|
|
739
|
+
safe = safe.replace(/url\s*\(/gi, "");
|
|
740
|
+
return safe.replace(/_/g, " ");
|
|
741
|
+
}
|
|
742
|
+
function semanticColorValue(token, prop) {
|
|
743
|
+
const key = token.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
744
|
+
if (key === "transparent") return "transparent";
|
|
745
|
+
if (key === "white") return "#fff";
|
|
746
|
+
if (key === "black") return "#000";
|
|
747
|
+
if (key === "background" || key === "bg" || key === "canvas") return "var(--d-bg)";
|
|
748
|
+
if (key === "surface" || key === "card") return "var(--d-surface)";
|
|
749
|
+
if (key === "surface-subtle" || key === "surface-muted") {
|
|
750
|
+
return "var(--d-surface-1,var(--d-surface))";
|
|
751
|
+
}
|
|
752
|
+
if (key === "surface-raised" || key === "raised" || key === "popover") {
|
|
753
|
+
return "var(--d-surface-raised)";
|
|
754
|
+
}
|
|
755
|
+
if (key === "primary") return "var(--d-primary)";
|
|
756
|
+
if (key === "secondary") return "var(--d-secondary)";
|
|
757
|
+
if (key === "accent") return "var(--d-accent)";
|
|
758
|
+
if (key === "success") return "var(--d-success,#22c55e)";
|
|
759
|
+
if (key === "warning") return "var(--d-warning,#f59e0b)";
|
|
760
|
+
if (key === "danger" || key === "error" || key === "destructive") return "var(--d-error,#ef4444)";
|
|
761
|
+
if (key === "info") return "var(--d-info,#3b82f6)";
|
|
762
|
+
if (key === "green") return "#22c55e";
|
|
763
|
+
if (key === "red") return "#ef4444";
|
|
764
|
+
if (key === "amber" || key === "yellow") return "#f59e0b";
|
|
765
|
+
if (key === "blue") return "#3b82f6";
|
|
766
|
+
if (key === "gray-950") return "#030712";
|
|
767
|
+
if (key === "gray" || key === "slate") return "#64748b";
|
|
768
|
+
if (key === "border" || key === "input") return "var(--d-border)";
|
|
769
|
+
if (key === "text" || key === "foreground" || key === "fg") return "var(--d-text)";
|
|
770
|
+
if (key === "muted") {
|
|
771
|
+
if (prop === "color") return "var(--d-text-muted,var(--d-muted))";
|
|
772
|
+
if (prop === "border-color") return "var(--d-muted,var(--d-border))";
|
|
773
|
+
return "var(--d-muted,var(--d-surface))";
|
|
774
|
+
}
|
|
775
|
+
return null;
|
|
776
|
+
}
|
|
777
|
+
function semanticColorDecl(prop, rawToken) {
|
|
778
|
+
const alphaMatch = rawToken.match(/^(.+)\/(\d+)$/);
|
|
779
|
+
const token = alphaMatch ? alphaMatch[1] : rawToken;
|
|
780
|
+
const value = semanticColorValue(token, prop);
|
|
781
|
+
if (!value) return null;
|
|
782
|
+
if (alphaMatch) {
|
|
783
|
+
const alpha = Number(alphaMatch[2]);
|
|
784
|
+
if (!Number.isFinite(alpha) || alpha < 0 || alpha > 100) return null;
|
|
785
|
+
return `${prop}:color-mix(in srgb,${value} ${alpha}%,transparent)`;
|
|
786
|
+
}
|
|
787
|
+
return `${prop}:${value}`;
|
|
788
|
+
}
|
|
789
|
+
function resolveTailwindishDecl(name) {
|
|
790
|
+
if (TAILWIND_DIRECT[name]) return TAILWIND_DIRECT[name];
|
|
791
|
+
const arbitraryMatch = name.match(/^([a-z]+(?:-[a-z]+)*)-\[([^\]]+)\]$/);
|
|
792
|
+
if (arbitraryMatch) {
|
|
793
|
+
const [, prefix, rawValue] = arbitraryMatch;
|
|
794
|
+
const prop = TAILWIND_ARBITRARY_PROPS[prefix];
|
|
795
|
+
if (!prop) return null;
|
|
796
|
+
const value = sanitizeTailwindValue(rawValue);
|
|
797
|
+
return value ? `${prop}:${value}` : null;
|
|
798
|
+
}
|
|
799
|
+
const compactArbitraryMatch = name.match(/^([a-z]+(?:-[a-z]+)?)\[([^\]]+)\]$/);
|
|
800
|
+
if (compactArbitraryMatch) {
|
|
801
|
+
const [, prefix, rawValue] = compactArbitraryMatch;
|
|
802
|
+
if (prefix === "scale") {
|
|
803
|
+
const value2 = sanitizeTailwindValue(rawValue);
|
|
804
|
+
return value2 ? `transform:scale(${value2})` : null;
|
|
805
|
+
}
|
|
806
|
+
const prop = TAILWIND_ARBITRARY_PROPS[prefix];
|
|
807
|
+
if (!prop) return null;
|
|
808
|
+
const value = sanitizeTailwindValue(rawValue);
|
|
809
|
+
return value ? `${prop}:${value}` : null;
|
|
810
|
+
}
|
|
811
|
+
const dimensionMatch = name.match(/^(w|h|min-w|min-h|max-w|max-h)-(.+)$/);
|
|
812
|
+
if (dimensionMatch) {
|
|
813
|
+
const [, prop, token] = dimensionMatch;
|
|
814
|
+
const cssProp = {
|
|
815
|
+
w: "width",
|
|
816
|
+
h: "height",
|
|
817
|
+
"min-w": "min-width",
|
|
818
|
+
"min-h": "min-height",
|
|
819
|
+
"max-w": "max-width",
|
|
820
|
+
"max-h": "max-height"
|
|
821
|
+
}[prop];
|
|
822
|
+
const value = dimensionValue(prop, token);
|
|
823
|
+
if (cssProp && value) return `${cssProp}:${value}`;
|
|
824
|
+
}
|
|
825
|
+
const spacingMatch = name.match(
|
|
826
|
+
/^(-?)(gap-x|gap-y|gap|px|py|pt|pr|pb|pl|p|mx|my|mt|mr|mb|ml|m|top|right|bottom|left|inset)-(\d+(?:\.\d+)?|px)$/
|
|
827
|
+
);
|
|
828
|
+
if (spacingMatch) {
|
|
829
|
+
const [, negative, prefix, token] = spacingMatch;
|
|
830
|
+
const prop = TAILWIND_SPACING_PROPS[prefix];
|
|
831
|
+
const value = spacingValue(token);
|
|
832
|
+
if (prop && value) {
|
|
833
|
+
const canBeNegative = prop.startsWith("margin") || ["top", "right", "bottom", "left"].includes(prop);
|
|
834
|
+
if (negative && !canBeNegative) return null;
|
|
835
|
+
return `${prop}:${negative ? "-" : ""}${value}`;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
const gridColsMatch = name.match(/^grid-cols-(\d+)$/);
|
|
839
|
+
if (gridColsMatch) {
|
|
840
|
+
return `grid-template-columns:repeat(${gridColsMatch[1]},minmax(0,1fr))`;
|
|
841
|
+
}
|
|
842
|
+
if (name === "grid-cols-auto-fill") {
|
|
843
|
+
return "grid-template-columns:repeat(auto-fill,minmax(16rem,1fr))";
|
|
844
|
+
}
|
|
845
|
+
if (name === "grid-cols-auto") {
|
|
846
|
+
return "grid-template-columns:repeat(auto-fit,minmax(0,1fr))";
|
|
847
|
+
}
|
|
848
|
+
const gridRowsMatch = name.match(/^grid-rows-(\d+)$/);
|
|
849
|
+
if (gridRowsMatch) {
|
|
850
|
+
return `grid-template-rows:repeat(${gridRowsMatch[1]},minmax(0,1fr))`;
|
|
851
|
+
}
|
|
852
|
+
const colSpanMatch = name.match(/^col-span-(\d+|full)$/);
|
|
853
|
+
if (colSpanMatch) {
|
|
854
|
+
const span = colSpanMatch[1];
|
|
855
|
+
return span === "full" ? "grid-column:1/-1" : `grid-column:span ${span}/span ${span}`;
|
|
856
|
+
}
|
|
857
|
+
const rowSpanMatch = name.match(/^row-span-(\d+|full)$/);
|
|
858
|
+
if (rowSpanMatch) {
|
|
859
|
+
const span = rowSpanMatch[1];
|
|
860
|
+
return span === "full" ? "grid-row:1/-1" : `grid-row:span ${span}/span ${span}`;
|
|
861
|
+
}
|
|
862
|
+
const columnsMatch = name.match(/^(?:cols|columns)(\d+)$/);
|
|
863
|
+
if (columnsMatch) return `columns:${columnsMatch[1]}`;
|
|
864
|
+
const textMatch = name.match(/^text-(.+)$/);
|
|
865
|
+
if (textMatch) {
|
|
866
|
+
const token = textMatch[1];
|
|
867
|
+
if (TEXT_SCALE[token]) return TEXT_SCALE[token];
|
|
868
|
+
return semanticColorDecl("color", token);
|
|
869
|
+
}
|
|
870
|
+
const bgMatch = name.match(/^bg-(.+)$/);
|
|
871
|
+
if (bgMatch) return semanticColorDecl("background", bgMatch[1]);
|
|
872
|
+
const borderColorMatch = name.match(/^border-(.+)$/);
|
|
873
|
+
if (borderColorMatch) {
|
|
874
|
+
const decl = semanticColorDecl("border-color", borderColorMatch[1]);
|
|
875
|
+
if (decl) return decl;
|
|
876
|
+
}
|
|
877
|
+
const compactBorderColorMatch = name.match(/^border([a-zA-Z0-9-]+\/?\d*)$/);
|
|
878
|
+
if (compactBorderColorMatch) {
|
|
879
|
+
const decl = semanticColorDecl("border-color", compactBorderColorMatch[1]);
|
|
880
|
+
if (decl) return decl;
|
|
881
|
+
}
|
|
882
|
+
const compactFgMatch = name.match(/^fg([a-zA-Z0-9-]+\/?\d*)$/);
|
|
883
|
+
if (compactFgMatch) return semanticColorDecl("color", compactFgMatch[1]);
|
|
884
|
+
const compactBgMatch = name.match(/^bg([a-zA-Z0-9-]+\/?\d*)$/);
|
|
885
|
+
if (compactBgMatch) return semanticColorDecl("background", compactBgMatch[1]);
|
|
886
|
+
const borderSideWidthMatch = name.match(/^border-([trbl])-(\d+)$/);
|
|
887
|
+
if (borderSideWidthMatch) {
|
|
888
|
+
const side = { t: "top", r: "right", b: "bottom", l: "left" }[borderSideWidthMatch[1]];
|
|
889
|
+
return `border-${side}:${borderSideWidthMatch[2]}px solid var(--d-border)`;
|
|
890
|
+
}
|
|
891
|
+
const roundedSideMatch = name.match(/^rounded-([rltb])-(sm|md|lg|xl|2xl|3xl|full)$/);
|
|
892
|
+
if (roundedSideMatch) {
|
|
893
|
+
const [, side, size] = roundedSideMatch;
|
|
894
|
+
const value = {
|
|
895
|
+
sm: "0.25rem",
|
|
896
|
+
md: "0.375rem",
|
|
897
|
+
lg: "0.5rem",
|
|
898
|
+
xl: "0.75rem",
|
|
899
|
+
"2xl": "1rem",
|
|
900
|
+
"3xl": "1.5rem",
|
|
901
|
+
full: "9999px"
|
|
902
|
+
}[size];
|
|
903
|
+
if (!value) return null;
|
|
904
|
+
if (side === "r") return `border-top-right-radius:${value};border-bottom-right-radius:${value}`;
|
|
905
|
+
if (side === "l") return `border-top-left-radius:${value};border-bottom-left-radius:${value}`;
|
|
906
|
+
if (side === "t") return `border-top-left-radius:${value};border-top-right-radius:${value}`;
|
|
907
|
+
if (side === "b") return `border-bottom-left-radius:${value};border-bottom-right-radius:${value}`;
|
|
908
|
+
}
|
|
909
|
+
const fontMatch = name.match(/^font-(.+)$/);
|
|
910
|
+
if (fontMatch && FONT_WEIGHTS[fontMatch[1]]) return `font-weight:${FONT_WEIGHTS[fontMatch[1]]}`;
|
|
911
|
+
const leadingMatch = name.match(/^leading-(.+)$/);
|
|
912
|
+
if (leadingMatch && LINE_HEIGHTS[leadingMatch[1]]) return `line-height:${LINE_HEIGHTS[leadingMatch[1]]}`;
|
|
913
|
+
const trackingMatch = name.match(/^tracking-(.+)$/);
|
|
914
|
+
if (trackingMatch && LETTER_SPACING[trackingMatch[1]]) {
|
|
915
|
+
return `letter-spacing:${LETTER_SPACING[trackingMatch[1]]}`;
|
|
916
|
+
}
|
|
917
|
+
const opacityMatch = name.match(/^opacity-(\d+)$/);
|
|
918
|
+
if (opacityMatch) {
|
|
919
|
+
const n = Number(opacityMatch[1]);
|
|
920
|
+
if (n >= 0 && n <= 100) return `opacity:${n / 100}`;
|
|
921
|
+
}
|
|
922
|
+
const zMatch = name.match(/^z-(\d+|auto)$/);
|
|
923
|
+
if (zMatch) return zMatch[1] === "auto" ? "z-index:auto" : `z-index:${zMatch[1]}`;
|
|
924
|
+
const compactZMatch = name.match(/^z(\d+)$/);
|
|
925
|
+
if (compactZMatch) return `z-index:${compactZMatch[1]}`;
|
|
926
|
+
const perspectiveMatch = name.match(/^perspective-(\d+)$/);
|
|
927
|
+
if (perspectiveMatch) return `perspective:${perspectiveMatch[1]}px`;
|
|
928
|
+
const negativeSpaceXMatch = name.match(/^-space-x-(\d+(?:\.\d+)?)$/);
|
|
929
|
+
if (negativeSpaceXMatch) {
|
|
930
|
+
const value = spacingValue(negativeSpaceXMatch[1]);
|
|
931
|
+
if (value) return `margin-left:-${value}`;
|
|
932
|
+
}
|
|
933
|
+
return null;
|
|
934
|
+
}
|
|
443
935
|
function resolveAtomDecl(atom) {
|
|
444
936
|
const name = atom.startsWith("_") ? atom.slice(1) : atom;
|
|
445
937
|
if (DIRECT[name]) return DIRECT[name];
|
|
@@ -447,6 +939,8 @@ function resolveAtomDecl(atom) {
|
|
|
447
939
|
if (GRID_COLS[name]) return GRID_COLS[name];
|
|
448
940
|
if (GRID_ROWS[name]) return GRID_ROWS[name];
|
|
449
941
|
if (GRID_SPAN[name]) return GRID_SPAN[name];
|
|
942
|
+
const tailwindish = resolveTailwindishDecl(name);
|
|
943
|
+
if (tailwindish) return tailwindish;
|
|
450
944
|
if (name.startsWith("text")) {
|
|
451
945
|
const size = name.slice(4);
|
|
452
946
|
if (TEXT_SCALE[size]) return TEXT_SCALE[size];
|
|
@@ -729,7 +1223,7 @@ function injectResponsive(className, declaration, bp) {
|
|
|
729
1223
|
if (injected.has(className)) return;
|
|
730
1224
|
injected.add(className);
|
|
731
1225
|
if (typeof document === "undefined") return;
|
|
732
|
-
const escaped = className
|
|
1226
|
+
const escaped = escapeSelector(className);
|
|
733
1227
|
if (!bpBuffers[bp]) bpBuffers[bp] = [];
|
|
734
1228
|
bpBuffers[bp].push(
|
|
735
1229
|
`@layer d.atoms{@media(min-width:${BREAKPOINTS[bp]}px){.${escaped}{${declaration}}}}`
|
|
@@ -740,7 +1234,7 @@ function injectResponsiveMax(className, declaration, bp) {
|
|
|
740
1234
|
if (injected.has(className)) return;
|
|
741
1235
|
injected.add(className);
|
|
742
1236
|
if (typeof document === "undefined") return;
|
|
743
|
-
const escaped = className
|
|
1237
|
+
const escaped = escapeSelector(className);
|
|
744
1238
|
const key = `${bp}max`;
|
|
745
1239
|
if (!bpBuffers[key]) bpBuffers[key] = [];
|
|
746
1240
|
const maxPx = BREAKPOINTS[bp] - 0.02;
|
|
@@ -791,7 +1285,7 @@ function injectContainer(className, declaration, width) {
|
|
|
791
1285
|
if (injected.has(className)) return;
|
|
792
1286
|
injected.add(className);
|
|
793
1287
|
if (typeof document === "undefined") return;
|
|
794
|
-
const escaped = className
|
|
1288
|
+
const escaped = escapeSelector(className);
|
|
795
1289
|
cqBuffer.push(`@layer d.atoms{@container(min-width:${width}px){.${escaped}{${declaration}}}}`);
|
|
796
1290
|
scheduleFlush();
|
|
797
1291
|
}
|
|
@@ -817,12 +1311,12 @@ function injectMediaQuery(className, declaration, query) {
|
|
|
817
1311
|
if (injected.has(className)) return;
|
|
818
1312
|
injected.add(className);
|
|
819
1313
|
if (typeof document === "undefined") return;
|
|
820
|
-
const escaped = className
|
|
1314
|
+
const escaped = escapeSelector(className);
|
|
821
1315
|
atomBuffer.push(`@layer d.atoms{@media${query}{.${escaped}{${declaration}}}}`);
|
|
822
1316
|
scheduleFlush();
|
|
823
1317
|
}
|
|
824
1318
|
function escapeSelector(className) {
|
|
825
|
-
return className.replace(/:/g, "\\:").replace(/\//g, "\\/").replace(/\[/g, "\\[").replace(/\]/g, "\\]").replace(/#/g, "\\#").replace(/%/g, "\\%").replace(/\(/g, "\\(").replace(/\)/g, "\\)").replace(/,/g, "\\,").replace(/\+/g, "\\+");
|
|
1319
|
+
return className.replace(/:/g, "\\:").replace(/\./g, "\\.").replace(/\//g, "\\/").replace(/\[/g, "\\[").replace(/\]/g, "\\]").replace(/#/g, "\\#").replace(/%/g, "\\%").replace(/\(/g, "\\(").replace(/\)/g, "\\)").replace(/,/g, "\\,").replace(/\+/g, "\\+");
|
|
826
1320
|
}
|
|
827
1321
|
function extractCSS() {
|
|
828
1322
|
flushBuffers();
|
|
@@ -1006,7 +1500,7 @@ function resolveAtom(atomPart) {
|
|
|
1006
1500
|
return null;
|
|
1007
1501
|
}
|
|
1008
1502
|
function escapeClass(cls) {
|
|
1009
|
-
return cls.replace(/:/g, "\\:").replace(/\//g, "\\/").replace(/\[/g, "\\[").replace(/\]/g, "\\]").replace(/#/g, "\\#").replace(/%/g, "\\%").replace(/\(/g, "\\(").replace(/\)/g, "\\)").replace(/,/g, "\\,").replace(/\+/g, "\\+");
|
|
1503
|
+
return cls.replace(/:/g, "\\:").replace(/\./g, "\\.").replace(/\//g, "\\/").replace(/\[/g, "\\[").replace(/\]/g, "\\]").replace(/#/g, "\\#").replace(/%/g, "\\%").replace(/\(/g, "\\(").replace(/\)/g, "\\)").replace(/,/g, "\\,").replace(/\+/g, "\\+");
|
|
1010
1504
|
}
|
|
1011
1505
|
function css(...classes) {
|
|
1012
1506
|
const result = [];
|
|
@@ -1121,7 +1615,7 @@ function css(...classes) {
|
|
|
1121
1615
|
}
|
|
1122
1616
|
const resolved = resolveAtom(part);
|
|
1123
1617
|
if (resolved) {
|
|
1124
|
-
const needsEscape = /[
|
|
1618
|
+
const needsEscape = /[./[\]#%(),+]/.test(resolved.className);
|
|
1125
1619
|
inject(
|
|
1126
1620
|
resolved.className,
|
|
1127
1621
|
resolved.decl,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decantr/css",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Framework-agnostic CSS atom runtime for Decantr projects",
|
|
5
5
|
"author": "Decantr AI",
|
|
6
6
|
"bugs": {
|
|
@@ -24,6 +24,9 @@
|
|
|
24
24
|
"files": [
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=20"
|
|
29
|
+
},
|
|
27
30
|
"publishConfig": {
|
|
28
31
|
"access": "public"
|
|
29
32
|
},
|