@kbach/react-native 1.0.0 → 1.1.1-beta.1

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,10 +1,10 @@
1
- import "./chunk-7CNURQSH.mjs";
1
+ import "./chunk-FSO4WVCH.mjs";
2
2
  import {
3
3
  Fragment,
4
4
  jsx,
5
5
  jsxs
6
- } from "./chunk-HYQFT32E.mjs";
7
- import "./chunk-MUPEQJRT.mjs";
6
+ } from "./chunk-6F44N62F.mjs";
7
+ import "./chunk-R7E5D3D6.mjs";
8
8
 
9
9
  // src/jsxRuntimeCore.ts
10
10
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -915,6 +915,73 @@ function parsePercentRelativeExpr(token) {
915
915
  return parsePercentRelativeMinMaxClamp(token);
916
916
  }
917
917
 
918
+ // src/jsEngine/groups.ts
919
+ function expandVariantGroups(input) {
920
+ if (!input.includes(":(")) return input;
921
+ const out = [];
922
+ for (const token of splitTopLevel(input)) expandToken(token, "", false, out);
923
+ return out.join(" ");
924
+ }
925
+ function splitTopLevel(s) {
926
+ const parts = [];
927
+ let depth = 0;
928
+ let start = -1;
929
+ for (let i = 0; i < s.length; i++) {
930
+ const ch = s[i];
931
+ if (ch === "(" || ch === "[") depth++;
932
+ else if (ch === ")" || ch === "]") depth--;
933
+ const space = /\s/.test(ch);
934
+ if (space && depth <= 0) {
935
+ if (start >= 0) {
936
+ parts.push(s.slice(start, i));
937
+ start = -1;
938
+ }
939
+ depth = Math.max(depth, 0);
940
+ } else if (start < 0 && !space) {
941
+ start = i;
942
+ }
943
+ }
944
+ if (start >= 0) parts.push(s.slice(start));
945
+ return parts;
946
+ }
947
+ function groupOpen(token) {
948
+ let brackets = 0;
949
+ for (let i = 0; i < token.length; i++) {
950
+ const ch = token[i];
951
+ if (ch === "[") brackets++;
952
+ else if (ch === "]") brackets--;
953
+ else if (ch === "(" && brackets === 0 && i > 1 && token[i - 1] === ":") return i;
954
+ }
955
+ return -1;
956
+ }
957
+ function groupClose(token, open) {
958
+ let depth = 0;
959
+ for (let i = open; i < token.length; i++) {
960
+ const ch = token[i];
961
+ if (ch === "(" || ch === "[") depth++;
962
+ else if (ch === ")" || ch === "]") {
963
+ depth--;
964
+ if (depth === 0) return ch === ")" ? i : -1;
965
+ }
966
+ }
967
+ return -1;
968
+ }
969
+ function pushClass(prefix, cls, important, out) {
970
+ if (!cls) return;
971
+ const bare = cls.split(":").pop() ?? cls;
972
+ out.push(prefix + cls + (important && !cls.endsWith("!") && !bare.startsWith("!") ? "!" : ""));
973
+ }
974
+ function expandToken(token, prefix, important, out) {
975
+ const open = groupOpen(token);
976
+ if (open < 0) return pushClass(prefix, token, important, out);
977
+ const close = groupClose(token, open);
978
+ if (close < 0) return pushClass(prefix, token, important, out);
979
+ const rest = token.slice(close + 1);
980
+ if (rest !== "" && rest !== "!") return pushClass(prefix, token, important, out);
981
+ const innerPrefix = prefix + token.slice(0, open);
982
+ for (const part of splitTopLevel(token.slice(open + 1, close))) expandToken(part, innerPrefix, rest === "!" || important, out);
983
+ }
984
+
918
985
  // src/jsxRuntimeCore.ts
919
986
  var DYNAMIC_TOKEN_MATCH_RE = /var\(--([a-zA-Z0-9-]+)\)/g;
920
987
  function substituteDynamicTokens(classStrRaw) {
@@ -1029,6 +1096,7 @@ function ReactiveElement({
1029
1096
  hostType,
1030
1097
  hostRest,
1031
1098
  classStrRaw,
1099
+ classNameProp,
1032
1100
  userStyle,
1033
1101
  resolveStyle: resolveStyle2,
1034
1102
  elementKey,
@@ -1104,7 +1172,7 @@ function ReactiveElement({
1104
1172
  return makeElement(
1105
1173
  isStaticChildren,
1106
1174
  hostType,
1107
- { ...hostRestWithLayout, className: classStrRaw, style: finalStyle },
1175
+ { ...hostRestWithLayout, className: classNameProp, style: finalStyle },
1108
1176
  elementKey
1109
1177
  );
1110
1178
  }
@@ -1112,20 +1180,21 @@ function processElement(resolveStyle2, type, rawProps, key, isStaticChildren) {
1112
1180
  if (type === null || typeof type === "symbol" || !rawProps) {
1113
1181
  return makeElement(isStaticChildren, type, rawProps ?? {}, key);
1114
1182
  }
1115
- const { className: classStrRaw, style: userStyle, ...rest } = rawProps;
1116
- if (typeof classStrRaw !== "string") {
1183
+ const { className: classNameProp, style: userStyle, ...rest } = rawProps;
1184
+ if (typeof classNameProp !== "string") {
1117
1185
  return makeElement(isStaticChildren, type, rawProps, key);
1118
1186
  }
1187
+ const classStrRaw = classNameProp.includes(":(") ? expandVariantGroups(classNameProp) : classNameProp;
1119
1188
  if (DARK_MODIFIER_RE.test(classStrRaw) || BREAKPOINT_MODIFIER_RE.test(classStrRaw) || HOVER_MODIFIER_RE.test(classStrRaw) || FOCUS_MODIFIER_RE.test(classStrRaw) || classStrRaw.includes("var(--") || PERCENT_RELATIVE_CALC_HINT_RE.test(classStrRaw) || usesModeAwareColor(classStrRaw)) {
1120
1189
  return (0, import_jsx_runtime.jsx)(
1121
1190
  ReactiveElement,
1122
- { hostType: type, hostRest: rest, classStrRaw, userStyle, resolveStyle: resolveStyle2, elementKey: key, isStaticChildren },
1191
+ { hostType: type, hostRest: rest, classStrRaw, classNameProp, userStyle, resolveStyle: resolveStyle2, elementKey: key, isStaticChildren },
1123
1192
  key
1124
1193
  );
1125
1194
  }
1126
1195
  const staticStates = { hover: false, focus: false, disabled: rest.disabled === true };
1127
1196
  const finalStyle = type === import_react_native.Pressable ? (state) => resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, state.pressed, rest, void 0, staticStates) : resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, false, rest, void 0, staticStates);
1128
- return makeElement(isStaticChildren, type, { ...rest, className: classStrRaw, style: finalStyle }, key);
1197
+ return makeElement(isStaticChildren, type, { ...rest, className: classNameProp, style: finalStyle }, key);
1129
1198
  }
1130
1199
  function createJsxFunctions(resolveStyle2) {
1131
1200
  function jsx2(type, props, key) {
@@ -2441,6 +2510,7 @@ Fix: use a plain px/rem calc, a fraction utility (e.g. w-1/2), or resolve this v
2441
2510
  return { value: null, warning };
2442
2511
  }
2443
2512
  function resolveStyleJsWithWarnings(classString, theme, colorScheme, pressed, width) {
2513
+ classString = expandVariantGroups(classString);
2444
2514
  const style = {};
2445
2515
  const warnings = [];
2446
2516
  let shadowOffset = null;