@mgcrea/react-native-tailwind 0.5.2 → 0.6.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 +108 -0
- package/dist/babel/index.cjs +289 -1
- package/dist/parser/colors.js +1 -1
- package/dist/parser/colors.test.js +1 -1
- package/dist/parser/index.d.ts +1 -0
- package/dist/parser/index.js +1 -1
- package/dist/parser/transforms.d.ts +13 -0
- package/dist/parser/transforms.js +1 -0
- package/dist/parser/transforms.test.js +1 -0
- package/dist/parser/typography.test.js +1 -1
- package/dist/types.d.ts +32 -2
- package/package.json +1 -1
- package/src/parser/colors.test.ts +10 -0
- package/src/parser/colors.ts +14 -0
- package/src/parser/index.ts +3 -0
- package/src/parser/transforms.test.ts +318 -0
- package/src/parser/transforms.ts +406 -0
- package/src/parser/typography.test.ts +2 -0
- package/src/types.ts +22 -1
package/README.md
CHANGED
|
@@ -858,6 +858,108 @@ Use `aspect-[width/height]` for custom ratios:
|
|
|
858
858
|
|
|
859
859
|
> **Note:** The aspect ratio is calculated as `width / height`. When combined with `w-full`, the height will be automatically calculated to maintain the ratio.
|
|
860
860
|
|
|
861
|
+
### Transforms
|
|
862
|
+
|
|
863
|
+
Apply 2D and 3D transformations to views with React Native's transform API. All transforms compile to optimized transform arrays at build time:
|
|
864
|
+
|
|
865
|
+
**Scale:**
|
|
866
|
+
|
|
867
|
+
- `scale-{value}` — Scale uniformly (both X and Y)
|
|
868
|
+
- `scale-x-{value}`, `scale-y-{value}` — Scale on specific axis
|
|
869
|
+
- **Values:** `0`, `50`, `75`, `90`, `95`, `100`, `105`, `110`, `125`, `150`, `200`
|
|
870
|
+
- **Arbitrary:** `scale-[1.23]`, `scale-x-[0.5]`, `scale-y-[2.5]`
|
|
871
|
+
|
|
872
|
+
**Rotate:**
|
|
873
|
+
|
|
874
|
+
- `rotate-{degrees}`, `-rotate-{degrees}` — Rotate in 2D
|
|
875
|
+
- `rotate-x-{degrees}`, `rotate-y-{degrees}`, `rotate-z-{degrees}` — Rotate on specific axis
|
|
876
|
+
- **Values:** `0`, `1`, `2`, `3`, `6`, `12`, `45`, `90`, `180`
|
|
877
|
+
- **Arbitrary:** `rotate-[37deg]`, `-rotate-[15deg]`, `rotate-x-[30deg]`
|
|
878
|
+
|
|
879
|
+
**Translate:**
|
|
880
|
+
|
|
881
|
+
- `translate-x-{spacing}`, `translate-y-{spacing}` — Move on specific axis
|
|
882
|
+
- `-translate-x-{spacing}`, `-translate-y-{spacing}` — Negative translation
|
|
883
|
+
- **Values:** Uses spacing scale (same as `m-*`, `p-*`)
|
|
884
|
+
- **Arbitrary:** `translate-x-[50px]`, `translate-y-[100px]`, `translate-x-[50%]`
|
|
885
|
+
|
|
886
|
+
**Skew:**
|
|
887
|
+
|
|
888
|
+
- `skew-x-{degrees}`, `skew-y-{degrees}` — Skew on specific axis
|
|
889
|
+
- `-skew-x-{degrees}`, `-skew-y-{degrees}` — Negative skew
|
|
890
|
+
- **Values:** `0`, `1`, `2`, `3`, `6`, `12`
|
|
891
|
+
- **Arbitrary:** `skew-x-[15deg]`, `-skew-y-[8deg]`
|
|
892
|
+
|
|
893
|
+
**Perspective:**
|
|
894
|
+
|
|
895
|
+
- `perspective-{value}` — Apply perspective transformation
|
|
896
|
+
- **Values:** `0`, `100`, `200`, `300`, `400`, `500`, `600`, `700`, `800`, `900`, `1000`
|
|
897
|
+
- **Arbitrary:** `perspective-[1500]`, `perspective-[2000]`
|
|
898
|
+
|
|
899
|
+
**Examples:**
|
|
900
|
+
|
|
901
|
+
```tsx
|
|
902
|
+
// Scale
|
|
903
|
+
<View className="scale-110 p-4">
|
|
904
|
+
{/* 110% scale (1.1x larger) */}
|
|
905
|
+
<Text>Scaled content</Text>
|
|
906
|
+
</View>
|
|
907
|
+
|
|
908
|
+
// Rotate
|
|
909
|
+
<View className="rotate-45 w-16 h-16 bg-blue-500" />
|
|
910
|
+
|
|
911
|
+
// Translate
|
|
912
|
+
<View className="translate-x-4 translate-y-2 bg-red-500 p-4">
|
|
913
|
+
{/* Moved 16px right, 8px down */}
|
|
914
|
+
</View>
|
|
915
|
+
|
|
916
|
+
// Arbitrary values
|
|
917
|
+
<View className="scale-[1.23] w-16 h-16 bg-green-500" />
|
|
918
|
+
<View className="rotate-[37deg] w-16 h-16 bg-purple-500" />
|
|
919
|
+
<View className="translate-x-[50px] bg-orange-500 p-4" />
|
|
920
|
+
|
|
921
|
+
// Negative values
|
|
922
|
+
<View className="-rotate-45 w-16 h-16 bg-pink-500" />
|
|
923
|
+
<View className="-translate-x-4 -translate-y-2 bg-indigo-500 p-4" />
|
|
924
|
+
|
|
925
|
+
// 3D rotation
|
|
926
|
+
<View className="rotate-x-45 w-16 h-16 bg-yellow-500" />
|
|
927
|
+
<View className="rotate-y-30 w-16 h-16 bg-teal-500" />
|
|
928
|
+
|
|
929
|
+
// Skew
|
|
930
|
+
<View className="skew-x-6 w-16 h-16 bg-cyan-500" />
|
|
931
|
+
|
|
932
|
+
// Perspective
|
|
933
|
+
<View className="perspective-500">
|
|
934
|
+
<View className="rotate-x-45 w-16 h-16 bg-blue-500" />
|
|
935
|
+
</View>
|
|
936
|
+
```
|
|
937
|
+
|
|
938
|
+
**Multiple Transforms Limitation:**
|
|
939
|
+
|
|
940
|
+
Due to the current architecture, multiple transform classes on the same element will overwrite each other. For example:
|
|
941
|
+
|
|
942
|
+
```tsx
|
|
943
|
+
// ❌ Only rotate-45 will apply (overwrites scale-110)
|
|
944
|
+
<View className="scale-110 rotate-45 w-16 h-16 bg-blue-500" />
|
|
945
|
+
|
|
946
|
+
// ✅ Workaround: Use nested Views for multiple transforms
|
|
947
|
+
<View className="scale-110">
|
|
948
|
+
<View className="rotate-45">
|
|
949
|
+
<View className="w-16 h-16 bg-blue-500" />
|
|
950
|
+
</View>
|
|
951
|
+
</View>
|
|
952
|
+
```
|
|
953
|
+
|
|
954
|
+
This limitation exists because the current parser architecture uses `Object.assign()` which overwrites the `transform` property when multiple transform classes are present. This will be addressed in a future update by modifying the Babel plugin to detect multiple transform classes and generate style arrays.
|
|
955
|
+
|
|
956
|
+
**What's Not Supported:**
|
|
957
|
+
|
|
958
|
+
- `transform-origin` — Not available in React Native (transforms always use center as origin)
|
|
959
|
+
- Multiple transforms on one element — Use nested Views (see workaround above)
|
|
960
|
+
|
|
961
|
+
> **Note:** All transform parsing happens at compile-time with zero runtime overhead. Each transform compiles to a React Native transform array: `transform: [{ scale: 1.1 }]`, `transform: [{ rotate: '45deg' }]`, etc.
|
|
962
|
+
|
|
861
963
|
### Sizing
|
|
862
964
|
|
|
863
965
|
- `w-{size}`, `h-{size}` — Width/height
|
|
@@ -889,6 +991,12 @@ Use arbitrary values for custom sizes, spacing, and borders not in the preset sc
|
|
|
889
991
|
- **Sizing:** `w-[...]`, `h-[...]`, `min-w-[...]`, `min-h-[...]`, `max-w-[...]`, `max-h-[...]` (px and %)
|
|
890
992
|
- **Border width:** `border-[...]`, `border-t-[...]`, `border-r-[...]`, `border-b-[...]`, `border-l-[...]` (px only)
|
|
891
993
|
- **Border radius:** `rounded-[...]`, `rounded-t-[...]`, `rounded-tl-[...]`, etc. (px only)
|
|
994
|
+
- **Transforms:**
|
|
995
|
+
- **Scale:** `scale-[...]`, `scale-x-[...]`, `scale-y-[...]` (number only, e.g., `[1.23]`)
|
|
996
|
+
- **Rotate:** `rotate-[...]`, `rotate-x-[...]`, `rotate-y-[...]`, `rotate-z-[...]` (deg only, e.g., `[37deg]`)
|
|
997
|
+
- **Translate:** `translate-x-[...]`, `translate-y-[...]` (px or %, e.g., `[50px]` or `[50%]`)
|
|
998
|
+
- **Skew:** `skew-x-[...]`, `skew-y-[...]` (deg only, e.g., `[15deg]`)
|
|
999
|
+
- **Perspective:** `perspective-[...]` (number only, e.g., `[1500]`)
|
|
892
1000
|
|
|
893
1001
|
**Formats:**
|
|
894
1002
|
|
package/dist/babel/index.cjs
CHANGED
|
@@ -429,6 +429,9 @@ function parseColor(cls, customColors) {
|
|
|
429
429
|
};
|
|
430
430
|
if (cls.startsWith("bg-")) {
|
|
431
431
|
const colorKey = cls.substring(3);
|
|
432
|
+
if (colorKey.startsWith("[") && !colorKey.startsWith("[#")) {
|
|
433
|
+
return null;
|
|
434
|
+
}
|
|
432
435
|
const color = parseColorWithOpacity(colorKey);
|
|
433
436
|
if (color) {
|
|
434
437
|
return { backgroundColor: color };
|
|
@@ -436,6 +439,9 @@ function parseColor(cls, customColors) {
|
|
|
436
439
|
}
|
|
437
440
|
if (cls.startsWith("text-")) {
|
|
438
441
|
const colorKey = cls.substring(5);
|
|
442
|
+
if (colorKey.startsWith("[") && !colorKey.startsWith("[#")) {
|
|
443
|
+
return null;
|
|
444
|
+
}
|
|
439
445
|
const color = parseColorWithOpacity(colorKey);
|
|
440
446
|
if (color) {
|
|
441
447
|
return { color };
|
|
@@ -443,6 +449,9 @@ function parseColor(cls, customColors) {
|
|
|
443
449
|
}
|
|
444
450
|
if (cls.startsWith("border-") && !cls.match(/^border-[0-9]/)) {
|
|
445
451
|
const colorKey = cls.substring(7);
|
|
452
|
+
if (colorKey.startsWith("[") && !colorKey.startsWith("[#")) {
|
|
453
|
+
return null;
|
|
454
|
+
}
|
|
446
455
|
const color = parseColorWithOpacity(colorKey);
|
|
447
456
|
if (color) {
|
|
448
457
|
return { borderColor: color };
|
|
@@ -1050,6 +1059,284 @@ function getPaddingStyle(dir, value) {
|
|
|
1050
1059
|
}
|
|
1051
1060
|
}
|
|
1052
1061
|
|
|
1062
|
+
// src/parser/transforms.ts
|
|
1063
|
+
var SCALE_MAP = {
|
|
1064
|
+
0: 0,
|
|
1065
|
+
50: 0.5,
|
|
1066
|
+
75: 0.75,
|
|
1067
|
+
90: 0.9,
|
|
1068
|
+
95: 0.95,
|
|
1069
|
+
100: 1,
|
|
1070
|
+
105: 1.05,
|
|
1071
|
+
110: 1.1,
|
|
1072
|
+
125: 1.25,
|
|
1073
|
+
150: 1.5,
|
|
1074
|
+
200: 2
|
|
1075
|
+
};
|
|
1076
|
+
var ROTATE_MAP = {
|
|
1077
|
+
0: 0,
|
|
1078
|
+
1: 1,
|
|
1079
|
+
2: 2,
|
|
1080
|
+
3: 3,
|
|
1081
|
+
6: 6,
|
|
1082
|
+
12: 12,
|
|
1083
|
+
45: 45,
|
|
1084
|
+
90: 90,
|
|
1085
|
+
180: 180
|
|
1086
|
+
};
|
|
1087
|
+
var SKEW_MAP = {
|
|
1088
|
+
0: 0,
|
|
1089
|
+
1: 1,
|
|
1090
|
+
2: 2,
|
|
1091
|
+
3: 3,
|
|
1092
|
+
6: 6,
|
|
1093
|
+
12: 12
|
|
1094
|
+
};
|
|
1095
|
+
var PERSPECTIVE_SCALE = {
|
|
1096
|
+
0: 0,
|
|
1097
|
+
100: 100,
|
|
1098
|
+
200: 200,
|
|
1099
|
+
300: 300,
|
|
1100
|
+
400: 400,
|
|
1101
|
+
500: 500,
|
|
1102
|
+
600: 600,
|
|
1103
|
+
700: 700,
|
|
1104
|
+
800: 800,
|
|
1105
|
+
900: 900,
|
|
1106
|
+
1e3: 1e3
|
|
1107
|
+
};
|
|
1108
|
+
function parseArbitraryScale(value) {
|
|
1109
|
+
const scaleMatch = value.match(/^\[(-?\d+(?:\.\d+)?)\]$/);
|
|
1110
|
+
if (scaleMatch) {
|
|
1111
|
+
return parseFloat(scaleMatch[1]);
|
|
1112
|
+
}
|
|
1113
|
+
if (value.startsWith("[") && value.endsWith("]")) {
|
|
1114
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1115
|
+
console.warn(
|
|
1116
|
+
`[react-native-tailwind] Invalid arbitrary scale value: ${value}. Only numbers are supported (e.g., [1.5], [0.75]).`
|
|
1117
|
+
);
|
|
1118
|
+
}
|
|
1119
|
+
return null;
|
|
1120
|
+
}
|
|
1121
|
+
return null;
|
|
1122
|
+
}
|
|
1123
|
+
function parseArbitraryRotation(value) {
|
|
1124
|
+
const rotateMatch = value.match(/^\[(-?\d+(?:\.\d+)?)deg\]$/);
|
|
1125
|
+
if (rotateMatch) {
|
|
1126
|
+
return `${rotateMatch[1]}deg`;
|
|
1127
|
+
}
|
|
1128
|
+
if (value.startsWith("[") && value.endsWith("]")) {
|
|
1129
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1130
|
+
console.warn(
|
|
1131
|
+
`[react-native-tailwind] Invalid arbitrary rotation value: ${value}. Only deg unit is supported (e.g., [45deg], [-15deg]).`
|
|
1132
|
+
);
|
|
1133
|
+
}
|
|
1134
|
+
return null;
|
|
1135
|
+
}
|
|
1136
|
+
return null;
|
|
1137
|
+
}
|
|
1138
|
+
function parseArbitraryTranslation(value) {
|
|
1139
|
+
const pxMatch = value.match(/^\[(-?\d+)(?:px)?\]$/);
|
|
1140
|
+
if (pxMatch) {
|
|
1141
|
+
return parseInt(pxMatch[1], 10);
|
|
1142
|
+
}
|
|
1143
|
+
const percentMatch = value.match(/^\[(-?\d+(?:\.\d+)?)%\]$/);
|
|
1144
|
+
if (percentMatch) {
|
|
1145
|
+
return `${percentMatch[1]}%`;
|
|
1146
|
+
}
|
|
1147
|
+
if (value.startsWith("[") && value.endsWith("]")) {
|
|
1148
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1149
|
+
console.warn(
|
|
1150
|
+
`[react-native-tailwind] Unsupported arbitrary translation unit: ${value}. Only px and % are supported.`
|
|
1151
|
+
);
|
|
1152
|
+
}
|
|
1153
|
+
return null;
|
|
1154
|
+
}
|
|
1155
|
+
return null;
|
|
1156
|
+
}
|
|
1157
|
+
function parseArbitraryPerspective(value) {
|
|
1158
|
+
const perspectiveMatch = value.match(/^\[(-?\d+)\]$/);
|
|
1159
|
+
if (perspectiveMatch) {
|
|
1160
|
+
return parseInt(perspectiveMatch[1], 10);
|
|
1161
|
+
}
|
|
1162
|
+
if (value.startsWith("[") && value.endsWith("]")) {
|
|
1163
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1164
|
+
console.warn(
|
|
1165
|
+
`[react-native-tailwind] Invalid arbitrary perspective value: ${value}. Only integers are supported (e.g., [1500]).`
|
|
1166
|
+
);
|
|
1167
|
+
}
|
|
1168
|
+
return null;
|
|
1169
|
+
}
|
|
1170
|
+
return null;
|
|
1171
|
+
}
|
|
1172
|
+
function parseTransform(cls) {
|
|
1173
|
+
if (cls.startsWith("origin-")) {
|
|
1174
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1175
|
+
console.warn(
|
|
1176
|
+
`[react-native-tailwind] transform-origin is not supported in React Native. Class "${cls}" will be ignored.`
|
|
1177
|
+
);
|
|
1178
|
+
}
|
|
1179
|
+
return null;
|
|
1180
|
+
}
|
|
1181
|
+
if (cls.startsWith("scale-")) {
|
|
1182
|
+
const scaleKey = cls.substring(6);
|
|
1183
|
+
const arbitraryScale = parseArbitraryScale(scaleKey);
|
|
1184
|
+
if (arbitraryScale !== null) {
|
|
1185
|
+
return { transform: [{ scale: arbitraryScale }] };
|
|
1186
|
+
}
|
|
1187
|
+
const scaleValue = SCALE_MAP[scaleKey];
|
|
1188
|
+
if (scaleValue !== void 0) {
|
|
1189
|
+
return { transform: [{ scale: scaleValue }] };
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
if (cls.startsWith("scale-x-")) {
|
|
1193
|
+
const scaleKey = cls.substring(8);
|
|
1194
|
+
const arbitraryScale = parseArbitraryScale(scaleKey);
|
|
1195
|
+
if (arbitraryScale !== null) {
|
|
1196
|
+
return { transform: [{ scaleX: arbitraryScale }] };
|
|
1197
|
+
}
|
|
1198
|
+
const scaleValue = SCALE_MAP[scaleKey];
|
|
1199
|
+
if (scaleValue !== void 0) {
|
|
1200
|
+
return { transform: [{ scaleX: scaleValue }] };
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
if (cls.startsWith("scale-y-")) {
|
|
1204
|
+
const scaleKey = cls.substring(8);
|
|
1205
|
+
const arbitraryScale = parseArbitraryScale(scaleKey);
|
|
1206
|
+
if (arbitraryScale !== null) {
|
|
1207
|
+
return { transform: [{ scaleY: arbitraryScale }] };
|
|
1208
|
+
}
|
|
1209
|
+
const scaleValue = SCALE_MAP[scaleKey];
|
|
1210
|
+
if (scaleValue !== void 0) {
|
|
1211
|
+
return { transform: [{ scaleY: scaleValue }] };
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
if (cls.startsWith("rotate-") || cls.startsWith("-rotate-")) {
|
|
1215
|
+
const isNegative = cls.startsWith("-");
|
|
1216
|
+
const rotateKey = isNegative ? cls.substring(8) : cls.substring(7);
|
|
1217
|
+
const arbitraryRotate = parseArbitraryRotation(rotateKey);
|
|
1218
|
+
if (arbitraryRotate !== null) {
|
|
1219
|
+
const degrees = isNegative ? `-${arbitraryRotate}` : arbitraryRotate;
|
|
1220
|
+
return { transform: [{ rotate: degrees }] };
|
|
1221
|
+
}
|
|
1222
|
+
const rotateValue = ROTATE_MAP[rotateKey];
|
|
1223
|
+
if (rotateValue !== void 0) {
|
|
1224
|
+
const degrees = isNegative ? -rotateValue : rotateValue;
|
|
1225
|
+
return { transform: [{ rotate: `${degrees}deg` }] };
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
if (cls.startsWith("rotate-x-") || cls.startsWith("-rotate-x-")) {
|
|
1229
|
+
const isNegative = cls.startsWith("-");
|
|
1230
|
+
const rotateKey = isNegative ? cls.substring(10) : cls.substring(9);
|
|
1231
|
+
const arbitraryRotate = parseArbitraryRotation(rotateKey);
|
|
1232
|
+
if (arbitraryRotate !== null) {
|
|
1233
|
+
const degrees = isNegative ? `-${arbitraryRotate}` : arbitraryRotate;
|
|
1234
|
+
return { transform: [{ rotateX: degrees }] };
|
|
1235
|
+
}
|
|
1236
|
+
const rotateValue = ROTATE_MAP[rotateKey];
|
|
1237
|
+
if (rotateValue !== void 0) {
|
|
1238
|
+
const degrees = isNegative ? -rotateValue : rotateValue;
|
|
1239
|
+
return { transform: [{ rotateX: `${degrees}deg` }] };
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
if (cls.startsWith("rotate-y-") || cls.startsWith("-rotate-y-")) {
|
|
1243
|
+
const isNegative = cls.startsWith("-");
|
|
1244
|
+
const rotateKey = isNegative ? cls.substring(10) : cls.substring(9);
|
|
1245
|
+
const arbitraryRotate = parseArbitraryRotation(rotateKey);
|
|
1246
|
+
if (arbitraryRotate !== null) {
|
|
1247
|
+
const degrees = isNegative ? `-${arbitraryRotate}` : arbitraryRotate;
|
|
1248
|
+
return { transform: [{ rotateY: degrees }] };
|
|
1249
|
+
}
|
|
1250
|
+
const rotateValue = ROTATE_MAP[rotateKey];
|
|
1251
|
+
if (rotateValue !== void 0) {
|
|
1252
|
+
const degrees = isNegative ? -rotateValue : rotateValue;
|
|
1253
|
+
return { transform: [{ rotateY: `${degrees}deg` }] };
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
if (cls.startsWith("rotate-z-") || cls.startsWith("-rotate-z-")) {
|
|
1257
|
+
const isNegative = cls.startsWith("-");
|
|
1258
|
+
const rotateKey = isNegative ? cls.substring(10) : cls.substring(9);
|
|
1259
|
+
const arbitraryRotate = parseArbitraryRotation(rotateKey);
|
|
1260
|
+
if (arbitraryRotate !== null) {
|
|
1261
|
+
const degrees = isNegative ? `-${arbitraryRotate}` : arbitraryRotate;
|
|
1262
|
+
return { transform: [{ rotateZ: degrees }] };
|
|
1263
|
+
}
|
|
1264
|
+
const rotateValue = ROTATE_MAP[rotateKey];
|
|
1265
|
+
if (rotateValue !== void 0) {
|
|
1266
|
+
const degrees = isNegative ? -rotateValue : rotateValue;
|
|
1267
|
+
return { transform: [{ rotateZ: `${degrees}deg` }] };
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
if (cls.startsWith("translate-x-") || cls.startsWith("-translate-x-")) {
|
|
1271
|
+
const isNegative = cls.startsWith("-");
|
|
1272
|
+
const translateKey = isNegative ? cls.substring(13) : cls.substring(12);
|
|
1273
|
+
const arbitraryTranslate = parseArbitraryTranslation(translateKey);
|
|
1274
|
+
if (arbitraryTranslate !== null) {
|
|
1275
|
+
const value = typeof arbitraryTranslate === "number" ? isNegative ? -arbitraryTranslate : arbitraryTranslate : isNegative ? `-${arbitraryTranslate}` : arbitraryTranslate;
|
|
1276
|
+
return { transform: [{ translateX: value }] };
|
|
1277
|
+
}
|
|
1278
|
+
const translateValue = SPACING_SCALE[translateKey];
|
|
1279
|
+
if (translateValue !== void 0) {
|
|
1280
|
+
const value = isNegative ? -translateValue : translateValue;
|
|
1281
|
+
return { transform: [{ translateX: value }] };
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
if (cls.startsWith("translate-y-") || cls.startsWith("-translate-y-")) {
|
|
1285
|
+
const isNegative = cls.startsWith("-");
|
|
1286
|
+
const translateKey = isNegative ? cls.substring(13) : cls.substring(12);
|
|
1287
|
+
const arbitraryTranslate = parseArbitraryTranslation(translateKey);
|
|
1288
|
+
if (arbitraryTranslate !== null) {
|
|
1289
|
+
const value = typeof arbitraryTranslate === "number" ? isNegative ? -arbitraryTranslate : arbitraryTranslate : isNegative ? `-${arbitraryTranslate}` : arbitraryTranslate;
|
|
1290
|
+
return { transform: [{ translateY: value }] };
|
|
1291
|
+
}
|
|
1292
|
+
const translateValue = SPACING_SCALE[translateKey];
|
|
1293
|
+
if (translateValue !== void 0) {
|
|
1294
|
+
const value = isNegative ? -translateValue : translateValue;
|
|
1295
|
+
return { transform: [{ translateY: value }] };
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
if (cls.startsWith("skew-x-") || cls.startsWith("-skew-x-")) {
|
|
1299
|
+
const isNegative = cls.startsWith("-");
|
|
1300
|
+
const skewKey = isNegative ? cls.substring(8) : cls.substring(7);
|
|
1301
|
+
const arbitrarySkew = parseArbitraryRotation(skewKey);
|
|
1302
|
+
if (arbitrarySkew !== null) {
|
|
1303
|
+
const degrees = isNegative ? `-${arbitrarySkew}` : arbitrarySkew;
|
|
1304
|
+
return { transform: [{ skewX: degrees }] };
|
|
1305
|
+
}
|
|
1306
|
+
const skewValue = SKEW_MAP[skewKey];
|
|
1307
|
+
if (skewValue !== void 0) {
|
|
1308
|
+
const degrees = isNegative ? -skewValue : skewValue;
|
|
1309
|
+
return { transform: [{ skewX: `${degrees}deg` }] };
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
if (cls.startsWith("skew-y-") || cls.startsWith("-skew-y-")) {
|
|
1313
|
+
const isNegative = cls.startsWith("-");
|
|
1314
|
+
const skewKey = isNegative ? cls.substring(8) : cls.substring(7);
|
|
1315
|
+
const arbitrarySkew = parseArbitraryRotation(skewKey);
|
|
1316
|
+
if (arbitrarySkew !== null) {
|
|
1317
|
+
const degrees = isNegative ? `-${arbitrarySkew}` : arbitrarySkew;
|
|
1318
|
+
return { transform: [{ skewY: degrees }] };
|
|
1319
|
+
}
|
|
1320
|
+
const skewValue = SKEW_MAP[skewKey];
|
|
1321
|
+
if (skewValue !== void 0) {
|
|
1322
|
+
const degrees = isNegative ? -skewValue : skewValue;
|
|
1323
|
+
return { transform: [{ skewY: `${degrees}deg` }] };
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
if (cls.startsWith("perspective-")) {
|
|
1327
|
+
const perspectiveKey = cls.substring(12);
|
|
1328
|
+
const arbitraryPerspective = parseArbitraryPerspective(perspectiveKey);
|
|
1329
|
+
if (arbitraryPerspective !== null) {
|
|
1330
|
+
return { transform: [{ perspective: arbitraryPerspective }] };
|
|
1331
|
+
}
|
|
1332
|
+
const perspectiveValue = PERSPECTIVE_SCALE[perspectiveKey];
|
|
1333
|
+
if (perspectiveValue !== void 0) {
|
|
1334
|
+
return { transform: [{ perspective: perspectiveValue }] };
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
return null;
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1053
1340
|
// src/parser/typography.ts
|
|
1054
1341
|
var FONT_SIZES = {
|
|
1055
1342
|
xs: 12,
|
|
@@ -1223,7 +1510,8 @@ function parseClass(cls, customColors) {
|
|
|
1223
1510
|
parseTypography,
|
|
1224
1511
|
parseSizing,
|
|
1225
1512
|
parseShadow,
|
|
1226
|
-
parseAspectRatio
|
|
1513
|
+
parseAspectRatio,
|
|
1514
|
+
parseTransform
|
|
1227
1515
|
];
|
|
1228
1516
|
for (const parser of parsers) {
|
|
1229
1517
|
const result = parser(cls);
|
package/dist/parser/colors.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});exports.COLORS=void 0;exports.parseColor=parseColor;var COLORS=exports.COLORS={"gray-50":"#F9FAFB","gray-100":"#F3F4F6","gray-200":"#E5E7EB","gray-300":"#D1D5DB","gray-400":"#9CA3AF","gray-500":"#6B7280","gray-600":"#4B5563","gray-700":"#374151","gray-800":"#1F2937","gray-900":"#111827","red-50":"#FEF2F2","red-100":"#FEE2E2","red-200":"#FECACA","red-300":"#FCA5A5","red-400":"#F87171","red-500":"#EF4444","red-600":"#DC2626","red-700":"#B91C1C","red-800":"#991B1B","red-900":"#7F1D1D","blue-50":"#EFF6FF","blue-100":"#DBEAFE","blue-200":"#BFDBFE","blue-300":"#93C5FD","blue-400":"#60A5FA","blue-500":"#3B82F6","blue-600":"#2563EB","blue-700":"#1D4ED8","blue-800":"#1E40AF","blue-900":"#1E3A8A","green-50":"#F0FDF4","green-100":"#DCFCE7","green-200":"#BBF7D0","green-300":"#86EFAC","green-400":"#4ADE80","green-500":"#22C55E","green-600":"#16A34A","green-700":"#15803D","green-800":"#166534","green-900":"#14532D","yellow-50":"#FEFCE8","yellow-100":"#FEF9C3","yellow-200":"#FEF08A","yellow-300":"#FDE047","yellow-400":"#FACC15","yellow-500":"#EAB308","yellow-600":"#CA8A04","yellow-700":"#A16207","yellow-800":"#854D0E","yellow-900":"#713F12","purple-50":"#FAF5FF","purple-100":"#F3E8FF","purple-200":"#E9D5FF","purple-300":"#D8B4FE","purple-400":"#C084FC","purple-500":"#A855F7","purple-600":"#9333EA","purple-700":"#7E22CE","purple-800":"#6B21A8","purple-900":"#581C87","pink-50":"#FDF2F8","pink-100":"#FCE7F3","pink-200":"#FBCFE8","pink-300":"#F9A8D4","pink-400":"#F472B6","pink-500":"#EC4899","pink-600":"#DB2777","pink-700":"#BE185D","pink-800":"#9D174D","pink-900":"#831843","orange-50":"#FFF7ED","orange-100":"#FFEDD5","orange-200":"#FED7AA","orange-300":"#FDBA74","orange-400":"#FB923C","orange-500":"#F97316","orange-600":"#EA580C","orange-700":"#C2410C","orange-800":"#9A3412","orange-900":"#7C2D12","indigo-50":"#EEF2FF","indigo-100":"#E0E7FF","indigo-200":"#C7D2FE","indigo-300":"#A5B4FC","indigo-400":"#818CF8","indigo-500":"#6366F1","indigo-600":"#4F46E5","indigo-700":"#4338CA","indigo-800":"#3730A3","indigo-900":"#312E81",white:"#FFFFFF",black:"#000000",transparent:"transparent"};function applyOpacity(hex,opacity){if(hex==="transparent"){return"transparent";}var cleanHex=hex.replace(/^#/,"");var fullHex=cleanHex.length===3?cleanHex.split("").map(function(char){return char+char;}).join(""):cleanHex;var alpha=Math.round(opacity/100*255);var alphaHex=alpha.toString(16).padStart(2,"0").toUpperCase();return`#${fullHex.toUpperCase()}${alphaHex}`;}function parseArbitraryColor(value){var hexMatch=value.match(/^\[#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})\]$/);if(hexMatch){var hex=hexMatch[1];if(hex.length===3){var expanded=hex.split("").map(function(char){return char+char;}).join("");return`#${expanded}`;}return`#${hex}`;}if(value.startsWith("[")&&value.endsWith("]")){if(process.env.NODE_ENV!=="production"){console.warn(`[react-native-tailwind] Unsupported arbitrary color value: ${value}. Only hex colors are supported (e.g., [#ff0000], [#f00], or [#ff0000aa]).`);}return null;}return null;}function parseColor(cls,customColors){var getColor=function getColor(key){var _customColors$key;return(_customColors$key=customColors==null?void 0:customColors[key])!=null?_customColors$key:COLORS[key];};var parseColorWithOpacity=function parseColorWithOpacity(colorKey){var _getColor;var opacityMatch=colorKey.match(/^(.+)\/(\d+)$/);if(opacityMatch){var baseColorKey=opacityMatch[1];var opacity=Number.parseInt(opacityMatch[2],10);if(opacity<0||opacity>100){if(process.env.NODE_ENV!=="production"){console.warn(`[react-native-tailwind] Invalid opacity value: ${opacity}. Opacity must be between 0 and 100.`);}return null;}var _arbitraryColor=parseArbitraryColor(baseColorKey);if(_arbitraryColor!==null){return applyOpacity(_arbitraryColor,opacity);}var color=getColor(baseColorKey);if(color){return applyOpacity(color,opacity);}return null;}var arbitraryColor=parseArbitraryColor(colorKey);if(arbitraryColor!==null){return arbitraryColor;}return(_getColor=getColor(colorKey))!=null?_getColor:null;};if(cls.startsWith("bg-")){var colorKey=cls.substring(3);var color=parseColorWithOpacity(colorKey);if(color){return{backgroundColor:color};}}if(cls.startsWith("text-")){var _colorKey=cls.substring(5);var _color=parseColorWithOpacity(_colorKey);if(_color){return{color:_color};}}if(cls.startsWith("border-")&&!cls.match(/^border-[0-9]/)){var _colorKey2=cls.substring(7);var _color2=parseColorWithOpacity(_colorKey2);if(_color2){return{borderColor:_color2};}}return null;}
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.COLORS=void 0;exports.parseColor=parseColor;var COLORS=exports.COLORS={"gray-50":"#F9FAFB","gray-100":"#F3F4F6","gray-200":"#E5E7EB","gray-300":"#D1D5DB","gray-400":"#9CA3AF","gray-500":"#6B7280","gray-600":"#4B5563","gray-700":"#374151","gray-800":"#1F2937","gray-900":"#111827","red-50":"#FEF2F2","red-100":"#FEE2E2","red-200":"#FECACA","red-300":"#FCA5A5","red-400":"#F87171","red-500":"#EF4444","red-600":"#DC2626","red-700":"#B91C1C","red-800":"#991B1B","red-900":"#7F1D1D","blue-50":"#EFF6FF","blue-100":"#DBEAFE","blue-200":"#BFDBFE","blue-300":"#93C5FD","blue-400":"#60A5FA","blue-500":"#3B82F6","blue-600":"#2563EB","blue-700":"#1D4ED8","blue-800":"#1E40AF","blue-900":"#1E3A8A","green-50":"#F0FDF4","green-100":"#DCFCE7","green-200":"#BBF7D0","green-300":"#86EFAC","green-400":"#4ADE80","green-500":"#22C55E","green-600":"#16A34A","green-700":"#15803D","green-800":"#166534","green-900":"#14532D","yellow-50":"#FEFCE8","yellow-100":"#FEF9C3","yellow-200":"#FEF08A","yellow-300":"#FDE047","yellow-400":"#FACC15","yellow-500":"#EAB308","yellow-600":"#CA8A04","yellow-700":"#A16207","yellow-800":"#854D0E","yellow-900":"#713F12","purple-50":"#FAF5FF","purple-100":"#F3E8FF","purple-200":"#E9D5FF","purple-300":"#D8B4FE","purple-400":"#C084FC","purple-500":"#A855F7","purple-600":"#9333EA","purple-700":"#7E22CE","purple-800":"#6B21A8","purple-900":"#581C87","pink-50":"#FDF2F8","pink-100":"#FCE7F3","pink-200":"#FBCFE8","pink-300":"#F9A8D4","pink-400":"#F472B6","pink-500":"#EC4899","pink-600":"#DB2777","pink-700":"#BE185D","pink-800":"#9D174D","pink-900":"#831843","orange-50":"#FFF7ED","orange-100":"#FFEDD5","orange-200":"#FED7AA","orange-300":"#FDBA74","orange-400":"#FB923C","orange-500":"#F97316","orange-600":"#EA580C","orange-700":"#C2410C","orange-800":"#9A3412","orange-900":"#7C2D12","indigo-50":"#EEF2FF","indigo-100":"#E0E7FF","indigo-200":"#C7D2FE","indigo-300":"#A5B4FC","indigo-400":"#818CF8","indigo-500":"#6366F1","indigo-600":"#4F46E5","indigo-700":"#4338CA","indigo-800":"#3730A3","indigo-900":"#312E81",white:"#FFFFFF",black:"#000000",transparent:"transparent"};function applyOpacity(hex,opacity){if(hex==="transparent"){return"transparent";}var cleanHex=hex.replace(/^#/,"");var fullHex=cleanHex.length===3?cleanHex.split("").map(function(char){return char+char;}).join(""):cleanHex;var alpha=Math.round(opacity/100*255);var alphaHex=alpha.toString(16).padStart(2,"0").toUpperCase();return`#${fullHex.toUpperCase()}${alphaHex}`;}function parseArbitraryColor(value){var hexMatch=value.match(/^\[#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})\]$/);if(hexMatch){var hex=hexMatch[1];if(hex.length===3){var expanded=hex.split("").map(function(char){return char+char;}).join("");return`#${expanded}`;}return`#${hex}`;}if(value.startsWith("[")&&value.endsWith("]")){if(process.env.NODE_ENV!=="production"){console.warn(`[react-native-tailwind] Unsupported arbitrary color value: ${value}. Only hex colors are supported (e.g., [#ff0000], [#f00], or [#ff0000aa]).`);}return null;}return null;}function parseColor(cls,customColors){var getColor=function getColor(key){var _customColors$key;return(_customColors$key=customColors==null?void 0:customColors[key])!=null?_customColors$key:COLORS[key];};var parseColorWithOpacity=function parseColorWithOpacity(colorKey){var _getColor;var opacityMatch=colorKey.match(/^(.+)\/(\d+)$/);if(opacityMatch){var baseColorKey=opacityMatch[1];var opacity=Number.parseInt(opacityMatch[2],10);if(opacity<0||opacity>100){if(process.env.NODE_ENV!=="production"){console.warn(`[react-native-tailwind] Invalid opacity value: ${opacity}. Opacity must be between 0 and 100.`);}return null;}var _arbitraryColor=parseArbitraryColor(baseColorKey);if(_arbitraryColor!==null){return applyOpacity(_arbitraryColor,opacity);}var color=getColor(baseColorKey);if(color){return applyOpacity(color,opacity);}return null;}var arbitraryColor=parseArbitraryColor(colorKey);if(arbitraryColor!==null){return arbitraryColor;}return(_getColor=getColor(colorKey))!=null?_getColor:null;};if(cls.startsWith("bg-")){var colorKey=cls.substring(3);if(colorKey.startsWith("[")&&!colorKey.startsWith("[#")){return null;}var color=parseColorWithOpacity(colorKey);if(color){return{backgroundColor:color};}}if(cls.startsWith("text-")){var _colorKey=cls.substring(5);if(_colorKey.startsWith("[")&&!_colorKey.startsWith("[#")){return null;}var _color=parseColorWithOpacity(_colorKey);if(_color){return{color:_color};}}if(cls.startsWith("border-")&&!cls.match(/^border-[0-9]/)){var _colorKey2=cls.substring(7);if(_colorKey2.startsWith("[")&&!_colorKey2.startsWith("[#")){return null;}var _color2=parseColorWithOpacity(_colorKey2);if(_color2){return{borderColor:_color2};}}return null;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var _vitest=require("vitest");var _colors=require("./colors");(0,_vitest.describe)("COLORS",function(){(0,_vitest.it)("should export complete color palette",function(){(0,_vitest.expect)(_colors.COLORS).toMatchSnapshot();});});(0,_vitest.describe)("parseColor - background colors",function(){(0,_vitest.it)("should parse background colors with preset values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-blue-500")).toEqual({backgroundColor:"#3B82F6"});(0,_vitest.expect)((0,_colors.parseColor)("bg-red-500")).toEqual({backgroundColor:"#EF4444"});(0,_vitest.expect)((0,_colors.parseColor)("bg-green-500")).toEqual({backgroundColor:"#22C55E"});(0,_vitest.expect)((0,_colors.parseColor)("bg-gray-300")).toEqual({backgroundColor:"#D1D5DB"});});(0,_vitest.it)("should parse background colors with basic values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-white")).toEqual({backgroundColor:"#FFFFFF"});(0,_vitest.expect)((0,_colors.parseColor)("bg-black")).toEqual({backgroundColor:"#000000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-transparent")).toEqual({backgroundColor:"transparent"});});(0,_vitest.it)("should parse background colors with arbitrary 6-digit hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000]")).toEqual({backgroundColor:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#3B82F6]")).toEqual({backgroundColor:"#3B82F6"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#000000]")).toEqual({backgroundColor:"#000000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#FFFFFF]")).toEqual({backgroundColor:"#FFFFFF"});});(0,_vitest.it)("should parse background colors with arbitrary 3-digit hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#f00]")).toEqual({backgroundColor:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#abc]")).toEqual({backgroundColor:"#aabbcc"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#123]")).toEqual({backgroundColor:"#112233"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#FFF]")).toEqual({backgroundColor:"#FFFFFF"});});(0,_vitest.it)("should parse background colors with arbitrary 8-digit hex values (with alpha)",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000aa]")).toEqual({backgroundColor:"#ff0000aa"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#3B82F680]")).toEqual({backgroundColor:"#3B82F680"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#00000000]")).toEqual({backgroundColor:"#00000000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#FFFFFFFF]")).toEqual({backgroundColor:"#FFFFFFFF"});});(0,_vitest.it)("should handle case-insensitive hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#FF0000]")).toEqual({backgroundColor:"#FF0000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000]")).toEqual({backgroundColor:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#Ff0000]")).toEqual({backgroundColor:"#Ff0000"});});(0,_vitest.it)("should prefer arbitrary values over preset colors",function(){var customColors={"[#ff0000]":"#00ff00"};(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000]",customColors)).toEqual({backgroundColor:"#ff0000"});});});(0,_vitest.describe)("parseColor - text colors",function(){(0,_vitest.it)("should parse text colors with preset values",function(){(0,_vitest.expect)((0,_colors.parseColor)("text-blue-500")).toEqual({color:"#3B82F6"});(0,_vitest.expect)((0,_colors.parseColor)("text-red-500")).toEqual({color:"#EF4444"});(0,_vitest.expect)((0,_colors.parseColor)("text-green-500")).toEqual({color:"#22C55E"});(0,_vitest.expect)((0,_colors.parseColor)("text-gray-700")).toEqual({color:"#374151"});});(0,_vitest.it)("should parse text colors with basic values",function(){(0,_vitest.expect)((0,_colors.parseColor)("text-white")).toEqual({color:"#FFFFFF"});(0,_vitest.expect)((0,_colors.parseColor)("text-black")).toEqual({color:"#000000"});});(0,_vitest.it)("should parse text colors with arbitrary 6-digit hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("text-[#ff0000]")).toEqual({color:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#3B82F6]")).toEqual({color:"#3B82F6"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#333333]")).toEqual({color:"#333333"});});(0,_vitest.it)("should parse text colors with arbitrary 3-digit hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("text-[#f00]")).toEqual({color:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#abc]")).toEqual({color:"#aabbcc"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#000]")).toEqual({color:"#000000"});});(0,_vitest.it)("should parse text colors with arbitrary 8-digit hex values (with alpha)",function(){(0,_vitest.expect)((0,_colors.parseColor)("text-[#ff0000aa]")).toEqual({color:"#ff0000aa"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#00000080]")).toEqual({color:"#00000080"});});});(0,_vitest.describe)("parseColor - border colors",function(){(0,_vitest.it)("should parse border colors with preset values",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-blue-500")).toEqual({borderColor:"#3B82F6"});(0,_vitest.expect)((0,_colors.parseColor)("border-red-500")).toEqual({borderColor:"#EF4444"});(0,_vitest.expect)((0,_colors.parseColor)("border-green-500")).toEqual({borderColor:"#22C55E"});(0,_vitest.expect)((0,_colors.parseColor)("border-gray-200")).toEqual({borderColor:"#E5E7EB"});});(0,_vitest.it)("should parse border colors with basic values",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-white")).toEqual({borderColor:"#FFFFFF"});(0,_vitest.expect)((0,_colors.parseColor)("border-black")).toEqual({borderColor:"#000000"});(0,_vitest.expect)((0,_colors.parseColor)("border-transparent")).toEqual({borderColor:"transparent"});});(0,_vitest.it)("should parse border colors with arbitrary 6-digit hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-[#ff0000]")).toEqual({borderColor:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#3B82F6]")).toEqual({borderColor:"#3B82F6"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#cccccc]")).toEqual({borderColor:"#cccccc"});});(0,_vitest.it)("should parse border colors with arbitrary 3-digit hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-[#f00]")).toEqual({borderColor:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#abc]")).toEqual({borderColor:"#aabbcc"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#999]")).toEqual({borderColor:"#999999"});});(0,_vitest.it)("should parse border colors with arbitrary 8-digit hex values (with alpha)",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-[#ff0000aa]")).toEqual({borderColor:"#ff0000aa"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#0000FF50]")).toEqual({borderColor:"#0000FF50"});});(0,_vitest.it)("should not match border width classes",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-0")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-2")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-4")).toBeNull();});});(0,_vitest.describe)("parseColor - custom colors",function(){var customColors={"brand-primary":"#FF6B6B","brand-secondary":"#4ECDC4",accent:"#FFE66D"};(0,_vitest.it)("should support custom background colors",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-brand-primary",customColors)).toEqual({backgroundColor:"#FF6B6B"});(0,_vitest.expect)((0,_colors.parseColor)("bg-brand-secondary",customColors)).toEqual({backgroundColor:"#4ECDC4"});(0,_vitest.expect)((0,_colors.parseColor)("bg-accent",customColors)).toEqual({backgroundColor:"#FFE66D"});});(0,_vitest.it)("should support custom text colors",function(){(0,_vitest.expect)((0,_colors.parseColor)("text-brand-primary",customColors)).toEqual({color:"#FF6B6B"});(0,_vitest.expect)((0,_colors.parseColor)("text-brand-secondary",customColors)).toEqual({color:"#4ECDC4"});});(0,_vitest.it)("should support custom border colors",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-brand-primary",customColors)).toEqual({borderColor:"#FF6B6B"});(0,_vitest.expect)((0,_colors.parseColor)("border-accent",customColors)).toEqual({borderColor:"#FFE66D"});});(0,_vitest.it)("should allow custom colors to override preset colors",function(){var overrideColors={"blue-500":"#FF0000"};(0,_vitest.expect)((0,_colors.parseColor)("bg-blue-500",overrideColors)).toEqual({backgroundColor:"#FF0000"});});(0,_vitest.it)("should fallback to preset colors when custom color not found",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-red-500",customColors)).toEqual({backgroundColor:"#EF4444"});});});(0,_vitest.describe)("parseColor - edge cases",function(){(0,_vitest.it)("should return null for invalid classes",function(){(0,_vitest.expect)((0,_colors.parseColor)("invalid")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("text")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border")).toBeNull();});(0,_vitest.it)("should return null for invalid color values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-invalid")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("text-notacolor")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-xyz")).toBeNull();});(0,_vitest.it)("should return null for invalid arbitrary hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ffff]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[#fffff]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[#fffffff]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[#fffffffff]")).toBeNull();});(0,_vitest.it)("should return null for malformed arbitrary values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-#ff0000]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[ff0000]")).toBeNull();});(0,_vitest.it)("should return null for non-hex arbitrary values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#gggggg]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[#zzzzzz]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[rgb(255,0,0)]")).toBeNull();});(0,_vitest.it)("should not match partial class names",function(){(0,_vitest.expect)((0,_colors.parseColor)("background-blue-500")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("textcolor-red-500")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-color-blue-500")).toBeNull();});(0,_vitest.it)("should handle all color scale variants",function(){var scales=["50","100","200","300","400","500","600","700","800","900"];scales.forEach(function(scale){(0,_vitest.expect)((0,_colors.parseColor)(`bg-blue-${scale}`)).toBeTruthy();(0,_vitest.expect)((0,_colors.parseColor)(`text-red-${scale}`)).toBeTruthy();(0,_vitest.expect)((0,_colors.parseColor)(`border-green-${scale}`)).toBeTruthy();});});});(0,_vitest.describe)("parseColor - comprehensive coverage",function(){(0,_vitest.it)("should parse all color types with same preset color",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-blue-500")).toEqual({backgroundColor:"#3B82F6"});(0,_vitest.expect)((0,_colors.parseColor)("text-blue-500")).toEqual({color:"#3B82F6"});(0,_vitest.expect)((0,_colors.parseColor)("border-blue-500")).toEqual({borderColor:"#3B82F6"});});(0,_vitest.it)("should parse all color types with same arbitrary hex",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000]")).toEqual({backgroundColor:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#ff0000]")).toEqual({color:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#ff0000]")).toEqual({borderColor:"#ff0000"});});(0,_vitest.it)("should handle all color families",function(){var families=["gray","red","blue","green","yellow","purple","pink","orange","indigo"];families.forEach(function(family){(0,_vitest.expect)((0,_colors.parseColor)(`bg-${family}-500`)).toBeTruthy();(0,_vitest.expect)((0,_colors.parseColor)(`text-${family}-500`)).toBeTruthy();(0,_vitest.expect)((0,_colors.parseColor)(`border-${family}-500`)).toBeTruthy();});});(0,_vitest.it)("should handle arbitrary values with mixed case",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#AbCdEf]")).toEqual({backgroundColor:"#AbCdEf"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#aBcDeF]")).toEqual({color:"#aBcDeF"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#ABCDEF]")).toEqual({borderColor:"#ABCDEF"});});(0,_vitest.it)("should expand 3-digit hex consistently across all color types",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#abc]")).toEqual({backgroundColor:"#aabbcc"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#abc]")).toEqual({color:"#aabbcc"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#abc]")).toEqual({borderColor:"#aabbcc"});});(0,_vitest.it)("should handle alpha channel consistently across all color types",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000aa]")).toEqual({backgroundColor:"#ff0000aa"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#ff0000aa]")).toEqual({color:"#ff0000aa"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#ff0000aa]")).toEqual({borderColor:"#ff0000aa"});});});(0,_vitest.describe)("parseColor - opacity modifiers",function(){(0,_vitest.it)("should parse background colors with opacity modifiers",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-black/50")).toEqual({backgroundColor:"#00000080"});(0,_vitest.expect)((0,_colors.parseColor)("bg-white/50")).toEqual({backgroundColor:"#FFFFFF80"});(0,_vitest.expect)((0,_colors.parseColor)("bg-blue-500/80")).toEqual({backgroundColor:"#3B82F6CC"});(0,_vitest.expect)((0,_colors.parseColor)("bg-red-500/30")).toEqual({backgroundColor:"#EF44444D"});});(0,_vitest.it)("should parse text colors with opacity modifiers",function(){(0,_vitest.expect)((0,_colors.parseColor)("text-black/80")).toEqual({color:"#000000CC"});(0,_vitest.expect)((0,_colors.parseColor)("text-white/90")).toEqual({color:"#FFFFFFE6"});(0,_vitest.expect)((0,_colors.parseColor)("text-gray-900/70")).toEqual({color:"#111827B3"});(0,_vitest.expect)((0,_colors.parseColor)("text-blue-500/50")).toEqual({color:"#3B82F680"});});(0,_vitest.it)("should parse border colors with opacity modifiers",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-black/25")).toEqual({borderColor:"#00000040"});(0,_vitest.expect)((0,_colors.parseColor)("border-red-500/60")).toEqual({borderColor:"#EF444499"});(0,_vitest.expect)((0,_colors.parseColor)("border-gray-200/40")).toEqual({borderColor:"#E5E7EB66"});});(0,_vitest.it)("should handle opacity modifier with arbitrary hex colors",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000]/50")).toEqual({backgroundColor:"#FF000080"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#3B82F6]/80")).toEqual({color:"#3B82F6CC"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#abc]/60")).toEqual({borderColor:"#AABBCC99"});});(0,_vitest.it)("should handle opacity modifier with custom colors",function(){var customColors={"brand-primary":"#FF6B6B"};(0,_vitest.expect)((0,_colors.parseColor)("bg-brand-primary/50",customColors)).toEqual({backgroundColor:"#FF6B6B80"});(0,_vitest.expect)((0,_colors.parseColor)("text-brand-primary/75",customColors)).toEqual({color:"#FF6B6BBF"});});(0,_vitest.it)("should handle opacity 0 (fully transparent)",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-black/0")).toEqual({backgroundColor:"#00000000"});(0,_vitest.expect)((0,_colors.parseColor)("text-red-500/0")).toEqual({color:"#EF444400"});});(0,_vitest.it)("should handle opacity 100 (fully opaque)",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-black/100")).toEqual({backgroundColor:"#000000FF"});(0,_vitest.expect)((0,_colors.parseColor)("text-blue-500/100")).toEqual({color:"#3B82F6FF"});});(0,_vitest.it)("should handle transparent color with opacity modifier",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-transparent/50")).toEqual({backgroundColor:"transparent"});});(0,_vitest.it)("should convert opacity percentage to correct hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-black/0")).toEqual({backgroundColor:"#00000000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-black/10")).toEqual({backgroundColor:"#0000001A"});(0,_vitest.expect)((0,_colors.parseColor)("bg-black/25")).toEqual({backgroundColor:"#00000040"});(0,_vitest.expect)((0,_colors.parseColor)("bg-black/50")).toEqual({backgroundColor:"#00000080"});(0,_vitest.expect)((0,_colors.parseColor)("bg-black/75")).toEqual({backgroundColor:"#000000BF"});(0,_vitest.expect)((0,_colors.parseColor)("bg-black/100")).toEqual({backgroundColor:"#000000FF"});});(0,_vitest.it)("should return null for invalid opacity values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-black/101")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-black/-1")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-black/150")).toBeNull();});(0,_vitest.it)("should return null for malformed opacity syntax",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-black/")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-black/abc")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-black/50/")).toBeNull();});(0,_vitest.it)("should handle opacity with 3-digit hex expansion",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#f00]/50")).toEqual({backgroundColor:"#FF000080"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#abc]/75")).toEqual({color:"#AABBCCBF"});});(0,_vitest.it)("should work with all color families",function(){var families=["gray","red","blue","green","yellow","purple","pink","orange","indigo"];families.forEach(function(family){(0,_vitest.expect)((0,_colors.parseColor)(`bg-${family}-500/50`)).toBeTruthy();(0,_vitest.expect)((0,_colors.parseColor)(`text-${family}-500/50`)).toBeTruthy();(0,_vitest.expect)((0,_colors.parseColor)(`border-${family}-500/50`)).toBeTruthy();});});});
|
|
1
|
+
var _vitest=require("vitest");var _colors=require("./colors");(0,_vitest.describe)("COLORS",function(){(0,_vitest.it)("should export complete color palette",function(){(0,_vitest.expect)(_colors.COLORS).toMatchSnapshot();});});(0,_vitest.describe)("parseColor - background colors",function(){(0,_vitest.it)("should parse background colors with preset values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-blue-500")).toEqual({backgroundColor:"#3B82F6"});(0,_vitest.expect)((0,_colors.parseColor)("bg-red-500")).toEqual({backgroundColor:"#EF4444"});(0,_vitest.expect)((0,_colors.parseColor)("bg-green-500")).toEqual({backgroundColor:"#22C55E"});(0,_vitest.expect)((0,_colors.parseColor)("bg-gray-300")).toEqual({backgroundColor:"#D1D5DB"});});(0,_vitest.it)("should parse background colors with basic values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-white")).toEqual({backgroundColor:"#FFFFFF"});(0,_vitest.expect)((0,_colors.parseColor)("bg-black")).toEqual({backgroundColor:"#000000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-transparent")).toEqual({backgroundColor:"transparent"});});(0,_vitest.it)("should parse background colors with arbitrary 6-digit hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000]")).toEqual({backgroundColor:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#3B82F6]")).toEqual({backgroundColor:"#3B82F6"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#000000]")).toEqual({backgroundColor:"#000000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#FFFFFF]")).toEqual({backgroundColor:"#FFFFFF"});});(0,_vitest.it)("should parse background colors with arbitrary 3-digit hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#f00]")).toEqual({backgroundColor:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#abc]")).toEqual({backgroundColor:"#aabbcc"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#123]")).toEqual({backgroundColor:"#112233"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#FFF]")).toEqual({backgroundColor:"#FFFFFF"});});(0,_vitest.it)("should parse background colors with arbitrary 8-digit hex values (with alpha)",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000aa]")).toEqual({backgroundColor:"#ff0000aa"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#3B82F680]")).toEqual({backgroundColor:"#3B82F680"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#00000000]")).toEqual({backgroundColor:"#00000000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#FFFFFFFF]")).toEqual({backgroundColor:"#FFFFFFFF"});});(0,_vitest.it)("should handle case-insensitive hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#FF0000]")).toEqual({backgroundColor:"#FF0000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000]")).toEqual({backgroundColor:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#Ff0000]")).toEqual({backgroundColor:"#Ff0000"});});(0,_vitest.it)("should prefer arbitrary values over preset colors",function(){var customColors={"[#ff0000]":"#00ff00"};(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000]",customColors)).toEqual({backgroundColor:"#ff0000"});});});(0,_vitest.describe)("parseColor - text colors",function(){(0,_vitest.it)("should parse text colors with preset values",function(){(0,_vitest.expect)((0,_colors.parseColor)("text-blue-500")).toEqual({color:"#3B82F6"});(0,_vitest.expect)((0,_colors.parseColor)("text-red-500")).toEqual({color:"#EF4444"});(0,_vitest.expect)((0,_colors.parseColor)("text-green-500")).toEqual({color:"#22C55E"});(0,_vitest.expect)((0,_colors.parseColor)("text-gray-700")).toEqual({color:"#374151"});});(0,_vitest.it)("should parse text colors with basic values",function(){(0,_vitest.expect)((0,_colors.parseColor)("text-white")).toEqual({color:"#FFFFFF"});(0,_vitest.expect)((0,_colors.parseColor)("text-black")).toEqual({color:"#000000"});});(0,_vitest.it)("should parse text colors with arbitrary 6-digit hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("text-[#ff0000]")).toEqual({color:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#3B82F6]")).toEqual({color:"#3B82F6"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#333333]")).toEqual({color:"#333333"});});(0,_vitest.it)("should parse text colors with arbitrary 3-digit hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("text-[#f00]")).toEqual({color:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#abc]")).toEqual({color:"#aabbcc"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#000]")).toEqual({color:"#000000"});});(0,_vitest.it)("should parse text colors with arbitrary 8-digit hex values (with alpha)",function(){(0,_vitest.expect)((0,_colors.parseColor)("text-[#ff0000aa]")).toEqual({color:"#ff0000aa"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#00000080]")).toEqual({color:"#00000080"});});});(0,_vitest.describe)("parseColor - border colors",function(){(0,_vitest.it)("should parse border colors with preset values",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-blue-500")).toEqual({borderColor:"#3B82F6"});(0,_vitest.expect)((0,_colors.parseColor)("border-red-500")).toEqual({borderColor:"#EF4444"});(0,_vitest.expect)((0,_colors.parseColor)("border-green-500")).toEqual({borderColor:"#22C55E"});(0,_vitest.expect)((0,_colors.parseColor)("border-gray-200")).toEqual({borderColor:"#E5E7EB"});});(0,_vitest.it)("should parse border colors with basic values",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-white")).toEqual({borderColor:"#FFFFFF"});(0,_vitest.expect)((0,_colors.parseColor)("border-black")).toEqual({borderColor:"#000000"});(0,_vitest.expect)((0,_colors.parseColor)("border-transparent")).toEqual({borderColor:"transparent"});});(0,_vitest.it)("should parse border colors with arbitrary 6-digit hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-[#ff0000]")).toEqual({borderColor:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#3B82F6]")).toEqual({borderColor:"#3B82F6"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#cccccc]")).toEqual({borderColor:"#cccccc"});});(0,_vitest.it)("should parse border colors with arbitrary 3-digit hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-[#f00]")).toEqual({borderColor:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#abc]")).toEqual({borderColor:"#aabbcc"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#999]")).toEqual({borderColor:"#999999"});});(0,_vitest.it)("should parse border colors with arbitrary 8-digit hex values (with alpha)",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-[#ff0000aa]")).toEqual({borderColor:"#ff0000aa"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#0000FF50]")).toEqual({borderColor:"#0000FF50"});});(0,_vitest.it)("should not match border width classes",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-0")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-2")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-4")).toBeNull();});});(0,_vitest.describe)("parseColor - custom colors",function(){var customColors={"brand-primary":"#FF6B6B","brand-secondary":"#4ECDC4",accent:"#FFE66D"};(0,_vitest.it)("should support custom background colors",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-brand-primary",customColors)).toEqual({backgroundColor:"#FF6B6B"});(0,_vitest.expect)((0,_colors.parseColor)("bg-brand-secondary",customColors)).toEqual({backgroundColor:"#4ECDC4"});(0,_vitest.expect)((0,_colors.parseColor)("bg-accent",customColors)).toEqual({backgroundColor:"#FFE66D"});});(0,_vitest.it)("should support custom text colors",function(){(0,_vitest.expect)((0,_colors.parseColor)("text-brand-primary",customColors)).toEqual({color:"#FF6B6B"});(0,_vitest.expect)((0,_colors.parseColor)("text-brand-secondary",customColors)).toEqual({color:"#4ECDC4"});});(0,_vitest.it)("should support custom border colors",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-brand-primary",customColors)).toEqual({borderColor:"#FF6B6B"});(0,_vitest.expect)((0,_colors.parseColor)("border-accent",customColors)).toEqual({borderColor:"#FFE66D"});});(0,_vitest.it)("should allow custom colors to override preset colors",function(){var overrideColors={"blue-500":"#FF0000"};(0,_vitest.expect)((0,_colors.parseColor)("bg-blue-500",overrideColors)).toEqual({backgroundColor:"#FF0000"});});(0,_vitest.it)("should fallback to preset colors when custom color not found",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-red-500",customColors)).toEqual({backgroundColor:"#EF4444"});});});(0,_vitest.describe)("parseColor - edge cases",function(){(0,_vitest.it)("should return null for invalid classes",function(){(0,_vitest.expect)((0,_colors.parseColor)("invalid")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("text")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border")).toBeNull();});(0,_vitest.it)("should return null for invalid color values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-invalid")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("text-notacolor")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-xyz")).toBeNull();});(0,_vitest.it)("should return null for invalid arbitrary hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ffff]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[#fffff]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[#fffffff]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[#fffffffff]")).toBeNull();});(0,_vitest.it)("should return null for malformed arbitrary values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-#ff0000]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[ff0000]")).toBeNull();});(0,_vitest.it)("should return null for non-hex arbitrary values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#gggggg]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[#zzzzzz]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[rgb(255,0,0)]")).toBeNull();});(0,_vitest.it)("should return null for non-color arbitrary values (to let other parsers handle them)",function(){(0,_vitest.expect)((0,_colors.parseColor)("text-[13px]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("text-[18px]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("text-[24]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[100%]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[50px]")).toBeNull();});(0,_vitest.it)("should not match partial class names",function(){(0,_vitest.expect)((0,_colors.parseColor)("background-blue-500")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("textcolor-red-500")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-color-blue-500")).toBeNull();});(0,_vitest.it)("should handle all color scale variants",function(){var scales=["50","100","200","300","400","500","600","700","800","900"];scales.forEach(function(scale){(0,_vitest.expect)((0,_colors.parseColor)(`bg-blue-${scale}`)).toBeTruthy();(0,_vitest.expect)((0,_colors.parseColor)(`text-red-${scale}`)).toBeTruthy();(0,_vitest.expect)((0,_colors.parseColor)(`border-green-${scale}`)).toBeTruthy();});});});(0,_vitest.describe)("parseColor - comprehensive coverage",function(){(0,_vitest.it)("should parse all color types with same preset color",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-blue-500")).toEqual({backgroundColor:"#3B82F6"});(0,_vitest.expect)((0,_colors.parseColor)("text-blue-500")).toEqual({color:"#3B82F6"});(0,_vitest.expect)((0,_colors.parseColor)("border-blue-500")).toEqual({borderColor:"#3B82F6"});});(0,_vitest.it)("should parse all color types with same arbitrary hex",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000]")).toEqual({backgroundColor:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#ff0000]")).toEqual({color:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#ff0000]")).toEqual({borderColor:"#ff0000"});});(0,_vitest.it)("should handle all color families",function(){var families=["gray","red","blue","green","yellow","purple","pink","orange","indigo"];families.forEach(function(family){(0,_vitest.expect)((0,_colors.parseColor)(`bg-${family}-500`)).toBeTruthy();(0,_vitest.expect)((0,_colors.parseColor)(`text-${family}-500`)).toBeTruthy();(0,_vitest.expect)((0,_colors.parseColor)(`border-${family}-500`)).toBeTruthy();});});(0,_vitest.it)("should handle arbitrary values with mixed case",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#AbCdEf]")).toEqual({backgroundColor:"#AbCdEf"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#aBcDeF]")).toEqual({color:"#aBcDeF"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#ABCDEF]")).toEqual({borderColor:"#ABCDEF"});});(0,_vitest.it)("should expand 3-digit hex consistently across all color types",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#abc]")).toEqual({backgroundColor:"#aabbcc"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#abc]")).toEqual({color:"#aabbcc"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#abc]")).toEqual({borderColor:"#aabbcc"});});(0,_vitest.it)("should handle alpha channel consistently across all color types",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000aa]")).toEqual({backgroundColor:"#ff0000aa"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#ff0000aa]")).toEqual({color:"#ff0000aa"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#ff0000aa]")).toEqual({borderColor:"#ff0000aa"});});});(0,_vitest.describe)("parseColor - opacity modifiers",function(){(0,_vitest.it)("should parse background colors with opacity modifiers",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-black/50")).toEqual({backgroundColor:"#00000080"});(0,_vitest.expect)((0,_colors.parseColor)("bg-white/50")).toEqual({backgroundColor:"#FFFFFF80"});(0,_vitest.expect)((0,_colors.parseColor)("bg-blue-500/80")).toEqual({backgroundColor:"#3B82F6CC"});(0,_vitest.expect)((0,_colors.parseColor)("bg-red-500/30")).toEqual({backgroundColor:"#EF44444D"});});(0,_vitest.it)("should parse text colors with opacity modifiers",function(){(0,_vitest.expect)((0,_colors.parseColor)("text-black/80")).toEqual({color:"#000000CC"});(0,_vitest.expect)((0,_colors.parseColor)("text-white/90")).toEqual({color:"#FFFFFFE6"});(0,_vitest.expect)((0,_colors.parseColor)("text-gray-900/70")).toEqual({color:"#111827B3"});(0,_vitest.expect)((0,_colors.parseColor)("text-blue-500/50")).toEqual({color:"#3B82F680"});});(0,_vitest.it)("should parse border colors with opacity modifiers",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-black/25")).toEqual({borderColor:"#00000040"});(0,_vitest.expect)((0,_colors.parseColor)("border-red-500/60")).toEqual({borderColor:"#EF444499"});(0,_vitest.expect)((0,_colors.parseColor)("border-gray-200/40")).toEqual({borderColor:"#E5E7EB66"});});(0,_vitest.it)("should handle opacity modifier with arbitrary hex colors",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000]/50")).toEqual({backgroundColor:"#FF000080"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#3B82F6]/80")).toEqual({color:"#3B82F6CC"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#abc]/60")).toEqual({borderColor:"#AABBCC99"});});(0,_vitest.it)("should handle opacity modifier with custom colors",function(){var customColors={"brand-primary":"#FF6B6B"};(0,_vitest.expect)((0,_colors.parseColor)("bg-brand-primary/50",customColors)).toEqual({backgroundColor:"#FF6B6B80"});(0,_vitest.expect)((0,_colors.parseColor)("text-brand-primary/75",customColors)).toEqual({color:"#FF6B6BBF"});});(0,_vitest.it)("should handle opacity 0 (fully transparent)",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-black/0")).toEqual({backgroundColor:"#00000000"});(0,_vitest.expect)((0,_colors.parseColor)("text-red-500/0")).toEqual({color:"#EF444400"});});(0,_vitest.it)("should handle opacity 100 (fully opaque)",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-black/100")).toEqual({backgroundColor:"#000000FF"});(0,_vitest.expect)((0,_colors.parseColor)("text-blue-500/100")).toEqual({color:"#3B82F6FF"});});(0,_vitest.it)("should handle transparent color with opacity modifier",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-transparent/50")).toEqual({backgroundColor:"transparent"});});(0,_vitest.it)("should convert opacity percentage to correct hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-black/0")).toEqual({backgroundColor:"#00000000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-black/10")).toEqual({backgroundColor:"#0000001A"});(0,_vitest.expect)((0,_colors.parseColor)("bg-black/25")).toEqual({backgroundColor:"#00000040"});(0,_vitest.expect)((0,_colors.parseColor)("bg-black/50")).toEqual({backgroundColor:"#00000080"});(0,_vitest.expect)((0,_colors.parseColor)("bg-black/75")).toEqual({backgroundColor:"#000000BF"});(0,_vitest.expect)((0,_colors.parseColor)("bg-black/100")).toEqual({backgroundColor:"#000000FF"});});(0,_vitest.it)("should return null for invalid opacity values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-black/101")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-black/-1")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-black/150")).toBeNull();});(0,_vitest.it)("should return null for malformed opacity syntax",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-black/")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-black/abc")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-black/50/")).toBeNull();});(0,_vitest.it)("should handle opacity with 3-digit hex expansion",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#f00]/50")).toEqual({backgroundColor:"#FF000080"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#abc]/75")).toEqual({color:"#AABBCCBF"});});(0,_vitest.it)("should work with all color families",function(){var families=["gray","red","blue","green","yellow","purple","pink","orange","indigo"];families.forEach(function(family){(0,_vitest.expect)((0,_colors.parseColor)(`bg-${family}-500/50`)).toBeTruthy();(0,_vitest.expect)((0,_colors.parseColor)(`text-${family}-500/50`)).toBeTruthy();(0,_vitest.expect)((0,_colors.parseColor)(`border-${family}-500/50`)).toBeTruthy();});});});
|
package/dist/parser/index.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export { parseLayout } from "./layout";
|
|
|
24
24
|
export { parseShadow } from "./shadows";
|
|
25
25
|
export { parseSizing } from "./sizing";
|
|
26
26
|
export { parseSpacing } from "./spacing";
|
|
27
|
+
export { parseTransform } from "./transforms";
|
|
27
28
|
export { parseTypography } from "./typography";
|
|
28
29
|
export { hasModifier, parseModifier, splitModifierClasses } from "./modifiers";
|
|
29
30
|
export type { ModifierType, ParsedModifier } from "./modifiers";
|
package/dist/parser/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"hasModifier",{enumerable:true,get:function get(){return _modifiers.hasModifier;}});Object.defineProperty(exports,"parseAspectRatio",{enumerable:true,get:function get(){return _aspectRatio.parseAspectRatio;}});Object.defineProperty(exports,"parseBorder",{enumerable:true,get:function get(){return _borders.parseBorder;}});exports.parseClass=parseClass;exports.parseClassName=parseClassName;Object.defineProperty(exports,"parseColor",{enumerable:true,get:function get(){return _colors.parseColor;}});Object.defineProperty(exports,"parseLayout",{enumerable:true,get:function get(){return _layout.parseLayout;}});Object.defineProperty(exports,"parseModifier",{enumerable:true,get:function get(){return _modifiers.parseModifier;}});Object.defineProperty(exports,"parseShadow",{enumerable:true,get:function get(){return _shadows.parseShadow;}});Object.defineProperty(exports,"parseSizing",{enumerable:true,get:function get(){return _sizing.parseSizing;}});Object.defineProperty(exports,"parseSpacing",{enumerable:true,get:function get(){return _spacing.parseSpacing;}});Object.defineProperty(exports,"parseTypography",{enumerable:true,get:function get(){return _typography.parseTypography;}});Object.defineProperty(exports,"splitModifierClasses",{enumerable:true,get:function get(){return _modifiers.splitModifierClasses;}});var _aspectRatio=require("./aspectRatio");var _borders=require("./borders");var _colors=require("./colors");var _layout=require("./layout");var _shadows=require("./shadows");var _sizing=require("./sizing");var _spacing=require("./spacing");var _typography=require("./typography");var _modifiers=require("./modifiers");function parseClassName(className,customColors){var classes=className.split(/\s+/).filter(Boolean);var style={};for(var cls of classes){var parsedStyle=parseClass(cls,customColors);Object.assign(style,parsedStyle);}return style;}function parseClass(cls,customColors){var parsers=[_spacing.parseSpacing,_borders.parseBorder,function(cls){return(0,_colors.parseColor)(cls,customColors);},_layout.parseLayout,_typography.parseTypography,_sizing.parseSizing,_shadows.parseShadow,_aspectRatio.parseAspectRatio];for(var parser of parsers){var result=parser(cls);if(result!==null){return result;}}if(process.env.NODE_ENV!=="production"){console.warn(`[react-native-tailwind] Unknown class: "${cls}"`);}return{};}
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"hasModifier",{enumerable:true,get:function get(){return _modifiers.hasModifier;}});Object.defineProperty(exports,"parseAspectRatio",{enumerable:true,get:function get(){return _aspectRatio.parseAspectRatio;}});Object.defineProperty(exports,"parseBorder",{enumerable:true,get:function get(){return _borders.parseBorder;}});exports.parseClass=parseClass;exports.parseClassName=parseClassName;Object.defineProperty(exports,"parseColor",{enumerable:true,get:function get(){return _colors.parseColor;}});Object.defineProperty(exports,"parseLayout",{enumerable:true,get:function get(){return _layout.parseLayout;}});Object.defineProperty(exports,"parseModifier",{enumerable:true,get:function get(){return _modifiers.parseModifier;}});Object.defineProperty(exports,"parseShadow",{enumerable:true,get:function get(){return _shadows.parseShadow;}});Object.defineProperty(exports,"parseSizing",{enumerable:true,get:function get(){return _sizing.parseSizing;}});Object.defineProperty(exports,"parseSpacing",{enumerable:true,get:function get(){return _spacing.parseSpacing;}});Object.defineProperty(exports,"parseTransform",{enumerable:true,get:function get(){return _transforms.parseTransform;}});Object.defineProperty(exports,"parseTypography",{enumerable:true,get:function get(){return _typography.parseTypography;}});Object.defineProperty(exports,"splitModifierClasses",{enumerable:true,get:function get(){return _modifiers.splitModifierClasses;}});var _aspectRatio=require("./aspectRatio");var _borders=require("./borders");var _colors=require("./colors");var _layout=require("./layout");var _shadows=require("./shadows");var _sizing=require("./sizing");var _spacing=require("./spacing");var _transforms=require("./transforms");var _typography=require("./typography");var _modifiers=require("./modifiers");function parseClassName(className,customColors){var classes=className.split(/\s+/).filter(Boolean);var style={};for(var cls of classes){var parsedStyle=parseClass(cls,customColors);Object.assign(style,parsedStyle);}return style;}function parseClass(cls,customColors){var parsers=[_spacing.parseSpacing,_borders.parseBorder,function(cls){return(0,_colors.parseColor)(cls,customColors);},_layout.parseLayout,_typography.parseTypography,_sizing.parseSizing,_shadows.parseShadow,_aspectRatio.parseAspectRatio,_transforms.parseTransform];for(var parser of parsers){var result=parser(cls);if(result!==null){return result;}}if(process.env.NODE_ENV!=="production"){console.warn(`[react-native-tailwind] Unknown class: "${cls}"`);}return{};}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transform utilities (scale, rotate, translate, skew, perspective)
|
|
3
|
+
*/
|
|
4
|
+
import type { StyleObject } from "../types";
|
|
5
|
+
export declare const SCALE_MAP: Record<string, number>;
|
|
6
|
+
export declare const ROTATE_MAP: Record<string, number>;
|
|
7
|
+
export declare const SKEW_MAP: Record<string, number>;
|
|
8
|
+
export declare const PERSPECTIVE_SCALE: Record<string, number>;
|
|
9
|
+
/**
|
|
10
|
+
* Parse transform classes
|
|
11
|
+
* Each transform class returns a transform array with a single transform object
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseTransform(cls: string): StyleObject | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.SKEW_MAP=exports.SCALE_MAP=exports.ROTATE_MAP=exports.PERSPECTIVE_SCALE=void 0;exports.parseTransform=parseTransform;var _spacing=require("./spacing");var SCALE_MAP=exports.SCALE_MAP={0:0,50:0.5,75:0.75,90:0.9,95:0.95,100:1,105:1.05,110:1.1,125:1.25,150:1.5,200:2};var ROTATE_MAP=exports.ROTATE_MAP={0:0,1:1,2:2,3:3,6:6,12:12,45:45,90:90,180:180};var SKEW_MAP=exports.SKEW_MAP={0:0,1:1,2:2,3:3,6:6,12:12};var PERSPECTIVE_SCALE=exports.PERSPECTIVE_SCALE={0:0,100:100,200:200,300:300,400:400,500:500,600:600,700:700,800:800,900:900,1000:1000};function parseArbitraryScale(value){var scaleMatch=value.match(/^\[(-?\d+(?:\.\d+)?)\]$/);if(scaleMatch){return parseFloat(scaleMatch[1]);}if(value.startsWith("[")&&value.endsWith("]")){if(process.env.NODE_ENV!=="production"){console.warn(`[react-native-tailwind] Invalid arbitrary scale value: ${value}. Only numbers are supported (e.g., [1.5], [0.75]).`);}return null;}return null;}function parseArbitraryRotation(value){var rotateMatch=value.match(/^\[(-?\d+(?:\.\d+)?)deg\]$/);if(rotateMatch){return`${rotateMatch[1]}deg`;}if(value.startsWith("[")&&value.endsWith("]")){if(process.env.NODE_ENV!=="production"){console.warn(`[react-native-tailwind] Invalid arbitrary rotation value: ${value}. Only deg unit is supported (e.g., [45deg], [-15deg]).`);}return null;}return null;}function parseArbitraryTranslation(value){var pxMatch=value.match(/^\[(-?\d+)(?:px)?\]$/);if(pxMatch){return parseInt(pxMatch[1],10);}var percentMatch=value.match(/^\[(-?\d+(?:\.\d+)?)%\]$/);if(percentMatch){return`${percentMatch[1]}%`;}if(value.startsWith("[")&&value.endsWith("]")){if(process.env.NODE_ENV!=="production"){console.warn(`[react-native-tailwind] Unsupported arbitrary translation unit: ${value}. Only px and % are supported.`);}return null;}return null;}function parseArbitraryPerspective(value){var perspectiveMatch=value.match(/^\[(-?\d+)\]$/);if(perspectiveMatch){return parseInt(perspectiveMatch[1],10);}if(value.startsWith("[")&&value.endsWith("]")){if(process.env.NODE_ENV!=="production"){console.warn(`[react-native-tailwind] Invalid arbitrary perspective value: ${value}. Only integers are supported (e.g., [1500]).`);}return null;}return null;}function parseTransform(cls){if(cls.startsWith("origin-")){if(process.env.NODE_ENV!=="production"){console.warn(`[react-native-tailwind] transform-origin is not supported in React Native. Class "${cls}" will be ignored.`);}return null;}if(cls.startsWith("scale-")){var scaleKey=cls.substring(6);var arbitraryScale=parseArbitraryScale(scaleKey);if(arbitraryScale!==null){return{transform:[{scale:arbitraryScale}]};}var scaleValue=SCALE_MAP[scaleKey];if(scaleValue!==undefined){return{transform:[{scale:scaleValue}]};}}if(cls.startsWith("scale-x-")){var _scaleKey=cls.substring(8);var _arbitraryScale=parseArbitraryScale(_scaleKey);if(_arbitraryScale!==null){return{transform:[{scaleX:_arbitraryScale}]};}var _scaleValue=SCALE_MAP[_scaleKey];if(_scaleValue!==undefined){return{transform:[{scaleX:_scaleValue}]};}}if(cls.startsWith("scale-y-")){var _scaleKey2=cls.substring(8);var _arbitraryScale2=parseArbitraryScale(_scaleKey2);if(_arbitraryScale2!==null){return{transform:[{scaleY:_arbitraryScale2}]};}var _scaleValue2=SCALE_MAP[_scaleKey2];if(_scaleValue2!==undefined){return{transform:[{scaleY:_scaleValue2}]};}}if(cls.startsWith("rotate-")||cls.startsWith("-rotate-")){var isNegative=cls.startsWith("-");var rotateKey=isNegative?cls.substring(8):cls.substring(7);var arbitraryRotate=parseArbitraryRotation(rotateKey);if(arbitraryRotate!==null){var degrees=isNegative?`-${arbitraryRotate}`:arbitraryRotate;return{transform:[{rotate:degrees}]};}var rotateValue=ROTATE_MAP[rotateKey];if(rotateValue!==undefined){var _degrees=isNegative?-rotateValue:rotateValue;return{transform:[{rotate:`${_degrees}deg`}]};}}if(cls.startsWith("rotate-x-")||cls.startsWith("-rotate-x-")){var _isNegative=cls.startsWith("-");var _rotateKey=_isNegative?cls.substring(10):cls.substring(9);var _arbitraryRotate=parseArbitraryRotation(_rotateKey);if(_arbitraryRotate!==null){var _degrees2=_isNegative?`-${_arbitraryRotate}`:_arbitraryRotate;return{transform:[{rotateX:_degrees2}]};}var _rotateValue=ROTATE_MAP[_rotateKey];if(_rotateValue!==undefined){var _degrees3=_isNegative?-_rotateValue:_rotateValue;return{transform:[{rotateX:`${_degrees3}deg`}]};}}if(cls.startsWith("rotate-y-")||cls.startsWith("-rotate-y-")){var _isNegative2=cls.startsWith("-");var _rotateKey2=_isNegative2?cls.substring(10):cls.substring(9);var _arbitraryRotate2=parseArbitraryRotation(_rotateKey2);if(_arbitraryRotate2!==null){var _degrees4=_isNegative2?`-${_arbitraryRotate2}`:_arbitraryRotate2;return{transform:[{rotateY:_degrees4}]};}var _rotateValue2=ROTATE_MAP[_rotateKey2];if(_rotateValue2!==undefined){var _degrees5=_isNegative2?-_rotateValue2:_rotateValue2;return{transform:[{rotateY:`${_degrees5}deg`}]};}}if(cls.startsWith("rotate-z-")||cls.startsWith("-rotate-z-")){var _isNegative3=cls.startsWith("-");var _rotateKey3=_isNegative3?cls.substring(10):cls.substring(9);var _arbitraryRotate3=parseArbitraryRotation(_rotateKey3);if(_arbitraryRotate3!==null){var _degrees6=_isNegative3?`-${_arbitraryRotate3}`:_arbitraryRotate3;return{transform:[{rotateZ:_degrees6}]};}var _rotateValue3=ROTATE_MAP[_rotateKey3];if(_rotateValue3!==undefined){var _degrees7=_isNegative3?-_rotateValue3:_rotateValue3;return{transform:[{rotateZ:`${_degrees7}deg`}]};}}if(cls.startsWith("translate-x-")||cls.startsWith("-translate-x-")){var _isNegative4=cls.startsWith("-");var translateKey=_isNegative4?cls.substring(13):cls.substring(12);var arbitraryTranslate=parseArbitraryTranslation(translateKey);if(arbitraryTranslate!==null){var value=typeof arbitraryTranslate==="number"?_isNegative4?-arbitraryTranslate:arbitraryTranslate:_isNegative4?`-${arbitraryTranslate}`:arbitraryTranslate;return{transform:[{translateX:value}]};}var translateValue=_spacing.SPACING_SCALE[translateKey];if(translateValue!==undefined){var _value=_isNegative4?-translateValue:translateValue;return{transform:[{translateX:_value}]};}}if(cls.startsWith("translate-y-")||cls.startsWith("-translate-y-")){var _isNegative5=cls.startsWith("-");var _translateKey=_isNegative5?cls.substring(13):cls.substring(12);var _arbitraryTranslate=parseArbitraryTranslation(_translateKey);if(_arbitraryTranslate!==null){var _value2=typeof _arbitraryTranslate==="number"?_isNegative5?-_arbitraryTranslate:_arbitraryTranslate:_isNegative5?`-${_arbitraryTranslate}`:_arbitraryTranslate;return{transform:[{translateY:_value2}]};}var _translateValue=_spacing.SPACING_SCALE[_translateKey];if(_translateValue!==undefined){var _value3=_isNegative5?-_translateValue:_translateValue;return{transform:[{translateY:_value3}]};}}if(cls.startsWith("skew-x-")||cls.startsWith("-skew-x-")){var _isNegative6=cls.startsWith("-");var skewKey=_isNegative6?cls.substring(8):cls.substring(7);var arbitrarySkew=parseArbitraryRotation(skewKey);if(arbitrarySkew!==null){var _degrees8=_isNegative6?`-${arbitrarySkew}`:arbitrarySkew;return{transform:[{skewX:_degrees8}]};}var skewValue=SKEW_MAP[skewKey];if(skewValue!==undefined){var _degrees9=_isNegative6?-skewValue:skewValue;return{transform:[{skewX:`${_degrees9}deg`}]};}}if(cls.startsWith("skew-y-")||cls.startsWith("-skew-y-")){var _isNegative7=cls.startsWith("-");var _skewKey=_isNegative7?cls.substring(8):cls.substring(7);var _arbitrarySkew=parseArbitraryRotation(_skewKey);if(_arbitrarySkew!==null){var _degrees0=_isNegative7?`-${_arbitrarySkew}`:_arbitrarySkew;return{transform:[{skewY:_degrees0}]};}var _skewValue=SKEW_MAP[_skewKey];if(_skewValue!==undefined){var _degrees1=_isNegative7?-_skewValue:_skewValue;return{transform:[{skewY:`${_degrees1}deg`}]};}}if(cls.startsWith("perspective-")){var perspectiveKey=cls.substring(12);var arbitraryPerspective=parseArbitraryPerspective(perspectiveKey);if(arbitraryPerspective!==null){return{transform:[{perspective:arbitraryPerspective}]};}var perspectiveValue=PERSPECTIVE_SCALE[perspectiveKey];if(perspectiveValue!==undefined){return{transform:[{perspective:perspectiveValue}]};}}return null;}
|