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