@kbach/react-native 1.0.0-beta.11 → 1.0.0-beta.13

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  resolveClassName
3
- } from "./chunk-H5Z24XX5.mjs";
3
+ } from "./chunk-ZB2UU6EO.mjs";
4
4
 
5
5
  // src/jsxRuntimeCoreWeb.ts
6
6
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  resolveStyle
3
- } from "./chunk-XHL653X2.mjs";
3
+ } from "./chunk-JMNJCPGK.mjs";
4
4
  import {
5
5
  createJsxFunctions
6
6
  } from "./chunk-4DQXTAM3.mjs";
@@ -642,6 +642,36 @@ function lookupHex(theme, key) {
642
642
  const entry = theme.colors[key];
643
643
  return typeof entry === "string" ? entry : null;
644
644
  }
645
+ function hexToRgb(hex) {
646
+ const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
647
+ if (!m) return null;
648
+ let h = m[1];
649
+ if (h.length === 3) h = h.split("").map((c) => c + c).join("");
650
+ const n = parseInt(h, 16);
651
+ return [n >> 16 & 255, n >> 8 & 255, n & 255];
652
+ }
653
+ function splitOpacity(value) {
654
+ const slash = value.lastIndexOf("/");
655
+ if (slash === -1) return [value, null];
656
+ const opacityText = value.slice(slash + 1);
657
+ const n = Number(opacityText);
658
+ if (opacityText !== "" && Number.isInteger(n) && n >= 0 && n <= 100) {
659
+ return [value.slice(0, slash), n];
660
+ }
661
+ return [value, null];
662
+ }
663
+ function colorValue(theme, parsed) {
664
+ const value = parsed.value;
665
+ if (value === null) return null;
666
+ if (parsed.isArbitrary) return value;
667
+ const [name, opacity] = splitOpacity(value);
668
+ const hex = lookupHex(theme, name);
669
+ if (hex === null) return null;
670
+ if (opacity === null) return hex;
671
+ const rgb = hexToRgb(hex);
672
+ if (rgb === null) return hex;
673
+ return `rgba(${rgb.join(",")},${opacity / 100})`;
674
+ }
645
675
 
646
676
  // src/jsEngine/resolvers/border.ts
647
677
  function radiusSize(key) {
@@ -701,8 +731,8 @@ function borderValue(theme, parsed) {
701
731
  if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
702
732
  return [decl("border-style", value)];
703
733
  }
704
- const hex = lookupHex(theme, value);
705
- return hex === null ? null : [decl("border-color", hex)];
734
+ const color = colorValue(theme, parsed);
735
+ return color === null ? null : [decl("border-color", color)];
706
736
  }
707
737
  function borderSideValue(theme, parsed, sideProperty) {
708
738
  const value = parsed.value;
@@ -715,8 +745,8 @@ function borderSideValue(theme, parsed, sideProperty) {
715
745
  if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
716
746
  return [decl(`${sideProperty}-style`, value)];
717
747
  }
718
- const hex = lookupHex(theme, value);
719
- return hex === null ? null : [decl(`${sideProperty}-color`, hex)];
748
+ const color = colorValue(theme, parsed);
749
+ return color === null ? null : [decl(`${sideProperty}-color`, color)];
720
750
  }
721
751
  function borderAxisValue(theme, parsed, sideA, sideB) {
722
752
  const value = parsed.value;
@@ -729,8 +759,8 @@ function borderAxisValue(theme, parsed, sideA, sideB) {
729
759
  if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
730
760
  return [decl(`${sideA}-style`, value), decl(`${sideB}-style`, value)];
731
761
  }
732
- const hex = lookupHex(theme, value);
733
- return hex === null ? null : [decl(`${sideA}-color`, hex), decl(`${sideB}-color`, hex)];
762
+ const color = colorValue(theme, parsed);
763
+ return color === null ? null : [decl(`${sideA}-color`, color), decl(`${sideB}-color`, color)];
734
764
  }
735
765
  function radiusProperties(side) {
736
766
  switch (side) {
@@ -792,8 +822,8 @@ function outlineValue(theme, parsed) {
792
822
  const w = outlineWidthValue(value);
793
823
  if (w !== null) return [decl("outline-width", w)];
794
824
  if (OUTLINE_STYLES.includes(value)) return [decl("outline-style", value)];
795
- const hex = lookupHex(theme, value);
796
- return hex === null ? null : [decl("outline-color", hex)];
825
+ const color = colorValue(theme, parsed);
826
+ return color === null ? null : [decl("outline-color", color)];
797
827
  }
798
828
  function outlineOffsetValue(parsed) {
799
829
  const value = parsed.value;
@@ -829,7 +859,7 @@ function ringValue(theme, parsed) {
829
859
  const w = ringWidth(value);
830
860
  if (w !== null) return [decl("--kb-ring-width", w), decl("box-shadow", RING_BOX_SHADOW)];
831
861
  }
832
- const color = parsed.isArbitrary ? value : lookupHex(theme, value);
862
+ const color = colorValue(theme, parsed);
833
863
  if (color === null) return null;
834
864
  return [decl("--kb-ring-color", color), decl("box-shadow", RING_BOX_SHADOW)];
835
865
  }
@@ -840,7 +870,7 @@ function ringOffsetValue(theme, parsed) {
840
870
  const w = ringWidth(value);
841
871
  if (w !== null) return [decl("--kb-ring-offset-width", w), decl("box-shadow", RING_BOX_SHADOW)];
842
872
  }
843
- const color = parsed.isArbitrary ? value : lookupHex(theme, value);
873
+ const color = colorValue(theme, parsed);
844
874
  if (color === null) return null;
845
875
  return [decl("--kb-ring-offset-color", color), decl("box-shadow", RING_BOX_SHADOW)];
846
876
  }
@@ -1047,9 +1077,7 @@ function resolveLeadingTrackingNative(parsed) {
1047
1077
  return null;
1048
1078
  }
1049
1079
  function nativeHexColor(parsed, theme) {
1050
- const value = parsed.value;
1051
- if (value === null) return null;
1052
- return parsed.isArbitrary ? value : lookupHex(theme, value);
1080
+ return colorValue(theme, parsed);
1053
1081
  }
1054
1082
  function resolveTextNative(parsed, theme) {
1055
1083
  if (!parsed.isArbitrary && parsed.value !== null) {