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

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-FSO4WVCH.mjs";
1
+ import "./chunk-BN6RWNCE.mjs";
2
2
  import {
3
3
  Fragment,
4
4
  jsx,
5
5
  jsxs
6
- } from "./chunk-6F44N62F.mjs";
7
- import "./chunk-R7E5D3D6.mjs";
6
+ } from "./chunk-VMI2JVCQ.mjs";
7
+ import "./chunk-TCSCNQQ7.mjs";
8
8
 
9
9
  // src/jsxRuntimeCore.ts
10
10
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -982,6 +982,63 @@ function expandToken(token, prefix, important, out) {
982
982
  for (const part of splitTopLevel(token.slice(open + 1, close))) expandToken(part, innerPrefix, rest === "!" || important, out);
983
983
  }
984
984
 
985
+ // src/jsEngine/compose.ts
986
+ var MAX_DEPTH = 8;
987
+ function splitVariants(token) {
988
+ let depth = 0;
989
+ let last = -1;
990
+ for (let i = 0; i < token.length; i++) {
991
+ const ch = token[i];
992
+ if (ch === "[" || ch === "(") depth++;
993
+ else if (ch === "]" || ch === ")") depth--;
994
+ else if (ch === ":" && depth === 0) last = i;
995
+ }
996
+ return last < 0 ? ["", token] : [token.slice(0, last + 1), token.slice(last + 1)];
997
+ }
998
+ function stripImportant(base) {
999
+ if (base.endsWith("!")) return [base.slice(0, -1), true];
1000
+ if (base.startsWith("!")) return [base.slice(1), true];
1001
+ return [base, false];
1002
+ }
1003
+ function withImportant(cls, important) {
1004
+ const [, base] = splitVariants(cls);
1005
+ return important && !cls.endsWith("!") && !base.startsWith("!") ? cls + "!" : cls;
1006
+ }
1007
+ function expandInto(prefix, value, important, compose, path, out) {
1008
+ for (const cls of expandVariantGroups(value).split(/\s+/).filter(Boolean)) {
1009
+ const [variants, base] = splitVariants(cls);
1010
+ const [name, bang] = stripImportant(base);
1011
+ const inner = Object.prototype.hasOwnProperty.call(compose, name) ? compose[name] : void 0;
1012
+ if (inner !== void 0 && path.length < MAX_DEPTH && !path.includes(name)) {
1013
+ path.push(name);
1014
+ expandInto(prefix + variants, inner, important || bang, compose, path, out);
1015
+ path.pop();
1016
+ } else {
1017
+ out.push(withImportant(prefix + cls, important));
1018
+ }
1019
+ }
1020
+ }
1021
+ function expandComposeToken(token, compose) {
1022
+ if (!compose) return null;
1023
+ const [variants, base] = splitVariants(token);
1024
+ const [name, important] = stripImportant(base);
1025
+ if (!Object.prototype.hasOwnProperty.call(compose, name)) return null;
1026
+ const out = [];
1027
+ expandInto(variants, compose[name], important, compose, [name], out);
1028
+ return out;
1029
+ }
1030
+ function expandComposeClasses(classString, compose) {
1031
+ if (!compose || Object.keys(compose).length === 0) return classString;
1032
+ const composed = [];
1033
+ const own = [];
1034
+ for (const token of classString.split(/\s+/).filter(Boolean)) {
1035
+ const classes = expandComposeToken(token, compose);
1036
+ if (classes) composed.push(...classes);
1037
+ else own.push(token);
1038
+ }
1039
+ return composed.length === 0 ? classString : [...composed, ...own].join(" ");
1040
+ }
1041
+
985
1042
  // src/jsxRuntimeCore.ts
986
1043
  var DYNAMIC_TOKEN_MATCH_RE = /var\(--([a-zA-Z0-9-]+)\)/g;
987
1044
  function substituteDynamicTokens(classStrRaw) {
@@ -1176,6 +1233,23 @@ function ReactiveElement({
1176
1233
  elementKey
1177
1234
  );
1178
1235
  }
1236
+ var flatCache = /* @__PURE__ */ new Map();
1237
+ var flatCacheTheme = null;
1238
+ function flatClasses(classNameProp) {
1239
+ const theme = (0, import_theme.getTheme)();
1240
+ if (!theme.compose && !classNameProp.includes(":(")) return classNameProp;
1241
+ if (theme !== flatCacheTheme) {
1242
+ flatCache.clear();
1243
+ flatCacheTheme = theme;
1244
+ }
1245
+ let flat = flatCache.get(classNameProp);
1246
+ if (flat === void 0) {
1247
+ flat = expandComposeClasses(classNameProp.includes(":(") ? expandVariantGroups(classNameProp) : classNameProp, theme.compose);
1248
+ if (flatCache.size >= 500) flatCache.clear();
1249
+ flatCache.set(classNameProp, flat);
1250
+ }
1251
+ return flat;
1252
+ }
1179
1253
  function processElement(resolveStyle2, type, rawProps, key, isStaticChildren) {
1180
1254
  if (type === null || typeof type === "symbol" || !rawProps) {
1181
1255
  return makeElement(isStaticChildren, type, rawProps ?? {}, key);
@@ -1184,7 +1258,7 @@ function processElement(resolveStyle2, type, rawProps, key, isStaticChildren) {
1184
1258
  if (typeof classNameProp !== "string") {
1185
1259
  return makeElement(isStaticChildren, type, rawProps, key);
1186
1260
  }
1187
- const classStrRaw = classNameProp.includes(":(") ? expandVariantGroups(classNameProp) : classNameProp;
1261
+ const classStrRaw = flatClasses(classNameProp);
1188
1262
  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)) {
1189
1263
  return (0, import_jsx_runtime.jsx)(
1190
1264
  ReactiveElement,
@@ -2510,7 +2584,7 @@ Fix: use a plain px/rem calc, a fraction utility (e.g. w-1/2), or resolve this v
2510
2584
  return { value: null, warning };
2511
2585
  }
2512
2586
  function resolveStyleJsWithWarnings(classString, theme, colorScheme, pressed, width) {
2513
- classString = expandVariantGroups(classString);
2587
+ classString = expandComposeClasses(expandVariantGroups(classString), theme.compose);
2514
2588
  const style = {};
2515
2589
  const warnings = [];
2516
2590
  let shadowOffset = null;