@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.
@@ -2,11 +2,12 @@ import {
2
2
  Fragment,
3
3
  jsx,
4
4
  jsxs
5
- } from "./chunk-YOC3SHF5.mjs";
6
- import "./chunk-H5Z24XX5.mjs";
5
+ } from "./chunk-OJIFXMLD.mjs";
6
+ import "./chunk-3LNPXJEW.mjs";
7
7
  import {
8
8
  createJsxDEV
9
- } from "./chunk-DLIXI5OW.mjs";
9
+ } from "./chunk-4DQXTAM3.mjs";
10
+ import "./chunk-RBJXE32L.mjs";
10
11
  import "./chunk-HK6PDJJK.mjs";
11
12
 
12
13
  // src/jsx-dev-runtime.web.tsx
@@ -29,43 +29,10 @@ module.exports = __toCommonJS(jsx_runtime_exports);
29
29
  // src/jsxRuntimeCore.ts
30
30
  var import_jsx_runtime = require("react/jsx-runtime");
31
31
  var import_react = require("react");
32
- var import_react_native = require("react-native");
33
- function makeElement(isStaticChildren, type, props, key) {
34
- return (isStaticChildren ? import_jsx_runtime.jsxs : import_jsx_runtime.jsx)(type, props, key);
35
- }
36
- function resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, pressed) {
37
- const resolved = resolveStyle2(classStrRaw, pressed);
38
- if (userStyle === void 0) {
39
- return resolved;
40
- }
41
- if (typeof userStyle === "function") {
42
- return [resolved, userStyle({ pressed })];
43
- }
44
- return [resolved, userStyle];
45
- }
46
- function processElement(resolveStyle2, type, rawProps, key, isStaticChildren) {
47
- if (type === null || typeof type === "symbol" || !rawProps) {
48
- return makeElement(isStaticChildren, type, rawProps ?? {}, key);
49
- }
50
- const { className: classStrRaw, style: userStyle, ...rest } = rawProps;
51
- if (typeof classStrRaw !== "string") {
52
- return makeElement(isStaticChildren, type, rawProps, key);
53
- }
54
- const finalStyle = type === import_react_native.Pressable ? (state) => resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, state.pressed) : resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, false);
55
- return makeElement(isStaticChildren, type, { ...rest, style: finalStyle }, key);
56
- }
57
- function createJsxFunctions(resolveStyle2) {
58
- function jsx2(type, props, key) {
59
- return processElement(resolveStyle2, type, props, key, false);
60
- }
61
- function jsxs2(type, props, key) {
62
- return processElement(resolveStyle2, type, props, key, true);
63
- }
64
- return { jsx: jsx2, jsxs: jsxs2 };
65
- }
32
+ var import_react_native2 = require("react-native");
66
33
 
67
- // src/nativeBridge.ts
68
- var import_react_native3 = require("react-native");
34
+ // src/darkModeStore.ts
35
+ var import_react_native = require("react-native");
69
36
 
70
37
  // src/generatedPalette.ts
71
38
  var PALETTE = {
@@ -425,10 +392,9 @@ function getThemeJson() {
425
392
  }
426
393
 
427
394
  // src/darkModeStore.ts
428
- var import_react_native2 = require("react-native");
429
395
  var listeners = /* @__PURE__ */ new Set();
430
396
  function systemPrefersDark() {
431
- return import_react_native2.Appearance.getColorScheme() === "dark";
397
+ return import_react_native.Appearance.getColorScheme() === "dark";
432
398
  }
433
399
  function resolveIsDark(m) {
434
400
  return m === "system" ? systemPrefersDark() : m === "dark";
@@ -447,7 +413,7 @@ function applyToDom(dark) {
447
413
  var mode = "system";
448
414
  var isDark = resolveIsDark(mode);
449
415
  applyToDom(isDark);
450
- var subscription = import_react_native2.Appearance.addChangeListener(({ colorScheme }) => {
416
+ var subscription = import_react_native.Appearance.addChangeListener(({ colorScheme }) => {
451
417
  if (mode !== "system") return;
452
418
  isDark = colorScheme === "dark";
453
419
  applyToDom(isDark);
@@ -460,6 +426,50 @@ function getGlobalDarkMode() {
460
426
  return isDark;
461
427
  }
462
428
 
429
+ // src/jsxRuntimeCore.ts
430
+ function makeElement(isStaticChildren, type, props, key) {
431
+ return (isStaticChildren ? import_jsx_runtime.jsxs : import_jsx_runtime.jsx)(type, props, key);
432
+ }
433
+ function resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, pressed) {
434
+ const resolved = resolveStyle2(classStrRaw, pressed);
435
+ if (userStyle === void 0) {
436
+ return resolved;
437
+ }
438
+ if (typeof userStyle === "function") {
439
+ return [resolved, userStyle({ pressed })];
440
+ }
441
+ return [resolved, userStyle];
442
+ }
443
+ var DARK_MODIFIER_RE = /(^|\s)dark:/;
444
+ function darkModeKeySuffix(classStrRaw) {
445
+ return DARK_MODIFIER_RE.test(classStrRaw) ? `:kb-dark-${getGlobalDarkMode()}` : "";
446
+ }
447
+ function processElement(resolveStyle2, type, rawProps, key, isStaticChildren) {
448
+ if (type === null || typeof type === "symbol" || !rawProps) {
449
+ return makeElement(isStaticChildren, type, rawProps ?? {}, key);
450
+ }
451
+ const { className: classStrRaw, style: userStyle, ...rest } = rawProps;
452
+ if (typeof classStrRaw !== "string") {
453
+ return makeElement(isStaticChildren, type, rawProps, key);
454
+ }
455
+ const finalStyle = type === import_react_native2.Pressable ? (state) => resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, state.pressed) : resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, false);
456
+ const suffix = darkModeKeySuffix(classStrRaw);
457
+ const finalKey = suffix ? `${key ?? ""}${suffix}` : key;
458
+ return makeElement(isStaticChildren, type, { ...rest, style: finalStyle }, finalKey);
459
+ }
460
+ function createJsxFunctions(resolveStyle2) {
461
+ function jsx2(type, props, key) {
462
+ return processElement(resolveStyle2, type, props, key, false);
463
+ }
464
+ function jsxs2(type, props, key) {
465
+ return processElement(resolveStyle2, type, props, key, true);
466
+ }
467
+ return { jsx: jsx2, jsxs: jsxs2 };
468
+ }
469
+
470
+ // src/nativeBridge.ts
471
+ var import_react_native3 = require("react-native");
472
+
463
473
  // src/jsEngine/parser.ts
464
474
  var VALUE_PREFIXES = [
465
475
  "bg-opacity-",
@@ -1093,6 +1103,36 @@ function lookupHex(theme, key) {
1093
1103
  const entry = theme.colors[key];
1094
1104
  return typeof entry === "string" ? entry : null;
1095
1105
  }
1106
+ function hexToRgb(hex) {
1107
+ const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
1108
+ if (!m) return null;
1109
+ let h = m[1];
1110
+ if (h.length === 3) h = h.split("").map((c) => c + c).join("");
1111
+ const n = parseInt(h, 16);
1112
+ return [n >> 16 & 255, n >> 8 & 255, n & 255];
1113
+ }
1114
+ function splitOpacity(value) {
1115
+ const slash = value.lastIndexOf("/");
1116
+ if (slash === -1) return [value, null];
1117
+ const opacityText = value.slice(slash + 1);
1118
+ const n = Number(opacityText);
1119
+ if (opacityText !== "" && Number.isInteger(n) && n >= 0 && n <= 100) {
1120
+ return [value.slice(0, slash), n];
1121
+ }
1122
+ return [value, null];
1123
+ }
1124
+ function colorValue(theme, parsed) {
1125
+ const value = parsed.value;
1126
+ if (value === null) return null;
1127
+ if (parsed.isArbitrary) return value;
1128
+ const [name, opacity] = splitOpacity(value);
1129
+ const hex = lookupHex(theme, name);
1130
+ if (hex === null) return null;
1131
+ if (opacity === null) return hex;
1132
+ const rgb = hexToRgb(hex);
1133
+ if (rgb === null) return hex;
1134
+ return `rgba(${rgb.join(",")},${opacity / 100})`;
1135
+ }
1096
1136
 
1097
1137
  // src/jsEngine/resolvers/border.ts
1098
1138
  function radiusSize(key) {
@@ -1498,9 +1538,7 @@ function resolveLeadingTrackingNative(parsed) {
1498
1538
  return null;
1499
1539
  }
1500
1540
  function nativeHexColor(parsed, theme) {
1501
- const value = parsed.value;
1502
- if (value === null) return null;
1503
- return parsed.isArbitrary ? value : lookupHex(theme, value);
1541
+ return colorValue(theme, parsed);
1504
1542
  }
1505
1543
  function resolveTextNative(parsed, theme) {
1506
1544
  if (!parsed.isArbitrary && parsed.value !== null) {
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  jsx,
3
3
  jsxs
4
- } from "./chunk-4N7UEVQL.mjs";
5
- import "./chunk-XHL653X2.mjs";
6
- import "./chunk-RBJXE32L.mjs";
4
+ } from "./chunk-7AIH5MXY.mjs";
5
+ import "./chunk-MGXMALPC.mjs";
7
6
  import {
8
7
  Fragment
9
- } from "./chunk-DLIXI5OW.mjs";
8
+ } from "./chunk-4DQXTAM3.mjs";
9
+ import "./chunk-RBJXE32L.mjs";
10
10
  import "./chunk-HK6PDJJK.mjs";
11
11
  export {
12
12
  Fragment,