@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.
Files changed (92) hide show
  1. package/README.md +2 -1
  2. package/dist/babel/index.cjs +334 -196
  3. package/dist/babel/index.d.ts +4 -40
  4. package/dist/babel/index.test.ts +214 -1
  5. package/dist/babel/index.ts +4 -1169
  6. package/dist/babel/plugin.d.ts +42 -0
  7. package/{src/babel/index.test.ts → dist/babel/plugin.test.ts} +216 -2
  8. package/dist/babel/plugin.ts +491 -0
  9. package/dist/babel/utils/attributeMatchers.d.ts +23 -0
  10. package/dist/babel/utils/attributeMatchers.test.ts +294 -0
  11. package/dist/babel/utils/attributeMatchers.ts +71 -0
  12. package/dist/babel/utils/componentSupport.d.ts +18 -0
  13. package/dist/babel/utils/componentSupport.test.ts +426 -0
  14. package/dist/babel/utils/componentSupport.ts +68 -0
  15. package/dist/babel/utils/dynamicProcessing.d.ts +32 -0
  16. package/dist/babel/utils/dynamicProcessing.ts +223 -0
  17. package/dist/babel/utils/modifierProcessing.d.ts +26 -0
  18. package/dist/babel/utils/modifierProcessing.ts +118 -0
  19. package/dist/babel/utils/styleInjection.d.ts +15 -0
  20. package/dist/babel/utils/styleInjection.ts +80 -0
  21. package/dist/babel/utils/styleTransforms.d.ts +39 -0
  22. package/dist/babel/utils/styleTransforms.test.ts +349 -0
  23. package/dist/babel/utils/styleTransforms.ts +258 -0
  24. package/dist/babel/utils/twProcessing.d.ts +28 -0
  25. package/dist/babel/utils/twProcessing.ts +124 -0
  26. package/dist/components/TextInput.d.ts +171 -14
  27. package/dist/config/tailwind.d.ts +302 -0
  28. package/dist/config/tailwind.js +1 -0
  29. package/dist/index.d.ts +5 -4
  30. package/dist/index.js +1 -1
  31. package/dist/parser/colors.js +1 -1
  32. package/dist/parser/colors.test.js +1 -1
  33. package/dist/parser/index.d.ts +1 -0
  34. package/dist/parser/index.js +1 -1
  35. package/dist/parser/modifiers.d.ts +2 -2
  36. package/dist/parser/modifiers.js +1 -1
  37. package/dist/parser/placeholder.d.ts +36 -0
  38. package/dist/parser/placeholder.js +1 -0
  39. package/dist/parser/placeholder.test.js +1 -0
  40. package/dist/parser/typography.d.ts +1 -0
  41. package/dist/parser/typography.js +1 -1
  42. package/dist/parser/typography.test.js +1 -1
  43. package/dist/runtime.cjs +1 -1
  44. package/dist/runtime.cjs.map +4 -4
  45. package/dist/runtime.d.ts +1 -14
  46. package/dist/runtime.js +1 -1
  47. package/dist/runtime.js.map +4 -4
  48. package/dist/stubs/tw.d.ts +1 -14
  49. package/dist/types/core.d.ts +40 -0
  50. package/dist/types/core.js +0 -0
  51. package/dist/types/index.d.ts +2 -0
  52. package/dist/types/index.js +1 -0
  53. package/dist/types/runtime.d.ts +15 -0
  54. package/dist/types/runtime.js +1 -0
  55. package/dist/types/util.d.ts +3 -0
  56. package/dist/types/util.js +0 -0
  57. package/dist/utils/flattenColors.d.ts +1 -0
  58. package/dist/utils/flattenColors.js +1 -1
  59. package/dist/utils/flattenColors.test.js +1 -1
  60. package/package.json +1 -1
  61. package/src/babel/index.ts +4 -1169
  62. package/src/babel/plugin.test.ts +482 -0
  63. package/src/babel/plugin.ts +491 -0
  64. package/src/babel/utils/attributeMatchers.test.ts +294 -0
  65. package/src/babel/utils/attributeMatchers.ts +71 -0
  66. package/src/babel/utils/componentSupport.test.ts +426 -0
  67. package/src/babel/utils/componentSupport.ts +68 -0
  68. package/src/babel/utils/dynamicProcessing.ts +223 -0
  69. package/src/babel/utils/modifierProcessing.ts +118 -0
  70. package/src/babel/utils/styleInjection.ts +80 -0
  71. package/src/babel/utils/styleTransforms.test.ts +349 -0
  72. package/src/babel/utils/styleTransforms.ts +258 -0
  73. package/src/babel/utils/twProcessing.ts +124 -0
  74. package/src/components/TextInput.tsx +17 -14
  75. package/src/config/{palettes.ts → tailwind.ts} +2 -2
  76. package/src/index.ts +6 -3
  77. package/src/parser/colors.test.ts +32 -0
  78. package/src/parser/colors.ts +2 -2
  79. package/src/parser/index.ts +2 -1
  80. package/src/parser/modifiers.ts +10 -4
  81. package/src/parser/placeholder.test.ts +105 -0
  82. package/src/parser/placeholder.ts +78 -0
  83. package/src/parser/typography.test.ts +11 -0
  84. package/src/parser/typography.ts +20 -2
  85. package/src/runtime.ts +1 -16
  86. package/src/stubs/tw.ts +1 -16
  87. package/src/{types.ts → types/core.ts} +0 -4
  88. package/src/types/index.ts +2 -0
  89. package/src/types/runtime.ts +17 -0
  90. package/src/types/util.ts +1 -0
  91. package/src/utils/flattenColors.test.ts +100 -0
  92. package/src/utils/flattenColors.ts +3 -1
@@ -358,4 +358,104 @@ describe("flattenColors", () => {
358
358
 
359
359
  expect(keys).toEqual(["z", "a", "m"]);
360
360
  });
361
+
362
+ it("should handle DEFAULT key in color scale objects", () => {
363
+ const colors = {
364
+ primary: {
365
+ "50": "#eefdfd",
366
+ "100": "#d4f9f9",
367
+ "200": "#aef2f3",
368
+ "500": "#1bacb5",
369
+ "900": "#1e4f5b",
370
+ DEFAULT: "#1bacb5",
371
+ },
372
+ };
373
+
374
+ expect(flattenColors(colors)).toEqual({
375
+ primary: "#1bacb5", // DEFAULT becomes the parent key
376
+ "primary-50": "#eefdfd",
377
+ "primary-100": "#d4f9f9",
378
+ "primary-200": "#aef2f3",
379
+ "primary-500": "#1bacb5",
380
+ "primary-900": "#1e4f5b",
381
+ });
382
+ });
383
+
384
+ it("should handle DEFAULT key with multiple color scales", () => {
385
+ const colors = {
386
+ primary: {
387
+ DEFAULT: "#1bacb5",
388
+ "500": "#1bacb5",
389
+ },
390
+ secondary: {
391
+ DEFAULT: "#ff6b6b",
392
+ "500": "#ff6b6b",
393
+ },
394
+ };
395
+
396
+ expect(flattenColors(colors)).toEqual({
397
+ primary: "#1bacb5",
398
+ "primary-500": "#1bacb5",
399
+ secondary: "#ff6b6b",
400
+ "secondary-500": "#ff6b6b",
401
+ });
402
+ });
403
+
404
+ it("should handle DEFAULT key in nested structures", () => {
405
+ const colors = {
406
+ brand: {
407
+ primary: {
408
+ DEFAULT: "#1bacb5",
409
+ light: "#d4f9f9",
410
+ dark: "#0e343e",
411
+ },
412
+ },
413
+ };
414
+
415
+ expect(flattenColors(colors)).toEqual({
416
+ "brand-primary": "#1bacb5", // DEFAULT uses parent key
417
+ "brand-primary-light": "#d4f9f9",
418
+ "brand-primary-dark": "#0e343e",
419
+ });
420
+ });
421
+
422
+ it("should handle DEFAULT at top level (edge case)", () => {
423
+ const colors = {
424
+ DEFAULT: "#000000",
425
+ primary: "#ff0000",
426
+ };
427
+
428
+ expect(flattenColors(colors)).toEqual({
429
+ DEFAULT: "#000000", // Top-level DEFAULT kept as-is (no parent)
430
+ primary: "#ff0000",
431
+ });
432
+ });
433
+
434
+ it("should handle mixed DEFAULT and regular keys", () => {
435
+ const colors = {
436
+ gray: {
437
+ "50": "#f9fafb",
438
+ "100": "#f3f4f6",
439
+ DEFAULT: "#6b7280",
440
+ "500": "#6b7280",
441
+ "900": "#111827",
442
+ },
443
+ white: "#ffffff",
444
+ brand: {
445
+ DEFAULT: "#ff6b6b",
446
+ accent: "#4ecdc4",
447
+ },
448
+ };
449
+
450
+ expect(flattenColors(colors)).toEqual({
451
+ "gray-50": "#f9fafb",
452
+ "gray-100": "#f3f4f6",
453
+ gray: "#6b7280", // DEFAULT becomes parent key
454
+ "gray-500": "#6b7280",
455
+ "gray-900": "#111827",
456
+ white: "#ffffff",
457
+ brand: "#ff6b6b", // DEFAULT becomes parent key
458
+ "brand-accent": "#4ecdc4",
459
+ });
460
+ });
361
461
  });
@@ -8,6 +8,7 @@ type NestedColors = {
8
8
  /**
9
9
  * Flatten nested color objects into flat key-value map
10
10
  * Example: { brand: { light: '#fff', dark: '#000' } } => { 'brand-light': '#fff', 'brand-dark': '#000' }
11
+ * Special handling for DEFAULT: { primary: { DEFAULT: '#000', 500: '#333' } } => { 'primary': '#000', 'primary-500': '#333' }
11
12
  *
12
13
  * @param colors - Nested color object where values can be strings or objects
13
14
  * @param prefix - Optional prefix for nested keys (used for recursion)
@@ -17,7 +18,8 @@ export function flattenColors(colors: NestedColors, prefix = ""): Record<string,
17
18
  const result: Record<string, string> = {};
18
19
 
19
20
  for (const [key, value] of Object.entries(colors)) {
20
- const newKey = prefix ? `${prefix}-${key}` : key;
21
+ // Special handling for DEFAULT key - use parent key without suffix
22
+ const newKey = key === "DEFAULT" && prefix ? prefix : prefix ? `${prefix}-${key}` : key;
21
23
 
22
24
  if (typeof value === "string") {
23
25
  result[newKey] = value;