@kbach/react-native 1.0.0-beta.10 → 1.0.0-beta.12

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,3 +1,7 @@
1
+ import {
2
+ getGlobalDarkMode
3
+ } from "./chunk-RBJXE32L.mjs";
4
+
1
5
  // src/jsxRuntimeCore.ts
2
6
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
7
  import { Fragment } from "react";
@@ -15,6 +19,10 @@ function resolvedStyleFor(resolveStyle, classStrRaw, userStyle, pressed) {
15
19
  }
16
20
  return [resolved, userStyle];
17
21
  }
22
+ var DARK_MODIFIER_RE = /(^|\s)dark:/;
23
+ function darkModeKeySuffix(classStrRaw) {
24
+ return DARK_MODIFIER_RE.test(classStrRaw) ? `:kb-dark-${getGlobalDarkMode()}` : "";
25
+ }
18
26
  function processElement(resolveStyle, type, rawProps, key, isStaticChildren) {
19
27
  if (type === null || typeof type === "symbol" || !rawProps) {
20
28
  return makeElement(isStaticChildren, type, rawProps ?? {}, key);
@@ -24,7 +32,9 @@ function processElement(resolveStyle, type, rawProps, key, isStaticChildren) {
24
32
  return makeElement(isStaticChildren, type, rawProps, key);
25
33
  }
26
34
  const finalStyle = type === Pressable ? (state) => resolvedStyleFor(resolveStyle, classStrRaw, userStyle, state.pressed) : resolvedStyleFor(resolveStyle, classStrRaw, userStyle, false);
27
- return makeElement(isStaticChildren, type, { ...rest, style: finalStyle }, key);
35
+ const suffix = darkModeKeySuffix(classStrRaw);
36
+ const finalKey = suffix ? `${key ?? ""}${suffix}` : key;
37
+ return makeElement(isStaticChildren, type, { ...rest, style: finalStyle }, finalKey);
28
38
  }
29
39
  function createJsxFunctions(resolveStyle) {
30
40
  function jsx(type, props, key) {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  resolveStyle
3
- } from "./chunk-XHL653X2.mjs";
3
+ } from "./chunk-MGXMALPC.mjs";
4
4
  import {
5
5
  createJsxFunctions
6
- } from "./chunk-DLIXI5OW.mjs";
6
+ } from "./chunk-4DQXTAM3.mjs";
7
7
 
8
8
  // src/jsx-runtime.tsx
9
9
  var { jsx, jsxs } = createJsxFunctions(resolveStyle);
@@ -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) {
@@ -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) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  resolveClassName
3
- } from "./chunk-H5Z24XX5.mjs";
3
+ } from "./chunk-3LNPXJEW.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
@@ -1095,6 +1095,36 @@ function lookupHex(theme, key) {
1095
1095
  const entry = theme.colors[key];
1096
1096
  return typeof entry === "string" ? entry : null;
1097
1097
  }
1098
+ function hexToRgb(hex) {
1099
+ const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
1100
+ if (!m) return null;
1101
+ let h = m[1];
1102
+ if (h.length === 3) h = h.split("").map((c) => c + c).join("");
1103
+ const n = parseInt(h, 16);
1104
+ return [n >> 16 & 255, n >> 8 & 255, n & 255];
1105
+ }
1106
+ function splitOpacity(value) {
1107
+ const slash = value.lastIndexOf("/");
1108
+ if (slash === -1) return [value, null];
1109
+ const opacityText = value.slice(slash + 1);
1110
+ const n = Number(opacityText);
1111
+ if (opacityText !== "" && Number.isInteger(n) && n >= 0 && n <= 100) {
1112
+ return [value.slice(0, slash), n];
1113
+ }
1114
+ return [value, null];
1115
+ }
1116
+ function colorValue(theme, parsed) {
1117
+ const value = parsed.value;
1118
+ if (value === null) return null;
1119
+ if (parsed.isArbitrary) return value;
1120
+ const [name, opacity] = splitOpacity(value);
1121
+ const hex = lookupHex(theme, name);
1122
+ if (hex === null) return null;
1123
+ if (opacity === null) return hex;
1124
+ const rgb = hexToRgb(hex);
1125
+ if (rgb === null) return hex;
1126
+ return `rgba(${rgb.join(",")},${opacity / 100})`;
1127
+ }
1098
1128
 
1099
1129
  // src/jsEngine/resolvers/border.ts
1100
1130
  function radiusSize(key) {
@@ -1500,9 +1530,7 @@ function resolveLeadingTrackingNative(parsed) {
1500
1530
  return null;
1501
1531
  }
1502
1532
  function nativeHexColor(parsed, theme) {
1503
- const value = parsed.value;
1504
- if (value === null) return null;
1505
- return parsed.isArbitrary ? value : lookupHex(theme, value);
1533
+ return colorValue(theme, parsed);
1506
1534
  }
1507
1535
  function resolveTextNative(parsed, theme) {
1508
1536
  if (!parsed.isArbitrary && parsed.value !== null) {
package/dist/index.mjs CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-TDWBXJH5.mjs";
8
8
  import {
9
9
  resolveStyle
10
- } from "./chunk-XHL653X2.mjs";
10
+ } from "./chunk-MGXMALPC.mjs";
11
11
  import {
12
12
  getGlobalDarkMode,
13
13
  getGlobalThemeMode,