@mgcrea/react-native-tailwind 0.13.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -30
- package/dist/babel/config-loader.d.ts +10 -0
- package/dist/babel/config-loader.test.ts +75 -21
- package/dist/babel/config-loader.ts +100 -2
- package/dist/babel/index.cjs +439 -46
- package/dist/babel/plugin/state.d.ts +4 -0
- package/dist/babel/plugin/state.ts +8 -0
- package/dist/babel/plugin/visitors/className.test.ts +313 -0
- package/dist/babel/plugin/visitors/className.ts +36 -8
- package/dist/babel/plugin/visitors/imports.ts +16 -1
- package/dist/babel/plugin/visitors/program.ts +19 -2
- package/dist/babel/plugin/visitors/tw.test.ts +151 -0
- package/dist/babel/utils/directionalModifierProcessing.d.ts +34 -0
- package/dist/babel/utils/directionalModifierProcessing.ts +99 -0
- package/dist/babel/utils/styleInjection.d.ts +16 -0
- package/dist/babel/utils/styleInjection.ts +138 -7
- package/dist/babel/utils/twProcessing.d.ts +2 -0
- package/dist/babel/utils/twProcessing.ts +92 -3
- package/dist/parser/borders.js +1 -1
- package/dist/parser/borders.test.js +1 -1
- package/dist/parser/index.d.ts +3 -2
- package/dist/parser/index.js +1 -1
- package/dist/parser/layout.d.ts +3 -1
- package/dist/parser/layout.js +1 -1
- package/dist/parser/layout.test.js +1 -1
- package/dist/parser/modifiers.d.ts +32 -2
- package/dist/parser/modifiers.js +1 -1
- package/dist/parser/modifiers.test.js +1 -1
- package/dist/parser/sizing.d.ts +3 -1
- package/dist/parser/sizing.js +1 -1
- package/dist/parser/sizing.test.js +1 -1
- package/dist/parser/spacing.d.ts +4 -2
- package/dist/parser/spacing.js +1 -1
- package/dist/parser/spacing.test.js +1 -1
- package/dist/parser/transforms.d.ts +3 -1
- package/dist/parser/transforms.js +1 -1
- package/dist/parser/transforms.test.js +1 -1
- package/dist/parser/typography.test.js +1 -1
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.cjs.map +3 -3
- package/dist/runtime.d.ts +2 -0
- package/dist/runtime.js +1 -1
- package/dist/runtime.js.map +3 -3
- package/dist/runtime.test.js +1 -1
- package/package.json +6 -6
- package/src/babel/config-loader.test.ts +75 -21
- package/src/babel/config-loader.ts +100 -2
- package/src/babel/plugin/state.ts +8 -0
- package/src/babel/plugin/visitors/className.test.ts +313 -0
- package/src/babel/plugin/visitors/className.ts +36 -8
- package/src/babel/plugin/visitors/imports.ts +16 -1
- package/src/babel/plugin/visitors/program.ts +19 -2
- package/src/babel/plugin/visitors/tw.test.ts +151 -0
- package/src/babel/utils/directionalModifierProcessing.ts +99 -0
- package/src/babel/utils/styleInjection.ts +138 -7
- package/src/babel/utils/twProcessing.ts +92 -3
- package/src/parser/borders.test.ts +104 -0
- package/src/parser/borders.ts +50 -7
- package/src/parser/index.ts +8 -5
- package/src/parser/layout.test.ts +168 -0
- package/src/parser/layout.ts +107 -8
- package/src/parser/modifiers.test.ts +206 -0
- package/src/parser/modifiers.ts +62 -3
- package/src/parser/sizing.test.ts +56 -0
- package/src/parser/sizing.ts +20 -15
- package/src/parser/spacing.test.ts +123 -0
- package/src/parser/spacing.ts +30 -15
- package/src/parser/transforms.test.ts +57 -0
- package/src/parser/transforms.ts +7 -3
- package/src/parser/typography.test.ts +8 -0
- package/src/parser/typography.ts +4 -0
- package/src/runtime.test.ts +149 -0
- package/src/runtime.ts +53 -1
package/dist/parser/sizing.d.ts
CHANGED
|
@@ -6,5 +6,7 @@ export declare const SIZE_SCALE: Record<string, number>;
|
|
|
6
6
|
export declare const SIZE_PERCENTAGES: Record<string, string>;
|
|
7
7
|
/**
|
|
8
8
|
* Parse sizing classes
|
|
9
|
+
* @param cls - The class name to parse
|
|
10
|
+
* @param customSpacing - Optional custom spacing values from tailwind.config (shared with spacing utilities)
|
|
9
11
|
*/
|
|
10
|
-
export declare function parseSizing(cls: string): StyleObject | null;
|
|
12
|
+
export declare function parseSizing(cls: string, customSpacing?: Record<string, number>): StyleObject | null;
|
package/dist/parser/sizing.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});exports.SIZE_SCALE=exports.SIZE_PERCENTAGES=void 0;exports.parseSizing=parseSizing;var _markers=require("../config/markers");var SIZE_SCALE=exports.SIZE_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,7:28,8:32,9:36,10:40,11:44,12:48,14:56,16:64,20:80,24:96,28:112,32:128,36:144,40:160,44:176,48:192,52:208,56:224,60:240,64:256,72:288,80:320,96:384};var SIZE_PERCENTAGES=exports.SIZE_PERCENTAGES={full:"100%","1/2":"50%","1/3":"33.333333%","2/3":"66.666667%","1/4":"25%","2/4":"50%","3/4":"75%","1/5":"20%","2/5":"40%","3/5":"60%","4/5":"80%","1/6":"16.666667%","2/6":"33.333333%","3/6":"50%","4/6":"66.666667%","5/6":"83.333333%"};function parseArbitrarySize(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 size unit: ${value}. Only px and % are supported.`);}return null;}return null;}function parseSizing(cls){if(cls.startsWith("w-")){var sizeKey=cls.substring(2);if(sizeKey==="screen"){return{width:`${_markers.RUNTIME_DIMENSIONS_MARKER}width}}`};}var arbitrarySize=parseArbitrarySize(sizeKey);if(arbitrarySize!==null){return{width:arbitrarySize};}var percentage=SIZE_PERCENTAGES[sizeKey];if(percentage){return{width:percentage};}var numericSize=
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.SIZE_SCALE=exports.SIZE_PERCENTAGES=void 0;exports.parseSizing=parseSizing;var _markers=require("../config/markers");var SIZE_SCALE=exports.SIZE_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,7:28,8:32,9:36,10:40,11:44,12:48,14:56,16:64,20:80,24:96,28:112,32:128,36:144,40:160,44:176,48:192,52:208,56:224,60:240,64:256,72:288,80:320,96:384};var SIZE_PERCENTAGES=exports.SIZE_PERCENTAGES={full:"100%","1/2":"50%","1/3":"33.333333%","2/3":"66.666667%","1/4":"25%","2/4":"50%","3/4":"75%","1/5":"20%","2/5":"40%","3/5":"60%","4/5":"80%","1/6":"16.666667%","2/6":"33.333333%","3/6":"50%","4/6":"66.666667%","5/6":"83.333333%"};function parseArbitrarySize(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 size unit: ${value}. Only px and % are supported.`);}return null;}return null;}function parseSizing(cls,customSpacing){var sizeMap=customSpacing?Object.assign({},SIZE_SCALE,customSpacing):SIZE_SCALE;if(cls.startsWith("w-")){var sizeKey=cls.substring(2);if(sizeKey==="screen"){return{width:`${_markers.RUNTIME_DIMENSIONS_MARKER}width}}`};}var arbitrarySize=parseArbitrarySize(sizeKey);if(arbitrarySize!==null){return{width:arbitrarySize};}var percentage=SIZE_PERCENTAGES[sizeKey];if(percentage){return{width:percentage};}var numericSize=sizeMap[sizeKey];if(numericSize!==undefined){return{width:numericSize};}if(sizeKey==="auto"){return{width:"auto"};}}if(cls.startsWith("h-")){var _sizeKey=cls.substring(2);if(_sizeKey==="screen"){return{height:`${_markers.RUNTIME_DIMENSIONS_MARKER}height}}`};}var _arbitrarySize=parseArbitrarySize(_sizeKey);if(_arbitrarySize!==null){return{height:_arbitrarySize};}var _percentage=SIZE_PERCENTAGES[_sizeKey];if(_percentage){return{height:_percentage};}var _numericSize=sizeMap[_sizeKey];if(_numericSize!==undefined){return{height:_numericSize};}if(_sizeKey==="auto"){return{height:"auto"};}}if(cls.startsWith("min-w-")){var _sizeKey2=cls.substring(6);var _arbitrarySize2=parseArbitrarySize(_sizeKey2);if(_arbitrarySize2!==null){return{minWidth:_arbitrarySize2};}var _percentage2=SIZE_PERCENTAGES[_sizeKey2];if(_percentage2){return{minWidth:_percentage2};}var _numericSize2=sizeMap[_sizeKey2];if(_numericSize2!==undefined){return{minWidth:_numericSize2};}}if(cls.startsWith("min-h-")){var _sizeKey3=cls.substring(6);var _arbitrarySize3=parseArbitrarySize(_sizeKey3);if(_arbitrarySize3!==null){return{minHeight:_arbitrarySize3};}var _percentage3=SIZE_PERCENTAGES[_sizeKey3];if(_percentage3){return{minHeight:_percentage3};}var _numericSize3=sizeMap[_sizeKey3];if(_numericSize3!==undefined){return{minHeight:_numericSize3};}}if(cls.startsWith("max-w-")){var _sizeKey4=cls.substring(6);var _arbitrarySize4=parseArbitrarySize(_sizeKey4);if(_arbitrarySize4!==null){return{maxWidth:_arbitrarySize4};}var _percentage4=SIZE_PERCENTAGES[_sizeKey4];if(_percentage4){return{maxWidth:_percentage4};}var _numericSize4=sizeMap[_sizeKey4];if(_numericSize4!==undefined){return{maxWidth:_numericSize4};}}if(cls.startsWith("max-h-")){var _sizeKey5=cls.substring(6);var _arbitrarySize5=parseArbitrarySize(_sizeKey5);if(_arbitrarySize5!==null){return{maxHeight:_arbitrarySize5};}var _percentage5=SIZE_PERCENTAGES[_sizeKey5];if(_percentage5){return{maxHeight:_percentage5};}var _numericSize5=sizeMap[_sizeKey5];if(_numericSize5!==undefined){return{maxHeight:_numericSize5};}}return null;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var _vitest=require("vitest");var _sizing=require("./sizing");(0,_vitest.describe)("SIZE_SCALE",function(){(0,_vitest.it)("should export complete size scale",function(){(0,_vitest.expect)(_sizing.SIZE_SCALE).toMatchSnapshot();});});(0,_vitest.describe)("SIZE_PERCENTAGES",function(){(0,_vitest.it)("should export complete percentage sizes",function(){(0,_vitest.expect)(_sizing.SIZE_PERCENTAGES).toMatchSnapshot();});});(0,_vitest.describe)("parseSizing - width",function(){(0,_vitest.it)("should parse width with numeric values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-0")).toEqual({width:0});(0,_vitest.expect)((0,_sizing.parseSizing)("w-4")).toEqual({width:16});(0,_vitest.expect)((0,_sizing.parseSizing)("w-8")).toEqual({width:32});(0,_vitest.expect)((0,_sizing.parseSizing)("w-96")).toEqual({width:384});});(0,_vitest.it)("should parse width with fractional values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-0.5")).toEqual({width:2});(0,_vitest.expect)((0,_sizing.parseSizing)("w-1.5")).toEqual({width:6});(0,_vitest.expect)((0,_sizing.parseSizing)("w-2.5")).toEqual({width:10});});(0,_vitest.it)("should parse width with percentage values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-full")).toEqual({width:"100%"});(0,_vitest.expect)((0,_sizing.parseSizing)("w-1/2")).toEqual({width:"50%"});(0,_vitest.expect)((0,_sizing.parseSizing)("w-1/3")).toEqual({width:"33.333333%"});(0,_vitest.expect)((0,_sizing.parseSizing)("w-2/3")).toEqual({width:"66.666667%"});(0,_vitest.expect)((0,_sizing.parseSizing)("w-1/4")).toEqual({width:"25%"});(0,_vitest.expect)((0,_sizing.parseSizing)("w-3/4")).toEqual({width:"75%"});});(0,_vitest.it)("should parse width with special values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-auto")).toEqual({width:"auto"});});(0,_vitest.it)("should parse width with arbitrary pixel values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-[123px]")).toEqual({width:123});(0,_vitest.expect)((0,_sizing.parseSizing)("w-[123]")).toEqual({width:123});(0,_vitest.expect)((0,_sizing.parseSizing)("w-[350px]")).toEqual({width:350});});(0,_vitest.it)("should parse width with arbitrary percentage values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-[50%]")).toEqual({width:"50%"});(0,_vitest.expect)((0,_sizing.parseSizing)("w-[33.333%]")).toEqual({width:"33.333%"});(0,_vitest.expect)((0,_sizing.parseSizing)("w-[85%]")).toEqual({width:"85%"});});});(0,_vitest.describe)("parseSizing - height",function(){(0,_vitest.it)("should parse height with numeric values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("h-0")).toEqual({height:0});(0,_vitest.expect)((0,_sizing.parseSizing)("h-4")).toEqual({height:16});(0,_vitest.expect)((0,_sizing.parseSizing)("h-8")).toEqual({height:32});(0,_vitest.expect)((0,_sizing.parseSizing)("h-96")).toEqual({height:384});});(0,_vitest.it)("should parse height with fractional values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("h-0.5")).toEqual({height:2});(0,_vitest.expect)((0,_sizing.parseSizing)("h-1.5")).toEqual({height:6});(0,_vitest.expect)((0,_sizing.parseSizing)("h-2.5")).toEqual({height:10});});(0,_vitest.it)("should parse height with percentage values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("h-full")).toEqual({height:"100%"});(0,_vitest.expect)((0,_sizing.parseSizing)("h-1/2")).toEqual({height:"50%"});(0,_vitest.expect)((0,_sizing.parseSizing)("h-1/3")).toEqual({height:"33.333333%"});(0,_vitest.expect)((0,_sizing.parseSizing)("h-2/3")).toEqual({height:"66.666667%"});});(0,_vitest.it)("should parse height with special values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("h-auto")).toEqual({height:"auto"});});(0,_vitest.it)("should parse height with arbitrary values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("h-[200px]")).toEqual({height:200});(0,_vitest.expect)((0,_sizing.parseSizing)("h-[75%]")).toEqual({height:"75%"});});});(0,_vitest.describe)("parseSizing - min width",function(){(0,_vitest.it)("should parse min-width with numeric values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("min-w-0")).toEqual({minWidth:0});(0,_vitest.expect)((0,_sizing.parseSizing)("min-w-4")).toEqual({minWidth:16});(0,_vitest.expect)((0,_sizing.parseSizing)("min-w-8")).toEqual({minWidth:32});});(0,_vitest.it)("should parse min-width with percentage values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("min-w-full")).toEqual({minWidth:"100%"});(0,_vitest.expect)((0,_sizing.parseSizing)("min-w-1/2")).toEqual({minWidth:"50%"});});(0,_vitest.it)("should parse min-width with arbitrary values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("min-w-[200px]")).toEqual({minWidth:200});(0,_vitest.expect)((0,_sizing.parseSizing)("min-w-[50%]")).toEqual({minWidth:"50%"});});});(0,_vitest.describe)("parseSizing - min height",function(){(0,_vitest.it)("should parse min-height with numeric values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("min-h-0")).toEqual({minHeight:0});(0,_vitest.expect)((0,_sizing.parseSizing)("min-h-4")).toEqual({minHeight:16});(0,_vitest.expect)((0,_sizing.parseSizing)("min-h-8")).toEqual({minHeight:32});});(0,_vitest.it)("should parse min-height with percentage values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("min-h-full")).toEqual({minHeight:"100%"});(0,_vitest.expect)((0,_sizing.parseSizing)("min-h-1/2")).toEqual({minHeight:"50%"});});(0,_vitest.it)("should parse min-height with arbitrary values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("min-h-[150px]")).toEqual({minHeight:150});(0,_vitest.expect)((0,_sizing.parseSizing)("min-h-[40%]")).toEqual({minHeight:"40%"});});});(0,_vitest.describe)("parseSizing - max width",function(){(0,_vitest.it)("should parse max-width with numeric values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("max-w-0")).toEqual({maxWidth:0});(0,_vitest.expect)((0,_sizing.parseSizing)("max-w-4")).toEqual({maxWidth:16});(0,_vitest.expect)((0,_sizing.parseSizing)("max-w-8")).toEqual({maxWidth:32});});(0,_vitest.it)("should parse max-width with percentage values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("max-w-full")).toEqual({maxWidth:"100%"});(0,_vitest.expect)((0,_sizing.parseSizing)("max-w-1/2")).toEqual({maxWidth:"50%"});});(0,_vitest.it)("should parse max-width with arbitrary values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("max-w-[500px]")).toEqual({maxWidth:500});(0,_vitest.expect)((0,_sizing.parseSizing)("max-w-[80%]")).toEqual({maxWidth:"80%"});});});(0,_vitest.describe)("parseSizing - max height",function(){(0,_vitest.it)("should parse max-height with numeric values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("max-h-0")).toEqual({maxHeight:0});(0,_vitest.expect)((0,_sizing.parseSizing)("max-h-4")).toEqual({maxHeight:16});(0,_vitest.expect)((0,_sizing.parseSizing)("max-h-8")).toEqual({maxHeight:32});});(0,_vitest.it)("should parse max-height with percentage values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("max-h-full")).toEqual({maxHeight:"100%"});(0,_vitest.expect)((0,_sizing.parseSizing)("max-h-1/2")).toEqual({maxHeight:"50%"});});(0,_vitest.it)("should parse max-height with arbitrary values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("max-h-[300px]")).toEqual({maxHeight:300});(0,_vitest.expect)((0,_sizing.parseSizing)("max-h-[90%]")).toEqual({maxHeight:"90%"});});});(0,_vitest.describe)("parseSizing - edge cases",function(){(0,_vitest.it)("should return null for invalid classes",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("invalid")).toBeNull();(0,_vitest.expect)((0,_sizing.parseSizing)("w")).toBeNull();(0,_vitest.expect)((0,_sizing.parseSizing)("h")).toBeNull();(0,_vitest.expect)((0,_sizing.parseSizing)("width-4")).toBeNull();(0,_vitest.expect)((0,_sizing.parseSizing)("height-4")).toBeNull();});(0,_vitest.it)("should return null for invalid size values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-invalid")).toBeNull();(0,_vitest.expect)((0,_sizing.parseSizing)("h-999")).toBeNull();(0,_vitest.expect)((0,_sizing.parseSizing)("min-w-abc")).toBeNull();});(0,_vitest.it)("should return null for arbitrary values with unsupported units",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-[16rem]")).toBeNull();(0,_vitest.expect)((0,_sizing.parseSizing)("h-[2em]")).toBeNull();(0,_vitest.expect)((0,_sizing.parseSizing)("max-w-[50vh]")).toBeNull();(0,_vitest.expect)((0,_sizing.parseSizing)("min-h-[100vw]")).toBeNull();});(0,_vitest.it)("should return null for malformed arbitrary values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-[16")).toBeNull();(0,_vitest.expect)((0,_sizing.parseSizing)("h-16]")).toBeNull();(0,_vitest.expect)((0,_sizing.parseSizing)("min-w-[]")).toBeNull();});(0,_vitest.it)("should handle edge case size values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-0")).toEqual({width:0});(0,_vitest.expect)((0,_sizing.parseSizing)("h-0")).toEqual({height:0});(0,_vitest.expect)((0,_sizing.parseSizing)("min-w-0")).toEqual({minWidth:0});(0,_vitest.expect)((0,_sizing.parseSizing)("max-h-0")).toEqual({maxHeight:0});});(0,_vitest.it)("should not match partial class names",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("tw-4")).toBeNull();(0,_vitest.expect)((0,_sizing.parseSizing)("width-4")).toBeNull();(0,_vitest.expect)((0,_sizing.parseSizing)("height-4")).toBeNull();});});(0,_vitest.describe)("parseSizing - comprehensive coverage",function(){(0,_vitest.it)("should parse all width variants with same value",function(){var value=16;(0,_vitest.expect)((0,_sizing.parseSizing)("w-4")).toEqual({width:value});(0,_vitest.expect)((0,_sizing.parseSizing)("min-w-4")).toEqual({minWidth:value});(0,_vitest.expect)((0,_sizing.parseSizing)("max-w-4")).toEqual({maxWidth:value});});(0,_vitest.it)("should parse all height variants with same value",function(){var value=16;(0,_vitest.expect)((0,_sizing.parseSizing)("h-4")).toEqual({height:value});(0,_vitest.expect)((0,_sizing.parseSizing)("min-h-4")).toEqual({minHeight:value});(0,_vitest.expect)((0,_sizing.parseSizing)("max-h-4")).toEqual({maxHeight:value});});(0,_vitest.it)("should handle large size values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-96")).toEqual({width:384});(0,_vitest.expect)((0,_sizing.parseSizing)("h-96")).toEqual({height:384});(0,_vitest.expect)((0,_sizing.parseSizing)("max-w-96")).toEqual({maxWidth:384});});(0,_vitest.it)("should handle arbitrary values across all width variants",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-[123px]")).toEqual({width:123});(0,_vitest.expect)((0,_sizing.parseSizing)("min-w-[123px]")).toEqual({minWidth:123});(0,_vitest.expect)((0,_sizing.parseSizing)("max-w-[123px]")).toEqual({maxWidth:123});});(0,_vitest.it)("should handle arbitrary values across all height variants",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("h-[200px]")).toEqual({height:200});(0,_vitest.expect)((0,_sizing.parseSizing)("min-h-[200px]")).toEqual({minHeight:200});(0,_vitest.expect)((0,_sizing.parseSizing)("max-h-[200px]")).toEqual({maxHeight:200});});(0,_vitest.it)("should handle arbitrary percentage values across all variants",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-[75%]")).toEqual({width:"75%"});(0,_vitest.expect)((0,_sizing.parseSizing)("h-[60%]")).toEqual({height:"60%"});(0,_vitest.expect)((0,_sizing.parseSizing)("min-w-[25%]")).toEqual({minWidth:"25%"});(0,_vitest.expect)((0,_sizing.parseSizing)("max-h-[90%]")).toEqual({maxHeight:"90%"});});(0,_vitest.it)("should handle all fractional percentage variants",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-1/5")).toEqual({width:"20%"});(0,_vitest.expect)((0,_sizing.parseSizing)("w-2/5")).toEqual({width:"40%"});(0,_vitest.expect)((0,_sizing.parseSizing)("w-3/5")).toEqual({width:"60%"});(0,_vitest.expect)((0,_sizing.parseSizing)("w-4/5")).toEqual({width:"80%"});(0,_vitest.expect)((0,_sizing.parseSizing)("w-1/6")).toEqual({width:"16.666667%"});(0,_vitest.expect)((0,_sizing.parseSizing)("w-5/6")).toEqual({width:"83.333333%"});});(0,_vitest.it)("should handle special values consistently",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-auto")).toEqual({width:"auto"});(0,_vitest.expect)((0,_sizing.parseSizing)("h-auto")).toEqual({height:"auto"});(0,_vitest.expect)((0,_sizing.parseSizing)("w-full")).toEqual({width:"100%"});(0,_vitest.expect)((0,_sizing.parseSizing)("h-full")).toEqual({height:"100%"});});});
|
|
1
|
+
var _vitest=require("vitest");var _sizing=require("./sizing");(0,_vitest.describe)("SIZE_SCALE",function(){(0,_vitest.it)("should export complete size scale",function(){(0,_vitest.expect)(_sizing.SIZE_SCALE).toMatchSnapshot();});});(0,_vitest.describe)("SIZE_PERCENTAGES",function(){(0,_vitest.it)("should export complete percentage sizes",function(){(0,_vitest.expect)(_sizing.SIZE_PERCENTAGES).toMatchSnapshot();});});(0,_vitest.describe)("parseSizing - width",function(){(0,_vitest.it)("should parse width with numeric values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-0")).toEqual({width:0});(0,_vitest.expect)((0,_sizing.parseSizing)("w-4")).toEqual({width:16});(0,_vitest.expect)((0,_sizing.parseSizing)("w-8")).toEqual({width:32});(0,_vitest.expect)((0,_sizing.parseSizing)("w-96")).toEqual({width:384});});(0,_vitest.it)("should parse width with fractional values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-0.5")).toEqual({width:2});(0,_vitest.expect)((0,_sizing.parseSizing)("w-1.5")).toEqual({width:6});(0,_vitest.expect)((0,_sizing.parseSizing)("w-2.5")).toEqual({width:10});});(0,_vitest.it)("should parse width with percentage values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-full")).toEqual({width:"100%"});(0,_vitest.expect)((0,_sizing.parseSizing)("w-1/2")).toEqual({width:"50%"});(0,_vitest.expect)((0,_sizing.parseSizing)("w-1/3")).toEqual({width:"33.333333%"});(0,_vitest.expect)((0,_sizing.parseSizing)("w-2/3")).toEqual({width:"66.666667%"});(0,_vitest.expect)((0,_sizing.parseSizing)("w-1/4")).toEqual({width:"25%"});(0,_vitest.expect)((0,_sizing.parseSizing)("w-3/4")).toEqual({width:"75%"});});(0,_vitest.it)("should parse width with special values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-auto")).toEqual({width:"auto"});});(0,_vitest.it)("should parse width with arbitrary pixel values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-[123px]")).toEqual({width:123});(0,_vitest.expect)((0,_sizing.parseSizing)("w-[123]")).toEqual({width:123});(0,_vitest.expect)((0,_sizing.parseSizing)("w-[350px]")).toEqual({width:350});});(0,_vitest.it)("should parse width with arbitrary percentage values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-[50%]")).toEqual({width:"50%"});(0,_vitest.expect)((0,_sizing.parseSizing)("w-[33.333%]")).toEqual({width:"33.333%"});(0,_vitest.expect)((0,_sizing.parseSizing)("w-[85%]")).toEqual({width:"85%"});});});(0,_vitest.describe)("parseSizing - height",function(){(0,_vitest.it)("should parse height with numeric values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("h-0")).toEqual({height:0});(0,_vitest.expect)((0,_sizing.parseSizing)("h-4")).toEqual({height:16});(0,_vitest.expect)((0,_sizing.parseSizing)("h-8")).toEqual({height:32});(0,_vitest.expect)((0,_sizing.parseSizing)("h-96")).toEqual({height:384});});(0,_vitest.it)("should parse height with fractional values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("h-0.5")).toEqual({height:2});(0,_vitest.expect)((0,_sizing.parseSizing)("h-1.5")).toEqual({height:6});(0,_vitest.expect)((0,_sizing.parseSizing)("h-2.5")).toEqual({height:10});});(0,_vitest.it)("should parse height with percentage values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("h-full")).toEqual({height:"100%"});(0,_vitest.expect)((0,_sizing.parseSizing)("h-1/2")).toEqual({height:"50%"});(0,_vitest.expect)((0,_sizing.parseSizing)("h-1/3")).toEqual({height:"33.333333%"});(0,_vitest.expect)((0,_sizing.parseSizing)("h-2/3")).toEqual({height:"66.666667%"});});(0,_vitest.it)("should parse height with special values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("h-auto")).toEqual({height:"auto"});});(0,_vitest.it)("should parse height with arbitrary values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("h-[200px]")).toEqual({height:200});(0,_vitest.expect)((0,_sizing.parseSizing)("h-[75%]")).toEqual({height:"75%"});});});(0,_vitest.describe)("parseSizing - min width",function(){(0,_vitest.it)("should parse min-width with numeric values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("min-w-0")).toEqual({minWidth:0});(0,_vitest.expect)((0,_sizing.parseSizing)("min-w-4")).toEqual({minWidth:16});(0,_vitest.expect)((0,_sizing.parseSizing)("min-w-8")).toEqual({minWidth:32});});(0,_vitest.it)("should parse min-width with percentage values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("min-w-full")).toEqual({minWidth:"100%"});(0,_vitest.expect)((0,_sizing.parseSizing)("min-w-1/2")).toEqual({minWidth:"50%"});});(0,_vitest.it)("should parse min-width with arbitrary values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("min-w-[200px]")).toEqual({minWidth:200});(0,_vitest.expect)((0,_sizing.parseSizing)("min-w-[50%]")).toEqual({minWidth:"50%"});});});(0,_vitest.describe)("parseSizing - min height",function(){(0,_vitest.it)("should parse min-height with numeric values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("min-h-0")).toEqual({minHeight:0});(0,_vitest.expect)((0,_sizing.parseSizing)("min-h-4")).toEqual({minHeight:16});(0,_vitest.expect)((0,_sizing.parseSizing)("min-h-8")).toEqual({minHeight:32});});(0,_vitest.it)("should parse min-height with percentage values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("min-h-full")).toEqual({minHeight:"100%"});(0,_vitest.expect)((0,_sizing.parseSizing)("min-h-1/2")).toEqual({minHeight:"50%"});});(0,_vitest.it)("should parse min-height with arbitrary values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("min-h-[150px]")).toEqual({minHeight:150});(0,_vitest.expect)((0,_sizing.parseSizing)("min-h-[40%]")).toEqual({minHeight:"40%"});});});(0,_vitest.describe)("parseSizing - max width",function(){(0,_vitest.it)("should parse max-width with numeric values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("max-w-0")).toEqual({maxWidth:0});(0,_vitest.expect)((0,_sizing.parseSizing)("max-w-4")).toEqual({maxWidth:16});(0,_vitest.expect)((0,_sizing.parseSizing)("max-w-8")).toEqual({maxWidth:32});});(0,_vitest.it)("should parse max-width with percentage values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("max-w-full")).toEqual({maxWidth:"100%"});(0,_vitest.expect)((0,_sizing.parseSizing)("max-w-1/2")).toEqual({maxWidth:"50%"});});(0,_vitest.it)("should parse max-width with arbitrary values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("max-w-[500px]")).toEqual({maxWidth:500});(0,_vitest.expect)((0,_sizing.parseSizing)("max-w-[80%]")).toEqual({maxWidth:"80%"});});});(0,_vitest.describe)("parseSizing - max height",function(){(0,_vitest.it)("should parse max-height with numeric values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("max-h-0")).toEqual({maxHeight:0});(0,_vitest.expect)((0,_sizing.parseSizing)("max-h-4")).toEqual({maxHeight:16});(0,_vitest.expect)((0,_sizing.parseSizing)("max-h-8")).toEqual({maxHeight:32});});(0,_vitest.it)("should parse max-height with percentage values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("max-h-full")).toEqual({maxHeight:"100%"});(0,_vitest.expect)((0,_sizing.parseSizing)("max-h-1/2")).toEqual({maxHeight:"50%"});});(0,_vitest.it)("should parse max-height with arbitrary values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("max-h-[300px]")).toEqual({maxHeight:300});(0,_vitest.expect)((0,_sizing.parseSizing)("max-h-[90%]")).toEqual({maxHeight:"90%"});});});(0,_vitest.describe)("parseSizing - edge cases",function(){(0,_vitest.it)("should return null for invalid classes",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("invalid")).toBeNull();(0,_vitest.expect)((0,_sizing.parseSizing)("w")).toBeNull();(0,_vitest.expect)((0,_sizing.parseSizing)("h")).toBeNull();(0,_vitest.expect)((0,_sizing.parseSizing)("width-4")).toBeNull();(0,_vitest.expect)((0,_sizing.parseSizing)("height-4")).toBeNull();});(0,_vitest.it)("should return null for invalid size values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-invalid")).toBeNull();(0,_vitest.expect)((0,_sizing.parseSizing)("h-999")).toBeNull();(0,_vitest.expect)((0,_sizing.parseSizing)("min-w-abc")).toBeNull();});(0,_vitest.it)("should return null for arbitrary values with unsupported units",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-[16rem]")).toBeNull();(0,_vitest.expect)((0,_sizing.parseSizing)("h-[2em]")).toBeNull();(0,_vitest.expect)((0,_sizing.parseSizing)("max-w-[50vh]")).toBeNull();(0,_vitest.expect)((0,_sizing.parseSizing)("min-h-[100vw]")).toBeNull();});(0,_vitest.it)("should return null for malformed arbitrary values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-[16")).toBeNull();(0,_vitest.expect)((0,_sizing.parseSizing)("h-16]")).toBeNull();(0,_vitest.expect)((0,_sizing.parseSizing)("min-w-[]")).toBeNull();});(0,_vitest.it)("should handle edge case size values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-0")).toEqual({width:0});(0,_vitest.expect)((0,_sizing.parseSizing)("h-0")).toEqual({height:0});(0,_vitest.expect)((0,_sizing.parseSizing)("min-w-0")).toEqual({minWidth:0});(0,_vitest.expect)((0,_sizing.parseSizing)("max-h-0")).toEqual({maxHeight:0});});(0,_vitest.it)("should not match partial class names",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("tw-4")).toBeNull();(0,_vitest.expect)((0,_sizing.parseSizing)("width-4")).toBeNull();(0,_vitest.expect)((0,_sizing.parseSizing)("height-4")).toBeNull();});});(0,_vitest.describe)("parseSizing - comprehensive coverage",function(){(0,_vitest.it)("should parse all width variants with same value",function(){var value=16;(0,_vitest.expect)((0,_sizing.parseSizing)("w-4")).toEqual({width:value});(0,_vitest.expect)((0,_sizing.parseSizing)("min-w-4")).toEqual({minWidth:value});(0,_vitest.expect)((0,_sizing.parseSizing)("max-w-4")).toEqual({maxWidth:value});});(0,_vitest.it)("should parse all height variants with same value",function(){var value=16;(0,_vitest.expect)((0,_sizing.parseSizing)("h-4")).toEqual({height:value});(0,_vitest.expect)((0,_sizing.parseSizing)("min-h-4")).toEqual({minHeight:value});(0,_vitest.expect)((0,_sizing.parseSizing)("max-h-4")).toEqual({maxHeight:value});});(0,_vitest.it)("should handle large size values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-96")).toEqual({width:384});(0,_vitest.expect)((0,_sizing.parseSizing)("h-96")).toEqual({height:384});(0,_vitest.expect)((0,_sizing.parseSizing)("max-w-96")).toEqual({maxWidth:384});});(0,_vitest.it)("should handle arbitrary values across all width variants",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-[123px]")).toEqual({width:123});(0,_vitest.expect)((0,_sizing.parseSizing)("min-w-[123px]")).toEqual({minWidth:123});(0,_vitest.expect)((0,_sizing.parseSizing)("max-w-[123px]")).toEqual({maxWidth:123});});(0,_vitest.it)("should handle arbitrary values across all height variants",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("h-[200px]")).toEqual({height:200});(0,_vitest.expect)((0,_sizing.parseSizing)("min-h-[200px]")).toEqual({minHeight:200});(0,_vitest.expect)((0,_sizing.parseSizing)("max-h-[200px]")).toEqual({maxHeight:200});});(0,_vitest.it)("should handle arbitrary percentage values across all variants",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-[75%]")).toEqual({width:"75%"});(0,_vitest.expect)((0,_sizing.parseSizing)("h-[60%]")).toEqual({height:"60%"});(0,_vitest.expect)((0,_sizing.parseSizing)("min-w-[25%]")).toEqual({minWidth:"25%"});(0,_vitest.expect)((0,_sizing.parseSizing)("max-h-[90%]")).toEqual({maxHeight:"90%"});});(0,_vitest.it)("should handle all fractional percentage variants",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-1/5")).toEqual({width:"20%"});(0,_vitest.expect)((0,_sizing.parseSizing)("w-2/5")).toEqual({width:"40%"});(0,_vitest.expect)((0,_sizing.parseSizing)("w-3/5")).toEqual({width:"60%"});(0,_vitest.expect)((0,_sizing.parseSizing)("w-4/5")).toEqual({width:"80%"});(0,_vitest.expect)((0,_sizing.parseSizing)("w-1/6")).toEqual({width:"16.666667%"});(0,_vitest.expect)((0,_sizing.parseSizing)("w-5/6")).toEqual({width:"83.333333%"});});(0,_vitest.it)("should handle special values consistently",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-auto")).toEqual({width:"auto"});(0,_vitest.expect)((0,_sizing.parseSizing)("h-auto")).toEqual({height:"auto"});(0,_vitest.expect)((0,_sizing.parseSizing)("w-full")).toEqual({width:"100%"});(0,_vitest.expect)((0,_sizing.parseSizing)("h-full")).toEqual({height:"100%"});});});(0,_vitest.describe)("parseSizing - custom spacing",function(){var customSpacing={xs:4,sm:8,md:16,lg:32,xl:64,"4":20};(0,_vitest.it)("should support custom spacing values for width",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-xs",customSpacing)).toEqual({width:4});(0,_vitest.expect)((0,_sizing.parseSizing)("w-sm",customSpacing)).toEqual({width:8});(0,_vitest.expect)((0,_sizing.parseSizing)("w-lg",customSpacing)).toEqual({width:32});(0,_vitest.expect)((0,_sizing.parseSizing)("w-xl",customSpacing)).toEqual({width:64});});(0,_vitest.it)("should support custom spacing values for height",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("h-xs",customSpacing)).toEqual({height:4});(0,_vitest.expect)((0,_sizing.parseSizing)("h-md",customSpacing)).toEqual({height:16});(0,_vitest.expect)((0,_sizing.parseSizing)("h-xl",customSpacing)).toEqual({height:64});});(0,_vitest.it)("should support custom spacing values for min/max dimensions",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("min-w-sm",customSpacing)).toEqual({minWidth:8});(0,_vitest.expect)((0,_sizing.parseSizing)("min-h-lg",customSpacing)).toEqual({minHeight:32});(0,_vitest.expect)((0,_sizing.parseSizing)("max-w-xl",customSpacing)).toEqual({maxWidth:64});(0,_vitest.expect)((0,_sizing.parseSizing)("max-h-md",customSpacing)).toEqual({maxHeight:16});});(0,_vitest.it)("should allow custom spacing to override preset values",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-4",customSpacing)).toEqual({width:20});(0,_vitest.expect)((0,_sizing.parseSizing)("h-4",customSpacing)).toEqual({height:20});});(0,_vitest.it)("should prefer arbitrary values over custom spacing",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-[24px]",customSpacing)).toEqual({width:24});(0,_vitest.expect)((0,_sizing.parseSizing)("h-[50]",customSpacing)).toEqual({height:50});});(0,_vitest.it)("should fall back to preset scale for unknown custom keys",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-8",customSpacing)).toEqual({width:32});(0,_vitest.expect)((0,_sizing.parseSizing)("h-12",customSpacing)).toEqual({height:48});});(0,_vitest.it)("should preserve percentage values with custom spacing",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-full",customSpacing)).toEqual({width:"100%"});(0,_vitest.expect)((0,_sizing.parseSizing)("h-1/2",customSpacing)).toEqual({height:"50%"});});(0,_vitest.it)("should work without custom spacing (backward compatible)",function(){(0,_vitest.expect)((0,_sizing.parseSizing)("w-4")).toEqual({width:16});(0,_vitest.expect)((0,_sizing.parseSizing)("h-8")).toEqual({height:32});});});
|
package/dist/parser/spacing.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ import type { StyleObject } from "../types";
|
|
|
5
5
|
export declare const SPACING_SCALE: Record<string, number>;
|
|
6
6
|
/**
|
|
7
7
|
* Parse spacing classes (margin, padding, gap)
|
|
8
|
-
* Examples: m-4, mx-2, mt-8, p-4, px-2, pt-8, gap-4, m-[16px], pl-[4.5px], -m-4, -mt-[10px]
|
|
8
|
+
* Examples: m-4, mx-2, mt-8, p-4, px-2, pt-8, gap-4, m-[16px], pl-[4.5px], -m-4, -mt-[10px], ms-4, pe-2
|
|
9
|
+
* @param cls - The class name to parse
|
|
10
|
+
* @param customSpacing - Optional custom spacing values from tailwind.config
|
|
9
11
|
*/
|
|
10
|
-
export declare function parseSpacing(cls: string): StyleObject | null;
|
|
12
|
+
export declare function parseSpacing(cls: string, customSpacing?: Record<string, number>): StyleObject | null;
|
package/dist/parser/spacing.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.SPACING_SCALE=void 0;exports.parseSpacing=parseSpacing;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var SPACING_SCALE=exports.SPACING_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,7:28,8:32,9:36,10:40,11:44,12:48,14:56,16:64,20:80,24:96,28:112,32:128,36:144,40:160,44:176,48:192,52:208,56:224,60:240,64:256,72:288,80:320,96:384};function parseArbitrarySpacing(value){var pxMatch=value.match(/^\[(-?\d+(?:\.\d+)?)(?:px)?\]$/);if(pxMatch){return parseFloat(pxMatch[1]);}if(value.startsWith("[")&&value.endsWith("]")){if(process.env.NODE_ENV!=="production"){console.warn(`[react-native-tailwind] Unsupported arbitrary spacing value: ${value}. Only px values are supported (e.g., [16px], [16], [4.5px], [4.5]).`);}return null;}return null;}function parseSpacing(cls){var marginMatch=cls.match(/^(-?)m([
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.SPACING_SCALE=void 0;exports.parseSpacing=parseSpacing;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var SPACING_SCALE=exports.SPACING_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,7:28,8:32,9:36,10:40,11:44,12:48,14:56,16:64,20:80,24:96,28:112,32:128,36:144,40:160,44:176,48:192,52:208,56:224,60:240,64:256,72:288,80:320,96:384};function parseArbitrarySpacing(value){var pxMatch=value.match(/^\[(-?\d+(?:\.\d+)?)(?:px)?\]$/);if(pxMatch){return parseFloat(pxMatch[1]);}if(value.startsWith("[")&&value.endsWith("]")){if(process.env.NODE_ENV!=="production"){console.warn(`[react-native-tailwind] Unsupported arbitrary spacing value: ${value}. Only px values are supported (e.g., [16px], [16], [4.5px], [4.5]).`);}return null;}return null;}function parseSpacing(cls,customSpacing){var spacingMap=customSpacing?Object.assign({},SPACING_SCALE,customSpacing):SPACING_SCALE;var marginMatch=cls.match(/^(-?)m([xytrblse]?)-(.+)$/);if(marginMatch){var _marginMatch=(0,_slicedToArray2.default)(marginMatch,4),negativePrefix=_marginMatch[1],dir=_marginMatch[2],valueStr=_marginMatch[3];var isNegative=negativePrefix==="-";var arbitraryValue=parseArbitrarySpacing(valueStr);if(arbitraryValue!==null){var finalValue=isNegative?-arbitraryValue:arbitraryValue;return getMarginStyle(dir,finalValue);}var scaleValue=spacingMap[valueStr];if(scaleValue!==undefined){var _finalValue=isNegative?-scaleValue:scaleValue;return getMarginStyle(dir,_finalValue);}}var paddingMatch=cls.match(/^p([xytrblse]?)-(.+)$/);if(paddingMatch){var _paddingMatch=(0,_slicedToArray2.default)(paddingMatch,3),_dir=_paddingMatch[1],_valueStr=_paddingMatch[2];var _arbitraryValue=parseArbitrarySpacing(_valueStr);if(_arbitraryValue!==null){return getPaddingStyle(_dir,_arbitraryValue);}var _scaleValue=spacingMap[_valueStr];if(_scaleValue!==undefined){return getPaddingStyle(_dir,_scaleValue);}}var gapMatch=cls.match(/^gap-(.+)$/);if(gapMatch){var _valueStr2=gapMatch[1];var _arbitraryValue2=parseArbitrarySpacing(_valueStr2);if(_arbitraryValue2!==null){return{gap:_arbitraryValue2};}var _scaleValue2=spacingMap[_valueStr2];if(_scaleValue2!==undefined){return{gap:_scaleValue2};}}return null;}function getMarginStyle(dir,value){switch(dir){case"":return{margin:value};case"x":return{marginHorizontal:value};case"y":return{marginVertical:value};case"t":return{marginTop:value};case"r":return{marginRight:value};case"b":return{marginBottom:value};case"l":return{marginLeft:value};case"s":return{marginStart:value};case"e":return{marginEnd:value};default:return{};}}function getPaddingStyle(dir,value){switch(dir){case"":return{padding:value};case"x":return{paddingHorizontal:value};case"y":return{paddingVertical:value};case"t":return{paddingTop:value};case"r":return{paddingRight:value};case"b":return{paddingBottom:value};case"l":return{paddingLeft:value};case"s":return{paddingStart:value};case"e":return{paddingEnd:value};default:return{};}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var _vitest=require("vitest");var _spacing=require("./spacing");(0,_vitest.describe)("SPACING_SCALE",function(){(0,_vitest.it)("should export complete spacing scale",function(){(0,_vitest.expect)(_spacing.SPACING_SCALE).toMatchSnapshot();});});(0,_vitest.describe)("parseSpacing - margin",function(){(0,_vitest.it)("should parse margin all sides",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("m-0")).toEqual({margin:0});(0,_vitest.expect)((0,_spacing.parseSpacing)("m-4")).toEqual({margin:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("m-8")).toEqual({margin:32});(0,_vitest.expect)((0,_spacing.parseSpacing)("m-96")).toEqual({margin:384});});(0,_vitest.it)("should parse margin with fractional values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("m-0.5")).toEqual({margin:2});(0,_vitest.expect)((0,_spacing.parseSpacing)("m-1.5")).toEqual({margin:6});(0,_vitest.expect)((0,_spacing.parseSpacing)("m-2.5")).toEqual({margin:10});});(0,_vitest.it)("should parse margin horizontal",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("mx-0")).toEqual({marginHorizontal:0});(0,_vitest.expect)((0,_spacing.parseSpacing)("mx-4")).toEqual({marginHorizontal:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("mx-8")).toEqual({marginHorizontal:32});});(0,_vitest.it)("should parse margin vertical",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("my-0")).toEqual({marginVertical:0});(0,_vitest.expect)((0,_spacing.parseSpacing)("my-4")).toEqual({marginVertical:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("my-8")).toEqual({marginVertical:32});});(0,_vitest.it)("should parse margin directional",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("mt-4")).toEqual({marginTop:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("mr-4")).toEqual({marginRight:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("mb-4")).toEqual({marginBottom:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("ml-4")).toEqual({marginLeft:16});});(0,_vitest.it)("should parse margin with arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("m-[16px]")).toEqual({margin:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("m-[16]")).toEqual({margin:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("m-[100px]")).toEqual({margin:100});(0,_vitest.expect)((0,_spacing.parseSpacing)("m-[100]")).toEqual({margin:100});});(0,_vitest.it)("should parse margin directional with arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("mt-[24px]")).toEqual({marginTop:24});(0,_vitest.expect)((0,_spacing.parseSpacing)("mr-[32]")).toEqual({marginRight:32});(0,_vitest.expect)((0,_spacing.parseSpacing)("mb-[16px]")).toEqual({marginBottom:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("ml-[48]")).toEqual({marginLeft:48});});(0,_vitest.it)("should parse margin horizontal/vertical with arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("mx-[20px]")).toEqual({marginHorizontal:20});(0,_vitest.expect)((0,_spacing.parseSpacing)("my-[30]")).toEqual({marginVertical:30});});});(0,_vitest.describe)("parseSpacing - negative margin",function(){(0,_vitest.it)("should parse negative margin all sides",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-0")).toEqual({margin:-0});(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-4")).toEqual({margin:-16});(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-8")).toEqual({margin:-32});(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-96")).toEqual({margin:-384});});(0,_vitest.it)("should parse negative margin with fractional values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-0.5")).toEqual({margin:-2});(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-1.5")).toEqual({margin:-6});(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-2.5")).toEqual({margin:-10});});(0,_vitest.it)("should parse negative margin horizontal",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("-mx-4")).toEqual({marginHorizontal:-16});(0,_vitest.expect)((0,_spacing.parseSpacing)("-mx-8")).toEqual({marginHorizontal:-32});});(0,_vitest.it)("should parse negative margin vertical",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("-my-4")).toEqual({marginVertical:-16});(0,_vitest.expect)((0,_spacing.parseSpacing)("-my-8")).toEqual({marginVertical:-32});});(0,_vitest.it)("should parse negative margin directional",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("-mt-4")).toEqual({marginTop:-16});(0,_vitest.expect)((0,_spacing.parseSpacing)("-mr-4")).toEqual({marginRight:-16});(0,_vitest.expect)((0,_spacing.parseSpacing)("-mb-4")).toEqual({marginBottom:-16});(0,_vitest.expect)((0,_spacing.parseSpacing)("-ml-4")).toEqual({marginLeft:-16});});(0,_vitest.it)("should parse negative margin with arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-[16px]")).toEqual({margin:-16});(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-[16]")).toEqual({margin:-16});(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-[100px]")).toEqual({margin:-100});(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-[100]")).toEqual({margin:-100});});(0,_vitest.it)("should parse negative margin directional with arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("-mt-[24px]")).toEqual({marginTop:-24});(0,_vitest.expect)((0,_spacing.parseSpacing)("-mr-[32]")).toEqual({marginRight:-32});(0,_vitest.expect)((0,_spacing.parseSpacing)("-mb-[16px]")).toEqual({marginBottom:-16});(0,_vitest.expect)((0,_spacing.parseSpacing)("-ml-[48]")).toEqual({marginLeft:-48});});(0,_vitest.it)("should parse negative margin horizontal/vertical with arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("-mx-[20px]")).toEqual({marginHorizontal:-20});(0,_vitest.expect)((0,_spacing.parseSpacing)("-my-[30]")).toEqual({marginVertical:-30});});(0,_vitest.it)("should not parse negative padding (invalid)",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("-p-4")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("-px-4")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("-pt-4")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("-p-[16px]")).toBeNull();});(0,_vitest.it)("should not parse negative gap (invalid)",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("-gap-4")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("-gap-[16px]")).toBeNull();});});(0,_vitest.describe)("parseSpacing - padding",function(){(0,_vitest.it)("should parse padding all sides",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("p-0")).toEqual({padding:0});(0,_vitest.expect)((0,_spacing.parseSpacing)("p-4")).toEqual({padding:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("p-8")).toEqual({padding:32});(0,_vitest.expect)((0,_spacing.parseSpacing)("p-96")).toEqual({padding:384});});(0,_vitest.it)("should parse padding with fractional values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("p-0.5")).toEqual({padding:2});(0,_vitest.expect)((0,_spacing.parseSpacing)("p-1.5")).toEqual({padding:6});(0,_vitest.expect)((0,_spacing.parseSpacing)("p-2.5")).toEqual({padding:10});});(0,_vitest.it)("should parse padding horizontal",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("px-0")).toEqual({paddingHorizontal:0});(0,_vitest.expect)((0,_spacing.parseSpacing)("px-4")).toEqual({paddingHorizontal:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("px-8")).toEqual({paddingHorizontal:32});});(0,_vitest.it)("should parse padding vertical",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("py-0")).toEqual({paddingVertical:0});(0,_vitest.expect)((0,_spacing.parseSpacing)("py-4")).toEqual({paddingVertical:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("py-8")).toEqual({paddingVertical:32});});(0,_vitest.it)("should parse padding directional",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("pt-4")).toEqual({paddingTop:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("pr-4")).toEqual({paddingRight:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("pb-4")).toEqual({paddingBottom:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("pl-4")).toEqual({paddingLeft:16});});(0,_vitest.it)("should parse padding with arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("p-[16px]")).toEqual({padding:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("p-[16]")).toEqual({padding:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("p-[100px]")).toEqual({padding:100});(0,_vitest.expect)((0,_spacing.parseSpacing)("p-[100]")).toEqual({padding:100});});(0,_vitest.it)("should parse padding directional with arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("pt-[24px]")).toEqual({paddingTop:24});(0,_vitest.expect)((0,_spacing.parseSpacing)("pr-[32]")).toEqual({paddingRight:32});(0,_vitest.expect)((0,_spacing.parseSpacing)("pb-[16px]")).toEqual({paddingBottom:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("pl-[48]")).toEqual({paddingLeft:48});});(0,_vitest.it)("should parse padding horizontal/vertical with arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("px-[20px]")).toEqual({paddingHorizontal:20});(0,_vitest.expect)((0,_spacing.parseSpacing)("py-[30]")).toEqual({paddingVertical:30});});});(0,_vitest.describe)("parseSpacing - gap",function(){(0,_vitest.it)("should parse gap",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-0")).toEqual({gap:0});(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-4")).toEqual({gap:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-8")).toEqual({gap:32});(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-96")).toEqual({gap:384});});(0,_vitest.it)("should parse gap with fractional values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-0.5")).toEqual({gap:2});(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-1.5")).toEqual({gap:6});(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-2.5")).toEqual({gap:10});});(0,_vitest.it)("should parse gap with arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-[16px]")).toEqual({gap:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-[16]")).toEqual({gap:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-[100px]")).toEqual({gap:100});(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-[100]")).toEqual({gap:100});});});(0,_vitest.describe)("parseSpacing - edge cases",function(){(0,_vitest.it)("should return null for invalid classes",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("invalid")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("m")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("p")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("margin-4")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("padding-4")).toBeNull();});(0,_vitest.it)("should return null for invalid spacing values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("m-invalid")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("p-999")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-abc")).toBeNull();});(0,_vitest.it)("should return null for arbitrary values with unsupported units",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("m-[16rem]")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("p-[2em]")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-[50%]")).toBeNull();});(0,_vitest.it)("should return null for malformed arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("m-[16")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("p-16]")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-[]")).toBeNull();});(0,_vitest.it)("should handle edge case spacing values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("m-0")).toEqual({margin:0});(0,_vitest.expect)((0,_spacing.parseSpacing)("p-0")).toEqual({padding:0});(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-0")).toEqual({gap:0});});(0,_vitest.it)("should not match partial class names",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("sm-4")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("margin-4")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("padding-4")).toBeNull();});});(0,_vitest.describe)("parseSpacing - decimal arbitrary values",function(){(0,_vitest.it)("should parse margin with decimal arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("m-[4.5px]")).toEqual({margin:4.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("m-[4.5]")).toEqual({margin:4.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("m-[16.75px]")).toEqual({margin:16.75});(0,_vitest.expect)((0,_spacing.parseSpacing)("m-[16.75]")).toEqual({margin:16.75});(0,_vitest.expect)((0,_spacing.parseSpacing)("m-[100.25px]")).toEqual({margin:100.25});(0,_vitest.expect)((0,_spacing.parseSpacing)("m-[0.5]")).toEqual({margin:0.5});});(0,_vitest.it)("should parse padding with decimal arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("p-[4.5px]")).toEqual({padding:4.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("p-[4.5]")).toEqual({padding:4.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("pl-[4.5px]")).toEqual({paddingLeft:4.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("pl-[4.5]")).toEqual({paddingLeft:4.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("pr-[16.75px]")).toEqual({paddingRight:16.75});(0,_vitest.expect)((0,_spacing.parseSpacing)("pt-[10.5]")).toEqual({paddingTop:10.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("pb-[20.25px]")).toEqual({paddingBottom:20.25});});(0,_vitest.it)("should parse padding horizontal/vertical with decimal arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("px-[4.5px]")).toEqual({paddingHorizontal:4.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("py-[10.75]")).toEqual({paddingVertical:10.75});});(0,_vitest.it)("should parse gap with decimal arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-[4.5px]")).toEqual({gap:4.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-[4.5]")).toEqual({gap:4.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-[16.75px]")).toEqual({gap:16.75});(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-[0.5]")).toEqual({gap:0.5});});(0,_vitest.it)("should parse negative margin with decimal arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-[4.5px]")).toEqual({margin:-4.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-[4.5]")).toEqual({margin:-4.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-[10.5px]")).toEqual({margin:-10.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("-mt-[16.75px]")).toEqual({marginTop:-16.75});(0,_vitest.expect)((0,_spacing.parseSpacing)("-ml-[8.25]")).toEqual({marginLeft:-8.25});(0,_vitest.expect)((0,_spacing.parseSpacing)("-mx-[12.5px]")).toEqual({marginHorizontal:-12.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("-my-[20.75]")).toEqual({marginVertical:-20.75});});(0,_vitest.it)("should parse margin directional with decimal arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("mt-[4.5px]")).toEqual({marginTop:4.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("mr-[8.25]")).toEqual({marginRight:8.25});(0,_vitest.expect)((0,_spacing.parseSpacing)("mb-[16.75px]")).toEqual({marginBottom:16.75});(0,_vitest.expect)((0,_spacing.parseSpacing)("ml-[12.5]")).toEqual({marginLeft:12.5});});(0,_vitest.it)("should parse margin horizontal/vertical with decimal arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("mx-[4.5px]")).toEqual({marginHorizontal:4.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("my-[10.75]")).toEqual({marginVertical:10.75});});(0,_vitest.it)("should handle edge case decimal values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("m-[0.1px]")).toEqual({margin:0.1});(0,_vitest.expect)((0,_spacing.parseSpacing)("p-[0.001]")).toEqual({padding:0.001});(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-[999.999px]")).toEqual({gap:999.999});(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-[0.5]")).toEqual({margin:-0.5});});});(0,_vitest.describe)("parseSpacing - comprehensive coverage",function(){(0,_vitest.it)("should parse all margin directions with same value",function(){var value=16;(0,_vitest.expect)((0,_spacing.parseSpacing)("m-4")).toEqual({margin:value});(0,_vitest.expect)((0,_spacing.parseSpacing)("mx-4")).toEqual({marginHorizontal:value});(0,_vitest.expect)((0,_spacing.parseSpacing)("my-4")).toEqual({marginVertical:value});(0,_vitest.expect)((0,_spacing.parseSpacing)("mt-4")).toEqual({marginTop:value});(0,_vitest.expect)((0,_spacing.parseSpacing)("mr-4")).toEqual({marginRight:value});(0,_vitest.expect)((0,_spacing.parseSpacing)("mb-4")).toEqual({marginBottom:value});(0,_vitest.expect)((0,_spacing.parseSpacing)("ml-4")).toEqual({marginLeft:value});});(0,_vitest.it)("should parse all padding directions with same value",function(){var value=16;(0,_vitest.expect)((0,_spacing.parseSpacing)("p-4")).toEqual({padding:value});(0,_vitest.expect)((0,_spacing.parseSpacing)("px-4")).toEqual({paddingHorizontal:value});(0,_vitest.expect)((0,_spacing.parseSpacing)("py-4")).toEqual({paddingVertical:value});(0,_vitest.expect)((0,_spacing.parseSpacing)("pt-4")).toEqual({paddingTop:value});(0,_vitest.expect)((0,_spacing.parseSpacing)("pr-4")).toEqual({paddingRight:value});(0,_vitest.expect)((0,_spacing.parseSpacing)("pb-4")).toEqual({paddingBottom:value});(0,_vitest.expect)((0,_spacing.parseSpacing)("pl-4")).toEqual({paddingLeft:value});});(0,_vitest.it)("should handle large spacing values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("m-96")).toEqual({margin:384});(0,_vitest.expect)((0,_spacing.parseSpacing)("p-96")).toEqual({padding:384});(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-96")).toEqual({gap:384});});(0,_vitest.it)("should handle arbitrary values across all margin directions",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("m-[50px]")).toEqual({margin:50});(0,_vitest.expect)((0,_spacing.parseSpacing)("mx-[50px]")).toEqual({marginHorizontal:50});(0,_vitest.expect)((0,_spacing.parseSpacing)("my-[50px]")).toEqual({marginVertical:50});(0,_vitest.expect)((0,_spacing.parseSpacing)("mt-[50px]")).toEqual({marginTop:50});(0,_vitest.expect)((0,_spacing.parseSpacing)("mr-[50px]")).toEqual({marginRight:50});(0,_vitest.expect)((0,_spacing.parseSpacing)("mb-[50px]")).toEqual({marginBottom:50});(0,_vitest.expect)((0,_spacing.parseSpacing)("ml-[50px]")).toEqual({marginLeft:50});});(0,_vitest.it)("should handle arbitrary values across all padding directions",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("p-[50px]")).toEqual({padding:50});(0,_vitest.expect)((0,_spacing.parseSpacing)("px-[50px]")).toEqual({paddingHorizontal:50});(0,_vitest.expect)((0,_spacing.parseSpacing)("py-[50px]")).toEqual({paddingVertical:50});(0,_vitest.expect)((0,_spacing.parseSpacing)("pt-[50px]")).toEqual({paddingTop:50});(0,_vitest.expect)((0,_spacing.parseSpacing)("pr-[50px]")).toEqual({paddingRight:50});(0,_vitest.expect)((0,_spacing.parseSpacing)("pb-[50px]")).toEqual({paddingBottom:50});(0,_vitest.expect)((0,_spacing.parseSpacing)("pl-[50px]")).toEqual({paddingLeft:50});});});
|
|
1
|
+
var _vitest=require("vitest");var _spacing=require("./spacing");(0,_vitest.describe)("SPACING_SCALE",function(){(0,_vitest.it)("should export complete spacing scale",function(){(0,_vitest.expect)(_spacing.SPACING_SCALE).toMatchSnapshot();});});(0,_vitest.describe)("parseSpacing - margin",function(){(0,_vitest.it)("should parse margin all sides",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("m-0")).toEqual({margin:0});(0,_vitest.expect)((0,_spacing.parseSpacing)("m-4")).toEqual({margin:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("m-8")).toEqual({margin:32});(0,_vitest.expect)((0,_spacing.parseSpacing)("m-96")).toEqual({margin:384});});(0,_vitest.it)("should parse margin with fractional values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("m-0.5")).toEqual({margin:2});(0,_vitest.expect)((0,_spacing.parseSpacing)("m-1.5")).toEqual({margin:6});(0,_vitest.expect)((0,_spacing.parseSpacing)("m-2.5")).toEqual({margin:10});});(0,_vitest.it)("should parse margin horizontal",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("mx-0")).toEqual({marginHorizontal:0});(0,_vitest.expect)((0,_spacing.parseSpacing)("mx-4")).toEqual({marginHorizontal:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("mx-8")).toEqual({marginHorizontal:32});});(0,_vitest.it)("should parse margin vertical",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("my-0")).toEqual({marginVertical:0});(0,_vitest.expect)((0,_spacing.parseSpacing)("my-4")).toEqual({marginVertical:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("my-8")).toEqual({marginVertical:32});});(0,_vitest.it)("should parse margin directional",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("mt-4")).toEqual({marginTop:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("mr-4")).toEqual({marginRight:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("mb-4")).toEqual({marginBottom:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("ml-4")).toEqual({marginLeft:16});});(0,_vitest.it)("should parse margin with arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("m-[16px]")).toEqual({margin:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("m-[16]")).toEqual({margin:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("m-[100px]")).toEqual({margin:100});(0,_vitest.expect)((0,_spacing.parseSpacing)("m-[100]")).toEqual({margin:100});});(0,_vitest.it)("should parse margin directional with arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("mt-[24px]")).toEqual({marginTop:24});(0,_vitest.expect)((0,_spacing.parseSpacing)("mr-[32]")).toEqual({marginRight:32});(0,_vitest.expect)((0,_spacing.parseSpacing)("mb-[16px]")).toEqual({marginBottom:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("ml-[48]")).toEqual({marginLeft:48});});(0,_vitest.it)("should parse margin horizontal/vertical with arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("mx-[20px]")).toEqual({marginHorizontal:20});(0,_vitest.expect)((0,_spacing.parseSpacing)("my-[30]")).toEqual({marginVertical:30});});});(0,_vitest.describe)("parseSpacing - negative margin",function(){(0,_vitest.it)("should parse negative margin all sides",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-0")).toEqual({margin:-0});(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-4")).toEqual({margin:-16});(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-8")).toEqual({margin:-32});(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-96")).toEqual({margin:-384});});(0,_vitest.it)("should parse negative margin with fractional values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-0.5")).toEqual({margin:-2});(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-1.5")).toEqual({margin:-6});(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-2.5")).toEqual({margin:-10});});(0,_vitest.it)("should parse negative margin horizontal",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("-mx-4")).toEqual({marginHorizontal:-16});(0,_vitest.expect)((0,_spacing.parseSpacing)("-mx-8")).toEqual({marginHorizontal:-32});});(0,_vitest.it)("should parse negative margin vertical",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("-my-4")).toEqual({marginVertical:-16});(0,_vitest.expect)((0,_spacing.parseSpacing)("-my-8")).toEqual({marginVertical:-32});});(0,_vitest.it)("should parse negative margin directional",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("-mt-4")).toEqual({marginTop:-16});(0,_vitest.expect)((0,_spacing.parseSpacing)("-mr-4")).toEqual({marginRight:-16});(0,_vitest.expect)((0,_spacing.parseSpacing)("-mb-4")).toEqual({marginBottom:-16});(0,_vitest.expect)((0,_spacing.parseSpacing)("-ml-4")).toEqual({marginLeft:-16});});(0,_vitest.it)("should parse negative margin with arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-[16px]")).toEqual({margin:-16});(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-[16]")).toEqual({margin:-16});(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-[100px]")).toEqual({margin:-100});(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-[100]")).toEqual({margin:-100});});(0,_vitest.it)("should parse negative margin directional with arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("-mt-[24px]")).toEqual({marginTop:-24});(0,_vitest.expect)((0,_spacing.parseSpacing)("-mr-[32]")).toEqual({marginRight:-32});(0,_vitest.expect)((0,_spacing.parseSpacing)("-mb-[16px]")).toEqual({marginBottom:-16});(0,_vitest.expect)((0,_spacing.parseSpacing)("-ml-[48]")).toEqual({marginLeft:-48});});(0,_vitest.it)("should parse negative margin horizontal/vertical with arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("-mx-[20px]")).toEqual({marginHorizontal:-20});(0,_vitest.expect)((0,_spacing.parseSpacing)("-my-[30]")).toEqual({marginVertical:-30});});(0,_vitest.it)("should not parse negative padding (invalid)",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("-p-4")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("-px-4")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("-pt-4")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("-p-[16px]")).toBeNull();});(0,_vitest.it)("should not parse negative gap (invalid)",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("-gap-4")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("-gap-[16px]")).toBeNull();});});(0,_vitest.describe)("parseSpacing - padding",function(){(0,_vitest.it)("should parse padding all sides",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("p-0")).toEqual({padding:0});(0,_vitest.expect)((0,_spacing.parseSpacing)("p-4")).toEqual({padding:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("p-8")).toEqual({padding:32});(0,_vitest.expect)((0,_spacing.parseSpacing)("p-96")).toEqual({padding:384});});(0,_vitest.it)("should parse padding with fractional values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("p-0.5")).toEqual({padding:2});(0,_vitest.expect)((0,_spacing.parseSpacing)("p-1.5")).toEqual({padding:6});(0,_vitest.expect)((0,_spacing.parseSpacing)("p-2.5")).toEqual({padding:10});});(0,_vitest.it)("should parse padding horizontal",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("px-0")).toEqual({paddingHorizontal:0});(0,_vitest.expect)((0,_spacing.parseSpacing)("px-4")).toEqual({paddingHorizontal:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("px-8")).toEqual({paddingHorizontal:32});});(0,_vitest.it)("should parse padding vertical",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("py-0")).toEqual({paddingVertical:0});(0,_vitest.expect)((0,_spacing.parseSpacing)("py-4")).toEqual({paddingVertical:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("py-8")).toEqual({paddingVertical:32});});(0,_vitest.it)("should parse padding directional",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("pt-4")).toEqual({paddingTop:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("pr-4")).toEqual({paddingRight:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("pb-4")).toEqual({paddingBottom:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("pl-4")).toEqual({paddingLeft:16});});(0,_vitest.it)("should parse padding with arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("p-[16px]")).toEqual({padding:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("p-[16]")).toEqual({padding:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("p-[100px]")).toEqual({padding:100});(0,_vitest.expect)((0,_spacing.parseSpacing)("p-[100]")).toEqual({padding:100});});(0,_vitest.it)("should parse padding directional with arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("pt-[24px]")).toEqual({paddingTop:24});(0,_vitest.expect)((0,_spacing.parseSpacing)("pr-[32]")).toEqual({paddingRight:32});(0,_vitest.expect)((0,_spacing.parseSpacing)("pb-[16px]")).toEqual({paddingBottom:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("pl-[48]")).toEqual({paddingLeft:48});});(0,_vitest.it)("should parse padding horizontal/vertical with arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("px-[20px]")).toEqual({paddingHorizontal:20});(0,_vitest.expect)((0,_spacing.parseSpacing)("py-[30]")).toEqual({paddingVertical:30});});});(0,_vitest.describe)("parseSpacing - gap",function(){(0,_vitest.it)("should parse gap",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-0")).toEqual({gap:0});(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-4")).toEqual({gap:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-8")).toEqual({gap:32});(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-96")).toEqual({gap:384});});(0,_vitest.it)("should parse gap with fractional values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-0.5")).toEqual({gap:2});(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-1.5")).toEqual({gap:6});(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-2.5")).toEqual({gap:10});});(0,_vitest.it)("should parse gap with arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-[16px]")).toEqual({gap:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-[16]")).toEqual({gap:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-[100px]")).toEqual({gap:100});(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-[100]")).toEqual({gap:100});});});(0,_vitest.describe)("parseSpacing - edge cases",function(){(0,_vitest.it)("should return null for invalid classes",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("invalid")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("m")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("p")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("margin-4")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("padding-4")).toBeNull();});(0,_vitest.it)("should return null for invalid spacing values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("m-invalid")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("p-999")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-abc")).toBeNull();});(0,_vitest.it)("should return null for arbitrary values with unsupported units",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("m-[16rem]")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("p-[2em]")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-[50%]")).toBeNull();});(0,_vitest.it)("should return null for malformed arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("m-[16")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("p-16]")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-[]")).toBeNull();});(0,_vitest.it)("should handle edge case spacing values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("m-0")).toEqual({margin:0});(0,_vitest.expect)((0,_spacing.parseSpacing)("p-0")).toEqual({padding:0});(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-0")).toEqual({gap:0});});(0,_vitest.it)("should not match partial class names",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("sm-4")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("margin-4")).toBeNull();(0,_vitest.expect)((0,_spacing.parseSpacing)("padding-4")).toBeNull();});});(0,_vitest.describe)("parseSpacing - decimal arbitrary values",function(){(0,_vitest.it)("should parse margin with decimal arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("m-[4.5px]")).toEqual({margin:4.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("m-[4.5]")).toEqual({margin:4.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("m-[16.75px]")).toEqual({margin:16.75});(0,_vitest.expect)((0,_spacing.parseSpacing)("m-[16.75]")).toEqual({margin:16.75});(0,_vitest.expect)((0,_spacing.parseSpacing)("m-[100.25px]")).toEqual({margin:100.25});(0,_vitest.expect)((0,_spacing.parseSpacing)("m-[0.5]")).toEqual({margin:0.5});});(0,_vitest.it)("should parse padding with decimal arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("p-[4.5px]")).toEqual({padding:4.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("p-[4.5]")).toEqual({padding:4.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("pl-[4.5px]")).toEqual({paddingLeft:4.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("pl-[4.5]")).toEqual({paddingLeft:4.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("pr-[16.75px]")).toEqual({paddingRight:16.75});(0,_vitest.expect)((0,_spacing.parseSpacing)("pt-[10.5]")).toEqual({paddingTop:10.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("pb-[20.25px]")).toEqual({paddingBottom:20.25});});(0,_vitest.it)("should parse padding horizontal/vertical with decimal arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("px-[4.5px]")).toEqual({paddingHorizontal:4.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("py-[10.75]")).toEqual({paddingVertical:10.75});});(0,_vitest.it)("should parse gap with decimal arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-[4.5px]")).toEqual({gap:4.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-[4.5]")).toEqual({gap:4.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-[16.75px]")).toEqual({gap:16.75});(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-[0.5]")).toEqual({gap:0.5});});(0,_vitest.it)("should parse negative margin with decimal arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-[4.5px]")).toEqual({margin:-4.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-[4.5]")).toEqual({margin:-4.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-[10.5px]")).toEqual({margin:-10.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("-mt-[16.75px]")).toEqual({marginTop:-16.75});(0,_vitest.expect)((0,_spacing.parseSpacing)("-ml-[8.25]")).toEqual({marginLeft:-8.25});(0,_vitest.expect)((0,_spacing.parseSpacing)("-mx-[12.5px]")).toEqual({marginHorizontal:-12.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("-my-[20.75]")).toEqual({marginVertical:-20.75});});(0,_vitest.it)("should parse margin directional with decimal arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("mt-[4.5px]")).toEqual({marginTop:4.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("mr-[8.25]")).toEqual({marginRight:8.25});(0,_vitest.expect)((0,_spacing.parseSpacing)("mb-[16.75px]")).toEqual({marginBottom:16.75});(0,_vitest.expect)((0,_spacing.parseSpacing)("ml-[12.5]")).toEqual({marginLeft:12.5});});(0,_vitest.it)("should parse margin horizontal/vertical with decimal arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("mx-[4.5px]")).toEqual({marginHorizontal:4.5});(0,_vitest.expect)((0,_spacing.parseSpacing)("my-[10.75]")).toEqual({marginVertical:10.75});});(0,_vitest.it)("should handle edge case decimal values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("m-[0.1px]")).toEqual({margin:0.1});(0,_vitest.expect)((0,_spacing.parseSpacing)("p-[0.001]")).toEqual({padding:0.001});(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-[999.999px]")).toEqual({gap:999.999});(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-[0.5]")).toEqual({margin:-0.5});});});(0,_vitest.describe)("parseSpacing - comprehensive coverage",function(){(0,_vitest.it)("should parse all margin directions with same value",function(){var value=16;(0,_vitest.expect)((0,_spacing.parseSpacing)("m-4")).toEqual({margin:value});(0,_vitest.expect)((0,_spacing.parseSpacing)("mx-4")).toEqual({marginHorizontal:value});(0,_vitest.expect)((0,_spacing.parseSpacing)("my-4")).toEqual({marginVertical:value});(0,_vitest.expect)((0,_spacing.parseSpacing)("mt-4")).toEqual({marginTop:value});(0,_vitest.expect)((0,_spacing.parseSpacing)("mr-4")).toEqual({marginRight:value});(0,_vitest.expect)((0,_spacing.parseSpacing)("mb-4")).toEqual({marginBottom:value});(0,_vitest.expect)((0,_spacing.parseSpacing)("ml-4")).toEqual({marginLeft:value});});(0,_vitest.it)("should parse all padding directions with same value",function(){var value=16;(0,_vitest.expect)((0,_spacing.parseSpacing)("p-4")).toEqual({padding:value});(0,_vitest.expect)((0,_spacing.parseSpacing)("px-4")).toEqual({paddingHorizontal:value});(0,_vitest.expect)((0,_spacing.parseSpacing)("py-4")).toEqual({paddingVertical:value});(0,_vitest.expect)((0,_spacing.parseSpacing)("pt-4")).toEqual({paddingTop:value});(0,_vitest.expect)((0,_spacing.parseSpacing)("pr-4")).toEqual({paddingRight:value});(0,_vitest.expect)((0,_spacing.parseSpacing)("pb-4")).toEqual({paddingBottom:value});(0,_vitest.expect)((0,_spacing.parseSpacing)("pl-4")).toEqual({paddingLeft:value});});(0,_vitest.it)("should handle large spacing values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("m-96")).toEqual({margin:384});(0,_vitest.expect)((0,_spacing.parseSpacing)("p-96")).toEqual({padding:384});(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-96")).toEqual({gap:384});});(0,_vitest.it)("should handle arbitrary values across all margin directions",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("m-[50px]")).toEqual({margin:50});(0,_vitest.expect)((0,_spacing.parseSpacing)("mx-[50px]")).toEqual({marginHorizontal:50});(0,_vitest.expect)((0,_spacing.parseSpacing)("my-[50px]")).toEqual({marginVertical:50});(0,_vitest.expect)((0,_spacing.parseSpacing)("mt-[50px]")).toEqual({marginTop:50});(0,_vitest.expect)((0,_spacing.parseSpacing)("mr-[50px]")).toEqual({marginRight:50});(0,_vitest.expect)((0,_spacing.parseSpacing)("mb-[50px]")).toEqual({marginBottom:50});(0,_vitest.expect)((0,_spacing.parseSpacing)("ml-[50px]")).toEqual({marginLeft:50});});(0,_vitest.it)("should handle arbitrary values across all padding directions",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("p-[50px]")).toEqual({padding:50});(0,_vitest.expect)((0,_spacing.parseSpacing)("px-[50px]")).toEqual({paddingHorizontal:50});(0,_vitest.expect)((0,_spacing.parseSpacing)("py-[50px]")).toEqual({paddingVertical:50});(0,_vitest.expect)((0,_spacing.parseSpacing)("pt-[50px]")).toEqual({paddingTop:50});(0,_vitest.expect)((0,_spacing.parseSpacing)("pr-[50px]")).toEqual({paddingRight:50});(0,_vitest.expect)((0,_spacing.parseSpacing)("pb-[50px]")).toEqual({paddingBottom:50});(0,_vitest.expect)((0,_spacing.parseSpacing)("pl-[50px]")).toEqual({paddingLeft:50});});});(0,_vitest.describe)("parseSpacing - logical margin (RTL-aware)",function(){(0,_vitest.it)("should parse margin start",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("ms-0")).toEqual({marginStart:0});(0,_vitest.expect)((0,_spacing.parseSpacing)("ms-4")).toEqual({marginStart:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("ms-8")).toEqual({marginStart:32});});(0,_vitest.it)("should parse margin end",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("me-0")).toEqual({marginEnd:0});(0,_vitest.expect)((0,_spacing.parseSpacing)("me-4")).toEqual({marginEnd:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("me-8")).toEqual({marginEnd:32});});(0,_vitest.it)("should parse margin start/end with fractional values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("ms-0.5")).toEqual({marginStart:2});(0,_vitest.expect)((0,_spacing.parseSpacing)("me-1.5")).toEqual({marginEnd:6});(0,_vitest.expect)((0,_spacing.parseSpacing)("ms-2.5")).toEqual({marginStart:10});});(0,_vitest.it)("should parse margin start/end with arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("ms-[16px]")).toEqual({marginStart:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("ms-[16]")).toEqual({marginStart:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("me-[24px]")).toEqual({marginEnd:24});(0,_vitest.expect)((0,_spacing.parseSpacing)("me-[24]")).toEqual({marginEnd:24});});(0,_vitest.it)("should parse negative margin start/end",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("-ms-4")).toEqual({marginStart:-16});(0,_vitest.expect)((0,_spacing.parseSpacing)("-me-4")).toEqual({marginEnd:-16});(0,_vitest.expect)((0,_spacing.parseSpacing)("-ms-8")).toEqual({marginStart:-32});(0,_vitest.expect)((0,_spacing.parseSpacing)("-me-8")).toEqual({marginEnd:-32});});(0,_vitest.it)("should parse negative margin start/end with arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("-ms-[16px]")).toEqual({marginStart:-16});(0,_vitest.expect)((0,_spacing.parseSpacing)("-me-[24]")).toEqual({marginEnd:-24});});});(0,_vitest.describe)("parseSpacing - logical padding (RTL-aware)",function(){(0,_vitest.it)("should parse padding start",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("ps-0")).toEqual({paddingStart:0});(0,_vitest.expect)((0,_spacing.parseSpacing)("ps-4")).toEqual({paddingStart:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("ps-8")).toEqual({paddingStart:32});});(0,_vitest.it)("should parse padding end",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("pe-0")).toEqual({paddingEnd:0});(0,_vitest.expect)((0,_spacing.parseSpacing)("pe-4")).toEqual({paddingEnd:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("pe-8")).toEqual({paddingEnd:32});});(0,_vitest.it)("should parse padding start/end with fractional values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("ps-0.5")).toEqual({paddingStart:2});(0,_vitest.expect)((0,_spacing.parseSpacing)("pe-1.5")).toEqual({paddingEnd:6});(0,_vitest.expect)((0,_spacing.parseSpacing)("ps-2.5")).toEqual({paddingStart:10});});(0,_vitest.it)("should parse padding start/end with arbitrary values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("ps-[16px]")).toEqual({paddingStart:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("ps-[16]")).toEqual({paddingStart:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("pe-[24px]")).toEqual({paddingEnd:24});(0,_vitest.expect)((0,_spacing.parseSpacing)("pe-[24]")).toEqual({paddingEnd:24});});});(0,_vitest.describe)("parseSpacing - custom spacing",function(){var customSpacing={xs:4,sm:8,md:16,lg:32,xl:64,"4":20};(0,_vitest.it)("should support custom spacing values for margin",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("m-xs",customSpacing)).toEqual({margin:4});(0,_vitest.expect)((0,_spacing.parseSpacing)("m-sm",customSpacing)).toEqual({margin:8});(0,_vitest.expect)((0,_spacing.parseSpacing)("m-lg",customSpacing)).toEqual({margin:32});(0,_vitest.expect)((0,_spacing.parseSpacing)("mx-xl",customSpacing)).toEqual({marginHorizontal:64});(0,_vitest.expect)((0,_spacing.parseSpacing)("mt-md",customSpacing)).toEqual({marginTop:16});});(0,_vitest.it)("should support custom spacing values for padding",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("p-xs",customSpacing)).toEqual({padding:4});(0,_vitest.expect)((0,_spacing.parseSpacing)("p-sm",customSpacing)).toEqual({padding:8});(0,_vitest.expect)((0,_spacing.parseSpacing)("px-lg",customSpacing)).toEqual({paddingHorizontal:32});(0,_vitest.expect)((0,_spacing.parseSpacing)("pt-xl",customSpacing)).toEqual({paddingTop:64});});(0,_vitest.it)("should support custom spacing values for gap",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-xs",customSpacing)).toEqual({gap:4});(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-md",customSpacing)).toEqual({gap:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("gap-xl",customSpacing)).toEqual({gap:64});});(0,_vitest.it)("should allow custom spacing to override preset values",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("m-4",customSpacing)).toEqual({margin:20});});(0,_vitest.it)("should prefer arbitrary values over custom spacing",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("m-[24px]",customSpacing)).toEqual({margin:24});(0,_vitest.expect)((0,_spacing.parseSpacing)("p-[50]",customSpacing)).toEqual({padding:50});});(0,_vitest.it)("should support negative margins with custom spacing",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-xs",customSpacing)).toEqual({margin:-4});(0,_vitest.expect)((0,_spacing.parseSpacing)("-m-lg",customSpacing)).toEqual({margin:-32});(0,_vitest.expect)((0,_spacing.parseSpacing)("-mx-xl",customSpacing)).toEqual({marginHorizontal:-64});});(0,_vitest.it)("should fall back to preset scale for unknown custom keys",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("m-8",customSpacing)).toEqual({margin:32});(0,_vitest.expect)((0,_spacing.parseSpacing)("p-12",customSpacing)).toEqual({padding:48});});(0,_vitest.it)("should work without custom spacing (backward compatible)",function(){(0,_vitest.expect)((0,_spacing.parseSpacing)("m-4")).toEqual({margin:16});(0,_vitest.expect)((0,_spacing.parseSpacing)("p-8")).toEqual({padding:32});});});
|
|
@@ -9,5 +9,7 @@ export declare const PERSPECTIVE_SCALE: Record<string, number>;
|
|
|
9
9
|
/**
|
|
10
10
|
* Parse transform classes
|
|
11
11
|
* Each transform class returns a transform array with a single transform object
|
|
12
|
+
* @param cls - The class name to parse
|
|
13
|
+
* @param customSpacing - Optional custom spacing values from tailwind.config (for translate utilities)
|
|
12
14
|
*/
|
|
13
|
-
export declare function parseTransform(cls: string): StyleObject | null;
|
|
15
|
+
export declare function parseTransform(cls: string, customSpacing?: Record<string, number>): StyleObject | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});exports.SKEW_MAP=exports.SCALE_MAP=exports.ROTATE_MAP=exports.PERSPECTIVE_SCALE=void 0;exports.parseTransform=parseTransform;var _spacing=require("./spacing");var SCALE_MAP=exports.SCALE_MAP={0:0,50:0.5,75:0.75,90:0.9,95:0.95,100:1,105:1.05,110:1.1,125:1.25,150:1.5,200:2};var ROTATE_MAP=exports.ROTATE_MAP={0:0,1:1,2:2,3:3,6:6,12:12,45:45,90:90,180:180};var SKEW_MAP=exports.SKEW_MAP={0:0,1:1,2:2,3:3,6:6,12:12};var PERSPECTIVE_SCALE=exports.PERSPECTIVE_SCALE={0:0,100:100,200:200,300:300,400:400,500:500,600:600,700:700,800:800,900:900,1000:1000};function parseArbitraryScale(value){var scaleMatch=value.match(/^\[(-?\d+(?:\.\d+)?)\]$/);if(scaleMatch){return parseFloat(scaleMatch[1]);}if(value.startsWith("[")&&value.endsWith("]")){if(process.env.NODE_ENV!=="production"){console.warn(`[react-native-tailwind] Invalid arbitrary scale value: ${value}. Only numbers are supported (e.g., [1.5], [0.75]).`);}return null;}return null;}function parseArbitraryRotation(value){var rotateMatch=value.match(/^\[(-?\d+(?:\.\d+)?)deg\]$/);if(rotateMatch){return`${rotateMatch[1]}deg`;}if(value.startsWith("[")&&value.endsWith("]")){if(process.env.NODE_ENV!=="production"){console.warn(`[react-native-tailwind] Invalid arbitrary rotation value: ${value}. Only deg unit is supported (e.g., [45deg], [-15deg]).`);}return null;}return null;}function parseArbitraryTranslation(value){var pxMatch=value.match(/^\[(-?\d+)(?:px)?\]$/);if(pxMatch){return parseInt(pxMatch[1],10);}var percentMatch=value.match(/^\[(-?\d+(?:\.\d+)?)%\]$/);if(percentMatch){return`${percentMatch[1]}%`;}if(value.startsWith("[")&&value.endsWith("]")){if(process.env.NODE_ENV!=="production"){console.warn(`[react-native-tailwind] Unsupported arbitrary translation unit: ${value}. Only px and % are supported.`);}return null;}return null;}function parseArbitraryPerspective(value){var perspectiveMatch=value.match(/^\[(-?\d+)\]$/);if(perspectiveMatch){return parseInt(perspectiveMatch[1],10);}if(value.startsWith("[")&&value.endsWith("]")){if(process.env.NODE_ENV!=="production"){console.warn(`[react-native-tailwind] Invalid arbitrary perspective value: ${value}. Only integers are supported (e.g., [1500]).`);}return null;}return null;}function parseTransform(cls){if(cls.startsWith("origin-")){if(process.env.NODE_ENV!=="production"){console.warn(`[react-native-tailwind] transform-origin is not supported in React Native. Class "${cls}" will be ignored.`);}return null;}if(cls.startsWith("scale-")){var scaleKey=cls.substring(6);var arbitraryScale=parseArbitraryScale(scaleKey);if(arbitraryScale!==null){return{transform:[{scale:arbitraryScale}]};}var scaleValue=SCALE_MAP[scaleKey];if(scaleValue!==undefined){return{transform:[{scale:scaleValue}]};}}if(cls.startsWith("scale-x-")){var _scaleKey=cls.substring(8);var _arbitraryScale=parseArbitraryScale(_scaleKey);if(_arbitraryScale!==null){return{transform:[{scaleX:_arbitraryScale}]};}var _scaleValue=SCALE_MAP[_scaleKey];if(_scaleValue!==undefined){return{transform:[{scaleX:_scaleValue}]};}}if(cls.startsWith("scale-y-")){var _scaleKey2=cls.substring(8);var _arbitraryScale2=parseArbitraryScale(_scaleKey2);if(_arbitraryScale2!==null){return{transform:[{scaleY:_arbitraryScale2}]};}var _scaleValue2=SCALE_MAP[_scaleKey2];if(_scaleValue2!==undefined){return{transform:[{scaleY:_scaleValue2}]};}}if(cls.startsWith("rotate-")||cls.startsWith("-rotate-")){var isNegative=cls.startsWith("-");var rotateKey=isNegative?cls.substring(8):cls.substring(7);var arbitraryRotate=parseArbitraryRotation(rotateKey);if(arbitraryRotate!==null){var degrees=isNegative?`-${arbitraryRotate}`:arbitraryRotate;return{transform:[{rotate:degrees}]};}var rotateValue=ROTATE_MAP[rotateKey];if(rotateValue!==undefined){var _degrees=isNegative?-rotateValue:rotateValue;return{transform:[{rotate:`${_degrees}deg`}]};}}if(cls.startsWith("rotate-x-")||cls.startsWith("-rotate-x-")){var _isNegative=cls.startsWith("-");var _rotateKey=_isNegative?cls.substring(10):cls.substring(9);var _arbitraryRotate=parseArbitraryRotation(_rotateKey);if(_arbitraryRotate!==null){var _degrees2=_isNegative?`-${_arbitraryRotate}`:_arbitraryRotate;return{transform:[{rotateX:_degrees2}]};}var _rotateValue=ROTATE_MAP[_rotateKey];if(_rotateValue!==undefined){var _degrees3=_isNegative?-_rotateValue:_rotateValue;return{transform:[{rotateX:`${_degrees3}deg`}]};}}if(cls.startsWith("rotate-y-")||cls.startsWith("-rotate-y-")){var _isNegative2=cls.startsWith("-");var _rotateKey2=_isNegative2?cls.substring(10):cls.substring(9);var _arbitraryRotate2=parseArbitraryRotation(_rotateKey2);if(_arbitraryRotate2!==null){var _degrees4=_isNegative2?`-${_arbitraryRotate2}`:_arbitraryRotate2;return{transform:[{rotateY:_degrees4}]};}var _rotateValue2=ROTATE_MAP[_rotateKey2];if(_rotateValue2!==undefined){var _degrees5=_isNegative2?-_rotateValue2:_rotateValue2;return{transform:[{rotateY:`${_degrees5}deg`}]};}}if(cls.startsWith("rotate-z-")||cls.startsWith("-rotate-z-")){var _isNegative3=cls.startsWith("-");var _rotateKey3=_isNegative3?cls.substring(10):cls.substring(9);var _arbitraryRotate3=parseArbitraryRotation(_rotateKey3);if(_arbitraryRotate3!==null){var _degrees6=_isNegative3?`-${_arbitraryRotate3}`:_arbitraryRotate3;return{transform:[{rotateZ:_degrees6}]};}var _rotateValue3=ROTATE_MAP[_rotateKey3];if(_rotateValue3!==undefined){var _degrees7=_isNegative3?-_rotateValue3:_rotateValue3;return{transform:[{rotateZ:`${_degrees7}deg`}]};}}if(cls.startsWith("translate-x-")||cls.startsWith("-translate-x-")){var _isNegative4=cls.startsWith("-");var translateKey=_isNegative4?cls.substring(13):cls.substring(12);var arbitraryTranslate=parseArbitraryTranslation(translateKey);if(arbitraryTranslate!==null){var value=typeof arbitraryTranslate==="number"?_isNegative4?-arbitraryTranslate:arbitraryTranslate:_isNegative4?`-${arbitraryTranslate}`:arbitraryTranslate;return{transform:[{translateX:value}]};}var translateValue=
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.SKEW_MAP=exports.SCALE_MAP=exports.ROTATE_MAP=exports.PERSPECTIVE_SCALE=void 0;exports.parseTransform=parseTransform;var _spacing=require("./spacing");var SCALE_MAP=exports.SCALE_MAP={0:0,50:0.5,75:0.75,90:0.9,95:0.95,100:1,105:1.05,110:1.1,125:1.25,150:1.5,200:2};var ROTATE_MAP=exports.ROTATE_MAP={0:0,1:1,2:2,3:3,6:6,12:12,45:45,90:90,180:180};var SKEW_MAP=exports.SKEW_MAP={0:0,1:1,2:2,3:3,6:6,12:12};var PERSPECTIVE_SCALE=exports.PERSPECTIVE_SCALE={0:0,100:100,200:200,300:300,400:400,500:500,600:600,700:700,800:800,900:900,1000:1000};function parseArbitraryScale(value){var scaleMatch=value.match(/^\[(-?\d+(?:\.\d+)?)\]$/);if(scaleMatch){return parseFloat(scaleMatch[1]);}if(value.startsWith("[")&&value.endsWith("]")){if(process.env.NODE_ENV!=="production"){console.warn(`[react-native-tailwind] Invalid arbitrary scale value: ${value}. Only numbers are supported (e.g., [1.5], [0.75]).`);}return null;}return null;}function parseArbitraryRotation(value){var rotateMatch=value.match(/^\[(-?\d+(?:\.\d+)?)deg\]$/);if(rotateMatch){return`${rotateMatch[1]}deg`;}if(value.startsWith("[")&&value.endsWith("]")){if(process.env.NODE_ENV!=="production"){console.warn(`[react-native-tailwind] Invalid arbitrary rotation value: ${value}. Only deg unit is supported (e.g., [45deg], [-15deg]).`);}return null;}return null;}function parseArbitraryTranslation(value){var pxMatch=value.match(/^\[(-?\d+)(?:px)?\]$/);if(pxMatch){return parseInt(pxMatch[1],10);}var percentMatch=value.match(/^\[(-?\d+(?:\.\d+)?)%\]$/);if(percentMatch){return`${percentMatch[1]}%`;}if(value.startsWith("[")&&value.endsWith("]")){if(process.env.NODE_ENV!=="production"){console.warn(`[react-native-tailwind] Unsupported arbitrary translation unit: ${value}. Only px and % are supported.`);}return null;}return null;}function parseArbitraryPerspective(value){var perspectiveMatch=value.match(/^\[(-?\d+)\]$/);if(perspectiveMatch){return parseInt(perspectiveMatch[1],10);}if(value.startsWith("[")&&value.endsWith("]")){if(process.env.NODE_ENV!=="production"){console.warn(`[react-native-tailwind] Invalid arbitrary perspective value: ${value}. Only integers are supported (e.g., [1500]).`);}return null;}return null;}function parseTransform(cls,customSpacing){var spacingMap=customSpacing?Object.assign({},_spacing.SPACING_SCALE,customSpacing):_spacing.SPACING_SCALE;if(cls.startsWith("origin-")){if(process.env.NODE_ENV!=="production"){console.warn(`[react-native-tailwind] transform-origin is not supported in React Native. Class "${cls}" will be ignored.`);}return null;}if(cls.startsWith("scale-")){var scaleKey=cls.substring(6);var arbitraryScale=parseArbitraryScale(scaleKey);if(arbitraryScale!==null){return{transform:[{scale:arbitraryScale}]};}var scaleValue=SCALE_MAP[scaleKey];if(scaleValue!==undefined){return{transform:[{scale:scaleValue}]};}}if(cls.startsWith("scale-x-")){var _scaleKey=cls.substring(8);var _arbitraryScale=parseArbitraryScale(_scaleKey);if(_arbitraryScale!==null){return{transform:[{scaleX:_arbitraryScale}]};}var _scaleValue=SCALE_MAP[_scaleKey];if(_scaleValue!==undefined){return{transform:[{scaleX:_scaleValue}]};}}if(cls.startsWith("scale-y-")){var _scaleKey2=cls.substring(8);var _arbitraryScale2=parseArbitraryScale(_scaleKey2);if(_arbitraryScale2!==null){return{transform:[{scaleY:_arbitraryScale2}]};}var _scaleValue2=SCALE_MAP[_scaleKey2];if(_scaleValue2!==undefined){return{transform:[{scaleY:_scaleValue2}]};}}if(cls.startsWith("rotate-")||cls.startsWith("-rotate-")){var isNegative=cls.startsWith("-");var rotateKey=isNegative?cls.substring(8):cls.substring(7);var arbitraryRotate=parseArbitraryRotation(rotateKey);if(arbitraryRotate!==null){var degrees=isNegative?`-${arbitraryRotate}`:arbitraryRotate;return{transform:[{rotate:degrees}]};}var rotateValue=ROTATE_MAP[rotateKey];if(rotateValue!==undefined){var _degrees=isNegative?-rotateValue:rotateValue;return{transform:[{rotate:`${_degrees}deg`}]};}}if(cls.startsWith("rotate-x-")||cls.startsWith("-rotate-x-")){var _isNegative=cls.startsWith("-");var _rotateKey=_isNegative?cls.substring(10):cls.substring(9);var _arbitraryRotate=parseArbitraryRotation(_rotateKey);if(_arbitraryRotate!==null){var _degrees2=_isNegative?`-${_arbitraryRotate}`:_arbitraryRotate;return{transform:[{rotateX:_degrees2}]};}var _rotateValue=ROTATE_MAP[_rotateKey];if(_rotateValue!==undefined){var _degrees3=_isNegative?-_rotateValue:_rotateValue;return{transform:[{rotateX:`${_degrees3}deg`}]};}}if(cls.startsWith("rotate-y-")||cls.startsWith("-rotate-y-")){var _isNegative2=cls.startsWith("-");var _rotateKey2=_isNegative2?cls.substring(10):cls.substring(9);var _arbitraryRotate2=parseArbitraryRotation(_rotateKey2);if(_arbitraryRotate2!==null){var _degrees4=_isNegative2?`-${_arbitraryRotate2}`:_arbitraryRotate2;return{transform:[{rotateY:_degrees4}]};}var _rotateValue2=ROTATE_MAP[_rotateKey2];if(_rotateValue2!==undefined){var _degrees5=_isNegative2?-_rotateValue2:_rotateValue2;return{transform:[{rotateY:`${_degrees5}deg`}]};}}if(cls.startsWith("rotate-z-")||cls.startsWith("-rotate-z-")){var _isNegative3=cls.startsWith("-");var _rotateKey3=_isNegative3?cls.substring(10):cls.substring(9);var _arbitraryRotate3=parseArbitraryRotation(_rotateKey3);if(_arbitraryRotate3!==null){var _degrees6=_isNegative3?`-${_arbitraryRotate3}`:_arbitraryRotate3;return{transform:[{rotateZ:_degrees6}]};}var _rotateValue3=ROTATE_MAP[_rotateKey3];if(_rotateValue3!==undefined){var _degrees7=_isNegative3?-_rotateValue3:_rotateValue3;return{transform:[{rotateZ:`${_degrees7}deg`}]};}}if(cls.startsWith("translate-x-")||cls.startsWith("-translate-x-")){var _isNegative4=cls.startsWith("-");var translateKey=_isNegative4?cls.substring(13):cls.substring(12);var arbitraryTranslate=parseArbitraryTranslation(translateKey);if(arbitraryTranslate!==null){var value=typeof arbitraryTranslate==="number"?_isNegative4?-arbitraryTranslate:arbitraryTranslate:_isNegative4?`-${arbitraryTranslate}`:arbitraryTranslate;return{transform:[{translateX:value}]};}var translateValue=spacingMap[translateKey];if(translateValue!==undefined){var _value=_isNegative4?-translateValue:translateValue;return{transform:[{translateX:_value}]};}}if(cls.startsWith("translate-y-")||cls.startsWith("-translate-y-")){var _isNegative5=cls.startsWith("-");var _translateKey=_isNegative5?cls.substring(13):cls.substring(12);var _arbitraryTranslate=parseArbitraryTranslation(_translateKey);if(_arbitraryTranslate!==null){var _value2=typeof _arbitraryTranslate==="number"?_isNegative5?-_arbitraryTranslate:_arbitraryTranslate:_isNegative5?`-${_arbitraryTranslate}`:_arbitraryTranslate;return{transform:[{translateY:_value2}]};}var _translateValue=spacingMap[_translateKey];if(_translateValue!==undefined){var _value3=_isNegative5?-_translateValue:_translateValue;return{transform:[{translateY:_value3}]};}}if(cls.startsWith("skew-x-")||cls.startsWith("-skew-x-")){var _isNegative6=cls.startsWith("-");var skewKey=_isNegative6?cls.substring(8):cls.substring(7);var arbitrarySkew=parseArbitraryRotation(skewKey);if(arbitrarySkew!==null){var _degrees8=_isNegative6?`-${arbitrarySkew}`:arbitrarySkew;return{transform:[{skewX:_degrees8}]};}var skewValue=SKEW_MAP[skewKey];if(skewValue!==undefined){var _degrees9=_isNegative6?-skewValue:skewValue;return{transform:[{skewX:`${_degrees9}deg`}]};}}if(cls.startsWith("skew-y-")||cls.startsWith("-skew-y-")){var _isNegative7=cls.startsWith("-");var _skewKey=_isNegative7?cls.substring(8):cls.substring(7);var _arbitrarySkew=parseArbitraryRotation(_skewKey);if(_arbitrarySkew!==null){var _degrees0=_isNegative7?`-${_arbitrarySkew}`:_arbitrarySkew;return{transform:[{skewY:_degrees0}]};}var _skewValue=SKEW_MAP[_skewKey];if(_skewValue!==undefined){var _degrees1=_isNegative7?-_skewValue:_skewValue;return{transform:[{skewY:`${_degrees1}deg`}]};}}if(cls.startsWith("perspective-")){var perspectiveKey=cls.substring(12);var arbitraryPerspective=parseArbitraryPerspective(perspectiveKey);if(arbitraryPerspective!==null){return{transform:[{perspective:arbitraryPerspective}]};}var perspectiveValue=PERSPECTIVE_SCALE[perspectiveKey];if(perspectiveValue!==undefined){return{transform:[{perspective:perspectiveValue}]};}}return null;}
|
|
@@ -1 +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
|
+
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();});});(0,_vitest.describe)("parseTransform - custom spacing",function(){var customSpacing={xs:4,sm:8,md:16,lg:32,xl:64,"4":20};(0,_vitest.it)("should support custom spacing values for translateX",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("translate-x-xs",customSpacing)).toEqual({transform:[{translateX:4}]});(0,_vitest.expect)((0,_transforms.parseTransform)("translate-x-sm",customSpacing)).toEqual({transform:[{translateX:8}]});(0,_vitest.expect)((0,_transforms.parseTransform)("translate-x-lg",customSpacing)).toEqual({transform:[{translateX:32}]});(0,_vitest.expect)((0,_transforms.parseTransform)("translate-x-xl",customSpacing)).toEqual({transform:[{translateX:64}]});});(0,_vitest.it)("should support custom spacing values for translateY",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("translate-y-xs",customSpacing)).toEqual({transform:[{translateY:4}]});(0,_vitest.expect)((0,_transforms.parseTransform)("translate-y-md",customSpacing)).toEqual({transform:[{translateY:16}]});(0,_vitest.expect)((0,_transforms.parseTransform)("translate-y-xl",customSpacing)).toEqual({transform:[{translateY:64}]});});(0,_vitest.it)("should support negative custom spacing for translate",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("-translate-x-sm",customSpacing)).toEqual({transform:[{translateX:-8}]});(0,_vitest.expect)((0,_transforms.parseTransform)("-translate-y-lg",customSpacing)).toEqual({transform:[{translateY:-32}]});});(0,_vitest.it)("should allow custom spacing to override preset values",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("translate-x-4",customSpacing)).toEqual({transform:[{translateX:20}]});(0,_vitest.expect)((0,_transforms.parseTransform)("translate-y-4",customSpacing)).toEqual({transform:[{translateY:20}]});});(0,_vitest.it)("should prefer arbitrary values over custom spacing",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("translate-x-[24px]",customSpacing)).toEqual({transform:[{translateX:24}]});(0,_vitest.expect)((0,_transforms.parseTransform)("translate-y-[50]",customSpacing)).toEqual({transform:[{translateY:50}]});});(0,_vitest.it)("should fall back to preset scale for unknown custom keys",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("translate-x-8",customSpacing)).toEqual({transform:[{translateX:32}]});(0,_vitest.expect)((0,_transforms.parseTransform)("translate-y-12",customSpacing)).toEqual({transform:[{translateY:48}]});});(0,_vitest.it)("should work without custom spacing (backward compatible)",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("translate-x-4")).toEqual({transform:[{translateX:16}]});(0,_vitest.expect)((0,_transforms.parseTransform)("translate-y-8")).toEqual({transform:[{translateY:32}]});});(0,_vitest.it)("should not affect non-translate transforms",function(){(0,_vitest.expect)((0,_transforms.parseTransform)("scale-110",customSpacing)).toEqual({transform:[{scale:1.1}]});(0,_vitest.expect)((0,_transforms.parseTransform)("rotate-45",customSpacing)).toEqual({transform:[{rotate:"45deg"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("skew-x-6",customSpacing)).toEqual({transform:[{skewX:"6deg"}]});(0,_vitest.expect)((0,_transforms.parseTransform)("perspective-500",customSpacing)).toEqual({transform:[{perspective:500}]});});});
|
|
@@ -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-[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.it)("should parse font size with decimal arbitrary values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-[13.5px]")).toEqual({fontSize:13.5});(0,_vitest.expect)((0,_typography.parseTypography)("text-[13.5]")).toEqual({fontSize:13.5});(0,_vitest.expect)((0,_typography.parseTypography)("text-[18.75px]")).toEqual({fontSize:18.75});(0,_vitest.expect)((0,_typography.parseTypography)("text-[18.75]")).toEqual({fontSize:18.75});(0,_vitest.expect)((0,_typography.parseTypography)("text-[22.5]")).toEqual({fontSize:22.5});});(0,_vitest.it)("should parse font size with Tailwind shorthand decimals",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-[.5]")).toEqual({fontSize:0.5});(0,_vitest.expect)((0,_typography.parseTypography)("text-[.75px]")).toEqual({fontSize:0.75});(0,_vitest.expect)((0,_typography.parseTypography)("text-[.5px]")).toEqual({fontSize:0.5});});});(0,_vitest.describe)("parseTypography - font family",function(){(0,_vitest.it)("should parse font family values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("font-sans")).toEqual({fontFamily:"System"});(0,_vitest.expect)((0,_typography.parseTypography)("font-serif")).toEqual({fontFamily:"serif"});(0,_vitest.expect)((0,_typography.parseTypography)("font-mono")).toEqual({fontFamily:"Courier"});});});(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 numeric scale",function(){(0,_vitest.expect)((0,_typography.parseTypography)("leading-3")).toEqual({lineHeight:12});(0,_vitest.expect)((0,_typography.parseTypography)("leading-4")).toEqual({lineHeight:16});(0,_vitest.expect)((0,_typography.parseTypography)("leading-5")).toEqual({lineHeight:20});(0,_vitest.expect)((0,_typography.parseTypography)("leading-6")).toEqual({lineHeight:24});(0,_vitest.expect)((0,_typography.parseTypography)("leading-7")).toEqual({lineHeight:28});(0,_vitest.expect)((0,_typography.parseTypography)("leading-8")).toEqual({lineHeight:32});(0,_vitest.expect)((0,_typography.parseTypography)("leading-9")).toEqual({lineHeight:36});(0,_vitest.expect)((0,_typography.parseTypography)("leading-10")).toEqual({lineHeight:40});});(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.it)("should parse line height with decimal arbitrary values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("leading-[21.5px]")).toEqual({lineHeight:21.5});(0,_vitest.expect)((0,_typography.parseTypography)("leading-[21.5]")).toEqual({lineHeight:21.5});(0,_vitest.expect)((0,_typography.parseTypography)("leading-[28.75px]")).toEqual({lineHeight:28.75});(0,_vitest.expect)((0,_typography.parseTypography)("leading-[28.75]")).toEqual({lineHeight:28.75});(0,_vitest.expect)((0,_typography.parseTypography)("leading-[32.5]")).toEqual({lineHeight:32.5});});(0,_vitest.it)("should parse line height with Tailwind shorthand decimals",function(){(0,_vitest.expect)((0,_typography.parseTypography)("leading-[.5]")).toEqual({lineHeight:0.5});(0,_vitest.expect)((0,_typography.parseTypography)("leading-[.75px]")).toEqual({lineHeight:0.75});(0,_vitest.expect)((0,_typography.parseTypography)("leading-[.5px]")).toEqual({lineHeight:0.5});});});(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.it)("should parse letter spacing with arbitrary values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[0.5px]")).toEqual({letterSpacing:0.5});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[0.5]")).toEqual({letterSpacing:0.5});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[0.3]")).toEqual({letterSpacing:0.3});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[1.2px]")).toEqual({letterSpacing:1.2});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[2]")).toEqual({letterSpacing:2});});(0,_vitest.it)("should parse letter spacing with Tailwind shorthand decimals",function(){(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[.5]")).toEqual({letterSpacing:0.5});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[.3px]")).toEqual({letterSpacing:0.3});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[.75]")).toEqual({letterSpacing:0.75});});(0,_vitest.it)("should parse negative letter spacing with arbitrary values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[-0.4px]")).toEqual({letterSpacing:-0.4});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[-0.4]")).toEqual({letterSpacing:-0.4});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[-0.5]")).toEqual({letterSpacing:-0.5});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[-1px]")).toEqual({letterSpacing:-1});});(0,_vitest.it)("should parse negative letter spacing with shorthand decimals",function(){(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[-.4]")).toEqual({letterSpacing:-0.4});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[-.5px]")).toEqual({letterSpacing:-0.5});});(0,_vitest.it)("should handle edge case letter spacing values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[0]")).toEqual({letterSpacing:0});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[0.1]")).toEqual({letterSpacing:0.1});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[10]")).toEqual({letterSpacing:10});});});(0,_vitest.describe)("parseTypography - custom fontSize",function(){var customFontSize={tiny:10,huge:96,xl:22,custom:17};(0,_vitest.it)("should support custom font sizes",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-tiny",undefined,customFontSize)).toEqual({fontSize:10});(0,_vitest.expect)((0,_typography.parseTypography)("text-huge",undefined,customFontSize)).toEqual({fontSize:96});(0,_vitest.expect)((0,_typography.parseTypography)("text-custom",undefined,customFontSize)).toEqual({fontSize:17});});(0,_vitest.it)("should allow custom fontSize to override preset sizes",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-xl",undefined,customFontSize)).toEqual({fontSize:22});});(0,_vitest.it)("should fallback to preset sizes when custom fontSize not found",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-base",undefined,customFontSize)).toEqual({fontSize:16});(0,_vitest.expect)((0,_typography.parseTypography)("text-lg",undefined,customFontSize)).toEqual({fontSize:18});(0,_vitest.expect)((0,_typography.parseTypography)("text-2xl",undefined,customFontSize)).toEqual({fontSize:24});});(0,_vitest.it)("should prefer arbitrary values over custom fontSize",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-[15px]",undefined,customFontSize)).toEqual({fontSize:15});(0,_vitest.expect)((0,_typography.parseTypography)("text-[13.5]",undefined,customFontSize)).toEqual({fontSize:13.5});});(0,_vitest.it)("should work with both customFontFamily and customFontSize",function(){var customFontFamily={brand:"MyCustomFont"};(0,_vitest.expect)((0,_typography.parseTypography)("text-tiny",customFontFamily,customFontSize)).toEqual({fontSize:10});(0,_vitest.expect)((0,_typography.parseTypography)("font-brand",customFontFamily,customFontSize)).toEqual({fontFamily:"MyCustomFont"});});(0,_vitest.it)("should return null for unknown custom fontSize keys",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-nonexistent",undefined,customFontSize)).toBeNull();});});(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-mono")).toEqual({fontFamily:"Courier"});(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.it)("should parse font size with decimal arbitrary values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-[13.5px]")).toEqual({fontSize:13.5});(0,_vitest.expect)((0,_typography.parseTypography)("text-[13.5]")).toEqual({fontSize:13.5});(0,_vitest.expect)((0,_typography.parseTypography)("text-[18.75px]")).toEqual({fontSize:18.75});(0,_vitest.expect)((0,_typography.parseTypography)("text-[18.75]")).toEqual({fontSize:18.75});(0,_vitest.expect)((0,_typography.parseTypography)("text-[22.5]")).toEqual({fontSize:22.5});});(0,_vitest.it)("should parse font size with Tailwind shorthand decimals",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-[.5]")).toEqual({fontSize:0.5});(0,_vitest.expect)((0,_typography.parseTypography)("text-[.75px]")).toEqual({fontSize:0.75});(0,_vitest.expect)((0,_typography.parseTypography)("text-[.5px]")).toEqual({fontSize:0.5});});});(0,_vitest.describe)("parseTypography - font family",function(){(0,_vitest.it)("should parse font family values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("font-sans")).toEqual({fontFamily:"System"});(0,_vitest.expect)((0,_typography.parseTypography)("font-serif")).toEqual({fontFamily:"serif"});(0,_vitest.expect)((0,_typography.parseTypography)("font-mono")).toEqual({fontFamily:"Courier"});});});(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.it)("should not parse text-start/text-end (handled via directional modifier expansion)",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-start")).toBeNull();(0,_vitest.expect)((0,_typography.parseTypography)("text-end")).toBeNull();});});(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 numeric scale",function(){(0,_vitest.expect)((0,_typography.parseTypography)("leading-3")).toEqual({lineHeight:12});(0,_vitest.expect)((0,_typography.parseTypography)("leading-4")).toEqual({lineHeight:16});(0,_vitest.expect)((0,_typography.parseTypography)("leading-5")).toEqual({lineHeight:20});(0,_vitest.expect)((0,_typography.parseTypography)("leading-6")).toEqual({lineHeight:24});(0,_vitest.expect)((0,_typography.parseTypography)("leading-7")).toEqual({lineHeight:28});(0,_vitest.expect)((0,_typography.parseTypography)("leading-8")).toEqual({lineHeight:32});(0,_vitest.expect)((0,_typography.parseTypography)("leading-9")).toEqual({lineHeight:36});(0,_vitest.expect)((0,_typography.parseTypography)("leading-10")).toEqual({lineHeight:40});});(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.it)("should parse line height with decimal arbitrary values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("leading-[21.5px]")).toEqual({lineHeight:21.5});(0,_vitest.expect)((0,_typography.parseTypography)("leading-[21.5]")).toEqual({lineHeight:21.5});(0,_vitest.expect)((0,_typography.parseTypography)("leading-[28.75px]")).toEqual({lineHeight:28.75});(0,_vitest.expect)((0,_typography.parseTypography)("leading-[28.75]")).toEqual({lineHeight:28.75});(0,_vitest.expect)((0,_typography.parseTypography)("leading-[32.5]")).toEqual({lineHeight:32.5});});(0,_vitest.it)("should parse line height with Tailwind shorthand decimals",function(){(0,_vitest.expect)((0,_typography.parseTypography)("leading-[.5]")).toEqual({lineHeight:0.5});(0,_vitest.expect)((0,_typography.parseTypography)("leading-[.75px]")).toEqual({lineHeight:0.75});(0,_vitest.expect)((0,_typography.parseTypography)("leading-[.5px]")).toEqual({lineHeight:0.5});});});(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.it)("should parse letter spacing with arbitrary values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[0.5px]")).toEqual({letterSpacing:0.5});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[0.5]")).toEqual({letterSpacing:0.5});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[0.3]")).toEqual({letterSpacing:0.3});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[1.2px]")).toEqual({letterSpacing:1.2});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[2]")).toEqual({letterSpacing:2});});(0,_vitest.it)("should parse letter spacing with Tailwind shorthand decimals",function(){(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[.5]")).toEqual({letterSpacing:0.5});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[.3px]")).toEqual({letterSpacing:0.3});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[.75]")).toEqual({letterSpacing:0.75});});(0,_vitest.it)("should parse negative letter spacing with arbitrary values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[-0.4px]")).toEqual({letterSpacing:-0.4});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[-0.4]")).toEqual({letterSpacing:-0.4});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[-0.5]")).toEqual({letterSpacing:-0.5});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[-1px]")).toEqual({letterSpacing:-1});});(0,_vitest.it)("should parse negative letter spacing with shorthand decimals",function(){(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[-.4]")).toEqual({letterSpacing:-0.4});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[-.5px]")).toEqual({letterSpacing:-0.5});});(0,_vitest.it)("should handle edge case letter spacing values",function(){(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[0]")).toEqual({letterSpacing:0});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[0.1]")).toEqual({letterSpacing:0.1});(0,_vitest.expect)((0,_typography.parseTypography)("tracking-[10]")).toEqual({letterSpacing:10});});});(0,_vitest.describe)("parseTypography - custom fontSize",function(){var customFontSize={tiny:10,huge:96,xl:22,custom:17};(0,_vitest.it)("should support custom font sizes",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-tiny",undefined,customFontSize)).toEqual({fontSize:10});(0,_vitest.expect)((0,_typography.parseTypography)("text-huge",undefined,customFontSize)).toEqual({fontSize:96});(0,_vitest.expect)((0,_typography.parseTypography)("text-custom",undefined,customFontSize)).toEqual({fontSize:17});});(0,_vitest.it)("should allow custom fontSize to override preset sizes",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-xl",undefined,customFontSize)).toEqual({fontSize:22});});(0,_vitest.it)("should fallback to preset sizes when custom fontSize not found",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-base",undefined,customFontSize)).toEqual({fontSize:16});(0,_vitest.expect)((0,_typography.parseTypography)("text-lg",undefined,customFontSize)).toEqual({fontSize:18});(0,_vitest.expect)((0,_typography.parseTypography)("text-2xl",undefined,customFontSize)).toEqual({fontSize:24});});(0,_vitest.it)("should prefer arbitrary values over custom fontSize",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-[15px]",undefined,customFontSize)).toEqual({fontSize:15});(0,_vitest.expect)((0,_typography.parseTypography)("text-[13.5]",undefined,customFontSize)).toEqual({fontSize:13.5});});(0,_vitest.it)("should work with both customFontFamily and customFontSize",function(){var customFontFamily={brand:"MyCustomFont"};(0,_vitest.expect)((0,_typography.parseTypography)("text-tiny",customFontFamily,customFontSize)).toEqual({fontSize:10});(0,_vitest.expect)((0,_typography.parseTypography)("font-brand",customFontFamily,customFontSize)).toEqual({fontFamily:"MyCustomFont"});});(0,_vitest.it)("should return null for unknown custom fontSize keys",function(){(0,_vitest.expect)((0,_typography.parseTypography)("text-nonexistent",undefined,customFontSize)).toBeNull();});});(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-mono")).toEqual({fontFamily:"Courier"});(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});});});
|