@mgcrea/react-native-tailwind 0.15.4 → 0.15.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/babel/index.cjs +93 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/parser/colors.js +1 -1
- package/dist/parser/colors.test.js +1 -1
- package/dist/parser/index.d.ts +1 -0
- package/dist/parser/index.js +1 -1
- package/dist/parser/outline.d.ts +9 -0
- package/dist/parser/outline.js +1 -0
- package/dist/parser/outline.test.js +1 -0
- package/dist/parser/shadows.d.ts +1 -1
- package/dist/parser/shadows.test.js +1 -1
- package/dist/parser/sizing.js +1 -1
- package/dist/parser/sizing.test.js +1 -1
- package/dist/parser/spacing.js +1 -1
- package/dist/parser/spacing.test.js +1 -1
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.cjs.map +4 -4
- package/dist/runtime.js +1 -1
- package/dist/runtime.js.map +4 -4
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/parser/colors.test.ts +1 -1
- package/src/parser/colors.ts +19 -0
- package/src/parser/index.ts +3 -0
- package/src/parser/outline.test.ts +57 -0
- package/src/parser/outline.ts +101 -0
- package/src/parser/shadows.test.ts +1 -1
- package/src/parser/shadows.ts +1 -1
- package/src/parser/sizing.test.ts +92 -0
- package/src/parser/sizing.ts +29 -0
- package/src/parser/spacing.test.ts +24 -0
- package/src/parser/spacing.ts +1 -0
package/dist/babel/index.cjs
CHANGED
|
@@ -791,6 +791,19 @@ function parseColor(cls, customColors) {
|
|
|
791
791
|
return { borderColor: color };
|
|
792
792
|
}
|
|
793
793
|
}
|
|
794
|
+
if (cls.startsWith("outline-") && !cls.match(/^outline-[0-9]/) && !cls.startsWith("outline-offset-")) {
|
|
795
|
+
const colorKey = cls.substring(8);
|
|
796
|
+
if (["solid", "dashed", "dotted", "none"].includes(colorKey)) {
|
|
797
|
+
return null;
|
|
798
|
+
}
|
|
799
|
+
if (colorKey.startsWith("[") && !colorKey.startsWith("[#")) {
|
|
800
|
+
return null;
|
|
801
|
+
}
|
|
802
|
+
const color = parseColorWithOpacity(colorKey);
|
|
803
|
+
if (color) {
|
|
804
|
+
return { outlineColor: color };
|
|
805
|
+
}
|
|
806
|
+
}
|
|
794
807
|
const dirBorderMatch = cls.match(/^border-([trblxy])-(.+)$/);
|
|
795
808
|
if (dirBorderMatch) {
|
|
796
809
|
const dir = dirBorderMatch[1];
|
|
@@ -1436,6 +1449,65 @@ function parseLayout(cls, customSpacing) {
|
|
|
1436
1449
|
return DISPLAY_MAP[cls] ?? FLEX_DIRECTION_MAP[cls] ?? FLEX_WRAP_MAP[cls] ?? FLEX_MAP[cls] ?? GROW_SHRINK_MAP[cls] ?? JUSTIFY_CONTENT_MAP[cls] ?? ALIGN_ITEMS_MAP[cls] ?? ALIGN_SELF_MAP[cls] ?? ALIGN_CONTENT_MAP[cls] ?? POSITION_MAP[cls] ?? OVERFLOW_MAP[cls] ?? OPACITY_MAP[cls] ?? null;
|
|
1437
1450
|
}
|
|
1438
1451
|
|
|
1452
|
+
// src/parser/outline.ts
|
|
1453
|
+
function parseArbitraryOutlineValue(value) {
|
|
1454
|
+
const pxMatch = value.match(/^\[(\d+)(?:px)?\]$/);
|
|
1455
|
+
if (pxMatch) {
|
|
1456
|
+
return parseInt(pxMatch[1], 10);
|
|
1457
|
+
}
|
|
1458
|
+
if (value.startsWith("[") && value.endsWith("]")) {
|
|
1459
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1460
|
+
console.warn(
|
|
1461
|
+
`[react-native-tailwind] Unsupported arbitrary outline value: ${value}. Only px values are supported (e.g., [8px] or [8]).`
|
|
1462
|
+
);
|
|
1463
|
+
}
|
|
1464
|
+
return null;
|
|
1465
|
+
}
|
|
1466
|
+
return null;
|
|
1467
|
+
}
|
|
1468
|
+
function parseOutline(cls) {
|
|
1469
|
+
if (cls === "outline") {
|
|
1470
|
+
return { outlineWidth: 1, outlineStyle: "solid" };
|
|
1471
|
+
}
|
|
1472
|
+
if (cls === "outline-none") {
|
|
1473
|
+
return { outlineWidth: 0 };
|
|
1474
|
+
}
|
|
1475
|
+
if (cls === "outline-solid") return { outlineStyle: "solid" };
|
|
1476
|
+
if (cls === "outline-dotted") return { outlineStyle: "dotted" };
|
|
1477
|
+
if (cls === "outline-dashed") return { outlineStyle: "dashed" };
|
|
1478
|
+
if (cls.startsWith("outline-offset-")) {
|
|
1479
|
+
const valueStr = cls.substring(15);
|
|
1480
|
+
if (valueStr.startsWith("[")) {
|
|
1481
|
+
const arbitraryValue = parseArbitraryOutlineValue(valueStr);
|
|
1482
|
+
if (arbitraryValue !== null) {
|
|
1483
|
+
return { outlineOffset: arbitraryValue };
|
|
1484
|
+
}
|
|
1485
|
+
return null;
|
|
1486
|
+
}
|
|
1487
|
+
const scaleValue = BORDER_WIDTH_SCALE[valueStr];
|
|
1488
|
+
if (scaleValue !== void 0) {
|
|
1489
|
+
return { outlineOffset: scaleValue };
|
|
1490
|
+
}
|
|
1491
|
+
return null;
|
|
1492
|
+
}
|
|
1493
|
+
const widthMatch = cls.match(/^outline-(\d+)$/);
|
|
1494
|
+
if (widthMatch) {
|
|
1495
|
+
const value = BORDER_WIDTH_SCALE[widthMatch[1]];
|
|
1496
|
+
if (value !== void 0) {
|
|
1497
|
+
return { outlineWidth: value };
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
const arbMatch = cls.match(/^outline-(\[.+\])$/);
|
|
1501
|
+
if (arbMatch) {
|
|
1502
|
+
const arbitraryValue = parseArbitraryOutlineValue(arbMatch[1]);
|
|
1503
|
+
if (arbitraryValue !== null) {
|
|
1504
|
+
return { outlineWidth: arbitraryValue };
|
|
1505
|
+
}
|
|
1506
|
+
return null;
|
|
1507
|
+
}
|
|
1508
|
+
return null;
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1439
1511
|
// src/parser/shadows.ts
|
|
1440
1512
|
var SHADOW_SCALE = {
|
|
1441
1513
|
"shadow-sm": {
|
|
@@ -1507,6 +1579,7 @@ var RUNTIME_DIMENSIONS_MARKER = "{{RUNTIME:dimensions.";
|
|
|
1507
1579
|
|
|
1508
1580
|
// src/parser/sizing.ts
|
|
1509
1581
|
var SIZE_SCALE = {
|
|
1582
|
+
px: 1,
|
|
1510
1583
|
0: 0,
|
|
1511
1584
|
0.5: 2,
|
|
1512
1585
|
1: 4,
|
|
@@ -1581,6 +1654,24 @@ function parseArbitrarySize(value) {
|
|
|
1581
1654
|
}
|
|
1582
1655
|
function parseSizing(cls, customSpacing) {
|
|
1583
1656
|
const sizeMap = customSpacing ? { ...SIZE_SCALE, ...customSpacing } : SIZE_SCALE;
|
|
1657
|
+
if (cls.startsWith("size-")) {
|
|
1658
|
+
const sizeKey = cls.substring(5);
|
|
1659
|
+
const arbitrarySize = parseArbitrarySize(sizeKey);
|
|
1660
|
+
if (arbitrarySize !== null) {
|
|
1661
|
+
return { width: arbitrarySize, height: arbitrarySize };
|
|
1662
|
+
}
|
|
1663
|
+
const percentage = SIZE_PERCENTAGES[sizeKey];
|
|
1664
|
+
if (percentage) {
|
|
1665
|
+
return { width: percentage, height: percentage };
|
|
1666
|
+
}
|
|
1667
|
+
const numericSize = sizeMap[sizeKey];
|
|
1668
|
+
if (numericSize !== void 0) {
|
|
1669
|
+
return { width: numericSize, height: numericSize };
|
|
1670
|
+
}
|
|
1671
|
+
if (sizeKey === "auto") {
|
|
1672
|
+
return { width: "auto", height: "auto" };
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1584
1675
|
if (cls.startsWith("w-")) {
|
|
1585
1676
|
const sizeKey = cls.substring(2);
|
|
1586
1677
|
if (sizeKey === "screen") {
|
|
@@ -1688,6 +1779,7 @@ function parseSizing(cls, customSpacing) {
|
|
|
1688
1779
|
|
|
1689
1780
|
// src/parser/spacing.ts
|
|
1690
1781
|
var SPACING_SCALE = {
|
|
1782
|
+
px: 1,
|
|
1691
1783
|
0: 0,
|
|
1692
1784
|
0.5: 2,
|
|
1693
1785
|
1: 4,
|
|
@@ -2449,6 +2541,7 @@ function parseClass(cls, customTheme) {
|
|
|
2449
2541
|
const parsers = [
|
|
2450
2542
|
(cls2) => parseSpacing(cls2, customTheme?.spacing),
|
|
2451
2543
|
(cls2) => parseBorder(cls2, customTheme?.colors),
|
|
2544
|
+
parseOutline,
|
|
2452
2545
|
(cls2) => parseColor(cls2, customTheme?.colors),
|
|
2453
2546
|
(cls2) => parseLayout(cls2, customTheme?.spacing),
|
|
2454
2547
|
(cls2) => parseTypography(cls2, customTheme?.fontFamily, customTheme?.fontSize),
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export { generateStyleKey } from "./utils/styleKey";
|
|
|
10
10
|
export type { StyleObject } from "./types/core";
|
|
11
11
|
export type { NativeStyle, TwStyle } from "./types/runtime";
|
|
12
12
|
export { TAILWIND_COLORS } from "./config/tailwind";
|
|
13
|
-
export { parseAspectRatio, parseBorder, parseColor, parseLayout, parsePlaceholderClass, parsePlaceholderClasses, parseShadow, parseSizing, parseSpacing, parseTypography, } from "./parser";
|
|
13
|
+
export { parseAspectRatio, parseBorder, parseColor, parseLayout, parseOutline, parsePlaceholderClass, parsePlaceholderClasses, parseShadow, parseSizing, parseSpacing, parseTypography, } from "./parser";
|
|
14
14
|
export { ASPECT_RATIO_PRESETS } from "./parser/aspectRatio";
|
|
15
15
|
export { COLORS } from "./parser/colors";
|
|
16
16
|
export { INSET_SCALE, Z_INDEX_SCALE } from "./parser/layout";
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});var _exportNames={tw:true,twStyle:true,parseClass:true,parseClassName:true,parseAspectRatio:true,parseBorder:true,parseColor:true,parseLayout:true,parsePlaceholderClass:true,parsePlaceholderClasses:true,parseShadow:true,parseSizing:true,parseSpacing:true,parseTypography:true,flattenColors:true,mergeStyles:true,generateStyleKey:true,TAILWIND_COLORS:true,ASPECT_RATIO_PRESETS:true,COLORS:true,INSET_SCALE:true,Z_INDEX_SCALE:true,SHADOW_SCALE:true,SIZE_PERCENTAGES:true,SIZE_SCALE:true,SPACING_SCALE:true,FONT_SIZES:true,LETTER_SPACING_SCALE:true};Object.defineProperty(exports,"ASPECT_RATIO_PRESETS",{enumerable:true,get:function get(){return _aspectRatio.ASPECT_RATIO_PRESETS;}});Object.defineProperty(exports,"COLORS",{enumerable:true,get:function get(){return _colors.COLORS;}});Object.defineProperty(exports,"FONT_SIZES",{enumerable:true,get:function get(){return _typography.FONT_SIZES;}});Object.defineProperty(exports,"INSET_SCALE",{enumerable:true,get:function get(){return _layout.INSET_SCALE;}});Object.defineProperty(exports,"LETTER_SPACING_SCALE",{enumerable:true,get:function get(){return _typography.LETTER_SPACING_SCALE;}});Object.defineProperty(exports,"SHADOW_SCALE",{enumerable:true,get:function get(){return _shadows.SHADOW_SCALE;}});Object.defineProperty(exports,"SIZE_PERCENTAGES",{enumerable:true,get:function get(){return _sizing.SIZE_PERCENTAGES;}});Object.defineProperty(exports,"SIZE_SCALE",{enumerable:true,get:function get(){return _sizing.SIZE_SCALE;}});Object.defineProperty(exports,"SPACING_SCALE",{enumerable:true,get:function get(){return _spacing.SPACING_SCALE;}});Object.defineProperty(exports,"TAILWIND_COLORS",{enumerable:true,get:function get(){return _tailwind.TAILWIND_COLORS;}});Object.defineProperty(exports,"Z_INDEX_SCALE",{enumerable:true,get:function get(){return _layout.Z_INDEX_SCALE;}});Object.defineProperty(exports,"flattenColors",{enumerable:true,get:function get(){return _flattenColors.flattenColors;}});Object.defineProperty(exports,"generateStyleKey",{enumerable:true,get:function get(){return _styleKey.generateStyleKey;}});Object.defineProperty(exports,"mergeStyles",{enumerable:true,get:function get(){return _mergeStyles.mergeStyles;}});Object.defineProperty(exports,"parseAspectRatio",{enumerable:true,get:function get(){return _parser.parseAspectRatio;}});Object.defineProperty(exports,"parseBorder",{enumerable:true,get:function get(){return _parser.parseBorder;}});Object.defineProperty(exports,"parseClass",{enumerable:true,get:function get(){return _parser.parseClass;}});Object.defineProperty(exports,"parseClassName",{enumerable:true,get:function get(){return _parser.parseClassName;}});Object.defineProperty(exports,"parseColor",{enumerable:true,get:function get(){return _parser.parseColor;}});Object.defineProperty(exports,"parseLayout",{enumerable:true,get:function get(){return _parser.parseLayout;}});Object.defineProperty(exports,"parsePlaceholderClass",{enumerable:true,get:function get(){return _parser.parsePlaceholderClass;}});Object.defineProperty(exports,"parsePlaceholderClasses",{enumerable:true,get:function get(){return _parser.parsePlaceholderClasses;}});Object.defineProperty(exports,"parseShadow",{enumerable:true,get:function get(){return _parser.parseShadow;}});Object.defineProperty(exports,"parseSizing",{enumerable:true,get:function get(){return _parser.parseSizing;}});Object.defineProperty(exports,"parseSpacing",{enumerable:true,get:function get(){return _parser.parseSpacing;}});Object.defineProperty(exports,"parseTypography",{enumerable:true,get:function get(){return _parser.parseTypography;}});Object.defineProperty(exports,"tw",{enumerable:true,get:function get(){return _tw.tw;}});Object.defineProperty(exports,"twStyle",{enumerable:true,get:function get(){return _tw.twStyle;}});var _tw=require("./stubs/tw");var _parser=require("./parser");var _flattenColors=require("./utils/flattenColors");var _mergeStyles=require("./utils/mergeStyles");var _styleKey=require("./utils/styleKey");var _tailwind=require("./config/tailwind");var _aspectRatio=require("./parser/aspectRatio");var _colors=require("./parser/colors");var _layout=require("./parser/layout");var _shadows=require("./parser/shadows");var _sizing=require("./parser/sizing");var _spacing=require("./parser/spacing");var _typography=require("./parser/typography");var _components=require("./components");Object.keys(_components).forEach(function(key){if(key==="default"||key==="__esModule")return;if(Object.prototype.hasOwnProperty.call(_exportNames,key))return;if(key in exports&&exports[key]===_components[key])return;Object.defineProperty(exports,key,{enumerable:true,get:function get(){return _components[key];}});});
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});var _exportNames={tw:true,twStyle:true,parseClass:true,parseClassName:true,parseAspectRatio:true,parseBorder:true,parseColor:true,parseLayout:true,parseOutline:true,parsePlaceholderClass:true,parsePlaceholderClasses:true,parseShadow:true,parseSizing:true,parseSpacing:true,parseTypography:true,flattenColors:true,mergeStyles:true,generateStyleKey:true,TAILWIND_COLORS:true,ASPECT_RATIO_PRESETS:true,COLORS:true,INSET_SCALE:true,Z_INDEX_SCALE:true,SHADOW_SCALE:true,SIZE_PERCENTAGES:true,SIZE_SCALE:true,SPACING_SCALE:true,FONT_SIZES:true,LETTER_SPACING_SCALE:true};Object.defineProperty(exports,"ASPECT_RATIO_PRESETS",{enumerable:true,get:function get(){return _aspectRatio.ASPECT_RATIO_PRESETS;}});Object.defineProperty(exports,"COLORS",{enumerable:true,get:function get(){return _colors.COLORS;}});Object.defineProperty(exports,"FONT_SIZES",{enumerable:true,get:function get(){return _typography.FONT_SIZES;}});Object.defineProperty(exports,"INSET_SCALE",{enumerable:true,get:function get(){return _layout.INSET_SCALE;}});Object.defineProperty(exports,"LETTER_SPACING_SCALE",{enumerable:true,get:function get(){return _typography.LETTER_SPACING_SCALE;}});Object.defineProperty(exports,"SHADOW_SCALE",{enumerable:true,get:function get(){return _shadows.SHADOW_SCALE;}});Object.defineProperty(exports,"SIZE_PERCENTAGES",{enumerable:true,get:function get(){return _sizing.SIZE_PERCENTAGES;}});Object.defineProperty(exports,"SIZE_SCALE",{enumerable:true,get:function get(){return _sizing.SIZE_SCALE;}});Object.defineProperty(exports,"SPACING_SCALE",{enumerable:true,get:function get(){return _spacing.SPACING_SCALE;}});Object.defineProperty(exports,"TAILWIND_COLORS",{enumerable:true,get:function get(){return _tailwind.TAILWIND_COLORS;}});Object.defineProperty(exports,"Z_INDEX_SCALE",{enumerable:true,get:function get(){return _layout.Z_INDEX_SCALE;}});Object.defineProperty(exports,"flattenColors",{enumerable:true,get:function get(){return _flattenColors.flattenColors;}});Object.defineProperty(exports,"generateStyleKey",{enumerable:true,get:function get(){return _styleKey.generateStyleKey;}});Object.defineProperty(exports,"mergeStyles",{enumerable:true,get:function get(){return _mergeStyles.mergeStyles;}});Object.defineProperty(exports,"parseAspectRatio",{enumerable:true,get:function get(){return _parser.parseAspectRatio;}});Object.defineProperty(exports,"parseBorder",{enumerable:true,get:function get(){return _parser.parseBorder;}});Object.defineProperty(exports,"parseClass",{enumerable:true,get:function get(){return _parser.parseClass;}});Object.defineProperty(exports,"parseClassName",{enumerable:true,get:function get(){return _parser.parseClassName;}});Object.defineProperty(exports,"parseColor",{enumerable:true,get:function get(){return _parser.parseColor;}});Object.defineProperty(exports,"parseLayout",{enumerable:true,get:function get(){return _parser.parseLayout;}});Object.defineProperty(exports,"parseOutline",{enumerable:true,get:function get(){return _parser.parseOutline;}});Object.defineProperty(exports,"parsePlaceholderClass",{enumerable:true,get:function get(){return _parser.parsePlaceholderClass;}});Object.defineProperty(exports,"parsePlaceholderClasses",{enumerable:true,get:function get(){return _parser.parsePlaceholderClasses;}});Object.defineProperty(exports,"parseShadow",{enumerable:true,get:function get(){return _parser.parseShadow;}});Object.defineProperty(exports,"parseSizing",{enumerable:true,get:function get(){return _parser.parseSizing;}});Object.defineProperty(exports,"parseSpacing",{enumerable:true,get:function get(){return _parser.parseSpacing;}});Object.defineProperty(exports,"parseTypography",{enumerable:true,get:function get(){return _parser.parseTypography;}});Object.defineProperty(exports,"tw",{enumerable:true,get:function get(){return _tw.tw;}});Object.defineProperty(exports,"twStyle",{enumerable:true,get:function get(){return _tw.twStyle;}});var _tw=require("./stubs/tw");var _parser=require("./parser");var _flattenColors=require("./utils/flattenColors");var _mergeStyles=require("./utils/mergeStyles");var _styleKey=require("./utils/styleKey");var _tailwind=require("./config/tailwind");var _aspectRatio=require("./parser/aspectRatio");var _colors=require("./parser/colors");var _layout=require("./parser/layout");var _shadows=require("./parser/shadows");var _sizing=require("./parser/sizing");var _spacing=require("./parser/spacing");var _typography=require("./parser/typography");var _components=require("./components");Object.keys(_components).forEach(function(key){if(key==="default"||key==="__esModule")return;if(Object.prototype.hasOwnProperty.call(_exportNames,key))return;if(key in exports&&exports[key]===_components[key])return;Object.defineProperty(exports,key,{enumerable:true,get:function get(){return _components[key];}});});
|
package/dist/parser/colors.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"COLORS",{enumerable:true,get:function get(){return _colorUtils.COLORS;}});exports.parseColor=parseColor;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _colorUtils=require("../utils/colorUtils");function parseColor(cls,customColors){var getColor=function getColor(key){var _customColors$key;return(_customColors$key=customColors==null?void 0:customColors[key])!=null?_customColors$key:_colorUtils.COLORS[key];};var parseColorWithOpacity=function parseColorWithOpacity(colorKey){var _getColor;var opacityMatch=colorKey.match(/^(.+)\/(\d+)$/);if(opacityMatch){var baseColorKey=opacityMatch[1];var opacity=Number.parseInt(opacityMatch[2],10);if(opacity<0||opacity>100){if(process.env.NODE_ENV!=="production"){console.warn(`[react-native-tailwind] Invalid opacity value: ${opacity}. Opacity must be between 0 and 100.`);}return null;}var _arbitraryColor=(0,_colorUtils.parseArbitraryColor)(baseColorKey);if(_arbitraryColor!==null){return(0,_colorUtils.applyOpacity)(_arbitraryColor,opacity);}var color=getColor(baseColorKey);if(color){return(0,_colorUtils.applyOpacity)(color,opacity);}return null;}var arbitraryColor=(0,_colorUtils.parseArbitraryColor)(colorKey);if(arbitraryColor!==null){return arbitraryColor;}if(colorKey.startsWith("[")&&colorKey.endsWith("]")){if(process.env.NODE_ENV!=="production"){console.warn(`[react-native-tailwind] Unsupported arbitrary color value: ${colorKey}. Only hex colors are supported (e.g., [#ff0000], [#f00], or [#ff0000aa]).`);}return null;}return(_getColor=getColor(colorKey))!=null?_getColor:null;};if(cls.startsWith("bg-")){var colorKey=cls.substring(3);if(colorKey.startsWith("[")&&!colorKey.startsWith("[#")){return null;}var color=parseColorWithOpacity(colorKey);if(color){return{backgroundColor:color};}}if(cls.startsWith("text-")){var _colorKey=cls.substring(5);if(_colorKey.startsWith("[")&&!_colorKey.startsWith("[#")){return null;}var _color=parseColorWithOpacity(_colorKey);if(_color){return{color:_color};}}if(cls.startsWith("border-")&&!cls.match(/^border-[0-9]/)){var _colorKey2=cls.substring(7);if(_colorKey2.startsWith("[")&&!_colorKey2.startsWith("[#")){return null;}var _color2=parseColorWithOpacity(_colorKey2);if(_color2){return{borderColor:_color2};}}var dirBorderMatch=cls.match(/^border-([trblxy])-(.+)$/);if(dirBorderMatch){var dir=dirBorderMatch[1];var
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"COLORS",{enumerable:true,get:function get(){return _colorUtils.COLORS;}});exports.parseColor=parseColor;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _colorUtils=require("../utils/colorUtils");function parseColor(cls,customColors){var getColor=function getColor(key){var _customColors$key;return(_customColors$key=customColors==null?void 0:customColors[key])!=null?_customColors$key:_colorUtils.COLORS[key];};var parseColorWithOpacity=function parseColorWithOpacity(colorKey){var _getColor;var opacityMatch=colorKey.match(/^(.+)\/(\d+)$/);if(opacityMatch){var baseColorKey=opacityMatch[1];var opacity=Number.parseInt(opacityMatch[2],10);if(opacity<0||opacity>100){if(process.env.NODE_ENV!=="production"){console.warn(`[react-native-tailwind] Invalid opacity value: ${opacity}. Opacity must be between 0 and 100.`);}return null;}var _arbitraryColor=(0,_colorUtils.parseArbitraryColor)(baseColorKey);if(_arbitraryColor!==null){return(0,_colorUtils.applyOpacity)(_arbitraryColor,opacity);}var color=getColor(baseColorKey);if(color){return(0,_colorUtils.applyOpacity)(color,opacity);}return null;}var arbitraryColor=(0,_colorUtils.parseArbitraryColor)(colorKey);if(arbitraryColor!==null){return arbitraryColor;}if(colorKey.startsWith("[")&&colorKey.endsWith("]")){if(process.env.NODE_ENV!=="production"){console.warn(`[react-native-tailwind] Unsupported arbitrary color value: ${colorKey}. Only hex colors are supported (e.g., [#ff0000], [#f00], or [#ff0000aa]).`);}return null;}return(_getColor=getColor(colorKey))!=null?_getColor:null;};if(cls.startsWith("bg-")){var colorKey=cls.substring(3);if(colorKey.startsWith("[")&&!colorKey.startsWith("[#")){return null;}var color=parseColorWithOpacity(colorKey);if(color){return{backgroundColor:color};}}if(cls.startsWith("text-")){var _colorKey=cls.substring(5);if(_colorKey.startsWith("[")&&!_colorKey.startsWith("[#")){return null;}var _color=parseColorWithOpacity(_colorKey);if(_color){return{color:_color};}}if(cls.startsWith("border-")&&!cls.match(/^border-[0-9]/)){var _colorKey2=cls.substring(7);if(_colorKey2.startsWith("[")&&!_colorKey2.startsWith("[#")){return null;}var _color2=parseColorWithOpacity(_colorKey2);if(_color2){return{borderColor:_color2};}}if(cls.startsWith("outline-")&&!cls.match(/^outline-[0-9]/)&&!cls.startsWith("outline-offset-")){var _colorKey3=cls.substring(8);if(["solid","dashed","dotted","none"].includes(_colorKey3)){return null;}if(_colorKey3.startsWith("[")&&!_colorKey3.startsWith("[#")){return null;}var _color3=parseColorWithOpacity(_colorKey3);if(_color3){return{outlineColor:_color3};}}var dirBorderMatch=cls.match(/^border-([trblxy])-(.+)$/);if(dirBorderMatch){var dir=dirBorderMatch[1];var _colorKey4=dirBorderMatch[2];if(_colorKey4.startsWith("[")&&!_colorKey4.startsWith("[#")){return null;}var _color4=parseColorWithOpacity(_colorKey4);if(_color4){if(dir==="x"){return{borderLeftColor:_color4,borderRightColor:_color4};}if(dir==="y"){return{borderTopColor:_color4,borderBottomColor:_color4};}var propMap={t:"borderTopColor",r:"borderRightColor",b:"borderBottomColor",l:"borderLeftColor"};return(0,_defineProperty2.default)({},propMap[dir],_color4);}}return null;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var _vitest=require("vitest");var _colors=require("./colors");var _colorUtils=require("../utils/colorUtils");(0,_vitest.describe)("COLORS",function(){(0,_vitest.it)("should export complete color palette",function(){(0,_vitest.expect)(_colors.COLORS).toMatchSnapshot();});});(0,_vitest.describe)("parseColor - background colors",function(){(0,_vitest.it)("should parse background colors with preset values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-blue-500")).toEqual({backgroundColor:_colors.COLORS["blue-500"]});(0,_vitest.expect)((0,_colors.parseColor)("bg-red-500")).toEqual({backgroundColor:_colors.COLORS["red-500"]});(0,_vitest.expect)((0,_colors.parseColor)("bg-green-500")).toEqual({backgroundColor:_colors.COLORS["green-500"]});(0,_vitest.expect)((0,_colors.parseColor)("bg-gray-300")).toEqual({backgroundColor:_colors.COLORS["gray-300"]});});(0,_vitest.it)("should parse background colors with basic values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-white")).toEqual({backgroundColor:"#FFFFFF"});(0,_vitest.expect)((0,_colors.parseColor)("bg-black")).toEqual({backgroundColor:"#000000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-transparent")).toEqual({backgroundColor:"transparent"});});(0,_vitest.it)("should parse background colors with arbitrary 6-digit hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000]")).toEqual({backgroundColor:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#3B82F6]")).toEqual({backgroundColor:"#3B82F6"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#000000]")).toEqual({backgroundColor:"#000000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#FFFFFF]")).toEqual({backgroundColor:"#FFFFFF"});});(0,_vitest.it)("should parse background colors with arbitrary 3-digit hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#f00]")).toEqual({backgroundColor:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#abc]")).toEqual({backgroundColor:"#aabbcc"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#123]")).toEqual({backgroundColor:"#112233"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#FFF]")).toEqual({backgroundColor:"#FFFFFF"});});(0,_vitest.it)("should parse background colors with arbitrary 8-digit hex values (with alpha)",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000aa]")).toEqual({backgroundColor:"#ff0000aa"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#3B82F680]")).toEqual({backgroundColor:"#3B82F680"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#00000000]")).toEqual({backgroundColor:"#00000000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#FFFFFFFF]")).toEqual({backgroundColor:"#FFFFFFFF"});});(0,_vitest.it)("should handle case-insensitive hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#FF0000]")).toEqual({backgroundColor:"#FF0000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000]")).toEqual({backgroundColor:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#Ff0000]")).toEqual({backgroundColor:"#Ff0000"});});(0,_vitest.it)("should prefer arbitrary values over preset colors",function(){var customColors={"[#ff0000]":"#00ff00"};(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000]",customColors)).toEqual({backgroundColor:"#ff0000"});});});(0,_vitest.describe)("parseColor - text colors",function(){(0,_vitest.it)("should parse text colors with preset values",function(){(0,_vitest.expect)((0,_colors.parseColor)("text-blue-500")).toEqual({color:_colors.COLORS["blue-500"]});(0,_vitest.expect)((0,_colors.parseColor)("text-red-500")).toEqual({color:_colors.COLORS["red-500"]});(0,_vitest.expect)((0,_colors.parseColor)("text-green-500")).toEqual({color:_colors.COLORS["green-500"]});(0,_vitest.expect)((0,_colors.parseColor)("text-gray-700")).toEqual({color:_colors.COLORS["gray-700"]});});(0,_vitest.it)("should parse text colors with basic values",function(){(0,_vitest.expect)((0,_colors.parseColor)("text-white")).toEqual({color:"#FFFFFF"});(0,_vitest.expect)((0,_colors.parseColor)("text-black")).toEqual({color:"#000000"});});(0,_vitest.it)("should parse text colors with arbitrary 6-digit hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("text-[#ff0000]")).toEqual({color:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#3B82F6]")).toEqual({color:"#3B82F6"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#333333]")).toEqual({color:"#333333"});});(0,_vitest.it)("should parse text colors with arbitrary 3-digit hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("text-[#f00]")).toEqual({color:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#abc]")).toEqual({color:"#aabbcc"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#000]")).toEqual({color:"#000000"});});(0,_vitest.it)("should parse text colors with arbitrary 8-digit hex values (with alpha)",function(){(0,_vitest.expect)((0,_colors.parseColor)("text-[#ff0000aa]")).toEqual({color:"#ff0000aa"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#00000080]")).toEqual({color:"#00000080"});});});(0,_vitest.describe)("parseColor - border colors",function(){(0,_vitest.it)("should parse border colors with preset values",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-blue-500")).toEqual({borderColor:_colors.COLORS["blue-500"]});(0,_vitest.expect)((0,_colors.parseColor)("border-red-500")).toEqual({borderColor:_colors.COLORS["red-500"]});(0,_vitest.expect)((0,_colors.parseColor)("border-green-500")).toEqual({borderColor:_colors.COLORS["green-500"]});(0,_vitest.expect)((0,_colors.parseColor)("border-gray-200")).toEqual({borderColor:_colors.COLORS["gray-200"]});});(0,_vitest.it)("should parse border colors with basic values",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-white")).toEqual({borderColor:"#FFFFFF"});(0,_vitest.expect)((0,_colors.parseColor)("border-black")).toEqual({borderColor:"#000000"});(0,_vitest.expect)((0,_colors.parseColor)("border-transparent")).toEqual({borderColor:"transparent"});});(0,_vitest.it)("should parse border colors with arbitrary 6-digit hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-[#ff0000]")).toEqual({borderColor:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#3B82F6]")).toEqual({borderColor:"#3B82F6"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#cccccc]")).toEqual({borderColor:"#cccccc"});});(0,_vitest.it)("should parse border colors with arbitrary 3-digit hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-[#f00]")).toEqual({borderColor:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#abc]")).toEqual({borderColor:"#aabbcc"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#999]")).toEqual({borderColor:"#999999"});});(0,_vitest.it)("should parse border colors with arbitrary 8-digit hex values (with alpha)",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-[#ff0000aa]")).toEqual({borderColor:"#ff0000aa"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#0000FF50]")).toEqual({borderColor:"#0000FF50"});});(0,_vitest.it)("should not match border width classes",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-0")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-2")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-4")).toBeNull();});});(0,_vitest.describe)("parseColor - custom colors",function(){var customColors={"brand-primary":"#FF6B6B","brand-secondary":"#4ECDC4",accent:"#FFE66D"};(0,_vitest.it)("should support custom background colors",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-brand-primary",customColors)).toEqual({backgroundColor:"#FF6B6B"});(0,_vitest.expect)((0,_colors.parseColor)("bg-brand-secondary",customColors)).toEqual({backgroundColor:"#4ECDC4"});(0,_vitest.expect)((0,_colors.parseColor)("bg-accent",customColors)).toEqual({backgroundColor:"#FFE66D"});});(0,_vitest.it)("should support custom text colors",function(){(0,_vitest.expect)((0,_colors.parseColor)("text-brand-primary",customColors)).toEqual({color:"#FF6B6B"});(0,_vitest.expect)((0,_colors.parseColor)("text-brand-secondary",customColors)).toEqual({color:"#4ECDC4"});});(0,_vitest.it)("should support custom border colors",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-brand-primary",customColors)).toEqual({borderColor:"#FF6B6B"});(0,_vitest.expect)((0,_colors.parseColor)("border-accent",customColors)).toEqual({borderColor:"#FFE66D"});});(0,_vitest.it)("should allow custom colors to override preset colors",function(){var overrideColors={"blue-500":"#FF0000"};(0,_vitest.expect)((0,_colors.parseColor)("bg-blue-500",overrideColors)).toEqual({backgroundColor:"#FF0000"});});(0,_vitest.it)("should support custom colors with DEFAULT key from tailwind.config",function(){var customColorsWithDefault={primary:"#1bacb5","primary-50":"#eefdfd","primary-100":"#d4f9f9","primary-500":"#1bacb5","primary-900":"#1e4f5b"};(0,_vitest.expect)((0,_colors.parseColor)("bg-primary",customColorsWithDefault)).toEqual({backgroundColor:"#1bacb5"});(0,_vitest.expect)((0,_colors.parseColor)("bg-primary-50",customColorsWithDefault)).toEqual({backgroundColor:"#eefdfd"});(0,_vitest.expect)((0,_colors.parseColor)("text-primary",customColorsWithDefault)).toEqual({color:"#1bacb5"});(0,_vitest.expect)((0,_colors.parseColor)("border-primary",customColorsWithDefault)).toEqual({borderColor:"#1bacb5"});});(0,_vitest.it)("should fallback to preset colors when custom color not found",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-red-500",customColors)).toEqual({backgroundColor:_colors.COLORS["red-500"]});});});(0,_vitest.describe)("parseColor - edge cases",function(){(0,_vitest.it)("should return null for invalid classes",function(){(0,_vitest.expect)((0,_colors.parseColor)("invalid")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("text")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border")).toBeNull();});(0,_vitest.it)("should return null for invalid color values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-invalid")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("text-notacolor")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-xyz")).toBeNull();});(0,_vitest.it)("should return null for invalid arbitrary hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ffff]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[#fffff]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[#fffffff]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[#fffffffff]")).toBeNull();});(0,_vitest.it)("should return null for malformed arbitrary values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-#ff0000]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[ff0000]")).toBeNull();});(0,_vitest.it)("should return null for non-hex arbitrary values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#gggggg]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[#zzzzzz]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[rgb(255,0,0)]")).toBeNull();});(0,_vitest.it)("should return null for non-color arbitrary values (to let other parsers handle them)",function(){(0,_vitest.expect)((0,_colors.parseColor)("text-[13px]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("text-[18px]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("text-[24]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[100%]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[50px]")).toBeNull();});(0,_vitest.it)("should not match partial class names",function(){(0,_vitest.expect)((0,_colors.parseColor)("background-blue-500")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("textcolor-red-500")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-color-blue-500")).toBeNull();});(0,_vitest.it)("should handle all color scale variants",function(){var scales=["50","100","200","300","400","500","600","700","800","900"];scales.forEach(function(scale){(0,_vitest.expect)((0,_colors.parseColor)(`bg-blue-${scale}`)).toBeTruthy();(0,_vitest.expect)((0,_colors.parseColor)(`text-red-${scale}`)).toBeTruthy();(0,_vitest.expect)((0,_colors.parseColor)(`border-green-${scale}`)).toBeTruthy();});});});(0,_vitest.describe)("parseColor - comprehensive coverage",function(){(0,_vitest.it)("should parse all color types with same preset color",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-blue-500")).toEqual({backgroundColor:_colors.COLORS["blue-500"]});(0,_vitest.expect)((0,_colors.parseColor)("text-blue-500")).toEqual({color:_colors.COLORS["blue-500"]});(0,_vitest.expect)((0,_colors.parseColor)("border-blue-500")).toEqual({borderColor:_colors.COLORS["blue-500"]});});(0,_vitest.it)("should parse all color types with same arbitrary hex",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000]")).toEqual({backgroundColor:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#ff0000]")).toEqual({color:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#ff0000]")).toEqual({borderColor:"#ff0000"});});(0,_vitest.it)("should handle all color families",function(){var families=["gray","red","blue","green","yellow","purple","pink","orange","indigo"];families.forEach(function(family){(0,_vitest.expect)((0,_colors.parseColor)(`bg-${family}-500`)).toBeTruthy();(0,_vitest.expect)((0,_colors.parseColor)(`text-${family}-500`)).toBeTruthy();(0,_vitest.expect)((0,_colors.parseColor)(`border-${family}-500`)).toBeTruthy();});});(0,_vitest.it)("should handle arbitrary values with mixed case",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#AbCdEf]")).toEqual({backgroundColor:"#AbCdEf"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#aBcDeF]")).toEqual({color:"#aBcDeF"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#ABCDEF]")).toEqual({borderColor:"#ABCDEF"});});(0,_vitest.it)("should expand 3-digit hex consistently across all color types",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#abc]")).toEqual({backgroundColor:"#aabbcc"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#abc]")).toEqual({color:"#aabbcc"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#abc]")).toEqual({borderColor:"#aabbcc"});});(0,_vitest.it)("should handle alpha channel consistently across all color types",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000aa]")).toEqual({backgroundColor:"#ff0000aa"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#ff0000aa]")).toEqual({color:"#ff0000aa"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#ff0000aa]")).toEqual({borderColor:"#ff0000aa"});});});(0,_vitest.describe)("parseColor - opacity modifiers",function(){(0,_vitest.it)("should parse background colors with opacity modifiers",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-black/50")).toEqual({backgroundColor:(0,_colorUtils.applyOpacity)(_colors.COLORS.black,50)});(0,_vitest.expect)((0,_colors.parseColor)("bg-white/50")).toEqual({backgroundColor:(0,_colorUtils.applyOpacity)(_colors.COLORS.white,50)});(0,_vitest.expect)((0,_colors.parseColor)("bg-blue-500/80")).toEqual({backgroundColor:(0,_colorUtils.applyOpacity)(_colors.COLORS["blue-500"],80)});(0,_vitest.expect)((0,_colors.parseColor)("bg-red-500/30")).toEqual({backgroundColor:(0,_colorUtils.applyOpacity)(_colors.COLORS["red-500"],30)});});(0,_vitest.it)("should parse text colors with opacity modifiers",function(){(0,_vitest.expect)((0,_colors.parseColor)("text-black/80")).toEqual({color:(0,_colorUtils.applyOpacity)(_colors.COLORS.black,80)});(0,_vitest.expect)((0,_colors.parseColor)("text-white/90")).toEqual({color:(0,_colorUtils.applyOpacity)(_colors.COLORS.white,90)});(0,_vitest.expect)((0,_colors.parseColor)("text-gray-900/70")).toEqual({color:(0,_colorUtils.applyOpacity)(_colors.COLORS["gray-900"],70)});(0,_vitest.expect)((0,_colors.parseColor)("text-blue-500/50")).toEqual({color:(0,_colorUtils.applyOpacity)(_colors.COLORS["blue-500"],50)});});(0,_vitest.it)("should parse border colors with opacity modifiers",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-black/25")).toEqual({borderColor:(0,_colorUtils.applyOpacity)(_colors.COLORS.black,25)});(0,_vitest.expect)((0,_colors.parseColor)("border-red-500/60")).toEqual({borderColor:(0,_colorUtils.applyOpacity)(_colors.COLORS["red-500"],60)});(0,_vitest.expect)((0,_colors.parseColor)("border-gray-200/40")).toEqual({borderColor:(0,_colorUtils.applyOpacity)(_colors.COLORS["gray-200"],40)});});(0,_vitest.it)("should handle opacity modifier with arbitrary hex colors",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000]/50")).toEqual({backgroundColor:"#FF000080"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#3B82F6]/80")).toEqual({color:"#3B82F6CC"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#abc]/60")).toEqual({borderColor:"#AABBCC99"});});(0,_vitest.it)("should handle opacity modifier with custom colors",function(){var customColors={"brand-primary":"#FF6B6B"};(0,_vitest.expect)((0,_colors.parseColor)("bg-brand-primary/50",customColors)).toEqual({backgroundColor:"#FF6B6B80"});(0,_vitest.expect)((0,_colors.parseColor)("text-brand-primary/75",customColors)).toEqual({color:"#FF6B6BBF"});});(0,_vitest.it)("should handle opacity 0 (fully transparent)",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-black/0")).toEqual({backgroundColor:(0,_colorUtils.applyOpacity)(_colors.COLORS.black,0)});(0,_vitest.expect)((0,_colors.parseColor)("text-red-500/0")).toEqual({color:(0,_colorUtils.applyOpacity)(_colors.COLORS["red-500"],0)});});(0,_vitest.it)("should handle opacity 100 (fully opaque)",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-black/100")).toEqual({backgroundColor:(0,_colorUtils.applyOpacity)(_colors.COLORS.black,100)});(0,_vitest.expect)((0,_colors.parseColor)("text-blue-500/100")).toEqual({color:(0,_colorUtils.applyOpacity)(_colors.COLORS["blue-500"],100)});});(0,_vitest.it)("should handle transparent color with opacity modifier",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-transparent/50")).toEqual({backgroundColor:"transparent"});});(0,_vitest.it)("should convert opacity percentage to correct hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-black/0")).toEqual({backgroundColor:"#00000000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-black/10")).toEqual({backgroundColor:"#0000001A"});(0,_vitest.expect)((0,_colors.parseColor)("bg-black/25")).toEqual({backgroundColor:"#00000040"});(0,_vitest.expect)((0,_colors.parseColor)("bg-black/50")).toEqual({backgroundColor:"#00000080"});(0,_vitest.expect)((0,_colors.parseColor)("bg-black/75")).toEqual({backgroundColor:"#000000BF"});(0,_vitest.expect)((0,_colors.parseColor)("bg-black/100")).toEqual({backgroundColor:"#000000FF"});});(0,_vitest.it)("should return null for invalid opacity values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-black/101")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-black/-1")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-black/150")).toBeNull();});(0,_vitest.it)("should return null for malformed opacity syntax",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-black/")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-black/abc")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-black/50/")).toBeNull();});(0,_vitest.it)("should handle opacity with 3-digit hex expansion",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#f00]/50")).toEqual({backgroundColor:"#FF000080"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#abc]/75")).toEqual({color:"#AABBCCBF"});});(0,_vitest.it)("should work with all color families",function(){var families=["gray","red","blue","green","yellow","purple","pink","orange","indigo"];families.forEach(function(family){(0,_vitest.expect)((0,_colors.parseColor)(`bg-${family}-500/50`)).toBeTruthy();(0,_vitest.expect)((0,_colors.parseColor)(`text-${family}-500/50`)).toBeTruthy();(0,_vitest.expect)((0,_colors.parseColor)(`border-${family}-500/50`)).toBeTruthy();});});});(0,_vitest.describe)("parseColor - directional border colors",function(){(0,_vitest.it)("should parse directional border colors with preset values",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-t-red-500")).toEqual({borderTopColor:_colors.COLORS["red-500"]});(0,_vitest.expect)((0,_colors.parseColor)("border-r-blue-500")).toEqual({borderRightColor:_colors.COLORS["blue-500"]});(0,_vitest.expect)((0,_colors.parseColor)("border-b-green-500")).toEqual({borderBottomColor:_colors.COLORS["green-500"]});(0,_vitest.expect)((0,_colors.parseColor)("border-l-yellow-500")).toEqual({borderLeftColor:_colors.COLORS["yellow-500"]});});(0,_vitest.it)("should parse directional border colors with basic values",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-t-white")).toEqual({borderTopColor:"#FFFFFF"});(0,_vitest.expect)((0,_colors.parseColor)("border-r-black")).toEqual({borderRightColor:"#000000"});(0,_vitest.expect)((0,_colors.parseColor)("border-b-transparent")).toEqual({borderBottomColor:"transparent"});(0,_vitest.expect)((0,_colors.parseColor)("border-l-white")).toEqual({borderLeftColor:"#FFFFFF"});});(0,_vitest.it)("should parse directional border colors with arbitrary 6-digit hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-t-[#ff0000]")).toEqual({borderTopColor:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("border-r-[#3B82F6]")).toEqual({borderRightColor:"#3B82F6"});(0,_vitest.expect)((0,_colors.parseColor)("border-b-[#00ff00]")).toEqual({borderBottomColor:"#00ff00"});(0,_vitest.expect)((0,_colors.parseColor)("border-l-[#cccccc]")).toEqual({borderLeftColor:"#cccccc"});});(0,_vitest.it)("should parse directional border colors with arbitrary 3-digit hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-t-[#f00]")).toEqual({borderTopColor:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("border-r-[#abc]")).toEqual({borderRightColor:"#aabbcc"});(0,_vitest.expect)((0,_colors.parseColor)("border-b-[#123]")).toEqual({borderBottomColor:"#112233"});(0,_vitest.expect)((0,_colors.parseColor)("border-l-[#999]")).toEqual({borderLeftColor:"#999999"});});(0,_vitest.it)("should parse directional border colors with arbitrary 8-digit hex values (with alpha)",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-t-[#ff0000aa]")).toEqual({borderTopColor:"#ff0000aa"});(0,_vitest.expect)((0,_colors.parseColor)("border-r-[#0000FF50]")).toEqual({borderRightColor:"#0000FF50"});(0,_vitest.expect)((0,_colors.parseColor)("border-b-[#00FF0080]")).toEqual({borderBottomColor:"#00FF0080"});(0,_vitest.expect)((0,_colors.parseColor)("border-l-[#FFFFFF00]")).toEqual({borderLeftColor:"#FFFFFF00"});});(0,_vitest.it)("should parse directional border colors with opacity modifiers",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-t-red-500/50")).toEqual({borderTopColor:(0,_colorUtils.applyOpacity)(_colors.COLORS["red-500"],50)});(0,_vitest.expect)((0,_colors.parseColor)("border-r-blue-500/80")).toEqual({borderRightColor:(0,_colorUtils.applyOpacity)(_colors.COLORS["blue-500"],80)});(0,_vitest.expect)((0,_colors.parseColor)("border-b-green-500/30")).toEqual({borderBottomColor:(0,_colorUtils.applyOpacity)(_colors.COLORS["green-500"],30)});(0,_vitest.expect)((0,_colors.parseColor)("border-l-black/25")).toEqual({borderLeftColor:(0,_colorUtils.applyOpacity)(_colors.COLORS.black,25)});});(0,_vitest.it)("should parse directional border colors with arbitrary hex and opacity",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-t-[#ff0000]/50")).toEqual({borderTopColor:"#FF000080"});(0,_vitest.expect)((0,_colors.parseColor)("border-r-[#3B82F6]/80")).toEqual({borderRightColor:"#3B82F6CC"});(0,_vitest.expect)((0,_colors.parseColor)("border-b-[#abc]/60")).toEqual({borderBottomColor:"#AABBCC99"});(0,_vitest.expect)((0,_colors.parseColor)("border-l-[#000]/100")).toEqual({borderLeftColor:"#000000FF"});});(0,_vitest.it)("should parse directional border colors with custom colors",function(){var customColors={"brand-primary":"#FF6B6B","brand-secondary":"#4ECDC4",accent:"#FFE66D"};(0,_vitest.expect)((0,_colors.parseColor)("border-t-brand-primary",customColors)).toEqual({borderTopColor:"#FF6B6B"});(0,_vitest.expect)((0,_colors.parseColor)("border-r-brand-secondary",customColors)).toEqual({borderRightColor:"#4ECDC4"});(0,_vitest.expect)((0,_colors.parseColor)("border-b-accent",customColors)).toEqual({borderBottomColor:"#FFE66D"});(0,_vitest.expect)((0,_colors.parseColor)("border-l-brand-primary",customColors)).toEqual({borderLeftColor:"#FF6B6B"});});(0,_vitest.it)("should parse directional border colors with custom colors and opacity",function(){var customColors={"brand-primary":"#FF6B6B"};(0,_vitest.expect)((0,_colors.parseColor)("border-t-brand-primary/50",customColors)).toEqual({borderTopColor:"#FF6B6B80"});(0,_vitest.expect)((0,_colors.parseColor)("border-l-brand-primary/75",customColors)).toEqual({borderLeftColor:"#FF6B6BBF"});});(0,_vitest.it)("should not match border width classes",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-t-2")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-r-4")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-b-8")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-l-0")).toBeNull();});(0,_vitest.it)("should not match border width arbitrary values",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-t-[3px]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-r-[8px]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-b-[5]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-l-[10px]")).toBeNull();});(0,_vitest.it)("should return null for invalid directional border color values",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-t-invalid")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-r-notacolor")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-b-xyz")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-l-wrongcolor")).toBeNull();});(0,_vitest.it)("should handle all directions with same color",function(){var color=_colors.COLORS["blue-500"];(0,_vitest.expect)((0,_colors.parseColor)("border-t-blue-500")).toEqual({borderTopColor:color});(0,_vitest.expect)((0,_colors.parseColor)("border-r-blue-500")).toEqual({borderRightColor:color});(0,_vitest.expect)((0,_colors.parseColor)("border-b-blue-500")).toEqual({borderBottomColor:color});(0,_vitest.expect)((0,_colors.parseColor)("border-l-blue-500")).toEqual({borderLeftColor:color});});(0,_vitest.it)("should handle all color families for directional borders",function(){var families=["gray","red","blue","green","yellow","purple","pink","orange","indigo"];families.forEach(function(family){(0,_vitest.expect)((0,_colors.parseColor)(`border-t-${family}-500`)).toBeTruthy();(0,_vitest.expect)((0,_colors.parseColor)(`border-r-${family}-500`)).toBeTruthy();(0,_vitest.expect)((0,_colors.parseColor)(`border-b-${family}-500`)).toBeTruthy();(0,_vitest.expect)((0,_colors.parseColor)(`border-l-${family}-500`)).toBeTruthy();});});(0,_vitest.it)("should handle directional borders with all opacity levels",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-t-black/0")).toEqual({borderTopColor:"#00000000"});(0,_vitest.expect)((0,_colors.parseColor)("border-t-black/25")).toEqual({borderTopColor:"#00000040"});(0,_vitest.expect)((0,_colors.parseColor)("border-t-black/50")).toEqual({borderTopColor:"#00000080"});(0,_vitest.expect)((0,_colors.parseColor)("border-t-black/75")).toEqual({borderTopColor:"#000000BF"});(0,_vitest.expect)((0,_colors.parseColor)("border-t-black/100")).toEqual({borderTopColor:"#000000FF"});});});(0,_vitest.describe)("parseColor - border-x and border-y colors",function(){(0,_vitest.it)("should parse border-x colors (horizontal: left + right)",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-x-red-500")).toEqual({borderLeftColor:_colors.COLORS["red-500"],borderRightColor:_colors.COLORS["red-500"]});(0,_vitest.expect)((0,_colors.parseColor)("border-x-blue-500")).toEqual({borderLeftColor:_colors.COLORS["blue-500"],borderRightColor:_colors.COLORS["blue-500"]});});(0,_vitest.it)("should parse border-y colors (vertical: top + bottom)",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-y-green-500")).toEqual({borderTopColor:_colors.COLORS["green-500"],borderBottomColor:_colors.COLORS["green-500"]});(0,_vitest.expect)((0,_colors.parseColor)("border-y-yellow-500")).toEqual({borderTopColor:_colors.COLORS["yellow-500"],borderBottomColor:_colors.COLORS["yellow-500"]});});(0,_vitest.it)("should parse border-x with basic colors",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-x-white")).toEqual({borderLeftColor:"#FFFFFF",borderRightColor:"#FFFFFF"});(0,_vitest.expect)((0,_colors.parseColor)("border-x-black")).toEqual({borderLeftColor:"#000000",borderRightColor:"#000000"});});(0,_vitest.it)("should parse border-y with basic colors",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-y-white")).toEqual({borderTopColor:"#FFFFFF",borderBottomColor:"#FFFFFF"});(0,_vitest.expect)((0,_colors.parseColor)("border-y-transparent")).toEqual({borderTopColor:"transparent",borderBottomColor:"transparent"});});(0,_vitest.it)("should parse border-x with opacity",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-x-red-500/50")).toEqual({borderLeftColor:(0,_colorUtils.applyOpacity)(_colors.COLORS["red-500"],50),borderRightColor:(0,_colorUtils.applyOpacity)(_colors.COLORS["red-500"],50)});});(0,_vitest.it)("should parse border-y with opacity",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-y-blue-500/80")).toEqual({borderTopColor:(0,_colorUtils.applyOpacity)(_colors.COLORS["blue-500"],80),borderBottomColor:(0,_colorUtils.applyOpacity)(_colors.COLORS["blue-500"],80)});});(0,_vitest.it)("should parse border-x with arbitrary hex colors",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-x-[#ff0000]")).toEqual({borderLeftColor:"#ff0000",borderRightColor:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("border-x-[#abc]")).toEqual({borderLeftColor:"#aabbcc",borderRightColor:"#aabbcc"});});(0,_vitest.it)("should parse border-y with arbitrary hex colors",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-y-[#00ff00]")).toEqual({borderTopColor:"#00ff00",borderBottomColor:"#00ff00"});(0,_vitest.expect)((0,_colors.parseColor)("border-y-[#123]")).toEqual({borderTopColor:"#112233",borderBottomColor:"#112233"});});(0,_vitest.it)("should parse border-x with custom colors",function(){var customColors={"brand-primary":"#FF6B6B"};(0,_vitest.expect)((0,_colors.parseColor)("border-x-brand-primary",customColors)).toEqual({borderLeftColor:"#FF6B6B",borderRightColor:"#FF6B6B"});});(0,_vitest.it)("should parse border-y with custom colors",function(){var customColors={accent:"#FFE66D"};(0,_vitest.expect)((0,_colors.parseColor)("border-y-accent",customColors)).toEqual({borderTopColor:"#FFE66D",borderBottomColor:"#FFE66D"});});(0,_vitest.it)("should not match border-x/border-y width classes",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-x-2")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-y-4")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-x-0")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-y-8")).toBeNull();});(0,_vitest.it)("should not match border-x/border-y arbitrary width values",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-x-[3px]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-y-[5px]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-x-[10]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-y-[8px]")).toBeNull();});});
|
|
1
|
+
var _vitest=require("vitest");var _colorUtils=require("../utils/colorUtils");var _colors=require("./colors");(0,_vitest.describe)("COLORS",function(){(0,_vitest.it)("should export complete color palette",function(){(0,_vitest.expect)(_colors.COLORS).toMatchSnapshot();});});(0,_vitest.describe)("parseColor - background colors",function(){(0,_vitest.it)("should parse background colors with preset values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-blue-500")).toEqual({backgroundColor:_colors.COLORS["blue-500"]});(0,_vitest.expect)((0,_colors.parseColor)("bg-red-500")).toEqual({backgroundColor:_colors.COLORS["red-500"]});(0,_vitest.expect)((0,_colors.parseColor)("bg-green-500")).toEqual({backgroundColor:_colors.COLORS["green-500"]});(0,_vitest.expect)((0,_colors.parseColor)("bg-gray-300")).toEqual({backgroundColor:_colors.COLORS["gray-300"]});});(0,_vitest.it)("should parse background colors with basic values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-white")).toEqual({backgroundColor:"#FFFFFF"});(0,_vitest.expect)((0,_colors.parseColor)("bg-black")).toEqual({backgroundColor:"#000000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-transparent")).toEqual({backgroundColor:"transparent"});});(0,_vitest.it)("should parse background colors with arbitrary 6-digit hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000]")).toEqual({backgroundColor:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#3B82F6]")).toEqual({backgroundColor:"#3B82F6"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#000000]")).toEqual({backgroundColor:"#000000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#FFFFFF]")).toEqual({backgroundColor:"#FFFFFF"});});(0,_vitest.it)("should parse background colors with arbitrary 3-digit hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#f00]")).toEqual({backgroundColor:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#abc]")).toEqual({backgroundColor:"#aabbcc"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#123]")).toEqual({backgroundColor:"#112233"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#FFF]")).toEqual({backgroundColor:"#FFFFFF"});});(0,_vitest.it)("should parse background colors with arbitrary 8-digit hex values (with alpha)",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000aa]")).toEqual({backgroundColor:"#ff0000aa"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#3B82F680]")).toEqual({backgroundColor:"#3B82F680"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#00000000]")).toEqual({backgroundColor:"#00000000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#FFFFFFFF]")).toEqual({backgroundColor:"#FFFFFFFF"});});(0,_vitest.it)("should handle case-insensitive hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#FF0000]")).toEqual({backgroundColor:"#FF0000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000]")).toEqual({backgroundColor:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-[#Ff0000]")).toEqual({backgroundColor:"#Ff0000"});});(0,_vitest.it)("should prefer arbitrary values over preset colors",function(){var customColors={"[#ff0000]":"#00ff00"};(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000]",customColors)).toEqual({backgroundColor:"#ff0000"});});});(0,_vitest.describe)("parseColor - text colors",function(){(0,_vitest.it)("should parse text colors with preset values",function(){(0,_vitest.expect)((0,_colors.parseColor)("text-blue-500")).toEqual({color:_colors.COLORS["blue-500"]});(0,_vitest.expect)((0,_colors.parseColor)("text-red-500")).toEqual({color:_colors.COLORS["red-500"]});(0,_vitest.expect)((0,_colors.parseColor)("text-green-500")).toEqual({color:_colors.COLORS["green-500"]});(0,_vitest.expect)((0,_colors.parseColor)("text-gray-700")).toEqual({color:_colors.COLORS["gray-700"]});});(0,_vitest.it)("should parse text colors with basic values",function(){(0,_vitest.expect)((0,_colors.parseColor)("text-white")).toEqual({color:"#FFFFFF"});(0,_vitest.expect)((0,_colors.parseColor)("text-black")).toEqual({color:"#000000"});});(0,_vitest.it)("should parse text colors with arbitrary 6-digit hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("text-[#ff0000]")).toEqual({color:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#3B82F6]")).toEqual({color:"#3B82F6"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#333333]")).toEqual({color:"#333333"});});(0,_vitest.it)("should parse text colors with arbitrary 3-digit hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("text-[#f00]")).toEqual({color:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#abc]")).toEqual({color:"#aabbcc"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#000]")).toEqual({color:"#000000"});});(0,_vitest.it)("should parse text colors with arbitrary 8-digit hex values (with alpha)",function(){(0,_vitest.expect)((0,_colors.parseColor)("text-[#ff0000aa]")).toEqual({color:"#ff0000aa"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#00000080]")).toEqual({color:"#00000080"});});});(0,_vitest.describe)("parseColor - border colors",function(){(0,_vitest.it)("should parse border colors with preset values",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-blue-500")).toEqual({borderColor:_colors.COLORS["blue-500"]});(0,_vitest.expect)((0,_colors.parseColor)("border-red-500")).toEqual({borderColor:_colors.COLORS["red-500"]});(0,_vitest.expect)((0,_colors.parseColor)("border-green-500")).toEqual({borderColor:_colors.COLORS["green-500"]});(0,_vitest.expect)((0,_colors.parseColor)("border-gray-200")).toEqual({borderColor:_colors.COLORS["gray-200"]});});(0,_vitest.it)("should parse border colors with basic values",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-white")).toEqual({borderColor:"#FFFFFF"});(0,_vitest.expect)((0,_colors.parseColor)("border-black")).toEqual({borderColor:"#000000"});(0,_vitest.expect)((0,_colors.parseColor)("border-transparent")).toEqual({borderColor:"transparent"});});(0,_vitest.it)("should parse border colors with arbitrary 6-digit hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-[#ff0000]")).toEqual({borderColor:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#3B82F6]")).toEqual({borderColor:"#3B82F6"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#cccccc]")).toEqual({borderColor:"#cccccc"});});(0,_vitest.it)("should parse border colors with arbitrary 3-digit hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-[#f00]")).toEqual({borderColor:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#abc]")).toEqual({borderColor:"#aabbcc"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#999]")).toEqual({borderColor:"#999999"});});(0,_vitest.it)("should parse border colors with arbitrary 8-digit hex values (with alpha)",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-[#ff0000aa]")).toEqual({borderColor:"#ff0000aa"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#0000FF50]")).toEqual({borderColor:"#0000FF50"});});(0,_vitest.it)("should not match border width classes",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-0")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-2")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-4")).toBeNull();});});(0,_vitest.describe)("parseColor - custom colors",function(){var customColors={"brand-primary":"#FF6B6B","brand-secondary":"#4ECDC4",accent:"#FFE66D"};(0,_vitest.it)("should support custom background colors",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-brand-primary",customColors)).toEqual({backgroundColor:"#FF6B6B"});(0,_vitest.expect)((0,_colors.parseColor)("bg-brand-secondary",customColors)).toEqual({backgroundColor:"#4ECDC4"});(0,_vitest.expect)((0,_colors.parseColor)("bg-accent",customColors)).toEqual({backgroundColor:"#FFE66D"});});(0,_vitest.it)("should support custom text colors",function(){(0,_vitest.expect)((0,_colors.parseColor)("text-brand-primary",customColors)).toEqual({color:"#FF6B6B"});(0,_vitest.expect)((0,_colors.parseColor)("text-brand-secondary",customColors)).toEqual({color:"#4ECDC4"});});(0,_vitest.it)("should support custom border colors",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-brand-primary",customColors)).toEqual({borderColor:"#FF6B6B"});(0,_vitest.expect)((0,_colors.parseColor)("border-accent",customColors)).toEqual({borderColor:"#FFE66D"});});(0,_vitest.it)("should allow custom colors to override preset colors",function(){var overrideColors={"blue-500":"#FF0000"};(0,_vitest.expect)((0,_colors.parseColor)("bg-blue-500",overrideColors)).toEqual({backgroundColor:"#FF0000"});});(0,_vitest.it)("should support custom colors with DEFAULT key from tailwind.config",function(){var customColorsWithDefault={primary:"#1bacb5","primary-50":"#eefdfd","primary-100":"#d4f9f9","primary-500":"#1bacb5","primary-900":"#1e4f5b"};(0,_vitest.expect)((0,_colors.parseColor)("bg-primary",customColorsWithDefault)).toEqual({backgroundColor:"#1bacb5"});(0,_vitest.expect)((0,_colors.parseColor)("bg-primary-50",customColorsWithDefault)).toEqual({backgroundColor:"#eefdfd"});(0,_vitest.expect)((0,_colors.parseColor)("text-primary",customColorsWithDefault)).toEqual({color:"#1bacb5"});(0,_vitest.expect)((0,_colors.parseColor)("border-primary",customColorsWithDefault)).toEqual({borderColor:"#1bacb5"});});(0,_vitest.it)("should fallback to preset colors when custom color not found",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-red-500",customColors)).toEqual({backgroundColor:_colors.COLORS["red-500"]});});});(0,_vitest.describe)("parseColor - edge cases",function(){(0,_vitest.it)("should return null for invalid classes",function(){(0,_vitest.expect)((0,_colors.parseColor)("invalid")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("text")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border")).toBeNull();});(0,_vitest.it)("should return null for invalid color values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-invalid")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("text-notacolor")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-xyz")).toBeNull();});(0,_vitest.it)("should return null for invalid arbitrary hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ffff]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[#fffff]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[#fffffff]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[#fffffffff]")).toBeNull();});(0,_vitest.it)("should return null for malformed arbitrary values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-#ff0000]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[ff0000]")).toBeNull();});(0,_vitest.it)("should return null for non-hex arbitrary values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#gggggg]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[#zzzzzz]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[rgb(255,0,0)]")).toBeNull();});(0,_vitest.it)("should return null for non-color arbitrary values (to let other parsers handle them)",function(){(0,_vitest.expect)((0,_colors.parseColor)("text-[13px]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("text-[18px]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("text-[24]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[100%]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-[50px]")).toBeNull();});(0,_vitest.it)("should not match partial class names",function(){(0,_vitest.expect)((0,_colors.parseColor)("background-blue-500")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("textcolor-red-500")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-color-blue-500")).toBeNull();});(0,_vitest.it)("should handle all color scale variants",function(){var scales=["50","100","200","300","400","500","600","700","800","900"];scales.forEach(function(scale){(0,_vitest.expect)((0,_colors.parseColor)(`bg-blue-${scale}`)).toBeTruthy();(0,_vitest.expect)((0,_colors.parseColor)(`text-red-${scale}`)).toBeTruthy();(0,_vitest.expect)((0,_colors.parseColor)(`border-green-${scale}`)).toBeTruthy();});});});(0,_vitest.describe)("parseColor - comprehensive coverage",function(){(0,_vitest.it)("should parse all color types with same preset color",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-blue-500")).toEqual({backgroundColor:_colors.COLORS["blue-500"]});(0,_vitest.expect)((0,_colors.parseColor)("text-blue-500")).toEqual({color:_colors.COLORS["blue-500"]});(0,_vitest.expect)((0,_colors.parseColor)("border-blue-500")).toEqual({borderColor:_colors.COLORS["blue-500"]});});(0,_vitest.it)("should parse all color types with same arbitrary hex",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000]")).toEqual({backgroundColor:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#ff0000]")).toEqual({color:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#ff0000]")).toEqual({borderColor:"#ff0000"});});(0,_vitest.it)("should handle all color families",function(){var families=["gray","red","blue","green","yellow","purple","pink","orange","indigo"];families.forEach(function(family){(0,_vitest.expect)((0,_colors.parseColor)(`bg-${family}-500`)).toBeTruthy();(0,_vitest.expect)((0,_colors.parseColor)(`text-${family}-500`)).toBeTruthy();(0,_vitest.expect)((0,_colors.parseColor)(`border-${family}-500`)).toBeTruthy();});});(0,_vitest.it)("should handle arbitrary values with mixed case",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#AbCdEf]")).toEqual({backgroundColor:"#AbCdEf"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#aBcDeF]")).toEqual({color:"#aBcDeF"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#ABCDEF]")).toEqual({borderColor:"#ABCDEF"});});(0,_vitest.it)("should expand 3-digit hex consistently across all color types",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#abc]")).toEqual({backgroundColor:"#aabbcc"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#abc]")).toEqual({color:"#aabbcc"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#abc]")).toEqual({borderColor:"#aabbcc"});});(0,_vitest.it)("should handle alpha channel consistently across all color types",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000aa]")).toEqual({backgroundColor:"#ff0000aa"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#ff0000aa]")).toEqual({color:"#ff0000aa"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#ff0000aa]")).toEqual({borderColor:"#ff0000aa"});});});(0,_vitest.describe)("parseColor - opacity modifiers",function(){(0,_vitest.it)("should parse background colors with opacity modifiers",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-black/50")).toEqual({backgroundColor:(0,_colorUtils.applyOpacity)(_colors.COLORS.black,50)});(0,_vitest.expect)((0,_colors.parseColor)("bg-white/50")).toEqual({backgroundColor:(0,_colorUtils.applyOpacity)(_colors.COLORS.white,50)});(0,_vitest.expect)((0,_colors.parseColor)("bg-blue-500/80")).toEqual({backgroundColor:(0,_colorUtils.applyOpacity)(_colors.COLORS["blue-500"],80)});(0,_vitest.expect)((0,_colors.parseColor)("bg-red-500/30")).toEqual({backgroundColor:(0,_colorUtils.applyOpacity)(_colors.COLORS["red-500"],30)});});(0,_vitest.it)("should parse text colors with opacity modifiers",function(){(0,_vitest.expect)((0,_colors.parseColor)("text-black/80")).toEqual({color:(0,_colorUtils.applyOpacity)(_colors.COLORS.black,80)});(0,_vitest.expect)((0,_colors.parseColor)("text-white/90")).toEqual({color:(0,_colorUtils.applyOpacity)(_colors.COLORS.white,90)});(0,_vitest.expect)((0,_colors.parseColor)("text-gray-900/70")).toEqual({color:(0,_colorUtils.applyOpacity)(_colors.COLORS["gray-900"],70)});(0,_vitest.expect)((0,_colors.parseColor)("text-blue-500/50")).toEqual({color:(0,_colorUtils.applyOpacity)(_colors.COLORS["blue-500"],50)});});(0,_vitest.it)("should parse border colors with opacity modifiers",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-black/25")).toEqual({borderColor:(0,_colorUtils.applyOpacity)(_colors.COLORS.black,25)});(0,_vitest.expect)((0,_colors.parseColor)("border-red-500/60")).toEqual({borderColor:(0,_colorUtils.applyOpacity)(_colors.COLORS["red-500"],60)});(0,_vitest.expect)((0,_colors.parseColor)("border-gray-200/40")).toEqual({borderColor:(0,_colorUtils.applyOpacity)(_colors.COLORS["gray-200"],40)});});(0,_vitest.it)("should handle opacity modifier with arbitrary hex colors",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#ff0000]/50")).toEqual({backgroundColor:"#FF000080"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#3B82F6]/80")).toEqual({color:"#3B82F6CC"});(0,_vitest.expect)((0,_colors.parseColor)("border-[#abc]/60")).toEqual({borderColor:"#AABBCC99"});});(0,_vitest.it)("should handle opacity modifier with custom colors",function(){var customColors={"brand-primary":"#FF6B6B"};(0,_vitest.expect)((0,_colors.parseColor)("bg-brand-primary/50",customColors)).toEqual({backgroundColor:"#FF6B6B80"});(0,_vitest.expect)((0,_colors.parseColor)("text-brand-primary/75",customColors)).toEqual({color:"#FF6B6BBF"});});(0,_vitest.it)("should handle opacity 0 (fully transparent)",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-black/0")).toEqual({backgroundColor:(0,_colorUtils.applyOpacity)(_colors.COLORS.black,0)});(0,_vitest.expect)((0,_colors.parseColor)("text-red-500/0")).toEqual({color:(0,_colorUtils.applyOpacity)(_colors.COLORS["red-500"],0)});});(0,_vitest.it)("should handle opacity 100 (fully opaque)",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-black/100")).toEqual({backgroundColor:(0,_colorUtils.applyOpacity)(_colors.COLORS.black,100)});(0,_vitest.expect)((0,_colors.parseColor)("text-blue-500/100")).toEqual({color:(0,_colorUtils.applyOpacity)(_colors.COLORS["blue-500"],100)});});(0,_vitest.it)("should handle transparent color with opacity modifier",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-transparent/50")).toEqual({backgroundColor:"transparent"});});(0,_vitest.it)("should convert opacity percentage to correct hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-black/0")).toEqual({backgroundColor:"#00000000"});(0,_vitest.expect)((0,_colors.parseColor)("bg-black/10")).toEqual({backgroundColor:"#0000001A"});(0,_vitest.expect)((0,_colors.parseColor)("bg-black/25")).toEqual({backgroundColor:"#00000040"});(0,_vitest.expect)((0,_colors.parseColor)("bg-black/50")).toEqual({backgroundColor:"#00000080"});(0,_vitest.expect)((0,_colors.parseColor)("bg-black/75")).toEqual({backgroundColor:"#000000BF"});(0,_vitest.expect)((0,_colors.parseColor)("bg-black/100")).toEqual({backgroundColor:"#000000FF"});});(0,_vitest.it)("should return null for invalid opacity values",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-black/101")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-black/-1")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-black/150")).toBeNull();});(0,_vitest.it)("should return null for malformed opacity syntax",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-black/")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-black/abc")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("bg-black/50/")).toBeNull();});(0,_vitest.it)("should handle opacity with 3-digit hex expansion",function(){(0,_vitest.expect)((0,_colors.parseColor)("bg-[#f00]/50")).toEqual({backgroundColor:"#FF000080"});(0,_vitest.expect)((0,_colors.parseColor)("text-[#abc]/75")).toEqual({color:"#AABBCCBF"});});(0,_vitest.it)("should work with all color families",function(){var families=["gray","red","blue","green","yellow","purple","pink","orange","indigo"];families.forEach(function(family){(0,_vitest.expect)((0,_colors.parseColor)(`bg-${family}-500/50`)).toBeTruthy();(0,_vitest.expect)((0,_colors.parseColor)(`text-${family}-500/50`)).toBeTruthy();(0,_vitest.expect)((0,_colors.parseColor)(`border-${family}-500/50`)).toBeTruthy();});});});(0,_vitest.describe)("parseColor - directional border colors",function(){(0,_vitest.it)("should parse directional border colors with preset values",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-t-red-500")).toEqual({borderTopColor:_colors.COLORS["red-500"]});(0,_vitest.expect)((0,_colors.parseColor)("border-r-blue-500")).toEqual({borderRightColor:_colors.COLORS["blue-500"]});(0,_vitest.expect)((0,_colors.parseColor)("border-b-green-500")).toEqual({borderBottomColor:_colors.COLORS["green-500"]});(0,_vitest.expect)((0,_colors.parseColor)("border-l-yellow-500")).toEqual({borderLeftColor:_colors.COLORS["yellow-500"]});});(0,_vitest.it)("should parse directional border colors with basic values",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-t-white")).toEqual({borderTopColor:"#FFFFFF"});(0,_vitest.expect)((0,_colors.parseColor)("border-r-black")).toEqual({borderRightColor:"#000000"});(0,_vitest.expect)((0,_colors.parseColor)("border-b-transparent")).toEqual({borderBottomColor:"transparent"});(0,_vitest.expect)((0,_colors.parseColor)("border-l-white")).toEqual({borderLeftColor:"#FFFFFF"});});(0,_vitest.it)("should parse directional border colors with arbitrary 6-digit hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-t-[#ff0000]")).toEqual({borderTopColor:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("border-r-[#3B82F6]")).toEqual({borderRightColor:"#3B82F6"});(0,_vitest.expect)((0,_colors.parseColor)("border-b-[#00ff00]")).toEqual({borderBottomColor:"#00ff00"});(0,_vitest.expect)((0,_colors.parseColor)("border-l-[#cccccc]")).toEqual({borderLeftColor:"#cccccc"});});(0,_vitest.it)("should parse directional border colors with arbitrary 3-digit hex values",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-t-[#f00]")).toEqual({borderTopColor:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("border-r-[#abc]")).toEqual({borderRightColor:"#aabbcc"});(0,_vitest.expect)((0,_colors.parseColor)("border-b-[#123]")).toEqual({borderBottomColor:"#112233"});(0,_vitest.expect)((0,_colors.parseColor)("border-l-[#999]")).toEqual({borderLeftColor:"#999999"});});(0,_vitest.it)("should parse directional border colors with arbitrary 8-digit hex values (with alpha)",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-t-[#ff0000aa]")).toEqual({borderTopColor:"#ff0000aa"});(0,_vitest.expect)((0,_colors.parseColor)("border-r-[#0000FF50]")).toEqual({borderRightColor:"#0000FF50"});(0,_vitest.expect)((0,_colors.parseColor)("border-b-[#00FF0080]")).toEqual({borderBottomColor:"#00FF0080"});(0,_vitest.expect)((0,_colors.parseColor)("border-l-[#FFFFFF00]")).toEqual({borderLeftColor:"#FFFFFF00"});});(0,_vitest.it)("should parse directional border colors with opacity modifiers",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-t-red-500/50")).toEqual({borderTopColor:(0,_colorUtils.applyOpacity)(_colors.COLORS["red-500"],50)});(0,_vitest.expect)((0,_colors.parseColor)("border-r-blue-500/80")).toEqual({borderRightColor:(0,_colorUtils.applyOpacity)(_colors.COLORS["blue-500"],80)});(0,_vitest.expect)((0,_colors.parseColor)("border-b-green-500/30")).toEqual({borderBottomColor:(0,_colorUtils.applyOpacity)(_colors.COLORS["green-500"],30)});(0,_vitest.expect)((0,_colors.parseColor)("border-l-black/25")).toEqual({borderLeftColor:(0,_colorUtils.applyOpacity)(_colors.COLORS.black,25)});});(0,_vitest.it)("should parse directional border colors with arbitrary hex and opacity",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-t-[#ff0000]/50")).toEqual({borderTopColor:"#FF000080"});(0,_vitest.expect)((0,_colors.parseColor)("border-r-[#3B82F6]/80")).toEqual({borderRightColor:"#3B82F6CC"});(0,_vitest.expect)((0,_colors.parseColor)("border-b-[#abc]/60")).toEqual({borderBottomColor:"#AABBCC99"});(0,_vitest.expect)((0,_colors.parseColor)("border-l-[#000]/100")).toEqual({borderLeftColor:"#000000FF"});});(0,_vitest.it)("should parse directional border colors with custom colors",function(){var customColors={"brand-primary":"#FF6B6B","brand-secondary":"#4ECDC4",accent:"#FFE66D"};(0,_vitest.expect)((0,_colors.parseColor)("border-t-brand-primary",customColors)).toEqual({borderTopColor:"#FF6B6B"});(0,_vitest.expect)((0,_colors.parseColor)("border-r-brand-secondary",customColors)).toEqual({borderRightColor:"#4ECDC4"});(0,_vitest.expect)((0,_colors.parseColor)("border-b-accent",customColors)).toEqual({borderBottomColor:"#FFE66D"});(0,_vitest.expect)((0,_colors.parseColor)("border-l-brand-primary",customColors)).toEqual({borderLeftColor:"#FF6B6B"});});(0,_vitest.it)("should parse directional border colors with custom colors and opacity",function(){var customColors={"brand-primary":"#FF6B6B"};(0,_vitest.expect)((0,_colors.parseColor)("border-t-brand-primary/50",customColors)).toEqual({borderTopColor:"#FF6B6B80"});(0,_vitest.expect)((0,_colors.parseColor)("border-l-brand-primary/75",customColors)).toEqual({borderLeftColor:"#FF6B6BBF"});});(0,_vitest.it)("should not match border width classes",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-t-2")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-r-4")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-b-8")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-l-0")).toBeNull();});(0,_vitest.it)("should not match border width arbitrary values",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-t-[3px]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-r-[8px]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-b-[5]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-l-[10px]")).toBeNull();});(0,_vitest.it)("should return null for invalid directional border color values",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-t-invalid")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-r-notacolor")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-b-xyz")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-l-wrongcolor")).toBeNull();});(0,_vitest.it)("should handle all directions with same color",function(){var color=_colors.COLORS["blue-500"];(0,_vitest.expect)((0,_colors.parseColor)("border-t-blue-500")).toEqual({borderTopColor:color});(0,_vitest.expect)((0,_colors.parseColor)("border-r-blue-500")).toEqual({borderRightColor:color});(0,_vitest.expect)((0,_colors.parseColor)("border-b-blue-500")).toEqual({borderBottomColor:color});(0,_vitest.expect)((0,_colors.parseColor)("border-l-blue-500")).toEqual({borderLeftColor:color});});(0,_vitest.it)("should handle all color families for directional borders",function(){var families=["gray","red","blue","green","yellow","purple","pink","orange","indigo"];families.forEach(function(family){(0,_vitest.expect)((0,_colors.parseColor)(`border-t-${family}-500`)).toBeTruthy();(0,_vitest.expect)((0,_colors.parseColor)(`border-r-${family}-500`)).toBeTruthy();(0,_vitest.expect)((0,_colors.parseColor)(`border-b-${family}-500`)).toBeTruthy();(0,_vitest.expect)((0,_colors.parseColor)(`border-l-${family}-500`)).toBeTruthy();});});(0,_vitest.it)("should handle directional borders with all opacity levels",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-t-black/0")).toEqual({borderTopColor:"#00000000"});(0,_vitest.expect)((0,_colors.parseColor)("border-t-black/25")).toEqual({borderTopColor:"#00000040"});(0,_vitest.expect)((0,_colors.parseColor)("border-t-black/50")).toEqual({borderTopColor:"#00000080"});(0,_vitest.expect)((0,_colors.parseColor)("border-t-black/75")).toEqual({borderTopColor:"#000000BF"});(0,_vitest.expect)((0,_colors.parseColor)("border-t-black/100")).toEqual({borderTopColor:"#000000FF"});});});(0,_vitest.describe)("parseColor - border-x and border-y colors",function(){(0,_vitest.it)("should parse border-x colors (horizontal: left + right)",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-x-red-500")).toEqual({borderLeftColor:_colors.COLORS["red-500"],borderRightColor:_colors.COLORS["red-500"]});(0,_vitest.expect)((0,_colors.parseColor)("border-x-blue-500")).toEqual({borderLeftColor:_colors.COLORS["blue-500"],borderRightColor:_colors.COLORS["blue-500"]});});(0,_vitest.it)("should parse border-y colors (vertical: top + bottom)",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-y-green-500")).toEqual({borderTopColor:_colors.COLORS["green-500"],borderBottomColor:_colors.COLORS["green-500"]});(0,_vitest.expect)((0,_colors.parseColor)("border-y-yellow-500")).toEqual({borderTopColor:_colors.COLORS["yellow-500"],borderBottomColor:_colors.COLORS["yellow-500"]});});(0,_vitest.it)("should parse border-x with basic colors",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-x-white")).toEqual({borderLeftColor:"#FFFFFF",borderRightColor:"#FFFFFF"});(0,_vitest.expect)((0,_colors.parseColor)("border-x-black")).toEqual({borderLeftColor:"#000000",borderRightColor:"#000000"});});(0,_vitest.it)("should parse border-y with basic colors",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-y-white")).toEqual({borderTopColor:"#FFFFFF",borderBottomColor:"#FFFFFF"});(0,_vitest.expect)((0,_colors.parseColor)("border-y-transparent")).toEqual({borderTopColor:"transparent",borderBottomColor:"transparent"});});(0,_vitest.it)("should parse border-x with opacity",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-x-red-500/50")).toEqual({borderLeftColor:(0,_colorUtils.applyOpacity)(_colors.COLORS["red-500"],50),borderRightColor:(0,_colorUtils.applyOpacity)(_colors.COLORS["red-500"],50)});});(0,_vitest.it)("should parse border-y with opacity",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-y-blue-500/80")).toEqual({borderTopColor:(0,_colorUtils.applyOpacity)(_colors.COLORS["blue-500"],80),borderBottomColor:(0,_colorUtils.applyOpacity)(_colors.COLORS["blue-500"],80)});});(0,_vitest.it)("should parse border-x with arbitrary hex colors",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-x-[#ff0000]")).toEqual({borderLeftColor:"#ff0000",borderRightColor:"#ff0000"});(0,_vitest.expect)((0,_colors.parseColor)("border-x-[#abc]")).toEqual({borderLeftColor:"#aabbcc",borderRightColor:"#aabbcc"});});(0,_vitest.it)("should parse border-y with arbitrary hex colors",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-y-[#00ff00]")).toEqual({borderTopColor:"#00ff00",borderBottomColor:"#00ff00"});(0,_vitest.expect)((0,_colors.parseColor)("border-y-[#123]")).toEqual({borderTopColor:"#112233",borderBottomColor:"#112233"});});(0,_vitest.it)("should parse border-x with custom colors",function(){var customColors={"brand-primary":"#FF6B6B"};(0,_vitest.expect)((0,_colors.parseColor)("border-x-brand-primary",customColors)).toEqual({borderLeftColor:"#FF6B6B",borderRightColor:"#FF6B6B"});});(0,_vitest.it)("should parse border-y with custom colors",function(){var customColors={accent:"#FFE66D"};(0,_vitest.expect)((0,_colors.parseColor)("border-y-accent",customColors)).toEqual({borderTopColor:"#FFE66D",borderBottomColor:"#FFE66D"});});(0,_vitest.it)("should not match border-x/border-y width classes",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-x-2")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-y-4")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-x-0")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-y-8")).toBeNull();});(0,_vitest.it)("should not match border-x/border-y arbitrary width values",function(){(0,_vitest.expect)((0,_colors.parseColor)("border-x-[3px]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-y-[5px]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-x-[10]")).toBeNull();(0,_vitest.expect)((0,_colors.parseColor)("border-y-[8px]")).toBeNull();});});
|
package/dist/parser/index.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export { parseAspectRatio } from "./aspectRatio";
|
|
|
30
30
|
export { parseBorder } from "./borders";
|
|
31
31
|
export { parseColor } from "./colors";
|
|
32
32
|
export { parseLayout } from "./layout";
|
|
33
|
+
export { parseOutline } from "./outline";
|
|
33
34
|
export { parsePlaceholderClass, parsePlaceholderClasses } from "./placeholder";
|
|
34
35
|
export { parseShadow } from "./shadows";
|
|
35
36
|
export { parseSizing } from "./sizing";
|
package/dist/parser/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"expandSchemeModifier",{enumerable:true,get:function get(){return _modifiers.expandSchemeModifier;}});Object.defineProperty(exports,"hasModifier",{enumerable:true,get:function get(){return _modifiers.hasModifier;}});Object.defineProperty(exports,"isColorClass",{enumerable:true,get:function get(){return _modifiers.isColorClass;}});Object.defineProperty(exports,"isColorSchemeModifier",{enumerable:true,get:function get(){return _modifiers.isColorSchemeModifier;}});Object.defineProperty(exports,"isDirectionalModifier",{enumerable:true,get:function get(){return _modifiers.isDirectionalModifier;}});Object.defineProperty(exports,"isPlatformModifier",{enumerable:true,get:function get(){return _modifiers.isPlatformModifier;}});Object.defineProperty(exports,"isSchemeModifier",{enumerable:true,get:function get(){return _modifiers.isSchemeModifier;}});Object.defineProperty(exports,"isStateModifier",{enumerable:true,get:function get(){return _modifiers.isStateModifier;}});Object.defineProperty(exports,"parseAspectRatio",{enumerable:true,get:function get(){return _aspectRatio.parseAspectRatio;}});Object.defineProperty(exports,"parseBorder",{enumerable:true,get:function get(){return _borders.parseBorder;}});exports.parseClass=parseClass;exports.parseClassName=parseClassName;Object.defineProperty(exports,"parseColor",{enumerable:true,get:function get(){return _colors.parseColor;}});Object.defineProperty(exports,"parseLayout",{enumerable:true,get:function get(){return _layout.parseLayout;}});Object.defineProperty(exports,"parseModifier",{enumerable:true,get:function get(){return _modifiers.parseModifier;}});Object.defineProperty(exports,"parsePlaceholderClass",{enumerable:true,get:function get(){return _placeholder.parsePlaceholderClass;}});Object.defineProperty(exports,"parsePlaceholderClasses",{enumerable:true,get:function get(){return _placeholder.parsePlaceholderClasses;}});Object.defineProperty(exports,"parseShadow",{enumerable:true,get:function get(){return _shadows.parseShadow;}});Object.defineProperty(exports,"parseSizing",{enumerable:true,get:function get(){return _sizing.parseSizing;}});Object.defineProperty(exports,"parseSpacing",{enumerable:true,get:function get(){return _spacing.parseSpacing;}});Object.defineProperty(exports,"parseTransform",{enumerable:true,get:function get(){return _transforms.parseTransform;}});Object.defineProperty(exports,"parseTypography",{enumerable:true,get:function get(){return _typography.parseTypography;}});Object.defineProperty(exports,"splitModifierClasses",{enumerable:true,get:function get(){return _modifiers.splitModifierClasses;}});var _mergeStyles=require("../utils/mergeStyles");var _aspectRatio=require("./aspectRatio");var _borders=require("./borders");var _colors=require("./colors");var _layout=require("./layout");var _shadows=require("./shadows");var _sizing=require("./sizing");var _spacing=require("./spacing");var _transforms=require("./transforms");var _typography=require("./typography");var _placeholder=require("./placeholder");var _modifiers=require("./modifiers");function parseClassName(className,customTheme){var classes=className.split(/\s+/).filter(Boolean);var style={};for(var cls of classes){var parsedStyle=parseClass(cls,customTheme);(0,_mergeStyles.mergeStyles)(style,parsedStyle);}return style;}function parseClass(cls,customTheme){var parsers=[function(cls){return(0,_spacing.parseSpacing)(cls,customTheme==null?void 0:customTheme.spacing);},function(cls){return(0,_borders.parseBorder)(cls,customTheme==null?void 0:customTheme.colors);},function(cls){return(0,_colors.parseColor)(cls,customTheme==null?void 0:customTheme.colors);},function(cls){return(0,_layout.parseLayout)(cls,customTheme==null?void 0:customTheme.spacing);},function(cls){return(0,_typography.parseTypography)(cls,customTheme==null?void 0:customTheme.fontFamily,customTheme==null?void 0:customTheme.fontSize);},function(cls){return(0,_sizing.parseSizing)(cls,customTheme==null?void 0:customTheme.spacing);},function(cls){return(0,_shadows.parseShadow)(cls,customTheme==null?void 0:customTheme.colors);},_aspectRatio.parseAspectRatio,function(cls){return(0,_transforms.parseTransform)(cls,customTheme==null?void 0:customTheme.spacing);}];for(var parser of parsers){var result=parser(cls);if(result!==null){return result;}}if(process.env.NODE_ENV!=="production"){console.warn(`[react-native-tailwind] Unknown class: "${cls}"`);}return{};}
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"expandSchemeModifier",{enumerable:true,get:function get(){return _modifiers.expandSchemeModifier;}});Object.defineProperty(exports,"hasModifier",{enumerable:true,get:function get(){return _modifiers.hasModifier;}});Object.defineProperty(exports,"isColorClass",{enumerable:true,get:function get(){return _modifiers.isColorClass;}});Object.defineProperty(exports,"isColorSchemeModifier",{enumerable:true,get:function get(){return _modifiers.isColorSchemeModifier;}});Object.defineProperty(exports,"isDirectionalModifier",{enumerable:true,get:function get(){return _modifiers.isDirectionalModifier;}});Object.defineProperty(exports,"isPlatformModifier",{enumerable:true,get:function get(){return _modifiers.isPlatformModifier;}});Object.defineProperty(exports,"isSchemeModifier",{enumerable:true,get:function get(){return _modifiers.isSchemeModifier;}});Object.defineProperty(exports,"isStateModifier",{enumerable:true,get:function get(){return _modifiers.isStateModifier;}});Object.defineProperty(exports,"parseAspectRatio",{enumerable:true,get:function get(){return _aspectRatio.parseAspectRatio;}});Object.defineProperty(exports,"parseBorder",{enumerable:true,get:function get(){return _borders.parseBorder;}});exports.parseClass=parseClass;exports.parseClassName=parseClassName;Object.defineProperty(exports,"parseColor",{enumerable:true,get:function get(){return _colors.parseColor;}});Object.defineProperty(exports,"parseLayout",{enumerable:true,get:function get(){return _layout.parseLayout;}});Object.defineProperty(exports,"parseModifier",{enumerable:true,get:function get(){return _modifiers.parseModifier;}});Object.defineProperty(exports,"parseOutline",{enumerable:true,get:function get(){return _outline.parseOutline;}});Object.defineProperty(exports,"parsePlaceholderClass",{enumerable:true,get:function get(){return _placeholder.parsePlaceholderClass;}});Object.defineProperty(exports,"parsePlaceholderClasses",{enumerable:true,get:function get(){return _placeholder.parsePlaceholderClasses;}});Object.defineProperty(exports,"parseShadow",{enumerable:true,get:function get(){return _shadows.parseShadow;}});Object.defineProperty(exports,"parseSizing",{enumerable:true,get:function get(){return _sizing.parseSizing;}});Object.defineProperty(exports,"parseSpacing",{enumerable:true,get:function get(){return _spacing.parseSpacing;}});Object.defineProperty(exports,"parseTransform",{enumerable:true,get:function get(){return _transforms.parseTransform;}});Object.defineProperty(exports,"parseTypography",{enumerable:true,get:function get(){return _typography.parseTypography;}});Object.defineProperty(exports,"splitModifierClasses",{enumerable:true,get:function get(){return _modifiers.splitModifierClasses;}});var _mergeStyles=require("../utils/mergeStyles");var _aspectRatio=require("./aspectRatio");var _borders=require("./borders");var _colors=require("./colors");var _layout=require("./layout");var _outline=require("./outline");var _shadows=require("./shadows");var _sizing=require("./sizing");var _spacing=require("./spacing");var _transforms=require("./transforms");var _typography=require("./typography");var _placeholder=require("./placeholder");var _modifiers=require("./modifiers");function parseClassName(className,customTheme){var classes=className.split(/\s+/).filter(Boolean);var style={};for(var cls of classes){var parsedStyle=parseClass(cls,customTheme);(0,_mergeStyles.mergeStyles)(style,parsedStyle);}return style;}function parseClass(cls,customTheme){var parsers=[function(cls){return(0,_spacing.parseSpacing)(cls,customTheme==null?void 0:customTheme.spacing);},function(cls){return(0,_borders.parseBorder)(cls,customTheme==null?void 0:customTheme.colors);},_outline.parseOutline,function(cls){return(0,_colors.parseColor)(cls,customTheme==null?void 0:customTheme.colors);},function(cls){return(0,_layout.parseLayout)(cls,customTheme==null?void 0:customTheme.spacing);},function(cls){return(0,_typography.parseTypography)(cls,customTheme==null?void 0:customTheme.fontFamily,customTheme==null?void 0:customTheme.fontSize);},function(cls){return(0,_sizing.parseSizing)(cls,customTheme==null?void 0:customTheme.spacing);},function(cls){return(0,_shadows.parseShadow)(cls,customTheme==null?void 0:customTheme.colors);},_aspectRatio.parseAspectRatio,function(cls){return(0,_transforms.parseTransform)(cls,customTheme==null?void 0:customTheme.spacing);}];for(var parser of parsers){var result=parser(cls);if(result!==null){return result;}}if(process.env.NODE_ENV!=="production"){console.warn(`[react-native-tailwind] Unknown class: "${cls}"`);}return{};}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.parseOutline=parseOutline;var _borders=require("./borders");function parseArbitraryOutlineValue(value){var pxMatch=value.match(/^\[(\d+)(?:px)?\]$/);if(pxMatch){return parseInt(pxMatch[1],10);}if(value.startsWith("[")&&value.endsWith("]")){if(process.env.NODE_ENV!=="production"){console.warn(`[react-native-tailwind] Unsupported arbitrary outline value: ${value}. Only px values are supported (e.g., [8px] or [8]).`);}return null;}return null;}function parseOutline(cls){if(cls==="outline"){return{outlineWidth:1,outlineStyle:"solid"};}if(cls==="outline-none"){return{outlineWidth:0};}if(cls==="outline-solid")return{outlineStyle:"solid"};if(cls==="outline-dotted")return{outlineStyle:"dotted"};if(cls==="outline-dashed")return{outlineStyle:"dashed"};if(cls.startsWith("outline-offset-")){var valueStr=cls.substring(15);if(valueStr.startsWith("[")){var arbitraryValue=parseArbitraryOutlineValue(valueStr);if(arbitraryValue!==null){return{outlineOffset:arbitraryValue};}return null;}var scaleValue=_borders.BORDER_WIDTH_SCALE[valueStr];if(scaleValue!==undefined){return{outlineOffset:scaleValue};}return null;}var widthMatch=cls.match(/^outline-(\d+)$/);if(widthMatch){var value=_borders.BORDER_WIDTH_SCALE[widthMatch[1]];if(value!==undefined){return{outlineWidth:value};}}var arbMatch=cls.match(/^outline-(\[.+\])$/);if(arbMatch){var _arbitraryValue=parseArbitraryOutlineValue(arbMatch[1]);if(_arbitraryValue!==null){return{outlineWidth:_arbitraryValue};}return null;}return null;}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var _vitest=require("vitest");var _outline=require("./outline");(0,_vitest.describe)("parseOutline",function(){(0,_vitest.it)("should parse outline shorthand",function(){(0,_vitest.expect)((0,_outline.parseOutline)("outline")).toEqual({outlineWidth:1,outlineStyle:"solid"});});(0,_vitest.it)("should parse outline-none",function(){(0,_vitest.expect)((0,_outline.parseOutline)("outline-none")).toEqual({outlineWidth:0});});(0,_vitest.it)("should parse outline width with preset values",function(){(0,_vitest.expect)((0,_outline.parseOutline)("outline-0")).toEqual({outlineWidth:0});(0,_vitest.expect)((0,_outline.parseOutline)("outline-2")).toEqual({outlineWidth:2});(0,_vitest.expect)((0,_outline.parseOutline)("outline-4")).toEqual({outlineWidth:4});(0,_vitest.expect)((0,_outline.parseOutline)("outline-8")).toEqual({outlineWidth:8});});(0,_vitest.it)("should parse outline width with arbitrary values",function(){(0,_vitest.expect)((0,_outline.parseOutline)("outline-[5px]")).toEqual({outlineWidth:5});(0,_vitest.expect)((0,_outline.parseOutline)("outline-[10]")).toEqual({outlineWidth:10});});(0,_vitest.it)("should parse outline style",function(){(0,_vitest.expect)((0,_outline.parseOutline)("outline-solid")).toEqual({outlineStyle:"solid"});(0,_vitest.expect)((0,_outline.parseOutline)("outline-dashed")).toEqual({outlineStyle:"dashed"});(0,_vitest.expect)((0,_outline.parseOutline)("outline-dotted")).toEqual({outlineStyle:"dotted"});});(0,_vitest.it)("should parse outline offset with preset values",function(){(0,_vitest.expect)((0,_outline.parseOutline)("outline-offset-0")).toEqual({outlineOffset:0});(0,_vitest.expect)((0,_outline.parseOutline)("outline-offset-2")).toEqual({outlineOffset:2});(0,_vitest.expect)((0,_outline.parseOutline)("outline-offset-4")).toEqual({outlineOffset:4});(0,_vitest.expect)((0,_outline.parseOutline)("outline-offset-8")).toEqual({outlineOffset:8});});(0,_vitest.it)("should parse outline offset with arbitrary values",function(){(0,_vitest.expect)((0,_outline.parseOutline)("outline-offset-[3px]")).toEqual({outlineOffset:3});(0,_vitest.expect)((0,_outline.parseOutline)("outline-offset-[5]")).toEqual({outlineOffset:5});});(0,_vitest.it)("should return null for invalid outline values",function(){(0,_vitest.expect)((0,_outline.parseOutline)("outline-invalid")).toBeNull();(0,_vitest.expect)((0,_outline.parseOutline)("outline-3")).toBeNull();(0,_vitest.expect)((0,_outline.parseOutline)("outline-offset-3")).toBeNull();(0,_vitest.expect)((0,_outline.parseOutline)("outline-[5rem]")).toBeNull();});(0,_vitest.it)("should return null for outline colors (handled by parseColor)",function(){(0,_vitest.expect)((0,_outline.parseOutline)("outline-red-500")).toBeNull();(0,_vitest.expect)((0,_outline.parseOutline)("outline-[#ff0000]")).toBeNull();});});
|
package/dist/parser/shadows.d.ts
CHANGED
|
@@ -24,4 +24,4 @@ declare const SHADOW_SCALE: Record<string, StyleObject>;
|
|
|
24
24
|
* @returns Style object or null if not a shadow class
|
|
25
25
|
*/
|
|
26
26
|
export declare function parseShadow(cls: string, customColors?: Record<string, string>): StyleObject | null;
|
|
27
|
-
export {
|
|
27
|
+
export { COLORS as SHADOW_COLORS, SHADOW_SCALE };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var _vitest=require("vitest");var _shadows=require("./shadows");var _colorUtils=require("../utils/colorUtils");(0,_vitest.describe)("SHADOW_SCALE",function(){(0,_vitest.it)("should export complete shadow scale",function(){(0,_vitest.expect)(_shadows.SHADOW_SCALE).toMatchSnapshot();});(0,_vitest.it)("should have all shadow variants",function(){(0,_vitest.expect)(_shadows.SHADOW_SCALE).toHaveProperty("shadow-sm");(0,_vitest.expect)(_shadows.SHADOW_SCALE).toHaveProperty("shadow");(0,_vitest.expect)(_shadows.SHADOW_SCALE).toHaveProperty("shadow-md");(0,_vitest.expect)(_shadows.SHADOW_SCALE).toHaveProperty("shadow-lg");(0,_vitest.expect)(_shadows.SHADOW_SCALE).toHaveProperty("shadow-xl");(0,_vitest.expect)(_shadows.SHADOW_SCALE).toHaveProperty("shadow-2xl");(0,_vitest.expect)(_shadows.SHADOW_SCALE).toHaveProperty("shadow-none");});});(0,_vitest.describe)("parseShadow - basic shadows",function(){(0,_vitest.it)("should parse shadow-sm",function(){var result=(0,_shadows.parseShadow)("shadow-sm");(0,_vitest.expect)(result).toBeTruthy();(0,_vitest.expect)(result).toHaveProperty("shadowColor");(0,_vitest.expect)(result).toHaveProperty("shadowOffset");(0,_vitest.expect)(result).toHaveProperty("shadowOpacity");(0,_vitest.expect)(result).toHaveProperty("shadowRadius");});(0,_vitest.it)("should parse default shadow",function(){var result=(0,_shadows.parseShadow)("shadow");(0,_vitest.expect)(result).toBeTruthy();});(0,_vitest.it)("should parse shadow-md",function(){var result=(0,_shadows.parseShadow)("shadow-md");(0,_vitest.expect)(result).toBeTruthy();});(0,_vitest.it)("should parse shadow-lg",function(){var result=(0,_shadows.parseShadow)("shadow-lg");(0,_vitest.expect)(result).toBeTruthy();});(0,_vitest.it)("should parse shadow-xl",function(){var result=(0,_shadows.parseShadow)("shadow-xl");(0,_vitest.expect)(result).toBeTruthy();});(0,_vitest.it)("should parse shadow-2xl",function(){var result=(0,_shadows.parseShadow)("shadow-2xl");(0,_vitest.expect)(result).toBeTruthy();});(0,_vitest.it)("should parse shadow-none",function(){var result=(0,_shadows.parseShadow)("shadow-none");(0,_vitest.expect)(result).toBeTruthy();(0,_vitest.expect)(result).toMatchObject({shadowColor:"transparent",shadowOpacity:0,shadowRadius:0});});});(0,_vitest.describe)("parseShadow - shadow properties (iOS)",function(){(0,_vitest.it)("should have increasing shadow values for larger shadows",function(){var sm=(0,_shadows.parseShadow)("shadow-sm");var md=(0,_shadows.parseShadow)("shadow-md");var lg=(0,_shadows.parseShadow)("shadow-lg");var xl=(0,_shadows.parseShadow)("shadow-xl");var xxl=(0,_shadows.parseShadow)("shadow-2xl");(0,_vitest.expect)(md==null?void 0:md.shadowOpacity).toBeGreaterThan(sm==null?void 0:sm.shadowOpacity);(0,_vitest.expect)(lg==null?void 0:lg.shadowOpacity).toBeGreaterThan(md==null?void 0:md.shadowOpacity);(0,_vitest.expect)(md==null?void 0:md.shadowRadius).toBeGreaterThan(sm==null?void 0:sm.shadowRadius);(0,_vitest.expect)(lg==null?void 0:lg.shadowRadius).toBeGreaterThan(md==null?void 0:md.shadowRadius);(0,_vitest.expect)(xl==null?void 0:xl.shadowRadius).toBeGreaterThan(lg==null?void 0:lg.shadowRadius);(0,_vitest.expect)(xxl==null?void 0:xxl.shadowRadius).toBeGreaterThan(xl==null?void 0:xl.shadowRadius);});(0,_vitest.it)("should use consistent shadow color",function(){var shadows=["shadow-sm","shadow","shadow-md","shadow-lg","shadow-xl","shadow-2xl"];shadows.forEach(function(shadow){var result=(0,_shadows.parseShadow)(shadow);(0,_vitest.expect)(result==null?void 0:result.shadowColor).toBe("#000000");});});(0,_vitest.it)("should have proper shadowOffset structure",function(){var result=(0,_shadows.parseShadow)("shadow");var shadowOffset=result==null?void 0:result.shadowOffset;(0,_vitest.expect)(shadowOffset).toHaveProperty("width");(0,_vitest.expect)(shadowOffset).toHaveProperty("height");if(typeof shadowOffset==="object"&&shadowOffset!==null){(0,_vitest.expect)(typeof shadowOffset.width).toBe("number");(0,_vitest.expect)(typeof shadowOffset.height).toBe("number");}});(0,_vitest.it)("should include both iOS shadow and Android elevation properties",function(){var result=(0,_shadows.parseShadow)("shadow");(0,_vitest.expect)(result).toHaveProperty("shadowColor");(0,_vitest.expect)(result).toHaveProperty("shadowOffset");(0,_vitest.expect)(result).toHaveProperty("shadowOpacity");(0,_vitest.expect)(result).toHaveProperty("shadowRadius");(0,_vitest.expect)(result).toHaveProperty("elevation");});});(0,_vitest.describe)("parseShadow - shadow properties (Android)",function(){(0,_vitest.it)("should have increasing elevation values for larger shadows",function(){var sm=(0,_shadows.parseShadow)("shadow-sm");var md=(0,_shadows.parseShadow)("shadow-md");var lg=(0,_shadows.parseShadow)("shadow-lg");var xl=(0,_shadows.parseShadow)("shadow-xl");var xxl=(0,_shadows.parseShadow)("shadow-2xl");(0,_vitest.expect)(md==null?void 0:md.elevation).toBeGreaterThan(sm==null?void 0:sm.elevation);(0,_vitest.expect)(lg==null?void 0:lg.elevation).toBeGreaterThan(md==null?void 0:md.elevation);(0,_vitest.expect)(xl==null?void 0:xl.elevation).toBeGreaterThan(lg==null?void 0:lg.elevation);(0,_vitest.expect)(xxl==null?void 0:xxl.elevation).toBeGreaterThan(xl==null?void 0:xl.elevation);});(0,_vitest.it)("should include elevation property for Android",function(){var result=(0,_shadows.parseShadow)("shadow");(0,_vitest.expect)(result).toHaveProperty("elevation");(0,_vitest.expect)(typeof(result==null?void 0:result.elevation)).toBe("number");});});(0,_vitest.describe)("parseShadow - invalid classes",function(){(0,_vitest.it)("should return null for invalid shadow classes",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-invalidcolor")).toBeNull();(0,_vitest.expect)((0,_shadows.parseShadow)("shadows")).toBeNull();(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-")).toBeNull();(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-small")).toBeNull();(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-3xl")).toBeNull();});(0,_vitest.it)("should return null for non-shadow classes",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("bg-blue-500")).toBeNull();(0,_vitest.expect)((0,_shadows.parseShadow)("p-4")).toBeNull();(0,_vitest.expect)((0,_shadows.parseShadow)("text-white")).toBeNull();(0,_vitest.expect)((0,_shadows.parseShadow)("border-2")).toBeNull();});(0,_vitest.it)("should return null for empty or invalid input",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("")).toBeNull();(0,_vitest.expect)((0,_shadows.parseShadow)("shadow123")).toBeNull();});});(0,_vitest.describe)("parseShadow - comprehensive coverage",function(){(0,_vitest.it)("should parse all shadow variants without errors",function(){var variants=["shadow-sm","shadow","shadow-md","shadow-lg","shadow-xl","shadow-2xl","shadow-none"];variants.forEach(function(variant){var result=(0,_shadows.parseShadow)(variant);(0,_vitest.expect)(result).toBeTruthy();(0,_vitest.expect)(typeof result).toBe("object");});});(0,_vitest.it)("should return consistent results for same input",function(){var result1=(0,_shadows.parseShadow)("shadow-md");var result2=(0,_shadows.parseShadow)("shadow-md");(0,_vitest.expect)(result1).toEqual(result2);});(0,_vitest.it)("should handle case-sensitive class names",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("SHADOW")).toBeNull();(0,_vitest.expect)((0,_shadows.parseShadow)("Shadow-md")).toBeNull();(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-MD")).toBeNull();});});(0,_vitest.describe)("parseShadow - shadow colors",function(){(0,_vitest.it)("should parse shadow color with preset colors",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-red-500")).toEqual({shadowColor:_shadows.SHADOW_COLORS["red-500"]});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-blue-800")).toEqual({shadowColor:_shadows.SHADOW_COLORS["blue-800"]});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-green-600")).toEqual({shadowColor:_shadows.SHADOW_COLORS["green-600"]});});(0,_vitest.it)("should parse shadow color with basic colors",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-black")).toEqual({shadowColor:_shadows.SHADOW_COLORS.black});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-white")).toEqual({shadowColor:_shadows.SHADOW_COLORS.white});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-transparent")).toEqual({shadowColor:"transparent"});});(0,_vitest.it)("should parse shadow color with opacity modifier",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-red-500/50")).toEqual({shadowColor:(0,_colorUtils.applyOpacity)(_shadows.SHADOW_COLORS["red-500"],50)});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-blue-800/80")).toEqual({shadowColor:(0,_colorUtils.applyOpacity)(_shadows.SHADOW_COLORS["blue-800"],80)});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-black/25")).toEqual({shadowColor:(0,_colorUtils.applyOpacity)(_shadows.SHADOW_COLORS.black,25)});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-white/0")).toEqual({shadowColor:(0,_colorUtils.applyOpacity)(_shadows.SHADOW_COLORS.white,0)});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-green-500/100")).toEqual({shadowColor:(0,_colorUtils.applyOpacity)(_shadows.SHADOW_COLORS["green-500"],100)});});(0,_vitest.it)("should parse shadow color with arbitrary hex values",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-[#ff0000]")).toEqual({shadowColor:"#ff0000"});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-[#00ff00]")).toEqual({shadowColor:"#00ff00"});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-[#0000ff]")).toEqual({shadowColor:"#0000ff"});});(0,_vitest.it)("should parse shadow color with 3-digit hex values",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-[#f00]")).toEqual({shadowColor:"#ff0000"});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-[#0f0]")).toEqual({shadowColor:"#00ff00"});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-[#00f]")).toEqual({shadowColor:"#0000ff"});});(0,_vitest.it)("should parse shadow color with arbitrary hex and opacity",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-[#ff0000]/50")).toEqual({shadowColor:"#FF000080"});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-[#00ff00]/25")).toEqual({shadowColor:"#00FF0040"});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-[#0000ff]/80")).toEqual({shadowColor:"#0000FFCC"});});(0,_vitest.it)("should parse shadow color with 8-digit hex (with alpha)",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-[#ff000080]")).toEqual({shadowColor:"#ff000080"});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-[#00ff00cc]")).toEqual({shadowColor:"#00ff00cc"});});(0,_vitest.it)("should handle transparent with opacity modifier",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-transparent/50")).toEqual({shadowColor:"transparent"});});(0,_vitest.it)("should return null for invalid opacity values",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-red-500/101")).toBeNull();(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-red-500/-1")).toBeNull();(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-red-500/abc")).toBeNull();});(0,_vitest.it)("should return null for invalid color names",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-notacolor")).toBeNull();(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-foobar-500")).toBeNull();(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-red-999")).toBeNull();});});(0,_vitest.describe)("parseShadow - shadow colors with custom colors",function(){var customColors={brand:"#FF5733","brand-primary":"#3498DB","brand-secondary":"#2ECC71"};(0,_vitest.it)("should parse shadow with custom colors",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-brand",customColors)).toEqual({shadowColor:"#FF5733"});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-brand-primary",customColors)).toEqual({shadowColor:"#3498DB"});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-brand-secondary",customColors)).toEqual({shadowColor:"#2ECC71"});});(0,_vitest.it)("should parse shadow with custom colors and opacity",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-brand/50",customColors)).toEqual({shadowColor:"#FF573380"});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-brand-primary/80",customColors)).toEqual({shadowColor:"#3498DBCC"});});(0,_vitest.it)("should still support preset colors with custom colors",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-red-500",customColors)).toEqual({shadowColor:_shadows.SHADOW_COLORS["red-500"]});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-blue-800/50",customColors)).toEqual({shadowColor:(0,_colorUtils.applyOpacity)(_shadows.SHADOW_COLORS["blue-800"],50)});});(0,_vitest.it)("should allow custom colors to override presets",function(){var overrideColors={"red-500":"#CUSTOM1"};(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-red-500",overrideColors)).toEqual({shadowColor:"#CUSTOM1"});});});
|
|
1
|
+
var _vitest=require("vitest");var _colorUtils=require("../utils/colorUtils");var _shadows=require("./shadows");(0,_vitest.describe)("SHADOW_SCALE",function(){(0,_vitest.it)("should export complete shadow scale",function(){(0,_vitest.expect)(_shadows.SHADOW_SCALE).toMatchSnapshot();});(0,_vitest.it)("should have all shadow variants",function(){(0,_vitest.expect)(_shadows.SHADOW_SCALE).toHaveProperty("shadow-sm");(0,_vitest.expect)(_shadows.SHADOW_SCALE).toHaveProperty("shadow");(0,_vitest.expect)(_shadows.SHADOW_SCALE).toHaveProperty("shadow-md");(0,_vitest.expect)(_shadows.SHADOW_SCALE).toHaveProperty("shadow-lg");(0,_vitest.expect)(_shadows.SHADOW_SCALE).toHaveProperty("shadow-xl");(0,_vitest.expect)(_shadows.SHADOW_SCALE).toHaveProperty("shadow-2xl");(0,_vitest.expect)(_shadows.SHADOW_SCALE).toHaveProperty("shadow-none");});});(0,_vitest.describe)("parseShadow - basic shadows",function(){(0,_vitest.it)("should parse shadow-sm",function(){var result=(0,_shadows.parseShadow)("shadow-sm");(0,_vitest.expect)(result).toBeTruthy();(0,_vitest.expect)(result).toHaveProperty("shadowColor");(0,_vitest.expect)(result).toHaveProperty("shadowOffset");(0,_vitest.expect)(result).toHaveProperty("shadowOpacity");(0,_vitest.expect)(result).toHaveProperty("shadowRadius");});(0,_vitest.it)("should parse default shadow",function(){var result=(0,_shadows.parseShadow)("shadow");(0,_vitest.expect)(result).toBeTruthy();});(0,_vitest.it)("should parse shadow-md",function(){var result=(0,_shadows.parseShadow)("shadow-md");(0,_vitest.expect)(result).toBeTruthy();});(0,_vitest.it)("should parse shadow-lg",function(){var result=(0,_shadows.parseShadow)("shadow-lg");(0,_vitest.expect)(result).toBeTruthy();});(0,_vitest.it)("should parse shadow-xl",function(){var result=(0,_shadows.parseShadow)("shadow-xl");(0,_vitest.expect)(result).toBeTruthy();});(0,_vitest.it)("should parse shadow-2xl",function(){var result=(0,_shadows.parseShadow)("shadow-2xl");(0,_vitest.expect)(result).toBeTruthy();});(0,_vitest.it)("should parse shadow-none",function(){var result=(0,_shadows.parseShadow)("shadow-none");(0,_vitest.expect)(result).toBeTruthy();(0,_vitest.expect)(result).toMatchObject({shadowColor:"transparent",shadowOpacity:0,shadowRadius:0});});});(0,_vitest.describe)("parseShadow - shadow properties (iOS)",function(){(0,_vitest.it)("should have increasing shadow values for larger shadows",function(){var sm=(0,_shadows.parseShadow)("shadow-sm");var md=(0,_shadows.parseShadow)("shadow-md");var lg=(0,_shadows.parseShadow)("shadow-lg");var xl=(0,_shadows.parseShadow)("shadow-xl");var xxl=(0,_shadows.parseShadow)("shadow-2xl");(0,_vitest.expect)(md==null?void 0:md.shadowOpacity).toBeGreaterThan(sm==null?void 0:sm.shadowOpacity);(0,_vitest.expect)(lg==null?void 0:lg.shadowOpacity).toBeGreaterThan(md==null?void 0:md.shadowOpacity);(0,_vitest.expect)(md==null?void 0:md.shadowRadius).toBeGreaterThan(sm==null?void 0:sm.shadowRadius);(0,_vitest.expect)(lg==null?void 0:lg.shadowRadius).toBeGreaterThan(md==null?void 0:md.shadowRadius);(0,_vitest.expect)(xl==null?void 0:xl.shadowRadius).toBeGreaterThan(lg==null?void 0:lg.shadowRadius);(0,_vitest.expect)(xxl==null?void 0:xxl.shadowRadius).toBeGreaterThan(xl==null?void 0:xl.shadowRadius);});(0,_vitest.it)("should use consistent shadow color",function(){var shadows=["shadow-sm","shadow","shadow-md","shadow-lg","shadow-xl","shadow-2xl"];shadows.forEach(function(shadow){var result=(0,_shadows.parseShadow)(shadow);(0,_vitest.expect)(result==null?void 0:result.shadowColor).toBe("#000000");});});(0,_vitest.it)("should have proper shadowOffset structure",function(){var result=(0,_shadows.parseShadow)("shadow");var shadowOffset=result==null?void 0:result.shadowOffset;(0,_vitest.expect)(shadowOffset).toHaveProperty("width");(0,_vitest.expect)(shadowOffset).toHaveProperty("height");if(typeof shadowOffset==="object"&&shadowOffset!==null){(0,_vitest.expect)(typeof shadowOffset.width).toBe("number");(0,_vitest.expect)(typeof shadowOffset.height).toBe("number");}});(0,_vitest.it)("should include both iOS shadow and Android elevation properties",function(){var result=(0,_shadows.parseShadow)("shadow");(0,_vitest.expect)(result).toHaveProperty("shadowColor");(0,_vitest.expect)(result).toHaveProperty("shadowOffset");(0,_vitest.expect)(result).toHaveProperty("shadowOpacity");(0,_vitest.expect)(result).toHaveProperty("shadowRadius");(0,_vitest.expect)(result).toHaveProperty("elevation");});});(0,_vitest.describe)("parseShadow - shadow properties (Android)",function(){(0,_vitest.it)("should have increasing elevation values for larger shadows",function(){var sm=(0,_shadows.parseShadow)("shadow-sm");var md=(0,_shadows.parseShadow)("shadow-md");var lg=(0,_shadows.parseShadow)("shadow-lg");var xl=(0,_shadows.parseShadow)("shadow-xl");var xxl=(0,_shadows.parseShadow)("shadow-2xl");(0,_vitest.expect)(md==null?void 0:md.elevation).toBeGreaterThan(sm==null?void 0:sm.elevation);(0,_vitest.expect)(lg==null?void 0:lg.elevation).toBeGreaterThan(md==null?void 0:md.elevation);(0,_vitest.expect)(xl==null?void 0:xl.elevation).toBeGreaterThan(lg==null?void 0:lg.elevation);(0,_vitest.expect)(xxl==null?void 0:xxl.elevation).toBeGreaterThan(xl==null?void 0:xl.elevation);});(0,_vitest.it)("should include elevation property for Android",function(){var result=(0,_shadows.parseShadow)("shadow");(0,_vitest.expect)(result).toHaveProperty("elevation");(0,_vitest.expect)(typeof(result==null?void 0:result.elevation)).toBe("number");});});(0,_vitest.describe)("parseShadow - invalid classes",function(){(0,_vitest.it)("should return null for invalid shadow classes",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-invalidcolor")).toBeNull();(0,_vitest.expect)((0,_shadows.parseShadow)("shadows")).toBeNull();(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-")).toBeNull();(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-small")).toBeNull();(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-3xl")).toBeNull();});(0,_vitest.it)("should return null for non-shadow classes",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("bg-blue-500")).toBeNull();(0,_vitest.expect)((0,_shadows.parseShadow)("p-4")).toBeNull();(0,_vitest.expect)((0,_shadows.parseShadow)("text-white")).toBeNull();(0,_vitest.expect)((0,_shadows.parseShadow)("border-2")).toBeNull();});(0,_vitest.it)("should return null for empty or invalid input",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("")).toBeNull();(0,_vitest.expect)((0,_shadows.parseShadow)("shadow123")).toBeNull();});});(0,_vitest.describe)("parseShadow - comprehensive coverage",function(){(0,_vitest.it)("should parse all shadow variants without errors",function(){var variants=["shadow-sm","shadow","shadow-md","shadow-lg","shadow-xl","shadow-2xl","shadow-none"];variants.forEach(function(variant){var result=(0,_shadows.parseShadow)(variant);(0,_vitest.expect)(result).toBeTruthy();(0,_vitest.expect)(typeof result).toBe("object");});});(0,_vitest.it)("should return consistent results for same input",function(){var result1=(0,_shadows.parseShadow)("shadow-md");var result2=(0,_shadows.parseShadow)("shadow-md");(0,_vitest.expect)(result1).toEqual(result2);});(0,_vitest.it)("should handle case-sensitive class names",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("SHADOW")).toBeNull();(0,_vitest.expect)((0,_shadows.parseShadow)("Shadow-md")).toBeNull();(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-MD")).toBeNull();});});(0,_vitest.describe)("parseShadow - shadow colors",function(){(0,_vitest.it)("should parse shadow color with preset colors",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-red-500")).toEqual({shadowColor:_shadows.SHADOW_COLORS["red-500"]});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-blue-800")).toEqual({shadowColor:_shadows.SHADOW_COLORS["blue-800"]});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-green-600")).toEqual({shadowColor:_shadows.SHADOW_COLORS["green-600"]});});(0,_vitest.it)("should parse shadow color with basic colors",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-black")).toEqual({shadowColor:_shadows.SHADOW_COLORS.black});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-white")).toEqual({shadowColor:_shadows.SHADOW_COLORS.white});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-transparent")).toEqual({shadowColor:"transparent"});});(0,_vitest.it)("should parse shadow color with opacity modifier",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-red-500/50")).toEqual({shadowColor:(0,_colorUtils.applyOpacity)(_shadows.SHADOW_COLORS["red-500"],50)});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-blue-800/80")).toEqual({shadowColor:(0,_colorUtils.applyOpacity)(_shadows.SHADOW_COLORS["blue-800"],80)});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-black/25")).toEqual({shadowColor:(0,_colorUtils.applyOpacity)(_shadows.SHADOW_COLORS.black,25)});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-white/0")).toEqual({shadowColor:(0,_colorUtils.applyOpacity)(_shadows.SHADOW_COLORS.white,0)});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-green-500/100")).toEqual({shadowColor:(0,_colorUtils.applyOpacity)(_shadows.SHADOW_COLORS["green-500"],100)});});(0,_vitest.it)("should parse shadow color with arbitrary hex values",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-[#ff0000]")).toEqual({shadowColor:"#ff0000"});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-[#00ff00]")).toEqual({shadowColor:"#00ff00"});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-[#0000ff]")).toEqual({shadowColor:"#0000ff"});});(0,_vitest.it)("should parse shadow color with 3-digit hex values",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-[#f00]")).toEqual({shadowColor:"#ff0000"});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-[#0f0]")).toEqual({shadowColor:"#00ff00"});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-[#00f]")).toEqual({shadowColor:"#0000ff"});});(0,_vitest.it)("should parse shadow color with arbitrary hex and opacity",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-[#ff0000]/50")).toEqual({shadowColor:"#FF000080"});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-[#00ff00]/25")).toEqual({shadowColor:"#00FF0040"});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-[#0000ff]/80")).toEqual({shadowColor:"#0000FFCC"});});(0,_vitest.it)("should parse shadow color with 8-digit hex (with alpha)",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-[#ff000080]")).toEqual({shadowColor:"#ff000080"});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-[#00ff00cc]")).toEqual({shadowColor:"#00ff00cc"});});(0,_vitest.it)("should handle transparent with opacity modifier",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-transparent/50")).toEqual({shadowColor:"transparent"});});(0,_vitest.it)("should return null for invalid opacity values",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-red-500/101")).toBeNull();(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-red-500/-1")).toBeNull();(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-red-500/abc")).toBeNull();});(0,_vitest.it)("should return null for invalid color names",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-notacolor")).toBeNull();(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-foobar-500")).toBeNull();(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-red-999")).toBeNull();});});(0,_vitest.describe)("parseShadow - shadow colors with custom colors",function(){var customColors={brand:"#FF5733","brand-primary":"#3498DB","brand-secondary":"#2ECC71"};(0,_vitest.it)("should parse shadow with custom colors",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-brand",customColors)).toEqual({shadowColor:"#FF5733"});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-brand-primary",customColors)).toEqual({shadowColor:"#3498DB"});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-brand-secondary",customColors)).toEqual({shadowColor:"#2ECC71"});});(0,_vitest.it)("should parse shadow with custom colors and opacity",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-brand/50",customColors)).toEqual({shadowColor:"#FF573380"});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-brand-primary/80",customColors)).toEqual({shadowColor:"#3498DBCC"});});(0,_vitest.it)("should still support preset colors with custom colors",function(){(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-red-500",customColors)).toEqual({shadowColor:_shadows.SHADOW_COLORS["red-500"]});(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-blue-800/50",customColors)).toEqual({shadowColor:(0,_colorUtils.applyOpacity)(_shadows.SHADOW_COLORS["blue-800"],50)});});(0,_vitest.it)("should allow custom colors to override presets",function(){var overrideColors={"red-500":"#CUSTOM1"};(0,_vitest.expect)((0,_shadows.parseShadow)("shadow-red-500",overrideColors)).toEqual({shadowColor:"#CUSTOM1"});});});
|
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,customSpacing){var sizeMap=customSpacing?Object.assign({},SIZE_SCALE,customSpacing):SIZE_SCALE;if(cls.startsWith("
|
|
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={px:1,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("size-")){var sizeKey=cls.substring(5);var arbitrarySize=parseArbitrarySize(sizeKey);if(arbitrarySize!==null){return{width:arbitrarySize,height:arbitrarySize};}var percentage=SIZE_PERCENTAGES[sizeKey];if(percentage){return{width:percentage,height:percentage};}var numericSize=sizeMap[sizeKey];if(numericSize!==undefined){return{width:numericSize,height:numericSize};}if(sizeKey==="auto"){return{width:"auto",height:"auto"};}}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 _sizeKey2=cls.substring(2);if(_sizeKey2==="screen"){return{height:`${_markers.RUNTIME_DIMENSIONS_MARKER}height}}`};}var _arbitrarySize2=parseArbitrarySize(_sizeKey2);if(_arbitrarySize2!==null){return{height:_arbitrarySize2};}var _percentage2=SIZE_PERCENTAGES[_sizeKey2];if(_percentage2){return{height:_percentage2};}var _numericSize2=sizeMap[_sizeKey2];if(_numericSize2!==undefined){return{height:_numericSize2};}if(_sizeKey2==="auto"){return{height:"auto"};}}if(cls.startsWith("min-w-")){var _sizeKey3=cls.substring(6);var _arbitrarySize3=parseArbitrarySize(_sizeKey3);if(_arbitrarySize3!==null){return{minWidth:_arbitrarySize3};}var _percentage3=SIZE_PERCENTAGES[_sizeKey3];if(_percentage3){return{minWidth:_percentage3};}var _numericSize3=sizeMap[_sizeKey3];if(_numericSize3!==undefined){return{minWidth:_numericSize3};}}if(cls.startsWith("min-h-")){var _sizeKey4=cls.substring(6);var _arbitrarySize4=parseArbitrarySize(_sizeKey4);if(_arbitrarySize4!==null){return{minHeight:_arbitrarySize4};}var _percentage4=SIZE_PERCENTAGES[_sizeKey4];if(_percentage4){return{minHeight:_percentage4};}var _numericSize4=sizeMap[_sizeKey4];if(_numericSize4!==undefined){return{minHeight:_numericSize4};}}if(cls.startsWith("max-w-")){var _sizeKey5=cls.substring(6);var _arbitrarySize5=parseArbitrarySize(_sizeKey5);if(_arbitrarySize5!==null){return{maxWidth:_arbitrarySize5};}var _percentage5=SIZE_PERCENTAGES[_sizeKey5];if(_percentage5){return{maxWidth:_percentage5};}var _numericSize5=sizeMap[_sizeKey5];if(_numericSize5!==undefined){return{maxWidth:_numericSize5};}}if(cls.startsWith("max-h-")){var _sizeKey6=cls.substring(6);var _arbitrarySize6=parseArbitrarySize(_sizeKey6);if(_arbitrarySize6!==null){return{maxHeight:_arbitrarySize6};}var _percentage6=SIZE_PERCENTAGES[_sizeKey6];if(_percentage6){return{maxHeight:_percentage6};}var _numericSize6=sizeMap[_sizeKey6];if(_numericSize6!==undefined){return{maxHeight:_numericSize6};}}return null;}
|