@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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  resolveClassName
3
- } from "./chunk-3LNPXJEW.mjs";
3
+ } from "./chunk-ZB2UU6EO.mjs";
4
4
 
5
5
  // src/jsxRuntimeCoreWeb.ts
6
6
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -1,10 +1,11 @@
1
1
  import {
2
- getGlobalDarkMode
2
+ getGlobalDarkMode,
3
+ subscribeGlobalDarkMode
3
4
  } from "./chunk-RBJXE32L.mjs";
4
5
 
5
6
  // src/jsxRuntimeCore.ts
6
7
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
- import { Fragment } from "react";
8
+ import { Fragment, useSyncExternalStore } from "react";
8
9
  import { Pressable } from "react-native";
9
10
  function makeElement(isStaticChildren, type, props, key) {
10
11
  return (isStaticChildren ? _jsxs : _jsx)(type, props, key);
@@ -23,6 +24,21 @@ var DARK_MODIFIER_RE = /(^|\s)dark:/;
23
24
  function darkModeKeySuffix(classStrRaw) {
24
25
  return DARK_MODIFIER_RE.test(classStrRaw) ? `:kb-dark-${getGlobalDarkMode()}` : "";
25
26
  }
27
+ function DarkAwareElement({
28
+ hostType,
29
+ hostRest,
30
+ classStrRaw,
31
+ userStyle,
32
+ resolveStyle,
33
+ elementKey,
34
+ isStaticChildren
35
+ }) {
36
+ useSyncExternalStore(subscribeGlobalDarkMode, getGlobalDarkMode);
37
+ const finalStyle = hostType === Pressable ? (state) => resolvedStyleFor(resolveStyle, classStrRaw, userStyle, state.pressed) : resolvedStyleFor(resolveStyle, classStrRaw, userStyle, false);
38
+ const suffix = darkModeKeySuffix(classStrRaw);
39
+ const finalKey = suffix ? `${elementKey ?? ""}${suffix}` : elementKey;
40
+ return makeElement(isStaticChildren, hostType, { ...hostRest, style: finalStyle }, finalKey);
41
+ }
26
42
  function processElement(resolveStyle, type, rawProps, key, isStaticChildren) {
27
43
  if (type === null || typeof type === "symbol" || !rawProps) {
28
44
  return makeElement(isStaticChildren, type, rawProps ?? {}, key);
@@ -31,10 +47,15 @@ function processElement(resolveStyle, type, rawProps, key, isStaticChildren) {
31
47
  if (typeof classStrRaw !== "string") {
32
48
  return makeElement(isStaticChildren, type, rawProps, key);
33
49
  }
50
+ if (DARK_MODIFIER_RE.test(classStrRaw)) {
51
+ return _jsx(
52
+ DarkAwareElement,
53
+ { hostType: type, hostRest: rest, classStrRaw, userStyle, resolveStyle, elementKey: key, isStaticChildren },
54
+ key
55
+ );
56
+ }
34
57
  const finalStyle = type === Pressable ? (state) => resolvedStyleFor(resolveStyle, classStrRaw, userStyle, state.pressed) : resolvedStyleFor(resolveStyle, classStrRaw, userStyle, false);
35
- const suffix = darkModeKeySuffix(classStrRaw);
36
- const finalKey = suffix ? `${key ?? ""}${suffix}` : key;
37
- return makeElement(isStaticChildren, type, { ...rest, style: finalStyle }, finalKey);
58
+ return makeElement(isStaticChildren, type, { ...rest, style: finalStyle }, key);
38
59
  }
39
60
  function createJsxFunctions(resolveStyle) {
40
61
  function jsx(type, props, key) {
@@ -731,8 +731,8 @@ function borderValue(theme, parsed) {
731
731
  if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
732
732
  return [decl("border-style", value)];
733
733
  }
734
- const hex = lookupHex(theme, value);
735
- return hex === null ? null : [decl("border-color", hex)];
734
+ const color = colorValue(theme, parsed);
735
+ return color === null ? null : [decl("border-color", color)];
736
736
  }
737
737
  function borderSideValue(theme, parsed, sideProperty) {
738
738
  const value = parsed.value;
@@ -745,8 +745,8 @@ function borderSideValue(theme, parsed, sideProperty) {
745
745
  if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
746
746
  return [decl(`${sideProperty}-style`, value)];
747
747
  }
748
- const hex = lookupHex(theme, value);
749
- return hex === null ? null : [decl(`${sideProperty}-color`, hex)];
748
+ const color = colorValue(theme, parsed);
749
+ return color === null ? null : [decl(`${sideProperty}-color`, color)];
750
750
  }
751
751
  function borderAxisValue(theme, parsed, sideA, sideB) {
752
752
  const value = parsed.value;
@@ -759,8 +759,8 @@ function borderAxisValue(theme, parsed, sideA, sideB) {
759
759
  if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
760
760
  return [decl(`${sideA}-style`, value), decl(`${sideB}-style`, value)];
761
761
  }
762
- const hex = lookupHex(theme, value);
763
- return hex === null ? null : [decl(`${sideA}-color`, hex), decl(`${sideB}-color`, hex)];
762
+ const color = colorValue(theme, parsed);
763
+ return color === null ? null : [decl(`${sideA}-color`, color), decl(`${sideB}-color`, color)];
764
764
  }
765
765
  function radiusProperties(side) {
766
766
  switch (side) {
@@ -822,8 +822,8 @@ function outlineValue(theme, parsed) {
822
822
  const w = outlineWidthValue(value);
823
823
  if (w !== null) return [decl("outline-width", w)];
824
824
  if (OUTLINE_STYLES.includes(value)) return [decl("outline-style", value)];
825
- const hex = lookupHex(theme, value);
826
- return hex === null ? null : [decl("outline-color", hex)];
825
+ const color = colorValue(theme, parsed);
826
+ return color === null ? null : [decl("outline-color", color)];
827
827
  }
828
828
  function outlineOffsetValue(parsed) {
829
829
  const value = parsed.value;
@@ -859,7 +859,7 @@ function ringValue(theme, parsed) {
859
859
  const w = ringWidth(value);
860
860
  if (w !== null) return [decl("--kb-ring-width", w), decl("box-shadow", RING_BOX_SHADOW)];
861
861
  }
862
- const color = parsed.isArbitrary ? value : lookupHex(theme, value);
862
+ const color = colorValue(theme, parsed);
863
863
  if (color === null) return null;
864
864
  return [decl("--kb-ring-color", color), decl("box-shadow", RING_BOX_SHADOW)];
865
865
  }
@@ -870,7 +870,7 @@ function ringOffsetValue(theme, parsed) {
870
870
  const w = ringWidth(value);
871
871
  if (w !== null) return [decl("--kb-ring-offset-width", w), decl("box-shadow", RING_BOX_SHADOW)];
872
872
  }
873
- const color = parsed.isArbitrary ? value : lookupHex(theme, value);
873
+ const color = colorValue(theme, parsed);
874
874
  if (color === null) return null;
875
875
  return [decl("--kb-ring-offset-color", color), decl("box-shadow", RING_BOX_SHADOW)];
876
876
  }
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  resolveStyle
3
- } from "./chunk-MGXMALPC.mjs";
3
+ } from "./chunk-JMNJCPGK.mjs";
4
4
  import {
5
5
  createJsxFunctions
6
- } from "./chunk-4DQXTAM3.mjs";
6
+ } from "./chunk-H57O3BJO.mjs";
7
7
 
8
8
  // src/jsx-runtime.tsx
9
9
  var { jsx, jsxs } = createJsxFunctions(resolveStyle);