@mgcrea/react-native-tailwind 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/babel/index.cjs +73 -7
- package/dist/parser/__snapshots__/aspectRatio.test.js.snap +9 -0
- package/dist/parser/__snapshots__/borders.test.js.snap +23 -0
- package/dist/parser/__snapshots__/colors.test.js.snap +99 -0
- package/dist/parser/__snapshots__/shadows.test.js.snap +76 -0
- package/dist/parser/__snapshots__/sizing.test.js.snap +61 -0
- package/dist/parser/__snapshots__/spacing.test.js.snap +40 -0
- package/dist/parser/__snapshots__/typography.test.js.snap +30 -0
- package/dist/parser/layout.js +1 -1
- package/dist/parser/layout.test.js +1 -1
- package/dist/react-native.d.ts +1 -1
- package/package.json +1 -1
- package/src/parser/layout.test.ts +92 -0
- package/src/parser/layout.ts +122 -16
- package/src/react-native.d.ts +1 -1
package/dist/babel/index.cjs
CHANGED
|
@@ -452,6 +452,40 @@ function parseColor(cls, customColors) {
|
|
|
452
452
|
}
|
|
453
453
|
|
|
454
454
|
// src/parser/layout.ts
|
|
455
|
+
function parseArbitraryInset(value) {
|
|
456
|
+
const pxMatch = value.match(/^\[(-?\d+)(?:px)?\]$/);
|
|
457
|
+
if (pxMatch) {
|
|
458
|
+
return parseInt(pxMatch[1], 10);
|
|
459
|
+
}
|
|
460
|
+
const percentMatch = value.match(/^\[(-?\d+(?:\.\d+)?)%\]$/);
|
|
461
|
+
if (percentMatch) {
|
|
462
|
+
return `${percentMatch[1]}%`;
|
|
463
|
+
}
|
|
464
|
+
if (value.startsWith("[") && value.endsWith("]")) {
|
|
465
|
+
if (process.env.NODE_ENV !== "production") {
|
|
466
|
+
console.warn(
|
|
467
|
+
`[react-native-tailwind] Unsupported arbitrary inset unit: ${value}. Only px and % are supported.`
|
|
468
|
+
);
|
|
469
|
+
}
|
|
470
|
+
return null;
|
|
471
|
+
}
|
|
472
|
+
return null;
|
|
473
|
+
}
|
|
474
|
+
function parseArbitraryZIndex(value) {
|
|
475
|
+
const zMatch = value.match(/^\[(-?\d+)\]$/);
|
|
476
|
+
if (zMatch) {
|
|
477
|
+
return parseInt(zMatch[1], 10);
|
|
478
|
+
}
|
|
479
|
+
if (value.startsWith("[") && value.endsWith("]")) {
|
|
480
|
+
if (process.env.NODE_ENV !== "production") {
|
|
481
|
+
console.warn(
|
|
482
|
+
`[react-native-tailwind] Invalid arbitrary z-index: ${value}. Only integers are supported.`
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
return null;
|
|
486
|
+
}
|
|
487
|
+
return null;
|
|
488
|
+
}
|
|
455
489
|
var DISPLAY_MAP = {
|
|
456
490
|
flex: { display: "flex" },
|
|
457
491
|
hidden: { display: "none" }
|
|
@@ -550,6 +584,10 @@ var INSET_SCALE = {
|
|
|
550
584
|
function parseLayout(cls) {
|
|
551
585
|
if (cls.startsWith("z-")) {
|
|
552
586
|
const zKey = cls.substring(2);
|
|
587
|
+
const arbitraryZ = parseArbitraryZIndex(zKey);
|
|
588
|
+
if (arbitraryZ !== null) {
|
|
589
|
+
return { zIndex: arbitraryZ };
|
|
590
|
+
}
|
|
553
591
|
const zValue = Z_INDEX_SCALE[zKey];
|
|
554
592
|
if (zValue !== void 0) {
|
|
555
593
|
return { zIndex: zValue };
|
|
@@ -560,6 +598,10 @@ function parseLayout(cls) {
|
|
|
560
598
|
if (topKey === "auto") {
|
|
561
599
|
return {};
|
|
562
600
|
}
|
|
601
|
+
const arbitraryTop = parseArbitraryInset(topKey);
|
|
602
|
+
if (arbitraryTop !== null) {
|
|
603
|
+
return { top: arbitraryTop };
|
|
604
|
+
}
|
|
563
605
|
const topValue = INSET_SCALE[topKey];
|
|
564
606
|
if (topValue !== void 0) {
|
|
565
607
|
return { top: topValue };
|
|
@@ -570,6 +612,10 @@ function parseLayout(cls) {
|
|
|
570
612
|
if (rightKey === "auto") {
|
|
571
613
|
return {};
|
|
572
614
|
}
|
|
615
|
+
const arbitraryRight = parseArbitraryInset(rightKey);
|
|
616
|
+
if (arbitraryRight !== null) {
|
|
617
|
+
return { right: arbitraryRight };
|
|
618
|
+
}
|
|
573
619
|
const rightValue = INSET_SCALE[rightKey];
|
|
574
620
|
if (rightValue !== void 0) {
|
|
575
621
|
return { right: rightValue };
|
|
@@ -580,6 +626,10 @@ function parseLayout(cls) {
|
|
|
580
626
|
if (bottomKey === "auto") {
|
|
581
627
|
return {};
|
|
582
628
|
}
|
|
629
|
+
const arbitraryBottom = parseArbitraryInset(bottomKey);
|
|
630
|
+
if (arbitraryBottom !== null) {
|
|
631
|
+
return { bottom: arbitraryBottom };
|
|
632
|
+
}
|
|
583
633
|
const bottomValue = INSET_SCALE[bottomKey];
|
|
584
634
|
if (bottomValue !== void 0) {
|
|
585
635
|
return { bottom: bottomValue };
|
|
@@ -590,20 +640,21 @@ function parseLayout(cls) {
|
|
|
590
640
|
if (leftKey === "auto") {
|
|
591
641
|
return {};
|
|
592
642
|
}
|
|
643
|
+
const arbitraryLeft = parseArbitraryInset(leftKey);
|
|
644
|
+
if (arbitraryLeft !== null) {
|
|
645
|
+
return { left: arbitraryLeft };
|
|
646
|
+
}
|
|
593
647
|
const leftValue = INSET_SCALE[leftKey];
|
|
594
648
|
if (leftValue !== void 0) {
|
|
595
649
|
return { left: leftValue };
|
|
596
650
|
}
|
|
597
651
|
}
|
|
598
|
-
if (cls.startsWith("inset-")) {
|
|
599
|
-
const insetKey = cls.substring(6);
|
|
600
|
-
const insetValue = INSET_SCALE[insetKey];
|
|
601
|
-
if (insetValue !== void 0) {
|
|
602
|
-
return { top: insetValue, right: insetValue, bottom: insetValue, left: insetValue };
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
652
|
if (cls.startsWith("inset-x-")) {
|
|
606
653
|
const insetKey = cls.substring(8);
|
|
654
|
+
const arbitraryInset = parseArbitraryInset(insetKey);
|
|
655
|
+
if (arbitraryInset !== null) {
|
|
656
|
+
return { left: arbitraryInset, right: arbitraryInset };
|
|
657
|
+
}
|
|
607
658
|
const insetValue = INSET_SCALE[insetKey];
|
|
608
659
|
if (insetValue !== void 0) {
|
|
609
660
|
return { left: insetValue, right: insetValue };
|
|
@@ -611,11 +662,26 @@ function parseLayout(cls) {
|
|
|
611
662
|
}
|
|
612
663
|
if (cls.startsWith("inset-y-")) {
|
|
613
664
|
const insetKey = cls.substring(8);
|
|
665
|
+
const arbitraryInset = parseArbitraryInset(insetKey);
|
|
666
|
+
if (arbitraryInset !== null) {
|
|
667
|
+
return { top: arbitraryInset, bottom: arbitraryInset };
|
|
668
|
+
}
|
|
614
669
|
const insetValue = INSET_SCALE[insetKey];
|
|
615
670
|
if (insetValue !== void 0) {
|
|
616
671
|
return { top: insetValue, bottom: insetValue };
|
|
617
672
|
}
|
|
618
673
|
}
|
|
674
|
+
if (cls.startsWith("inset-")) {
|
|
675
|
+
const insetKey = cls.substring(6);
|
|
676
|
+
const arbitraryInset = parseArbitraryInset(insetKey);
|
|
677
|
+
if (arbitraryInset !== null) {
|
|
678
|
+
return { top: arbitraryInset, right: arbitraryInset, bottom: arbitraryInset, left: arbitraryInset };
|
|
679
|
+
}
|
|
680
|
+
const insetValue = INSET_SCALE[insetKey];
|
|
681
|
+
if (insetValue !== void 0) {
|
|
682
|
+
return { top: insetValue, right: insetValue, bottom: insetValue, left: insetValue };
|
|
683
|
+
}
|
|
684
|
+
}
|
|
619
685
|
return DISPLAY_MAP[cls] ?? FLEX_DIRECTION_MAP[cls] ?? FLEX_WRAP_MAP[cls] ?? FLEX_MAP[cls] ?? GROW_SHRINK_MAP[cls] ?? JUSTIFY_CONTENT_MAP[cls] ?? ALIGN_ITEMS_MAP[cls] ?? ALIGN_SELF_MAP[cls] ?? ALIGN_CONTENT_MAP[cls] ?? POSITION_MAP[cls] ?? OVERFLOW_MAP[cls] ?? null;
|
|
620
686
|
}
|
|
621
687
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
|
|
2
|
+
|
|
3
|
+
exports[`BORDER_WIDTH_SCALE should export complete border width scale 1`] = `
|
|
4
|
+
{
|
|
5
|
+
"0": 0,
|
|
6
|
+
"2": 2,
|
|
7
|
+
"4": 4,
|
|
8
|
+
"8": 8,
|
|
9
|
+
}
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
exports[`BORDER_RADIUS_SCALE should export complete border radius scale 1`] = `
|
|
13
|
+
{
|
|
14
|
+
"2xl": 16,
|
|
15
|
+
"3xl": 24,
|
|
16
|
+
"full": 9999,
|
|
17
|
+
"lg": 8,
|
|
18
|
+
"md": 6,
|
|
19
|
+
"none": 0,
|
|
20
|
+
"sm": 2,
|
|
21
|
+
"xl": 12,
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
|
|
2
|
+
|
|
3
|
+
exports[`COLORS should export complete color palette 1`] = `
|
|
4
|
+
{
|
|
5
|
+
"black": "#000000",
|
|
6
|
+
"blue-100": "#DBEAFE",
|
|
7
|
+
"blue-200": "#BFDBFE",
|
|
8
|
+
"blue-300": "#93C5FD",
|
|
9
|
+
"blue-400": "#60A5FA",
|
|
10
|
+
"blue-50": "#EFF6FF",
|
|
11
|
+
"blue-500": "#3B82F6",
|
|
12
|
+
"blue-600": "#2563EB",
|
|
13
|
+
"blue-700": "#1D4ED8",
|
|
14
|
+
"blue-800": "#1E40AF",
|
|
15
|
+
"blue-900": "#1E3A8A",
|
|
16
|
+
"gray-100": "#F3F4F6",
|
|
17
|
+
"gray-200": "#E5E7EB",
|
|
18
|
+
"gray-300": "#D1D5DB",
|
|
19
|
+
"gray-400": "#9CA3AF",
|
|
20
|
+
"gray-50": "#F9FAFB",
|
|
21
|
+
"gray-500": "#6B7280",
|
|
22
|
+
"gray-600": "#4B5563",
|
|
23
|
+
"gray-700": "#374151",
|
|
24
|
+
"gray-800": "#1F2937",
|
|
25
|
+
"gray-900": "#111827",
|
|
26
|
+
"green-100": "#DCFCE7",
|
|
27
|
+
"green-200": "#BBF7D0",
|
|
28
|
+
"green-300": "#86EFAC",
|
|
29
|
+
"green-400": "#4ADE80",
|
|
30
|
+
"green-50": "#F0FDF4",
|
|
31
|
+
"green-500": "#22C55E",
|
|
32
|
+
"green-600": "#16A34A",
|
|
33
|
+
"green-700": "#15803D",
|
|
34
|
+
"green-800": "#166534",
|
|
35
|
+
"green-900": "#14532D",
|
|
36
|
+
"indigo-100": "#E0E7FF",
|
|
37
|
+
"indigo-200": "#C7D2FE",
|
|
38
|
+
"indigo-300": "#A5B4FC",
|
|
39
|
+
"indigo-400": "#818CF8",
|
|
40
|
+
"indigo-50": "#EEF2FF",
|
|
41
|
+
"indigo-500": "#6366F1",
|
|
42
|
+
"indigo-600": "#4F46E5",
|
|
43
|
+
"indigo-700": "#4338CA",
|
|
44
|
+
"indigo-800": "#3730A3",
|
|
45
|
+
"indigo-900": "#312E81",
|
|
46
|
+
"orange-100": "#FFEDD5",
|
|
47
|
+
"orange-200": "#FED7AA",
|
|
48
|
+
"orange-300": "#FDBA74",
|
|
49
|
+
"orange-400": "#FB923C",
|
|
50
|
+
"orange-50": "#FFF7ED",
|
|
51
|
+
"orange-500": "#F97316",
|
|
52
|
+
"orange-600": "#EA580C",
|
|
53
|
+
"orange-700": "#C2410C",
|
|
54
|
+
"orange-800": "#9A3412",
|
|
55
|
+
"orange-900": "#7C2D12",
|
|
56
|
+
"pink-100": "#FCE7F3",
|
|
57
|
+
"pink-200": "#FBCFE8",
|
|
58
|
+
"pink-300": "#F9A8D4",
|
|
59
|
+
"pink-400": "#F472B6",
|
|
60
|
+
"pink-50": "#FDF2F8",
|
|
61
|
+
"pink-500": "#EC4899",
|
|
62
|
+
"pink-600": "#DB2777",
|
|
63
|
+
"pink-700": "#BE185D",
|
|
64
|
+
"pink-800": "#9D174D",
|
|
65
|
+
"pink-900": "#831843",
|
|
66
|
+
"purple-100": "#F3E8FF",
|
|
67
|
+
"purple-200": "#E9D5FF",
|
|
68
|
+
"purple-300": "#D8B4FE",
|
|
69
|
+
"purple-400": "#C084FC",
|
|
70
|
+
"purple-50": "#FAF5FF",
|
|
71
|
+
"purple-500": "#A855F7",
|
|
72
|
+
"purple-600": "#9333EA",
|
|
73
|
+
"purple-700": "#7E22CE",
|
|
74
|
+
"purple-800": "#6B21A8",
|
|
75
|
+
"purple-900": "#581C87",
|
|
76
|
+
"red-100": "#FEE2E2",
|
|
77
|
+
"red-200": "#FECACA",
|
|
78
|
+
"red-300": "#FCA5A5",
|
|
79
|
+
"red-400": "#F87171",
|
|
80
|
+
"red-50": "#FEF2F2",
|
|
81
|
+
"red-500": "#EF4444",
|
|
82
|
+
"red-600": "#DC2626",
|
|
83
|
+
"red-700": "#B91C1C",
|
|
84
|
+
"red-800": "#991B1B",
|
|
85
|
+
"red-900": "#7F1D1D",
|
|
86
|
+
"transparent": "transparent",
|
|
87
|
+
"white": "#FFFFFF",
|
|
88
|
+
"yellow-100": "#FEF9C3",
|
|
89
|
+
"yellow-200": "#FEF08A",
|
|
90
|
+
"yellow-300": "#FDE047",
|
|
91
|
+
"yellow-400": "#FACC15",
|
|
92
|
+
"yellow-50": "#FEFCE8",
|
|
93
|
+
"yellow-500": "#EAB308",
|
|
94
|
+
"yellow-600": "#CA8A04",
|
|
95
|
+
"yellow-700": "#A16207",
|
|
96
|
+
"yellow-800": "#854D0E",
|
|
97
|
+
"yellow-900": "#713F12",
|
|
98
|
+
}
|
|
99
|
+
`;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
|
|
2
|
+
|
|
3
|
+
exports[`SHADOW_SCALE should export complete shadow scale 1`] = `
|
|
4
|
+
{
|
|
5
|
+
"shadow": {
|
|
6
|
+
"elevation": 2,
|
|
7
|
+
"shadowColor": "#000000",
|
|
8
|
+
"shadowOffset": {
|
|
9
|
+
"height": 1,
|
|
10
|
+
"width": 0,
|
|
11
|
+
},
|
|
12
|
+
"shadowOpacity": 0.1,
|
|
13
|
+
"shadowRadius": 2,
|
|
14
|
+
},
|
|
15
|
+
"shadow-2xl": {
|
|
16
|
+
"elevation": 16,
|
|
17
|
+
"shadowColor": "#000000",
|
|
18
|
+
"shadowOffset": {
|
|
19
|
+
"height": 20,
|
|
20
|
+
"width": 0,
|
|
21
|
+
},
|
|
22
|
+
"shadowOpacity": 0.3,
|
|
23
|
+
"shadowRadius": 24,
|
|
24
|
+
},
|
|
25
|
+
"shadow-lg": {
|
|
26
|
+
"elevation": 8,
|
|
27
|
+
"shadowColor": "#000000",
|
|
28
|
+
"shadowOffset": {
|
|
29
|
+
"height": 6,
|
|
30
|
+
"width": 0,
|
|
31
|
+
},
|
|
32
|
+
"shadowOpacity": 0.2,
|
|
33
|
+
"shadowRadius": 8,
|
|
34
|
+
},
|
|
35
|
+
"shadow-md": {
|
|
36
|
+
"elevation": 4,
|
|
37
|
+
"shadowColor": "#000000",
|
|
38
|
+
"shadowOffset": {
|
|
39
|
+
"height": 3,
|
|
40
|
+
"width": 0,
|
|
41
|
+
},
|
|
42
|
+
"shadowOpacity": 0.15,
|
|
43
|
+
"shadowRadius": 4,
|
|
44
|
+
},
|
|
45
|
+
"shadow-none": {
|
|
46
|
+
"elevation": 0,
|
|
47
|
+
"shadowColor": "transparent",
|
|
48
|
+
"shadowOffset": {
|
|
49
|
+
"height": 0,
|
|
50
|
+
"width": 0,
|
|
51
|
+
},
|
|
52
|
+
"shadowOpacity": 0,
|
|
53
|
+
"shadowRadius": 0,
|
|
54
|
+
},
|
|
55
|
+
"shadow-sm": {
|
|
56
|
+
"elevation": 1,
|
|
57
|
+
"shadowColor": "#000000",
|
|
58
|
+
"shadowOffset": {
|
|
59
|
+
"height": 1,
|
|
60
|
+
"width": 0,
|
|
61
|
+
},
|
|
62
|
+
"shadowOpacity": 0.05,
|
|
63
|
+
"shadowRadius": 1,
|
|
64
|
+
},
|
|
65
|
+
"shadow-xl": {
|
|
66
|
+
"elevation": 12,
|
|
67
|
+
"shadowColor": "#000000",
|
|
68
|
+
"shadowOffset": {
|
|
69
|
+
"height": 10,
|
|
70
|
+
"width": 0,
|
|
71
|
+
},
|
|
72
|
+
"shadowOpacity": 0.25,
|
|
73
|
+
"shadowRadius": 12,
|
|
74
|
+
},
|
|
75
|
+
}
|
|
76
|
+
`;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
|
|
2
|
+
|
|
3
|
+
exports[`SIZE_SCALE should export complete size scale 1`] = `
|
|
4
|
+
{
|
|
5
|
+
"0": 0,
|
|
6
|
+
"0.5": 2,
|
|
7
|
+
"1": 4,
|
|
8
|
+
"1.5": 6,
|
|
9
|
+
"10": 40,
|
|
10
|
+
"11": 44,
|
|
11
|
+
"12": 48,
|
|
12
|
+
"14": 56,
|
|
13
|
+
"16": 64,
|
|
14
|
+
"2": 8,
|
|
15
|
+
"2.5": 10,
|
|
16
|
+
"20": 80,
|
|
17
|
+
"24": 96,
|
|
18
|
+
"28": 112,
|
|
19
|
+
"3": 12,
|
|
20
|
+
"3.5": 14,
|
|
21
|
+
"32": 128,
|
|
22
|
+
"36": 144,
|
|
23
|
+
"4": 16,
|
|
24
|
+
"40": 160,
|
|
25
|
+
"44": 176,
|
|
26
|
+
"48": 192,
|
|
27
|
+
"5": 20,
|
|
28
|
+
"52": 208,
|
|
29
|
+
"56": 224,
|
|
30
|
+
"6": 24,
|
|
31
|
+
"60": 240,
|
|
32
|
+
"64": 256,
|
|
33
|
+
"7": 28,
|
|
34
|
+
"72": 288,
|
|
35
|
+
"8": 32,
|
|
36
|
+
"80": 320,
|
|
37
|
+
"9": 36,
|
|
38
|
+
"96": 384,
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
exports[`SIZE_PERCENTAGES should export complete percentage sizes 1`] = `
|
|
43
|
+
{
|
|
44
|
+
"1/2": "50%",
|
|
45
|
+
"1/3": "33.333333%",
|
|
46
|
+
"1/4": "25%",
|
|
47
|
+
"1/5": "20%",
|
|
48
|
+
"1/6": "16.666667%",
|
|
49
|
+
"2/3": "66.666667%",
|
|
50
|
+
"2/4": "50%",
|
|
51
|
+
"2/5": "40%",
|
|
52
|
+
"2/6": "33.333333%",
|
|
53
|
+
"3/4": "75%",
|
|
54
|
+
"3/5": "60%",
|
|
55
|
+
"3/6": "50%",
|
|
56
|
+
"4/5": "80%",
|
|
57
|
+
"4/6": "66.666667%",
|
|
58
|
+
"5/6": "83.333333%",
|
|
59
|
+
"full": "100%",
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
|
|
2
|
+
|
|
3
|
+
exports[`SPACING_SCALE should export complete spacing scale 1`] = `
|
|
4
|
+
{
|
|
5
|
+
"0": 0,
|
|
6
|
+
"0.5": 2,
|
|
7
|
+
"1": 4,
|
|
8
|
+
"1.5": 6,
|
|
9
|
+
"10": 40,
|
|
10
|
+
"11": 44,
|
|
11
|
+
"12": 48,
|
|
12
|
+
"14": 56,
|
|
13
|
+
"16": 64,
|
|
14
|
+
"2": 8,
|
|
15
|
+
"2.5": 10,
|
|
16
|
+
"20": 80,
|
|
17
|
+
"24": 96,
|
|
18
|
+
"28": 112,
|
|
19
|
+
"3": 12,
|
|
20
|
+
"3.5": 14,
|
|
21
|
+
"32": 128,
|
|
22
|
+
"36": 144,
|
|
23
|
+
"4": 16,
|
|
24
|
+
"40": 160,
|
|
25
|
+
"44": 176,
|
|
26
|
+
"48": 192,
|
|
27
|
+
"5": 20,
|
|
28
|
+
"52": 208,
|
|
29
|
+
"56": 224,
|
|
30
|
+
"6": 24,
|
|
31
|
+
"60": 240,
|
|
32
|
+
"64": 256,
|
|
33
|
+
"7": 28,
|
|
34
|
+
"72": 288,
|
|
35
|
+
"8": 32,
|
|
36
|
+
"80": 320,
|
|
37
|
+
"9": 36,
|
|
38
|
+
"96": 384,
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
|
|
2
|
+
|
|
3
|
+
exports[`FONT_SIZES should export complete font size scale 1`] = `
|
|
4
|
+
{
|
|
5
|
+
"2xl": 24,
|
|
6
|
+
"3xl": 30,
|
|
7
|
+
"4xl": 36,
|
|
8
|
+
"5xl": 48,
|
|
9
|
+
"6xl": 60,
|
|
10
|
+
"7xl": 72,
|
|
11
|
+
"8xl": 96,
|
|
12
|
+
"9xl": 128,
|
|
13
|
+
"base": 16,
|
|
14
|
+
"lg": 18,
|
|
15
|
+
"sm": 14,
|
|
16
|
+
"xl": 20,
|
|
17
|
+
"xs": 12,
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
exports[`LETTER_SPACING_SCALE should export complete letter spacing scale 1`] = `
|
|
22
|
+
{
|
|
23
|
+
"normal": 0,
|
|
24
|
+
"tight": -0.4,
|
|
25
|
+
"tighter": -0.8,
|
|
26
|
+
"wide": 0.4,
|
|
27
|
+
"wider": 0.8,
|
|
28
|
+
"widest": 1.6,
|
|
29
|
+
}
|
|
30
|
+
`;
|
package/dist/parser/layout.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});exports.Z_INDEX_SCALE=exports.INSET_SCALE=void 0;exports.parseLayout=parseLayout;var DISPLAY_MAP={flex:{display:"flex"},hidden:{display:"none"}};var FLEX_DIRECTION_MAP={"flex-row":{flexDirection:"row"},"flex-row-reverse":{flexDirection:"row-reverse"},"flex-col":{flexDirection:"column"},"flex-col-reverse":{flexDirection:"column-reverse"}};var FLEX_WRAP_MAP={"flex-wrap":{flexWrap:"wrap"},"flex-wrap-reverse":{flexWrap:"wrap-reverse"},"flex-nowrap":{flexWrap:"nowrap"}};var FLEX_MAP={"flex-1":{flex:1},"flex-auto":{flex:1},"flex-none":{flex:0}};var GROW_SHRINK_MAP={grow:{flexGrow:1},"grow-0":{flexGrow:0},shrink:{flexShrink:1},"shrink-0":{flexShrink:0}};var JUSTIFY_CONTENT_MAP={"justify-start":{justifyContent:"flex-start"},"justify-end":{justifyContent:"flex-end"},"justify-center":{justifyContent:"center"},"justify-between":{justifyContent:"space-between"},"justify-around":{justifyContent:"space-around"},"justify-evenly":{justifyContent:"space-evenly"}};var ALIGN_ITEMS_MAP={"items-start":{alignItems:"flex-start"},"items-end":{alignItems:"flex-end"},"items-center":{alignItems:"center"},"items-baseline":{alignItems:"baseline"},"items-stretch":{alignItems:"stretch"}};var ALIGN_SELF_MAP={"self-auto":{alignSelf:"auto"},"self-start":{alignSelf:"flex-start"},"self-end":{alignSelf:"flex-end"},"self-center":{alignSelf:"center"},"self-stretch":{alignSelf:"stretch"},"self-baseline":{alignSelf:"baseline"}};var ALIGN_CONTENT_MAP={"content-start":{alignContent:"flex-start"},"content-end":{alignContent:"flex-end"},"content-center":{alignContent:"center"},"content-between":{alignContent:"space-between"},"content-around":{alignContent:"space-around"},"content-stretch":{alignContent:"stretch"}};var POSITION_MAP={absolute:{position:"absolute"},relative:{position:"relative"}};var OVERFLOW_MAP={"overflow-hidden":{overflow:"hidden"},"overflow-visible":{overflow:"visible"},"overflow-scroll":{overflow:"scroll"}};var Z_INDEX_SCALE=exports.Z_INDEX_SCALE={0:0,10:10,20:20,30:30,40:40,50:50,auto:0};var INSET_SCALE=exports.INSET_SCALE={0:0,0.5:2,1:4,1.5:6,2:8,2.5:10,3:12,3.5:14,4:16,5:20,6:24,8:32,10:40,12:48,16:64,20:80,24:96};function parseLayout(cls){var _ref,_ref2,_ref3,_ref4,_ref5,_ref6,_ref7,_ref8,_ref9,_ref0,_DISPLAY_MAP$cls;if(cls.startsWith("z-")){var zKey=cls.substring(2);var zValue=Z_INDEX_SCALE[zKey];if(zValue!==undefined){return{zIndex:zValue};}}if(cls.startsWith("top-")){var topKey=cls.substring(4);if(topKey==="auto"){return{};}var topValue=INSET_SCALE[topKey];if(topValue!==undefined){return{top:topValue};}}if(cls.startsWith("right-")){var rightKey=cls.substring(6);if(rightKey==="auto"){return{};}var rightValue=INSET_SCALE[rightKey];if(rightValue!==undefined){return{right:rightValue};}}if(cls.startsWith("bottom-")){var bottomKey=cls.substring(7);if(bottomKey==="auto"){return{};}var bottomValue=INSET_SCALE[bottomKey];if(bottomValue!==undefined){return{bottom:bottomValue};}}if(cls.startsWith("left-")){var leftKey=cls.substring(5);if(leftKey==="auto"){return{};}var leftValue=INSET_SCALE[leftKey];if(leftValue!==undefined){return{left:leftValue};}}if(cls.startsWith("inset-")){var insetKey=cls.substring(
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.Z_INDEX_SCALE=exports.INSET_SCALE=void 0;exports.parseLayout=parseLayout;function parseArbitraryInset(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 inset unit: ${value}. Only px and % are supported.`);}return null;}return null;}function parseArbitraryZIndex(value){var zMatch=value.match(/^\[(-?\d+)\]$/);if(zMatch){return parseInt(zMatch[1],10);}if(value.startsWith("[")&&value.endsWith("]")){if(process.env.NODE_ENV!=="production"){console.warn(`[react-native-tailwind] Invalid arbitrary z-index: ${value}. Only integers are supported.`);}return null;}return null;}var DISPLAY_MAP={flex:{display:"flex"},hidden:{display:"none"}};var FLEX_DIRECTION_MAP={"flex-row":{flexDirection:"row"},"flex-row-reverse":{flexDirection:"row-reverse"},"flex-col":{flexDirection:"column"},"flex-col-reverse":{flexDirection:"column-reverse"}};var FLEX_WRAP_MAP={"flex-wrap":{flexWrap:"wrap"},"flex-wrap-reverse":{flexWrap:"wrap-reverse"},"flex-nowrap":{flexWrap:"nowrap"}};var FLEX_MAP={"flex-1":{flex:1},"flex-auto":{flex:1},"flex-none":{flex:0}};var GROW_SHRINK_MAP={grow:{flexGrow:1},"grow-0":{flexGrow:0},shrink:{flexShrink:1},"shrink-0":{flexShrink:0}};var JUSTIFY_CONTENT_MAP={"justify-start":{justifyContent:"flex-start"},"justify-end":{justifyContent:"flex-end"},"justify-center":{justifyContent:"center"},"justify-between":{justifyContent:"space-between"},"justify-around":{justifyContent:"space-around"},"justify-evenly":{justifyContent:"space-evenly"}};var ALIGN_ITEMS_MAP={"items-start":{alignItems:"flex-start"},"items-end":{alignItems:"flex-end"},"items-center":{alignItems:"center"},"items-baseline":{alignItems:"baseline"},"items-stretch":{alignItems:"stretch"}};var ALIGN_SELF_MAP={"self-auto":{alignSelf:"auto"},"self-start":{alignSelf:"flex-start"},"self-end":{alignSelf:"flex-end"},"self-center":{alignSelf:"center"},"self-stretch":{alignSelf:"stretch"},"self-baseline":{alignSelf:"baseline"}};var ALIGN_CONTENT_MAP={"content-start":{alignContent:"flex-start"},"content-end":{alignContent:"flex-end"},"content-center":{alignContent:"center"},"content-between":{alignContent:"space-between"},"content-around":{alignContent:"space-around"},"content-stretch":{alignContent:"stretch"}};var POSITION_MAP={absolute:{position:"absolute"},relative:{position:"relative"}};var OVERFLOW_MAP={"overflow-hidden":{overflow:"hidden"},"overflow-visible":{overflow:"visible"},"overflow-scroll":{overflow:"scroll"}};var Z_INDEX_SCALE=exports.Z_INDEX_SCALE={0:0,10:10,20:20,30:30,40:40,50:50,auto:0};var INSET_SCALE=exports.INSET_SCALE={0:0,0.5:2,1:4,1.5:6,2:8,2.5:10,3:12,3.5:14,4:16,5:20,6:24,8:32,10:40,12:48,16:64,20:80,24:96};function parseLayout(cls){var _ref,_ref2,_ref3,_ref4,_ref5,_ref6,_ref7,_ref8,_ref9,_ref0,_DISPLAY_MAP$cls;if(cls.startsWith("z-")){var zKey=cls.substring(2);var arbitraryZ=parseArbitraryZIndex(zKey);if(arbitraryZ!==null){return{zIndex:arbitraryZ};}var zValue=Z_INDEX_SCALE[zKey];if(zValue!==undefined){return{zIndex:zValue};}}if(cls.startsWith("top-")){var topKey=cls.substring(4);if(topKey==="auto"){return{};}var arbitraryTop=parseArbitraryInset(topKey);if(arbitraryTop!==null){return{top:arbitraryTop};}var topValue=INSET_SCALE[topKey];if(topValue!==undefined){return{top:topValue};}}if(cls.startsWith("right-")){var rightKey=cls.substring(6);if(rightKey==="auto"){return{};}var arbitraryRight=parseArbitraryInset(rightKey);if(arbitraryRight!==null){return{right:arbitraryRight};}var rightValue=INSET_SCALE[rightKey];if(rightValue!==undefined){return{right:rightValue};}}if(cls.startsWith("bottom-")){var bottomKey=cls.substring(7);if(bottomKey==="auto"){return{};}var arbitraryBottom=parseArbitraryInset(bottomKey);if(arbitraryBottom!==null){return{bottom:arbitraryBottom};}var bottomValue=INSET_SCALE[bottomKey];if(bottomValue!==undefined){return{bottom:bottomValue};}}if(cls.startsWith("left-")){var leftKey=cls.substring(5);if(leftKey==="auto"){return{};}var arbitraryLeft=parseArbitraryInset(leftKey);if(arbitraryLeft!==null){return{left:arbitraryLeft};}var leftValue=INSET_SCALE[leftKey];if(leftValue!==undefined){return{left:leftValue};}}if(cls.startsWith("inset-x-")){var insetKey=cls.substring(8);var arbitraryInset=parseArbitraryInset(insetKey);if(arbitraryInset!==null){return{left:arbitraryInset,right:arbitraryInset};}var insetValue=INSET_SCALE[insetKey];if(insetValue!==undefined){return{left:insetValue,right:insetValue};}}if(cls.startsWith("inset-y-")){var _insetKey=cls.substring(8);var _arbitraryInset=parseArbitraryInset(_insetKey);if(_arbitraryInset!==null){return{top:_arbitraryInset,bottom:_arbitraryInset};}var _insetValue=INSET_SCALE[_insetKey];if(_insetValue!==undefined){return{top:_insetValue,bottom:_insetValue};}}if(cls.startsWith("inset-")){var _insetKey2=cls.substring(6);var _arbitraryInset2=parseArbitraryInset(_insetKey2);if(_arbitraryInset2!==null){return{top:_arbitraryInset2,right:_arbitraryInset2,bottom:_arbitraryInset2,left:_arbitraryInset2};}var _insetValue2=INSET_SCALE[_insetKey2];if(_insetValue2!==undefined){return{top:_insetValue2,right:_insetValue2,bottom:_insetValue2,left:_insetValue2};}}return(_ref=(_ref2=(_ref3=(_ref4=(_ref5=(_ref6=(_ref7=(_ref8=(_ref9=(_ref0=(_DISPLAY_MAP$cls=DISPLAY_MAP[cls])!=null?_DISPLAY_MAP$cls:FLEX_DIRECTION_MAP[cls])!=null?_ref0:FLEX_WRAP_MAP[cls])!=null?_ref9:FLEX_MAP[cls])!=null?_ref8:GROW_SHRINK_MAP[cls])!=null?_ref7:JUSTIFY_CONTENT_MAP[cls])!=null?_ref6:ALIGN_ITEMS_MAP[cls])!=null?_ref5:ALIGN_SELF_MAP[cls])!=null?_ref4:ALIGN_CONTENT_MAP[cls])!=null?_ref3:POSITION_MAP[cls])!=null?_ref2:OVERFLOW_MAP[cls])!=null?_ref:null;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var _vitest=require("vitest");var _layout=require("./layout");(0,_vitest.describe)("parseLayout - display utilities",function(){(0,_vitest.it)("should parse display flex",function(){(0,_vitest.expect)((0,_layout.parseLayout)("flex")).toEqual({display:"flex"});});(0,_vitest.it)("should parse display hidden",function(){(0,_vitest.expect)((0,_layout.parseLayout)("hidden")).toEqual({display:"none"});});});(0,_vitest.describe)("parseLayout - flex direction utilities",function(){(0,_vitest.it)("should parse flex row",function(){(0,_vitest.expect)((0,_layout.parseLayout)("flex-row")).toEqual({flexDirection:"row"});});(0,_vitest.it)("should parse flex row reverse",function(){(0,_vitest.expect)((0,_layout.parseLayout)("flex-row-reverse")).toEqual({flexDirection:"row-reverse"});});(0,_vitest.it)("should parse flex column",function(){(0,_vitest.expect)((0,_layout.parseLayout)("flex-col")).toEqual({flexDirection:"column"});});(0,_vitest.it)("should parse flex column reverse",function(){(0,_vitest.expect)((0,_layout.parseLayout)("flex-col-reverse")).toEqual({flexDirection:"column-reverse"});});});(0,_vitest.describe)("parseLayout - flex wrap utilities",function(){(0,_vitest.it)("should parse flex wrap",function(){(0,_vitest.expect)((0,_layout.parseLayout)("flex-wrap")).toEqual({flexWrap:"wrap"});});(0,_vitest.it)("should parse flex wrap reverse",function(){(0,_vitest.expect)((0,_layout.parseLayout)("flex-wrap-reverse")).toEqual({flexWrap:"wrap-reverse"});});(0,_vitest.it)("should parse flex nowrap",function(){(0,_vitest.expect)((0,_layout.parseLayout)("flex-nowrap")).toEqual({flexWrap:"nowrap"});});});(0,_vitest.describe)("parseLayout - flex utilities",function(){(0,_vitest.it)("should parse flex-1",function(){(0,_vitest.expect)((0,_layout.parseLayout)("flex-1")).toEqual({flex:1});});(0,_vitest.it)("should parse flex-auto",function(){(0,_vitest.expect)((0,_layout.parseLayout)("flex-auto")).toEqual({flex:1});});(0,_vitest.it)("should parse flex-none",function(){(0,_vitest.expect)((0,_layout.parseLayout)("flex-none")).toEqual({flex:0});});});(0,_vitest.describe)("parseLayout - flex grow/shrink utilities",function(){(0,_vitest.it)("should parse grow",function(){(0,_vitest.expect)((0,_layout.parseLayout)("grow")).toEqual({flexGrow:1});});(0,_vitest.it)("should parse grow-0",function(){(0,_vitest.expect)((0,_layout.parseLayout)("grow-0")).toEqual({flexGrow:0});});(0,_vitest.it)("should parse shrink",function(){(0,_vitest.expect)((0,_layout.parseLayout)("shrink")).toEqual({flexShrink:1});});(0,_vitest.it)("should parse shrink-0",function(){(0,_vitest.expect)((0,_layout.parseLayout)("shrink-0")).toEqual({flexShrink:0});});});(0,_vitest.describe)("parseLayout - justify content utilities",function(){(0,_vitest.it)("should parse justify-start",function(){(0,_vitest.expect)((0,_layout.parseLayout)("justify-start")).toEqual({justifyContent:"flex-start"});});(0,_vitest.it)("should parse justify-end",function(){(0,_vitest.expect)((0,_layout.parseLayout)("justify-end")).toEqual({justifyContent:"flex-end"});});(0,_vitest.it)("should parse justify-center",function(){(0,_vitest.expect)((0,_layout.parseLayout)("justify-center")).toEqual({justifyContent:"center"});});(0,_vitest.it)("should parse justify-between",function(){(0,_vitest.expect)((0,_layout.parseLayout)("justify-between")).toEqual({justifyContent:"space-between"});});(0,_vitest.it)("should parse justify-around",function(){(0,_vitest.expect)((0,_layout.parseLayout)("justify-around")).toEqual({justifyContent:"space-around"});});(0,_vitest.it)("should parse justify-evenly",function(){(0,_vitest.expect)((0,_layout.parseLayout)("justify-evenly")).toEqual({justifyContent:"space-evenly"});});});(0,_vitest.describe)("parseLayout - align items utilities",function(){(0,_vitest.it)("should parse items-start",function(){(0,_vitest.expect)((0,_layout.parseLayout)("items-start")).toEqual({alignItems:"flex-start"});});(0,_vitest.it)("should parse items-end",function(){(0,_vitest.expect)((0,_layout.parseLayout)("items-end")).toEqual({alignItems:"flex-end"});});(0,_vitest.it)("should parse items-center",function(){(0,_vitest.expect)((0,_layout.parseLayout)("items-center")).toEqual({alignItems:"center"});});(0,_vitest.it)("should parse items-baseline",function(){(0,_vitest.expect)((0,_layout.parseLayout)("items-baseline")).toEqual({alignItems:"baseline"});});(0,_vitest.it)("should parse items-stretch",function(){(0,_vitest.expect)((0,_layout.parseLayout)("items-stretch")).toEqual({alignItems:"stretch"});});});(0,_vitest.describe)("parseLayout - align self utilities",function(){(0,_vitest.it)("should parse self-auto",function(){(0,_vitest.expect)((0,_layout.parseLayout)("self-auto")).toEqual({alignSelf:"auto"});});(0,_vitest.it)("should parse self-start",function(){(0,_vitest.expect)((0,_layout.parseLayout)("self-start")).toEqual({alignSelf:"flex-start"});});(0,_vitest.it)("should parse self-end",function(){(0,_vitest.expect)((0,_layout.parseLayout)("self-end")).toEqual({alignSelf:"flex-end"});});(0,_vitest.it)("should parse self-center",function(){(0,_vitest.expect)((0,_layout.parseLayout)("self-center")).toEqual({alignSelf:"center"});});(0,_vitest.it)("should parse self-stretch",function(){(0,_vitest.expect)((0,_layout.parseLayout)("self-stretch")).toEqual({alignSelf:"stretch"});});(0,_vitest.it)("should parse self-baseline",function(){(0,_vitest.expect)((0,_layout.parseLayout)("self-baseline")).toEqual({alignSelf:"baseline"});});});(0,_vitest.describe)("parseLayout - align content utilities",function(){(0,_vitest.it)("should parse content-start",function(){(0,_vitest.expect)((0,_layout.parseLayout)("content-start")).toEqual({alignContent:"flex-start"});});(0,_vitest.it)("should parse content-end",function(){(0,_vitest.expect)((0,_layout.parseLayout)("content-end")).toEqual({alignContent:"flex-end"});});(0,_vitest.it)("should parse content-center",function(){(0,_vitest.expect)((0,_layout.parseLayout)("content-center")).toEqual({alignContent:"center"});});(0,_vitest.it)("should parse content-between",function(){(0,_vitest.expect)((0,_layout.parseLayout)("content-between")).toEqual({alignContent:"space-between"});});(0,_vitest.it)("should parse content-around",function(){(0,_vitest.expect)((0,_layout.parseLayout)("content-around")).toEqual({alignContent:"space-around"});});(0,_vitest.it)("should parse content-stretch",function(){(0,_vitest.expect)((0,_layout.parseLayout)("content-stretch")).toEqual({alignContent:"stretch"});});});(0,_vitest.describe)("parseLayout - position utilities",function(){(0,_vitest.it)("should parse absolute",function(){(0,_vitest.expect)((0,_layout.parseLayout)("absolute")).toEqual({position:"absolute"});});(0,_vitest.it)("should parse relative",function(){(0,_vitest.expect)((0,_layout.parseLayout)("relative")).toEqual({position:"relative"});});});(0,_vitest.describe)("parseLayout - overflow utilities",function(){(0,_vitest.it)("should parse overflow-hidden",function(){(0,_vitest.expect)((0,_layout.parseLayout)("overflow-hidden")).toEqual({overflow:"hidden"});});(0,_vitest.it)("should parse overflow-visible",function(){(0,_vitest.expect)((0,_layout.parseLayout)("overflow-visible")).toEqual({overflow:"visible"});});(0,_vitest.it)("should parse overflow-scroll",function(){(0,_vitest.expect)((0,_layout.parseLayout)("overflow-scroll")).toEqual({overflow:"scroll"});});});(0,_vitest.describe)("parseLayout - edge cases",function(){(0,_vitest.it)("should return null for invalid classes",function(){(0,_vitest.expect)((0,_layout.parseLayout)("invalid")).toBeNull();(0,_vitest.expect)((0,_layout.parseLayout)("flex-invalid")).toBeNull();(0,_vitest.expect)((0,_layout.parseLayout)("justify")).toBeNull();(0,_vitest.expect)((0,_layout.parseLayout)("items")).toBeNull();});(0,_vitest.it)("should return null for empty string",function(){(0,_vitest.expect)((0,_layout.parseLayout)("")).toBeNull();});(0,_vitest.it)("should return null for partial class names",function(){(0,_vitest.expect)((0,_layout.parseLayout)("fle")).toBeNull();(0,_vitest.expect)((0,_layout.parseLayout)("flexbox")).toBeNull();(0,_vitest.expect)((0,_layout.parseLayout)("justify-start-center")).toBeNull();});(0,_vitest.it)("should return null for CSS classes not in React Native",function(){(0,_vitest.expect)((0,_layout.parseLayout)("inline")).toBeNull();(0,_vitest.expect)((0,_layout.parseLayout)("block")).toBeNull();(0,_vitest.expect)((0,_layout.parseLayout)("inline-block")).toBeNull();(0,_vitest.expect)((0,_layout.parseLayout)("grid")).toBeNull();});});(0,_vitest.describe)("parseLayout - comprehensive coverage",function(){(0,_vitest.it)("should handle all flex direction variants",function(){var directions=["flex-row","flex-row-reverse","flex-col","flex-col-reverse"];directions.forEach(function(dir){(0,_vitest.expect)((0,_layout.parseLayout)(dir)).toBeTruthy();});});(0,_vitest.it)("should handle all flex wrap variants",function(){var wraps=["flex-wrap","flex-wrap-reverse","flex-nowrap"];wraps.forEach(function(wrap){(0,_vitest.expect)((0,_layout.parseLayout)(wrap)).toBeTruthy();});});(0,_vitest.it)("should handle all justify content variants",function(){var justifies=["justify-start","justify-end","justify-center","justify-between","justify-around","justify-evenly"];justifies.forEach(function(justify){(0,_vitest.expect)((0,_layout.parseLayout)(justify)).toBeTruthy();});});(0,_vitest.it)("should handle all align items variants",function(){var aligns=["items-start","items-end","items-center","items-baseline","items-stretch"];aligns.forEach(function(align){(0,_vitest.expect)((0,_layout.parseLayout)(align)).toBeTruthy();});});(0,_vitest.it)("should handle all align self variants",function(){var selfs=["self-auto","self-start","self-end","self-center","self-stretch","self-baseline"];selfs.forEach(function(self){(0,_vitest.expect)((0,_layout.parseLayout)(self)).toBeTruthy();});});(0,_vitest.it)("should handle all align content variants",function(){var contents=["content-start","content-end","content-center","content-between","content-around","content-stretch"];contents.forEach(function(content){(0,_vitest.expect)((0,_layout.parseLayout)(content)).toBeTruthy();});});(0,_vitest.it)("should handle all position variants",function(){var positions=["absolute","relative"];positions.forEach(function(position){(0,_vitest.expect)((0,_layout.parseLayout)(position)).toBeTruthy();});});(0,_vitest.it)("should handle all overflow variants",function(){var overflows=["overflow-hidden","overflow-visible","overflow-scroll"];overflows.forEach(function(overflow){(0,_vitest.expect)((0,_layout.parseLayout)(overflow)).toBeTruthy();});});});(0,_vitest.describe)("parseLayout - case sensitivity",function(){(0,_vitest.it)("should be case-sensitive",function(){(0,_vitest.expect)((0,_layout.parseLayout)("FLEX")).toBeNull();(0,_vitest.expect)((0,_layout.parseLayout)("Flex")).toBeNull();(0,_vitest.expect)((0,_layout.parseLayout)("ABSOLUTE")).toBeNull();});});(0,_vitest.describe)("parseLayout - z-index utilities",function(){(0,_vitest.it)("should parse z-index values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("z-0")).toEqual({zIndex:0});(0,_vitest.expect)((0,_layout.parseLayout)("z-10")).toEqual({zIndex:10});(0,_vitest.expect)((0,_layout.parseLayout)("z-20")).toEqual({zIndex:20});(0,_vitest.expect)((0,_layout.parseLayout)("z-30")).toEqual({zIndex:30});(0,_vitest.expect)((0,_layout.parseLayout)("z-40")).toEqual({zIndex:40});(0,_vitest.expect)((0,_layout.parseLayout)("z-50")).toEqual({zIndex:50});});(0,_vitest.it)("should parse z-auto as 0",function(){(0,_vitest.expect)((0,_layout.parseLayout)("z-auto")).toEqual({zIndex:0});});(0,_vitest.it)("should return null for invalid z-index values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("z-100")).toBeNull();(0,_vitest.expect)((0,_layout.parseLayout)("z-5")).toBeNull();(0,_vitest.expect)((0,_layout.parseLayout)("z-invalid")).toBeNull();});});(0,_vitest.describe)("parseLayout - positioning utilities",function(){(0,_vitest.it)("should parse top values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("top-0")).toEqual({top:0});(0,_vitest.expect)((0,_layout.parseLayout)("top-4")).toEqual({top:16});(0,_vitest.expect)((0,_layout.parseLayout)("top-8")).toEqual({top:32});(0,_vitest.expect)((0,_layout.parseLayout)("top-16")).toEqual({top:64});});(0,_vitest.it)("should parse right values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("right-0")).toEqual({right:0});(0,_vitest.expect)((0,_layout.parseLayout)("right-4")).toEqual({right:16});(0,_vitest.expect)((0,_layout.parseLayout)("right-8")).toEqual({right:32});(0,_vitest.expect)((0,_layout.parseLayout)("right-16")).toEqual({right:64});});(0,_vitest.it)("should parse bottom values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("bottom-0")).toEqual({bottom:0});(0,_vitest.expect)((0,_layout.parseLayout)("bottom-4")).toEqual({bottom:16});(0,_vitest.expect)((0,_layout.parseLayout)("bottom-8")).toEqual({bottom:32});(0,_vitest.expect)((0,_layout.parseLayout)("bottom-16")).toEqual({bottom:64});});(0,_vitest.it)("should parse left values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("left-0")).toEqual({left:0});(0,_vitest.expect)((0,_layout.parseLayout)("left-4")).toEqual({left:16});(0,_vitest.expect)((0,_layout.parseLayout)("left-8")).toEqual({left:32});(0,_vitest.expect)((0,_layout.parseLayout)("left-16")).toEqual({left:64});});(0,_vitest.it)("should parse fractional positioning values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("top-0.5")).toEqual({top:2});(0,_vitest.expect)((0,_layout.parseLayout)("right-1.5")).toEqual({right:6});(0,_vitest.expect)((0,_layout.parseLayout)("bottom-2.5")).toEqual({bottom:10});(0,_vitest.expect)((0,_layout.parseLayout)("left-3.5")).toEqual({left:14});});(0,_vitest.it)("should parse auto positioning values as empty object",function(){(0,_vitest.expect)((0,_layout.parseLayout)("top-auto")).toEqual({});(0,_vitest.expect)((0,_layout.parseLayout)("right-auto")).toEqual({});(0,_vitest.expect)((0,_layout.parseLayout)("bottom-auto")).toEqual({});(0,_vitest.expect)((0,_layout.parseLayout)("left-auto")).toEqual({});});});(0,_vitest.describe)("parseLayout - inset utilities",function(){(0,_vitest.it)("should parse inset (all sides) values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("inset-0")).toEqual({top:0,right:0,bottom:0,left:0});(0,_vitest.expect)((0,_layout.parseLayout)("inset-4")).toEqual({top:16,right:16,bottom:16,left:16});(0,_vitest.expect)((0,_layout.parseLayout)("inset-8")).toEqual({top:32,right:32,bottom:32,left:32});});(0,_vitest.it)("should parse inset-x (horizontal) values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("inset-x-0")).toEqual({left:0,right:0});(0,_vitest.expect)((0,_layout.parseLayout)("inset-x-4")).toEqual({left:16,right:16});(0,_vitest.expect)((0,_layout.parseLayout)("inset-x-8")).toEqual({left:32,right:32});});(0,_vitest.it)("should parse inset-y (vertical) values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("inset-y-0")).toEqual({top:0,bottom:0});(0,_vitest.expect)((0,_layout.parseLayout)("inset-y-4")).toEqual({top:16,bottom:16});(0,_vitest.expect)((0,_layout.parseLayout)("inset-y-8")).toEqual({top:32,bottom:32});});(0,_vitest.it)("should parse fractional inset values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("inset-0.5")).toEqual({top:2,right:2,bottom:2,left:2});(0,_vitest.expect)((0,_layout.parseLayout)("inset-x-1.5")).toEqual({left:6,right:6});(0,_vitest.expect)((0,_layout.parseLayout)("inset-y-2.5")).toEqual({top:10,bottom:10});});(0,_vitest.it)("should return null for invalid inset values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("inset-100")).toBeNull();(0,_vitest.expect)((0,_layout.parseLayout)("inset-x-100")).toBeNull();(0,_vitest.expect)((0,_layout.parseLayout)("inset-y-100")).toBeNull();});});(0,_vitest.describe)("parseLayout - specific property coverage",function(){(0,_vitest.it)("should return unique objects for each class",function(){var flex1=(0,_layout.parseLayout)("flex");var flex2=(0,_layout.parseLayout)("flex");(0,_vitest.expect)(flex1).toEqual(flex2);});(0,_vitest.it)("should handle flex value variations",function(){(0,_vitest.expect)((0,_layout.parseLayout)("flex-1")).toEqual({flex:1});(0,_vitest.expect)((0,_layout.parseLayout)("flex-auto")).toEqual({flex:1});(0,_vitest.expect)((0,_layout.parseLayout)("flex-none")).toEqual({flex:0});});(0,_vitest.it)("should distinguish between similar class names",function(){(0,_vitest.expect)((0,_layout.parseLayout)("flex")).not.toEqual((0,_layout.parseLayout)("flex-1"));(0,_vitest.expect)((0,_layout.parseLayout)("grow")).not.toEqual((0,_layout.parseLayout)("grow-0"));(0,_vitest.expect)((0,_layout.parseLayout)("shrink")).not.toEqual((0,_layout.parseLayout)("shrink-0"));});(0,_vitest.it)("should handle positioning with absolute/relative",function(){(0,_vitest.expect)((0,_layout.parseLayout)("absolute")).toEqual({position:"absolute"});(0,_vitest.expect)((0,_layout.parseLayout)("top-0")).toEqual({top:0});(0,_vitest.expect)((0,_layout.parseLayout)("left-0")).toEqual({left:0});});(0,_vitest.it)("should handle all positioning directions",function(){(0,_vitest.expect)((0,_layout.parseLayout)("top-4")).toHaveProperty("top");(0,_vitest.expect)((0,_layout.parseLayout)("right-4")).toHaveProperty("right");(0,_vitest.expect)((0,_layout.parseLayout)("bottom-4")).toHaveProperty("bottom");(0,_vitest.expect)((0,_layout.parseLayout)("left-4")).toHaveProperty("left");});(0,_vitest.it)("should handle inset shorthand variations",function(){var insetAll=(0,_layout.parseLayout)("inset-4");(0,_vitest.expect)(insetAll).toHaveProperty("top",16);(0,_vitest.expect)(insetAll).toHaveProperty("right",16);(0,_vitest.expect)(insetAll).toHaveProperty("bottom",16);(0,_vitest.expect)(insetAll).toHaveProperty("left",16);var insetX=(0,_layout.parseLayout)("inset-x-4");(0,_vitest.expect)(insetX).toHaveProperty("left",16);(0,_vitest.expect)(insetX).toHaveProperty("right",16);(0,_vitest.expect)(insetX).not.toHaveProperty("top");(0,_vitest.expect)(insetX).not.toHaveProperty("bottom");var insetY=(0,_layout.parseLayout)("inset-y-4");(0,_vitest.expect)(insetY).toHaveProperty("top",16);(0,_vitest.expect)(insetY).toHaveProperty("bottom",16);(0,_vitest.expect)(insetY).not.toHaveProperty("left");(0,_vitest.expect)(insetY).not.toHaveProperty("right");});});
|
|
1
|
+
var _vitest=require("vitest");var _layout=require("./layout");(0,_vitest.describe)("parseLayout - display utilities",function(){(0,_vitest.it)("should parse display flex",function(){(0,_vitest.expect)((0,_layout.parseLayout)("flex")).toEqual({display:"flex"});});(0,_vitest.it)("should parse display hidden",function(){(0,_vitest.expect)((0,_layout.parseLayout)("hidden")).toEqual({display:"none"});});});(0,_vitest.describe)("parseLayout - flex direction utilities",function(){(0,_vitest.it)("should parse flex row",function(){(0,_vitest.expect)((0,_layout.parseLayout)("flex-row")).toEqual({flexDirection:"row"});});(0,_vitest.it)("should parse flex row reverse",function(){(0,_vitest.expect)((0,_layout.parseLayout)("flex-row-reverse")).toEqual({flexDirection:"row-reverse"});});(0,_vitest.it)("should parse flex column",function(){(0,_vitest.expect)((0,_layout.parseLayout)("flex-col")).toEqual({flexDirection:"column"});});(0,_vitest.it)("should parse flex column reverse",function(){(0,_vitest.expect)((0,_layout.parseLayout)("flex-col-reverse")).toEqual({flexDirection:"column-reverse"});});});(0,_vitest.describe)("parseLayout - flex wrap utilities",function(){(0,_vitest.it)("should parse flex wrap",function(){(0,_vitest.expect)((0,_layout.parseLayout)("flex-wrap")).toEqual({flexWrap:"wrap"});});(0,_vitest.it)("should parse flex wrap reverse",function(){(0,_vitest.expect)((0,_layout.parseLayout)("flex-wrap-reverse")).toEqual({flexWrap:"wrap-reverse"});});(0,_vitest.it)("should parse flex nowrap",function(){(0,_vitest.expect)((0,_layout.parseLayout)("flex-nowrap")).toEqual({flexWrap:"nowrap"});});});(0,_vitest.describe)("parseLayout - flex utilities",function(){(0,_vitest.it)("should parse flex-1",function(){(0,_vitest.expect)((0,_layout.parseLayout)("flex-1")).toEqual({flex:1});});(0,_vitest.it)("should parse flex-auto",function(){(0,_vitest.expect)((0,_layout.parseLayout)("flex-auto")).toEqual({flex:1});});(0,_vitest.it)("should parse flex-none",function(){(0,_vitest.expect)((0,_layout.parseLayout)("flex-none")).toEqual({flex:0});});});(0,_vitest.describe)("parseLayout - flex grow/shrink utilities",function(){(0,_vitest.it)("should parse grow",function(){(0,_vitest.expect)((0,_layout.parseLayout)("grow")).toEqual({flexGrow:1});});(0,_vitest.it)("should parse grow-0",function(){(0,_vitest.expect)((0,_layout.parseLayout)("grow-0")).toEqual({flexGrow:0});});(0,_vitest.it)("should parse shrink",function(){(0,_vitest.expect)((0,_layout.parseLayout)("shrink")).toEqual({flexShrink:1});});(0,_vitest.it)("should parse shrink-0",function(){(0,_vitest.expect)((0,_layout.parseLayout)("shrink-0")).toEqual({flexShrink:0});});});(0,_vitest.describe)("parseLayout - justify content utilities",function(){(0,_vitest.it)("should parse justify-start",function(){(0,_vitest.expect)((0,_layout.parseLayout)("justify-start")).toEqual({justifyContent:"flex-start"});});(0,_vitest.it)("should parse justify-end",function(){(0,_vitest.expect)((0,_layout.parseLayout)("justify-end")).toEqual({justifyContent:"flex-end"});});(0,_vitest.it)("should parse justify-center",function(){(0,_vitest.expect)((0,_layout.parseLayout)("justify-center")).toEqual({justifyContent:"center"});});(0,_vitest.it)("should parse justify-between",function(){(0,_vitest.expect)((0,_layout.parseLayout)("justify-between")).toEqual({justifyContent:"space-between"});});(0,_vitest.it)("should parse justify-around",function(){(0,_vitest.expect)((0,_layout.parseLayout)("justify-around")).toEqual({justifyContent:"space-around"});});(0,_vitest.it)("should parse justify-evenly",function(){(0,_vitest.expect)((0,_layout.parseLayout)("justify-evenly")).toEqual({justifyContent:"space-evenly"});});});(0,_vitest.describe)("parseLayout - align items utilities",function(){(0,_vitest.it)("should parse items-start",function(){(0,_vitest.expect)((0,_layout.parseLayout)("items-start")).toEqual({alignItems:"flex-start"});});(0,_vitest.it)("should parse items-end",function(){(0,_vitest.expect)((0,_layout.parseLayout)("items-end")).toEqual({alignItems:"flex-end"});});(0,_vitest.it)("should parse items-center",function(){(0,_vitest.expect)((0,_layout.parseLayout)("items-center")).toEqual({alignItems:"center"});});(0,_vitest.it)("should parse items-baseline",function(){(0,_vitest.expect)((0,_layout.parseLayout)("items-baseline")).toEqual({alignItems:"baseline"});});(0,_vitest.it)("should parse items-stretch",function(){(0,_vitest.expect)((0,_layout.parseLayout)("items-stretch")).toEqual({alignItems:"stretch"});});});(0,_vitest.describe)("parseLayout - align self utilities",function(){(0,_vitest.it)("should parse self-auto",function(){(0,_vitest.expect)((0,_layout.parseLayout)("self-auto")).toEqual({alignSelf:"auto"});});(0,_vitest.it)("should parse self-start",function(){(0,_vitest.expect)((0,_layout.parseLayout)("self-start")).toEqual({alignSelf:"flex-start"});});(0,_vitest.it)("should parse self-end",function(){(0,_vitest.expect)((0,_layout.parseLayout)("self-end")).toEqual({alignSelf:"flex-end"});});(0,_vitest.it)("should parse self-center",function(){(0,_vitest.expect)((0,_layout.parseLayout)("self-center")).toEqual({alignSelf:"center"});});(0,_vitest.it)("should parse self-stretch",function(){(0,_vitest.expect)((0,_layout.parseLayout)("self-stretch")).toEqual({alignSelf:"stretch"});});(0,_vitest.it)("should parse self-baseline",function(){(0,_vitest.expect)((0,_layout.parseLayout)("self-baseline")).toEqual({alignSelf:"baseline"});});});(0,_vitest.describe)("parseLayout - align content utilities",function(){(0,_vitest.it)("should parse content-start",function(){(0,_vitest.expect)((0,_layout.parseLayout)("content-start")).toEqual({alignContent:"flex-start"});});(0,_vitest.it)("should parse content-end",function(){(0,_vitest.expect)((0,_layout.parseLayout)("content-end")).toEqual({alignContent:"flex-end"});});(0,_vitest.it)("should parse content-center",function(){(0,_vitest.expect)((0,_layout.parseLayout)("content-center")).toEqual({alignContent:"center"});});(0,_vitest.it)("should parse content-between",function(){(0,_vitest.expect)((0,_layout.parseLayout)("content-between")).toEqual({alignContent:"space-between"});});(0,_vitest.it)("should parse content-around",function(){(0,_vitest.expect)((0,_layout.parseLayout)("content-around")).toEqual({alignContent:"space-around"});});(0,_vitest.it)("should parse content-stretch",function(){(0,_vitest.expect)((0,_layout.parseLayout)("content-stretch")).toEqual({alignContent:"stretch"});});});(0,_vitest.describe)("parseLayout - position utilities",function(){(0,_vitest.it)("should parse absolute",function(){(0,_vitest.expect)((0,_layout.parseLayout)("absolute")).toEqual({position:"absolute"});});(0,_vitest.it)("should parse relative",function(){(0,_vitest.expect)((0,_layout.parseLayout)("relative")).toEqual({position:"relative"});});});(0,_vitest.describe)("parseLayout - overflow utilities",function(){(0,_vitest.it)("should parse overflow-hidden",function(){(0,_vitest.expect)((0,_layout.parseLayout)("overflow-hidden")).toEqual({overflow:"hidden"});});(0,_vitest.it)("should parse overflow-visible",function(){(0,_vitest.expect)((0,_layout.parseLayout)("overflow-visible")).toEqual({overflow:"visible"});});(0,_vitest.it)("should parse overflow-scroll",function(){(0,_vitest.expect)((0,_layout.parseLayout)("overflow-scroll")).toEqual({overflow:"scroll"});});});(0,_vitest.describe)("parseLayout - edge cases",function(){(0,_vitest.it)("should return null for invalid classes",function(){(0,_vitest.expect)((0,_layout.parseLayout)("invalid")).toBeNull();(0,_vitest.expect)((0,_layout.parseLayout)("flex-invalid")).toBeNull();(0,_vitest.expect)((0,_layout.parseLayout)("justify")).toBeNull();(0,_vitest.expect)((0,_layout.parseLayout)("items")).toBeNull();});(0,_vitest.it)("should return null for empty string",function(){(0,_vitest.expect)((0,_layout.parseLayout)("")).toBeNull();});(0,_vitest.it)("should return null for partial class names",function(){(0,_vitest.expect)((0,_layout.parseLayout)("fle")).toBeNull();(0,_vitest.expect)((0,_layout.parseLayout)("flexbox")).toBeNull();(0,_vitest.expect)((0,_layout.parseLayout)("justify-start-center")).toBeNull();});(0,_vitest.it)("should return null for CSS classes not in React Native",function(){(0,_vitest.expect)((0,_layout.parseLayout)("inline")).toBeNull();(0,_vitest.expect)((0,_layout.parseLayout)("block")).toBeNull();(0,_vitest.expect)((0,_layout.parseLayout)("inline-block")).toBeNull();(0,_vitest.expect)((0,_layout.parseLayout)("grid")).toBeNull();});});(0,_vitest.describe)("parseLayout - comprehensive coverage",function(){(0,_vitest.it)("should handle all flex direction variants",function(){var directions=["flex-row","flex-row-reverse","flex-col","flex-col-reverse"];directions.forEach(function(dir){(0,_vitest.expect)((0,_layout.parseLayout)(dir)).toBeTruthy();});});(0,_vitest.it)("should handle all flex wrap variants",function(){var wraps=["flex-wrap","flex-wrap-reverse","flex-nowrap"];wraps.forEach(function(wrap){(0,_vitest.expect)((0,_layout.parseLayout)(wrap)).toBeTruthy();});});(0,_vitest.it)("should handle all justify content variants",function(){var justifies=["justify-start","justify-end","justify-center","justify-between","justify-around","justify-evenly"];justifies.forEach(function(justify){(0,_vitest.expect)((0,_layout.parseLayout)(justify)).toBeTruthy();});});(0,_vitest.it)("should handle all align items variants",function(){var aligns=["items-start","items-end","items-center","items-baseline","items-stretch"];aligns.forEach(function(align){(0,_vitest.expect)((0,_layout.parseLayout)(align)).toBeTruthy();});});(0,_vitest.it)("should handle all align self variants",function(){var selfs=["self-auto","self-start","self-end","self-center","self-stretch","self-baseline"];selfs.forEach(function(self){(0,_vitest.expect)((0,_layout.parseLayout)(self)).toBeTruthy();});});(0,_vitest.it)("should handle all align content variants",function(){var contents=["content-start","content-end","content-center","content-between","content-around","content-stretch"];contents.forEach(function(content){(0,_vitest.expect)((0,_layout.parseLayout)(content)).toBeTruthy();});});(0,_vitest.it)("should handle all position variants",function(){var positions=["absolute","relative"];positions.forEach(function(position){(0,_vitest.expect)((0,_layout.parseLayout)(position)).toBeTruthy();});});(0,_vitest.it)("should handle all overflow variants",function(){var overflows=["overflow-hidden","overflow-visible","overflow-scroll"];overflows.forEach(function(overflow){(0,_vitest.expect)((0,_layout.parseLayout)(overflow)).toBeTruthy();});});});(0,_vitest.describe)("parseLayout - case sensitivity",function(){(0,_vitest.it)("should be case-sensitive",function(){(0,_vitest.expect)((0,_layout.parseLayout)("FLEX")).toBeNull();(0,_vitest.expect)((0,_layout.parseLayout)("Flex")).toBeNull();(0,_vitest.expect)((0,_layout.parseLayout)("ABSOLUTE")).toBeNull();});});(0,_vitest.describe)("parseLayout - z-index utilities",function(){(0,_vitest.it)("should parse z-index values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("z-0")).toEqual({zIndex:0});(0,_vitest.expect)((0,_layout.parseLayout)("z-10")).toEqual({zIndex:10});(0,_vitest.expect)((0,_layout.parseLayout)("z-20")).toEqual({zIndex:20});(0,_vitest.expect)((0,_layout.parseLayout)("z-30")).toEqual({zIndex:30});(0,_vitest.expect)((0,_layout.parseLayout)("z-40")).toEqual({zIndex:40});(0,_vitest.expect)((0,_layout.parseLayout)("z-50")).toEqual({zIndex:50});});(0,_vitest.it)("should parse z-auto as 0",function(){(0,_vitest.expect)((0,_layout.parseLayout)("z-auto")).toEqual({zIndex:0});});(0,_vitest.it)("should parse arbitrary z-index values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("z-[999]")).toEqual({zIndex:999});(0,_vitest.expect)((0,_layout.parseLayout)("z-[100]")).toEqual({zIndex:100});(0,_vitest.expect)((0,_layout.parseLayout)("z-[1]")).toEqual({zIndex:1});});(0,_vitest.it)("should parse negative arbitrary z-index values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("z-[-1]")).toEqual({zIndex:-1});(0,_vitest.expect)((0,_layout.parseLayout)("z-[-10]")).toEqual({zIndex:-10});(0,_vitest.expect)((0,_layout.parseLayout)("z-[-999]")).toEqual({zIndex:-999});});(0,_vitest.it)("should return null for invalid z-index values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("z-100")).toBeNull();(0,_vitest.expect)((0,_layout.parseLayout)("z-5")).toBeNull();(0,_vitest.expect)((0,_layout.parseLayout)("z-invalid")).toBeNull();});});(0,_vitest.describe)("parseLayout - positioning utilities",function(){(0,_vitest.it)("should parse top values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("top-0")).toEqual({top:0});(0,_vitest.expect)((0,_layout.parseLayout)("top-4")).toEqual({top:16});(0,_vitest.expect)((0,_layout.parseLayout)("top-8")).toEqual({top:32});(0,_vitest.expect)((0,_layout.parseLayout)("top-16")).toEqual({top:64});});(0,_vitest.it)("should parse right values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("right-0")).toEqual({right:0});(0,_vitest.expect)((0,_layout.parseLayout)("right-4")).toEqual({right:16});(0,_vitest.expect)((0,_layout.parseLayout)("right-8")).toEqual({right:32});(0,_vitest.expect)((0,_layout.parseLayout)("right-16")).toEqual({right:64});});(0,_vitest.it)("should parse bottom values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("bottom-0")).toEqual({bottom:0});(0,_vitest.expect)((0,_layout.parseLayout)("bottom-4")).toEqual({bottom:16});(0,_vitest.expect)((0,_layout.parseLayout)("bottom-8")).toEqual({bottom:32});(0,_vitest.expect)((0,_layout.parseLayout)("bottom-16")).toEqual({bottom:64});});(0,_vitest.it)("should parse left values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("left-0")).toEqual({left:0});(0,_vitest.expect)((0,_layout.parseLayout)("left-4")).toEqual({left:16});(0,_vitest.expect)((0,_layout.parseLayout)("left-8")).toEqual({left:32});(0,_vitest.expect)((0,_layout.parseLayout)("left-16")).toEqual({left:64});});(0,_vitest.it)("should parse fractional positioning values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("top-0.5")).toEqual({top:2});(0,_vitest.expect)((0,_layout.parseLayout)("right-1.5")).toEqual({right:6});(0,_vitest.expect)((0,_layout.parseLayout)("bottom-2.5")).toEqual({bottom:10});(0,_vitest.expect)((0,_layout.parseLayout)("left-3.5")).toEqual({left:14});});(0,_vitest.it)("should parse auto positioning values as empty object",function(){(0,_vitest.expect)((0,_layout.parseLayout)("top-auto")).toEqual({});(0,_vitest.expect)((0,_layout.parseLayout)("right-auto")).toEqual({});(0,_vitest.expect)((0,_layout.parseLayout)("bottom-auto")).toEqual({});(0,_vitest.expect)((0,_layout.parseLayout)("left-auto")).toEqual({});});(0,_vitest.it)("should parse arbitrary top values with pixels",function(){(0,_vitest.expect)((0,_layout.parseLayout)("top-[50px]")).toEqual({top:50});(0,_vitest.expect)((0,_layout.parseLayout)("top-[100px]")).toEqual({top:100});(0,_vitest.expect)((0,_layout.parseLayout)("top-[0px]")).toEqual({top:0});});(0,_vitest.it)("should parse arbitrary top values without unit (defaults to px)",function(){(0,_vitest.expect)((0,_layout.parseLayout)("top-[50]")).toEqual({top:50});(0,_vitest.expect)((0,_layout.parseLayout)("top-[100]")).toEqual({top:100});});(0,_vitest.it)("should parse arbitrary top values with percentages",function(){(0,_vitest.expect)((0,_layout.parseLayout)("top-[25%]")).toEqual({top:"25%"});(0,_vitest.expect)((0,_layout.parseLayout)("top-[50%]")).toEqual({top:"50%"});(0,_vitest.expect)((0,_layout.parseLayout)("top-[10.5%]")).toEqual({top:"10.5%"});});(0,_vitest.it)("should parse negative arbitrary top values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("top-[-10px]")).toEqual({top:-10});(0,_vitest.expect)((0,_layout.parseLayout)("top-[-50]")).toEqual({top:-50});(0,_vitest.expect)((0,_layout.parseLayout)("top-[-25%]")).toEqual({top:"-25%"});});(0,_vitest.it)("should parse arbitrary right values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("right-[30px]")).toEqual({right:30});(0,_vitest.expect)((0,_layout.parseLayout)("right-[20]")).toEqual({right:20});(0,_vitest.expect)((0,_layout.parseLayout)("right-[15%]")).toEqual({right:"15%"});(0,_vitest.expect)((0,_layout.parseLayout)("right-[-10px]")).toEqual({right:-10});});(0,_vitest.it)("should parse arbitrary bottom values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("bottom-[40px]")).toEqual({bottom:40});(0,_vitest.expect)((0,_layout.parseLayout)("bottom-[25]")).toEqual({bottom:25});(0,_vitest.expect)((0,_layout.parseLayout)("bottom-[33.333%]")).toEqual({bottom:"33.333%"});(0,_vitest.expect)((0,_layout.parseLayout)("bottom-[-15px]")).toEqual({bottom:-15});});(0,_vitest.it)("should parse arbitrary left values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("left-[60px]")).toEqual({left:60});(0,_vitest.expect)((0,_layout.parseLayout)("left-[45]")).toEqual({left:45});(0,_vitest.expect)((0,_layout.parseLayout)("left-[12.5%]")).toEqual({left:"12.5%"});(0,_vitest.expect)((0,_layout.parseLayout)("left-[-20px]")).toEqual({left:-20});});});(0,_vitest.describe)("parseLayout - inset utilities",function(){(0,_vitest.it)("should parse inset (all sides) values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("inset-0")).toEqual({top:0,right:0,bottom:0,left:0});(0,_vitest.expect)((0,_layout.parseLayout)("inset-4")).toEqual({top:16,right:16,bottom:16,left:16});(0,_vitest.expect)((0,_layout.parseLayout)("inset-8")).toEqual({top:32,right:32,bottom:32,left:32});});(0,_vitest.it)("should parse inset-x (horizontal) values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("inset-x-0")).toEqual({left:0,right:0});(0,_vitest.expect)((0,_layout.parseLayout)("inset-x-4")).toEqual({left:16,right:16});(0,_vitest.expect)((0,_layout.parseLayout)("inset-x-8")).toEqual({left:32,right:32});});(0,_vitest.it)("should parse inset-y (vertical) values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("inset-y-0")).toEqual({top:0,bottom:0});(0,_vitest.expect)((0,_layout.parseLayout)("inset-y-4")).toEqual({top:16,bottom:16});(0,_vitest.expect)((0,_layout.parseLayout)("inset-y-8")).toEqual({top:32,bottom:32});});(0,_vitest.it)("should parse fractional inset values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("inset-0.5")).toEqual({top:2,right:2,bottom:2,left:2});(0,_vitest.expect)((0,_layout.parseLayout)("inset-x-1.5")).toEqual({left:6,right:6});(0,_vitest.expect)((0,_layout.parseLayout)("inset-y-2.5")).toEqual({top:10,bottom:10});});(0,_vitest.it)("should return null for invalid inset values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("inset-100")).toBeNull();(0,_vitest.expect)((0,_layout.parseLayout)("inset-x-100")).toBeNull();(0,_vitest.expect)((0,_layout.parseLayout)("inset-y-100")).toBeNull();});(0,_vitest.it)("should parse arbitrary inset (all sides) values with pixels",function(){(0,_vitest.expect)((0,_layout.parseLayout)("inset-[10px]")).toEqual({top:10,right:10,bottom:10,left:10});(0,_vitest.expect)((0,_layout.parseLayout)("inset-[25px]")).toEqual({top:25,right:25,bottom:25,left:25});(0,_vitest.expect)((0,_layout.parseLayout)("inset-[0px]")).toEqual({top:0,right:0,bottom:0,left:0});});(0,_vitest.it)("should parse arbitrary inset values without unit (defaults to px)",function(){(0,_vitest.expect)((0,_layout.parseLayout)("inset-[15]")).toEqual({top:15,right:15,bottom:15,left:15});(0,_vitest.expect)((0,_layout.parseLayout)("inset-[30]")).toEqual({top:30,right:30,bottom:30,left:30});});(0,_vitest.it)("should parse arbitrary inset values with percentages",function(){(0,_vitest.expect)((0,_layout.parseLayout)("inset-[10%]")).toEqual({top:"10%",right:"10%",bottom:"10%",left:"10%"});(0,_vitest.expect)((0,_layout.parseLayout)("inset-[25%]")).toEqual({top:"25%",right:"25%",bottom:"25%",left:"25%"});(0,_vitest.expect)((0,_layout.parseLayout)("inset-[5.5%]")).toEqual({top:"5.5%",right:"5.5%",bottom:"5.5%",left:"5.5%"});});(0,_vitest.it)("should parse arbitrary inset-x (horizontal) values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("inset-x-[20px]")).toEqual({left:20,right:20});(0,_vitest.expect)((0,_layout.parseLayout)("inset-x-[15]")).toEqual({left:15,right:15});(0,_vitest.expect)((0,_layout.parseLayout)("inset-x-[10%]")).toEqual({left:"10%",right:"10%"});});(0,_vitest.it)("should parse arbitrary inset-y (vertical) values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("inset-y-[30px]")).toEqual({top:30,bottom:30});(0,_vitest.expect)((0,_layout.parseLayout)("inset-y-[25]")).toEqual({top:25,bottom:25});(0,_vitest.expect)((0,_layout.parseLayout)("inset-y-[15%]")).toEqual({top:"15%",bottom:"15%"});});(0,_vitest.it)("should parse negative arbitrary inset values",function(){(0,_vitest.expect)((0,_layout.parseLayout)("inset-[-5px]")).toEqual({top:-5,right:-5,bottom:-5,left:-5});(0,_vitest.expect)((0,_layout.parseLayout)("inset-x-[-10px]")).toEqual({left:-10,right:-10});(0,_vitest.expect)((0,_layout.parseLayout)("inset-y-[-15px]")).toEqual({top:-15,bottom:-15});(0,_vitest.expect)((0,_layout.parseLayout)("inset-[-20%]")).toEqual({top:"-20%",right:"-20%",bottom:"-20%",left:"-20%"});});});(0,_vitest.describe)("parseLayout - specific property coverage",function(){(0,_vitest.it)("should return unique objects for each class",function(){var flex1=(0,_layout.parseLayout)("flex");var flex2=(0,_layout.parseLayout)("flex");(0,_vitest.expect)(flex1).toEqual(flex2);});(0,_vitest.it)("should handle flex value variations",function(){(0,_vitest.expect)((0,_layout.parseLayout)("flex-1")).toEqual({flex:1});(0,_vitest.expect)((0,_layout.parseLayout)("flex-auto")).toEqual({flex:1});(0,_vitest.expect)((0,_layout.parseLayout)("flex-none")).toEqual({flex:0});});(0,_vitest.it)("should distinguish between similar class names",function(){(0,_vitest.expect)((0,_layout.parseLayout)("flex")).not.toEqual((0,_layout.parseLayout)("flex-1"));(0,_vitest.expect)((0,_layout.parseLayout)("grow")).not.toEqual((0,_layout.parseLayout)("grow-0"));(0,_vitest.expect)((0,_layout.parseLayout)("shrink")).not.toEqual((0,_layout.parseLayout)("shrink-0"));});(0,_vitest.it)("should handle positioning with absolute/relative",function(){(0,_vitest.expect)((0,_layout.parseLayout)("absolute")).toEqual({position:"absolute"});(0,_vitest.expect)((0,_layout.parseLayout)("top-0")).toEqual({top:0});(0,_vitest.expect)((0,_layout.parseLayout)("left-0")).toEqual({left:0});});(0,_vitest.it)("should handle all positioning directions",function(){(0,_vitest.expect)((0,_layout.parseLayout)("top-4")).toHaveProperty("top");(0,_vitest.expect)((0,_layout.parseLayout)("right-4")).toHaveProperty("right");(0,_vitest.expect)((0,_layout.parseLayout)("bottom-4")).toHaveProperty("bottom");(0,_vitest.expect)((0,_layout.parseLayout)("left-4")).toHaveProperty("left");});(0,_vitest.it)("should handle inset shorthand variations",function(){var insetAll=(0,_layout.parseLayout)("inset-4");(0,_vitest.expect)(insetAll).toHaveProperty("top",16);(0,_vitest.expect)(insetAll).toHaveProperty("right",16);(0,_vitest.expect)(insetAll).toHaveProperty("bottom",16);(0,_vitest.expect)(insetAll).toHaveProperty("left",16);var insetX=(0,_layout.parseLayout)("inset-x-4");(0,_vitest.expect)(insetX).toHaveProperty("left",16);(0,_vitest.expect)(insetX).toHaveProperty("right",16);(0,_vitest.expect)(insetX).not.toHaveProperty("top");(0,_vitest.expect)(insetX).not.toHaveProperty("bottom");var insetY=(0,_layout.parseLayout)("inset-y-4");(0,_vitest.expect)(insetY).toHaveProperty("top",16);(0,_vitest.expect)(insetY).toHaveProperty("bottom",16);(0,_vitest.expect)(insetY).not.toHaveProperty("left");(0,_vitest.expect)(insetY).not.toHaveProperty("right");});});
|
package/dist/react-native.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mgcrea/react-native-tailwind",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Compile-time Tailwind CSS for React Native with zero runtime overhead",
|
|
5
5
|
"author": "Olivier Louvignes <olivier@mgcrea.io> (https://github.com/mgcrea)",
|
|
6
6
|
"homepage": "https://github.com/mgcrea/react-native-tailwind#readme",
|
|
@@ -319,6 +319,18 @@ describe("parseLayout - z-index utilities", () => {
|
|
|
319
319
|
expect(parseLayout("z-auto")).toEqual({ zIndex: 0 });
|
|
320
320
|
});
|
|
321
321
|
|
|
322
|
+
it("should parse arbitrary z-index values", () => {
|
|
323
|
+
expect(parseLayout("z-[999]")).toEqual({ zIndex: 999 });
|
|
324
|
+
expect(parseLayout("z-[100]")).toEqual({ zIndex: 100 });
|
|
325
|
+
expect(parseLayout("z-[1]")).toEqual({ zIndex: 1 });
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
it("should parse negative arbitrary z-index values", () => {
|
|
329
|
+
expect(parseLayout("z-[-1]")).toEqual({ zIndex: -1 });
|
|
330
|
+
expect(parseLayout("z-[-10]")).toEqual({ zIndex: -10 });
|
|
331
|
+
expect(parseLayout("z-[-999]")).toEqual({ zIndex: -999 });
|
|
332
|
+
});
|
|
333
|
+
|
|
322
334
|
it("should return null for invalid z-index values", () => {
|
|
323
335
|
expect(parseLayout("z-100")).toBeNull();
|
|
324
336
|
expect(parseLayout("z-5")).toBeNull();
|
|
@@ -369,6 +381,50 @@ describe("parseLayout - positioning utilities", () => {
|
|
|
369
381
|
expect(parseLayout("bottom-auto")).toEqual({});
|
|
370
382
|
expect(parseLayout("left-auto")).toEqual({});
|
|
371
383
|
});
|
|
384
|
+
|
|
385
|
+
it("should parse arbitrary top values with pixels", () => {
|
|
386
|
+
expect(parseLayout("top-[50px]")).toEqual({ top: 50 });
|
|
387
|
+
expect(parseLayout("top-[100px]")).toEqual({ top: 100 });
|
|
388
|
+
expect(parseLayout("top-[0px]")).toEqual({ top: 0 });
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
it("should parse arbitrary top values without unit (defaults to px)", () => {
|
|
392
|
+
expect(parseLayout("top-[50]")).toEqual({ top: 50 });
|
|
393
|
+
expect(parseLayout("top-[100]")).toEqual({ top: 100 });
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
it("should parse arbitrary top values with percentages", () => {
|
|
397
|
+
expect(parseLayout("top-[25%]")).toEqual({ top: "25%" });
|
|
398
|
+
expect(parseLayout("top-[50%]")).toEqual({ top: "50%" });
|
|
399
|
+
expect(parseLayout("top-[10.5%]")).toEqual({ top: "10.5%" });
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
it("should parse negative arbitrary top values", () => {
|
|
403
|
+
expect(parseLayout("top-[-10px]")).toEqual({ top: -10 });
|
|
404
|
+
expect(parseLayout("top-[-50]")).toEqual({ top: -50 });
|
|
405
|
+
expect(parseLayout("top-[-25%]")).toEqual({ top: "-25%" });
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
it("should parse arbitrary right values", () => {
|
|
409
|
+
expect(parseLayout("right-[30px]")).toEqual({ right: 30 });
|
|
410
|
+
expect(parseLayout("right-[20]")).toEqual({ right: 20 });
|
|
411
|
+
expect(parseLayout("right-[15%]")).toEqual({ right: "15%" });
|
|
412
|
+
expect(parseLayout("right-[-10px]")).toEqual({ right: -10 });
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
it("should parse arbitrary bottom values", () => {
|
|
416
|
+
expect(parseLayout("bottom-[40px]")).toEqual({ bottom: 40 });
|
|
417
|
+
expect(parseLayout("bottom-[25]")).toEqual({ bottom: 25 });
|
|
418
|
+
expect(parseLayout("bottom-[33.333%]")).toEqual({ bottom: "33.333%" });
|
|
419
|
+
expect(parseLayout("bottom-[-15px]")).toEqual({ bottom: -15 });
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
it("should parse arbitrary left values", () => {
|
|
423
|
+
expect(parseLayout("left-[60px]")).toEqual({ left: 60 });
|
|
424
|
+
expect(parseLayout("left-[45]")).toEqual({ left: 45 });
|
|
425
|
+
expect(parseLayout("left-[12.5%]")).toEqual({ left: "12.5%" });
|
|
426
|
+
expect(parseLayout("left-[-20px]")).toEqual({ left: -20 });
|
|
427
|
+
});
|
|
372
428
|
});
|
|
373
429
|
|
|
374
430
|
describe("parseLayout - inset utilities", () => {
|
|
@@ -401,6 +457,42 @@ describe("parseLayout - inset utilities", () => {
|
|
|
401
457
|
expect(parseLayout("inset-x-100")).toBeNull();
|
|
402
458
|
expect(parseLayout("inset-y-100")).toBeNull();
|
|
403
459
|
});
|
|
460
|
+
|
|
461
|
+
it("should parse arbitrary inset (all sides) values with pixels", () => {
|
|
462
|
+
expect(parseLayout("inset-[10px]")).toEqual({ top: 10, right: 10, bottom: 10, left: 10 });
|
|
463
|
+
expect(parseLayout("inset-[25px]")).toEqual({ top: 25, right: 25, bottom: 25, left: 25 });
|
|
464
|
+
expect(parseLayout("inset-[0px]")).toEqual({ top: 0, right: 0, bottom: 0, left: 0 });
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
it("should parse arbitrary inset values without unit (defaults to px)", () => {
|
|
468
|
+
expect(parseLayout("inset-[15]")).toEqual({ top: 15, right: 15, bottom: 15, left: 15 });
|
|
469
|
+
expect(parseLayout("inset-[30]")).toEqual({ top: 30, right: 30, bottom: 30, left: 30 });
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
it("should parse arbitrary inset values with percentages", () => {
|
|
473
|
+
expect(parseLayout("inset-[10%]")).toEqual({ top: "10%", right: "10%", bottom: "10%", left: "10%" });
|
|
474
|
+
expect(parseLayout("inset-[25%]")).toEqual({ top: "25%", right: "25%", bottom: "25%", left: "25%" });
|
|
475
|
+
expect(parseLayout("inset-[5.5%]")).toEqual({ top: "5.5%", right: "5.5%", bottom: "5.5%", left: "5.5%" });
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
it("should parse arbitrary inset-x (horizontal) values", () => {
|
|
479
|
+
expect(parseLayout("inset-x-[20px]")).toEqual({ left: 20, right: 20 });
|
|
480
|
+
expect(parseLayout("inset-x-[15]")).toEqual({ left: 15, right: 15 });
|
|
481
|
+
expect(parseLayout("inset-x-[10%]")).toEqual({ left: "10%", right: "10%" });
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
it("should parse arbitrary inset-y (vertical) values", () => {
|
|
485
|
+
expect(parseLayout("inset-y-[30px]")).toEqual({ top: 30, bottom: 30 });
|
|
486
|
+
expect(parseLayout("inset-y-[25]")).toEqual({ top: 25, bottom: 25 });
|
|
487
|
+
expect(parseLayout("inset-y-[15%]")).toEqual({ top: "15%", bottom: "15%" });
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
it("should parse negative arbitrary inset values", () => {
|
|
491
|
+
expect(parseLayout("inset-[-5px]")).toEqual({ top: -5, right: -5, bottom: -5, left: -5 });
|
|
492
|
+
expect(parseLayout("inset-x-[-10px]")).toEqual({ left: -10, right: -10 });
|
|
493
|
+
expect(parseLayout("inset-y-[-15px]")).toEqual({ top: -15, bottom: -15 });
|
|
494
|
+
expect(parseLayout("inset-[-20%]")).toEqual({ top: "-20%", right: "-20%", bottom: "-20%", left: "-20%" });
|
|
495
|
+
});
|
|
404
496
|
});
|
|
405
497
|
|
|
406
498
|
describe("parseLayout - specific property coverage", () => {
|
package/src/parser/layout.ts
CHANGED
|
@@ -4,6 +4,60 @@
|
|
|
4
4
|
|
|
5
5
|
import type { StyleObject } from "../types";
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Parse arbitrary inset value: [123px], [123], [50%], [-10px]
|
|
9
|
+
* Returns number for px values, string for % values, null for unsupported units
|
|
10
|
+
*/
|
|
11
|
+
function parseArbitraryInset(value: string): number | string | null {
|
|
12
|
+
// Match: [123px], [123], [-123px], [-123] (pixels)
|
|
13
|
+
const pxMatch = value.match(/^\[(-?\d+)(?:px)?\]$/);
|
|
14
|
+
if (pxMatch) {
|
|
15
|
+
return parseInt(pxMatch[1], 10);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Match: [50%], [-50%] (percentage)
|
|
19
|
+
const percentMatch = value.match(/^\[(-?\d+(?:\.\d+)?)%\]$/);
|
|
20
|
+
if (percentMatch) {
|
|
21
|
+
return `${percentMatch[1]}%`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Unsupported units (rem, em, vh, vw, etc.) - warn and reject
|
|
25
|
+
if (value.startsWith("[") && value.endsWith("]")) {
|
|
26
|
+
if (process.env.NODE_ENV !== "production") {
|
|
27
|
+
console.warn(
|
|
28
|
+
`[react-native-tailwind] Unsupported arbitrary inset unit: ${value}. Only px and % are supported.`,
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Parse arbitrary z-index value: [123], [-10]
|
|
39
|
+
* Returns number for valid z-index, null otherwise
|
|
40
|
+
*/
|
|
41
|
+
function parseArbitraryZIndex(value: string): number | null {
|
|
42
|
+
// Match: [123], [-123] (integers only)
|
|
43
|
+
const zMatch = value.match(/^\[(-?\d+)\]$/);
|
|
44
|
+
if (zMatch) {
|
|
45
|
+
return parseInt(zMatch[1], 10);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Unsupported format - warn and reject
|
|
49
|
+
if (value.startsWith("[") && value.endsWith("]")) {
|
|
50
|
+
if (process.env.NODE_ENV !== "production") {
|
|
51
|
+
console.warn(
|
|
52
|
+
`[react-native-tailwind] Invalid arbitrary z-index: ${value}. Only integers are supported.`,
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
|
|
7
61
|
// Display utilities
|
|
8
62
|
const DISPLAY_MAP: Record<string, StyleObject> = {
|
|
9
63
|
flex: { display: "flex" },
|
|
@@ -128,16 +182,23 @@ export const INSET_SCALE: Record<string, number> = {
|
|
|
128
182
|
* Parse layout classes
|
|
129
183
|
*/
|
|
130
184
|
export function parseLayout(cls: string): StyleObject | null {
|
|
131
|
-
// Z-index: z-0, z-10, z-20, etc.
|
|
185
|
+
// Z-index: z-0, z-10, z-20, z-[999], etc.
|
|
132
186
|
if (cls.startsWith("z-")) {
|
|
133
187
|
const zKey = cls.substring(2);
|
|
188
|
+
|
|
189
|
+
// Arbitrary values: z-[123], z-[-10]
|
|
190
|
+
const arbitraryZ = parseArbitraryZIndex(zKey);
|
|
191
|
+
if (arbitraryZ !== null) {
|
|
192
|
+
return { zIndex: arbitraryZ };
|
|
193
|
+
}
|
|
194
|
+
|
|
134
195
|
const zValue = Z_INDEX_SCALE[zKey];
|
|
135
196
|
if (zValue !== undefined) {
|
|
136
197
|
return { zIndex: zValue };
|
|
137
198
|
}
|
|
138
199
|
}
|
|
139
200
|
|
|
140
|
-
// Top positioning: top-0, top-4, etc.
|
|
201
|
+
// Top positioning: top-0, top-4, top-[10px], top-[50%], etc.
|
|
141
202
|
if (cls.startsWith("top-")) {
|
|
142
203
|
const topKey = cls.substring(4);
|
|
143
204
|
|
|
@@ -146,13 +207,19 @@ export function parseLayout(cls: string): StyleObject | null {
|
|
|
146
207
|
return {};
|
|
147
208
|
}
|
|
148
209
|
|
|
210
|
+
// Arbitrary values: top-[123px], top-[50%], top-[-10px]
|
|
211
|
+
const arbitraryTop = parseArbitraryInset(topKey);
|
|
212
|
+
if (arbitraryTop !== null) {
|
|
213
|
+
return { top: arbitraryTop };
|
|
214
|
+
}
|
|
215
|
+
|
|
149
216
|
const topValue = INSET_SCALE[topKey];
|
|
150
217
|
if (topValue !== undefined) {
|
|
151
218
|
return { top: topValue };
|
|
152
219
|
}
|
|
153
220
|
}
|
|
154
221
|
|
|
155
|
-
// Right positioning: right-0, right-4, etc.
|
|
222
|
+
// Right positioning: right-0, right-4, right-[10px], right-[50%], etc.
|
|
156
223
|
if (cls.startsWith("right-")) {
|
|
157
224
|
const rightKey = cls.substring(6);
|
|
158
225
|
|
|
@@ -161,13 +228,19 @@ export function parseLayout(cls: string): StyleObject | null {
|
|
|
161
228
|
return {};
|
|
162
229
|
}
|
|
163
230
|
|
|
231
|
+
// Arbitrary values: right-[123px], right-[50%], right-[-10px]
|
|
232
|
+
const arbitraryRight = parseArbitraryInset(rightKey);
|
|
233
|
+
if (arbitraryRight !== null) {
|
|
234
|
+
return { right: arbitraryRight };
|
|
235
|
+
}
|
|
236
|
+
|
|
164
237
|
const rightValue = INSET_SCALE[rightKey];
|
|
165
238
|
if (rightValue !== undefined) {
|
|
166
239
|
return { right: rightValue };
|
|
167
240
|
}
|
|
168
241
|
}
|
|
169
242
|
|
|
170
|
-
// Bottom positioning: bottom-0, bottom-4, etc.
|
|
243
|
+
// Bottom positioning: bottom-0, bottom-4, bottom-[10px], bottom-[50%], etc.
|
|
171
244
|
if (cls.startsWith("bottom-")) {
|
|
172
245
|
const bottomKey = cls.substring(7);
|
|
173
246
|
|
|
@@ -176,13 +249,19 @@ export function parseLayout(cls: string): StyleObject | null {
|
|
|
176
249
|
return {};
|
|
177
250
|
}
|
|
178
251
|
|
|
252
|
+
// Arbitrary values: bottom-[123px], bottom-[50%], bottom-[-10px]
|
|
253
|
+
const arbitraryBottom = parseArbitraryInset(bottomKey);
|
|
254
|
+
if (arbitraryBottom !== null) {
|
|
255
|
+
return { bottom: arbitraryBottom };
|
|
256
|
+
}
|
|
257
|
+
|
|
179
258
|
const bottomValue = INSET_SCALE[bottomKey];
|
|
180
259
|
if (bottomValue !== undefined) {
|
|
181
260
|
return { bottom: bottomValue };
|
|
182
261
|
}
|
|
183
262
|
}
|
|
184
263
|
|
|
185
|
-
// Left positioning: left-0, left-4, etc.
|
|
264
|
+
// Left positioning: left-0, left-4, left-[10px], left-[50%], etc.
|
|
186
265
|
if (cls.startsWith("left-")) {
|
|
187
266
|
const leftKey = cls.substring(5);
|
|
188
267
|
|
|
@@ -191,39 +270,66 @@ export function parseLayout(cls: string): StyleObject | null {
|
|
|
191
270
|
return {};
|
|
192
271
|
}
|
|
193
272
|
|
|
273
|
+
// Arbitrary values: left-[123px], left-[50%], left-[-10px]
|
|
274
|
+
const arbitraryLeft = parseArbitraryInset(leftKey);
|
|
275
|
+
if (arbitraryLeft !== null) {
|
|
276
|
+
return { left: arbitraryLeft };
|
|
277
|
+
}
|
|
278
|
+
|
|
194
279
|
const leftValue = INSET_SCALE[leftKey];
|
|
195
280
|
if (leftValue !== undefined) {
|
|
196
281
|
return { left: leftValue };
|
|
197
282
|
}
|
|
198
283
|
}
|
|
199
284
|
|
|
200
|
-
// Inset (
|
|
201
|
-
if (cls.startsWith("inset-")) {
|
|
202
|
-
const insetKey = cls.substring(6);
|
|
203
|
-
const insetValue = INSET_SCALE[insetKey];
|
|
204
|
-
if (insetValue !== undefined) {
|
|
205
|
-
return { top: insetValue, right: insetValue, bottom: insetValue, left: insetValue };
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// Inset X (left and right): inset-x-0, inset-x-4, etc.
|
|
285
|
+
// Inset X (left and right): inset-x-0, inset-x-4, inset-x-[10px], etc.
|
|
210
286
|
if (cls.startsWith("inset-x-")) {
|
|
211
287
|
const insetKey = cls.substring(8);
|
|
288
|
+
|
|
289
|
+
// Arbitrary values: inset-x-[123px], inset-x-[50%]
|
|
290
|
+
const arbitraryInset = parseArbitraryInset(insetKey);
|
|
291
|
+
if (arbitraryInset !== null) {
|
|
292
|
+
return { left: arbitraryInset, right: arbitraryInset };
|
|
293
|
+
}
|
|
294
|
+
|
|
212
295
|
const insetValue = INSET_SCALE[insetKey];
|
|
213
296
|
if (insetValue !== undefined) {
|
|
214
297
|
return { left: insetValue, right: insetValue };
|
|
215
298
|
}
|
|
216
299
|
}
|
|
217
300
|
|
|
218
|
-
// Inset Y (top and bottom): inset-y-0, inset-y-4, etc.
|
|
301
|
+
// Inset Y (top and bottom): inset-y-0, inset-y-4, inset-y-[10px], etc.
|
|
219
302
|
if (cls.startsWith("inset-y-")) {
|
|
220
303
|
const insetKey = cls.substring(8);
|
|
304
|
+
|
|
305
|
+
// Arbitrary values: inset-y-[123px], inset-y-[50%]
|
|
306
|
+
const arbitraryInset = parseArbitraryInset(insetKey);
|
|
307
|
+
if (arbitraryInset !== null) {
|
|
308
|
+
return { top: arbitraryInset, bottom: arbitraryInset };
|
|
309
|
+
}
|
|
310
|
+
|
|
221
311
|
const insetValue = INSET_SCALE[insetKey];
|
|
222
312
|
if (insetValue !== undefined) {
|
|
223
313
|
return { top: insetValue, bottom: insetValue };
|
|
224
314
|
}
|
|
225
315
|
}
|
|
226
316
|
|
|
317
|
+
// Inset (all sides): inset-0, inset-4, inset-[10px], etc.
|
|
318
|
+
if (cls.startsWith("inset-")) {
|
|
319
|
+
const insetKey = cls.substring(6);
|
|
320
|
+
|
|
321
|
+
// Arbitrary values: inset-[123px], inset-[50%]
|
|
322
|
+
const arbitraryInset = parseArbitraryInset(insetKey);
|
|
323
|
+
if (arbitraryInset !== null) {
|
|
324
|
+
return { top: arbitraryInset, right: arbitraryInset, bottom: arbitraryInset, left: arbitraryInset };
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
const insetValue = INSET_SCALE[insetKey];
|
|
328
|
+
if (insetValue !== undefined) {
|
|
329
|
+
return { top: insetValue, right: insetValue, bottom: insetValue, left: insetValue };
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
227
333
|
// Try each lookup table in order
|
|
228
334
|
return (
|
|
229
335
|
DISPLAY_MAP[cls] ??
|
package/src/react-native.d.ts
CHANGED