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

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.
package/dist/index.js CHANGED
@@ -541,6 +541,73 @@ function parseClass(token) {
541
541
  };
542
542
  }
543
543
 
544
+ // src/jsEngine/groups.ts
545
+ function expandVariantGroups(input) {
546
+ if (!input.includes(":(")) return input;
547
+ const out = [];
548
+ for (const token of splitTopLevel(input)) expandToken(token, "", false, out);
549
+ return out.join(" ");
550
+ }
551
+ function splitTopLevel(s) {
552
+ const parts = [];
553
+ let depth = 0;
554
+ let start = -1;
555
+ for (let i = 0; i < s.length; i++) {
556
+ const ch = s[i];
557
+ if (ch === "(" || ch === "[") depth++;
558
+ else if (ch === ")" || ch === "]") depth--;
559
+ const space = /\s/.test(ch);
560
+ if (space && depth <= 0) {
561
+ if (start >= 0) {
562
+ parts.push(s.slice(start, i));
563
+ start = -1;
564
+ }
565
+ depth = Math.max(depth, 0);
566
+ } else if (start < 0 && !space) {
567
+ start = i;
568
+ }
569
+ }
570
+ if (start >= 0) parts.push(s.slice(start));
571
+ return parts;
572
+ }
573
+ function groupOpen(token) {
574
+ let brackets = 0;
575
+ for (let i = 0; i < token.length; i++) {
576
+ const ch = token[i];
577
+ if (ch === "[") brackets++;
578
+ else if (ch === "]") brackets--;
579
+ else if (ch === "(" && brackets === 0 && i > 1 && token[i - 1] === ":") return i;
580
+ }
581
+ return -1;
582
+ }
583
+ function groupClose(token, open) {
584
+ let depth = 0;
585
+ for (let i = open; i < token.length; i++) {
586
+ const ch = token[i];
587
+ if (ch === "(" || ch === "[") depth++;
588
+ else if (ch === ")" || ch === "]") {
589
+ depth--;
590
+ if (depth === 0) return ch === ")" ? i : -1;
591
+ }
592
+ }
593
+ return -1;
594
+ }
595
+ function pushClass(prefix, cls, important, out) {
596
+ if (!cls) return;
597
+ const bare = cls.split(":").pop() ?? cls;
598
+ out.push(prefix + cls + (important && !cls.endsWith("!") && !bare.startsWith("!") ? "!" : ""));
599
+ }
600
+ function expandToken(token, prefix, important, out) {
601
+ const open = groupOpen(token);
602
+ if (open < 0) return pushClass(prefix, token, important, out);
603
+ const close = groupClose(token, open);
604
+ if (close < 0) return pushClass(prefix, token, important, out);
605
+ const rest = token.slice(close + 1);
606
+ if (rest !== "" && rest !== "!") return pushClass(prefix, token, important, out);
607
+ const innerPrefix = prefix + token.slice(0, open);
608
+ for (const part of splitTopLevel(token.slice(open + 1, close))) expandToken(part, innerPrefix, rest === "!" || important, out);
609
+ }
610
+
544
611
  // src/jsEngine/shared.ts
545
612
  function decl(property, value) {
546
613
  return { property, value };
@@ -2070,6 +2137,7 @@ Fix: use a plain px/rem calc, a fraction utility (e.g. w-1/2), or resolve this v
2070
2137
  return { value: null, warning };
2071
2138
  }
2072
2139
  function resolveStyleJsWithWarnings(classString, theme, colorScheme, pressed, width) {
2140
+ classString = expandVariantGroups(classString);
2073
2141
  const style = {};
2074
2142
  const warnings = [];
2075
2143
  let shadowOffset = null;