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

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.
@@ -10,13 +10,13 @@ import {
10
10
  subscribeDynamicTokens,
11
11
  subscribeGlobalDarkMode,
12
12
  toggleGlobalDarkMode
13
- } from "./chunk-YYCSHELO.mjs";
13
+ } from "./chunk-KT6TQLWI.mjs";
14
14
  import {
15
15
  defaultTheme,
16
16
  getTheme,
17
17
  resolveClassName,
18
18
  setTheme
19
- } from "./chunk-A3PV4XGK.mjs";
19
+ } from "./chunk-DKZM4NUU.mjs";
20
20
 
21
21
  // src/config.ts
22
22
  function parseHexRgb(hex) {
@@ -43,14 +43,20 @@ function findModeAwareColor(base, theme) {
43
43
  const rest = important ? base.slice(1) : base;
44
44
  for (const prefix of MODE_AWARE_COLOR_PREFIXES) {
45
45
  if (!rest.startsWith(prefix)) continue;
46
- const value = rest.slice(prefix.length);
47
- const entry = theme.colors[value];
46
+ const [name, opacity] = splitOpacity(rest.slice(prefix.length));
47
+ const entry = theme.colors[name];
48
48
  if (typeof entry === "object" && entry !== null) {
49
- return { prefix: `${important}${prefix}`, light: entry.light, dark: entry.dark };
49
+ return { prefix: `${important}${prefix}`, opacity, light: entry.light, dark: entry.dark };
50
50
  }
51
51
  }
52
52
  return null;
53
53
  }
54
+ function applyOpacityToHex(hex, opacity) {
55
+ if (opacity === null) return hex;
56
+ const rgb = hexToRgb(hex);
57
+ if (rgb === null) return hex;
58
+ return `rgba(${rgb.join(",")},${opacity / 100})`;
59
+ }
54
60
  function substituteModeAwareColorToken(token, theme, colorScheme) {
55
61
  const segments = token.split(":");
56
62
  const base = segments.pop() ?? token;
@@ -58,7 +64,7 @@ function substituteModeAwareColorToken(token, theme, colorScheme) {
58
64
  const found = findModeAwareColor(base, theme);
59
65
  if (found === null) return token;
60
66
  const hex = colorScheme === "dark" ? found.dark : found.light;
61
- return `${modifierPrefix}${found.prefix}[${hex}]`;
67
+ return `${modifierPrefix}${found.prefix}[${applyOpacityToHex(hex, found.opacity)}]`;
62
68
  }
63
69
  function classStringUsesModeAwareColor(classString, theme) {
64
70
  return classString.split(/\s+/).some((rawToken) => {
@@ -98,6 +104,12 @@ function colorValue(theme, parsed) {
98
104
  if (rgb === null) return hex;
99
105
  return `rgba(${rgb.join(",")},${opacity / 100})`;
100
106
  }
107
+ var LENGTH_UNITS = ["px", "rem", "em", "%", "vh", "vw"];
108
+ function looksLikeLength(value) {
109
+ const unit = LENGTH_UNITS.find((u) => value.endsWith(u));
110
+ const withoutUnit = unit ? value.slice(0, value.length - unit.length) : value;
111
+ return withoutUnit !== "" && Number.isFinite(Number(withoutUnit));
112
+ }
101
113
 
102
114
  // src/jsxRuntimeCore.ts
103
115
  var import_dynamicTokens = require("./dynamicTokens");
@@ -1497,7 +1509,9 @@ function borderValue(theme, parsed) {
1497
1509
  if (value === "separate") return [decl("border-collapse", "separate")];
1498
1510
  }
1499
1511
  if (parsed.isArbitrary) {
1500
- return [decl("border-width", value)];
1512
+ if (looksLikeLength(value)) return [decl("border-width", value)];
1513
+ const color2 = colorValue(theme, parsed);
1514
+ return color2 === null ? null : [decl("border-color", color2)];
1501
1515
  }
1502
1516
  if (Number.isFinite(Number(value)) && value.trim() !== "") {
1503
1517
  const v = resolveLength(theme, parsed);
@@ -1512,7 +1526,11 @@ function borderValue(theme, parsed) {
1512
1526
  function borderSideValue(theme, parsed, sideProperty) {
1513
1527
  const value = parsed.value;
1514
1528
  if (value === null) return null;
1515
- if (parsed.isArbitrary) return [decl(`${sideProperty}-width`, value)];
1529
+ if (parsed.isArbitrary) {
1530
+ if (looksLikeLength(value)) return [decl(`${sideProperty}-width`, value)];
1531
+ const color2 = colorValue(theme, parsed);
1532
+ return color2 === null ? null : [decl(`${sideProperty}-color`, color2)];
1533
+ }
1516
1534
  if (Number.isFinite(Number(value)) && value.trim() !== "") {
1517
1535
  const v = resolveLength(theme, parsed);
1518
1536
  return v === null ? null : [decl(`${sideProperty}-width`, v)];
@@ -1526,7 +1544,11 @@ function borderSideValue(theme, parsed, sideProperty) {
1526
1544
  function borderAxisValue(theme, parsed, sideA, sideB) {
1527
1545
  const value = parsed.value;
1528
1546
  if (value === null) return null;
1529
- if (parsed.isArbitrary) return [decl(`${sideA}-width`, value), decl(`${sideB}-width`, value)];
1547
+ if (parsed.isArbitrary) {
1548
+ if (looksLikeLength(value)) return [decl(`${sideA}-width`, value), decl(`${sideB}-width`, value)];
1549
+ const color2 = colorValue(theme, parsed);
1550
+ return color2 === null ? null : [decl(`${sideA}-color`, color2), decl(`${sideB}-color`, color2)];
1551
+ }
1530
1552
  if (Number.isFinite(Number(value)) && value.trim() !== "") {
1531
1553
  const v = resolveLength(theme, parsed);
1532
1554
  return v === null ? null : [decl(`${sideA}-width`, v), decl(`${sideB}-width`, v)];
@@ -1593,7 +1615,11 @@ function outlineWidthValue(key) {
1593
1615
  function outlineValue(theme, parsed) {
1594
1616
  const value = parsed.value;
1595
1617
  if (value === null) return null;
1596
- if (parsed.isArbitrary) return [decl("outline-width", value)];
1618
+ if (parsed.isArbitrary) {
1619
+ if (looksLikeLength(value)) return [decl("outline-width", value)];
1620
+ const color2 = colorValue(theme, parsed);
1621
+ return color2 === null ? null : [decl("outline-color", color2)];
1622
+ }
1597
1623
  const w = outlineWidthValue(value);
1598
1624
  if (w !== null) return [decl("outline-width", w)];
1599
1625
  if (OUTLINE_STYLES.includes(value)) return [decl("outline-style", value)];