@mgcrea/react-native-tailwind 0.7.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/babel/index.cjs +334 -196
- package/dist/babel/index.d.ts +4 -40
- package/dist/babel/index.test.ts +214 -1
- package/dist/babel/index.ts +4 -1169
- package/dist/babel/plugin.d.ts +42 -0
- package/{src/babel/index.test.ts → dist/babel/plugin.test.ts} +216 -2
- package/dist/babel/plugin.ts +491 -0
- package/dist/babel/utils/attributeMatchers.d.ts +23 -0
- package/dist/babel/utils/attributeMatchers.test.ts +294 -0
- package/dist/babel/utils/attributeMatchers.ts +71 -0
- package/dist/babel/utils/componentSupport.d.ts +18 -0
- package/dist/babel/utils/componentSupport.test.ts +426 -0
- package/dist/babel/utils/componentSupport.ts +68 -0
- package/dist/babel/utils/dynamicProcessing.d.ts +32 -0
- package/dist/babel/utils/dynamicProcessing.ts +223 -0
- package/dist/babel/utils/modifierProcessing.d.ts +26 -0
- package/dist/babel/utils/modifierProcessing.ts +118 -0
- package/dist/babel/utils/styleInjection.d.ts +15 -0
- package/dist/babel/utils/styleInjection.ts +80 -0
- package/dist/babel/utils/styleTransforms.d.ts +39 -0
- package/dist/babel/utils/styleTransforms.test.ts +349 -0
- package/dist/babel/utils/styleTransforms.ts +258 -0
- package/dist/babel/utils/twProcessing.d.ts +28 -0
- package/dist/babel/utils/twProcessing.ts +124 -0
- package/dist/components/TextInput.d.ts +171 -14
- package/dist/config/tailwind.d.ts +302 -0
- package/dist/config/tailwind.js +1 -0
- package/dist/index.d.ts +5 -4
- 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/modifiers.d.ts +2 -2
- package/dist/parser/modifiers.js +1 -1
- package/dist/parser/placeholder.d.ts +36 -0
- package/dist/parser/placeholder.js +1 -0
- package/dist/parser/placeholder.test.js +1 -0
- package/dist/parser/typography.d.ts +1 -0
- package/dist/parser/typography.js +1 -1
- package/dist/parser/typography.test.js +1 -1
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.cjs.map +4 -4
- package/dist/runtime.d.ts +1 -14
- package/dist/runtime.js +1 -1
- package/dist/runtime.js.map +4 -4
- package/dist/stubs/tw.d.ts +1 -14
- package/dist/types/core.d.ts +40 -0
- package/dist/types/core.js +0 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +1 -0
- package/dist/types/runtime.d.ts +15 -0
- package/dist/types/runtime.js +1 -0
- package/dist/types/util.d.ts +3 -0
- package/dist/types/util.js +0 -0
- package/dist/utils/flattenColors.d.ts +1 -0
- package/dist/utils/flattenColors.js +1 -1
- package/dist/utils/flattenColors.test.js +1 -1
- package/package.json +1 -1
- package/src/babel/index.ts +4 -1169
- package/src/babel/plugin.test.ts +482 -0
- package/src/babel/plugin.ts +491 -0
- package/src/babel/utils/attributeMatchers.test.ts +294 -0
- package/src/babel/utils/attributeMatchers.ts +71 -0
- package/src/babel/utils/componentSupport.test.ts +426 -0
- package/src/babel/utils/componentSupport.ts +68 -0
- package/src/babel/utils/dynamicProcessing.ts +223 -0
- package/src/babel/utils/modifierProcessing.ts +118 -0
- package/src/babel/utils/styleInjection.ts +80 -0
- package/src/babel/utils/styleTransforms.test.ts +349 -0
- package/src/babel/utils/styleTransforms.ts +258 -0
- package/src/babel/utils/twProcessing.ts +124 -0
- package/src/components/TextInput.tsx +17 -14
- package/src/config/{palettes.ts → tailwind.ts} +2 -2
- package/src/index.ts +6 -3
- package/src/parser/colors.test.ts +32 -0
- package/src/parser/colors.ts +2 -2
- package/src/parser/index.ts +2 -1
- package/src/parser/modifiers.ts +10 -4
- package/src/parser/placeholder.test.ts +105 -0
- package/src/parser/placeholder.ts +78 -0
- package/src/parser/typography.test.ts +11 -0
- package/src/parser/typography.ts +20 -2
- package/src/runtime.ts +1 -16
- package/src/stubs/tw.ts +1 -16
- package/src/{types.ts → types/core.ts} +0 -4
- package/src/types/index.ts +2 -0
- package/src/types/runtime.ts +17 -0
- package/src/types/util.ts +1 -0
- package/src/utils/flattenColors.test.ts +100 -0
- package/src/utils/flattenColors.ts +3 -1
package/dist/stubs/tw.d.ts
CHANGED
|
@@ -6,20 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* For runtime parsing, use: import { tw } from '@mgcrea/react-native-tailwind/runtime'
|
|
8
8
|
*/
|
|
9
|
-
import type {
|
|
10
|
-
/**
|
|
11
|
-
* Union type for all React Native style types
|
|
12
|
-
*/
|
|
13
|
-
export type NativeStyle = ViewStyle | TextStyle | ImageStyle;
|
|
14
|
-
/**
|
|
15
|
-
* Return type for tw/twStyle functions with separate style properties for modifiers
|
|
16
|
-
*/
|
|
17
|
-
export type TwStyle<T extends NativeStyle = NativeStyle> = {
|
|
18
|
-
style: T;
|
|
19
|
-
activeStyle?: T;
|
|
20
|
-
focusStyle?: T;
|
|
21
|
-
disabledStyle?: T;
|
|
22
|
-
};
|
|
9
|
+
import type { NativeStyle, TwStyle } from "../types/runtime.js";
|
|
23
10
|
/**
|
|
24
11
|
* Compile-time Tailwind CSS template tag (transformed by Babel plugin)
|
|
25
12
|
*
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core type definitions
|
|
3
|
+
*/
|
|
4
|
+
export type TransformStyle = {
|
|
5
|
+
scale?: number;
|
|
6
|
+
} | {
|
|
7
|
+
scaleX?: number;
|
|
8
|
+
} | {
|
|
9
|
+
scaleY?: number;
|
|
10
|
+
} | {
|
|
11
|
+
rotate?: string;
|
|
12
|
+
} | {
|
|
13
|
+
rotateX?: string;
|
|
14
|
+
} | {
|
|
15
|
+
rotateY?: string;
|
|
16
|
+
} | {
|
|
17
|
+
rotateZ?: string;
|
|
18
|
+
} | {
|
|
19
|
+
translateX?: number | string;
|
|
20
|
+
} | {
|
|
21
|
+
translateY?: number | string;
|
|
22
|
+
} | {
|
|
23
|
+
skewX?: string;
|
|
24
|
+
} | {
|
|
25
|
+
skewY?: string;
|
|
26
|
+
} | {
|
|
27
|
+
perspective?: number;
|
|
28
|
+
};
|
|
29
|
+
export type ShadowOffsetStyle = {
|
|
30
|
+
width: number;
|
|
31
|
+
height: number;
|
|
32
|
+
};
|
|
33
|
+
export type StyleObject = {
|
|
34
|
+
[key: string]: string | number | ShadowOffsetStyle | TransformStyle[] | undefined;
|
|
35
|
+
shadowOffset?: ShadowOffsetStyle;
|
|
36
|
+
transform?: TransformStyle[];
|
|
37
|
+
};
|
|
38
|
+
export type SpacingValue = number;
|
|
39
|
+
export type ColorValue = string;
|
|
40
|
+
export type Parser = (className: string) => StyleObject | null;
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});var _core=require("./core");Object.keys(_core).forEach(function(key){if(key==="default"||key==="__esModule")return;if(key in exports&&exports[key]===_core[key])return;Object.defineProperty(exports,key,{enumerable:true,get:function get(){return _core[key];}});});var _util=require("./util");Object.keys(_util).forEach(function(key){if(key==="default"||key==="__esModule")return;if(key in exports&&exports[key]===_util[key])return;Object.defineProperty(exports,key,{enumerable:true,get:function get(){return _util[key];}});});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ImageStyle, TextStyle, ViewStyle } from "react-native";
|
|
2
|
+
/**
|
|
3
|
+
* Union type for all React Native style types
|
|
4
|
+
*/
|
|
5
|
+
export type NativeStyle = ViewStyle | TextStyle | ImageStyle;
|
|
6
|
+
/**
|
|
7
|
+
* Return type for tw/twStyle functions with separate style properties for modifiers
|
|
8
|
+
*/
|
|
9
|
+
export type TwStyle<T extends NativeStyle = NativeStyle> = {
|
|
10
|
+
style: T;
|
|
11
|
+
activeStyle?: T;
|
|
12
|
+
focusStyle?: T;
|
|
13
|
+
disabledStyle?: T;
|
|
14
|
+
placeholderStyle?: TextStyle;
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});
|
|
File without changes
|
|
@@ -7,6 +7,7 @@ type NestedColors = {
|
|
|
7
7
|
/**
|
|
8
8
|
* Flatten nested color objects into flat key-value map
|
|
9
9
|
* Example: { brand: { light: '#fff', dark: '#000' } } => { 'brand-light': '#fff', 'brand-dark': '#000' }
|
|
10
|
+
* Special handling for DEFAULT: { primary: { DEFAULT: '#000', 500: '#333' } } => { 'primary': '#000', 'primary-500': '#333' }
|
|
10
11
|
*
|
|
11
12
|
* @param colors - Nested color object where values can be strings or objects
|
|
12
13
|
* @param prefix - Optional prefix for nested keys (used for recursion)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.flattenColors=flattenColors;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));function flattenColors(colors){var prefix=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"";var result={};for(var _ref of Object.entries(colors)){var _ref2=(0,_slicedToArray2.default)(_ref,2);var _key=_ref2[0];var value=_ref2[1];var newKey=prefix?`${prefix}-${_key}`:_key;if(typeof value==="string"){result[newKey]=value;}else if(typeof value==="object"&&value!==null){Object.assign(result,flattenColors(value,newKey));}}return result;}
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.flattenColors=flattenColors;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));function flattenColors(colors){var prefix=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"";var result={};for(var _ref of Object.entries(colors)){var _ref2=(0,_slicedToArray2.default)(_ref,2);var _key=_ref2[0];var value=_ref2[1];var newKey=_key==="DEFAULT"&&prefix?prefix:prefix?`${prefix}-${_key}`:_key;if(typeof value==="string"){result[newKey]=value;}else if(typeof value==="object"&&value!==null){Object.assign(result,flattenColors(value,newKey));}}return result;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var _vitest=require("vitest");var _flattenColors=require("./flattenColors");(0,_vitest.describe)("flattenColors",function(){(0,_vitest.it)("should handle flat color objects",function(){var colors={red:"#ff0000",blue:"#0000ff",green:"#00ff00"};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({red:"#ff0000",blue:"#0000ff",green:"#00ff00"});});(0,_vitest.it)("should flatten single-level nested objects",function(){var colors={brand:{primary:"#ff6b6b",secondary:"#4ecdc4"}};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({"brand-primary":"#ff6b6b","brand-secondary":"#4ecdc4"});});(0,_vitest.it)("should flatten multi-level nested objects",function(){var colors={brand:{light:{primary:"#ffcccc",secondary:"#ccffff"},dark:{primary:"#990000",secondary:"#006666"}}};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({"brand-light-primary":"#ffcccc","brand-light-secondary":"#ccffff","brand-dark-primary":"#990000","brand-dark-secondary":"#006666"});});(0,_vitest.it)("should handle mixed flat and nested objects",function(){var colors={white:"#ffffff",black:"#000000",brand:{primary:"#ff6b6b",secondary:"#4ecdc4"},accent:"#ffe66d"};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({white:"#ffffff",black:"#000000","brand-primary":"#ff6b6b","brand-secondary":"#4ecdc4",accent:"#ffe66d"});});(0,_vitest.it)("should handle Tailwind-style color scale objects",function(){var colors={gray:{"50":"#f9fafb","100":"#f3f4f6","200":"#e5e7eb","500":"#6b7280","900":"#111827"}};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({"gray-50":"#f9fafb","gray-100":"#f3f4f6","gray-200":"#e5e7eb","gray-500":"#6b7280","gray-900":"#111827"});});(0,_vitest.it)("should handle empty object",function(){(0,_vitest.expect)((0,_flattenColors.flattenColors)({})).toEqual({});});(0,_vitest.it)("should handle single color",function(){var colors={primary:"#ff0000"};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({primary:"#ff0000"});});(0,_vitest.it)("should handle deeply nested objects (3+ levels)",function(){var colors={theme:{light:{brand:{primary:"#ff6b6b",secondary:"#4ecdc4"}},dark:{brand:{primary:"#990000",secondary:"#006666"}}}};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({"theme-light-brand-primary":"#ff6b6b","theme-light-brand-secondary":"#4ecdc4","theme-dark-brand-primary":"#990000","theme-dark-brand-secondary":"#006666"});});(0,_vitest.it)("should handle numeric keys",function(){var colors={blue:{"100":"#dbeafe","500":"#3b82f6","900":"#1e3a8a"}};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({"blue-100":"#dbeafe","blue-500":"#3b82f6","blue-900":"#1e3a8a"});});(0,_vitest.it)("should handle keys with hyphens",function(){var colors={"brand-primary":"#ff0000","brand-secondary":{light:"#00ff00",dark:"#006600"}};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({"brand-primary":"#ff0000","brand-secondary-light":"#00ff00","brand-secondary-dark":"#006600"});});(0,_vitest.it)("should handle uppercase and lowercase hex values",function(){var colors={red:"#FF0000",blue:"#0000ff",green:"#00Ff00"};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({red:"#FF0000",blue:"#0000ff",green:"#00Ff00"});});(0,_vitest.it)("should handle 3-digit hex values",function(){var colors={red:"#f00",blue:"#00f",green:"#0f0"};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({red:"#f00",blue:"#00f",green:"#0f0"});});(0,_vitest.it)("should handle 8-digit hex values (with alpha)",function(){var colors={"red-50":"#ff000080","blue-50":"#0000ff80"};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({"red-50":"#ff000080","blue-50":"#0000ff80"});});(0,_vitest.it)("should handle complex real-world Tailwind config",function(){var colors={transparent:"transparent",current:"currentColor",white:"#ffffff",black:"#000000",gray:{"50":"#f9fafb","100":"#f3f4f6","500":"#6b7280","900":"#111827"},brand:{primary:"#ff6b6b",secondary:"#4ecdc4",accent:{light:"#ffe66d",dark:"#ffb900"}}};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({transparent:"transparent",current:"currentColor",white:"#ffffff",black:"#000000","gray-50":"#f9fafb","gray-100":"#f3f4f6","gray-500":"#6b7280","gray-900":"#111827","brand-primary":"#ff6b6b","brand-secondary":"#4ecdc4","brand-accent-light":"#ffe66d","brand-accent-dark":"#ffb900"});});(0,_vitest.it)("should not mutate input object",function(){var colors={brand:{primary:"#ff6b6b",secondary:"#4ecdc4"}};var original=JSON.parse(JSON.stringify(colors));(0,_flattenColors.flattenColors)(colors);(0,_vitest.expect)(colors).toEqual(original);});(0,_vitest.it)("should handle undefined values gracefully",function(){var colors={red:"#ff0000",blue:undefined,green:"#00ff00"};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({red:"#ff0000",green:"#00ff00"});});(0,_vitest.it)("should handle special color keywords",function(){var colors={transparent:"transparent",current:"currentColor",inherit:"inherit"};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({transparent:"transparent",current:"currentColor",inherit:"inherit"});});(0,_vitest.it)("should handle RGB/RGBA color values",function(){var colors={primary:"rgb(255, 0, 0)",secondary:"rgba(0, 255, 0, 0.5)"};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({primary:"rgb(255, 0, 0)",secondary:"rgba(0, 255, 0, 0.5)"});});(0,_vitest.it)("should handle very deeply nested structures (stress test)",function(){var colors={level1:{level2:{level3:{level4:{level5:"#ff0000"}}}}};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({"level1-level2-level3-level4-level5":"#ff0000"});});(0,_vitest.it)("should handle camelCase keys",function(){var colors={brandPrimary:"#ff0000",accentColor:{lightShade:"#ffcccc",darkShade:"#cc0000"}};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({brandPrimary:"#ff0000","accentColor-lightShade":"#ffcccc","accentColor-darkShade":"#cc0000"});});(0,_vitest.it)("should produce consistent output",function(){var colors={brand:{primary:"#ff6b6b",secondary:"#4ecdc4"}};var result1=(0,_flattenColors.flattenColors)(colors);var result2=(0,_flattenColors.flattenColors)(colors);var result3=(0,_flattenColors.flattenColors)(colors);(0,_vitest.expect)(result1).toEqual(result2);(0,_vitest.expect)(result2).toEqual(result3);});(0,_vitest.it)("should maintain key order (insertion order)",function(){var colors={z:"#000001",a:"#000002",m:"#000003"};var flattened=(0,_flattenColors.flattenColors)(colors);var keys=Object.keys(flattened);(0,_vitest.expect)(keys).toEqual(["z","a","m"]);});});
|
|
1
|
+
var _vitest=require("vitest");var _flattenColors=require("./flattenColors");(0,_vitest.describe)("flattenColors",function(){(0,_vitest.it)("should handle flat color objects",function(){var colors={red:"#ff0000",blue:"#0000ff",green:"#00ff00"};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({red:"#ff0000",blue:"#0000ff",green:"#00ff00"});});(0,_vitest.it)("should flatten single-level nested objects",function(){var colors={brand:{primary:"#ff6b6b",secondary:"#4ecdc4"}};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({"brand-primary":"#ff6b6b","brand-secondary":"#4ecdc4"});});(0,_vitest.it)("should flatten multi-level nested objects",function(){var colors={brand:{light:{primary:"#ffcccc",secondary:"#ccffff"},dark:{primary:"#990000",secondary:"#006666"}}};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({"brand-light-primary":"#ffcccc","brand-light-secondary":"#ccffff","brand-dark-primary":"#990000","brand-dark-secondary":"#006666"});});(0,_vitest.it)("should handle mixed flat and nested objects",function(){var colors={white:"#ffffff",black:"#000000",brand:{primary:"#ff6b6b",secondary:"#4ecdc4"},accent:"#ffe66d"};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({white:"#ffffff",black:"#000000","brand-primary":"#ff6b6b","brand-secondary":"#4ecdc4",accent:"#ffe66d"});});(0,_vitest.it)("should handle Tailwind-style color scale objects",function(){var colors={gray:{"50":"#f9fafb","100":"#f3f4f6","200":"#e5e7eb","500":"#6b7280","900":"#111827"}};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({"gray-50":"#f9fafb","gray-100":"#f3f4f6","gray-200":"#e5e7eb","gray-500":"#6b7280","gray-900":"#111827"});});(0,_vitest.it)("should handle empty object",function(){(0,_vitest.expect)((0,_flattenColors.flattenColors)({})).toEqual({});});(0,_vitest.it)("should handle single color",function(){var colors={primary:"#ff0000"};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({primary:"#ff0000"});});(0,_vitest.it)("should handle deeply nested objects (3+ levels)",function(){var colors={theme:{light:{brand:{primary:"#ff6b6b",secondary:"#4ecdc4"}},dark:{brand:{primary:"#990000",secondary:"#006666"}}}};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({"theme-light-brand-primary":"#ff6b6b","theme-light-brand-secondary":"#4ecdc4","theme-dark-brand-primary":"#990000","theme-dark-brand-secondary":"#006666"});});(0,_vitest.it)("should handle numeric keys",function(){var colors={blue:{"100":"#dbeafe","500":"#3b82f6","900":"#1e3a8a"}};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({"blue-100":"#dbeafe","blue-500":"#3b82f6","blue-900":"#1e3a8a"});});(0,_vitest.it)("should handle keys with hyphens",function(){var colors={"brand-primary":"#ff0000","brand-secondary":{light:"#00ff00",dark:"#006600"}};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({"brand-primary":"#ff0000","brand-secondary-light":"#00ff00","brand-secondary-dark":"#006600"});});(0,_vitest.it)("should handle uppercase and lowercase hex values",function(){var colors={red:"#FF0000",blue:"#0000ff",green:"#00Ff00"};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({red:"#FF0000",blue:"#0000ff",green:"#00Ff00"});});(0,_vitest.it)("should handle 3-digit hex values",function(){var colors={red:"#f00",blue:"#00f",green:"#0f0"};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({red:"#f00",blue:"#00f",green:"#0f0"});});(0,_vitest.it)("should handle 8-digit hex values (with alpha)",function(){var colors={"red-50":"#ff000080","blue-50":"#0000ff80"};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({"red-50":"#ff000080","blue-50":"#0000ff80"});});(0,_vitest.it)("should handle complex real-world Tailwind config",function(){var colors={transparent:"transparent",current:"currentColor",white:"#ffffff",black:"#000000",gray:{"50":"#f9fafb","100":"#f3f4f6","500":"#6b7280","900":"#111827"},brand:{primary:"#ff6b6b",secondary:"#4ecdc4",accent:{light:"#ffe66d",dark:"#ffb900"}}};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({transparent:"transparent",current:"currentColor",white:"#ffffff",black:"#000000","gray-50":"#f9fafb","gray-100":"#f3f4f6","gray-500":"#6b7280","gray-900":"#111827","brand-primary":"#ff6b6b","brand-secondary":"#4ecdc4","brand-accent-light":"#ffe66d","brand-accent-dark":"#ffb900"});});(0,_vitest.it)("should not mutate input object",function(){var colors={brand:{primary:"#ff6b6b",secondary:"#4ecdc4"}};var original=JSON.parse(JSON.stringify(colors));(0,_flattenColors.flattenColors)(colors);(0,_vitest.expect)(colors).toEqual(original);});(0,_vitest.it)("should handle undefined values gracefully",function(){var colors={red:"#ff0000",blue:undefined,green:"#00ff00"};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({red:"#ff0000",green:"#00ff00"});});(0,_vitest.it)("should handle special color keywords",function(){var colors={transparent:"transparent",current:"currentColor",inherit:"inherit"};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({transparent:"transparent",current:"currentColor",inherit:"inherit"});});(0,_vitest.it)("should handle RGB/RGBA color values",function(){var colors={primary:"rgb(255, 0, 0)",secondary:"rgba(0, 255, 0, 0.5)"};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({primary:"rgb(255, 0, 0)",secondary:"rgba(0, 255, 0, 0.5)"});});(0,_vitest.it)("should handle very deeply nested structures (stress test)",function(){var colors={level1:{level2:{level3:{level4:{level5:"#ff0000"}}}}};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({"level1-level2-level3-level4-level5":"#ff0000"});});(0,_vitest.it)("should handle camelCase keys",function(){var colors={brandPrimary:"#ff0000",accentColor:{lightShade:"#ffcccc",darkShade:"#cc0000"}};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({brandPrimary:"#ff0000","accentColor-lightShade":"#ffcccc","accentColor-darkShade":"#cc0000"});});(0,_vitest.it)("should produce consistent output",function(){var colors={brand:{primary:"#ff6b6b",secondary:"#4ecdc4"}};var result1=(0,_flattenColors.flattenColors)(colors);var result2=(0,_flattenColors.flattenColors)(colors);var result3=(0,_flattenColors.flattenColors)(colors);(0,_vitest.expect)(result1).toEqual(result2);(0,_vitest.expect)(result2).toEqual(result3);});(0,_vitest.it)("should maintain key order (insertion order)",function(){var colors={z:"#000001",a:"#000002",m:"#000003"};var flattened=(0,_flattenColors.flattenColors)(colors);var keys=Object.keys(flattened);(0,_vitest.expect)(keys).toEqual(["z","a","m"]);});(0,_vitest.it)("should handle DEFAULT key in color scale objects",function(){var colors={primary:{"50":"#eefdfd","100":"#d4f9f9","200":"#aef2f3","500":"#1bacb5","900":"#1e4f5b",DEFAULT:"#1bacb5"}};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({primary:"#1bacb5","primary-50":"#eefdfd","primary-100":"#d4f9f9","primary-200":"#aef2f3","primary-500":"#1bacb5","primary-900":"#1e4f5b"});});(0,_vitest.it)("should handle DEFAULT key with multiple color scales",function(){var colors={primary:{DEFAULT:"#1bacb5","500":"#1bacb5"},secondary:{DEFAULT:"#ff6b6b","500":"#ff6b6b"}};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({primary:"#1bacb5","primary-500":"#1bacb5",secondary:"#ff6b6b","secondary-500":"#ff6b6b"});});(0,_vitest.it)("should handle DEFAULT key in nested structures",function(){var colors={brand:{primary:{DEFAULT:"#1bacb5",light:"#d4f9f9",dark:"#0e343e"}}};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({"brand-primary":"#1bacb5","brand-primary-light":"#d4f9f9","brand-primary-dark":"#0e343e"});});(0,_vitest.it)("should handle DEFAULT at top level (edge case)",function(){var colors={DEFAULT:"#000000",primary:"#ff0000"};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({DEFAULT:"#000000",primary:"#ff0000"});});(0,_vitest.it)("should handle mixed DEFAULT and regular keys",function(){var colors={gray:{"50":"#f9fafb","100":"#f3f4f6",DEFAULT:"#6b7280","500":"#6b7280","900":"#111827"},white:"#ffffff",brand:{DEFAULT:"#ff6b6b",accent:"#4ecdc4"}};(0,_vitest.expect)((0,_flattenColors.flattenColors)(colors)).toEqual({"gray-50":"#f9fafb","gray-100":"#f3f4f6",gray:"#6b7280","gray-500":"#6b7280","gray-900":"#111827",white:"#ffffff",brand:"#ff6b6b","brand-accent":"#4ecdc4"});});});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mgcrea/react-native-tailwind",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "Compile-time Tailwind CSS for React Native with zero runtime overhead",
|
|
5
5
|
"author": "Olivier Louvignes <olivier@mgcrea.io> (https://github.com/mgcrea)",
|
|
6
6
|
"homepage": "https://github.com/mgcrea/react-native-tailwind#readme",
|