@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.
@@ -1,10 +1,10 @@
1
- import "./chunk-YYCSHELO.mjs";
1
+ import "./chunk-KT6TQLWI.mjs";
2
2
  import {
3
3
  Fragment,
4
4
  jsx,
5
5
  jsxs
6
- } from "./chunk-3AY4XSVY.mjs";
7
- import "./chunk-A3PV4XGK.mjs";
6
+ } from "./chunk-UFSVFF3V.mjs";
7
+ import "./chunk-DKZM4NUU.mjs";
8
8
 
9
9
  // src/jsxRuntimeCore.ts
10
10
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -44,14 +44,20 @@ function findModeAwareColor(base, theme) {
44
44
  const rest = important ? base.slice(1) : base;
45
45
  for (const prefix of MODE_AWARE_COLOR_PREFIXES) {
46
46
  if (!rest.startsWith(prefix)) continue;
47
- const value = rest.slice(prefix.length);
48
- const entry = theme.colors[value];
47
+ const [name, opacity] = splitOpacity(rest.slice(prefix.length));
48
+ const entry = theme.colors[name];
49
49
  if (typeof entry === "object" && entry !== null) {
50
- return { prefix: `${important}${prefix}`, light: entry.light, dark: entry.dark };
50
+ return { prefix: `${important}${prefix}`, opacity, light: entry.light, dark: entry.dark };
51
51
  }
52
52
  }
53
53
  return null;
54
54
  }
55
+ function applyOpacityToHex(hex, opacity) {
56
+ if (opacity === null) return hex;
57
+ const rgb = hexToRgb(hex);
58
+ if (rgb === null) return hex;
59
+ return `rgba(${rgb.join(",")},${opacity / 100})`;
60
+ }
55
61
  function substituteModeAwareColorToken(token, theme, colorScheme) {
56
62
  const segments = token.split(":");
57
63
  const base = segments.pop() ?? token;
@@ -59,7 +65,7 @@ function substituteModeAwareColorToken(token, theme, colorScheme) {
59
65
  const found = findModeAwareColor(base, theme);
60
66
  if (found === null) return token;
61
67
  const hex = colorScheme === "dark" ? found.dark : found.light;
62
- return `${modifierPrefix}${found.prefix}[${hex}]`;
68
+ return `${modifierPrefix}${found.prefix}[${applyOpacityToHex(hex, found.opacity)}]`;
63
69
  }
64
70
  function classStringUsesModeAwareColor(classString, theme) {
65
71
  return classString.split(/\s+/).some((rawToken) => {
@@ -99,6 +105,12 @@ function colorValue(theme, parsed) {
99
105
  if (rgb === null) return hex;
100
106
  return `rgba(${rgb.join(",")},${opacity / 100})`;
101
107
  }
108
+ var LENGTH_UNITS = ["px", "rem", "em", "%", "vh", "vw"];
109
+ function looksLikeLength(value) {
110
+ const unit = LENGTH_UNITS.find((u) => value.endsWith(u));
111
+ const withoutUnit = unit ? value.slice(0, value.length - unit.length) : value;
112
+ return withoutUnit !== "" && Number.isFinite(Number(withoutUnit));
113
+ }
102
114
 
103
115
  // src/jsxRuntimeCore.ts
104
116
  var import_dynamicTokens = require("./dynamicTokens");
@@ -1488,7 +1500,9 @@ function borderValue(theme, parsed) {
1488
1500
  if (value === "separate") return [decl("border-collapse", "separate")];
1489
1501
  }
1490
1502
  if (parsed.isArbitrary) {
1491
- return [decl("border-width", value)];
1503
+ if (looksLikeLength(value)) return [decl("border-width", value)];
1504
+ const color2 = colorValue(theme, parsed);
1505
+ return color2 === null ? null : [decl("border-color", color2)];
1492
1506
  }
1493
1507
  if (Number.isFinite(Number(value)) && value.trim() !== "") {
1494
1508
  const v = resolveLength(theme, parsed);
@@ -1503,7 +1517,11 @@ function borderValue(theme, parsed) {
1503
1517
  function borderSideValue(theme, parsed, sideProperty) {
1504
1518
  const value = parsed.value;
1505
1519
  if (value === null) return null;
1506
- if (parsed.isArbitrary) return [decl(`${sideProperty}-width`, value)];
1520
+ if (parsed.isArbitrary) {
1521
+ if (looksLikeLength(value)) return [decl(`${sideProperty}-width`, value)];
1522
+ const color2 = colorValue(theme, parsed);
1523
+ return color2 === null ? null : [decl(`${sideProperty}-color`, color2)];
1524
+ }
1507
1525
  if (Number.isFinite(Number(value)) && value.trim() !== "") {
1508
1526
  const v = resolveLength(theme, parsed);
1509
1527
  return v === null ? null : [decl(`${sideProperty}-width`, v)];
@@ -1517,7 +1535,11 @@ function borderSideValue(theme, parsed, sideProperty) {
1517
1535
  function borderAxisValue(theme, parsed, sideA, sideB) {
1518
1536
  const value = parsed.value;
1519
1537
  if (value === null) return null;
1520
- if (parsed.isArbitrary) return [decl(`${sideA}-width`, value), decl(`${sideB}-width`, value)];
1538
+ if (parsed.isArbitrary) {
1539
+ if (looksLikeLength(value)) return [decl(`${sideA}-width`, value), decl(`${sideB}-width`, value)];
1540
+ const color2 = colorValue(theme, parsed);
1541
+ return color2 === null ? null : [decl(`${sideA}-color`, color2), decl(`${sideB}-color`, color2)];
1542
+ }
1521
1543
  if (Number.isFinite(Number(value)) && value.trim() !== "") {
1522
1544
  const v = resolveLength(theme, parsed);
1523
1545
  return v === null ? null : [decl(`${sideA}-width`, v), decl(`${sideB}-width`, v)];
@@ -1584,7 +1606,11 @@ function outlineWidthValue(key) {
1584
1606
  function outlineValue(theme, parsed) {
1585
1607
  const value = parsed.value;
1586
1608
  if (value === null) return null;
1587
- if (parsed.isArbitrary) return [decl("outline-width", value)];
1609
+ if (parsed.isArbitrary) {
1610
+ if (looksLikeLength(value)) return [decl("outline-width", value)];
1611
+ const color2 = colorValue(theme, parsed);
1612
+ return color2 === null ? null : [decl("outline-color", color2)];
1613
+ }
1588
1614
  const w = outlineWidthValue(value);
1589
1615
  if (w !== null) return [decl("outline-width", w)];
1590
1616
  if (OUTLINE_STYLES.includes(value)) return [decl("outline-style", value)];