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

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-3LNPXJEW.mjs";
10
+ } from "./chunk-ZB2UU6EO.mjs";
11
11
  import {
12
12
  getGlobalDarkMode,
13
13
  getGlobalThemeMode,
@@ -424,6 +424,10 @@ function notify() {
424
424
  function getGlobalDarkMode() {
425
425
  return isDark;
426
426
  }
427
+ function subscribeGlobalDarkMode(listener) {
428
+ listeners.add(listener);
429
+ return () => listeners.delete(listener);
430
+ }
427
431
 
428
432
  // src/jsxRuntimeCore.ts
429
433
  function makeElement(isStaticChildren, type, props, key) {
@@ -443,6 +447,21 @@ var DARK_MODIFIER_RE = /(^|\s)dark:/;
443
447
  function darkModeKeySuffix(classStrRaw) {
444
448
  return DARK_MODIFIER_RE.test(classStrRaw) ? `:kb-dark-${getGlobalDarkMode()}` : "";
445
449
  }
450
+ function DarkAwareElement({
451
+ hostType,
452
+ hostRest,
453
+ classStrRaw,
454
+ userStyle,
455
+ resolveStyle: resolveStyle2,
456
+ elementKey,
457
+ isStaticChildren
458
+ }) {
459
+ (0, import_react.useSyncExternalStore)(subscribeGlobalDarkMode, getGlobalDarkMode);
460
+ const finalStyle = hostType === import_react_native2.Pressable ? (state) => resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, state.pressed) : resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, false);
461
+ const suffix = darkModeKeySuffix(classStrRaw);
462
+ const finalKey = suffix ? `${elementKey ?? ""}${suffix}` : elementKey;
463
+ return makeElement(isStaticChildren, hostType, { ...hostRest, style: finalStyle }, finalKey);
464
+ }
446
465
  function processElement(resolveStyle2, type, rawProps, key, isStaticChildren) {
447
466
  if (type === null || typeof type === "symbol" || !rawProps) {
448
467
  return makeElement(isStaticChildren, type, rawProps ?? {}, key);
@@ -451,10 +470,15 @@ function processElement(resolveStyle2, type, rawProps, key, isStaticChildren) {
451
470
  if (typeof classStrRaw !== "string") {
452
471
  return makeElement(isStaticChildren, type, rawProps, key);
453
472
  }
473
+ if (DARK_MODIFIER_RE.test(classStrRaw)) {
474
+ return (0, import_jsx_runtime.jsx)(
475
+ DarkAwareElement,
476
+ { hostType: type, hostRest: rest, classStrRaw, userStyle, resolveStyle: resolveStyle2, elementKey: key, isStaticChildren },
477
+ key
478
+ );
479
+ }
454
480
  const finalStyle = type === import_react_native2.Pressable ? (state) => resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, state.pressed) : resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, false);
455
- const suffix = darkModeKeySuffix(classStrRaw);
456
- const finalKey = suffix ? `${key ?? ""}${suffix}` : key;
457
- return makeElement(isStaticChildren, type, { ...rest, style: finalStyle }, finalKey);
481
+ return makeElement(isStaticChildren, type, { ...rest, style: finalStyle }, key);
458
482
  }
459
483
  function createJsxFunctions(resolveStyle2) {
460
484
  function jsx2(type, props, key) {
@@ -1201,8 +1225,8 @@ function borderValue(theme, parsed) {
1201
1225
  if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
1202
1226
  return [decl("border-style", value)];
1203
1227
  }
1204
- const hex = lookupHex(theme, value);
1205
- return hex === null ? null : [decl("border-color", hex)];
1228
+ const color = colorValue(theme, parsed);
1229
+ return color === null ? null : [decl("border-color", color)];
1206
1230
  }
1207
1231
  function borderSideValue(theme, parsed, sideProperty) {
1208
1232
  const value = parsed.value;
@@ -1215,8 +1239,8 @@ function borderSideValue(theme, parsed, sideProperty) {
1215
1239
  if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
1216
1240
  return [decl(`${sideProperty}-style`, value)];
1217
1241
  }
1218
- const hex = lookupHex(theme, value);
1219
- return hex === null ? null : [decl(`${sideProperty}-color`, hex)];
1242
+ const color = colorValue(theme, parsed);
1243
+ return color === null ? null : [decl(`${sideProperty}-color`, color)];
1220
1244
  }
1221
1245
  function borderAxisValue(theme, parsed, sideA, sideB) {
1222
1246
  const value = parsed.value;
@@ -1229,8 +1253,8 @@ function borderAxisValue(theme, parsed, sideA, sideB) {
1229
1253
  if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
1230
1254
  return [decl(`${sideA}-style`, value), decl(`${sideB}-style`, value)];
1231
1255
  }
1232
- const hex = lookupHex(theme, value);
1233
- return hex === null ? null : [decl(`${sideA}-color`, hex), decl(`${sideB}-color`, hex)];
1256
+ const color = colorValue(theme, parsed);
1257
+ return color === null ? null : [decl(`${sideA}-color`, color), decl(`${sideB}-color`, color)];
1234
1258
  }
1235
1259
  function radiusProperties(side) {
1236
1260
  switch (side) {
@@ -1292,8 +1316,8 @@ function outlineValue(theme, parsed) {
1292
1316
  const w = outlineWidthValue(value);
1293
1317
  if (w !== null) return [decl("outline-width", w)];
1294
1318
  if (OUTLINE_STYLES.includes(value)) return [decl("outline-style", value)];
1295
- const hex = lookupHex(theme, value);
1296
- return hex === null ? null : [decl("outline-color", hex)];
1319
+ const color = colorValue(theme, parsed);
1320
+ return color === null ? null : [decl("outline-color", color)];
1297
1321
  }
1298
1322
  function outlineOffsetValue(parsed) {
1299
1323
  const value = parsed.value;
@@ -1329,7 +1353,7 @@ function ringValue(theme, parsed) {
1329
1353
  const w = ringWidth(value);
1330
1354
  if (w !== null) return [decl("--kb-ring-width", w), decl("box-shadow", RING_BOX_SHADOW)];
1331
1355
  }
1332
- const color = parsed.isArbitrary ? value : lookupHex(theme, value);
1356
+ const color = colorValue(theme, parsed);
1333
1357
  if (color === null) return null;
1334
1358
  return [decl("--kb-ring-color", color), decl("box-shadow", RING_BOX_SHADOW)];
1335
1359
  }
@@ -1340,7 +1364,7 @@ function ringOffsetValue(theme, parsed) {
1340
1364
  const w = ringWidth(value);
1341
1365
  if (w !== null) return [decl("--kb-ring-offset-width", w), decl("box-shadow", RING_BOX_SHADOW)];
1342
1366
  }
1343
- const color = parsed.isArbitrary ? value : lookupHex(theme, value);
1367
+ const color = colorValue(theme, parsed);
1344
1368
  if (color === null) return null;
1345
1369
  return [decl("--kb-ring-offset-color", color), decl("box-shadow", RING_BOX_SHADOW)];
1346
1370
  }
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  jsx,
3
3
  jsxs
4
- } from "./chunk-7AIH5MXY.mjs";
5
- import "./chunk-MGXMALPC.mjs";
4
+ } from "./chunk-WT6WH54F.mjs";
5
+ import "./chunk-JMNJCPGK.mjs";
6
6
  import {
7
7
  Fragment,
8
8
  createJsxDEV
9
- } from "./chunk-4DQXTAM3.mjs";
9
+ } from "./chunk-H57O3BJO.mjs";
10
10
  import "./chunk-RBJXE32L.mjs";
11
11
  import "./chunk-HK6PDJJK.mjs";
12
12