@csszyx/compiler 0.1.3 → 0.3.0
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/README.md +2 -2
- package/dist/index.cjs +175 -27
- package/dist/index.d.cts +62 -2
- package/dist/index.d.ts +62 -2
- package/dist/index.js +175 -27
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @csszyx/compiler
|
|
2
2
|
|
|
3
|
-
TypeScript compiler package for
|
|
3
|
+
TypeScript compiler package for CSSzyx - handles JSX transformation, recovery token generation, and manifest creation.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
@@ -83,7 +83,7 @@ const manifest = builder.build();
|
|
|
83
83
|
|
|
84
84
|
#### `transform(szProp: SzObject, prefix?: string): string`
|
|
85
85
|
|
|
86
|
-
Transforms a
|
|
86
|
+
Transforms a CSSzyx sz object into a Tailwind CSS className string.
|
|
87
87
|
|
|
88
88
|
#### `isValidSzProp(szProp: unknown): boolean`
|
|
89
89
|
|
package/dist/index.cjs
CHANGED
|
@@ -83,6 +83,8 @@ var PROPERTY_CATEGORY_MAP = {
|
|
|
83
83
|
py: 0 /* SPACING */,
|
|
84
84
|
ps: 0 /* SPACING */,
|
|
85
85
|
pe: 0 /* SPACING */,
|
|
86
|
+
pbs: 0 /* SPACING */,
|
|
87
|
+
pbe: 0 /* SPACING */,
|
|
86
88
|
m: 0 /* SPACING */,
|
|
87
89
|
mt: 0 /* SPACING */,
|
|
88
90
|
mr: 0 /* SPACING */,
|
|
@@ -92,6 +94,8 @@ var PROPERTY_CATEGORY_MAP = {
|
|
|
92
94
|
my: 0 /* SPACING */,
|
|
93
95
|
ms: 0 /* SPACING */,
|
|
94
96
|
me: 0 /* SPACING */,
|
|
97
|
+
mbs: 0 /* SPACING */,
|
|
98
|
+
mbe: 0 /* SPACING */,
|
|
95
99
|
spaceX: 0 /* SPACING */,
|
|
96
100
|
spaceY: 0 /* SPACING */,
|
|
97
101
|
gap: 0 /* SPACING */,
|
|
@@ -106,6 +110,10 @@ var PROPERTY_CATEGORY_MAP = {
|
|
|
106
110
|
left: 0 /* SPACING */,
|
|
107
111
|
start: 0 /* SPACING */,
|
|
108
112
|
end: 0 /* SPACING */,
|
|
113
|
+
insetS: 0 /* SPACING */,
|
|
114
|
+
insetE: 0 /* SPACING */,
|
|
115
|
+
insetBs: 0 /* SPACING */,
|
|
116
|
+
insetBe: 0 /* SPACING */,
|
|
109
117
|
w: 0 /* SPACING */,
|
|
110
118
|
minW: 0 /* SPACING */,
|
|
111
119
|
maxW: 0 /* SPACING */,
|
|
@@ -113,6 +121,12 @@ var PROPERTY_CATEGORY_MAP = {
|
|
|
113
121
|
minH: 0 /* SPACING */,
|
|
114
122
|
maxH: 0 /* SPACING */,
|
|
115
123
|
size: 0 /* SPACING */,
|
|
124
|
+
blockSize: 0 /* SPACING */,
|
|
125
|
+
minBlockSize: 0 /* SPACING */,
|
|
126
|
+
maxBlockSize: 0 /* SPACING */,
|
|
127
|
+
inlineSize: 0 /* SPACING */,
|
|
128
|
+
minInlineSize: 0 /* SPACING */,
|
|
129
|
+
maxInlineSize: 0 /* SPACING */,
|
|
116
130
|
basis: 0 /* SPACING */,
|
|
117
131
|
indent: 0 /* SPACING */,
|
|
118
132
|
scrollM: 0 /* SPACING */,
|
|
@@ -133,6 +147,10 @@ var PROPERTY_CATEGORY_MAP = {
|
|
|
133
147
|
scrollPe: 0 /* SPACING */,
|
|
134
148
|
scrollPx: 0 /* SPACING */,
|
|
135
149
|
scrollPy: 0 /* SPACING */,
|
|
150
|
+
scrollPbs: 0 /* SPACING */,
|
|
151
|
+
scrollPbe: 0 /* SPACING */,
|
|
152
|
+
scrollMbs: 0 /* SPACING */,
|
|
153
|
+
scrollMbe: 0 /* SPACING */,
|
|
136
154
|
translateX: 0 /* SPACING */,
|
|
137
155
|
translateY: 0 /* SPACING */,
|
|
138
156
|
borderSpacing: 0 /* SPACING */,
|
|
@@ -200,6 +218,8 @@ var PROPERTY_CATEGORY_MAP = {
|
|
|
200
218
|
borderY: 3 /* UNITLESS */,
|
|
201
219
|
borderS: 3 /* UNITLESS */,
|
|
202
220
|
borderE: 3 /* UNITLESS */,
|
|
221
|
+
borderBs: 3 /* UNITLESS */,
|
|
222
|
+
borderBe: 3 /* UNITLESS */,
|
|
203
223
|
ring: 3 /* UNITLESS */,
|
|
204
224
|
outline: 3 /* UNITLESS */,
|
|
205
225
|
leading: 3 /* UNITLESS */,
|
|
@@ -344,6 +364,8 @@ var PROPERTY_MAP = {
|
|
|
344
364
|
borderY: "border-y",
|
|
345
365
|
borderS: "border-s",
|
|
346
366
|
borderE: "border-e",
|
|
367
|
+
borderBs: "border-bs",
|
|
368
|
+
borderBe: "border-be",
|
|
347
369
|
// Divide
|
|
348
370
|
divideX: "divide-x",
|
|
349
371
|
divideY: "divide-y",
|
|
@@ -369,6 +391,8 @@ var PROPERTY_MAP = {
|
|
|
369
391
|
py: "py",
|
|
370
392
|
ps: "ps",
|
|
371
393
|
pe: "pe",
|
|
394
|
+
pbs: "pbs",
|
|
395
|
+
pbe: "pbe",
|
|
372
396
|
m: "m",
|
|
373
397
|
mt: "mt",
|
|
374
398
|
mr: "mr",
|
|
@@ -378,6 +402,8 @@ var PROPERTY_MAP = {
|
|
|
378
402
|
my: "my",
|
|
379
403
|
ms: "ms",
|
|
380
404
|
me: "me",
|
|
405
|
+
mbs: "mbs",
|
|
406
|
+
mbe: "mbe",
|
|
381
407
|
// Space between
|
|
382
408
|
spaceX: "space-x",
|
|
383
409
|
spaceY: "space-y",
|
|
@@ -389,6 +415,12 @@ var PROPERTY_MAP = {
|
|
|
389
415
|
minH: "min-h",
|
|
390
416
|
maxH: "max-h",
|
|
391
417
|
size: "size",
|
|
418
|
+
blockSize: "block",
|
|
419
|
+
minBlockSize: "min-block",
|
|
420
|
+
maxBlockSize: "max-block",
|
|
421
|
+
inlineSize: "inline",
|
|
422
|
+
minInlineSize: "min-inline",
|
|
423
|
+
maxInlineSize: "max-inline",
|
|
392
424
|
// Layout
|
|
393
425
|
aspect: "aspect",
|
|
394
426
|
columns: "columns",
|
|
@@ -418,14 +450,20 @@ var PROPERTY_MAP = {
|
|
|
418
450
|
right: "right",
|
|
419
451
|
bottom: "bottom",
|
|
420
452
|
left: "left",
|
|
421
|
-
|
|
422
|
-
|
|
453
|
+
// TW v4.2: start/end now emit inset-s-*/inset-e-* (same CSS, deprecated old class names)
|
|
454
|
+
start: "inset-s",
|
|
455
|
+
end: "inset-e",
|
|
456
|
+
insetS: "inset-s",
|
|
457
|
+
insetE: "inset-e",
|
|
458
|
+
insetBs: "inset-bs",
|
|
459
|
+
insetBe: "inset-be",
|
|
423
460
|
// Visibility
|
|
424
461
|
visibility: "visibility",
|
|
425
462
|
// Typography
|
|
426
463
|
color: "text",
|
|
427
464
|
text: "text",
|
|
428
465
|
fontWeight: "font",
|
|
466
|
+
weight: "font",
|
|
429
467
|
fontFamily: "font",
|
|
430
468
|
fontStretch: "font-stretch",
|
|
431
469
|
textAlign: "text",
|
|
@@ -447,6 +485,7 @@ var PROPERTY_MAP = {
|
|
|
447
485
|
leading: "leading",
|
|
448
486
|
tracking: "tracking",
|
|
449
487
|
lineClamp: "line-clamp",
|
|
488
|
+
fontFeatures: "font-features",
|
|
450
489
|
list: "list",
|
|
451
490
|
listPos: "list",
|
|
452
491
|
listImg: "list-image",
|
|
@@ -516,9 +555,14 @@ var PROPERTY_MAP = {
|
|
|
516
555
|
scale: "scale",
|
|
517
556
|
scaleX: "scale-x",
|
|
518
557
|
scaleY: "scale-y",
|
|
558
|
+
scaleZ: "scale-z",
|
|
519
559
|
rotate: "rotate",
|
|
560
|
+
rotateX: "rotate-x",
|
|
561
|
+
rotateY: "rotate-y",
|
|
562
|
+
rotateZ: "rotate-z",
|
|
520
563
|
translateX: "translate-x",
|
|
521
564
|
translateY: "translate-y",
|
|
565
|
+
translateZ: "translate-z",
|
|
522
566
|
skewX: "skew-x",
|
|
523
567
|
skewY: "skew-y",
|
|
524
568
|
origin: "origin",
|
|
@@ -526,6 +570,7 @@ var PROPERTY_MAP = {
|
|
|
526
570
|
perspective: "perspective",
|
|
527
571
|
perspectiveOrigin: "perspective-origin",
|
|
528
572
|
transformStyle: "transform",
|
|
573
|
+
transform: "transform",
|
|
529
574
|
// Transitions & Animation
|
|
530
575
|
transition: "transition",
|
|
531
576
|
transitionBehavior: "transition",
|
|
@@ -543,6 +588,8 @@ var PROPERTY_MAP = {
|
|
|
543
588
|
cursor: "cursor",
|
|
544
589
|
caret: "caret",
|
|
545
590
|
pointerEvents: "pointer-events",
|
|
591
|
+
fieldSizing: "field-sizing",
|
|
592
|
+
scheme: "scheme",
|
|
546
593
|
resize: "resize",
|
|
547
594
|
scroll: "scroll",
|
|
548
595
|
scrollM: "scroll-m",
|
|
@@ -563,6 +610,10 @@ var PROPERTY_MAP = {
|
|
|
563
610
|
scrollPe: "scroll-pe",
|
|
564
611
|
scrollPx: "scroll-px",
|
|
565
612
|
scrollPy: "scroll-py",
|
|
613
|
+
scrollPbs: "scroll-pbs",
|
|
614
|
+
scrollPbe: "scroll-pbe",
|
|
615
|
+
scrollMbs: "scroll-mbs",
|
|
616
|
+
scrollMbe: "scroll-mbe",
|
|
566
617
|
snapAlign: "snap",
|
|
567
618
|
snapStop: "snap",
|
|
568
619
|
snapType: "snap",
|
|
@@ -912,6 +963,7 @@ var BOOLEAN_SHORTHANDS = /* @__PURE__ */ new Set([
|
|
|
912
963
|
// Misc
|
|
913
964
|
"container",
|
|
914
965
|
"prose",
|
|
966
|
+
"proseInvert",
|
|
915
967
|
"srOnly",
|
|
916
968
|
"notSrOnly",
|
|
917
969
|
"isolate",
|
|
@@ -938,8 +990,7 @@ var BOOLEAN_SHORTHANDS = /* @__PURE__ */ new Set([
|
|
|
938
990
|
"rotate3d",
|
|
939
991
|
"translate3d",
|
|
940
992
|
"transformGpu",
|
|
941
|
-
"transformCpu"
|
|
942
|
-
"transformNone"
|
|
993
|
+
"transformCpu"
|
|
943
994
|
]);
|
|
944
995
|
var BOOLEAN_TO_CLASS = {
|
|
945
996
|
inlineBlock: "inline-block",
|
|
@@ -977,7 +1028,8 @@ var BOOLEAN_TO_CLASS = {
|
|
|
977
1028
|
translate3d: "translate-3d",
|
|
978
1029
|
transformGpu: "transform-gpu",
|
|
979
1030
|
transformCpu: "transform-cpu",
|
|
980
|
-
|
|
1031
|
+
// Misc
|
|
1032
|
+
proseInvert: "prose-invert"
|
|
981
1033
|
};
|
|
982
1034
|
var SNAP_DIRECT_MAP = {
|
|
983
1035
|
snapAlign: {
|
|
@@ -1011,6 +1063,8 @@ var NEGATIVE_ALLOWED = /* @__PURE__ */ new Set([
|
|
|
1011
1063
|
"my",
|
|
1012
1064
|
"ms",
|
|
1013
1065
|
"me",
|
|
1066
|
+
"mbs",
|
|
1067
|
+
"mbe",
|
|
1014
1068
|
"top",
|
|
1015
1069
|
"right",
|
|
1016
1070
|
"bottom",
|
|
@@ -1018,8 +1072,11 @@ var NEGATIVE_ALLOWED = /* @__PURE__ */ new Set([
|
|
|
1018
1072
|
"inset",
|
|
1019
1073
|
"inset-x",
|
|
1020
1074
|
"inset-y",
|
|
1021
|
-
|
|
1022
|
-
"
|
|
1075
|
+
// TW v4.2: start/end now map to inset-s/inset-e
|
|
1076
|
+
"inset-s",
|
|
1077
|
+
"inset-e",
|
|
1078
|
+
"inset-bs",
|
|
1079
|
+
"inset-be",
|
|
1023
1080
|
"z",
|
|
1024
1081
|
"order",
|
|
1025
1082
|
"col",
|
|
@@ -1029,10 +1086,16 @@ var NEGATIVE_ALLOWED = /* @__PURE__ */ new Set([
|
|
|
1029
1086
|
"row-start",
|
|
1030
1087
|
"row-end",
|
|
1031
1088
|
"rotate",
|
|
1089
|
+
"rotate-x",
|
|
1090
|
+
"rotate-y",
|
|
1091
|
+
"rotate-z",
|
|
1092
|
+
"scale-z",
|
|
1032
1093
|
"skew-x",
|
|
1033
1094
|
"skew-y",
|
|
1034
1095
|
"translate-x",
|
|
1035
1096
|
"translate-y",
|
|
1097
|
+
"translate-z",
|
|
1098
|
+
"mask",
|
|
1036
1099
|
"space-x",
|
|
1037
1100
|
"space-y",
|
|
1038
1101
|
"tracking",
|
|
@@ -1072,7 +1135,7 @@ function normalizeArbitraryVariant(key) {
|
|
|
1072
1135
|
return key.replace(/\s+/g, "");
|
|
1073
1136
|
}
|
|
1074
1137
|
function normalizeArbitraryValue(value) {
|
|
1075
|
-
return value.trim().replace(/\s
|
|
1138
|
+
return value.trim().replace(/\s+/g, "_");
|
|
1076
1139
|
}
|
|
1077
1140
|
var FRACTION_SUPPORTED_PROPS = /* @__PURE__ */ new Set([
|
|
1078
1141
|
// Sizing (both rawKey and resolved key forms)
|
|
@@ -1113,11 +1176,15 @@ var FRACTION_SUPPORTED_PROPS = /* @__PURE__ */ new Set([
|
|
|
1113
1176
|
"translate-x",
|
|
1114
1177
|
"translateX",
|
|
1115
1178
|
"translate-y",
|
|
1116
|
-
"translateY"
|
|
1179
|
+
"translateY",
|
|
1180
|
+
// Aspect
|
|
1181
|
+
"aspect"
|
|
1117
1182
|
]);
|
|
1118
1183
|
function needsArbitraryBrackets(value) {
|
|
1119
|
-
return /^\d+(\.\d+)?(px|rem|em|%|vh|vw|ch|dvh|dvw|svh|svw|lvh|lvw|cqw|cqh|deg|rad|turn|grad|ms|s|fr)$/.test(value) || //
|
|
1184
|
+
return /^\d+(\.\d+)?(px|rem|em|%|vh|vw|ch|dvh|dvw|svh|svw|lvh|lvw|cqw|cqh|deg|rad|turn|grad|ms|s|fr)$/.test(value) || // Positive units
|
|
1185
|
+
/^-\d+(\.\d+)?(px|rem|em|%|vh|vw|ch|dvh|dvw|svh|svw|lvh|lvw|cqw|cqh|deg|rad|turn|grad|ms|s|fr)$/.test(value) || // Negative units like -1px, -2rem
|
|
1120
1186
|
/^\.\d+(px|rem|em|%|vh|vw|ch)?$/.test(value) || // Values starting with . like .25em
|
|
1187
|
+
/^-\.\d+(px|rem|em|%|vh|vw|ch)?$/.test(value) || // Negative values starting with -. like -.25em
|
|
1121
1188
|
value.startsWith("#") || // Hex colors
|
|
1122
1189
|
value.startsWith("rgb") || // RGB colors
|
|
1123
1190
|
value.startsWith("hsl") || // HSL colors
|
|
@@ -1569,12 +1636,13 @@ function transform(szProp, prefix = "", mangleMap) {
|
|
|
1569
1636
|
}
|
|
1570
1637
|
let className = prefix;
|
|
1571
1638
|
if (rawKey === "willChange" && typeof value === "string") {
|
|
1572
|
-
|
|
1573
|
-
|
|
1639
|
+
const WILL_CHANGE_KEYWORDS = /* @__PURE__ */ new Set(["auto", "scroll", "contents", "transform"]);
|
|
1640
|
+
if (WILL_CHANGE_KEYWORDS.has(value)) {
|
|
1641
|
+
classes.push(`${prefix}will-change-${value}`);
|
|
1574
1642
|
} else if (value.startsWith("--")) {
|
|
1575
1643
|
classes.push(`${prefix}will-change-(${value})`);
|
|
1576
1644
|
} else {
|
|
1577
|
-
classes.push(`${prefix}will-change
|
|
1645
|
+
classes.push(`${prefix}will-change-[${normalizeArbitraryValue(value)}]`);
|
|
1578
1646
|
}
|
|
1579
1647
|
continue;
|
|
1580
1648
|
}
|
|
@@ -1688,10 +1756,10 @@ function transform(szProp, prefix = "", mangleMap) {
|
|
|
1688
1756
|
continue;
|
|
1689
1757
|
}
|
|
1690
1758
|
if (rawKey === "textOverflow") {
|
|
1691
|
-
if (value === "ellipsis") {
|
|
1692
|
-
classes.push(`${prefix}truncate`);
|
|
1693
|
-
} else {
|
|
1759
|
+
if (value === "ellipsis" || value === "clip") {
|
|
1694
1760
|
classes.push(`${prefix}text-${value}`);
|
|
1761
|
+
} else {
|
|
1762
|
+
classes.push(`${prefix}text-[${value}]`);
|
|
1695
1763
|
}
|
|
1696
1764
|
continue;
|
|
1697
1765
|
}
|
|
@@ -1759,8 +1827,13 @@ function transform(szProp, prefix = "", mangleMap) {
|
|
|
1759
1827
|
className += `font-${sValue}`;
|
|
1760
1828
|
} else if (sValue.startsWith("--")) {
|
|
1761
1829
|
className += `font-stretch-(${sValue})`;
|
|
1762
|
-
} else if (/^\d
|
|
1763
|
-
|
|
1830
|
+
} else if (/^\d+(\.\d+)?%$/.test(sValue)) {
|
|
1831
|
+
const valNum = parseFloat(sValue);
|
|
1832
|
+
if (sValue.includes(".") || !Number.isInteger(valNum)) {
|
|
1833
|
+
className += `font-stretch-[${sValue}]`;
|
|
1834
|
+
} else {
|
|
1835
|
+
className += `font-stretch-${sValue}`;
|
|
1836
|
+
}
|
|
1764
1837
|
} else {
|
|
1765
1838
|
className += `font-stretch-[${sValue}]`;
|
|
1766
1839
|
}
|
|
@@ -1881,6 +1954,17 @@ function transform(szProp, prefix = "", mangleMap) {
|
|
|
1881
1954
|
classes.push(className);
|
|
1882
1955
|
continue;
|
|
1883
1956
|
}
|
|
1957
|
+
if (rawKey === "bgRepeat" || rawKey === "backgroundRepeat") {
|
|
1958
|
+
if (value === "repeat") {
|
|
1959
|
+
className += "bg-repeat";
|
|
1960
|
+
} else if (value === "no-repeat") {
|
|
1961
|
+
className += "bg-no-repeat";
|
|
1962
|
+
} else {
|
|
1963
|
+
className += `bg-repeat-${value}`;
|
|
1964
|
+
}
|
|
1965
|
+
classes.push(className);
|
|
1966
|
+
continue;
|
|
1967
|
+
}
|
|
1884
1968
|
if (rawKey === "maskSize") {
|
|
1885
1969
|
className += `mask-${value}`;
|
|
1886
1970
|
classes.push(className);
|
|
@@ -1906,8 +1990,11 @@ function transform(szProp, prefix = "", mangleMap) {
|
|
|
1906
1990
|
classes.push(className);
|
|
1907
1991
|
continue;
|
|
1908
1992
|
}
|
|
1909
|
-
if (rawKey === "content") {
|
|
1910
|
-
|
|
1993
|
+
if (rawKey === "content" || rawKey === "alignContent") {
|
|
1994
|
+
const ALIGN_CONTENT_KEYWORDS = /* @__PURE__ */ new Set(["normal", "center", "start", "end", "between", "around", "evenly", "baseline", "stretch"]);
|
|
1995
|
+
if (ALIGN_CONTENT_KEYWORDS.has(value)) {
|
|
1996
|
+
className += `content-${value}`;
|
|
1997
|
+
} else if (value.startsWith("--")) {
|
|
1911
1998
|
className += `content-(${value})`;
|
|
1912
1999
|
} else if (!["none", "empty"].includes(value)) {
|
|
1913
2000
|
className += `content-[${value}]`;
|
|
@@ -2057,7 +2144,6 @@ function transform(szProp, prefix = "", mangleMap) {
|
|
|
2057
2144
|
classes.push(className);
|
|
2058
2145
|
continue;
|
|
2059
2146
|
}
|
|
2060
|
-
const isAspectRatio = key === "aspect" && /^\d+\/\d+$/.test(finalValue);
|
|
2061
2147
|
if (finalValue.startsWith("--")) {
|
|
2062
2148
|
const typeHint = CSS_VAR_TYPE_HINTS[rawKey];
|
|
2063
2149
|
if (typeHint) {
|
|
@@ -2071,10 +2157,19 @@ function transform(szProp, prefix = "", mangleMap) {
|
|
|
2071
2157
|
if (!FRACTION_SUPPORTED_PROPS.has(rawKey)) {
|
|
2072
2158
|
finalValue = `[${finalValue}]`;
|
|
2073
2159
|
}
|
|
2074
|
-
} else if (
|
|
2160
|
+
} else if (key === "aspect" && /^[0-9]+(?:\.[0-9]+)?\/[0-9]+(?:\.[0-9]+)?$/.test(finalValue)) {
|
|
2161
|
+
if (finalValue === "auto" || finalValue === "square" || finalValue === "video" || /^\d+\/\d+$/.test(finalValue)) {
|
|
2162
|
+
} else {
|
|
2163
|
+
finalValue = `[${finalValue}]`;
|
|
2164
|
+
}
|
|
2165
|
+
} else if (needsArbitraryBrackets(finalValue) || /^\d+\.\d+%$/.test(finalValue)) {
|
|
2075
2166
|
finalValue = `[${normalizeArbitraryValue(finalValue)}]`;
|
|
2076
2167
|
}
|
|
2077
|
-
|
|
2168
|
+
if (finalValue.startsWith("-") && NEGATIVE_ALLOWED.has(key)) {
|
|
2169
|
+
className = `-${prefix}${key}-${finalValue.substring(1)}`;
|
|
2170
|
+
} else {
|
|
2171
|
+
className += `${key}-${finalValue}`;
|
|
2172
|
+
}
|
|
2078
2173
|
if (important) {
|
|
2079
2174
|
className += "!";
|
|
2080
2175
|
}
|
|
@@ -2135,8 +2230,9 @@ function transformSourceCode(source) {
|
|
|
2135
2230
|
let usesRuntime = false;
|
|
2136
2231
|
let usesColorVar = false;
|
|
2137
2232
|
let transformed = false;
|
|
2233
|
+
const collectedClasses = /* @__PURE__ */ new Set();
|
|
2138
2234
|
if (!source.includes("sz")) {
|
|
2139
|
-
return { code: source, transformed: false, usesRuntime: false, usesColorVar: false };
|
|
2235
|
+
return { code: source, transformed: false, usesRuntime: false, usesColorVar: false, classes: collectedClasses };
|
|
2140
2236
|
}
|
|
2141
2237
|
try {
|
|
2142
2238
|
const result = babel.transformSync(source, {
|
|
@@ -2154,12 +2250,29 @@ function transformSourceCode(source) {
|
|
|
2154
2250
|
return {
|
|
2155
2251
|
visitor: {
|
|
2156
2252
|
JSXAttribute(path) {
|
|
2157
|
-
|
|
2253
|
+
const attrName = t.isJSXIdentifier(path.node.name) ? path.node.name.name : "";
|
|
2254
|
+
if (attrName === "className" || attrName === "class") {
|
|
2255
|
+
const val = path.node.value;
|
|
2256
|
+
if (t.isStringLiteral(val)) {
|
|
2257
|
+
for (const c of val.value.split(/\s+/)) {
|
|
2258
|
+
if (c) {
|
|
2259
|
+
collectedClasses.add(c);
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
2263
|
+
return;
|
|
2264
|
+
}
|
|
2265
|
+
if (attrName !== "sz") {
|
|
2158
2266
|
return;
|
|
2159
2267
|
}
|
|
2160
2268
|
const value = path.node.value;
|
|
2161
2269
|
if (t.isStringLiteral(value)) {
|
|
2162
2270
|
path.node.name.name = "className";
|
|
2271
|
+
for (const c of value.value.split(/\s+/)) {
|
|
2272
|
+
if (c) {
|
|
2273
|
+
collectedClasses.add(c);
|
|
2274
|
+
}
|
|
2275
|
+
}
|
|
2163
2276
|
transformed = true;
|
|
2164
2277
|
return;
|
|
2165
2278
|
}
|
|
@@ -2169,6 +2282,11 @@ function transformSourceCode(source) {
|
|
|
2169
2282
|
const staticObject = evaluateStaticObject(expression);
|
|
2170
2283
|
if (staticObject !== null) {
|
|
2171
2284
|
const { className, attributes } = transform(staticObject);
|
|
2285
|
+
for (const c of className.split(/\s+/)) {
|
|
2286
|
+
if (c) {
|
|
2287
|
+
collectedClasses.add(c);
|
|
2288
|
+
}
|
|
2289
|
+
}
|
|
2172
2290
|
path.node.name.name = "className";
|
|
2173
2291
|
path.node.value = t.stringLiteral(className);
|
|
2174
2292
|
Object.entries(attributes).forEach(([key, val]) => {
|
|
@@ -2207,6 +2325,11 @@ function transformSourceCode(source) {
|
|
|
2207
2325
|
);
|
|
2208
2326
|
}
|
|
2209
2327
|
const allClasses = [...staticClasses, ...partial.rawClasses, ...cssVarClasses].join(" ");
|
|
2328
|
+
for (const c of allClasses.split(/\s+/)) {
|
|
2329
|
+
if (c) {
|
|
2330
|
+
collectedClasses.add(c);
|
|
2331
|
+
}
|
|
2332
|
+
}
|
|
2210
2333
|
path.node.name.name = "className";
|
|
2211
2334
|
path.node.value = t.stringLiteral(allClasses);
|
|
2212
2335
|
if (styleProps.length > 0 && path.parentPath?.isJSXOpeningElement()) {
|
|
@@ -2235,8 +2358,14 @@ function transformSourceCode(source) {
|
|
|
2235
2358
|
path.node.name.name = "className";
|
|
2236
2359
|
if (t.isStringLiteral(resolved)) {
|
|
2237
2360
|
path.node.value = resolved;
|
|
2361
|
+
for (const c of resolved.value.split(/\s+/)) {
|
|
2362
|
+
if (c) {
|
|
2363
|
+
collectedClasses.add(c);
|
|
2364
|
+
}
|
|
2365
|
+
}
|
|
2238
2366
|
} else {
|
|
2239
2367
|
value.expression = resolved;
|
|
2368
|
+
collectFromExpr(resolved, collectedClasses);
|
|
2240
2369
|
}
|
|
2241
2370
|
transformed = true;
|
|
2242
2371
|
return;
|
|
@@ -2250,8 +2379,14 @@ function transformSourceCode(source) {
|
|
|
2250
2379
|
path.node.name.name = "className";
|
|
2251
2380
|
if (t.isStringLiteral(resolved)) {
|
|
2252
2381
|
path.node.value = resolved;
|
|
2382
|
+
for (const c of resolved.value.split(/\s+/)) {
|
|
2383
|
+
if (c) {
|
|
2384
|
+
collectedClasses.add(c);
|
|
2385
|
+
}
|
|
2386
|
+
}
|
|
2253
2387
|
} else {
|
|
2254
2388
|
value.expression = resolved;
|
|
2389
|
+
collectFromExpr(resolved, collectedClasses);
|
|
2255
2390
|
}
|
|
2256
2391
|
transformed = true;
|
|
2257
2392
|
return;
|
|
@@ -2276,11 +2411,12 @@ function transformSourceCode(source) {
|
|
|
2276
2411
|
code: result?.code || source,
|
|
2277
2412
|
transformed,
|
|
2278
2413
|
usesRuntime,
|
|
2279
|
-
usesColorVar
|
|
2414
|
+
usesColorVar,
|
|
2415
|
+
classes: collectedClasses
|
|
2280
2416
|
};
|
|
2281
2417
|
} catch (e) {
|
|
2282
2418
|
console.warn("[csszyx] AST transform failed, falling back to original code:", e);
|
|
2283
|
-
return { code: source, transformed: false, usesRuntime: false, usesColorVar: false };
|
|
2419
|
+
return { code: source, transformed: false, usesRuntime: false, usesColorVar: false, classes: collectedClasses };
|
|
2284
2420
|
}
|
|
2285
2421
|
}
|
|
2286
2422
|
function tryStaticTransformNode(node) {
|
|
@@ -2519,6 +2655,18 @@ function generateStyleValueExpression(info) {
|
|
|
2519
2655
|
);
|
|
2520
2656
|
}
|
|
2521
2657
|
}
|
|
2658
|
+
function collectFromExpr(node, classes) {
|
|
2659
|
+
if (t.isStringLiteral(node)) {
|
|
2660
|
+
for (const c of node.value.split(/\s+/)) {
|
|
2661
|
+
if (c) {
|
|
2662
|
+
classes.add(c);
|
|
2663
|
+
}
|
|
2664
|
+
}
|
|
2665
|
+
} else if (t.isConditionalExpression(node)) {
|
|
2666
|
+
collectFromExpr(node.consequent, classes);
|
|
2667
|
+
collectFromExpr(node.alternate, classes);
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
2522
2670
|
function buildCSSVarClassName(info) {
|
|
2523
2671
|
const { twPrefix, varName, variantChain } = info;
|
|
2524
2672
|
const variantPrefix = variantChain ? `${getVariantPrefix(variantChain)}:` : "";
|
package/dist/index.d.cts
CHANGED
|
@@ -61,6 +61,7 @@ declare function transformSourceCode(source: string): {
|
|
|
61
61
|
transformed: boolean;
|
|
62
62
|
usesRuntime: boolean;
|
|
63
63
|
usesColorVar: boolean;
|
|
64
|
+
classes: Set<string>;
|
|
64
65
|
};
|
|
65
66
|
|
|
66
67
|
/**
|
|
@@ -530,7 +531,7 @@ type SpacingValue = SpacingScale | 'px' | 'auto' | (number & {}) | (string & {})
|
|
|
530
531
|
/** Negative spacing value */
|
|
531
532
|
type NegativeSpacingValue = SpacingValue | number;
|
|
532
533
|
/** Tailwind color names */
|
|
533
|
-
type ColorName = 'inherit' | 'current' | 'transparent' | 'black' | 'white' | 'slate' | 'gray' | 'zinc' | 'neutral' | 'stone' | 'red' | 'orange' | 'amber' | 'yellow' | 'lime' | 'green' | 'emerald' | 'teal' | 'cyan' | 'sky' | 'blue' | 'indigo' | 'violet' | 'purple' | 'fuchsia' | 'pink' | 'rose';
|
|
534
|
+
type ColorName = 'inherit' | 'current' | 'transparent' | 'black' | 'white' | 'slate' | 'gray' | 'zinc' | 'neutral' | 'stone' | 'red' | 'orange' | 'amber' | 'yellow' | 'lime' | 'green' | 'emerald' | 'teal' | 'cyan' | 'sky' | 'blue' | 'indigo' | 'violet' | 'purple' | 'fuchsia' | 'pink' | 'rose' | 'mauve' | 'olive' | 'mist' | 'taupe';
|
|
534
535
|
/** Tailwind color shades */
|
|
535
536
|
type ColorShade = 50 | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950;
|
|
536
537
|
/** Color value (string-based) */
|
|
@@ -606,6 +607,8 @@ interface LayoutProps {
|
|
|
606
607
|
container?: boolean;
|
|
607
608
|
/** Boolean sugar for prose */
|
|
608
609
|
prose?: boolean;
|
|
610
|
+
/** Boolean sugar for prose-invert (requires @tailwindcss/typography plugin) */
|
|
611
|
+
proseInvert?: boolean;
|
|
609
612
|
/** @see https://tailwindcss.com/docs/float */
|
|
610
613
|
float?: 'right' | 'left' | 'start' | 'end' | 'none';
|
|
611
614
|
/** @see https://tailwindcss.com/docs/clear */
|
|
@@ -642,6 +645,14 @@ interface LayoutProps {
|
|
|
642
645
|
left?: NegativeSpacingValue;
|
|
643
646
|
start?: SpacingValue;
|
|
644
647
|
end?: SpacingValue;
|
|
648
|
+
/** inset-inline-start (camelCase alias for start, emits inset-s-*) */
|
|
649
|
+
insetS?: SpacingValue;
|
|
650
|
+
/** inset-inline-end (camelCase alias for end, emits inset-e-*) */
|
|
651
|
+
insetE?: SpacingValue;
|
|
652
|
+
/** inset-block-start */
|
|
653
|
+
insetBs?: SpacingValue;
|
|
654
|
+
/** inset-block-end */
|
|
655
|
+
insetBe?: SpacingValue;
|
|
645
656
|
/** @see https://tailwindcss.com/docs/visibility */
|
|
646
657
|
visibility?: 'visible' | 'hidden' | 'collapse';
|
|
647
658
|
visible?: boolean;
|
|
@@ -729,6 +740,10 @@ interface SpacingProps {
|
|
|
729
740
|
ps?: SpacingValue;
|
|
730
741
|
/** Padding - inline end (logical) */
|
|
731
742
|
pe?: SpacingValue;
|
|
743
|
+
/** Padding - block-start (logical) */
|
|
744
|
+
pbs?: SpacingValue;
|
|
745
|
+
/** Padding - block-end (logical) */
|
|
746
|
+
pbe?: SpacingValue;
|
|
732
747
|
/** Margin - all sides */
|
|
733
748
|
m?: NegativeSpacingValue;
|
|
734
749
|
/** Margin - X axis (left/right) */
|
|
@@ -747,6 +762,10 @@ interface SpacingProps {
|
|
|
747
762
|
ms?: NegativeSpacingValue;
|
|
748
763
|
/** Margin - inline end (logical) */
|
|
749
764
|
me?: NegativeSpacingValue;
|
|
765
|
+
/** Margin - block-start (logical) */
|
|
766
|
+
mbs?: NegativeSpacingValue;
|
|
767
|
+
/** Margin - block-end (logical) */
|
|
768
|
+
mbe?: NegativeSpacingValue;
|
|
750
769
|
/** Space between child elements - X axis */
|
|
751
770
|
spaceX?: NegativeSpacingValue;
|
|
752
771
|
/** Space between child elements - Y axis */
|
|
@@ -774,6 +793,18 @@ interface SizingProps {
|
|
|
774
793
|
maxH?: SpacingScale | 'px' | 'full' | 'screen' | 'svh' | 'lvh' | 'dvh' | 'min' | 'max' | 'fit' | (string & {});
|
|
775
794
|
/** @see https://tailwindcss.com/docs/size */
|
|
776
795
|
size?: SpacingScale | 'px' | 'auto' | 'full' | 'min' | 'max' | 'fit' | (string & {});
|
|
796
|
+
/** @see https://tailwindcss.com/docs/block-size — block-size (logical height) */
|
|
797
|
+
blockSize?: SpacingScale | 'px' | 'auto' | 'full' | 'screen' | 'svh' | 'lvh' | 'dvh' | 'min' | 'max' | 'fit' | FractionValue | (string & {});
|
|
798
|
+
/** @see https://tailwindcss.com/docs/min-block-size */
|
|
799
|
+
minBlockSize?: SpacingScale | 'px' | 'full' | 'screen' | 'svh' | 'lvh' | 'dvh' | 'min' | 'max' | 'fit' | (string & {});
|
|
800
|
+
/** @see https://tailwindcss.com/docs/max-block-size */
|
|
801
|
+
maxBlockSize?: SpacingScale | 'px' | 'full' | 'screen' | 'svh' | 'lvh' | 'dvh' | 'min' | 'max' | 'fit' | (string & {});
|
|
802
|
+
/** @see https://tailwindcss.com/docs/inline-size — inline-size (logical width) */
|
|
803
|
+
inlineSize?: SpacingScale | 'px' | 'auto' | 'full' | 'screen' | 'svw' | 'lvw' | 'dvw' | 'min' | 'max' | 'fit' | FractionValue | (string & {});
|
|
804
|
+
/** @see https://tailwindcss.com/docs/min-inline-size */
|
|
805
|
+
minInlineSize?: SpacingScale | 'px' | 'full' | 'min' | 'max' | 'fit' | FractionValue | (string & {});
|
|
806
|
+
/** @see https://tailwindcss.com/docs/max-inline-size */
|
|
807
|
+
maxInlineSize?: SpacingScale | 'px' | 'full' | 'none' | 'prose' | 'min' | 'max' | 'fit' | ContainerSize | FractionValue | (string & {});
|
|
777
808
|
}
|
|
778
809
|
/**
|
|
779
810
|
*
|
|
@@ -858,6 +889,8 @@ interface TypographyProps {
|
|
|
858
889
|
hyphens?: 'none' | 'manual' | 'auto';
|
|
859
890
|
/** @see https://tailwindcss.com/docs/content — also handles align-content */
|
|
860
891
|
content?: 'none' | 'normal' | 'start' | 'end' | 'center' | 'between' | 'around' | 'evenly' | 'baseline' | 'stretch' | (string & {});
|
|
892
|
+
/** @see https://tailwindcss.com/docs/font-feature-settings */
|
|
893
|
+
fontFeatures?: string & {};
|
|
861
894
|
/** @see https://tailwindcss.com/docs/forced-color-adjust */
|
|
862
895
|
forcedColorAdjust?: 'auto' | 'none';
|
|
863
896
|
}
|
|
@@ -926,6 +959,10 @@ interface BorderProps {
|
|
|
926
959
|
borderL?: boolean | 0 | 2 | 4 | 8 | (string & {});
|
|
927
960
|
borderS?: boolean | 0 | 2 | 4 | 8 | (string & {});
|
|
928
961
|
borderE?: boolean | 0 | 2 | 4 | 8 | (string & {});
|
|
962
|
+
/** border-block-start width */
|
|
963
|
+
borderBs?: boolean | 0 | 2 | 4 | 8 | (string & {});
|
|
964
|
+
/** border-block-end width */
|
|
965
|
+
borderBe?: boolean | 0 | 2 | 4 | 8 | (string & {});
|
|
929
966
|
/** @see https://tailwindcss.com/docs/border-color */
|
|
930
967
|
borderColor?: ColorPropValue;
|
|
931
968
|
/** @see https://tailwindcss.com/docs/border-style */
|
|
@@ -1032,15 +1069,25 @@ interface TransformProps {
|
|
|
1032
1069
|
scale?: 0 | 50 | 75 | 90 | 95 | 100 | 105 | 110 | 125 | 150 | 200 | number | (string & {});
|
|
1033
1070
|
scaleX?: TransformProps['scale'];
|
|
1034
1071
|
scaleY?: TransformProps['scale'];
|
|
1072
|
+
/** @see https://tailwindcss.com/docs/scale (Z-axis, 3D) */
|
|
1073
|
+
scaleZ?: TransformProps['scale'];
|
|
1035
1074
|
/** Boolean sugar for 3D scale */
|
|
1036
1075
|
scale3d?: boolean;
|
|
1037
1076
|
/** @see https://tailwindcss.com/docs/rotate */
|
|
1038
1077
|
rotate?: 0 | 1 | 2 | 3 | 6 | 12 | 45 | 90 | 180 | number | (string & {});
|
|
1078
|
+
/** @see https://tailwindcss.com/docs/rotate (X-axis, 3D) */
|
|
1079
|
+
rotateX?: TransformProps['rotate'];
|
|
1080
|
+
/** @see https://tailwindcss.com/docs/rotate (Y-axis, 3D) */
|
|
1081
|
+
rotateY?: TransformProps['rotate'];
|
|
1082
|
+
/** @see https://tailwindcss.com/docs/rotate (Z-axis, 3D) */
|
|
1083
|
+
rotateZ?: TransformProps['rotate'];
|
|
1039
1084
|
/** Boolean sugar for 3D rotate */
|
|
1040
1085
|
rotate3d?: boolean;
|
|
1041
1086
|
/** @see https://tailwindcss.com/docs/translate */
|
|
1042
1087
|
translateX?: SpacingValue | FractionValue;
|
|
1043
1088
|
translateY?: SpacingValue | FractionValue;
|
|
1089
|
+
/** @see https://tailwindcss.com/docs/translate (Z-axis, 3D) */
|
|
1090
|
+
translateZ?: SpacingValue;
|
|
1044
1091
|
/** Boolean sugar for 3D translate */
|
|
1045
1092
|
translate3d?: boolean;
|
|
1046
1093
|
/** @see https://tailwindcss.com/docs/skew */
|
|
@@ -1051,7 +1098,8 @@ interface TransformProps {
|
|
|
1051
1098
|
/** Transform rendering hints */
|
|
1052
1099
|
transformGpu?: boolean;
|
|
1053
1100
|
transformCpu?: boolean;
|
|
1054
|
-
|
|
1101
|
+
/** @see https://tailwindcss.com/docs/transform */
|
|
1102
|
+
transform?: 'none';
|
|
1055
1103
|
/** @see https://tailwindcss.com/docs/perspective */
|
|
1056
1104
|
perspective?: 'none' | (string & {});
|
|
1057
1105
|
perspectiveOrigin?: (string & {});
|
|
@@ -1087,6 +1135,10 @@ interface InteractivityProps {
|
|
|
1087
1135
|
caret?: 'auto' | ColorPropValue;
|
|
1088
1136
|
/** @see https://tailwindcss.com/docs/pointer-events */
|
|
1089
1137
|
pointerEvents?: 'none' | 'auto';
|
|
1138
|
+
/** @see https://tailwindcss.com/docs/field-sizing */
|
|
1139
|
+
fieldSizing?: 'fixed' | 'content';
|
|
1140
|
+
/** @see https://tailwindcss.com/docs/color-scheme */
|
|
1141
|
+
scheme?: 'normal' | 'dark' | 'light' | 'light-dark' | 'only-dark' | 'only-light';
|
|
1090
1142
|
/** @see https://tailwindcss.com/docs/resize */
|
|
1091
1143
|
resize?: 'none' | 'y' | 'x' | boolean;
|
|
1092
1144
|
/** @see https://tailwindcss.com/docs/scroll-behavior */
|
|
@@ -1111,6 +1163,14 @@ interface InteractivityProps {
|
|
|
1111
1163
|
scrollPl?: SpacingValue;
|
|
1112
1164
|
scrollPs?: SpacingValue;
|
|
1113
1165
|
scrollPe?: SpacingValue;
|
|
1166
|
+
/** scroll-padding-block-start */
|
|
1167
|
+
scrollPbs?: SpacingValue;
|
|
1168
|
+
/** scroll-padding-block-end */
|
|
1169
|
+
scrollPbe?: SpacingValue;
|
|
1170
|
+
/** scroll-margin-block-start */
|
|
1171
|
+
scrollMbs?: SpacingValue;
|
|
1172
|
+
/** scroll-margin-block-end */
|
|
1173
|
+
scrollMbe?: SpacingValue;
|
|
1114
1174
|
/** @see https://tailwindcss.com/docs/scroll-snap-align */
|
|
1115
1175
|
snapAlign?: 'start' | 'end' | 'center' | 'align-none';
|
|
1116
1176
|
/** @see https://tailwindcss.com/docs/scroll-snap-stop */
|
package/dist/index.d.ts
CHANGED
|
@@ -61,6 +61,7 @@ declare function transformSourceCode(source: string): {
|
|
|
61
61
|
transformed: boolean;
|
|
62
62
|
usesRuntime: boolean;
|
|
63
63
|
usesColorVar: boolean;
|
|
64
|
+
classes: Set<string>;
|
|
64
65
|
};
|
|
65
66
|
|
|
66
67
|
/**
|
|
@@ -530,7 +531,7 @@ type SpacingValue = SpacingScale | 'px' | 'auto' | (number & {}) | (string & {})
|
|
|
530
531
|
/** Negative spacing value */
|
|
531
532
|
type NegativeSpacingValue = SpacingValue | number;
|
|
532
533
|
/** Tailwind color names */
|
|
533
|
-
type ColorName = 'inherit' | 'current' | 'transparent' | 'black' | 'white' | 'slate' | 'gray' | 'zinc' | 'neutral' | 'stone' | 'red' | 'orange' | 'amber' | 'yellow' | 'lime' | 'green' | 'emerald' | 'teal' | 'cyan' | 'sky' | 'blue' | 'indigo' | 'violet' | 'purple' | 'fuchsia' | 'pink' | 'rose';
|
|
534
|
+
type ColorName = 'inherit' | 'current' | 'transparent' | 'black' | 'white' | 'slate' | 'gray' | 'zinc' | 'neutral' | 'stone' | 'red' | 'orange' | 'amber' | 'yellow' | 'lime' | 'green' | 'emerald' | 'teal' | 'cyan' | 'sky' | 'blue' | 'indigo' | 'violet' | 'purple' | 'fuchsia' | 'pink' | 'rose' | 'mauve' | 'olive' | 'mist' | 'taupe';
|
|
534
535
|
/** Tailwind color shades */
|
|
535
536
|
type ColorShade = 50 | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950;
|
|
536
537
|
/** Color value (string-based) */
|
|
@@ -606,6 +607,8 @@ interface LayoutProps {
|
|
|
606
607
|
container?: boolean;
|
|
607
608
|
/** Boolean sugar for prose */
|
|
608
609
|
prose?: boolean;
|
|
610
|
+
/** Boolean sugar for prose-invert (requires @tailwindcss/typography plugin) */
|
|
611
|
+
proseInvert?: boolean;
|
|
609
612
|
/** @see https://tailwindcss.com/docs/float */
|
|
610
613
|
float?: 'right' | 'left' | 'start' | 'end' | 'none';
|
|
611
614
|
/** @see https://tailwindcss.com/docs/clear */
|
|
@@ -642,6 +645,14 @@ interface LayoutProps {
|
|
|
642
645
|
left?: NegativeSpacingValue;
|
|
643
646
|
start?: SpacingValue;
|
|
644
647
|
end?: SpacingValue;
|
|
648
|
+
/** inset-inline-start (camelCase alias for start, emits inset-s-*) */
|
|
649
|
+
insetS?: SpacingValue;
|
|
650
|
+
/** inset-inline-end (camelCase alias for end, emits inset-e-*) */
|
|
651
|
+
insetE?: SpacingValue;
|
|
652
|
+
/** inset-block-start */
|
|
653
|
+
insetBs?: SpacingValue;
|
|
654
|
+
/** inset-block-end */
|
|
655
|
+
insetBe?: SpacingValue;
|
|
645
656
|
/** @see https://tailwindcss.com/docs/visibility */
|
|
646
657
|
visibility?: 'visible' | 'hidden' | 'collapse';
|
|
647
658
|
visible?: boolean;
|
|
@@ -729,6 +740,10 @@ interface SpacingProps {
|
|
|
729
740
|
ps?: SpacingValue;
|
|
730
741
|
/** Padding - inline end (logical) */
|
|
731
742
|
pe?: SpacingValue;
|
|
743
|
+
/** Padding - block-start (logical) */
|
|
744
|
+
pbs?: SpacingValue;
|
|
745
|
+
/** Padding - block-end (logical) */
|
|
746
|
+
pbe?: SpacingValue;
|
|
732
747
|
/** Margin - all sides */
|
|
733
748
|
m?: NegativeSpacingValue;
|
|
734
749
|
/** Margin - X axis (left/right) */
|
|
@@ -747,6 +762,10 @@ interface SpacingProps {
|
|
|
747
762
|
ms?: NegativeSpacingValue;
|
|
748
763
|
/** Margin - inline end (logical) */
|
|
749
764
|
me?: NegativeSpacingValue;
|
|
765
|
+
/** Margin - block-start (logical) */
|
|
766
|
+
mbs?: NegativeSpacingValue;
|
|
767
|
+
/** Margin - block-end (logical) */
|
|
768
|
+
mbe?: NegativeSpacingValue;
|
|
750
769
|
/** Space between child elements - X axis */
|
|
751
770
|
spaceX?: NegativeSpacingValue;
|
|
752
771
|
/** Space between child elements - Y axis */
|
|
@@ -774,6 +793,18 @@ interface SizingProps {
|
|
|
774
793
|
maxH?: SpacingScale | 'px' | 'full' | 'screen' | 'svh' | 'lvh' | 'dvh' | 'min' | 'max' | 'fit' | (string & {});
|
|
775
794
|
/** @see https://tailwindcss.com/docs/size */
|
|
776
795
|
size?: SpacingScale | 'px' | 'auto' | 'full' | 'min' | 'max' | 'fit' | (string & {});
|
|
796
|
+
/** @see https://tailwindcss.com/docs/block-size — block-size (logical height) */
|
|
797
|
+
blockSize?: SpacingScale | 'px' | 'auto' | 'full' | 'screen' | 'svh' | 'lvh' | 'dvh' | 'min' | 'max' | 'fit' | FractionValue | (string & {});
|
|
798
|
+
/** @see https://tailwindcss.com/docs/min-block-size */
|
|
799
|
+
minBlockSize?: SpacingScale | 'px' | 'full' | 'screen' | 'svh' | 'lvh' | 'dvh' | 'min' | 'max' | 'fit' | (string & {});
|
|
800
|
+
/** @see https://tailwindcss.com/docs/max-block-size */
|
|
801
|
+
maxBlockSize?: SpacingScale | 'px' | 'full' | 'screen' | 'svh' | 'lvh' | 'dvh' | 'min' | 'max' | 'fit' | (string & {});
|
|
802
|
+
/** @see https://tailwindcss.com/docs/inline-size — inline-size (logical width) */
|
|
803
|
+
inlineSize?: SpacingScale | 'px' | 'auto' | 'full' | 'screen' | 'svw' | 'lvw' | 'dvw' | 'min' | 'max' | 'fit' | FractionValue | (string & {});
|
|
804
|
+
/** @see https://tailwindcss.com/docs/min-inline-size */
|
|
805
|
+
minInlineSize?: SpacingScale | 'px' | 'full' | 'min' | 'max' | 'fit' | FractionValue | (string & {});
|
|
806
|
+
/** @see https://tailwindcss.com/docs/max-inline-size */
|
|
807
|
+
maxInlineSize?: SpacingScale | 'px' | 'full' | 'none' | 'prose' | 'min' | 'max' | 'fit' | ContainerSize | FractionValue | (string & {});
|
|
777
808
|
}
|
|
778
809
|
/**
|
|
779
810
|
*
|
|
@@ -858,6 +889,8 @@ interface TypographyProps {
|
|
|
858
889
|
hyphens?: 'none' | 'manual' | 'auto';
|
|
859
890
|
/** @see https://tailwindcss.com/docs/content — also handles align-content */
|
|
860
891
|
content?: 'none' | 'normal' | 'start' | 'end' | 'center' | 'between' | 'around' | 'evenly' | 'baseline' | 'stretch' | (string & {});
|
|
892
|
+
/** @see https://tailwindcss.com/docs/font-feature-settings */
|
|
893
|
+
fontFeatures?: string & {};
|
|
861
894
|
/** @see https://tailwindcss.com/docs/forced-color-adjust */
|
|
862
895
|
forcedColorAdjust?: 'auto' | 'none';
|
|
863
896
|
}
|
|
@@ -926,6 +959,10 @@ interface BorderProps {
|
|
|
926
959
|
borderL?: boolean | 0 | 2 | 4 | 8 | (string & {});
|
|
927
960
|
borderS?: boolean | 0 | 2 | 4 | 8 | (string & {});
|
|
928
961
|
borderE?: boolean | 0 | 2 | 4 | 8 | (string & {});
|
|
962
|
+
/** border-block-start width */
|
|
963
|
+
borderBs?: boolean | 0 | 2 | 4 | 8 | (string & {});
|
|
964
|
+
/** border-block-end width */
|
|
965
|
+
borderBe?: boolean | 0 | 2 | 4 | 8 | (string & {});
|
|
929
966
|
/** @see https://tailwindcss.com/docs/border-color */
|
|
930
967
|
borderColor?: ColorPropValue;
|
|
931
968
|
/** @see https://tailwindcss.com/docs/border-style */
|
|
@@ -1032,15 +1069,25 @@ interface TransformProps {
|
|
|
1032
1069
|
scale?: 0 | 50 | 75 | 90 | 95 | 100 | 105 | 110 | 125 | 150 | 200 | number | (string & {});
|
|
1033
1070
|
scaleX?: TransformProps['scale'];
|
|
1034
1071
|
scaleY?: TransformProps['scale'];
|
|
1072
|
+
/** @see https://tailwindcss.com/docs/scale (Z-axis, 3D) */
|
|
1073
|
+
scaleZ?: TransformProps['scale'];
|
|
1035
1074
|
/** Boolean sugar for 3D scale */
|
|
1036
1075
|
scale3d?: boolean;
|
|
1037
1076
|
/** @see https://tailwindcss.com/docs/rotate */
|
|
1038
1077
|
rotate?: 0 | 1 | 2 | 3 | 6 | 12 | 45 | 90 | 180 | number | (string & {});
|
|
1078
|
+
/** @see https://tailwindcss.com/docs/rotate (X-axis, 3D) */
|
|
1079
|
+
rotateX?: TransformProps['rotate'];
|
|
1080
|
+
/** @see https://tailwindcss.com/docs/rotate (Y-axis, 3D) */
|
|
1081
|
+
rotateY?: TransformProps['rotate'];
|
|
1082
|
+
/** @see https://tailwindcss.com/docs/rotate (Z-axis, 3D) */
|
|
1083
|
+
rotateZ?: TransformProps['rotate'];
|
|
1039
1084
|
/** Boolean sugar for 3D rotate */
|
|
1040
1085
|
rotate3d?: boolean;
|
|
1041
1086
|
/** @see https://tailwindcss.com/docs/translate */
|
|
1042
1087
|
translateX?: SpacingValue | FractionValue;
|
|
1043
1088
|
translateY?: SpacingValue | FractionValue;
|
|
1089
|
+
/** @see https://tailwindcss.com/docs/translate (Z-axis, 3D) */
|
|
1090
|
+
translateZ?: SpacingValue;
|
|
1044
1091
|
/** Boolean sugar for 3D translate */
|
|
1045
1092
|
translate3d?: boolean;
|
|
1046
1093
|
/** @see https://tailwindcss.com/docs/skew */
|
|
@@ -1051,7 +1098,8 @@ interface TransformProps {
|
|
|
1051
1098
|
/** Transform rendering hints */
|
|
1052
1099
|
transformGpu?: boolean;
|
|
1053
1100
|
transformCpu?: boolean;
|
|
1054
|
-
|
|
1101
|
+
/** @see https://tailwindcss.com/docs/transform */
|
|
1102
|
+
transform?: 'none';
|
|
1055
1103
|
/** @see https://tailwindcss.com/docs/perspective */
|
|
1056
1104
|
perspective?: 'none' | (string & {});
|
|
1057
1105
|
perspectiveOrigin?: (string & {});
|
|
@@ -1087,6 +1135,10 @@ interface InteractivityProps {
|
|
|
1087
1135
|
caret?: 'auto' | ColorPropValue;
|
|
1088
1136
|
/** @see https://tailwindcss.com/docs/pointer-events */
|
|
1089
1137
|
pointerEvents?: 'none' | 'auto';
|
|
1138
|
+
/** @see https://tailwindcss.com/docs/field-sizing */
|
|
1139
|
+
fieldSizing?: 'fixed' | 'content';
|
|
1140
|
+
/** @see https://tailwindcss.com/docs/color-scheme */
|
|
1141
|
+
scheme?: 'normal' | 'dark' | 'light' | 'light-dark' | 'only-dark' | 'only-light';
|
|
1090
1142
|
/** @see https://tailwindcss.com/docs/resize */
|
|
1091
1143
|
resize?: 'none' | 'y' | 'x' | boolean;
|
|
1092
1144
|
/** @see https://tailwindcss.com/docs/scroll-behavior */
|
|
@@ -1111,6 +1163,14 @@ interface InteractivityProps {
|
|
|
1111
1163
|
scrollPl?: SpacingValue;
|
|
1112
1164
|
scrollPs?: SpacingValue;
|
|
1113
1165
|
scrollPe?: SpacingValue;
|
|
1166
|
+
/** scroll-padding-block-start */
|
|
1167
|
+
scrollPbs?: SpacingValue;
|
|
1168
|
+
/** scroll-padding-block-end */
|
|
1169
|
+
scrollPbe?: SpacingValue;
|
|
1170
|
+
/** scroll-margin-block-start */
|
|
1171
|
+
scrollMbs?: SpacingValue;
|
|
1172
|
+
/** scroll-margin-block-end */
|
|
1173
|
+
scrollMbe?: SpacingValue;
|
|
1114
1174
|
/** @see https://tailwindcss.com/docs/scroll-snap-align */
|
|
1115
1175
|
snapAlign?: 'start' | 'end' | 'center' | 'align-none';
|
|
1116
1176
|
/** @see https://tailwindcss.com/docs/scroll-snap-stop */
|
package/dist/index.js
CHANGED
|
@@ -31,6 +31,8 @@ var PROPERTY_CATEGORY_MAP = {
|
|
|
31
31
|
py: 0 /* SPACING */,
|
|
32
32
|
ps: 0 /* SPACING */,
|
|
33
33
|
pe: 0 /* SPACING */,
|
|
34
|
+
pbs: 0 /* SPACING */,
|
|
35
|
+
pbe: 0 /* SPACING */,
|
|
34
36
|
m: 0 /* SPACING */,
|
|
35
37
|
mt: 0 /* SPACING */,
|
|
36
38
|
mr: 0 /* SPACING */,
|
|
@@ -40,6 +42,8 @@ var PROPERTY_CATEGORY_MAP = {
|
|
|
40
42
|
my: 0 /* SPACING */,
|
|
41
43
|
ms: 0 /* SPACING */,
|
|
42
44
|
me: 0 /* SPACING */,
|
|
45
|
+
mbs: 0 /* SPACING */,
|
|
46
|
+
mbe: 0 /* SPACING */,
|
|
43
47
|
spaceX: 0 /* SPACING */,
|
|
44
48
|
spaceY: 0 /* SPACING */,
|
|
45
49
|
gap: 0 /* SPACING */,
|
|
@@ -54,6 +58,10 @@ var PROPERTY_CATEGORY_MAP = {
|
|
|
54
58
|
left: 0 /* SPACING */,
|
|
55
59
|
start: 0 /* SPACING */,
|
|
56
60
|
end: 0 /* SPACING */,
|
|
61
|
+
insetS: 0 /* SPACING */,
|
|
62
|
+
insetE: 0 /* SPACING */,
|
|
63
|
+
insetBs: 0 /* SPACING */,
|
|
64
|
+
insetBe: 0 /* SPACING */,
|
|
57
65
|
w: 0 /* SPACING */,
|
|
58
66
|
minW: 0 /* SPACING */,
|
|
59
67
|
maxW: 0 /* SPACING */,
|
|
@@ -61,6 +69,12 @@ var PROPERTY_CATEGORY_MAP = {
|
|
|
61
69
|
minH: 0 /* SPACING */,
|
|
62
70
|
maxH: 0 /* SPACING */,
|
|
63
71
|
size: 0 /* SPACING */,
|
|
72
|
+
blockSize: 0 /* SPACING */,
|
|
73
|
+
minBlockSize: 0 /* SPACING */,
|
|
74
|
+
maxBlockSize: 0 /* SPACING */,
|
|
75
|
+
inlineSize: 0 /* SPACING */,
|
|
76
|
+
minInlineSize: 0 /* SPACING */,
|
|
77
|
+
maxInlineSize: 0 /* SPACING */,
|
|
64
78
|
basis: 0 /* SPACING */,
|
|
65
79
|
indent: 0 /* SPACING */,
|
|
66
80
|
scrollM: 0 /* SPACING */,
|
|
@@ -81,6 +95,10 @@ var PROPERTY_CATEGORY_MAP = {
|
|
|
81
95
|
scrollPe: 0 /* SPACING */,
|
|
82
96
|
scrollPx: 0 /* SPACING */,
|
|
83
97
|
scrollPy: 0 /* SPACING */,
|
|
98
|
+
scrollPbs: 0 /* SPACING */,
|
|
99
|
+
scrollPbe: 0 /* SPACING */,
|
|
100
|
+
scrollMbs: 0 /* SPACING */,
|
|
101
|
+
scrollMbe: 0 /* SPACING */,
|
|
84
102
|
translateX: 0 /* SPACING */,
|
|
85
103
|
translateY: 0 /* SPACING */,
|
|
86
104
|
borderSpacing: 0 /* SPACING */,
|
|
@@ -148,6 +166,8 @@ var PROPERTY_CATEGORY_MAP = {
|
|
|
148
166
|
borderY: 3 /* UNITLESS */,
|
|
149
167
|
borderS: 3 /* UNITLESS */,
|
|
150
168
|
borderE: 3 /* UNITLESS */,
|
|
169
|
+
borderBs: 3 /* UNITLESS */,
|
|
170
|
+
borderBe: 3 /* UNITLESS */,
|
|
151
171
|
ring: 3 /* UNITLESS */,
|
|
152
172
|
outline: 3 /* UNITLESS */,
|
|
153
173
|
leading: 3 /* UNITLESS */,
|
|
@@ -292,6 +312,8 @@ var PROPERTY_MAP = {
|
|
|
292
312
|
borderY: "border-y",
|
|
293
313
|
borderS: "border-s",
|
|
294
314
|
borderE: "border-e",
|
|
315
|
+
borderBs: "border-bs",
|
|
316
|
+
borderBe: "border-be",
|
|
295
317
|
// Divide
|
|
296
318
|
divideX: "divide-x",
|
|
297
319
|
divideY: "divide-y",
|
|
@@ -317,6 +339,8 @@ var PROPERTY_MAP = {
|
|
|
317
339
|
py: "py",
|
|
318
340
|
ps: "ps",
|
|
319
341
|
pe: "pe",
|
|
342
|
+
pbs: "pbs",
|
|
343
|
+
pbe: "pbe",
|
|
320
344
|
m: "m",
|
|
321
345
|
mt: "mt",
|
|
322
346
|
mr: "mr",
|
|
@@ -326,6 +350,8 @@ var PROPERTY_MAP = {
|
|
|
326
350
|
my: "my",
|
|
327
351
|
ms: "ms",
|
|
328
352
|
me: "me",
|
|
353
|
+
mbs: "mbs",
|
|
354
|
+
mbe: "mbe",
|
|
329
355
|
// Space between
|
|
330
356
|
spaceX: "space-x",
|
|
331
357
|
spaceY: "space-y",
|
|
@@ -337,6 +363,12 @@ var PROPERTY_MAP = {
|
|
|
337
363
|
minH: "min-h",
|
|
338
364
|
maxH: "max-h",
|
|
339
365
|
size: "size",
|
|
366
|
+
blockSize: "block",
|
|
367
|
+
minBlockSize: "min-block",
|
|
368
|
+
maxBlockSize: "max-block",
|
|
369
|
+
inlineSize: "inline",
|
|
370
|
+
minInlineSize: "min-inline",
|
|
371
|
+
maxInlineSize: "max-inline",
|
|
340
372
|
// Layout
|
|
341
373
|
aspect: "aspect",
|
|
342
374
|
columns: "columns",
|
|
@@ -366,14 +398,20 @@ var PROPERTY_MAP = {
|
|
|
366
398
|
right: "right",
|
|
367
399
|
bottom: "bottom",
|
|
368
400
|
left: "left",
|
|
369
|
-
|
|
370
|
-
|
|
401
|
+
// TW v4.2: start/end now emit inset-s-*/inset-e-* (same CSS, deprecated old class names)
|
|
402
|
+
start: "inset-s",
|
|
403
|
+
end: "inset-e",
|
|
404
|
+
insetS: "inset-s",
|
|
405
|
+
insetE: "inset-e",
|
|
406
|
+
insetBs: "inset-bs",
|
|
407
|
+
insetBe: "inset-be",
|
|
371
408
|
// Visibility
|
|
372
409
|
visibility: "visibility",
|
|
373
410
|
// Typography
|
|
374
411
|
color: "text",
|
|
375
412
|
text: "text",
|
|
376
413
|
fontWeight: "font",
|
|
414
|
+
weight: "font",
|
|
377
415
|
fontFamily: "font",
|
|
378
416
|
fontStretch: "font-stretch",
|
|
379
417
|
textAlign: "text",
|
|
@@ -395,6 +433,7 @@ var PROPERTY_MAP = {
|
|
|
395
433
|
leading: "leading",
|
|
396
434
|
tracking: "tracking",
|
|
397
435
|
lineClamp: "line-clamp",
|
|
436
|
+
fontFeatures: "font-features",
|
|
398
437
|
list: "list",
|
|
399
438
|
listPos: "list",
|
|
400
439
|
listImg: "list-image",
|
|
@@ -464,9 +503,14 @@ var PROPERTY_MAP = {
|
|
|
464
503
|
scale: "scale",
|
|
465
504
|
scaleX: "scale-x",
|
|
466
505
|
scaleY: "scale-y",
|
|
506
|
+
scaleZ: "scale-z",
|
|
467
507
|
rotate: "rotate",
|
|
508
|
+
rotateX: "rotate-x",
|
|
509
|
+
rotateY: "rotate-y",
|
|
510
|
+
rotateZ: "rotate-z",
|
|
468
511
|
translateX: "translate-x",
|
|
469
512
|
translateY: "translate-y",
|
|
513
|
+
translateZ: "translate-z",
|
|
470
514
|
skewX: "skew-x",
|
|
471
515
|
skewY: "skew-y",
|
|
472
516
|
origin: "origin",
|
|
@@ -474,6 +518,7 @@ var PROPERTY_MAP = {
|
|
|
474
518
|
perspective: "perspective",
|
|
475
519
|
perspectiveOrigin: "perspective-origin",
|
|
476
520
|
transformStyle: "transform",
|
|
521
|
+
transform: "transform",
|
|
477
522
|
// Transitions & Animation
|
|
478
523
|
transition: "transition",
|
|
479
524
|
transitionBehavior: "transition",
|
|
@@ -491,6 +536,8 @@ var PROPERTY_MAP = {
|
|
|
491
536
|
cursor: "cursor",
|
|
492
537
|
caret: "caret",
|
|
493
538
|
pointerEvents: "pointer-events",
|
|
539
|
+
fieldSizing: "field-sizing",
|
|
540
|
+
scheme: "scheme",
|
|
494
541
|
resize: "resize",
|
|
495
542
|
scroll: "scroll",
|
|
496
543
|
scrollM: "scroll-m",
|
|
@@ -511,6 +558,10 @@ var PROPERTY_MAP = {
|
|
|
511
558
|
scrollPe: "scroll-pe",
|
|
512
559
|
scrollPx: "scroll-px",
|
|
513
560
|
scrollPy: "scroll-py",
|
|
561
|
+
scrollPbs: "scroll-pbs",
|
|
562
|
+
scrollPbe: "scroll-pbe",
|
|
563
|
+
scrollMbs: "scroll-mbs",
|
|
564
|
+
scrollMbe: "scroll-mbe",
|
|
514
565
|
snapAlign: "snap",
|
|
515
566
|
snapStop: "snap",
|
|
516
567
|
snapType: "snap",
|
|
@@ -860,6 +911,7 @@ var BOOLEAN_SHORTHANDS = /* @__PURE__ */ new Set([
|
|
|
860
911
|
// Misc
|
|
861
912
|
"container",
|
|
862
913
|
"prose",
|
|
914
|
+
"proseInvert",
|
|
863
915
|
"srOnly",
|
|
864
916
|
"notSrOnly",
|
|
865
917
|
"isolate",
|
|
@@ -886,8 +938,7 @@ var BOOLEAN_SHORTHANDS = /* @__PURE__ */ new Set([
|
|
|
886
938
|
"rotate3d",
|
|
887
939
|
"translate3d",
|
|
888
940
|
"transformGpu",
|
|
889
|
-
"transformCpu"
|
|
890
|
-
"transformNone"
|
|
941
|
+
"transformCpu"
|
|
891
942
|
]);
|
|
892
943
|
var BOOLEAN_TO_CLASS = {
|
|
893
944
|
inlineBlock: "inline-block",
|
|
@@ -925,7 +976,8 @@ var BOOLEAN_TO_CLASS = {
|
|
|
925
976
|
translate3d: "translate-3d",
|
|
926
977
|
transformGpu: "transform-gpu",
|
|
927
978
|
transformCpu: "transform-cpu",
|
|
928
|
-
|
|
979
|
+
// Misc
|
|
980
|
+
proseInvert: "prose-invert"
|
|
929
981
|
};
|
|
930
982
|
var SNAP_DIRECT_MAP = {
|
|
931
983
|
snapAlign: {
|
|
@@ -959,6 +1011,8 @@ var NEGATIVE_ALLOWED = /* @__PURE__ */ new Set([
|
|
|
959
1011
|
"my",
|
|
960
1012
|
"ms",
|
|
961
1013
|
"me",
|
|
1014
|
+
"mbs",
|
|
1015
|
+
"mbe",
|
|
962
1016
|
"top",
|
|
963
1017
|
"right",
|
|
964
1018
|
"bottom",
|
|
@@ -966,8 +1020,11 @@ var NEGATIVE_ALLOWED = /* @__PURE__ */ new Set([
|
|
|
966
1020
|
"inset",
|
|
967
1021
|
"inset-x",
|
|
968
1022
|
"inset-y",
|
|
969
|
-
|
|
970
|
-
"
|
|
1023
|
+
// TW v4.2: start/end now map to inset-s/inset-e
|
|
1024
|
+
"inset-s",
|
|
1025
|
+
"inset-e",
|
|
1026
|
+
"inset-bs",
|
|
1027
|
+
"inset-be",
|
|
971
1028
|
"z",
|
|
972
1029
|
"order",
|
|
973
1030
|
"col",
|
|
@@ -977,10 +1034,16 @@ var NEGATIVE_ALLOWED = /* @__PURE__ */ new Set([
|
|
|
977
1034
|
"row-start",
|
|
978
1035
|
"row-end",
|
|
979
1036
|
"rotate",
|
|
1037
|
+
"rotate-x",
|
|
1038
|
+
"rotate-y",
|
|
1039
|
+
"rotate-z",
|
|
1040
|
+
"scale-z",
|
|
980
1041
|
"skew-x",
|
|
981
1042
|
"skew-y",
|
|
982
1043
|
"translate-x",
|
|
983
1044
|
"translate-y",
|
|
1045
|
+
"translate-z",
|
|
1046
|
+
"mask",
|
|
984
1047
|
"space-x",
|
|
985
1048
|
"space-y",
|
|
986
1049
|
"tracking",
|
|
@@ -1020,7 +1083,7 @@ function normalizeArbitraryVariant(key) {
|
|
|
1020
1083
|
return key.replace(/\s+/g, "");
|
|
1021
1084
|
}
|
|
1022
1085
|
function normalizeArbitraryValue(value) {
|
|
1023
|
-
return value.trim().replace(/\s
|
|
1086
|
+
return value.trim().replace(/\s+/g, "_");
|
|
1024
1087
|
}
|
|
1025
1088
|
var FRACTION_SUPPORTED_PROPS = /* @__PURE__ */ new Set([
|
|
1026
1089
|
// Sizing (both rawKey and resolved key forms)
|
|
@@ -1061,11 +1124,15 @@ var FRACTION_SUPPORTED_PROPS = /* @__PURE__ */ new Set([
|
|
|
1061
1124
|
"translate-x",
|
|
1062
1125
|
"translateX",
|
|
1063
1126
|
"translate-y",
|
|
1064
|
-
"translateY"
|
|
1127
|
+
"translateY",
|
|
1128
|
+
// Aspect
|
|
1129
|
+
"aspect"
|
|
1065
1130
|
]);
|
|
1066
1131
|
function needsArbitraryBrackets(value) {
|
|
1067
|
-
return /^\d+(\.\d+)?(px|rem|em|%|vh|vw|ch|dvh|dvw|svh|svw|lvh|lvw|cqw|cqh|deg|rad|turn|grad|ms|s|fr)$/.test(value) || //
|
|
1132
|
+
return /^\d+(\.\d+)?(px|rem|em|%|vh|vw|ch|dvh|dvw|svh|svw|lvh|lvw|cqw|cqh|deg|rad|turn|grad|ms|s|fr)$/.test(value) || // Positive units
|
|
1133
|
+
/^-\d+(\.\d+)?(px|rem|em|%|vh|vw|ch|dvh|dvw|svh|svw|lvh|lvw|cqw|cqh|deg|rad|turn|grad|ms|s|fr)$/.test(value) || // Negative units like -1px, -2rem
|
|
1068
1134
|
/^\.\d+(px|rem|em|%|vh|vw|ch)?$/.test(value) || // Values starting with . like .25em
|
|
1135
|
+
/^-\.\d+(px|rem|em|%|vh|vw|ch)?$/.test(value) || // Negative values starting with -. like -.25em
|
|
1069
1136
|
value.startsWith("#") || // Hex colors
|
|
1070
1137
|
value.startsWith("rgb") || // RGB colors
|
|
1071
1138
|
value.startsWith("hsl") || // HSL colors
|
|
@@ -1517,12 +1584,13 @@ function transform(szProp, prefix = "", mangleMap) {
|
|
|
1517
1584
|
}
|
|
1518
1585
|
let className = prefix;
|
|
1519
1586
|
if (rawKey === "willChange" && typeof value === "string") {
|
|
1520
|
-
|
|
1521
|
-
|
|
1587
|
+
const WILL_CHANGE_KEYWORDS = /* @__PURE__ */ new Set(["auto", "scroll", "contents", "transform"]);
|
|
1588
|
+
if (WILL_CHANGE_KEYWORDS.has(value)) {
|
|
1589
|
+
classes.push(`${prefix}will-change-${value}`);
|
|
1522
1590
|
} else if (value.startsWith("--")) {
|
|
1523
1591
|
classes.push(`${prefix}will-change-(${value})`);
|
|
1524
1592
|
} else {
|
|
1525
|
-
classes.push(`${prefix}will-change
|
|
1593
|
+
classes.push(`${prefix}will-change-[${normalizeArbitraryValue(value)}]`);
|
|
1526
1594
|
}
|
|
1527
1595
|
continue;
|
|
1528
1596
|
}
|
|
@@ -1636,10 +1704,10 @@ function transform(szProp, prefix = "", mangleMap) {
|
|
|
1636
1704
|
continue;
|
|
1637
1705
|
}
|
|
1638
1706
|
if (rawKey === "textOverflow") {
|
|
1639
|
-
if (value === "ellipsis") {
|
|
1640
|
-
classes.push(`${prefix}truncate`);
|
|
1641
|
-
} else {
|
|
1707
|
+
if (value === "ellipsis" || value === "clip") {
|
|
1642
1708
|
classes.push(`${prefix}text-${value}`);
|
|
1709
|
+
} else {
|
|
1710
|
+
classes.push(`${prefix}text-[${value}]`);
|
|
1643
1711
|
}
|
|
1644
1712
|
continue;
|
|
1645
1713
|
}
|
|
@@ -1707,8 +1775,13 @@ function transform(szProp, prefix = "", mangleMap) {
|
|
|
1707
1775
|
className += `font-${sValue}`;
|
|
1708
1776
|
} else if (sValue.startsWith("--")) {
|
|
1709
1777
|
className += `font-stretch-(${sValue})`;
|
|
1710
|
-
} else if (/^\d
|
|
1711
|
-
|
|
1778
|
+
} else if (/^\d+(\.\d+)?%$/.test(sValue)) {
|
|
1779
|
+
const valNum = parseFloat(sValue);
|
|
1780
|
+
if (sValue.includes(".") || !Number.isInteger(valNum)) {
|
|
1781
|
+
className += `font-stretch-[${sValue}]`;
|
|
1782
|
+
} else {
|
|
1783
|
+
className += `font-stretch-${sValue}`;
|
|
1784
|
+
}
|
|
1712
1785
|
} else {
|
|
1713
1786
|
className += `font-stretch-[${sValue}]`;
|
|
1714
1787
|
}
|
|
@@ -1829,6 +1902,17 @@ function transform(szProp, prefix = "", mangleMap) {
|
|
|
1829
1902
|
classes.push(className);
|
|
1830
1903
|
continue;
|
|
1831
1904
|
}
|
|
1905
|
+
if (rawKey === "bgRepeat" || rawKey === "backgroundRepeat") {
|
|
1906
|
+
if (value === "repeat") {
|
|
1907
|
+
className += "bg-repeat";
|
|
1908
|
+
} else if (value === "no-repeat") {
|
|
1909
|
+
className += "bg-no-repeat";
|
|
1910
|
+
} else {
|
|
1911
|
+
className += `bg-repeat-${value}`;
|
|
1912
|
+
}
|
|
1913
|
+
classes.push(className);
|
|
1914
|
+
continue;
|
|
1915
|
+
}
|
|
1832
1916
|
if (rawKey === "maskSize") {
|
|
1833
1917
|
className += `mask-${value}`;
|
|
1834
1918
|
classes.push(className);
|
|
@@ -1854,8 +1938,11 @@ function transform(szProp, prefix = "", mangleMap) {
|
|
|
1854
1938
|
classes.push(className);
|
|
1855
1939
|
continue;
|
|
1856
1940
|
}
|
|
1857
|
-
if (rawKey === "content") {
|
|
1858
|
-
|
|
1941
|
+
if (rawKey === "content" || rawKey === "alignContent") {
|
|
1942
|
+
const ALIGN_CONTENT_KEYWORDS = /* @__PURE__ */ new Set(["normal", "center", "start", "end", "between", "around", "evenly", "baseline", "stretch"]);
|
|
1943
|
+
if (ALIGN_CONTENT_KEYWORDS.has(value)) {
|
|
1944
|
+
className += `content-${value}`;
|
|
1945
|
+
} else if (value.startsWith("--")) {
|
|
1859
1946
|
className += `content-(${value})`;
|
|
1860
1947
|
} else if (!["none", "empty"].includes(value)) {
|
|
1861
1948
|
className += `content-[${value}]`;
|
|
@@ -2005,7 +2092,6 @@ function transform(szProp, prefix = "", mangleMap) {
|
|
|
2005
2092
|
classes.push(className);
|
|
2006
2093
|
continue;
|
|
2007
2094
|
}
|
|
2008
|
-
const isAspectRatio = key === "aspect" && /^\d+\/\d+$/.test(finalValue);
|
|
2009
2095
|
if (finalValue.startsWith("--")) {
|
|
2010
2096
|
const typeHint = CSS_VAR_TYPE_HINTS[rawKey];
|
|
2011
2097
|
if (typeHint) {
|
|
@@ -2019,10 +2105,19 @@ function transform(szProp, prefix = "", mangleMap) {
|
|
|
2019
2105
|
if (!FRACTION_SUPPORTED_PROPS.has(rawKey)) {
|
|
2020
2106
|
finalValue = `[${finalValue}]`;
|
|
2021
2107
|
}
|
|
2022
|
-
} else if (
|
|
2108
|
+
} else if (key === "aspect" && /^[0-9]+(?:\.[0-9]+)?\/[0-9]+(?:\.[0-9]+)?$/.test(finalValue)) {
|
|
2109
|
+
if (finalValue === "auto" || finalValue === "square" || finalValue === "video" || /^\d+\/\d+$/.test(finalValue)) {
|
|
2110
|
+
} else {
|
|
2111
|
+
finalValue = `[${finalValue}]`;
|
|
2112
|
+
}
|
|
2113
|
+
} else if (needsArbitraryBrackets(finalValue) || /^\d+\.\d+%$/.test(finalValue)) {
|
|
2023
2114
|
finalValue = `[${normalizeArbitraryValue(finalValue)}]`;
|
|
2024
2115
|
}
|
|
2025
|
-
|
|
2116
|
+
if (finalValue.startsWith("-") && NEGATIVE_ALLOWED.has(key)) {
|
|
2117
|
+
className = `-${prefix}${key}-${finalValue.substring(1)}`;
|
|
2118
|
+
} else {
|
|
2119
|
+
className += `${key}-${finalValue}`;
|
|
2120
|
+
}
|
|
2026
2121
|
if (important) {
|
|
2027
2122
|
className += "!";
|
|
2028
2123
|
}
|
|
@@ -2083,8 +2178,9 @@ function transformSourceCode(source) {
|
|
|
2083
2178
|
let usesRuntime = false;
|
|
2084
2179
|
let usesColorVar = false;
|
|
2085
2180
|
let transformed = false;
|
|
2181
|
+
const collectedClasses = /* @__PURE__ */ new Set();
|
|
2086
2182
|
if (!source.includes("sz")) {
|
|
2087
|
-
return { code: source, transformed: false, usesRuntime: false, usesColorVar: false };
|
|
2183
|
+
return { code: source, transformed: false, usesRuntime: false, usesColorVar: false, classes: collectedClasses };
|
|
2088
2184
|
}
|
|
2089
2185
|
try {
|
|
2090
2186
|
const result = babel.transformSync(source, {
|
|
@@ -2102,12 +2198,29 @@ function transformSourceCode(source) {
|
|
|
2102
2198
|
return {
|
|
2103
2199
|
visitor: {
|
|
2104
2200
|
JSXAttribute(path) {
|
|
2105
|
-
|
|
2201
|
+
const attrName = t.isJSXIdentifier(path.node.name) ? path.node.name.name : "";
|
|
2202
|
+
if (attrName === "className" || attrName === "class") {
|
|
2203
|
+
const val = path.node.value;
|
|
2204
|
+
if (t.isStringLiteral(val)) {
|
|
2205
|
+
for (const c of val.value.split(/\s+/)) {
|
|
2206
|
+
if (c) {
|
|
2207
|
+
collectedClasses.add(c);
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
}
|
|
2211
|
+
return;
|
|
2212
|
+
}
|
|
2213
|
+
if (attrName !== "sz") {
|
|
2106
2214
|
return;
|
|
2107
2215
|
}
|
|
2108
2216
|
const value = path.node.value;
|
|
2109
2217
|
if (t.isStringLiteral(value)) {
|
|
2110
2218
|
path.node.name.name = "className";
|
|
2219
|
+
for (const c of value.value.split(/\s+/)) {
|
|
2220
|
+
if (c) {
|
|
2221
|
+
collectedClasses.add(c);
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2111
2224
|
transformed = true;
|
|
2112
2225
|
return;
|
|
2113
2226
|
}
|
|
@@ -2117,6 +2230,11 @@ function transformSourceCode(source) {
|
|
|
2117
2230
|
const staticObject = evaluateStaticObject(expression);
|
|
2118
2231
|
if (staticObject !== null) {
|
|
2119
2232
|
const { className, attributes } = transform(staticObject);
|
|
2233
|
+
for (const c of className.split(/\s+/)) {
|
|
2234
|
+
if (c) {
|
|
2235
|
+
collectedClasses.add(c);
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2120
2238
|
path.node.name.name = "className";
|
|
2121
2239
|
path.node.value = t.stringLiteral(className);
|
|
2122
2240
|
Object.entries(attributes).forEach(([key, val]) => {
|
|
@@ -2155,6 +2273,11 @@ function transformSourceCode(source) {
|
|
|
2155
2273
|
);
|
|
2156
2274
|
}
|
|
2157
2275
|
const allClasses = [...staticClasses, ...partial.rawClasses, ...cssVarClasses].join(" ");
|
|
2276
|
+
for (const c of allClasses.split(/\s+/)) {
|
|
2277
|
+
if (c) {
|
|
2278
|
+
collectedClasses.add(c);
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
2158
2281
|
path.node.name.name = "className";
|
|
2159
2282
|
path.node.value = t.stringLiteral(allClasses);
|
|
2160
2283
|
if (styleProps.length > 0 && path.parentPath?.isJSXOpeningElement()) {
|
|
@@ -2183,8 +2306,14 @@ function transformSourceCode(source) {
|
|
|
2183
2306
|
path.node.name.name = "className";
|
|
2184
2307
|
if (t.isStringLiteral(resolved)) {
|
|
2185
2308
|
path.node.value = resolved;
|
|
2309
|
+
for (const c of resolved.value.split(/\s+/)) {
|
|
2310
|
+
if (c) {
|
|
2311
|
+
collectedClasses.add(c);
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2186
2314
|
} else {
|
|
2187
2315
|
value.expression = resolved;
|
|
2316
|
+
collectFromExpr(resolved, collectedClasses);
|
|
2188
2317
|
}
|
|
2189
2318
|
transformed = true;
|
|
2190
2319
|
return;
|
|
@@ -2198,8 +2327,14 @@ function transformSourceCode(source) {
|
|
|
2198
2327
|
path.node.name.name = "className";
|
|
2199
2328
|
if (t.isStringLiteral(resolved)) {
|
|
2200
2329
|
path.node.value = resolved;
|
|
2330
|
+
for (const c of resolved.value.split(/\s+/)) {
|
|
2331
|
+
if (c) {
|
|
2332
|
+
collectedClasses.add(c);
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2201
2335
|
} else {
|
|
2202
2336
|
value.expression = resolved;
|
|
2337
|
+
collectFromExpr(resolved, collectedClasses);
|
|
2203
2338
|
}
|
|
2204
2339
|
transformed = true;
|
|
2205
2340
|
return;
|
|
@@ -2224,11 +2359,12 @@ function transformSourceCode(source) {
|
|
|
2224
2359
|
code: result?.code || source,
|
|
2225
2360
|
transformed,
|
|
2226
2361
|
usesRuntime,
|
|
2227
|
-
usesColorVar
|
|
2362
|
+
usesColorVar,
|
|
2363
|
+
classes: collectedClasses
|
|
2228
2364
|
};
|
|
2229
2365
|
} catch (e) {
|
|
2230
2366
|
console.warn("[csszyx] AST transform failed, falling back to original code:", e);
|
|
2231
|
-
return { code: source, transformed: false, usesRuntime: false, usesColorVar: false };
|
|
2367
|
+
return { code: source, transformed: false, usesRuntime: false, usesColorVar: false, classes: collectedClasses };
|
|
2232
2368
|
}
|
|
2233
2369
|
}
|
|
2234
2370
|
function tryStaticTransformNode(node) {
|
|
@@ -2467,6 +2603,18 @@ function generateStyleValueExpression(info) {
|
|
|
2467
2603
|
);
|
|
2468
2604
|
}
|
|
2469
2605
|
}
|
|
2606
|
+
function collectFromExpr(node, classes) {
|
|
2607
|
+
if (t.isStringLiteral(node)) {
|
|
2608
|
+
for (const c of node.value.split(/\s+/)) {
|
|
2609
|
+
if (c) {
|
|
2610
|
+
classes.add(c);
|
|
2611
|
+
}
|
|
2612
|
+
}
|
|
2613
|
+
} else if (t.isConditionalExpression(node)) {
|
|
2614
|
+
collectFromExpr(node.consequent, classes);
|
|
2615
|
+
collectFromExpr(node.alternate, classes);
|
|
2616
|
+
}
|
|
2617
|
+
}
|
|
2470
2618
|
function buildCSSVarClassName(info) {
|
|
2471
2619
|
const { twPrefix, varName, variantChain } = info;
|
|
2472
2620
|
const variantPrefix = variantChain ? `${getVariantPrefix(variantChain)}:` : "";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@csszyx/compiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Core compiler and transformation logic for csszyx",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"csszyx",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@babel/core": "^7.23.7",
|
|
39
39
|
"@babel/types": "^7.23.6",
|
|
40
40
|
"@babel/traverse": "^7.23.7",
|
|
41
|
-
"@csszyx/core": "0.
|
|
41
|
+
"@csszyx/core": "0.3.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/babel__core": "^7.20.5",
|