@kbach/react-native 1.0.0-beta.42 → 1.0.0-beta.43

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-A3PV4XGK.mjs";
3
+ } from "./chunk-BTIGG7K2.mjs";
4
4
 
5
5
  // src/jsxRuntimeCoreWeb.ts
6
6
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
package/dist/index.js CHANGED
@@ -855,14 +855,20 @@ function findModeAwareColor(base, theme) {
855
855
  const rest = important ? base.slice(1) : base;
856
856
  for (const prefix of MODE_AWARE_COLOR_PREFIXES) {
857
857
  if (!rest.startsWith(prefix)) continue;
858
- const value = rest.slice(prefix.length);
859
- const entry = theme.colors[value];
858
+ const [name, opacity] = splitOpacity(rest.slice(prefix.length));
859
+ const entry = theme.colors[name];
860
860
  if (typeof entry === "object" && entry !== null) {
861
- return { prefix: `${important}${prefix}`, light: entry.light, dark: entry.dark };
861
+ return { prefix: `${important}${prefix}`, opacity, light: entry.light, dark: entry.dark };
862
862
  }
863
863
  }
864
864
  return null;
865
865
  }
866
+ function applyOpacityToHex(hex, opacity) {
867
+ if (opacity === null) return hex;
868
+ const rgb = hexToRgb(hex);
869
+ if (rgb === null) return hex;
870
+ return `rgba(${rgb.join(",")},${opacity / 100})`;
871
+ }
866
872
  function substituteModeAwareColorToken(token, theme, colorScheme) {
867
873
  const segments = token.split(":");
868
874
  const base = segments.pop() ?? token;
@@ -870,7 +876,7 @@ function substituteModeAwareColorToken(token, theme, colorScheme) {
870
876
  const found = findModeAwareColor(base, theme);
871
877
  if (found === null) return token;
872
878
  const hex = colorScheme === "dark" ? found.dark : found.light;
873
- return `${modifierPrefix}${found.prefix}[${hex}]`;
879
+ return `${modifierPrefix}${found.prefix}[${applyOpacityToHex(hex, found.opacity)}]`;
874
880
  }
875
881
  function hexToRgb(hex) {
876
882
  const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
@@ -1885,7 +1891,7 @@ function parseHexRgb(hex) {
1885
1891
  const n = parseInt(h, 16);
1886
1892
  return [n >> 16 & 255, n >> 8 & 255, n & 255];
1887
1893
  }
1888
- function applyOpacityToHex(hex, opacityText) {
1894
+ function applyOpacityToHex2(hex, opacityText) {
1889
1895
  const rgb = parseHexRgb(hex);
1890
1896
  if (!rgb) return hex;
1891
1897
  const a = Number(opacityText) / 100;
@@ -1898,7 +1904,7 @@ function resolveColorEntry(value, lookup) {
1898
1904
  const opacity = slash === -1 ? void 0 : value.slice(slash + 1);
1899
1905
  const base = lookup(name);
1900
1906
  if (base === void 0) return value;
1901
- return opacity === void 0 ? base : applyOpacityToHex(base, opacity);
1907
+ return opacity === void 0 ? base : applyOpacityToHex2(base, opacity);
1902
1908
  }
1903
1909
  function resolveColors(extend, existing) {
1904
1910
  const { dark: darkExtend, ...lightExtend } = extend;