@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.
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-TDWBXJH5.mjs";
8
8
  import {
9
9
  resolveClassName
10
- } from "./chunk-H5Z24XX5.mjs";
10
+ } from "./chunk-ZB2UU6EO.mjs";
11
11
  import {
12
12
  getGlobalDarkMode,
13
13
  getGlobalThemeMode,
@@ -1112,6 +1112,36 @@ function lookupHex(theme, key) {
1112
1112
  const entry = theme.colors[key];
1113
1113
  return typeof entry === "string" ? entry : null;
1114
1114
  }
1115
+ function hexToRgb(hex) {
1116
+ const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
1117
+ if (!m) return null;
1118
+ let h = m[1];
1119
+ if (h.length === 3) h = h.split("").map((c) => c + c).join("");
1120
+ const n = parseInt(h, 16);
1121
+ return [n >> 16 & 255, n >> 8 & 255, n & 255];
1122
+ }
1123
+ function splitOpacity(value) {
1124
+ const slash = value.lastIndexOf("/");
1125
+ if (slash === -1) return [value, null];
1126
+ const opacityText = value.slice(slash + 1);
1127
+ const n = Number(opacityText);
1128
+ if (opacityText !== "" && Number.isInteger(n) && n >= 0 && n <= 100) {
1129
+ return [value.slice(0, slash), n];
1130
+ }
1131
+ return [value, null];
1132
+ }
1133
+ function colorValue(theme, parsed) {
1134
+ const value = parsed.value;
1135
+ if (value === null) return null;
1136
+ if (parsed.isArbitrary) return value;
1137
+ const [name, opacity] = splitOpacity(value);
1138
+ const hex = lookupHex(theme, name);
1139
+ if (hex === null) return null;
1140
+ if (opacity === null) return hex;
1141
+ const rgb = hexToRgb(hex);
1142
+ if (rgb === null) return hex;
1143
+ return `rgba(${rgb.join(",")},${opacity / 100})`;
1144
+ }
1115
1145
 
1116
1146
  // src/jsEngine/resolvers/border.ts
1117
1147
  function radiusSize(key) {
@@ -1171,8 +1201,8 @@ function borderValue(theme, parsed) {
1171
1201
  if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
1172
1202
  return [decl("border-style", value)];
1173
1203
  }
1174
- const hex = lookupHex(theme, value);
1175
- return hex === null ? null : [decl("border-color", hex)];
1204
+ const color = colorValue(theme, parsed);
1205
+ return color === null ? null : [decl("border-color", color)];
1176
1206
  }
1177
1207
  function borderSideValue(theme, parsed, sideProperty) {
1178
1208
  const value = parsed.value;
@@ -1185,8 +1215,8 @@ function borderSideValue(theme, parsed, sideProperty) {
1185
1215
  if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
1186
1216
  return [decl(`${sideProperty}-style`, value)];
1187
1217
  }
1188
- const hex = lookupHex(theme, value);
1189
- return hex === null ? null : [decl(`${sideProperty}-color`, hex)];
1218
+ const color = colorValue(theme, parsed);
1219
+ return color === null ? null : [decl(`${sideProperty}-color`, color)];
1190
1220
  }
1191
1221
  function borderAxisValue(theme, parsed, sideA, sideB) {
1192
1222
  const value = parsed.value;
@@ -1199,8 +1229,8 @@ function borderAxisValue(theme, parsed, sideA, sideB) {
1199
1229
  if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
1200
1230
  return [decl(`${sideA}-style`, value), decl(`${sideB}-style`, value)];
1201
1231
  }
1202
- const hex = lookupHex(theme, value);
1203
- return hex === null ? null : [decl(`${sideA}-color`, hex), decl(`${sideB}-color`, hex)];
1232
+ const color = colorValue(theme, parsed);
1233
+ return color === null ? null : [decl(`${sideA}-color`, color), decl(`${sideB}-color`, color)];
1204
1234
  }
1205
1235
  function radiusProperties(side) {
1206
1236
  switch (side) {
@@ -1262,8 +1292,8 @@ function outlineValue(theme, parsed) {
1262
1292
  const w = outlineWidthValue(value);
1263
1293
  if (w !== null) return [decl("outline-width", w)];
1264
1294
  if (OUTLINE_STYLES.includes(value)) return [decl("outline-style", value)];
1265
- const hex = lookupHex(theme, value);
1266
- return hex === null ? null : [decl("outline-color", hex)];
1295
+ const color = colorValue(theme, parsed);
1296
+ return color === null ? null : [decl("outline-color", color)];
1267
1297
  }
1268
1298
  function outlineOffsetValue(parsed) {
1269
1299
  const value = parsed.value;
@@ -1299,7 +1329,7 @@ function ringValue(theme, parsed) {
1299
1329
  const w = ringWidth(value);
1300
1330
  if (w !== null) return [decl("--kb-ring-width", w), decl("box-shadow", RING_BOX_SHADOW)];
1301
1331
  }
1302
- const color = parsed.isArbitrary ? value : lookupHex(theme, value);
1332
+ const color = colorValue(theme, parsed);
1303
1333
  if (color === null) return null;
1304
1334
  return [decl("--kb-ring-color", color), decl("box-shadow", RING_BOX_SHADOW)];
1305
1335
  }
@@ -1310,7 +1340,7 @@ function ringOffsetValue(theme, parsed) {
1310
1340
  const w = ringWidth(value);
1311
1341
  if (w !== null) return [decl("--kb-ring-offset-width", w), decl("box-shadow", RING_BOX_SHADOW)];
1312
1342
  }
1313
- const color = parsed.isArbitrary ? value : lookupHex(theme, value);
1343
+ const color = colorValue(theme, parsed);
1314
1344
  if (color === null) return null;
1315
1345
  return [decl("--kb-ring-offset-color", color), decl("box-shadow", RING_BOX_SHADOW)];
1316
1346
  }
@@ -1517,9 +1547,7 @@ function resolveLeadingTrackingNative(parsed) {
1517
1547
  return null;
1518
1548
  }
1519
1549
  function nativeHexColor(parsed, theme) {
1520
- const value = parsed.value;
1521
- if (value === null) return null;
1522
- return parsed.isArbitrary ? value : lookupHex(theme, value);
1550
+ return colorValue(theme, parsed);
1523
1551
  }
1524
1552
  function resolveTextNative(parsed, theme) {
1525
1553
  if (!parsed.isArbitrary && parsed.value !== null) {
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  jsx,
3
3
  jsxs
4
- } from "./chunk-5MU6PEXV.mjs";
5
- import "./chunk-XHL653X2.mjs";
4
+ } from "./chunk-GU6DH6UE.mjs";
5
+ import "./chunk-JMNJCPGK.mjs";
6
6
  import {
7
7
  Fragment,
8
8
  createJsxDEV