@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.
@@ -0,0 +1 @@
1
+ var _vitest=require("vitest");var _transforms=require("./transforms");(0,_vitest.describe)("SCALE_MAP",function(){(0,_vitest.it)("should export complete scale map",function(){(0,_vitest.expect)(_transforms.SCALE_MAP).toMatchSnapshot();});});(0,_vitest.describe)("ROTATE_MAP",function(){(0,_vitest.it)("should export complete rotate map",function(){(0,_vitest.expect)(_transforms.ROTATE_MAP).toMatchSnapshot();});});(0,_vitest.describe)("SKEW_MAP",function(){(0,_vitest.it)("should export complete skew map",function(){(0,_vitest.expect)(_transforms.SKEW_MAP).toMatchSnapshot();});});(0,_vitest.describe)("PERSPECTIVE_SCALE",function(){(0,_vitest.it)("should export complete perspective scale",function(){(0,_vitest.expect)(_transforms.PERSPECTIVE_SCALE).toMatchSnapshot();});});(0,_vitest.describe)("parseTransform - scale utilities",function(){(0,_vitest.it)("should parse scale values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("scale-0")).toEqual({transform:[{scale:0}]});(0,_vitest.expect)((0,_transforms.parseTransform)("scale-50")).toEqual({transform:[{scale:0.5}]});(0,_vitest.expect)((0,_transforms.parseTransform)("scale-75")).toEqual({transform:[{scale:0.75}]});(0,_vitest.expect)((0,_transforms.parseTransform)("scale-90")).toEqual({transform:[{scale:0.9}]});(0,_vitest.expect)((0,_transforms.parseTransform)("scale-95")).toEqual({transform:[{scale:0.95}]});(0,_vitest.expect)((0,_transforms.parseTransform)("scale-100")).toEqual({transform:[{scale:1}]});(0,_vitest.expect)((0,_transforms.parseTransform)("scale-105")).toEqual({transform:[{scale:1.05}]});(0,_vitest.expect)((0,_transforms.parseTransform)("scale-110")).toEqual({transform:[{scale:1.1}]});(0,_vitest.expect)((0,_transforms.parseTransform)("scale-125")).toEqual({transform:[{scale:1.25}]});(0,_vitest.expect)((0,_transforms.parseTransform)("scale-150")).toEqual({transform:[{scale:1.5}]});(0,_vitest.expect)((0,_transforms.parseTransform)("scale-200")).toEqual({transform:[{scale:2}]});});(0,_vitest.it)("should parse scaleX values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("scale-x-0")).toEqual({transform:[{scaleX:0}]});(0,_vitest.expect)((0,_transforms.parseTransform)("scale-x-50")).toEqual({transform:[{scaleX:0.5}]});(0,_vitest.expect)((0,_transforms.parseTransform)("scale-x-100")).toEqual({transform:[{scaleX:1}]});(0,_vitest.expect)((0,_transforms.parseTransform)("scale-x-150")).toEqual({transform:[{scaleX:1.5}]});});(0,_vitest.it)("should parse scaleY values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("scale-y-0")).toEqual({transform:[{scaleY:0}]});(0,_vitest.expect)((0,_transforms.parseTransform)("scale-y-75")).toEqual({transform:[{scaleY:0.75}]});(0,_vitest.expect)((0,_transforms.parseTransform)("scale-y-100")).toEqual({transform:[{scaleY:1}]});(0,_vitest.expect)((0,_transforms.parseTransform)("scale-y-125")).toEqual({transform:[{scaleY:1.25}]});});(0,_vitest.it)("should parse arbitrary scale values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("scale-[1.23]")).toEqual({transform:[{scale:1.23}]});(0,_vitest.expect)((0,_transforms.parseTransform)("scale-[0.5]")).toEqual({transform:[{scale:0.5}]});(0,_vitest.expect)((0,_transforms.parseTransform)("scale-[2.5]")).toEqual({transform:[{scale:2.5}]});(0,_vitest.expect)((0,_transforms.parseTransform)("scale-x-[1.5]")).toEqual({transform:[{scaleX:1.5}]});(0,_vitest.expect)((0,_transforms.parseTransform)("scale-y-[0.8]")).toEqual({transform:[{scaleY:0.8}]});});(0,_vitest.it)("should parse negative arbitrary scale values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("scale-[-1]")).toEqual({transform:[{scale:-1}]});(0,_vitest.expect)((0,_transforms.parseTransform)("scale-x-[-0.5]")).toEqual({transform:[{scaleX:-0.5}]});});(0,_vitest.it)("should return null for invalid scale values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("scale-999")).toBeNull();(0,_vitest.expect)((0,_transforms.parseTransform)("scale-invalid")).toBeNull();});});(0,_vitest.describe)("parseTransform - rotate utilities",function(){(0,_vitest.it)("should parse rotate values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("rotate-0")).toEqual({transform:[{rotate:"0deg"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("rotate-1")).toEqual({transform:[{rotate:"1deg"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("rotate-45")).toEqual({transform:[{rotate:"45deg"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("rotate-90")).toEqual({transform:[{rotate:"90deg"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("rotate-180")).toEqual({transform:[{rotate:"180deg"}]});});(0,_vitest.it)("should parse negative rotate values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("-rotate-45")).toEqual({transform:[{rotate:"-45deg"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("-rotate-90")).toEqual({transform:[{rotate:"-90deg"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("-rotate-180")).toEqual({transform:[{rotate:"-180deg"}]});});(0,_vitest.it)("should parse arbitrary rotate values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("rotate-[37deg]")).toEqual({transform:[{rotate:"37deg"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("rotate-[15.5deg]")).toEqual({transform:[{rotate:"15.5deg"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("-rotate-[15deg]")).toEqual({transform:[{rotate:"-15deg"}]});});(0,_vitest.it)("should parse rotateX values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("rotate-x-45")).toEqual({transform:[{rotateX:"45deg"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("rotate-x-90")).toEqual({transform:[{rotateX:"90deg"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("-rotate-x-45")).toEqual({transform:[{rotateX:"-45deg"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("rotate-x-[30deg]")).toEqual({transform:[{rotateX:"30deg"}]});});(0,_vitest.it)("should parse rotateY values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("rotate-y-45")).toEqual({transform:[{rotateY:"45deg"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("rotate-y-180")).toEqual({transform:[{rotateY:"180deg"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("-rotate-y-90")).toEqual({transform:[{rotateY:"-90deg"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("rotate-y-[60deg]")).toEqual({transform:[{rotateY:"60deg"}]});});(0,_vitest.it)("should parse rotateZ values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("rotate-z-45")).toEqual({transform:[{rotateZ:"45deg"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("rotate-z-90")).toEqual({transform:[{rotateZ:"90deg"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("-rotate-z-12")).toEqual({transform:[{rotateZ:"-12deg"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("rotate-z-[75deg]")).toEqual({transform:[{rotateZ:"75deg"}]});});(0,_vitest.it)("should return null for invalid rotate values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("rotate-999")).toBeNull();(0,_vitest.expect)((0,_transforms.parseTransform)("rotate-invalid")).toBeNull();});});(0,_vitest.describe)("parseTransform - translate utilities",function(){(0,_vitest.it)("should parse translateX values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("translate-x-0")).toEqual({transform:[{translateX:0}]});(0,_vitest.expect)((0,_transforms.parseTransform)("translate-x-4")).toEqual({transform:[{translateX:16}]});(0,_vitest.expect)((0,_transforms.parseTransform)("translate-x-8")).toEqual({transform:[{translateX:32}]});(0,_vitest.expect)((0,_transforms.parseTransform)("translate-x-16")).toEqual({transform:[{translateX:64}]});});(0,_vitest.it)("should parse negative translateX values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("-translate-x-4")).toEqual({transform:[{translateX:-16}]});(0,_vitest.expect)((0,_transforms.parseTransform)("-translate-x-8")).toEqual({transform:[{translateX:-32}]});});(0,_vitest.it)("should parse translateY values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("translate-y-0")).toEqual({transform:[{translateY:0}]});(0,_vitest.expect)((0,_transforms.parseTransform)("translate-y-4")).toEqual({transform:[{translateY:16}]});(0,_vitest.expect)((0,_transforms.parseTransform)("translate-y-12")).toEqual({transform:[{translateY:48}]});});(0,_vitest.it)("should parse negative translateY values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("-translate-y-4")).toEqual({transform:[{translateY:-16}]});(0,_vitest.expect)((0,_transforms.parseTransform)("-translate-y-10")).toEqual({transform:[{translateY:-40}]});});(0,_vitest.it)("should parse arbitrary translateX pixel values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("translate-x-[123px]")).toEqual({transform:[{translateX:123}]});(0,_vitest.expect)((0,_transforms.parseTransform)("translate-x-[50]")).toEqual({transform:[{translateX:50}]});(0,_vitest.expect)((0,_transforms.parseTransform)("-translate-x-[100px]")).toEqual({transform:[{translateX:-100}]});});(0,_vitest.it)("should parse arbitrary translateX percentage values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("translate-x-[50%]")).toEqual({transform:[{translateX:"50%"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("translate-x-[33.333%]")).toEqual({transform:[{translateX:"33.333%"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("-translate-x-[25%]")).toEqual({transform:[{translateX:"-25%"}]});});(0,_vitest.it)("should parse arbitrary translateY pixel values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("translate-y-[200px]")).toEqual({transform:[{translateY:200}]});(0,_vitest.expect)((0,_transforms.parseTransform)("-translate-y-[75px]")).toEqual({transform:[{translateY:-75}]});});(0,_vitest.it)("should parse arbitrary translateY percentage values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("translate-y-[100%]")).toEqual({transform:[{translateY:"100%"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("-translate-y-[50%]")).toEqual({transform:[{translateY:"-50%"}]});});(0,_vitest.it)("should return null for invalid translate values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("translate-x-999")).toBeNull();(0,_vitest.expect)((0,_transforms.parseTransform)("translate-y-invalid")).toBeNull();});});(0,_vitest.describe)("parseTransform - skew utilities",function(){(0,_vitest.it)("should parse skewX values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("skew-x-0")).toEqual({transform:[{skewX:"0deg"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("skew-x-1")).toEqual({transform:[{skewX:"1deg"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("skew-x-3")).toEqual({transform:[{skewX:"3deg"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("skew-x-6")).toEqual({transform:[{skewX:"6deg"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("skew-x-12")).toEqual({transform:[{skewX:"12deg"}]});});(0,_vitest.it)("should parse negative skewX values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("-skew-x-3")).toEqual({transform:[{skewX:"-3deg"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("-skew-x-12")).toEqual({transform:[{skewX:"-12deg"}]});});(0,_vitest.it)("should parse skewY values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("skew-y-0")).toEqual({transform:[{skewY:"0deg"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("skew-y-2")).toEqual({transform:[{skewY:"2deg"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("skew-y-6")).toEqual({transform:[{skewY:"6deg"}]});});(0,_vitest.it)("should parse negative skewY values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("-skew-y-2")).toEqual({transform:[{skewY:"-2deg"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("-skew-y-6")).toEqual({transform:[{skewY:"-6deg"}]});});(0,_vitest.it)("should parse arbitrary skew values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("skew-x-[15deg]")).toEqual({transform:[{skewX:"15deg"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("skew-y-[20deg]")).toEqual({transform:[{skewY:"20deg"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("-skew-x-[8deg]")).toEqual({transform:[{skewX:"-8deg"}]});});(0,_vitest.it)("should return null for invalid skew values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("skew-x-999")).toBeNull();(0,_vitest.expect)((0,_transforms.parseTransform)("skew-y-invalid")).toBeNull();});});(0,_vitest.describe)("parseTransform - perspective utility",function(){(0,_vitest.it)("should parse perspective values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("perspective-0")).toEqual({transform:[{perspective:0}]});(0,_vitest.expect)((0,_transforms.parseTransform)("perspective-100")).toEqual({transform:[{perspective:100}]});(0,_vitest.expect)((0,_transforms.parseTransform)("perspective-500")).toEqual({transform:[{perspective:500}]});(0,_vitest.expect)((0,_transforms.parseTransform)("perspective-1000")).toEqual({transform:[{perspective:1000}]});});(0,_vitest.it)("should parse arbitrary perspective values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("perspective-[1500]")).toEqual({transform:[{perspective:1500}]});(0,_vitest.expect)((0,_transforms.parseTransform)("perspective-[2000]")).toEqual({transform:[{perspective:2000}]});(0,_vitest.expect)((0,_transforms.parseTransform)("perspective-[250]")).toEqual({transform:[{perspective:250}]});});(0,_vitest.it)("should return null for invalid perspective values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("perspective-99")).toBeNull();(0,_vitest.expect)((0,_transforms.parseTransform)("perspective-invalid")).toBeNull();});});(0,_vitest.describe)("parseTransform - transform origin warning",function(){(0,_vitest.it)("should return null and warn for origin classes",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("origin-center")).toBeNull();(0,_vitest.expect)((0,_transforms.parseTransform)("origin-top")).toBeNull();(0,_vitest.expect)((0,_transforms.parseTransform)("origin-left")).toBeNull();});});(0,_vitest.describe)("parseTransform - edge cases",function(){(0,_vitest.it)("should return null for invalid classes",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("invalid")).toBeNull();(0,_vitest.expect)((0,_transforms.parseTransform)("transform")).toBeNull();(0,_vitest.expect)((0,_transforms.parseTransform)("transforms")).toBeNull();});(0,_vitest.it)("should return null for empty string",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("")).toBeNull();});(0,_vitest.it)("should return null for partial class names",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("scal")).toBeNull();(0,_vitest.expect)((0,_transforms.parseTransform)("rotat")).toBeNull();(0,_vitest.expect)((0,_transforms.parseTransform)("translat")).toBeNull();});(0,_vitest.it)("should handle all transform types returning arrays",function(){var scaleResult=(0,_transforms.parseTransform)("scale-110");(0,_vitest.expect)(scaleResult).toHaveProperty("transform");(0,_vitest.expect)(Array.isArray(scaleResult==null?void 0:scaleResult.transform)).toBe(true);var rotateResult=(0,_transforms.parseTransform)("rotate-45");(0,_vitest.expect)(rotateResult).toHaveProperty("transform");(0,_vitest.expect)(Array.isArray(rotateResult==null?void 0:rotateResult.transform)).toBe(true);var translateResult=(0,_transforms.parseTransform)("translate-x-4");(0,_vitest.expect)(translateResult).toHaveProperty("transform");(0,_vitest.expect)(Array.isArray(translateResult==null?void 0:translateResult.transform)).toBe(true);});});(0,_vitest.describe)("parseTransform - comprehensive coverage",function(){(0,_vitest.it)("should handle all scale variants",function(){var scaleClasses=["scale-0","scale-50","scale-100","scale-150"];scaleClasses.forEach(function(cls){(0,_vitest.expect)((0,_transforms.parseTransform)(cls)).toBeTruthy();});});(0,_vitest.it)("should handle all rotate variants",function(){var rotateClasses=["rotate-0","rotate-45","rotate-90","rotate-180"];rotateClasses.forEach(function(cls){(0,_vitest.expect)((0,_transforms.parseTransform)(cls)).toBeTruthy();});});(0,_vitest.it)("should handle all translate variants",function(){var translateClasses=["translate-x-0","translate-x-4","translate-y-8","-translate-x-2"];translateClasses.forEach(function(cls){(0,_vitest.expect)((0,_transforms.parseTransform)(cls)).toBeTruthy();});});(0,_vitest.it)("should handle all skew variants",function(){var skewClasses=["skew-x-3","skew-y-6","-skew-x-12"];skewClasses.forEach(function(cls){(0,_vitest.expect)((0,_transforms.parseTransform)(cls)).toBeTruthy();});});(0,_vitest.it)("should handle all perspective variants",function(){var perspectiveClasses=["perspective-100","perspective-500","perspective-1000"];perspectiveClasses.forEach(function(cls){(0,_vitest.expect)((0,_transforms.parseTransform)(cls)).toBeTruthy();});});});(0,_vitest.describe)("parseTransform - case sensitivity",function(){(0,_vitest.it)("should be case-sensitive",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("SCALE-110")).toBeNull();(0,_vitest.expect)((0,_transforms.parseTransform)("Scale-110")).toBeNull();(0,_vitest.expect)((0,_transforms.parseTransform)("ROTATE-45")).toBeNull();});});
@@ -1 +1 @@
1
- var _vitest=require("vitest");var _typography=require("./typography");(0,_vitest.describe)("FONT_SIZES",function(){(0,_vitest.it)("should export complete font size scale",function(){(0,_vitest.expect)(_typography.FONT_SIZES).toMatchSnapshot();});});(0,_vitest.describe)("LETTER_SPACING_SCALE",function(){(0,_vitest.it)("should export complete letter spacing scale",function(){(0,_vitest.expect)(_typography.LETTER_SPACING_SCALE).toMatchSnapshot();});});(0,_vitest.describe)("parseTypography - font size",function(){(0,_vitest.it)("should parse font size with preset values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-xs")).toEqual({fontSize:12});(0,_vitest.expect)((0,_typography.parseTypography)("text-sm")).toEqual({fontSize:14});(0,_vitest.expect)((0,_typography.parseTypography)("text-base")).toEqual({fontSize:16});(0,_vitest.expect)((0,_typography.parseTypography)("text-lg")).toEqual({fontSize:18});(0,_vitest.expect)((0,_typography.parseTypography)("text-xl")).toEqual({fontSize:20});(0,_vitest.expect)((0,_typography.parseTypography)("text-2xl")).toEqual({fontSize:24});(0,_vitest.expect)((0,_typography.parseTypography)("text-3xl")).toEqual({fontSize:30});(0,_vitest.expect)((0,_typography.parseTypography)("text-4xl")).toEqual({fontSize:36});(0,_vitest.expect)((0,_typography.parseTypography)("text-5xl")).toEqual({fontSize:48});(0,_vitest.expect)((0,_typography.parseTypography)("text-6xl")).toEqual({fontSize:60});(0,_vitest.expect)((0,_typography.parseTypography)("text-7xl")).toEqual({fontSize:72});(0,_vitest.expect)((0,_typography.parseTypography)("text-8xl")).toEqual({fontSize:96});(0,_vitest.expect)((0,_typography.parseTypography)("text-9xl")).toEqual({fontSize:128});});(0,_vitest.it)("should parse font size with arbitrary pixel values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-[18px]")).toEqual({fontSize:18});(0,_vitest.expect)((0,_typography.parseTypography)("text-[18]")).toEqual({fontSize:18});(0,_vitest.expect)((0,_typography.parseTypography)("text-[22px]")).toEqual({fontSize:22});(0,_vitest.expect)((0,_typography.parseTypography)("text-[22]")).toEqual({fontSize:22});(0,_vitest.expect)((0,_typography.parseTypography)("text-[100px]")).toEqual({fontSize:100});});});(0,_vitest.describe)("parseTypography - font weight",function(){(0,_vitest.it)("should parse font weight values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("font-thin")).toEqual({fontWeight:"100"});(0,_vitest.expect)((0,_typography.parseTypography)("font-extralight")).toEqual({fontWeight:"200"});(0,_vitest.expect)((0,_typography.parseTypography)("font-light")).toEqual({fontWeight:"300"});(0,_vitest.expect)((0,_typography.parseTypography)("font-normal")).toEqual({fontWeight:"400"});(0,_vitest.expect)((0,_typography.parseTypography)("font-medium")).toEqual({fontWeight:"500"});(0,_vitest.expect)((0,_typography.parseTypography)("font-semibold")).toEqual({fontWeight:"600"});(0,_vitest.expect)((0,_typography.parseTypography)("font-bold")).toEqual({fontWeight:"700"});(0,_vitest.expect)((0,_typography.parseTypography)("font-extrabold")).toEqual({fontWeight:"800"});(0,_vitest.expect)((0,_typography.parseTypography)("font-black")).toEqual({fontWeight:"900"});});});(0,_vitest.describe)("parseTypography - font style",function(){(0,_vitest.it)("should parse font style values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("italic")).toEqual({fontStyle:"italic"});(0,_vitest.expect)((0,_typography.parseTypography)("not-italic")).toEqual({fontStyle:"normal"});});});(0,_vitest.describe)("parseTypography - text alignment",function(){(0,_vitest.it)("should parse text alignment values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-left")).toEqual({textAlign:"left"});(0,_vitest.expect)((0,_typography.parseTypography)("text-center")).toEqual({textAlign:"center"});(0,_vitest.expect)((0,_typography.parseTypography)("text-right")).toEqual({textAlign:"right"});(0,_vitest.expect)((0,_typography.parseTypography)("text-justify")).toEqual({textAlign:"justify"});});});(0,_vitest.describe)("parseTypography - text decoration",function(){(0,_vitest.it)("should parse text decoration values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("underline")).toEqual({textDecorationLine:"underline"});(0,_vitest.expect)((0,_typography.parseTypography)("line-through")).toEqual({textDecorationLine:"line-through"});(0,_vitest.expect)((0,_typography.parseTypography)("no-underline")).toEqual({textDecorationLine:"none"});});});(0,_vitest.describe)("parseTypography - text transform",function(){(0,_vitest.it)("should parse text transform values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("uppercase")).toEqual({textTransform:"uppercase"});(0,_vitest.expect)((0,_typography.parseTypography)("lowercase")).toEqual({textTransform:"lowercase"});(0,_vitest.expect)((0,_typography.parseTypography)("capitalize")).toEqual({textTransform:"capitalize"});(0,_vitest.expect)((0,_typography.parseTypography)("normal-case")).toEqual({textTransform:"none"});});});(0,_vitest.describe)("parseTypography - line height",function(){(0,_vitest.it)("should parse line height with preset values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("leading-none")).toEqual({lineHeight:16});(0,_vitest.expect)((0,_typography.parseTypography)("leading-tight")).toEqual({lineHeight:20});(0,_vitest.expect)((0,_typography.parseTypography)("leading-snug")).toEqual({lineHeight:22});(0,_vitest.expect)((0,_typography.parseTypography)("leading-normal")).toEqual({lineHeight:24});(0,_vitest.expect)((0,_typography.parseTypography)("leading-relaxed")).toEqual({lineHeight:28});(0,_vitest.expect)((0,_typography.parseTypography)("leading-loose")).toEqual({lineHeight:32});});(0,_vitest.it)("should parse line height with arbitrary pixel values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("leading-[24px]")).toEqual({lineHeight:24});(0,_vitest.expect)((0,_typography.parseTypography)("leading-[24]")).toEqual({lineHeight:24});(0,_vitest.expect)((0,_typography.parseTypography)("leading-[30px]")).toEqual({lineHeight:30});(0,_vitest.expect)((0,_typography.parseTypography)("leading-[30]")).toEqual({lineHeight:30});(0,_vitest.expect)((0,_typography.parseTypography)("leading-[50px]")).toEqual({lineHeight:50});});});(0,_vitest.describe)("parseTypography - letter spacing",function(){(0,_vitest.it)("should parse letter spacing with preset values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("tracking-tighter")).toEqual({letterSpacing:-0.8});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-tight")).toEqual({letterSpacing:-0.4});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-normal")).toEqual({letterSpacing:0});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-wide")).toEqual({letterSpacing:0.4});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-wider")).toEqual({letterSpacing:0.8});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-widest")).toEqual({letterSpacing:1.6});});});(0,_vitest.describe)("parseTypography - edge cases",function(){(0,_vitest.it)("should return null for invalid classes",function(){(0,_vitest.expect)((0,_typography.parseTypography)("invalid")).toBeNull();(0,_vitest.expect)((0,_typography.parseTypography)("text")).toBeNull();(0,_vitest.expect)((0,_typography.parseTypography)("font")).toBeNull();(0,_vitest.expect)((0,_typography.parseTypography)("leading")).toBeNull();(0,_vitest.expect)((0,_typography.parseTypography)("tracking")).toBeNull();});(0,_vitest.it)("should return null for invalid font size values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-invalid")).toBeNull();(0,_vitest.expect)((0,_typography.parseTypography)("text-10xl")).toBeNull();});(0,_vitest.it)("should return null for invalid font weight values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("font-invalid")).toBeNull();(0,_vitest.expect)((0,_typography.parseTypography)("font-100")).toBeNull();});(0,_vitest.it)("should return null for arbitrary values with unsupported units",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-[16rem]")).toBeNull();(0,_vitest.expect)((0,_typography.parseTypography)("text-[2em]")).toBeNull();(0,_vitest.expect)((0,_typography.parseTypography)("leading-[2rem]")).toBeNull();(0,_vitest.expect)((0,_typography.parseTypography)("leading-[1.5em]")).toBeNull();});(0,_vitest.it)("should return null for malformed arbitrary values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-[16")).toBeNull();(0,_vitest.expect)((0,_typography.parseTypography)("text-16]")).toBeNull();(0,_vitest.expect)((0,_typography.parseTypography)("text-[]")).toBeNull();(0,_vitest.expect)((0,_typography.parseTypography)("leading-[24")).toBeNull();(0,_vitest.expect)((0,_typography.parseTypography)("leading-24]")).toBeNull();});(0,_vitest.it)("should not match partial class names",function(){(0,_vitest.expect)((0,_typography.parseTypography)("mytext-lg")).toBeNull();(0,_vitest.expect)((0,_typography.parseTypography)("font-bold-extra")).toBeNull();(0,_vitest.expect)((0,_typography.parseTypography)("italic-text")).toBeNull();});});(0,_vitest.describe)("parseTypography - comprehensive coverage",function(){(0,_vitest.it)("should handle all typography categories independently",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-base")).toEqual({fontSize:16});(0,_vitest.expect)((0,_typography.parseTypography)("font-bold")).toEqual({fontWeight:"700"});(0,_vitest.expect)((0,_typography.parseTypography)("italic")).toEqual({fontStyle:"italic"});(0,_vitest.expect)((0,_typography.parseTypography)("text-center")).toEqual({textAlign:"center"});(0,_vitest.expect)((0,_typography.parseTypography)("underline")).toEqual({textDecorationLine:"underline"});(0,_vitest.expect)((0,_typography.parseTypography)("uppercase")).toEqual({textTransform:"uppercase"});(0,_vitest.expect)((0,_typography.parseTypography)("leading-normal")).toEqual({lineHeight:24});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-wide")).toEqual({letterSpacing:0.4});});(0,_vitest.it)("should handle arbitrary values for font size and line height",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-[19px]")).toEqual({fontSize:19});(0,_vitest.expect)((0,_typography.parseTypography)("text-[19]")).toEqual({fontSize:19});(0,_vitest.expect)((0,_typography.parseTypography)("leading-[26px]")).toEqual({lineHeight:26});(0,_vitest.expect)((0,_typography.parseTypography)("leading-[26]")).toEqual({lineHeight:26});});(0,_vitest.it)("should handle edge case values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-xs")).toEqual({fontSize:12});(0,_vitest.expect)((0,_typography.parseTypography)("text-9xl")).toEqual({fontSize:128});(0,_vitest.expect)((0,_typography.parseTypography)("leading-none")).toEqual({lineHeight:16});(0,_vitest.expect)((0,_typography.parseTypography)("leading-loose")).toEqual({lineHeight:32});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-tighter")).toEqual({letterSpacing:-0.8});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-widest")).toEqual({letterSpacing:1.6});});});
1
+ var _vitest=require("vitest");var _typography=require("./typography");(0,_vitest.describe)("FONT_SIZES",function(){(0,_vitest.it)("should export complete font size scale",function(){(0,_vitest.expect)(_typography.FONT_SIZES).toMatchSnapshot();});});(0,_vitest.describe)("LETTER_SPACING_SCALE",function(){(0,_vitest.it)("should export complete letter spacing scale",function(){(0,_vitest.expect)(_typography.LETTER_SPACING_SCALE).toMatchSnapshot();});});(0,_vitest.describe)("parseTypography - font size",function(){(0,_vitest.it)("should parse font size with preset values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-xs")).toEqual({fontSize:12});(0,_vitest.expect)((0,_typography.parseTypography)("text-sm")).toEqual({fontSize:14});(0,_vitest.expect)((0,_typography.parseTypography)("text-base")).toEqual({fontSize:16});(0,_vitest.expect)((0,_typography.parseTypography)("text-lg")).toEqual({fontSize:18});(0,_vitest.expect)((0,_typography.parseTypography)("text-xl")).toEqual({fontSize:20});(0,_vitest.expect)((0,_typography.parseTypography)("text-2xl")).toEqual({fontSize:24});(0,_vitest.expect)((0,_typography.parseTypography)("text-3xl")).toEqual({fontSize:30});(0,_vitest.expect)((0,_typography.parseTypography)("text-4xl")).toEqual({fontSize:36});(0,_vitest.expect)((0,_typography.parseTypography)("text-5xl")).toEqual({fontSize:48});(0,_vitest.expect)((0,_typography.parseTypography)("text-6xl")).toEqual({fontSize:60});(0,_vitest.expect)((0,_typography.parseTypography)("text-7xl")).toEqual({fontSize:72});(0,_vitest.expect)((0,_typography.parseTypography)("text-8xl")).toEqual({fontSize:96});(0,_vitest.expect)((0,_typography.parseTypography)("text-9xl")).toEqual({fontSize:128});});(0,_vitest.it)("should parse font size with arbitrary pixel values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-[13px]")).toEqual({fontSize:13});(0,_vitest.expect)((0,_typography.parseTypography)("text-[13]")).toEqual({fontSize:13});(0,_vitest.expect)((0,_typography.parseTypography)("text-[18px]")).toEqual({fontSize:18});(0,_vitest.expect)((0,_typography.parseTypography)("text-[18]")).toEqual({fontSize:18});(0,_vitest.expect)((0,_typography.parseTypography)("text-[22px]")).toEqual({fontSize:22});(0,_vitest.expect)((0,_typography.parseTypography)("text-[22]")).toEqual({fontSize:22});(0,_vitest.expect)((0,_typography.parseTypography)("text-[100px]")).toEqual({fontSize:100});});});(0,_vitest.describe)("parseTypography - font weight",function(){(0,_vitest.it)("should parse font weight values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("font-thin")).toEqual({fontWeight:"100"});(0,_vitest.expect)((0,_typography.parseTypography)("font-extralight")).toEqual({fontWeight:"200"});(0,_vitest.expect)((0,_typography.parseTypography)("font-light")).toEqual({fontWeight:"300"});(0,_vitest.expect)((0,_typography.parseTypography)("font-normal")).toEqual({fontWeight:"400"});(0,_vitest.expect)((0,_typography.parseTypography)("font-medium")).toEqual({fontWeight:"500"});(0,_vitest.expect)((0,_typography.parseTypography)("font-semibold")).toEqual({fontWeight:"600"});(0,_vitest.expect)((0,_typography.parseTypography)("font-bold")).toEqual({fontWeight:"700"});(0,_vitest.expect)((0,_typography.parseTypography)("font-extrabold")).toEqual({fontWeight:"800"});(0,_vitest.expect)((0,_typography.parseTypography)("font-black")).toEqual({fontWeight:"900"});});});(0,_vitest.describe)("parseTypography - font style",function(){(0,_vitest.it)("should parse font style values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("italic")).toEqual({fontStyle:"italic"});(0,_vitest.expect)((0,_typography.parseTypography)("not-italic")).toEqual({fontStyle:"normal"});});});(0,_vitest.describe)("parseTypography - text alignment",function(){(0,_vitest.it)("should parse text alignment values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-left")).toEqual({textAlign:"left"});(0,_vitest.expect)((0,_typography.parseTypography)("text-center")).toEqual({textAlign:"center"});(0,_vitest.expect)((0,_typography.parseTypography)("text-right")).toEqual({textAlign:"right"});(0,_vitest.expect)((0,_typography.parseTypography)("text-justify")).toEqual({textAlign:"justify"});});});(0,_vitest.describe)("parseTypography - text decoration",function(){(0,_vitest.it)("should parse text decoration values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("underline")).toEqual({textDecorationLine:"underline"});(0,_vitest.expect)((0,_typography.parseTypography)("line-through")).toEqual({textDecorationLine:"line-through"});(0,_vitest.expect)((0,_typography.parseTypography)("no-underline")).toEqual({textDecorationLine:"none"});});});(0,_vitest.describe)("parseTypography - text transform",function(){(0,_vitest.it)("should parse text transform values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("uppercase")).toEqual({textTransform:"uppercase"});(0,_vitest.expect)((0,_typography.parseTypography)("lowercase")).toEqual({textTransform:"lowercase"});(0,_vitest.expect)((0,_typography.parseTypography)("capitalize")).toEqual({textTransform:"capitalize"});(0,_vitest.expect)((0,_typography.parseTypography)("normal-case")).toEqual({textTransform:"none"});});});(0,_vitest.describe)("parseTypography - line height",function(){(0,_vitest.it)("should parse line height with preset values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("leading-none")).toEqual({lineHeight:16});(0,_vitest.expect)((0,_typography.parseTypography)("leading-tight")).toEqual({lineHeight:20});(0,_vitest.expect)((0,_typography.parseTypography)("leading-snug")).toEqual({lineHeight:22});(0,_vitest.expect)((0,_typography.parseTypography)("leading-normal")).toEqual({lineHeight:24});(0,_vitest.expect)((0,_typography.parseTypography)("leading-relaxed")).toEqual({lineHeight:28});(0,_vitest.expect)((0,_typography.parseTypography)("leading-loose")).toEqual({lineHeight:32});});(0,_vitest.it)("should parse line height with arbitrary pixel values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("leading-[24px]")).toEqual({lineHeight:24});(0,_vitest.expect)((0,_typography.parseTypography)("leading-[24]")).toEqual({lineHeight:24});(0,_vitest.expect)((0,_typography.parseTypography)("leading-[30px]")).toEqual({lineHeight:30});(0,_vitest.expect)((0,_typography.parseTypography)("leading-[30]")).toEqual({lineHeight:30});(0,_vitest.expect)((0,_typography.parseTypography)("leading-[50px]")).toEqual({lineHeight:50});});});(0,_vitest.describe)("parseTypography - letter spacing",function(){(0,_vitest.it)("should parse letter spacing with preset values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("tracking-tighter")).toEqual({letterSpacing:-0.8});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-tight")).toEqual({letterSpacing:-0.4});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-normal")).toEqual({letterSpacing:0});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-wide")).toEqual({letterSpacing:0.4});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-wider")).toEqual({letterSpacing:0.8});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-widest")).toEqual({letterSpacing:1.6});});});(0,_vitest.describe)("parseTypography - edge cases",function(){(0,_vitest.it)("should return null for invalid classes",function(){(0,_vitest.expect)((0,_typography.parseTypography)("invalid")).toBeNull();(0,_vitest.expect)((0,_typography.parseTypography)("text")).toBeNull();(0,_vitest.expect)((0,_typography.parseTypography)("font")).toBeNull();(0,_vitest.expect)((0,_typography.parseTypography)("leading")).toBeNull();(0,_vitest.expect)((0,_typography.parseTypography)("tracking")).toBeNull();});(0,_vitest.it)("should return null for invalid font size values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-invalid")).toBeNull();(0,_vitest.expect)((0,_typography.parseTypography)("text-10xl")).toBeNull();});(0,_vitest.it)("should return null for invalid font weight values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("font-invalid")).toBeNull();(0,_vitest.expect)((0,_typography.parseTypography)("font-100")).toBeNull();});(0,_vitest.it)("should return null for arbitrary values with unsupported units",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-[16rem]")).toBeNull();(0,_vitest.expect)((0,_typography.parseTypography)("text-[2em]")).toBeNull();(0,_vitest.expect)((0,_typography.parseTypography)("leading-[2rem]")).toBeNull();(0,_vitest.expect)((0,_typography.parseTypography)("leading-[1.5em]")).toBeNull();});(0,_vitest.it)("should return null for malformed arbitrary values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-[16")).toBeNull();(0,_vitest.expect)((0,_typography.parseTypography)("text-16]")).toBeNull();(0,_vitest.expect)((0,_typography.parseTypography)("text-[]")).toBeNull();(0,_vitest.expect)((0,_typography.parseTypography)("leading-[24")).toBeNull();(0,_vitest.expect)((0,_typography.parseTypography)("leading-24]")).toBeNull();});(0,_vitest.it)("should not match partial class names",function(){(0,_vitest.expect)((0,_typography.parseTypography)("mytext-lg")).toBeNull();(0,_vitest.expect)((0,_typography.parseTypography)("font-bold-extra")).toBeNull();(0,_vitest.expect)((0,_typography.parseTypography)("italic-text")).toBeNull();});});(0,_vitest.describe)("parseTypography - comprehensive coverage",function(){(0,_vitest.it)("should handle all typography categories independently",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-base")).toEqual({fontSize:16});(0,_vitest.expect)((0,_typography.parseTypography)("font-bold")).toEqual({fontWeight:"700"});(0,_vitest.expect)((0,_typography.parseTypography)("italic")).toEqual({fontStyle:"italic"});(0,_vitest.expect)((0,_typography.parseTypography)("text-center")).toEqual({textAlign:"center"});(0,_vitest.expect)((0,_typography.parseTypography)("underline")).toEqual({textDecorationLine:"underline"});(0,_vitest.expect)((0,_typography.parseTypography)("uppercase")).toEqual({textTransform:"uppercase"});(0,_vitest.expect)((0,_typography.parseTypography)("leading-normal")).toEqual({lineHeight:24});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-wide")).toEqual({letterSpacing:0.4});});(0,_vitest.it)("should handle arbitrary values for font size and line height",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-[19px]")).toEqual({fontSize:19});(0,_vitest.expect)((0,_typography.parseTypography)("text-[19]")).toEqual({fontSize:19});(0,_vitest.expect)((0,_typography.parseTypography)("leading-[26px]")).toEqual({lineHeight:26});(0,_vitest.expect)((0,_typography.parseTypography)("leading-[26]")).toEqual({lineHeight:26});});(0,_vitest.it)("should handle edge case values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-xs")).toEqual({fontSize:12});(0,_vitest.expect)((0,_typography.parseTypography)("text-9xl")).toEqual({fontSize:128});(0,_vitest.expect)((0,_typography.parseTypography)("leading-none")).toEqual({lineHeight:16});(0,_vitest.expect)((0,_typography.parseTypography)("leading-loose")).toEqual({lineHeight:32});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-tighter")).toEqual({letterSpacing:-0.8});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-widest")).toEqual({letterSpacing:1.6});});});
package/dist/types.d.ts CHANGED
@@ -3,10 +3,40 @@
3
3
  */
4
4
  import type { ImageStyle, TextStyle, ViewStyle } from "react-native";
5
5
  export type RNStyle = ViewStyle | TextStyle | ImageStyle;
6
- export type StyleObject = Record<string, string | number | {
6
+ export type TransformStyle = {
7
+ scale?: number;
8
+ } | {
9
+ scaleX?: number;
10
+ } | {
11
+ scaleY?: number;
12
+ } | {
13
+ rotate?: string;
14
+ } | {
15
+ rotateX?: string;
16
+ } | {
17
+ rotateY?: string;
18
+ } | {
19
+ rotateZ?: string;
20
+ } | {
21
+ translateX?: number | string;
22
+ } | {
23
+ translateY?: number | string;
24
+ } | {
25
+ skewX?: string;
26
+ } | {
27
+ skewY?: string;
28
+ } | {
29
+ perspective?: number;
30
+ };
31
+ export type ShadowOffsetStyle = {
7
32
  width: number;
8
33
  height: number;
9
- } | undefined>;
34
+ };
35
+ export type StyleObject = {
36
+ [key: string]: string | number | ShadowOffsetStyle | TransformStyle[] | undefined;
37
+ shadowOffset?: ShadowOffsetStyle;
38
+ transform?: TransformStyle[];
39
+ };
10
40
  export type SpacingValue = number;
11
41
  export type ColorValue = string;
12
42
  export type Parser = (className: string) => StyleObject | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mgcrea/react-native-tailwind",
3
- "version": "0.5.2",
3
+ "version": "0.6.0",
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",
@@ -192,6 +192,16 @@ describe("parseColor - edge cases", () => {
192
192
  expect(parseColor("bg-[rgb(255,0,0)]")).toBeNull(); // RGB format not supported
193
193
  });
194
194
 
195
+ it("should return null for non-color arbitrary values (to let other parsers handle them)", () => {
196
+ // These should be handled by typography parser
197
+ expect(parseColor("text-[13px]")).toBeNull();
198
+ expect(parseColor("text-[18px]")).toBeNull();
199
+ expect(parseColor("text-[24]")).toBeNull();
200
+ // These should be handled by sizing parser
201
+ expect(parseColor("bg-[100%]")).toBeNull();
202
+ expect(parseColor("bg-[50px]")).toBeNull();
203
+ });
204
+
195
205
  it("should not match partial class names", () => {
196
206
  expect(parseColor("background-blue-500")).toBeNull();
197
207
  expect(parseColor("textcolor-red-500")).toBeNull();
@@ -241,8 +241,13 @@ export function parseColor(cls: string, customColors?: Record<string, string>):
241
241
  };
242
242
 
243
243
  // Background color: bg-blue-500, bg-blue-500/50, bg-[#ff0000]/80
244
+ // Only parse arbitrary values that look like colors (start with #)
244
245
  if (cls.startsWith("bg-")) {
245
246
  const colorKey = cls.substring(3);
247
+ // Skip arbitrary values that don't look like colors (e.g., bg-[100%] is sizing)
248
+ if (colorKey.startsWith("[") && !colorKey.startsWith("[#")) {
249
+ return null;
250
+ }
246
251
  const color = parseColorWithOpacity(colorKey);
247
252
  if (color) {
248
253
  return { backgroundColor: color };
@@ -250,8 +255,13 @@ export function parseColor(cls: string, customColors?: Record<string, string>):
250
255
  }
251
256
 
252
257
  // Text color: text-blue-500, text-blue-500/50, text-[#ff0000]/80
258
+ // Only parse arbitrary values that look like colors (start with #)
253
259
  if (cls.startsWith("text-")) {
254
260
  const colorKey = cls.substring(5);
261
+ // Skip arbitrary values that don't look like colors (e.g., text-[13px] is font size)
262
+ if (colorKey.startsWith("[") && !colorKey.startsWith("[#")) {
263
+ return null;
264
+ }
255
265
  const color = parseColorWithOpacity(colorKey);
256
266
  if (color) {
257
267
  return { color: color };
@@ -261,6 +271,10 @@ export function parseColor(cls: string, customColors?: Record<string, string>):
261
271
  // Border color: border-blue-500, border-blue-500/50, border-[#ff0000]/80
262
272
  if (cls.startsWith("border-") && !cls.match(/^border-[0-9]/)) {
263
273
  const colorKey = cls.substring(7);
274
+ // Skip arbitrary values that don't look like colors (e.g., border-[3px] is width)
275
+ if (colorKey.startsWith("[") && !colorKey.startsWith("[#")) {
276
+ return null;
277
+ }
264
278
  const color = parseColorWithOpacity(colorKey);
265
279
  if (color) {
266
280
  return { borderColor: color };
@@ -11,6 +11,7 @@ import { parseLayout } from "./layout";
11
11
  import { parseShadow } from "./shadows";
12
12
  import { parseSizing } from "./sizing";
13
13
  import { parseSpacing } from "./spacing";
14
+ import { parseTransform } from "./transforms";
14
15
  import { parseTypography } from "./typography";
15
16
 
16
17
  /**
@@ -50,6 +51,7 @@ export function parseClass(cls: string, customColors?: Record<string, string>):
50
51
  parseSizing,
51
52
  parseShadow,
52
53
  parseAspectRatio,
54
+ parseTransform,
53
55
  ];
54
56
 
55
57
  for (const parser of parsers) {
@@ -75,6 +77,7 @@ export { parseLayout } from "./layout";
75
77
  export { parseShadow } from "./shadows";
76
78
  export { parseSizing } from "./sizing";
77
79
  export { parseSpacing } from "./spacing";
80
+ export { parseTransform } from "./transforms";
78
81
  export { parseTypography } from "./typography";
79
82
 
80
83
  // Re-export modifier utilities
@@ -0,0 +1,318 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { PERSPECTIVE_SCALE, ROTATE_MAP, SCALE_MAP, SKEW_MAP, parseTransform } from "./transforms";
3
+
4
+ describe("SCALE_MAP", () => {
5
+ it("should export complete scale map", () => {
6
+ expect(SCALE_MAP).toMatchSnapshot();
7
+ });
8
+ });
9
+
10
+ describe("ROTATE_MAP", () => {
11
+ it("should export complete rotate map", () => {
12
+ expect(ROTATE_MAP).toMatchSnapshot();
13
+ });
14
+ });
15
+
16
+ describe("SKEW_MAP", () => {
17
+ it("should export complete skew map", () => {
18
+ expect(SKEW_MAP).toMatchSnapshot();
19
+ });
20
+ });
21
+
22
+ describe("PERSPECTIVE_SCALE", () => {
23
+ it("should export complete perspective scale", () => {
24
+ expect(PERSPECTIVE_SCALE).toMatchSnapshot();
25
+ });
26
+ });
27
+
28
+ describe("parseTransform - scale utilities", () => {
29
+ it("should parse scale values", () => {
30
+ expect(parseTransform("scale-0")).toEqual({ transform: [{ scale: 0 }] });
31
+ expect(parseTransform("scale-50")).toEqual({ transform: [{ scale: 0.5 }] });
32
+ expect(parseTransform("scale-75")).toEqual({ transform: [{ scale: 0.75 }] });
33
+ expect(parseTransform("scale-90")).toEqual({ transform: [{ scale: 0.9 }] });
34
+ expect(parseTransform("scale-95")).toEqual({ transform: [{ scale: 0.95 }] });
35
+ expect(parseTransform("scale-100")).toEqual({ transform: [{ scale: 1 }] });
36
+ expect(parseTransform("scale-105")).toEqual({ transform: [{ scale: 1.05 }] });
37
+ expect(parseTransform("scale-110")).toEqual({ transform: [{ scale: 1.1 }] });
38
+ expect(parseTransform("scale-125")).toEqual({ transform: [{ scale: 1.25 }] });
39
+ expect(parseTransform("scale-150")).toEqual({ transform: [{ scale: 1.5 }] });
40
+ expect(parseTransform("scale-200")).toEqual({ transform: [{ scale: 2 }] });
41
+ });
42
+
43
+ it("should parse scaleX values", () => {
44
+ expect(parseTransform("scale-x-0")).toEqual({ transform: [{ scaleX: 0 }] });
45
+ expect(parseTransform("scale-x-50")).toEqual({ transform: [{ scaleX: 0.5 }] });
46
+ expect(parseTransform("scale-x-100")).toEqual({ transform: [{ scaleX: 1 }] });
47
+ expect(parseTransform("scale-x-150")).toEqual({ transform: [{ scaleX: 1.5 }] });
48
+ });
49
+
50
+ it("should parse scaleY values", () => {
51
+ expect(parseTransform("scale-y-0")).toEqual({ transform: [{ scaleY: 0 }] });
52
+ expect(parseTransform("scale-y-75")).toEqual({ transform: [{ scaleY: 0.75 }] });
53
+ expect(parseTransform("scale-y-100")).toEqual({ transform: [{ scaleY: 1 }] });
54
+ expect(parseTransform("scale-y-125")).toEqual({ transform: [{ scaleY: 1.25 }] });
55
+ });
56
+
57
+ it("should parse arbitrary scale values", () => {
58
+ expect(parseTransform("scale-[1.23]")).toEqual({ transform: [{ scale: 1.23 }] });
59
+ expect(parseTransform("scale-[0.5]")).toEqual({ transform: [{ scale: 0.5 }] });
60
+ expect(parseTransform("scale-[2.5]")).toEqual({ transform: [{ scale: 2.5 }] });
61
+ expect(parseTransform("scale-x-[1.5]")).toEqual({ transform: [{ scaleX: 1.5 }] });
62
+ expect(parseTransform("scale-y-[0.8]")).toEqual({ transform: [{ scaleY: 0.8 }] });
63
+ });
64
+
65
+ it("should parse negative arbitrary scale values", () => {
66
+ expect(parseTransform("scale-[-1]")).toEqual({ transform: [{ scale: -1 }] });
67
+ expect(parseTransform("scale-x-[-0.5]")).toEqual({ transform: [{ scaleX: -0.5 }] });
68
+ });
69
+
70
+ it("should return null for invalid scale values", () => {
71
+ expect(parseTransform("scale-999")).toBeNull();
72
+ expect(parseTransform("scale-invalid")).toBeNull();
73
+ });
74
+ });
75
+
76
+ describe("parseTransform - rotate utilities", () => {
77
+ it("should parse rotate values", () => {
78
+ expect(parseTransform("rotate-0")).toEqual({ transform: [{ rotate: "0deg" }] });
79
+ expect(parseTransform("rotate-1")).toEqual({ transform: [{ rotate: "1deg" }] });
80
+ expect(parseTransform("rotate-45")).toEqual({ transform: [{ rotate: "45deg" }] });
81
+ expect(parseTransform("rotate-90")).toEqual({ transform: [{ rotate: "90deg" }] });
82
+ expect(parseTransform("rotate-180")).toEqual({ transform: [{ rotate: "180deg" }] });
83
+ });
84
+
85
+ it("should parse negative rotate values", () => {
86
+ expect(parseTransform("-rotate-45")).toEqual({ transform: [{ rotate: "-45deg" }] });
87
+ expect(parseTransform("-rotate-90")).toEqual({ transform: [{ rotate: "-90deg" }] });
88
+ expect(parseTransform("-rotate-180")).toEqual({ transform: [{ rotate: "-180deg" }] });
89
+ });
90
+
91
+ it("should parse arbitrary rotate values", () => {
92
+ expect(parseTransform("rotate-[37deg]")).toEqual({ transform: [{ rotate: "37deg" }] });
93
+ expect(parseTransform("rotate-[15.5deg]")).toEqual({ transform: [{ rotate: "15.5deg" }] });
94
+ expect(parseTransform("-rotate-[15deg]")).toEqual({ transform: [{ rotate: "-15deg" }] });
95
+ });
96
+
97
+ it("should parse rotateX values", () => {
98
+ expect(parseTransform("rotate-x-45")).toEqual({ transform: [{ rotateX: "45deg" }] });
99
+ expect(parseTransform("rotate-x-90")).toEqual({ transform: [{ rotateX: "90deg" }] });
100
+ expect(parseTransform("-rotate-x-45")).toEqual({ transform: [{ rotateX: "-45deg" }] });
101
+ expect(parseTransform("rotate-x-[30deg]")).toEqual({ transform: [{ rotateX: "30deg" }] });
102
+ });
103
+
104
+ it("should parse rotateY values", () => {
105
+ expect(parseTransform("rotate-y-45")).toEqual({ transform: [{ rotateY: "45deg" }] });
106
+ expect(parseTransform("rotate-y-180")).toEqual({ transform: [{ rotateY: "180deg" }] });
107
+ expect(parseTransform("-rotate-y-90")).toEqual({ transform: [{ rotateY: "-90deg" }] });
108
+ expect(parseTransform("rotate-y-[60deg]")).toEqual({ transform: [{ rotateY: "60deg" }] });
109
+ });
110
+
111
+ it("should parse rotateZ values", () => {
112
+ expect(parseTransform("rotate-z-45")).toEqual({ transform: [{ rotateZ: "45deg" }] });
113
+ expect(parseTransform("rotate-z-90")).toEqual({ transform: [{ rotateZ: "90deg" }] });
114
+ expect(parseTransform("-rotate-z-12")).toEqual({ transform: [{ rotateZ: "-12deg" }] });
115
+ expect(parseTransform("rotate-z-[75deg]")).toEqual({ transform: [{ rotateZ: "75deg" }] });
116
+ });
117
+
118
+ it("should return null for invalid rotate values", () => {
119
+ expect(parseTransform("rotate-999")).toBeNull();
120
+ expect(parseTransform("rotate-invalid")).toBeNull();
121
+ });
122
+ });
123
+
124
+ describe("parseTransform - translate utilities", () => {
125
+ it("should parse translateX values", () => {
126
+ expect(parseTransform("translate-x-0")).toEqual({ transform: [{ translateX: 0 }] });
127
+ expect(parseTransform("translate-x-4")).toEqual({ transform: [{ translateX: 16 }] });
128
+ expect(parseTransform("translate-x-8")).toEqual({ transform: [{ translateX: 32 }] });
129
+ expect(parseTransform("translate-x-16")).toEqual({ transform: [{ translateX: 64 }] });
130
+ });
131
+
132
+ it("should parse negative translateX values", () => {
133
+ expect(parseTransform("-translate-x-4")).toEqual({ transform: [{ translateX: -16 }] });
134
+ expect(parseTransform("-translate-x-8")).toEqual({ transform: [{ translateX: -32 }] });
135
+ });
136
+
137
+ it("should parse translateY values", () => {
138
+ expect(parseTransform("translate-y-0")).toEqual({ transform: [{ translateY: 0 }] });
139
+ expect(parseTransform("translate-y-4")).toEqual({ transform: [{ translateY: 16 }] });
140
+ expect(parseTransform("translate-y-12")).toEqual({ transform: [{ translateY: 48 }] });
141
+ });
142
+
143
+ it("should parse negative translateY values", () => {
144
+ expect(parseTransform("-translate-y-4")).toEqual({ transform: [{ translateY: -16 }] });
145
+ expect(parseTransform("-translate-y-10")).toEqual({ transform: [{ translateY: -40 }] });
146
+ });
147
+
148
+ it("should parse arbitrary translateX pixel values", () => {
149
+ expect(parseTransform("translate-x-[123px]")).toEqual({ transform: [{ translateX: 123 }] });
150
+ expect(parseTransform("translate-x-[50]")).toEqual({ transform: [{ translateX: 50 }] });
151
+ expect(parseTransform("-translate-x-[100px]")).toEqual({ transform: [{ translateX: -100 }] });
152
+ });
153
+
154
+ it("should parse arbitrary translateX percentage values", () => {
155
+ expect(parseTransform("translate-x-[50%]")).toEqual({ transform: [{ translateX: "50%" }] });
156
+ expect(parseTransform("translate-x-[33.333%]")).toEqual({ transform: [{ translateX: "33.333%" }] });
157
+ expect(parseTransform("-translate-x-[25%]")).toEqual({ transform: [{ translateX: "-25%" }] });
158
+ });
159
+
160
+ it("should parse arbitrary translateY pixel values", () => {
161
+ expect(parseTransform("translate-y-[200px]")).toEqual({ transform: [{ translateY: 200 }] });
162
+ expect(parseTransform("-translate-y-[75px]")).toEqual({ transform: [{ translateY: -75 }] });
163
+ });
164
+
165
+ it("should parse arbitrary translateY percentage values", () => {
166
+ expect(parseTransform("translate-y-[100%]")).toEqual({ transform: [{ translateY: "100%" }] });
167
+ expect(parseTransform("-translate-y-[50%]")).toEqual({ transform: [{ translateY: "-50%" }] });
168
+ });
169
+
170
+ it("should return null for invalid translate values", () => {
171
+ expect(parseTransform("translate-x-999")).toBeNull();
172
+ expect(parseTransform("translate-y-invalid")).toBeNull();
173
+ });
174
+ });
175
+
176
+ describe("parseTransform - skew utilities", () => {
177
+ it("should parse skewX values", () => {
178
+ expect(parseTransform("skew-x-0")).toEqual({ transform: [{ skewX: "0deg" }] });
179
+ expect(parseTransform("skew-x-1")).toEqual({ transform: [{ skewX: "1deg" }] });
180
+ expect(parseTransform("skew-x-3")).toEqual({ transform: [{ skewX: "3deg" }] });
181
+ expect(parseTransform("skew-x-6")).toEqual({ transform: [{ skewX: "6deg" }] });
182
+ expect(parseTransform("skew-x-12")).toEqual({ transform: [{ skewX: "12deg" }] });
183
+ });
184
+
185
+ it("should parse negative skewX values", () => {
186
+ expect(parseTransform("-skew-x-3")).toEqual({ transform: [{ skewX: "-3deg" }] });
187
+ expect(parseTransform("-skew-x-12")).toEqual({ transform: [{ skewX: "-12deg" }] });
188
+ });
189
+
190
+ it("should parse skewY values", () => {
191
+ expect(parseTransform("skew-y-0")).toEqual({ transform: [{ skewY: "0deg" }] });
192
+ expect(parseTransform("skew-y-2")).toEqual({ transform: [{ skewY: "2deg" }] });
193
+ expect(parseTransform("skew-y-6")).toEqual({ transform: [{ skewY: "6deg" }] });
194
+ });
195
+
196
+ it("should parse negative skewY values", () => {
197
+ expect(parseTransform("-skew-y-2")).toEqual({ transform: [{ skewY: "-2deg" }] });
198
+ expect(parseTransform("-skew-y-6")).toEqual({ transform: [{ skewY: "-6deg" }] });
199
+ });
200
+
201
+ it("should parse arbitrary skew values", () => {
202
+ expect(parseTransform("skew-x-[15deg]")).toEqual({ transform: [{ skewX: "15deg" }] });
203
+ expect(parseTransform("skew-y-[20deg]")).toEqual({ transform: [{ skewY: "20deg" }] });
204
+ expect(parseTransform("-skew-x-[8deg]")).toEqual({ transform: [{ skewX: "-8deg" }] });
205
+ });
206
+
207
+ it("should return null for invalid skew values", () => {
208
+ expect(parseTransform("skew-x-999")).toBeNull();
209
+ expect(parseTransform("skew-y-invalid")).toBeNull();
210
+ });
211
+ });
212
+
213
+ describe("parseTransform - perspective utility", () => {
214
+ it("should parse perspective values", () => {
215
+ expect(parseTransform("perspective-0")).toEqual({ transform: [{ perspective: 0 }] });
216
+ expect(parseTransform("perspective-100")).toEqual({ transform: [{ perspective: 100 }] });
217
+ expect(parseTransform("perspective-500")).toEqual({ transform: [{ perspective: 500 }] });
218
+ expect(parseTransform("perspective-1000")).toEqual({ transform: [{ perspective: 1000 }] });
219
+ });
220
+
221
+ it("should parse arbitrary perspective values", () => {
222
+ expect(parseTransform("perspective-[1500]")).toEqual({ transform: [{ perspective: 1500 }] });
223
+ expect(parseTransform("perspective-[2000]")).toEqual({ transform: [{ perspective: 2000 }] });
224
+ expect(parseTransform("perspective-[250]")).toEqual({ transform: [{ perspective: 250 }] });
225
+ });
226
+
227
+ it("should return null for invalid perspective values", () => {
228
+ expect(parseTransform("perspective-99")).toBeNull();
229
+ expect(parseTransform("perspective-invalid")).toBeNull();
230
+ });
231
+ });
232
+
233
+ describe("parseTransform - transform origin warning", () => {
234
+ it("should return null and warn for origin classes", () => {
235
+ // Note: warnings are logged in development, testing null return is sufficient
236
+ expect(parseTransform("origin-center")).toBeNull();
237
+ expect(parseTransform("origin-top")).toBeNull();
238
+ expect(parseTransform("origin-left")).toBeNull();
239
+ });
240
+ });
241
+
242
+ describe("parseTransform - edge cases", () => {
243
+ it("should return null for invalid classes", () => {
244
+ expect(parseTransform("invalid")).toBeNull();
245
+ expect(parseTransform("transform")).toBeNull();
246
+ expect(parseTransform("transforms")).toBeNull();
247
+ });
248
+
249
+ it("should return null for empty string", () => {
250
+ expect(parseTransform("")).toBeNull();
251
+ });
252
+
253
+ it("should return null for partial class names", () => {
254
+ expect(parseTransform("scal")).toBeNull();
255
+ expect(parseTransform("rotat")).toBeNull();
256
+ expect(parseTransform("translat")).toBeNull();
257
+ });
258
+
259
+ it("should handle all transform types returning arrays", () => {
260
+ // Verify all transforms return arrays (required for React Native)
261
+ const scaleResult = parseTransform("scale-110");
262
+ expect(scaleResult).toHaveProperty("transform");
263
+ expect(Array.isArray(scaleResult?.transform)).toBe(true);
264
+
265
+ const rotateResult = parseTransform("rotate-45");
266
+ expect(rotateResult).toHaveProperty("transform");
267
+ expect(Array.isArray(rotateResult?.transform)).toBe(true);
268
+
269
+ const translateResult = parseTransform("translate-x-4");
270
+ expect(translateResult).toHaveProperty("transform");
271
+ expect(Array.isArray(translateResult?.transform)).toBe(true);
272
+ });
273
+ });
274
+
275
+ describe("parseTransform - comprehensive coverage", () => {
276
+ it("should handle all scale variants", () => {
277
+ const scaleClasses = ["scale-0", "scale-50", "scale-100", "scale-150"];
278
+ scaleClasses.forEach((cls) => {
279
+ expect(parseTransform(cls)).toBeTruthy();
280
+ });
281
+ });
282
+
283
+ it("should handle all rotate variants", () => {
284
+ const rotateClasses = ["rotate-0", "rotate-45", "rotate-90", "rotate-180"];
285
+ rotateClasses.forEach((cls) => {
286
+ expect(parseTransform(cls)).toBeTruthy();
287
+ });
288
+ });
289
+
290
+ it("should handle all translate variants", () => {
291
+ const translateClasses = ["translate-x-0", "translate-x-4", "translate-y-8", "-translate-x-2"];
292
+ translateClasses.forEach((cls) => {
293
+ expect(parseTransform(cls)).toBeTruthy();
294
+ });
295
+ });
296
+
297
+ it("should handle all skew variants", () => {
298
+ const skewClasses = ["skew-x-3", "skew-y-6", "-skew-x-12"];
299
+ skewClasses.forEach((cls) => {
300
+ expect(parseTransform(cls)).toBeTruthy();
301
+ });
302
+ });
303
+
304
+ it("should handle all perspective variants", () => {
305
+ const perspectiveClasses = ["perspective-100", "perspective-500", "perspective-1000"];
306
+ perspectiveClasses.forEach((cls) => {
307
+ expect(parseTransform(cls)).toBeTruthy();
308
+ });
309
+ });
310
+ });
311
+
312
+ describe("parseTransform - case sensitivity", () => {
313
+ it("should be case-sensitive", () => {
314
+ expect(parseTransform("SCALE-110")).toBeNull();
315
+ expect(parseTransform("Scale-110")).toBeNull();
316
+ expect(parseTransform("ROTATE-45")).toBeNull();
317
+ });
318
+ });