@mgcrea/react-native-tailwind 0.5.2 → 0.6.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 +141 -10
- package/dist/babel/index.cjs +625 -111
- package/dist/components/Pressable.d.ts +2 -0
- package/dist/components/TextInput.d.ts +2 -0
- package/dist/config/palettes.d.ts +302 -0
- package/dist/config/palettes.js +1 -0
- 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/layout.js +1 -1
- package/dist/parser/layout.test.js +1 -1
- package/dist/parser/transforms.d.ts +13 -0
- package/dist/parser/transforms.js +1 -0
- package/dist/parser/transforms.test.js +1 -0
- package/dist/parser/typography.js +1 -1
- package/dist/parser/typography.test.js +1 -1
- package/dist/types.d.ts +32 -2
- package/package.json +1 -1
- package/src/components/Pressable.tsx +1 -0
- package/src/components/TextInput.tsx +1 -0
- package/src/config/palettes.ts +304 -0
- package/src/parser/colors.test.ts +57 -31
- package/src/parser/colors.ts +34 -111
- package/src/parser/index.ts +3 -0
- package/src/parser/layout.test.ts +35 -0
- package/src/parser/layout.ts +26 -0
- package/src/parser/transforms.test.ts +318 -0
- package/src/parser/transforms.ts +406 -0
- package/src/parser/typography.test.ts +12 -0
- package/src/parser/typography.ts +8 -0
- package/src/types.ts +22 -1
package/dist/babel/index.cjs
CHANGED
|
@@ -258,112 +258,310 @@ function parseBorderRadius(cls) {
|
|
|
258
258
|
return null;
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
-
// src/
|
|
262
|
-
var
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
261
|
+
// src/config/palettes.ts
|
|
262
|
+
var TAILWIND_PALETTES = {
|
|
263
|
+
red: {
|
|
264
|
+
"50": "#fef2f2",
|
|
265
|
+
"100": "#ffe2e2",
|
|
266
|
+
"200": "#ffc9c9",
|
|
267
|
+
"300": "#ffa2a2",
|
|
268
|
+
"400": "#ff6467",
|
|
269
|
+
"500": "#fb2c36",
|
|
270
|
+
"600": "#e7000b",
|
|
271
|
+
"700": "#c10007",
|
|
272
|
+
"800": "#9f0712",
|
|
273
|
+
"900": "#82181a",
|
|
274
|
+
"950": "#460809"
|
|
275
|
+
},
|
|
276
|
+
orange: {
|
|
277
|
+
"50": "#fff7ed",
|
|
278
|
+
"100": "#ffedd4",
|
|
279
|
+
"200": "#ffd6a7",
|
|
280
|
+
"300": "#ffb86a",
|
|
281
|
+
"400": "#ff8904",
|
|
282
|
+
"500": "#ff6900",
|
|
283
|
+
"600": "#f54900",
|
|
284
|
+
"700": "#ca3500",
|
|
285
|
+
"800": "#9f2d00",
|
|
286
|
+
"900": "#7e2a0c",
|
|
287
|
+
"950": "#441306"
|
|
288
|
+
},
|
|
289
|
+
amber: {
|
|
290
|
+
"50": "#fffbeb",
|
|
291
|
+
"100": "#fef3c6",
|
|
292
|
+
"200": "#fee685",
|
|
293
|
+
"300": "#ffd230",
|
|
294
|
+
"400": "#ffb900",
|
|
295
|
+
"500": "#fe9a00",
|
|
296
|
+
"600": "#e17100",
|
|
297
|
+
"700": "#bb4d00",
|
|
298
|
+
"800": "#973c00",
|
|
299
|
+
"900": "#7b3306",
|
|
300
|
+
"950": "#461901"
|
|
301
|
+
},
|
|
302
|
+
yellow: {
|
|
303
|
+
"50": "#fefce8",
|
|
304
|
+
"100": "#fef9c2",
|
|
305
|
+
"200": "#fff085",
|
|
306
|
+
"300": "#ffdf20",
|
|
307
|
+
"400": "#fdc700",
|
|
308
|
+
"500": "#f0b100",
|
|
309
|
+
"600": "#d08700",
|
|
310
|
+
"700": "#a65f00",
|
|
311
|
+
"800": "#894b00",
|
|
312
|
+
"900": "#733e0a",
|
|
313
|
+
"950": "#432004"
|
|
314
|
+
},
|
|
315
|
+
lime: {
|
|
316
|
+
"50": "#f7fee7",
|
|
317
|
+
"100": "#ecfcca",
|
|
318
|
+
"200": "#d8f999",
|
|
319
|
+
"300": "#bbf451",
|
|
320
|
+
"400": "#9ae600",
|
|
321
|
+
"500": "#7ccf00",
|
|
322
|
+
"600": "#5ea500",
|
|
323
|
+
"700": "#497d00",
|
|
324
|
+
"800": "#3c6300",
|
|
325
|
+
"900": "#35530e",
|
|
326
|
+
"950": "#192e03"
|
|
327
|
+
},
|
|
328
|
+
green: {
|
|
329
|
+
"50": "#f0fdf4",
|
|
330
|
+
"100": "#dcfce7",
|
|
331
|
+
"200": "#b9f8cf",
|
|
332
|
+
"300": "#7bf1a8",
|
|
333
|
+
"400": "#05df72",
|
|
334
|
+
"500": "#00c950",
|
|
335
|
+
"600": "#00a63e",
|
|
336
|
+
"700": "#008236",
|
|
337
|
+
"800": "#016630",
|
|
338
|
+
"900": "#0d542b",
|
|
339
|
+
"950": "#032e15"
|
|
340
|
+
},
|
|
341
|
+
emerald: {
|
|
342
|
+
"50": "#ecfdf5",
|
|
343
|
+
"100": "#d0fae5",
|
|
344
|
+
"200": "#a4f4cf",
|
|
345
|
+
"300": "#5ee9b5",
|
|
346
|
+
"400": "#00d492",
|
|
347
|
+
"500": "#00bc7d",
|
|
348
|
+
"600": "#009966",
|
|
349
|
+
"700": "#007a55",
|
|
350
|
+
"800": "#006045",
|
|
351
|
+
"900": "#004f3b",
|
|
352
|
+
"950": "#002c22"
|
|
353
|
+
},
|
|
354
|
+
teal: {
|
|
355
|
+
"50": "#f0fdfa",
|
|
356
|
+
"100": "#cbfbf1",
|
|
357
|
+
"200": "#96f7e4",
|
|
358
|
+
"300": "#46ecd5",
|
|
359
|
+
"400": "#00d5be",
|
|
360
|
+
"500": "#00bba7",
|
|
361
|
+
"600": "#009689",
|
|
362
|
+
"700": "#00786f",
|
|
363
|
+
"800": "#005f5a",
|
|
364
|
+
"900": "#0b4f4a",
|
|
365
|
+
"950": "#022f2e"
|
|
366
|
+
},
|
|
367
|
+
cyan: {
|
|
368
|
+
"50": "#ecfeff",
|
|
369
|
+
"100": "#cefafe",
|
|
370
|
+
"200": "#a2f4fd",
|
|
371
|
+
"300": "#53eafd",
|
|
372
|
+
"400": "#00d3f2",
|
|
373
|
+
"500": "#00b8db",
|
|
374
|
+
"600": "#0092b8",
|
|
375
|
+
"700": "#007595",
|
|
376
|
+
"800": "#005f78",
|
|
377
|
+
"900": "#104e64",
|
|
378
|
+
"950": "#053345"
|
|
379
|
+
},
|
|
380
|
+
sky: {
|
|
381
|
+
"50": "#f0f9ff",
|
|
382
|
+
"100": "#dff2fe",
|
|
383
|
+
"200": "#b8e6fe",
|
|
384
|
+
"300": "#74d4ff",
|
|
385
|
+
"400": "#00bcff",
|
|
386
|
+
"500": "#00a6f4",
|
|
387
|
+
"600": "#0084d1",
|
|
388
|
+
"700": "#0069a8",
|
|
389
|
+
"800": "#00598a",
|
|
390
|
+
"900": "#024a70",
|
|
391
|
+
"950": "#052f4a"
|
|
392
|
+
},
|
|
393
|
+
blue: {
|
|
394
|
+
"50": "#eff6ff",
|
|
395
|
+
"100": "#dbeafe",
|
|
396
|
+
"200": "#bedbff",
|
|
397
|
+
"300": "#8ec5ff",
|
|
398
|
+
"400": "#51a2ff",
|
|
399
|
+
"500": "#2b7fff",
|
|
400
|
+
"600": "#155dfc",
|
|
401
|
+
"700": "#1447e6",
|
|
402
|
+
"800": "#193cb8",
|
|
403
|
+
"900": "#1c398e",
|
|
404
|
+
"950": "#162456"
|
|
405
|
+
},
|
|
406
|
+
indigo: {
|
|
407
|
+
"50": "#eef2ff",
|
|
408
|
+
"100": "#e0e7ff",
|
|
409
|
+
"200": "#c6d2ff",
|
|
410
|
+
"300": "#a3b3ff",
|
|
411
|
+
"400": "#7c86ff",
|
|
412
|
+
"500": "#615fff",
|
|
413
|
+
"600": "#4f39f6",
|
|
414
|
+
"700": "#432dd7",
|
|
415
|
+
"800": "#372aac",
|
|
416
|
+
"900": "#312c85",
|
|
417
|
+
"950": "#1e1a4d"
|
|
418
|
+
},
|
|
419
|
+
violet: {
|
|
420
|
+
"50": "#f5f3ff",
|
|
421
|
+
"100": "#ede9fe",
|
|
422
|
+
"200": "#ddd6ff",
|
|
423
|
+
"300": "#c4b4ff",
|
|
424
|
+
"400": "#a684ff",
|
|
425
|
+
"500": "#8e51ff",
|
|
426
|
+
"600": "#7f22fe",
|
|
427
|
+
"700": "#7008e7",
|
|
428
|
+
"800": "#5d0ec0",
|
|
429
|
+
"900": "#4d179a",
|
|
430
|
+
"950": "#2f0d68"
|
|
431
|
+
},
|
|
432
|
+
purple: {
|
|
433
|
+
"50": "#faf5ff",
|
|
434
|
+
"100": "#f3e8ff",
|
|
435
|
+
"200": "#e9d4ff",
|
|
436
|
+
"300": "#dab2ff",
|
|
437
|
+
"400": "#c27aff",
|
|
438
|
+
"500": "#ad46ff",
|
|
439
|
+
"600": "#9810fa",
|
|
440
|
+
"700": "#8200db",
|
|
441
|
+
"800": "#6e11b0",
|
|
442
|
+
"900": "#59168b",
|
|
443
|
+
"950": "#3c0366"
|
|
444
|
+
},
|
|
445
|
+
fuchsia: {
|
|
446
|
+
"50": "#fdf4ff",
|
|
447
|
+
"100": "#fae8ff",
|
|
448
|
+
"200": "#f6cfff",
|
|
449
|
+
"300": "#f4a8ff",
|
|
450
|
+
"400": "#ed6aff",
|
|
451
|
+
"500": "#e12afb",
|
|
452
|
+
"600": "#c800de",
|
|
453
|
+
"700": "#a800b7",
|
|
454
|
+
"800": "#8a0194",
|
|
455
|
+
"900": "#721378",
|
|
456
|
+
"950": "#4b004f"
|
|
457
|
+
},
|
|
458
|
+
pink: {
|
|
459
|
+
"50": "#fdf2f8",
|
|
460
|
+
"100": "#fce7f3",
|
|
461
|
+
"200": "#fccee8",
|
|
462
|
+
"300": "#fda5d5",
|
|
463
|
+
"400": "#fb64b6",
|
|
464
|
+
"500": "#f6339a",
|
|
465
|
+
"600": "#e60076",
|
|
466
|
+
"700": "#c6005c",
|
|
467
|
+
"800": "#a3004c",
|
|
468
|
+
"900": "#861043",
|
|
469
|
+
"950": "#510424"
|
|
470
|
+
},
|
|
471
|
+
rose: {
|
|
472
|
+
"50": "#fff1f2",
|
|
473
|
+
"100": "#ffe4e6",
|
|
474
|
+
"200": "#ffccd3",
|
|
475
|
+
"300": "#ffa1ad",
|
|
476
|
+
"400": "#ff637e",
|
|
477
|
+
"500": "#ff2056",
|
|
478
|
+
"600": "#ec003f",
|
|
479
|
+
"700": "#c70036",
|
|
480
|
+
"800": "#a50036",
|
|
481
|
+
"900": "#8b0836",
|
|
482
|
+
"950": "#4d0218"
|
|
483
|
+
},
|
|
484
|
+
slate: {
|
|
485
|
+
"50": "#f8fafc",
|
|
486
|
+
"100": "#f1f5f9",
|
|
487
|
+
"200": "#e2e8f0",
|
|
488
|
+
"300": "#cad5e2",
|
|
489
|
+
"400": "#90a1b9",
|
|
490
|
+
"500": "#62748e",
|
|
491
|
+
"600": "#45556c",
|
|
492
|
+
"700": "#314158",
|
|
493
|
+
"800": "#1d293d",
|
|
494
|
+
"900": "#0f172b",
|
|
495
|
+
"950": "#020618"
|
|
496
|
+
},
|
|
497
|
+
gray: {
|
|
498
|
+
"50": "#f9fafb",
|
|
499
|
+
"100": "#f3f4f6",
|
|
500
|
+
"200": "#e5e7eb",
|
|
501
|
+
"300": "#d1d5dc",
|
|
502
|
+
"400": "#99a1af",
|
|
503
|
+
"500": "#6a7282",
|
|
504
|
+
"600": "#4a5565",
|
|
505
|
+
"700": "#364153",
|
|
506
|
+
"800": "#1e2939",
|
|
507
|
+
"900": "#101828",
|
|
508
|
+
"950": "#030712"
|
|
509
|
+
},
|
|
510
|
+
zinc: {
|
|
511
|
+
"50": "#fafafa",
|
|
512
|
+
"100": "#f4f4f5",
|
|
513
|
+
"200": "#e4e4e7",
|
|
514
|
+
"300": "#d4d4d8",
|
|
515
|
+
"400": "#9f9fa9",
|
|
516
|
+
"500": "#71717b",
|
|
517
|
+
"600": "#52525c",
|
|
518
|
+
"700": "#3f3f46",
|
|
519
|
+
"800": "#27272a",
|
|
520
|
+
"900": "#18181b",
|
|
521
|
+
"950": "#09090b"
|
|
522
|
+
},
|
|
523
|
+
neutral: {
|
|
524
|
+
"50": "#fafafa",
|
|
525
|
+
"100": "#f5f5f5",
|
|
526
|
+
"200": "#e5e5e5",
|
|
527
|
+
"300": "#d4d4d4",
|
|
528
|
+
"400": "#a1a1a1",
|
|
529
|
+
"500": "#737373",
|
|
530
|
+
"600": "#525252",
|
|
531
|
+
"700": "#404040",
|
|
532
|
+
"800": "#262626",
|
|
533
|
+
"900": "#171717",
|
|
534
|
+
"950": "#0a0a0a"
|
|
535
|
+
},
|
|
536
|
+
stone: {
|
|
537
|
+
"50": "#fafaf9",
|
|
538
|
+
"100": "#f5f5f4",
|
|
539
|
+
"200": "#e7e5e4",
|
|
540
|
+
"300": "#d6d3d1",
|
|
541
|
+
"400": "#a6a09b",
|
|
542
|
+
"500": "#79716b",
|
|
543
|
+
"600": "#57534d",
|
|
544
|
+
"700": "#44403b",
|
|
545
|
+
"800": "#292524",
|
|
546
|
+
"900": "#1c1917",
|
|
547
|
+
"950": "#0c0a09"
|
|
548
|
+
}
|
|
366
549
|
};
|
|
550
|
+
|
|
551
|
+
// src/parser/colors.ts
|
|
552
|
+
function flattenColors() {
|
|
553
|
+
const flat = {};
|
|
554
|
+
for (const [colorName, shades] of Object.entries(TAILWIND_PALETTES)) {
|
|
555
|
+
for (const [shade, hex] of Object.entries(shades)) {
|
|
556
|
+
flat[`${colorName}-${shade}`] = hex;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
flat.white = "#FFFFFF";
|
|
560
|
+
flat.black = "#000000";
|
|
561
|
+
flat.transparent = "transparent";
|
|
562
|
+
return flat;
|
|
563
|
+
}
|
|
564
|
+
var COLORS = flattenColors();
|
|
367
565
|
function applyOpacity(hex, opacity) {
|
|
368
566
|
if (hex === "transparent") {
|
|
369
567
|
return "transparent";
|
|
@@ -429,6 +627,9 @@ function parseColor(cls, customColors) {
|
|
|
429
627
|
};
|
|
430
628
|
if (cls.startsWith("bg-")) {
|
|
431
629
|
const colorKey = cls.substring(3);
|
|
630
|
+
if (colorKey.startsWith("[") && !colorKey.startsWith("[#")) {
|
|
631
|
+
return null;
|
|
632
|
+
}
|
|
432
633
|
const color = parseColorWithOpacity(colorKey);
|
|
433
634
|
if (color) {
|
|
434
635
|
return { backgroundColor: color };
|
|
@@ -436,6 +637,9 @@ function parseColor(cls, customColors) {
|
|
|
436
637
|
}
|
|
437
638
|
if (cls.startsWith("text-")) {
|
|
438
639
|
const colorKey = cls.substring(5);
|
|
640
|
+
if (colorKey.startsWith("[") && !colorKey.startsWith("[#")) {
|
|
641
|
+
return null;
|
|
642
|
+
}
|
|
439
643
|
const color = parseColorWithOpacity(colorKey);
|
|
440
644
|
if (color) {
|
|
441
645
|
return { color };
|
|
@@ -443,6 +647,9 @@ function parseColor(cls, customColors) {
|
|
|
443
647
|
}
|
|
444
648
|
if (cls.startsWith("border-") && !cls.match(/^border-[0-9]/)) {
|
|
445
649
|
const colorKey = cls.substring(7);
|
|
650
|
+
if (colorKey.startsWith("[") && !colorKey.startsWith("[#")) {
|
|
651
|
+
return null;
|
|
652
|
+
}
|
|
446
653
|
const color = parseColorWithOpacity(colorKey);
|
|
447
654
|
if (color) {
|
|
448
655
|
return { borderColor: color };
|
|
@@ -552,6 +759,29 @@ var OVERFLOW_MAP = {
|
|
|
552
759
|
"overflow-visible": { overflow: "visible" },
|
|
553
760
|
"overflow-scroll": { overflow: "scroll" }
|
|
554
761
|
};
|
|
762
|
+
var OPACITY_MAP = {
|
|
763
|
+
"opacity-0": { opacity: 0 },
|
|
764
|
+
"opacity-5": { opacity: 0.05 },
|
|
765
|
+
"opacity-10": { opacity: 0.1 },
|
|
766
|
+
"opacity-15": { opacity: 0.15 },
|
|
767
|
+
"opacity-20": { opacity: 0.2 },
|
|
768
|
+
"opacity-25": { opacity: 0.25 },
|
|
769
|
+
"opacity-30": { opacity: 0.3 },
|
|
770
|
+
"opacity-35": { opacity: 0.35 },
|
|
771
|
+
"opacity-40": { opacity: 0.4 },
|
|
772
|
+
"opacity-45": { opacity: 0.45 },
|
|
773
|
+
"opacity-50": { opacity: 0.5 },
|
|
774
|
+
"opacity-55": { opacity: 0.55 },
|
|
775
|
+
"opacity-60": { opacity: 0.6 },
|
|
776
|
+
"opacity-65": { opacity: 0.65 },
|
|
777
|
+
"opacity-70": { opacity: 0.7 },
|
|
778
|
+
"opacity-75": { opacity: 0.75 },
|
|
779
|
+
"opacity-80": { opacity: 0.8 },
|
|
780
|
+
"opacity-85": { opacity: 0.85 },
|
|
781
|
+
"opacity-90": { opacity: 0.9 },
|
|
782
|
+
"opacity-95": { opacity: 0.95 },
|
|
783
|
+
"opacity-100": { opacity: 1 }
|
|
784
|
+
};
|
|
555
785
|
var Z_INDEX_SCALE = {
|
|
556
786
|
0: 0,
|
|
557
787
|
10: 10,
|
|
@@ -682,7 +912,7 @@ function parseLayout(cls) {
|
|
|
682
912
|
return { top: insetValue, right: insetValue, bottom: insetValue, left: insetValue };
|
|
683
913
|
}
|
|
684
914
|
}
|
|
685
|
-
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] ?? null;
|
|
915
|
+
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;
|
|
686
916
|
}
|
|
687
917
|
|
|
688
918
|
// src/parser/shadows.ts
|
|
@@ -1050,6 +1280,284 @@ function getPaddingStyle(dir, value) {
|
|
|
1050
1280
|
}
|
|
1051
1281
|
}
|
|
1052
1282
|
|
|
1283
|
+
// src/parser/transforms.ts
|
|
1284
|
+
var SCALE_MAP = {
|
|
1285
|
+
0: 0,
|
|
1286
|
+
50: 0.5,
|
|
1287
|
+
75: 0.75,
|
|
1288
|
+
90: 0.9,
|
|
1289
|
+
95: 0.95,
|
|
1290
|
+
100: 1,
|
|
1291
|
+
105: 1.05,
|
|
1292
|
+
110: 1.1,
|
|
1293
|
+
125: 1.25,
|
|
1294
|
+
150: 1.5,
|
|
1295
|
+
200: 2
|
|
1296
|
+
};
|
|
1297
|
+
var ROTATE_MAP = {
|
|
1298
|
+
0: 0,
|
|
1299
|
+
1: 1,
|
|
1300
|
+
2: 2,
|
|
1301
|
+
3: 3,
|
|
1302
|
+
6: 6,
|
|
1303
|
+
12: 12,
|
|
1304
|
+
45: 45,
|
|
1305
|
+
90: 90,
|
|
1306
|
+
180: 180
|
|
1307
|
+
};
|
|
1308
|
+
var SKEW_MAP = {
|
|
1309
|
+
0: 0,
|
|
1310
|
+
1: 1,
|
|
1311
|
+
2: 2,
|
|
1312
|
+
3: 3,
|
|
1313
|
+
6: 6,
|
|
1314
|
+
12: 12
|
|
1315
|
+
};
|
|
1316
|
+
var PERSPECTIVE_SCALE = {
|
|
1317
|
+
0: 0,
|
|
1318
|
+
100: 100,
|
|
1319
|
+
200: 200,
|
|
1320
|
+
300: 300,
|
|
1321
|
+
400: 400,
|
|
1322
|
+
500: 500,
|
|
1323
|
+
600: 600,
|
|
1324
|
+
700: 700,
|
|
1325
|
+
800: 800,
|
|
1326
|
+
900: 900,
|
|
1327
|
+
1e3: 1e3
|
|
1328
|
+
};
|
|
1329
|
+
function parseArbitraryScale(value) {
|
|
1330
|
+
const scaleMatch = value.match(/^\[(-?\d+(?:\.\d+)?)\]$/);
|
|
1331
|
+
if (scaleMatch) {
|
|
1332
|
+
return parseFloat(scaleMatch[1]);
|
|
1333
|
+
}
|
|
1334
|
+
if (value.startsWith("[") && value.endsWith("]")) {
|
|
1335
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1336
|
+
console.warn(
|
|
1337
|
+
`[react-native-tailwind] Invalid arbitrary scale value: ${value}. Only numbers are supported (e.g., [1.5], [0.75]).`
|
|
1338
|
+
);
|
|
1339
|
+
}
|
|
1340
|
+
return null;
|
|
1341
|
+
}
|
|
1342
|
+
return null;
|
|
1343
|
+
}
|
|
1344
|
+
function parseArbitraryRotation(value) {
|
|
1345
|
+
const rotateMatch = value.match(/^\[(-?\d+(?:\.\d+)?)deg\]$/);
|
|
1346
|
+
if (rotateMatch) {
|
|
1347
|
+
return `${rotateMatch[1]}deg`;
|
|
1348
|
+
}
|
|
1349
|
+
if (value.startsWith("[") && value.endsWith("]")) {
|
|
1350
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1351
|
+
console.warn(
|
|
1352
|
+
`[react-native-tailwind] Invalid arbitrary rotation value: ${value}. Only deg unit is supported (e.g., [45deg], [-15deg]).`
|
|
1353
|
+
);
|
|
1354
|
+
}
|
|
1355
|
+
return null;
|
|
1356
|
+
}
|
|
1357
|
+
return null;
|
|
1358
|
+
}
|
|
1359
|
+
function parseArbitraryTranslation(value) {
|
|
1360
|
+
const pxMatch = value.match(/^\[(-?\d+)(?:px)?\]$/);
|
|
1361
|
+
if (pxMatch) {
|
|
1362
|
+
return parseInt(pxMatch[1], 10);
|
|
1363
|
+
}
|
|
1364
|
+
const percentMatch = value.match(/^\[(-?\d+(?:\.\d+)?)%\]$/);
|
|
1365
|
+
if (percentMatch) {
|
|
1366
|
+
return `${percentMatch[1]}%`;
|
|
1367
|
+
}
|
|
1368
|
+
if (value.startsWith("[") && value.endsWith("]")) {
|
|
1369
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1370
|
+
console.warn(
|
|
1371
|
+
`[react-native-tailwind] Unsupported arbitrary translation unit: ${value}. Only px and % are supported.`
|
|
1372
|
+
);
|
|
1373
|
+
}
|
|
1374
|
+
return null;
|
|
1375
|
+
}
|
|
1376
|
+
return null;
|
|
1377
|
+
}
|
|
1378
|
+
function parseArbitraryPerspective(value) {
|
|
1379
|
+
const perspectiveMatch = value.match(/^\[(-?\d+)\]$/);
|
|
1380
|
+
if (perspectiveMatch) {
|
|
1381
|
+
return parseInt(perspectiveMatch[1], 10);
|
|
1382
|
+
}
|
|
1383
|
+
if (value.startsWith("[") && value.endsWith("]")) {
|
|
1384
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1385
|
+
console.warn(
|
|
1386
|
+
`[react-native-tailwind] Invalid arbitrary perspective value: ${value}. Only integers are supported (e.g., [1500]).`
|
|
1387
|
+
);
|
|
1388
|
+
}
|
|
1389
|
+
return null;
|
|
1390
|
+
}
|
|
1391
|
+
return null;
|
|
1392
|
+
}
|
|
1393
|
+
function parseTransform(cls) {
|
|
1394
|
+
if (cls.startsWith("origin-")) {
|
|
1395
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1396
|
+
console.warn(
|
|
1397
|
+
`[react-native-tailwind] transform-origin is not supported in React Native. Class "${cls}" will be ignored.`
|
|
1398
|
+
);
|
|
1399
|
+
}
|
|
1400
|
+
return null;
|
|
1401
|
+
}
|
|
1402
|
+
if (cls.startsWith("scale-")) {
|
|
1403
|
+
const scaleKey = cls.substring(6);
|
|
1404
|
+
const arbitraryScale = parseArbitraryScale(scaleKey);
|
|
1405
|
+
if (arbitraryScale !== null) {
|
|
1406
|
+
return { transform: [{ scale: arbitraryScale }] };
|
|
1407
|
+
}
|
|
1408
|
+
const scaleValue = SCALE_MAP[scaleKey];
|
|
1409
|
+
if (scaleValue !== void 0) {
|
|
1410
|
+
return { transform: [{ scale: scaleValue }] };
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
if (cls.startsWith("scale-x-")) {
|
|
1414
|
+
const scaleKey = cls.substring(8);
|
|
1415
|
+
const arbitraryScale = parseArbitraryScale(scaleKey);
|
|
1416
|
+
if (arbitraryScale !== null) {
|
|
1417
|
+
return { transform: [{ scaleX: arbitraryScale }] };
|
|
1418
|
+
}
|
|
1419
|
+
const scaleValue = SCALE_MAP[scaleKey];
|
|
1420
|
+
if (scaleValue !== void 0) {
|
|
1421
|
+
return { transform: [{ scaleX: scaleValue }] };
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
if (cls.startsWith("scale-y-")) {
|
|
1425
|
+
const scaleKey = cls.substring(8);
|
|
1426
|
+
const arbitraryScale = parseArbitraryScale(scaleKey);
|
|
1427
|
+
if (arbitraryScale !== null) {
|
|
1428
|
+
return { transform: [{ scaleY: arbitraryScale }] };
|
|
1429
|
+
}
|
|
1430
|
+
const scaleValue = SCALE_MAP[scaleKey];
|
|
1431
|
+
if (scaleValue !== void 0) {
|
|
1432
|
+
return { transform: [{ scaleY: scaleValue }] };
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
if (cls.startsWith("rotate-") || cls.startsWith("-rotate-")) {
|
|
1436
|
+
const isNegative = cls.startsWith("-");
|
|
1437
|
+
const rotateKey = isNegative ? cls.substring(8) : cls.substring(7);
|
|
1438
|
+
const arbitraryRotate = parseArbitraryRotation(rotateKey);
|
|
1439
|
+
if (arbitraryRotate !== null) {
|
|
1440
|
+
const degrees = isNegative ? `-${arbitraryRotate}` : arbitraryRotate;
|
|
1441
|
+
return { transform: [{ rotate: degrees }] };
|
|
1442
|
+
}
|
|
1443
|
+
const rotateValue = ROTATE_MAP[rotateKey];
|
|
1444
|
+
if (rotateValue !== void 0) {
|
|
1445
|
+
const degrees = isNegative ? -rotateValue : rotateValue;
|
|
1446
|
+
return { transform: [{ rotate: `${degrees}deg` }] };
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
if (cls.startsWith("rotate-x-") || cls.startsWith("-rotate-x-")) {
|
|
1450
|
+
const isNegative = cls.startsWith("-");
|
|
1451
|
+
const rotateKey = isNegative ? cls.substring(10) : cls.substring(9);
|
|
1452
|
+
const arbitraryRotate = parseArbitraryRotation(rotateKey);
|
|
1453
|
+
if (arbitraryRotate !== null) {
|
|
1454
|
+
const degrees = isNegative ? `-${arbitraryRotate}` : arbitraryRotate;
|
|
1455
|
+
return { transform: [{ rotateX: degrees }] };
|
|
1456
|
+
}
|
|
1457
|
+
const rotateValue = ROTATE_MAP[rotateKey];
|
|
1458
|
+
if (rotateValue !== void 0) {
|
|
1459
|
+
const degrees = isNegative ? -rotateValue : rotateValue;
|
|
1460
|
+
return { transform: [{ rotateX: `${degrees}deg` }] };
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
if (cls.startsWith("rotate-y-") || cls.startsWith("-rotate-y-")) {
|
|
1464
|
+
const isNegative = cls.startsWith("-");
|
|
1465
|
+
const rotateKey = isNegative ? cls.substring(10) : cls.substring(9);
|
|
1466
|
+
const arbitraryRotate = parseArbitraryRotation(rotateKey);
|
|
1467
|
+
if (arbitraryRotate !== null) {
|
|
1468
|
+
const degrees = isNegative ? `-${arbitraryRotate}` : arbitraryRotate;
|
|
1469
|
+
return { transform: [{ rotateY: degrees }] };
|
|
1470
|
+
}
|
|
1471
|
+
const rotateValue = ROTATE_MAP[rotateKey];
|
|
1472
|
+
if (rotateValue !== void 0) {
|
|
1473
|
+
const degrees = isNegative ? -rotateValue : rotateValue;
|
|
1474
|
+
return { transform: [{ rotateY: `${degrees}deg` }] };
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
if (cls.startsWith("rotate-z-") || cls.startsWith("-rotate-z-")) {
|
|
1478
|
+
const isNegative = cls.startsWith("-");
|
|
1479
|
+
const rotateKey = isNegative ? cls.substring(10) : cls.substring(9);
|
|
1480
|
+
const arbitraryRotate = parseArbitraryRotation(rotateKey);
|
|
1481
|
+
if (arbitraryRotate !== null) {
|
|
1482
|
+
const degrees = isNegative ? `-${arbitraryRotate}` : arbitraryRotate;
|
|
1483
|
+
return { transform: [{ rotateZ: degrees }] };
|
|
1484
|
+
}
|
|
1485
|
+
const rotateValue = ROTATE_MAP[rotateKey];
|
|
1486
|
+
if (rotateValue !== void 0) {
|
|
1487
|
+
const degrees = isNegative ? -rotateValue : rotateValue;
|
|
1488
|
+
return { transform: [{ rotateZ: `${degrees}deg` }] };
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
if (cls.startsWith("translate-x-") || cls.startsWith("-translate-x-")) {
|
|
1492
|
+
const isNegative = cls.startsWith("-");
|
|
1493
|
+
const translateKey = isNegative ? cls.substring(13) : cls.substring(12);
|
|
1494
|
+
const arbitraryTranslate = parseArbitraryTranslation(translateKey);
|
|
1495
|
+
if (arbitraryTranslate !== null) {
|
|
1496
|
+
const value = typeof arbitraryTranslate === "number" ? isNegative ? -arbitraryTranslate : arbitraryTranslate : isNegative ? `-${arbitraryTranslate}` : arbitraryTranslate;
|
|
1497
|
+
return { transform: [{ translateX: value }] };
|
|
1498
|
+
}
|
|
1499
|
+
const translateValue = SPACING_SCALE[translateKey];
|
|
1500
|
+
if (translateValue !== void 0) {
|
|
1501
|
+
const value = isNegative ? -translateValue : translateValue;
|
|
1502
|
+
return { transform: [{ translateX: value }] };
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
if (cls.startsWith("translate-y-") || cls.startsWith("-translate-y-")) {
|
|
1506
|
+
const isNegative = cls.startsWith("-");
|
|
1507
|
+
const translateKey = isNegative ? cls.substring(13) : cls.substring(12);
|
|
1508
|
+
const arbitraryTranslate = parseArbitraryTranslation(translateKey);
|
|
1509
|
+
if (arbitraryTranslate !== null) {
|
|
1510
|
+
const value = typeof arbitraryTranslate === "number" ? isNegative ? -arbitraryTranslate : arbitraryTranslate : isNegative ? `-${arbitraryTranslate}` : arbitraryTranslate;
|
|
1511
|
+
return { transform: [{ translateY: value }] };
|
|
1512
|
+
}
|
|
1513
|
+
const translateValue = SPACING_SCALE[translateKey];
|
|
1514
|
+
if (translateValue !== void 0) {
|
|
1515
|
+
const value = isNegative ? -translateValue : translateValue;
|
|
1516
|
+
return { transform: [{ translateY: value }] };
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
if (cls.startsWith("skew-x-") || cls.startsWith("-skew-x-")) {
|
|
1520
|
+
const isNegative = cls.startsWith("-");
|
|
1521
|
+
const skewKey = isNegative ? cls.substring(8) : cls.substring(7);
|
|
1522
|
+
const arbitrarySkew = parseArbitraryRotation(skewKey);
|
|
1523
|
+
if (arbitrarySkew !== null) {
|
|
1524
|
+
const degrees = isNegative ? `-${arbitrarySkew}` : arbitrarySkew;
|
|
1525
|
+
return { transform: [{ skewX: degrees }] };
|
|
1526
|
+
}
|
|
1527
|
+
const skewValue = SKEW_MAP[skewKey];
|
|
1528
|
+
if (skewValue !== void 0) {
|
|
1529
|
+
const degrees = isNegative ? -skewValue : skewValue;
|
|
1530
|
+
return { transform: [{ skewX: `${degrees}deg` }] };
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
if (cls.startsWith("skew-y-") || cls.startsWith("-skew-y-")) {
|
|
1534
|
+
const isNegative = cls.startsWith("-");
|
|
1535
|
+
const skewKey = isNegative ? cls.substring(8) : cls.substring(7);
|
|
1536
|
+
const arbitrarySkew = parseArbitraryRotation(skewKey);
|
|
1537
|
+
if (arbitrarySkew !== null) {
|
|
1538
|
+
const degrees = isNegative ? `-${arbitrarySkew}` : arbitrarySkew;
|
|
1539
|
+
return { transform: [{ skewY: degrees }] };
|
|
1540
|
+
}
|
|
1541
|
+
const skewValue = SKEW_MAP[skewKey];
|
|
1542
|
+
if (skewValue !== void 0) {
|
|
1543
|
+
const degrees = isNegative ? -skewValue : skewValue;
|
|
1544
|
+
return { transform: [{ skewY: `${degrees}deg` }] };
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
if (cls.startsWith("perspective-")) {
|
|
1548
|
+
const perspectiveKey = cls.substring(12);
|
|
1549
|
+
const arbitraryPerspective = parseArbitraryPerspective(perspectiveKey);
|
|
1550
|
+
if (arbitraryPerspective !== null) {
|
|
1551
|
+
return { transform: [{ perspective: arbitraryPerspective }] };
|
|
1552
|
+
}
|
|
1553
|
+
const perspectiveValue = PERSPECTIVE_SCALE[perspectiveKey];
|
|
1554
|
+
if (perspectiveValue !== void 0) {
|
|
1555
|
+
return { transform: [{ perspective: perspectiveValue }] };
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
return null;
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1053
1561
|
// src/parser/typography.ts
|
|
1054
1562
|
var FONT_SIZES = {
|
|
1055
1563
|
xs: 12,
|
|
@@ -1066,6 +1574,11 @@ var FONT_SIZES = {
|
|
|
1066
1574
|
"8xl": 96,
|
|
1067
1575
|
"9xl": 128
|
|
1068
1576
|
};
|
|
1577
|
+
var FONT_FAMILY_MAP = {
|
|
1578
|
+
"font-sans": { fontFamily: "System" },
|
|
1579
|
+
"font-serif": { fontFamily: "serif" },
|
|
1580
|
+
"font-mono": { fontFamily: "Courier" }
|
|
1581
|
+
};
|
|
1069
1582
|
var FONT_WEIGHT_MAP = {
|
|
1070
1583
|
"font-thin": { fontWeight: "100" },
|
|
1071
1584
|
"font-extralight": { fontWeight: "200" },
|
|
@@ -1163,7 +1676,7 @@ function parseTypography(cls) {
|
|
|
1163
1676
|
return { lineHeight: arbitraryValue };
|
|
1164
1677
|
}
|
|
1165
1678
|
}
|
|
1166
|
-
return FONT_WEIGHT_MAP[cls] ?? FONT_STYLE_MAP[cls] ?? TEXT_ALIGN_MAP[cls] ?? TEXT_DECORATION_MAP[cls] ?? TEXT_TRANSFORM_MAP[cls] ?? LINE_HEIGHT_MAP[cls] ?? TRACKING_MAP[cls] ?? null;
|
|
1679
|
+
return FONT_FAMILY_MAP[cls] ?? FONT_WEIGHT_MAP[cls] ?? FONT_STYLE_MAP[cls] ?? TEXT_ALIGN_MAP[cls] ?? TEXT_DECORATION_MAP[cls] ?? TEXT_TRANSFORM_MAP[cls] ?? LINE_HEIGHT_MAP[cls] ?? TRACKING_MAP[cls] ?? null;
|
|
1167
1680
|
}
|
|
1168
1681
|
|
|
1169
1682
|
// src/parser/modifiers.ts
|
|
@@ -1223,7 +1736,8 @@ function parseClass(cls, customColors) {
|
|
|
1223
1736
|
parseTypography,
|
|
1224
1737
|
parseSizing,
|
|
1225
1738
|
parseShadow,
|
|
1226
|
-
parseAspectRatio
|
|
1739
|
+
parseAspectRatio,
|
|
1740
|
+
parseTransform
|
|
1227
1741
|
];
|
|
1228
1742
|
for (const parser of parsers) {
|
|
1229
1743
|
const result = parser(cls);
|
|
@@ -1287,14 +1801,14 @@ function loadTailwindConfig(configPath) {
|
|
|
1287
1801
|
return null;
|
|
1288
1802
|
}
|
|
1289
1803
|
}
|
|
1290
|
-
function
|
|
1804
|
+
function flattenColors2(colors, prefix = "") {
|
|
1291
1805
|
const result = {};
|
|
1292
1806
|
for (const [key, value] of Object.entries(colors)) {
|
|
1293
1807
|
const newKey = prefix ? `${prefix}-${key}` : key;
|
|
1294
1808
|
if (typeof value === "string") {
|
|
1295
1809
|
result[newKey] = value;
|
|
1296
1810
|
} else if (typeof value === "object" && value !== null) {
|
|
1297
|
-
Object.assign(result,
|
|
1811
|
+
Object.assign(result, flattenColors2(value, newKey));
|
|
1298
1812
|
}
|
|
1299
1813
|
}
|
|
1300
1814
|
return result;
|
|
@@ -1315,7 +1829,7 @@ function extractCustomColors(filename) {
|
|
|
1315
1829
|
);
|
|
1316
1830
|
}
|
|
1317
1831
|
const colors = config.theme.extend?.colors ?? config.theme.colors ?? {};
|
|
1318
|
-
return
|
|
1832
|
+
return flattenColors2(colors);
|
|
1319
1833
|
}
|
|
1320
1834
|
|
|
1321
1835
|
// src/babel/index.ts
|