@kbach/react-native 1.0.0-beta.7 → 1.0.0-beta.8
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 +108 -39
- package/dist/ThemeContext-Dc5AC-m0.d.mts +98 -0
- package/dist/ThemeContext-Dc5AC-m0.d.ts +98 -0
- package/dist/{chunk-AEVOM2NB.mjs → chunk-4BXM3QUV.mjs} +38 -57
- package/dist/{chunk-4KCCEMEN.mjs → chunk-CGU7UM2F.mjs} +1 -1
- package/dist/chunk-JR3BLUAV.mjs +1204 -0
- package/dist/chunk-JS5KIGAB.mjs +192 -0
- package/dist/{chunk-OJQAJLYT.mjs → chunk-KV3ZIXSH.mjs} +1 -1
- package/dist/chunk-OIW7OQWO.mjs +40 -0
- package/dist/chunk-Z664AKW7.mjs +54 -0
- package/dist/index.d.mts +21 -98
- package/dist/index.d.ts +21 -98
- package/dist/index.js +1219 -5
- package/dist/index.mjs +8 -6
- package/dist/index.web.d.mts +12 -4
- package/dist/index.web.d.ts +12 -4
- package/dist/index.web.js +101 -36
- package/dist/index.web.mjs +11 -9
- package/dist/jsx-dev-runtime.js +1223 -5
- package/dist/jsx-dev-runtime.mjs +4 -3
- package/dist/jsx-dev-runtime.web.js +108 -71
- package/dist/jsx-dev-runtime.web.mjs +4 -4
- package/dist/jsx-runtime.js +1223 -5
- package/dist/jsx-runtime.mjs +4 -3
- package/dist/jsx-runtime.web.js +93 -61
- package/dist/jsx-runtime.web.mjs +4 -6
- package/package.json +22 -4
- package/dist/chunk-5WK55Z56.mjs +0 -14
- package/dist/chunk-FG5E4NLJ.mjs +0 -18
- package/dist/chunk-T3HPTH62.mjs +0 -161
package/dist/jsx-runtime.js
CHANGED
|
@@ -347,16 +347,49 @@ var PALETTE = {
|
|
|
347
347
|
// src/theme.ts
|
|
348
348
|
var defaultTheme = {
|
|
349
349
|
colors: PALETTE,
|
|
350
|
+
// Real Tailwind's default spacing scale in full — every step is exactly
|
|
351
|
+
// `n * 4px`, including the fractional `.5` steps (`1.5` -> 6px, `2.5` ->
|
|
352
|
+
// 10px, `3.5` -> 14px) and the "px" literal (a bare 1px). Previously
|
|
353
|
+
// this only had {0,1,2,4,6,8} — a handful of spot-checked values, not
|
|
354
|
+
// the real scale — so anything else (`p-3`, `w-5`, `border-2`,
|
|
355
|
+
// `gap-10`, ...) silently failed to resolve. Mirrors @kbach/react's
|
|
356
|
+
// theme.ts exactly.
|
|
350
357
|
spacing: {
|
|
351
|
-
// "0" is always a hardcoded zero in real Tailwind's own scale too,
|
|
352
|
-
// regardless of the base spacing unit — needed for `p-0`/`m-0`/etc.
|
|
353
|
-
// Mirrors the identical fix in @kbach/react's theme.ts.
|
|
354
358
|
"0": 0,
|
|
359
|
+
"px": 1,
|
|
360
|
+
"0.5": 2,
|
|
355
361
|
"1": 4,
|
|
362
|
+
"1.5": 6,
|
|
356
363
|
"2": 8,
|
|
364
|
+
"2.5": 10,
|
|
365
|
+
"3": 12,
|
|
366
|
+
"3.5": 14,
|
|
357
367
|
"4": 16,
|
|
368
|
+
"5": 20,
|
|
358
369
|
"6": 24,
|
|
359
|
-
"
|
|
370
|
+
"7": 28,
|
|
371
|
+
"8": 32,
|
|
372
|
+
"9": 36,
|
|
373
|
+
"10": 40,
|
|
374
|
+
"11": 44,
|
|
375
|
+
"12": 48,
|
|
376
|
+
"14": 56,
|
|
377
|
+
"16": 64,
|
|
378
|
+
"20": 80,
|
|
379
|
+
"24": 96,
|
|
380
|
+
"28": 112,
|
|
381
|
+
"32": 128,
|
|
382
|
+
"36": 144,
|
|
383
|
+
"40": 160,
|
|
384
|
+
"44": 176,
|
|
385
|
+
"48": 192,
|
|
386
|
+
"52": 208,
|
|
387
|
+
"56": 224,
|
|
388
|
+
"60": 240,
|
|
389
|
+
"64": 256,
|
|
390
|
+
"72": 288,
|
|
391
|
+
"80": 320,
|
|
392
|
+
"96": 384
|
|
360
393
|
},
|
|
361
394
|
screens: {
|
|
362
395
|
sm: 640,
|
|
@@ -367,7 +400,11 @@ var defaultTheme = {
|
|
|
367
400
|
},
|
|
368
401
|
darkMode: "attribute"
|
|
369
402
|
};
|
|
403
|
+
var activeTheme = defaultTheme;
|
|
370
404
|
var activeThemeJson = JSON.stringify(defaultTheme);
|
|
405
|
+
function getTheme() {
|
|
406
|
+
return activeTheme;
|
|
407
|
+
}
|
|
371
408
|
function getThemeJson() {
|
|
372
409
|
return activeThemeJson;
|
|
373
410
|
}
|
|
@@ -395,11 +432,1192 @@ function getGlobalDarkMode() {
|
|
|
395
432
|
return isDark;
|
|
396
433
|
}
|
|
397
434
|
|
|
435
|
+
// src/jsEngine/parser.ts
|
|
436
|
+
var VALUE_PREFIXES = [
|
|
437
|
+
"bg-opacity-",
|
|
438
|
+
"text-opacity-",
|
|
439
|
+
"bg-blend-",
|
|
440
|
+
"text-shadow-",
|
|
441
|
+
"bg-",
|
|
442
|
+
"text-",
|
|
443
|
+
"border-x-",
|
|
444
|
+
"border-y-",
|
|
445
|
+
"border-t-",
|
|
446
|
+
"border-r-",
|
|
447
|
+
"border-b-",
|
|
448
|
+
"border-l-",
|
|
449
|
+
"border-",
|
|
450
|
+
"caret-",
|
|
451
|
+
"accent-",
|
|
452
|
+
"fill-",
|
|
453
|
+
"stroke-width-",
|
|
454
|
+
"stroke-",
|
|
455
|
+
"resize-",
|
|
456
|
+
"touch-",
|
|
457
|
+
"will-change-",
|
|
458
|
+
"scroll-mx-",
|
|
459
|
+
"scroll-my-",
|
|
460
|
+
"scroll-mt-",
|
|
461
|
+
"scroll-mr-",
|
|
462
|
+
"scroll-mb-",
|
|
463
|
+
"scroll-ml-",
|
|
464
|
+
"scroll-m-",
|
|
465
|
+
"scroll-px-",
|
|
466
|
+
"scroll-py-",
|
|
467
|
+
"scroll-pt-",
|
|
468
|
+
"scroll-pr-",
|
|
469
|
+
"scroll-pb-",
|
|
470
|
+
"scroll-pl-",
|
|
471
|
+
"scroll-p-",
|
|
472
|
+
"px-",
|
|
473
|
+
"py-",
|
|
474
|
+
"pt-",
|
|
475
|
+
"pr-",
|
|
476
|
+
"pb-",
|
|
477
|
+
"pl-",
|
|
478
|
+
"p-",
|
|
479
|
+
"mx-",
|
|
480
|
+
"my-",
|
|
481
|
+
"mt-",
|
|
482
|
+
"mr-",
|
|
483
|
+
"mb-",
|
|
484
|
+
"ml-",
|
|
485
|
+
"m-",
|
|
486
|
+
"gap-x-",
|
|
487
|
+
"gap-y-",
|
|
488
|
+
"gap-",
|
|
489
|
+
"min-w-",
|
|
490
|
+
"max-w-",
|
|
491
|
+
"w-",
|
|
492
|
+
"min-h-",
|
|
493
|
+
"max-h-",
|
|
494
|
+
"h-",
|
|
495
|
+
"size-",
|
|
496
|
+
"basis-",
|
|
497
|
+
"rounded-tl-",
|
|
498
|
+
"rounded-tr-",
|
|
499
|
+
"rounded-br-",
|
|
500
|
+
"rounded-bl-",
|
|
501
|
+
"rounded-t-",
|
|
502
|
+
"rounded-r-",
|
|
503
|
+
"rounded-b-",
|
|
504
|
+
"rounded-l-",
|
|
505
|
+
"rounded-",
|
|
506
|
+
"ring-offset-",
|
|
507
|
+
"ring-",
|
|
508
|
+
"outline-offset-",
|
|
509
|
+
"outline-",
|
|
510
|
+
"shadow-",
|
|
511
|
+
"opacity-",
|
|
512
|
+
"duration-",
|
|
513
|
+
"delay-",
|
|
514
|
+
"ease-",
|
|
515
|
+
"cursor-",
|
|
516
|
+
"mix-blend-",
|
|
517
|
+
"animate-",
|
|
518
|
+
"leading-",
|
|
519
|
+
"tracking-",
|
|
520
|
+
"font-",
|
|
521
|
+
"z-",
|
|
522
|
+
"inset-",
|
|
523
|
+
"top-",
|
|
524
|
+
"right-",
|
|
525
|
+
"bottom-",
|
|
526
|
+
"left-",
|
|
527
|
+
"divide-color-",
|
|
528
|
+
"space-x-",
|
|
529
|
+
"space-y-",
|
|
530
|
+
"flex-",
|
|
531
|
+
"grow-",
|
|
532
|
+
"shrink-",
|
|
533
|
+
"order-",
|
|
534
|
+
"grid-cols-",
|
|
535
|
+
"grid-rows-",
|
|
536
|
+
"grid-flow-",
|
|
537
|
+
"auto-cols-",
|
|
538
|
+
"auto-rows-",
|
|
539
|
+
"col-span-",
|
|
540
|
+
"col-start-",
|
|
541
|
+
"col-end-",
|
|
542
|
+
"col-",
|
|
543
|
+
"row-span-",
|
|
544
|
+
"row-start-",
|
|
545
|
+
"row-end-",
|
|
546
|
+
"row-",
|
|
547
|
+
"place-items-",
|
|
548
|
+
"place-content-",
|
|
549
|
+
"place-self-",
|
|
550
|
+
"justify-items-",
|
|
551
|
+
"justify-self-",
|
|
552
|
+
"scale-x-",
|
|
553
|
+
"scale-y-",
|
|
554
|
+
"scale-",
|
|
555
|
+
"rotate-",
|
|
556
|
+
"translate-x-",
|
|
557
|
+
"translate-y-",
|
|
558
|
+
"skew-x-",
|
|
559
|
+
"skew-y-",
|
|
560
|
+
"origin-",
|
|
561
|
+
"blur-",
|
|
562
|
+
"brightness-",
|
|
563
|
+
"contrast-",
|
|
564
|
+
"grayscale-",
|
|
565
|
+
"hue-rotate-",
|
|
566
|
+
"invert-",
|
|
567
|
+
"saturate-",
|
|
568
|
+
"sepia-",
|
|
569
|
+
"drop-shadow-",
|
|
570
|
+
"filter-",
|
|
571
|
+
"backdrop-blur-",
|
|
572
|
+
"backdrop-brightness-",
|
|
573
|
+
"backdrop-contrast-",
|
|
574
|
+
"backdrop-grayscale-",
|
|
575
|
+
"backdrop-hue-rotate-",
|
|
576
|
+
"backdrop-invert-",
|
|
577
|
+
"backdrop-opacity-",
|
|
578
|
+
"backdrop-saturate-",
|
|
579
|
+
"backdrop-sepia-",
|
|
580
|
+
"backdrop-filter-",
|
|
581
|
+
"decoration-",
|
|
582
|
+
"underline-offset-",
|
|
583
|
+
"indent-",
|
|
584
|
+
"from-",
|
|
585
|
+
"via-",
|
|
586
|
+
"to-"
|
|
587
|
+
];
|
|
588
|
+
var ARBITRARY_PROPERTY_SENTINEL = "[arbitrary-property]";
|
|
589
|
+
function isSafeArbitraryValue(value) {
|
|
590
|
+
return !value.includes("{") && !value.includes("}") && !value.includes(";");
|
|
591
|
+
}
|
|
592
|
+
function splitRespectingBrackets(token) {
|
|
593
|
+
const parts = [];
|
|
594
|
+
let depth = 0;
|
|
595
|
+
let start = 0;
|
|
596
|
+
for (let i = 0; i < token.length; i++) {
|
|
597
|
+
const ch = token[i];
|
|
598
|
+
if (ch === "[") depth += 1;
|
|
599
|
+
else if (ch === "]") depth -= 1;
|
|
600
|
+
else if (ch === ":" && depth <= 0) {
|
|
601
|
+
parts.push(token.slice(start, i));
|
|
602
|
+
start = i + 1;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
parts.push(token.slice(start));
|
|
606
|
+
return parts;
|
|
607
|
+
}
|
|
608
|
+
function parseClass(token) {
|
|
609
|
+
const parts = splitRespectingBrackets(token);
|
|
610
|
+
let base = parts.pop() ?? token;
|
|
611
|
+
const modifiers = parts;
|
|
612
|
+
const important = base.startsWith("!");
|
|
613
|
+
if (important) {
|
|
614
|
+
base = base.slice(1);
|
|
615
|
+
}
|
|
616
|
+
const negative = base.startsWith("-");
|
|
617
|
+
if (negative) {
|
|
618
|
+
base = base.slice(1);
|
|
619
|
+
}
|
|
620
|
+
if (base.length >= 2 && base.startsWith("[") && base.endsWith("]")) {
|
|
621
|
+
const raw = base.slice(1, -1);
|
|
622
|
+
const colonIdx = raw.indexOf(":");
|
|
623
|
+
if (colonIdx !== -1) {
|
|
624
|
+
const property = raw.slice(0, colonIdx);
|
|
625
|
+
const rawValue = raw.slice(colonIdx + 1);
|
|
626
|
+
if (property !== "" && rawValue !== "" && isSafeArbitraryValue(raw)) {
|
|
627
|
+
const value = rawValue.replace(/_/g, " ");
|
|
628
|
+
return {
|
|
629
|
+
modifiers,
|
|
630
|
+
utility: ARBITRARY_PROPERTY_SENTINEL,
|
|
631
|
+
value: `${property}:${value}`,
|
|
632
|
+
isArbitrary: true,
|
|
633
|
+
important,
|
|
634
|
+
negative,
|
|
635
|
+
original: token
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
for (const prefix of VALUE_PREFIXES) {
|
|
641
|
+
if (!base.startsWith(prefix)) continue;
|
|
642
|
+
const value = base.slice(prefix.length);
|
|
643
|
+
if (value === "") continue;
|
|
644
|
+
if (value.length >= 2 && value.startsWith("[") && value.endsWith("]")) {
|
|
645
|
+
const raw = value.slice(1, -1);
|
|
646
|
+
if (!isSafeArbitraryValue(raw)) {
|
|
647
|
+
continue;
|
|
648
|
+
}
|
|
649
|
+
const spaced = raw.replace(/_/g, " ");
|
|
650
|
+
return {
|
|
651
|
+
modifiers,
|
|
652
|
+
utility: prefix.slice(0, -1),
|
|
653
|
+
value: spaced,
|
|
654
|
+
isArbitrary: true,
|
|
655
|
+
important,
|
|
656
|
+
negative,
|
|
657
|
+
original: token
|
|
658
|
+
};
|
|
659
|
+
}
|
|
660
|
+
return {
|
|
661
|
+
modifiers,
|
|
662
|
+
utility: prefix.slice(0, -1),
|
|
663
|
+
value,
|
|
664
|
+
isArbitrary: false,
|
|
665
|
+
important,
|
|
666
|
+
negative,
|
|
667
|
+
original: token
|
|
668
|
+
};
|
|
669
|
+
}
|
|
670
|
+
return {
|
|
671
|
+
modifiers,
|
|
672
|
+
utility: base,
|
|
673
|
+
value: null,
|
|
674
|
+
isArbitrary: false,
|
|
675
|
+
important,
|
|
676
|
+
negative,
|
|
677
|
+
original: token
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
// src/jsEngine/shared.ts
|
|
682
|
+
function decl(property, value) {
|
|
683
|
+
return { property, value };
|
|
684
|
+
}
|
|
685
|
+
function resolveLength(theme, parsed) {
|
|
686
|
+
if (parsed.negative) return null;
|
|
687
|
+
const value = parsed.value;
|
|
688
|
+
if (value === null) return null;
|
|
689
|
+
if (parsed.isArbitrary) return value;
|
|
690
|
+
if (value === "full") return "100%";
|
|
691
|
+
if (value === "auto") return "auto";
|
|
692
|
+
const px = theme.spacing[value];
|
|
693
|
+
return px === void 0 ? null : `${px}px`;
|
|
694
|
+
}
|
|
695
|
+
function resolveNegatableLength(theme, parsed) {
|
|
696
|
+
if (!parsed.negative) return resolveLength(theme, parsed);
|
|
697
|
+
if (parsed.isArbitrary) return null;
|
|
698
|
+
const value = parsed.value;
|
|
699
|
+
if (value === null) return null;
|
|
700
|
+
const px = theme.spacing[value];
|
|
701
|
+
if (px === void 0) return null;
|
|
702
|
+
if (px === 0) return "0px";
|
|
703
|
+
return `-${px}px`;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
// src/jsEngine/resolvers/layout.ts
|
|
707
|
+
function negateRaw(value, negative) {
|
|
708
|
+
return negative ? `-${value}` : value;
|
|
709
|
+
}
|
|
710
|
+
function resolve(parsed, theme) {
|
|
711
|
+
switch (parsed.utility) {
|
|
712
|
+
case "flex":
|
|
713
|
+
return parsed.value === null ? [decl("display", "flex")] : null;
|
|
714
|
+
case "grid":
|
|
715
|
+
return [decl("display", "grid")];
|
|
716
|
+
case "block":
|
|
717
|
+
return [decl("display", "block")];
|
|
718
|
+
case "inline-block":
|
|
719
|
+
return [decl("display", "inline-block")];
|
|
720
|
+
case "inline":
|
|
721
|
+
return [decl("display", "inline")];
|
|
722
|
+
case "inline-flex":
|
|
723
|
+
return [decl("display", "inline-flex")];
|
|
724
|
+
case "inline-grid":
|
|
725
|
+
return [decl("display", "inline-grid")];
|
|
726
|
+
case "contents":
|
|
727
|
+
return [decl("display", "contents")];
|
|
728
|
+
case "flow-root":
|
|
729
|
+
return [decl("display", "flow-root")];
|
|
730
|
+
case "hidden":
|
|
731
|
+
return [decl("display", "none")];
|
|
732
|
+
case "@container":
|
|
733
|
+
return [decl("container-type", "inline-size")];
|
|
734
|
+
case "items-center":
|
|
735
|
+
return [decl("align-items", "center")];
|
|
736
|
+
case "items-start":
|
|
737
|
+
return [decl("align-items", "flex-start")];
|
|
738
|
+
case "items-end":
|
|
739
|
+
return [decl("align-items", "flex-end")];
|
|
740
|
+
case "items-baseline":
|
|
741
|
+
return [decl("align-items", "baseline")];
|
|
742
|
+
case "items-stretch":
|
|
743
|
+
return [decl("align-items", "stretch")];
|
|
744
|
+
case "justify-center":
|
|
745
|
+
return [decl("justify-content", "center")];
|
|
746
|
+
case "justify-start":
|
|
747
|
+
return [decl("justify-content", "flex-start")];
|
|
748
|
+
case "justify-end":
|
|
749
|
+
return [decl("justify-content", "flex-end")];
|
|
750
|
+
case "justify-between":
|
|
751
|
+
return [decl("justify-content", "space-between")];
|
|
752
|
+
case "justify-around":
|
|
753
|
+
return [decl("justify-content", "space-around")];
|
|
754
|
+
case "justify-evenly":
|
|
755
|
+
return [decl("justify-content", "space-evenly")];
|
|
756
|
+
case "content-start":
|
|
757
|
+
return [decl("align-content", "flex-start")];
|
|
758
|
+
case "content-end":
|
|
759
|
+
return [decl("align-content", "flex-end")];
|
|
760
|
+
case "content-center":
|
|
761
|
+
return [decl("align-content", "center")];
|
|
762
|
+
case "content-between":
|
|
763
|
+
return [decl("align-content", "space-between")];
|
|
764
|
+
case "content-around":
|
|
765
|
+
return [decl("align-content", "space-around")];
|
|
766
|
+
case "content-evenly":
|
|
767
|
+
return [decl("align-content", "space-evenly")];
|
|
768
|
+
case "content-stretch":
|
|
769
|
+
return [decl("align-content", "stretch")];
|
|
770
|
+
case "self-auto":
|
|
771
|
+
return [decl("align-self", "auto")];
|
|
772
|
+
case "self-center":
|
|
773
|
+
return [decl("align-self", "center")];
|
|
774
|
+
case "self-start":
|
|
775
|
+
return [decl("align-self", "flex-start")];
|
|
776
|
+
case "self-end":
|
|
777
|
+
return [decl("align-self", "flex-end")];
|
|
778
|
+
case "self-stretch":
|
|
779
|
+
return [decl("align-self", "stretch")];
|
|
780
|
+
case "self-baseline":
|
|
781
|
+
return [decl("align-self", "baseline")];
|
|
782
|
+
case "overflow-hidden":
|
|
783
|
+
return [decl("overflow", "hidden")];
|
|
784
|
+
case "overflow-auto":
|
|
785
|
+
return [decl("overflow", "auto")];
|
|
786
|
+
case "overflow-scroll":
|
|
787
|
+
return [decl("overflow", "scroll")];
|
|
788
|
+
case "overflow-visible":
|
|
789
|
+
return [decl("overflow", "visible")];
|
|
790
|
+
case "static":
|
|
791
|
+
return [decl("position", "static")];
|
|
792
|
+
case "relative":
|
|
793
|
+
return [decl("position", "relative")];
|
|
794
|
+
case "absolute":
|
|
795
|
+
return [decl("position", "absolute")];
|
|
796
|
+
case "fixed":
|
|
797
|
+
return [decl("position", "fixed")];
|
|
798
|
+
case "sticky":
|
|
799
|
+
return [decl("position", "sticky")];
|
|
800
|
+
case "z":
|
|
801
|
+
return parsed.value === null ? null : [decl("z-index", negateRaw(parsed.value, parsed.negative))];
|
|
802
|
+
case "order":
|
|
803
|
+
return parsed.value === null ? null : [decl("order", negateRaw(parsed.value, parsed.negative))];
|
|
804
|
+
case "grow":
|
|
805
|
+
return [decl("flex-grow", parsed.value ?? "1")];
|
|
806
|
+
case "shrink":
|
|
807
|
+
return [decl("flex-shrink", parsed.value ?? "1")];
|
|
808
|
+
// top/right/bottom/left/inset support real Tailwind's negative-value
|
|
809
|
+
// convention ("-top-4") — see resolveNegatableLength's own doc comment.
|
|
810
|
+
case "top": {
|
|
811
|
+
const v = resolveNegatableLength(theme, parsed);
|
|
812
|
+
return v === null ? null : [decl("top", v)];
|
|
813
|
+
}
|
|
814
|
+
case "right": {
|
|
815
|
+
const v = resolveNegatableLength(theme, parsed);
|
|
816
|
+
return v === null ? null : [decl("right", v)];
|
|
817
|
+
}
|
|
818
|
+
case "bottom": {
|
|
819
|
+
const v = resolveNegatableLength(theme, parsed);
|
|
820
|
+
return v === null ? null : [decl("bottom", v)];
|
|
821
|
+
}
|
|
822
|
+
case "left": {
|
|
823
|
+
const v = resolveNegatableLength(theme, parsed);
|
|
824
|
+
return v === null ? null : [decl("left", v)];
|
|
825
|
+
}
|
|
826
|
+
case "inset": {
|
|
827
|
+
const v = resolveNegatableLength(theme, parsed);
|
|
828
|
+
return v === null ? null : [decl("inset", v)];
|
|
829
|
+
}
|
|
830
|
+
case "aspect-square":
|
|
831
|
+
return [decl("aspect-ratio", "1 / 1")];
|
|
832
|
+
case "aspect-video":
|
|
833
|
+
return [decl("aspect-ratio", "16 / 9")];
|
|
834
|
+
default:
|
|
835
|
+
return null;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
function resolveFlex(parsed, web) {
|
|
839
|
+
if (parsed.utility !== "flex") return null;
|
|
840
|
+
const value = parsed.value;
|
|
841
|
+
if (value === null) return null;
|
|
842
|
+
if (parsed.isArbitrary) return [decl("flex", value)];
|
|
843
|
+
switch (value) {
|
|
844
|
+
case "row":
|
|
845
|
+
return [decl("flex-direction", "row")];
|
|
846
|
+
case "col":
|
|
847
|
+
return [decl("flex-direction", "column")];
|
|
848
|
+
case "row-reverse":
|
|
849
|
+
return [decl("flex-direction", "row-reverse")];
|
|
850
|
+
case "col-reverse":
|
|
851
|
+
return [decl("flex-direction", "column-reverse")];
|
|
852
|
+
case "wrap":
|
|
853
|
+
return [decl("flex-wrap", "wrap")];
|
|
854
|
+
case "wrap-reverse":
|
|
855
|
+
return [decl("flex-wrap", "wrap-reverse")];
|
|
856
|
+
case "nowrap":
|
|
857
|
+
return [decl("flex-wrap", "nowrap")];
|
|
858
|
+
case "1":
|
|
859
|
+
return [decl("flex", "1")];
|
|
860
|
+
case "auto":
|
|
861
|
+
return [decl("flex", web ? "auto" : "1")];
|
|
862
|
+
case "initial":
|
|
863
|
+
return [decl("flex", web ? "initial" : "1")];
|
|
864
|
+
case "none":
|
|
865
|
+
return [decl("flex", web ? "none" : "0")];
|
|
866
|
+
case "grow":
|
|
867
|
+
return [decl("flex-grow", "1")];
|
|
868
|
+
case "grow-0":
|
|
869
|
+
return [decl("flex-grow", "0")];
|
|
870
|
+
case "shrink":
|
|
871
|
+
return [decl("flex-shrink", "1")];
|
|
872
|
+
case "shrink-0":
|
|
873
|
+
return [decl("flex-shrink", "0")];
|
|
874
|
+
default:
|
|
875
|
+
return null;
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
// src/jsEngine/resolvers/spacing.ts
|
|
880
|
+
function namedSize(key) {
|
|
881
|
+
switch (key) {
|
|
882
|
+
case "sm":
|
|
883
|
+
return "24rem";
|
|
884
|
+
case "md":
|
|
885
|
+
return "28rem";
|
|
886
|
+
case "lg":
|
|
887
|
+
return "32rem";
|
|
888
|
+
case "xl":
|
|
889
|
+
return "36rem";
|
|
890
|
+
case "2xl":
|
|
891
|
+
return "42rem";
|
|
892
|
+
case "3xl":
|
|
893
|
+
return "48rem";
|
|
894
|
+
case "4xl":
|
|
895
|
+
return "56rem";
|
|
896
|
+
case "5xl":
|
|
897
|
+
return "64rem";
|
|
898
|
+
case "6xl":
|
|
899
|
+
return "72rem";
|
|
900
|
+
case "7xl":
|
|
901
|
+
return "80rem";
|
|
902
|
+
case "8xl":
|
|
903
|
+
return "88rem";
|
|
904
|
+
case "9xl":
|
|
905
|
+
return "96rem";
|
|
906
|
+
default:
|
|
907
|
+
return null;
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
function fractionPercent(value) {
|
|
911
|
+
const slashIdx = value.indexOf("/");
|
|
912
|
+
if (slashIdx === -1) return null;
|
|
913
|
+
const numStr = value.slice(0, slashIdx);
|
|
914
|
+
const denStr = value.slice(slashIdx + 1);
|
|
915
|
+
const num = Number(numStr);
|
|
916
|
+
const den = Number(denStr);
|
|
917
|
+
if (!Number.isFinite(num) || !Number.isFinite(den) || numStr.trim() === "" || denStr.trim() === "") return null;
|
|
918
|
+
if (den === 0) return null;
|
|
919
|
+
const pct = num / den * 100;
|
|
920
|
+
const formatted = pct.toFixed(6);
|
|
921
|
+
const trimmed = formatted.replace(/0+$/, "").replace(/\.$/, "");
|
|
922
|
+
return `${trimmed}%`;
|
|
923
|
+
}
|
|
924
|
+
function cssSizeKeyword(key) {
|
|
925
|
+
switch (key) {
|
|
926
|
+
case "min":
|
|
927
|
+
return "min-content";
|
|
928
|
+
case "max":
|
|
929
|
+
return "max-content";
|
|
930
|
+
case "fit":
|
|
931
|
+
return "fit-content";
|
|
932
|
+
default:
|
|
933
|
+
return null;
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
function resolveSize(theme, parsed) {
|
|
937
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
938
|
+
const named = namedSize(parsed.value);
|
|
939
|
+
if (named !== null) return named;
|
|
940
|
+
const kw = cssSizeKeyword(parsed.value);
|
|
941
|
+
if (kw !== null) return kw;
|
|
942
|
+
const fraction = fractionPercent(parsed.value);
|
|
943
|
+
if (fraction !== null) return fraction;
|
|
944
|
+
}
|
|
945
|
+
return resolveLength(theme, parsed);
|
|
946
|
+
}
|
|
947
|
+
function resolve2(parsed, theme) {
|
|
948
|
+
const length = () => resolveLength(theme, parsed);
|
|
949
|
+
const size = () => resolveSize(theme, parsed);
|
|
950
|
+
const negatableLength = () => resolveNegatableLength(theme, parsed);
|
|
951
|
+
switch (parsed.utility) {
|
|
952
|
+
case "p": {
|
|
953
|
+
const v = length();
|
|
954
|
+
return v === null ? null : [decl("padding", v)];
|
|
955
|
+
}
|
|
956
|
+
case "px": {
|
|
957
|
+
const v = length();
|
|
958
|
+
return v === null ? null : [decl("padding-left", v), decl("padding-right", v)];
|
|
959
|
+
}
|
|
960
|
+
case "py": {
|
|
961
|
+
const v = length();
|
|
962
|
+
return v === null ? null : [decl("padding-top", v), decl("padding-bottom", v)];
|
|
963
|
+
}
|
|
964
|
+
case "pt": {
|
|
965
|
+
const v = length();
|
|
966
|
+
return v === null ? null : [decl("padding-top", v)];
|
|
967
|
+
}
|
|
968
|
+
case "pr": {
|
|
969
|
+
const v = length();
|
|
970
|
+
return v === null ? null : [decl("padding-right", v)];
|
|
971
|
+
}
|
|
972
|
+
case "pb": {
|
|
973
|
+
const v = length();
|
|
974
|
+
return v === null ? null : [decl("padding-bottom", v)];
|
|
975
|
+
}
|
|
976
|
+
case "pl": {
|
|
977
|
+
const v = length();
|
|
978
|
+
return v === null ? null : [decl("padding-left", v)];
|
|
979
|
+
}
|
|
980
|
+
case "m": {
|
|
981
|
+
const v = negatableLength();
|
|
982
|
+
return v === null ? null : [decl("margin", v)];
|
|
983
|
+
}
|
|
984
|
+
case "mx": {
|
|
985
|
+
const v = negatableLength();
|
|
986
|
+
return v === null ? null : [decl("margin-left", v), decl("margin-right", v)];
|
|
987
|
+
}
|
|
988
|
+
case "my": {
|
|
989
|
+
const v = negatableLength();
|
|
990
|
+
return v === null ? null : [decl("margin-top", v), decl("margin-bottom", v)];
|
|
991
|
+
}
|
|
992
|
+
case "mt": {
|
|
993
|
+
const v = negatableLength();
|
|
994
|
+
return v === null ? null : [decl("margin-top", v)];
|
|
995
|
+
}
|
|
996
|
+
case "mr": {
|
|
997
|
+
const v = negatableLength();
|
|
998
|
+
return v === null ? null : [decl("margin-right", v)];
|
|
999
|
+
}
|
|
1000
|
+
case "mb": {
|
|
1001
|
+
const v = negatableLength();
|
|
1002
|
+
return v === null ? null : [decl("margin-bottom", v)];
|
|
1003
|
+
}
|
|
1004
|
+
case "ml": {
|
|
1005
|
+
const v = negatableLength();
|
|
1006
|
+
return v === null ? null : [decl("margin-left", v)];
|
|
1007
|
+
}
|
|
1008
|
+
case "gap": {
|
|
1009
|
+
const v = length();
|
|
1010
|
+
return v === null ? null : [decl("gap", v)];
|
|
1011
|
+
}
|
|
1012
|
+
case "gap-x": {
|
|
1013
|
+
const v = length();
|
|
1014
|
+
return v === null ? null : [decl("column-gap", v)];
|
|
1015
|
+
}
|
|
1016
|
+
case "gap-y": {
|
|
1017
|
+
const v = length();
|
|
1018
|
+
return v === null ? null : [decl("row-gap", v)];
|
|
1019
|
+
}
|
|
1020
|
+
case "w": {
|
|
1021
|
+
const v = size();
|
|
1022
|
+
return v === null ? null : [decl("width", v)];
|
|
1023
|
+
}
|
|
1024
|
+
case "h": {
|
|
1025
|
+
const v = size();
|
|
1026
|
+
return v === null ? null : [decl("height", v)];
|
|
1027
|
+
}
|
|
1028
|
+
case "min-w": {
|
|
1029
|
+
const v = size();
|
|
1030
|
+
return v === null ? null : [decl("min-width", v)];
|
|
1031
|
+
}
|
|
1032
|
+
case "max-w": {
|
|
1033
|
+
const v = size();
|
|
1034
|
+
return v === null ? null : [decl("max-width", v)];
|
|
1035
|
+
}
|
|
1036
|
+
case "min-h": {
|
|
1037
|
+
const v = size();
|
|
1038
|
+
return v === null ? null : [decl("min-height", v)];
|
|
1039
|
+
}
|
|
1040
|
+
case "max-h": {
|
|
1041
|
+
const v = size();
|
|
1042
|
+
return v === null ? null : [decl("max-height", v)];
|
|
1043
|
+
}
|
|
1044
|
+
case "size": {
|
|
1045
|
+
const v = size();
|
|
1046
|
+
return v === null ? null : [decl("width", v), decl("height", v)];
|
|
1047
|
+
}
|
|
1048
|
+
case "basis": {
|
|
1049
|
+
const v = size();
|
|
1050
|
+
return v === null ? null : [decl("flex-basis", v)];
|
|
1051
|
+
}
|
|
1052
|
+
default:
|
|
1053
|
+
return null;
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
// src/jsEngine/resolvers/color.ts
|
|
1058
|
+
function lookupHex(theme, key) {
|
|
1059
|
+
return theme.colors[key] ?? null;
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
// src/jsEngine/resolvers/border.ts
|
|
1063
|
+
function radiusSize(key) {
|
|
1064
|
+
switch (key) {
|
|
1065
|
+
case "none":
|
|
1066
|
+
return "0px";
|
|
1067
|
+
case "sm":
|
|
1068
|
+
return "0.125rem";
|
|
1069
|
+
case "md":
|
|
1070
|
+
return "0.375rem";
|
|
1071
|
+
case "lg":
|
|
1072
|
+
return "0.5rem";
|
|
1073
|
+
case "xl":
|
|
1074
|
+
return "0.75rem";
|
|
1075
|
+
case "2xl":
|
|
1076
|
+
return "1rem";
|
|
1077
|
+
case "3xl":
|
|
1078
|
+
return "1.5rem";
|
|
1079
|
+
case "full":
|
|
1080
|
+
return "9999px";
|
|
1081
|
+
default:
|
|
1082
|
+
return null;
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
function borderSideProperty(side) {
|
|
1086
|
+
switch (side) {
|
|
1087
|
+
case "t":
|
|
1088
|
+
return "border-top";
|
|
1089
|
+
case "r":
|
|
1090
|
+
return "border-right";
|
|
1091
|
+
case "b":
|
|
1092
|
+
return "border-bottom";
|
|
1093
|
+
case "l":
|
|
1094
|
+
return "border-left";
|
|
1095
|
+
default:
|
|
1096
|
+
return null;
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
function borderValue(theme, parsed) {
|
|
1100
|
+
const value = parsed.value;
|
|
1101
|
+
if (value === null) return null;
|
|
1102
|
+
if (!parsed.isArbitrary) {
|
|
1103
|
+
const side = borderSideProperty(value);
|
|
1104
|
+
if (side !== null) {
|
|
1105
|
+
return [decl(`${side}-width`, "1px"), decl(`${side}-style`, "solid")];
|
|
1106
|
+
}
|
|
1107
|
+
if (value === "collapse") return [decl("border-collapse", "collapse")];
|
|
1108
|
+
if (value === "separate") return [decl("border-collapse", "separate")];
|
|
1109
|
+
}
|
|
1110
|
+
if (parsed.isArbitrary) {
|
|
1111
|
+
return [decl("border-width", value)];
|
|
1112
|
+
}
|
|
1113
|
+
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
1114
|
+
const v = resolveLength(theme, parsed);
|
|
1115
|
+
return v === null ? null : [decl("border-width", v)];
|
|
1116
|
+
}
|
|
1117
|
+
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
1118
|
+
return [decl("border-style", value)];
|
|
1119
|
+
}
|
|
1120
|
+
const hex = lookupHex(theme, value);
|
|
1121
|
+
return hex === null ? null : [decl("border-color", hex)];
|
|
1122
|
+
}
|
|
1123
|
+
function borderSideValue(theme, parsed, sideProperty) {
|
|
1124
|
+
const value = parsed.value;
|
|
1125
|
+
if (value === null) return null;
|
|
1126
|
+
if (parsed.isArbitrary) return [decl(`${sideProperty}-width`, value)];
|
|
1127
|
+
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
1128
|
+
const v = resolveLength(theme, parsed);
|
|
1129
|
+
return v === null ? null : [decl(`${sideProperty}-width`, v)];
|
|
1130
|
+
}
|
|
1131
|
+
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
1132
|
+
return [decl(`${sideProperty}-style`, value)];
|
|
1133
|
+
}
|
|
1134
|
+
const hex = lookupHex(theme, value);
|
|
1135
|
+
return hex === null ? null : [decl(`${sideProperty}-color`, hex)];
|
|
1136
|
+
}
|
|
1137
|
+
function borderAxisValue(theme, parsed, sideA, sideB) {
|
|
1138
|
+
const value = parsed.value;
|
|
1139
|
+
if (value === null) return null;
|
|
1140
|
+
if (parsed.isArbitrary) return [decl(`${sideA}-width`, value), decl(`${sideB}-width`, value)];
|
|
1141
|
+
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
1142
|
+
const v = resolveLength(theme, parsed);
|
|
1143
|
+
return v === null ? null : [decl(`${sideA}-width`, v), decl(`${sideB}-width`, v)];
|
|
1144
|
+
}
|
|
1145
|
+
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
1146
|
+
return [decl(`${sideA}-style`, value), decl(`${sideB}-style`, value)];
|
|
1147
|
+
}
|
|
1148
|
+
const hex = lookupHex(theme, value);
|
|
1149
|
+
return hex === null ? null : [decl(`${sideA}-color`, hex), decl(`${sideB}-color`, hex)];
|
|
1150
|
+
}
|
|
1151
|
+
function radiusProperties(side) {
|
|
1152
|
+
switch (side) {
|
|
1153
|
+
case "t":
|
|
1154
|
+
return ["border-top-left-radius", "border-top-right-radius"];
|
|
1155
|
+
case "r":
|
|
1156
|
+
return ["border-top-right-radius", "border-bottom-right-radius"];
|
|
1157
|
+
case "b":
|
|
1158
|
+
return ["border-bottom-right-radius", "border-bottom-left-radius"];
|
|
1159
|
+
case "l":
|
|
1160
|
+
return ["border-top-left-radius", "border-bottom-left-radius"];
|
|
1161
|
+
case "tl":
|
|
1162
|
+
return ["border-top-left-radius"];
|
|
1163
|
+
case "tr":
|
|
1164
|
+
return ["border-top-right-radius"];
|
|
1165
|
+
case "br":
|
|
1166
|
+
return ["border-bottom-right-radius"];
|
|
1167
|
+
case "bl":
|
|
1168
|
+
return ["border-bottom-left-radius"];
|
|
1169
|
+
default:
|
|
1170
|
+
return null;
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
function resolveRadiusValue(theme, parsed) {
|
|
1174
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
1175
|
+
const size = radiusSize(parsed.value);
|
|
1176
|
+
if (size !== null) return size;
|
|
1177
|
+
}
|
|
1178
|
+
return resolveLength(theme, parsed);
|
|
1179
|
+
}
|
|
1180
|
+
function resolveRadiusSide(theme, parsed, side) {
|
|
1181
|
+
const properties = radiusProperties(side);
|
|
1182
|
+
if (properties === null) return null;
|
|
1183
|
+
const value = resolveRadiusValue(theme, parsed);
|
|
1184
|
+
if (value === null) return null;
|
|
1185
|
+
return properties.map((p) => decl(p, value));
|
|
1186
|
+
}
|
|
1187
|
+
var OUTLINE_STYLES = ["solid", "dashed", "dotted", "double"];
|
|
1188
|
+
function outlineWidthValue(key) {
|
|
1189
|
+
switch (key) {
|
|
1190
|
+
case "0":
|
|
1191
|
+
return "0px";
|
|
1192
|
+
case "1":
|
|
1193
|
+
return "1px";
|
|
1194
|
+
case "2":
|
|
1195
|
+
return "2px";
|
|
1196
|
+
case "4":
|
|
1197
|
+
return "4px";
|
|
1198
|
+
case "8":
|
|
1199
|
+
return "8px";
|
|
1200
|
+
default:
|
|
1201
|
+
return null;
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
function outlineValue(theme, parsed) {
|
|
1205
|
+
const value = parsed.value;
|
|
1206
|
+
if (value === null) return null;
|
|
1207
|
+
if (parsed.isArbitrary) return [decl("outline-width", value)];
|
|
1208
|
+
const w = outlineWidthValue(value);
|
|
1209
|
+
if (w !== null) return [decl("outline-width", w)];
|
|
1210
|
+
if (OUTLINE_STYLES.includes(value)) return [decl("outline-style", value)];
|
|
1211
|
+
const hex = lookupHex(theme, value);
|
|
1212
|
+
return hex === null ? null : [decl("outline-color", hex)];
|
|
1213
|
+
}
|
|
1214
|
+
function outlineOffsetValue(parsed) {
|
|
1215
|
+
const value = parsed.value;
|
|
1216
|
+
if (value === null) return null;
|
|
1217
|
+
if (parsed.isArbitrary) return [decl("outline-offset", value)];
|
|
1218
|
+
const w = outlineWidthValue(value);
|
|
1219
|
+
return w === null ? null : [decl("outline-offset", w)];
|
|
1220
|
+
}
|
|
1221
|
+
var RING_BOX_SHADOW = "var(--kb-ring-inset,) 0 0 0 var(--kb-ring-offset-width, 0px) var(--kb-ring-offset-color, #fff), var(--kb-ring-inset,) 0 0 0 calc(var(--kb-ring-width, 0px) + var(--kb-ring-offset-width, 0px)) var(--kb-ring-color, rgba(59,130,246,0.5))";
|
|
1222
|
+
function ringWidth(key) {
|
|
1223
|
+
switch (key) {
|
|
1224
|
+
case "0":
|
|
1225
|
+
return "0px";
|
|
1226
|
+
case "1":
|
|
1227
|
+
return "1px";
|
|
1228
|
+
case "2":
|
|
1229
|
+
return "2px";
|
|
1230
|
+
case "4":
|
|
1231
|
+
return "4px";
|
|
1232
|
+
case "8":
|
|
1233
|
+
return "8px";
|
|
1234
|
+
default:
|
|
1235
|
+
return null;
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
function ringValue(theme, parsed) {
|
|
1239
|
+
const value = parsed.value;
|
|
1240
|
+
if (value === null) return null;
|
|
1241
|
+
if (value === "inset") {
|
|
1242
|
+
return [decl("--kb-ring-inset", "inset"), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1243
|
+
}
|
|
1244
|
+
if (!parsed.isArbitrary) {
|
|
1245
|
+
const w = ringWidth(value);
|
|
1246
|
+
if (w !== null) return [decl("--kb-ring-width", w), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1247
|
+
}
|
|
1248
|
+
const color = parsed.isArbitrary ? value : lookupHex(theme, value);
|
|
1249
|
+
if (color === null) return null;
|
|
1250
|
+
return [decl("--kb-ring-color", color), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1251
|
+
}
|
|
1252
|
+
function ringOffsetValue(theme, parsed) {
|
|
1253
|
+
const value = parsed.value;
|
|
1254
|
+
if (value === null) return null;
|
|
1255
|
+
if (!parsed.isArbitrary) {
|
|
1256
|
+
const w = ringWidth(value);
|
|
1257
|
+
if (w !== null) return [decl("--kb-ring-offset-width", w), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1258
|
+
}
|
|
1259
|
+
const color = parsed.isArbitrary ? value : lookupHex(theme, value);
|
|
1260
|
+
if (color === null) return null;
|
|
1261
|
+
return [decl("--kb-ring-offset-color", color), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1262
|
+
}
|
|
1263
|
+
var RADIUS_SIDES = /* @__PURE__ */ new Set(["t", "r", "b", "l", "tl", "tr", "br", "bl"]);
|
|
1264
|
+
function resolve3(parsed, theme) {
|
|
1265
|
+
switch (parsed.utility) {
|
|
1266
|
+
case "border":
|
|
1267
|
+
if (parsed.value === null) return [decl("border-width", "1px"), decl("border-style", "solid")];
|
|
1268
|
+
return borderValue(theme, parsed);
|
|
1269
|
+
case "border-t":
|
|
1270
|
+
return borderSideValue(theme, parsed, "border-top");
|
|
1271
|
+
case "border-r":
|
|
1272
|
+
return borderSideValue(theme, parsed, "border-right");
|
|
1273
|
+
case "border-b":
|
|
1274
|
+
return borderSideValue(theme, parsed, "border-bottom");
|
|
1275
|
+
case "border-l":
|
|
1276
|
+
return borderSideValue(theme, parsed, "border-left");
|
|
1277
|
+
case "border-x":
|
|
1278
|
+
return borderAxisValue(theme, parsed, "border-left", "border-right");
|
|
1279
|
+
case "border-y":
|
|
1280
|
+
return borderAxisValue(theme, parsed, "border-top", "border-bottom");
|
|
1281
|
+
case "rounded": {
|
|
1282
|
+
if (parsed.value === null) return [decl("border-radius", "0.25rem")];
|
|
1283
|
+
const value = parsed.value;
|
|
1284
|
+
if (!parsed.isArbitrary) {
|
|
1285
|
+
const size = radiusSize(value);
|
|
1286
|
+
if (size !== null) return [decl("border-radius", size)];
|
|
1287
|
+
}
|
|
1288
|
+
const v = resolveLength(theme, parsed);
|
|
1289
|
+
return v === null ? null : [decl("border-radius", v)];
|
|
1290
|
+
}
|
|
1291
|
+
case "ring":
|
|
1292
|
+
if (parsed.value === null) return [decl("--kb-ring-width", "3px"), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1293
|
+
return ringValue(theme, parsed);
|
|
1294
|
+
case "ring-offset":
|
|
1295
|
+
return ringOffsetValue(theme, parsed);
|
|
1296
|
+
case "outline":
|
|
1297
|
+
if (parsed.value === null) return [decl("outline-style", "solid")];
|
|
1298
|
+
if (parsed.value === "none") return [decl("outline", "none")];
|
|
1299
|
+
return outlineValue(theme, parsed);
|
|
1300
|
+
case "outline-offset":
|
|
1301
|
+
return outlineOffsetValue(parsed);
|
|
1302
|
+
default:
|
|
1303
|
+
if (parsed.utility.startsWith("rounded-") && RADIUS_SIDES.has(parsed.utility.slice("rounded-".length))) {
|
|
1304
|
+
return resolveRadiusSide(theme, parsed, parsed.utility.slice("rounded-".length));
|
|
1305
|
+
}
|
|
1306
|
+
return null;
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
// src/jsEngine/resolvers/typography.ts
|
|
1311
|
+
function textSize(key) {
|
|
1312
|
+
switch (key) {
|
|
1313
|
+
case "xs":
|
|
1314
|
+
return "0.75rem";
|
|
1315
|
+
case "sm":
|
|
1316
|
+
return "0.875rem";
|
|
1317
|
+
case "base":
|
|
1318
|
+
return "1rem";
|
|
1319
|
+
case "lg":
|
|
1320
|
+
return "1.125rem";
|
|
1321
|
+
case "xl":
|
|
1322
|
+
return "1.25rem";
|
|
1323
|
+
case "2xl":
|
|
1324
|
+
return "1.5rem";
|
|
1325
|
+
case "3xl":
|
|
1326
|
+
return "1.875rem";
|
|
1327
|
+
case "4xl":
|
|
1328
|
+
return "2.25rem";
|
|
1329
|
+
default:
|
|
1330
|
+
return null;
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
function lineHeightSize(key) {
|
|
1334
|
+
switch (key) {
|
|
1335
|
+
case "3":
|
|
1336
|
+
return "0.75rem";
|
|
1337
|
+
case "4":
|
|
1338
|
+
return "1rem";
|
|
1339
|
+
case "5":
|
|
1340
|
+
return "1.25rem";
|
|
1341
|
+
case "6":
|
|
1342
|
+
return "1.5rem";
|
|
1343
|
+
case "7":
|
|
1344
|
+
return "1.75rem";
|
|
1345
|
+
case "8":
|
|
1346
|
+
return "2rem";
|
|
1347
|
+
case "9":
|
|
1348
|
+
return "2.25rem";
|
|
1349
|
+
case "10":
|
|
1350
|
+
return "2.5rem";
|
|
1351
|
+
default:
|
|
1352
|
+
return null;
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
function textAlign(key) {
|
|
1356
|
+
switch (key) {
|
|
1357
|
+
case "left":
|
|
1358
|
+
return "left";
|
|
1359
|
+
case "center":
|
|
1360
|
+
return "center";
|
|
1361
|
+
case "right":
|
|
1362
|
+
return "right";
|
|
1363
|
+
case "justify":
|
|
1364
|
+
return "justify";
|
|
1365
|
+
default:
|
|
1366
|
+
return null;
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
function fontWeight(key) {
|
|
1370
|
+
switch (key) {
|
|
1371
|
+
case "thin":
|
|
1372
|
+
return "100";
|
|
1373
|
+
case "normal":
|
|
1374
|
+
return "400";
|
|
1375
|
+
case "medium":
|
|
1376
|
+
return "500";
|
|
1377
|
+
case "semibold":
|
|
1378
|
+
return "600";
|
|
1379
|
+
case "bold":
|
|
1380
|
+
return "700";
|
|
1381
|
+
case "extrabold":
|
|
1382
|
+
return "800";
|
|
1383
|
+
default:
|
|
1384
|
+
return null;
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
// src/jsEngine/resolvers/effects.ts
|
|
1389
|
+
function nativeShadowValue(key) {
|
|
1390
|
+
switch (key) {
|
|
1391
|
+
case "sm":
|
|
1392
|
+
return { offsetY: 1, radius: 2, opacity: 0.05, elevation: 1 };
|
|
1393
|
+
case "DEFAULT":
|
|
1394
|
+
return { offsetY: 1, radius: 3, opacity: 0.1, elevation: 2 };
|
|
1395
|
+
case "md":
|
|
1396
|
+
return { offsetY: 4, radius: 6, opacity: 0.1, elevation: 4 };
|
|
1397
|
+
case "lg":
|
|
1398
|
+
return { offsetY: 10, radius: 15, opacity: 0.1, elevation: 8 };
|
|
1399
|
+
case "xl":
|
|
1400
|
+
return { offsetY: 20, radius: 25, opacity: 0.1, elevation: 12 };
|
|
1401
|
+
case "2xl":
|
|
1402
|
+
return { offsetY: 25, radius: 50, opacity: 0.25, elevation: 16 };
|
|
1403
|
+
case "none":
|
|
1404
|
+
return { offsetY: 0, radius: 0, opacity: 0, elevation: 0 };
|
|
1405
|
+
default:
|
|
1406
|
+
return null;
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
function nativeShadowDeclarations(parsed) {
|
|
1410
|
+
if (parsed.utility !== "shadow" || parsed.isArbitrary) return null;
|
|
1411
|
+
const key = parsed.value ?? "DEFAULT";
|
|
1412
|
+
const s = nativeShadowValue(key);
|
|
1413
|
+
if (s === null) return null;
|
|
1414
|
+
return [
|
|
1415
|
+
decl("shadow-color", "#000000"),
|
|
1416
|
+
decl("shadow-offset-x", "0"),
|
|
1417
|
+
decl("shadow-offset-y", String(s.offsetY)),
|
|
1418
|
+
decl("shadow-opacity", String(s.opacity)),
|
|
1419
|
+
decl("shadow-radius", String(s.radius)),
|
|
1420
|
+
decl("elevation", String(s.elevation))
|
|
1421
|
+
];
|
|
1422
|
+
}
|
|
1423
|
+
|
|
1424
|
+
// src/jsEngine/resolveUtilityNative.ts
|
|
1425
|
+
function resolveTypographyNative(parsed) {
|
|
1426
|
+
switch (parsed.utility) {
|
|
1427
|
+
case "font": {
|
|
1428
|
+
if (parsed.value === null) return null;
|
|
1429
|
+
const w = fontWeight(parsed.value);
|
|
1430
|
+
return w === null ? null : [decl("font-weight", w)];
|
|
1431
|
+
}
|
|
1432
|
+
case "uppercase":
|
|
1433
|
+
return [decl("text-transform", "uppercase")];
|
|
1434
|
+
case "lowercase":
|
|
1435
|
+
return [decl("text-transform", "lowercase")];
|
|
1436
|
+
case "capitalize":
|
|
1437
|
+
return [decl("text-transform", "capitalize")];
|
|
1438
|
+
case "underline":
|
|
1439
|
+
return [decl("text-decoration-line", "underline")];
|
|
1440
|
+
case "line-through":
|
|
1441
|
+
return [decl("text-decoration-line", "line-through")];
|
|
1442
|
+
case "no-underline":
|
|
1443
|
+
return [decl("text-decoration-line", "none")];
|
|
1444
|
+
case "italic":
|
|
1445
|
+
return [decl("font-style", "italic")];
|
|
1446
|
+
case "not-italic":
|
|
1447
|
+
return [decl("font-style", "normal")];
|
|
1448
|
+
default:
|
|
1449
|
+
return null;
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
function resolveLeadingTrackingNative(parsed) {
|
|
1453
|
+
const value = parsed.value;
|
|
1454
|
+
if (value === null) return null;
|
|
1455
|
+
if (parsed.utility === "leading") {
|
|
1456
|
+
if (parsed.isArbitrary) return [decl("line-height", value)];
|
|
1457
|
+
const v = lineHeightSize(value);
|
|
1458
|
+
return v === null ? null : [decl("line-height", v)];
|
|
1459
|
+
}
|
|
1460
|
+
if (parsed.utility === "tracking" && parsed.isArbitrary) {
|
|
1461
|
+
return [decl("letter-spacing", value)];
|
|
1462
|
+
}
|
|
1463
|
+
return null;
|
|
1464
|
+
}
|
|
1465
|
+
function nativeHexColor(parsed, theme) {
|
|
1466
|
+
const value = parsed.value;
|
|
1467
|
+
if (value === null) return null;
|
|
1468
|
+
return parsed.isArbitrary ? value : lookupHex(theme, value);
|
|
1469
|
+
}
|
|
1470
|
+
function resolveTextNative(parsed, theme) {
|
|
1471
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
1472
|
+
const size = textSize(parsed.value);
|
|
1473
|
+
if (size !== null) return [decl("font-size", size)];
|
|
1474
|
+
const align = textAlign(parsed.value);
|
|
1475
|
+
if (align !== null) return [decl("text-align", align)];
|
|
1476
|
+
}
|
|
1477
|
+
const hex = nativeHexColor(parsed, theme);
|
|
1478
|
+
return hex === null ? null : [decl("color", hex)];
|
|
1479
|
+
}
|
|
1480
|
+
function resolveColorNative(parsed, theme) {
|
|
1481
|
+
switch (parsed.utility) {
|
|
1482
|
+
case "bg": {
|
|
1483
|
+
const hex = nativeHexColor(parsed, theme);
|
|
1484
|
+
return hex === null ? null : [decl("background-color", hex)];
|
|
1485
|
+
}
|
|
1486
|
+
case "text":
|
|
1487
|
+
return resolveTextNative(parsed, theme);
|
|
1488
|
+
default:
|
|
1489
|
+
return null;
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
function resolveUtilityNative(parsed, theme) {
|
|
1493
|
+
return resolveFlex(parsed, false) ?? resolve(parsed, theme) ?? resolve2(parsed, theme) ?? resolve3(parsed, theme) ?? resolveColorNative(parsed, theme) ?? resolveLeadingTrackingNative(parsed) ?? resolveTypographyNative(parsed) ?? nativeShadowDeclarations(parsed);
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
// src/jsEngine/resolveStyle.ts
|
|
1497
|
+
var RESPONSIVE_BREAKPOINTS = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
|
|
1498
|
+
function nativeModifierState(modifier, theme, colorScheme, pressed, width) {
|
|
1499
|
+
if (modifier === "dark") return colorScheme === "dark";
|
|
1500
|
+
if (modifier === "active") return pressed;
|
|
1501
|
+
if (RESPONSIVE_BREAKPOINTS.has(modifier)) {
|
|
1502
|
+
const minWidth = theme.screens[modifier];
|
|
1503
|
+
if (minWidth === void 0) return null;
|
|
1504
|
+
return width >= minWidth;
|
|
1505
|
+
}
|
|
1506
|
+
return null;
|
|
1507
|
+
}
|
|
1508
|
+
function kebabToCamel(s) {
|
|
1509
|
+
return s.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
1510
|
+
}
|
|
1511
|
+
var NUMERIC_LENGTH_PROPS = /* @__PURE__ */ new Set([
|
|
1512
|
+
"padding",
|
|
1513
|
+
"padding-top",
|
|
1514
|
+
"padding-right",
|
|
1515
|
+
"padding-bottom",
|
|
1516
|
+
"padding-left",
|
|
1517
|
+
"margin",
|
|
1518
|
+
"margin-top",
|
|
1519
|
+
"margin-right",
|
|
1520
|
+
"margin-bottom",
|
|
1521
|
+
"margin-left",
|
|
1522
|
+
"gap",
|
|
1523
|
+
"column-gap",
|
|
1524
|
+
"row-gap",
|
|
1525
|
+
"width",
|
|
1526
|
+
"height",
|
|
1527
|
+
"min-width",
|
|
1528
|
+
"max-width",
|
|
1529
|
+
"min-height",
|
|
1530
|
+
"max-height",
|
|
1531
|
+
"top",
|
|
1532
|
+
"right",
|
|
1533
|
+
"bottom",
|
|
1534
|
+
"left",
|
|
1535
|
+
"inset",
|
|
1536
|
+
"border-radius",
|
|
1537
|
+
"border-width",
|
|
1538
|
+
"font-size",
|
|
1539
|
+
"z-index",
|
|
1540
|
+
"line-height",
|
|
1541
|
+
"letter-spacing",
|
|
1542
|
+
"flex",
|
|
1543
|
+
"flex-grow",
|
|
1544
|
+
"flex-shrink",
|
|
1545
|
+
"order",
|
|
1546
|
+
"flex-basis",
|
|
1547
|
+
"shadow-opacity",
|
|
1548
|
+
"shadow-radius",
|
|
1549
|
+
"elevation",
|
|
1550
|
+
// Per-side border width + per-corner radius — see resolvers/border.ts's
|
|
1551
|
+
// new borderSideValue/borderAxisValue/resolveRadiusSide additions; RN's
|
|
1552
|
+
// style system wants plain numbers for these exactly like the generic
|
|
1553
|
+
// "border-width"/"border-radius" forms above.
|
|
1554
|
+
"border-top-width",
|
|
1555
|
+
"border-right-width",
|
|
1556
|
+
"border-bottom-width",
|
|
1557
|
+
"border-left-width",
|
|
1558
|
+
"border-top-left-radius",
|
|
1559
|
+
"border-top-right-radius",
|
|
1560
|
+
"border-bottom-right-radius",
|
|
1561
|
+
"border-bottom-left-radius",
|
|
1562
|
+
"outline-width",
|
|
1563
|
+
"outline-offset"
|
|
1564
|
+
]);
|
|
1565
|
+
function rnStyleValue(property, value) {
|
|
1566
|
+
if (NUMERIC_LENGTH_PROPS.has(property)) {
|
|
1567
|
+
let px = null;
|
|
1568
|
+
if (value.endsWith("px")) {
|
|
1569
|
+
const n = Number(value.slice(0, -2));
|
|
1570
|
+
px = Number.isFinite(n) ? n : null;
|
|
1571
|
+
} else if (value.endsWith("rem")) {
|
|
1572
|
+
const n = Number(value.slice(0, -3));
|
|
1573
|
+
px = Number.isFinite(n) ? n * 16 : null;
|
|
1574
|
+
} else {
|
|
1575
|
+
const n = Number(value);
|
|
1576
|
+
px = value.trim() !== "" && Number.isFinite(n) ? n : null;
|
|
1577
|
+
}
|
|
1578
|
+
if (px !== null) return px;
|
|
1579
|
+
}
|
|
1580
|
+
return value;
|
|
1581
|
+
}
|
|
1582
|
+
function resolveStyleJs(classString, theme, colorScheme, pressed, width) {
|
|
1583
|
+
const style = {};
|
|
1584
|
+
let shadowOffset = null;
|
|
1585
|
+
for (const token of classString.split(/\s+/).filter(Boolean)) {
|
|
1586
|
+
const parsed = parseClass(token);
|
|
1587
|
+
const allModifiersHold = parsed.modifiers.every(
|
|
1588
|
+
(m) => nativeModifierState(m, theme, colorScheme, pressed, width) === true
|
|
1589
|
+
);
|
|
1590
|
+
if (!allModifiersHold) continue;
|
|
1591
|
+
const decls = resolveUtilityNative(parsed, theme);
|
|
1592
|
+
if (decls === null) continue;
|
|
1593
|
+
for (const d of decls) {
|
|
1594
|
+
if (d.property.startsWith("__")) {
|
|
1595
|
+
continue;
|
|
1596
|
+
}
|
|
1597
|
+
if (d.property === "shadow-offset-x" || d.property === "shadow-offset-y") {
|
|
1598
|
+
const n = Number(d.value);
|
|
1599
|
+
if (!Number.isFinite(n)) continue;
|
|
1600
|
+
if (shadowOffset === null) shadowOffset = {};
|
|
1601
|
+
shadowOffset[d.property === "shadow-offset-x" ? "width" : "height"] = n;
|
|
1602
|
+
continue;
|
|
1603
|
+
}
|
|
1604
|
+
style[kebabToCamel(d.property)] = rnStyleValue(d.property, d.value);
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
if (shadowOffset !== null) {
|
|
1608
|
+
style.shadowOffset = { width: shadowOffset.width ?? 0, height: shadowOffset.height ?? 0 };
|
|
1609
|
+
}
|
|
1610
|
+
return style;
|
|
1611
|
+
}
|
|
1612
|
+
|
|
398
1613
|
// src/nativeBridge.ts
|
|
399
1614
|
function resolveStyle(classString, pressed = false) {
|
|
400
|
-
const KbachModule = import_react_native3.TurboModuleRegistry.getEnforcing("KbachModule");
|
|
401
1615
|
const colorScheme = getGlobalDarkMode() ? "dark" : "light";
|
|
402
1616
|
const width = import_react_native3.Dimensions.get("window").width;
|
|
1617
|
+
const KbachModule = import_react_native3.TurboModuleRegistry.get("KbachModule");
|
|
1618
|
+
if (!KbachModule) {
|
|
1619
|
+
return resolveStyleJs(classString, getTheme(), colorScheme, pressed, width);
|
|
1620
|
+
}
|
|
403
1621
|
const json = KbachModule.resolveStyle(classString, getThemeJson(), colorScheme, pressed, width);
|
|
404
1622
|
return JSON.parse(json);
|
|
405
1623
|
}
|