@kbach/react-native 1.0.0-beta.54 → 1.0.0-beta.56

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-NPDSBCXR.mjs";
1
+ import "./chunk-VWGUF2NB.mjs";
2
2
  import {
3
3
  Fragment,
4
4
  jsx,
5
5
  jsxs
6
- } from "./chunk-NXRSUBSY.mjs";
7
- import "./chunk-MLBH2JYH.mjs";
6
+ } from "./chunk-YDA2XA35.mjs";
7
+ import "./chunk-4WQ2DOOC.mjs";
8
8
 
9
9
  // src/jsxRuntimeCore.ts
10
10
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -109,7 +109,27 @@ var LENGTH_UNITS = ["px", "rem", "em", "%", "vh", "vw"];
109
109
  function looksLikeLength(value) {
110
110
  const unit = LENGTH_UNITS.find((u) => value.endsWith(u));
111
111
  const withoutUnit = unit ? value.slice(0, value.length - unit.length) : value;
112
- return withoutUnit !== "" && Number.isFinite(Number(withoutUnit));
112
+ if (withoutUnit !== "" && Number.isFinite(Number(withoutUnit))) return true;
113
+ if (!["calc(", "clamp(", "min(", "max("].some((f) => value.startsWith(f))) return false;
114
+ return MATH_LENGTH_UNIT.test(value);
115
+ }
116
+ var MATH_LENGTH_UNIT = /\d(?:px|rem|em|%|vh|vw|vmin|vmax|dvh|dvw|svh|svw|lvh|lvw|ch|ex|lh|cqw|cqh|cqi|cqb)(?![A-Za-z])/;
117
+ function isLength(parsed, value) {
118
+ switch (parsed.typeHint ?? null) {
119
+ case null:
120
+ return looksLikeLength(value);
121
+ case "length":
122
+ case "size":
123
+ case "line-width":
124
+ case "percentage":
125
+ case "number":
126
+ case "integer":
127
+ case "absolute-size":
128
+ case "relative-size":
129
+ return true;
130
+ default:
131
+ return false;
132
+ }
113
133
  }
114
134
 
115
135
  // src/jsxRuntimeCore.ts
@@ -664,14 +684,68 @@ function normalizeMathWhitespace(raw) {
664
684
  }
665
685
  return out;
666
686
  }
687
+ var TYPE_HINTS = /* @__PURE__ */ new Set([
688
+ "color",
689
+ "length",
690
+ "size",
691
+ "line-width",
692
+ "percentage",
693
+ "number",
694
+ "integer",
695
+ "image",
696
+ "url",
697
+ "position",
698
+ "bg-size",
699
+ "family-name",
700
+ "absolute-size",
701
+ "relative-size",
702
+ "angle",
703
+ "shadow",
704
+ "any"
705
+ ]);
706
+ function splitTypeHint(raw) {
707
+ const i = raw.indexOf(":");
708
+ if (i > 0 && i < raw.length - 1 && TYPE_HINTS.has(raw.slice(0, i))) return [raw.slice(0, i), raw.slice(i + 1)];
709
+ return [null, raw];
710
+ }
711
+ function parenVarShorthand(value) {
712
+ const m = /^\((?:([a-z-]+):)?--([A-Za-z0-9_-]+)\)(\/.*)?$/.exec(value);
713
+ if (!m) return null;
714
+ const [, hint, name, tail = ""] = m;
715
+ if (hint !== void 0 && !TYPE_HINTS.has(hint)) return null;
716
+ return hint ? `[${hint}:var(--${name})]${tail}` : `[var(--${name})]${tail}`;
717
+ }
718
+ function splitArbitraryOpacity(value) {
719
+ if (value.startsWith("[")) {
720
+ const i = value.lastIndexOf("]/");
721
+ if (i !== -1) {
722
+ const pct = value.slice(i + 2);
723
+ if (/^\d+$/.test(pct) && Number(pct) <= 100) return [value.slice(0, i + 1), Number(pct)];
724
+ }
725
+ }
726
+ return [value, null];
727
+ }
728
+ var COLOR_FUNCTIONS = ["rgb(", "rgba(", "hsl(", "hsla(", "hwb(", "lab(", "lch(", "oklab(", "oklch(", "color(", "color-mix(", "var("];
729
+ function looksLikeColor(value) {
730
+ return value.startsWith("#") || COLOR_FUNCTIONS.some((f) => value.startsWith(f)) || /^[A-Za-z]+$/.test(value);
731
+ }
732
+ function colorWithOpacity(color, pct) {
733
+ const m = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.exec(color);
734
+ if (m) {
735
+ const h = m[1].length === 3 ? m[1].split("").map((c) => c + c).join("") : m[1];
736
+ const [r, g, b] = [0, 2, 4].map((i) => parseInt(h.slice(i, i + 2), 16));
737
+ return `rgba(${r},${g},${b},${pct / 100})`;
738
+ }
739
+ return `color-mix(in srgb, ${color} ${pct}%, transparent)`;
740
+ }
667
741
  function splitRespectingBrackets(token) {
668
742
  const parts = [];
669
743
  let depth = 0;
670
744
  let start = 0;
671
745
  for (let i = 0; i < token.length; i++) {
672
746
  const ch = token[i];
673
- if (ch === "[") depth += 1;
674
- else if (ch === "]") depth -= 1;
747
+ if (ch === "[" || ch === "(") depth += 1;
748
+ else if (ch === "]" || ch === ")") depth -= 1;
675
749
  else if (ch === ":" && depth <= 0) {
676
750
  parts.push(token.slice(start, i));
677
751
  start = i + 1;
@@ -684,9 +758,11 @@ function parseClass(token) {
684
758
  const parts = splitRespectingBrackets(token);
685
759
  let base = parts.pop() ?? token;
686
760
  const modifiers = parts;
687
- const important = base.startsWith("!");
688
- if (important) {
761
+ const important = base.startsWith("!") || base.length > 1 && base.endsWith("!");
762
+ if (base.startsWith("!")) {
689
763
  base = base.slice(1);
764
+ } else if (important) {
765
+ base = base.slice(0, -1);
690
766
  }
691
767
  const negative = base.startsWith("-");
692
768
  if (negative) {
@@ -714,18 +790,26 @@ function parseClass(token) {
714
790
  }
715
791
  for (const prefix of VALUE_PREFIXES) {
716
792
  if (!base.startsWith(prefix)) continue;
717
- const value = base.slice(prefix.length);
718
- if (value === "") continue;
793
+ const written = base.slice(prefix.length);
794
+ if (written === "") continue;
795
+ const [value, arbitraryOpacity] = splitArbitraryOpacity(parenVarShorthand(written) ?? written);
719
796
  if (value.length >= 2 && value.startsWith("[") && value.endsWith("]")) {
720
797
  const raw = value.slice(1, -1);
721
798
  if (!isSafeArbitraryValue(raw)) {
722
799
  continue;
723
800
  }
724
801
  const spaced = normalizeMathWhitespace(raw.replace(/_/g, " "));
802
+ let [typeHint, hinted] = splitTypeHint(spaced);
803
+ if (arbitraryOpacity !== null) {
804
+ if (!(typeHint === "color" || typeHint === null && looksLikeColor(hinted))) continue;
805
+ hinted = colorWithOpacity(hinted, arbitraryOpacity);
806
+ typeHint = "color";
807
+ }
725
808
  return {
726
809
  modifiers,
727
810
  utility: prefix.slice(0, -1),
728
- value: spaced,
811
+ value: hinted,
812
+ typeHint,
729
813
  isArbitrary: true,
730
814
  important,
731
815
  negative,
@@ -735,7 +819,8 @@ function parseClass(token) {
735
819
  return {
736
820
  modifiers,
737
821
  utility: prefix.slice(0, -1),
738
- value,
822
+ // a named value keeps its own /opacity (`bg-blue-6/50`)
823
+ value: arbitraryOpacity === null ? value : `${value}/${arbitraryOpacity}`,
739
824
  isArbitrary: false,
740
825
  important,
741
826
  negative,
@@ -1050,6 +1135,8 @@ function resolvePercent(parsed) {
1050
1135
  function negateRaw(value, negative) {
1051
1136
  return negative ? `-${value}` : value;
1052
1137
  }
1138
+ var WHOLE = /^\d+$/;
1139
+ var PLAIN_NUMBER = /^(?:\d+\.?\d*|\.\d+)$/;
1053
1140
  function overflowAxisValue(property, value) {
1054
1141
  switch (value) {
1055
1142
  case "auto":
@@ -1180,14 +1267,29 @@ function resolve(parsed, theme) {
1180
1267
  return [decl("position", "fixed")];
1181
1268
  case "sticky":
1182
1269
  return [decl("position", "sticky")];
1183
- case "z":
1184
- return parsed.value === null ? null : [decl("z-index", negateRaw(parsed.value, parsed.negative))];
1185
- case "order":
1186
- return parsed.value === null ? null : [decl("order", negateRaw(parsed.value, parsed.negative))];
1270
+ // Only real values, mirroring layout.rs: a whole number, z-auto, the
1271
+ // order-first/-last/-none keywords, or an arbitrary [...]. Anything
1272
+ // else used to pass straight through (z-banana -> z-index: banana).
1273
+ case "z": {
1274
+ const v = parsed.value;
1275
+ if (v === null || !(parsed.isArbitrary || v === "auto" || WHOLE.test(v))) return null;
1276
+ return [decl("z-index", negateRaw(v, parsed.negative))];
1277
+ }
1278
+ case "order": {
1279
+ const v = parsed.value;
1280
+ if (v === null) return null;
1281
+ if (v === "first") return [decl("order", "-9999")];
1282
+ if (v === "last") return [decl("order", "9999")];
1283
+ if (v === "none") return [decl("order", "0")];
1284
+ if (!(parsed.isArbitrary || WHOLE.test(v))) return null;
1285
+ return [decl("order", negateRaw(v, parsed.negative))];
1286
+ }
1187
1287
  case "grow":
1188
- return [decl("flex-grow", parsed.value ?? "1")];
1189
- case "shrink":
1190
- return [decl("flex-shrink", parsed.value ?? "1")];
1288
+ case "shrink": {
1289
+ const v = parsed.value ?? "1";
1290
+ if (!(parsed.isArbitrary || PLAIN_NUMBER.test(v))) return null;
1291
+ return [decl(parsed.utility === "grow" ? "flex-grow" : "flex-shrink", v)];
1292
+ }
1191
1293
  // top/right/bottom/left/inset support real Tailwind's negative-value
1192
1294
  // convention ("-top-4") AND its percentage-fraction scale ("top-1/2",
1193
1295
  // "-inset-1/3") — see resolveNegatableSize's own doc comment.
@@ -1525,7 +1627,7 @@ function borderValue(theme, parsed) {
1525
1627
  if (value === "separate") return [decl("border-collapse", "separate")];
1526
1628
  }
1527
1629
  if (parsed.isArbitrary) {
1528
- if (looksLikeLength(value)) return [decl("border-width", value)];
1630
+ if (isLength(parsed, value)) return [decl("border-width", value)];
1529
1631
  const color2 = colorValue(theme, parsed);
1530
1632
  return color2 === null ? null : [decl("border-color", color2)];
1531
1633
  }
@@ -1543,7 +1645,7 @@ function borderSideValue(theme, parsed, sideProperty) {
1543
1645
  const value = parsed.value;
1544
1646
  if (value === null) return null;
1545
1647
  if (parsed.isArbitrary) {
1546
- if (looksLikeLength(value)) return [decl(`${sideProperty}-width`, value)];
1648
+ if (isLength(parsed, value)) return [decl(`${sideProperty}-width`, value)];
1547
1649
  const color2 = colorValue(theme, parsed);
1548
1650
  return color2 === null ? null : [decl(`${sideProperty}-color`, color2)];
1549
1651
  }
@@ -1561,7 +1663,7 @@ function borderAxisValue(theme, parsed, sideA, sideB) {
1561
1663
  const value = parsed.value;
1562
1664
  if (value === null) return null;
1563
1665
  if (parsed.isArbitrary) {
1564
- if (looksLikeLength(value)) return [decl(`${sideA}-width`, value), decl(`${sideB}-width`, value)];
1666
+ if (isLength(parsed, value)) return [decl(`${sideA}-width`, value), decl(`${sideB}-width`, value)];
1565
1667
  const color2 = colorValue(theme, parsed);
1566
1668
  return color2 === null ? null : [decl(`${sideA}-color`, color2), decl(`${sideB}-color`, color2)];
1567
1669
  }
@@ -1619,7 +1721,7 @@ function outlineValue(theme, parsed) {
1619
1721
  const value = parsed.value;
1620
1722
  if (value === null) return null;
1621
1723
  if (parsed.isArbitrary) {
1622
- if (looksLikeLength(value)) return [decl("outline-width", value)];
1724
+ if (isLength(parsed, value)) return [decl("outline-width", value)];
1623
1725
  const color2 = colorValue(theme, parsed);
1624
1726
  return color2 === null ? null : [decl("outline-color", color2)];
1625
1727
  }
@@ -1837,7 +1939,12 @@ function scaleFactor(parsed) {
1837
1939
  }
1838
1940
  function angle(parsed) {
1839
1941
  if (parsed.value === null) return null;
1840
- if (parsed.isArbitrary) return parsed.value;
1942
+ if (parsed.isArbitrary) {
1943
+ if (!parsed.negative) return parsed.value;
1944
+ if (parsed.value.startsWith("-")) return parsed.value.slice(1);
1945
+ if (/^[\d.]/.test(parsed.value)) return `-${parsed.value}`;
1946
+ return `calc(${parsed.value} * -1)`;
1947
+ }
1841
1948
  const n = Number(parsed.value);
1842
1949
  if (!Number.isFinite(n)) return null;
1843
1950
  return `${parsed.negative ? -n : n}deg`;
@@ -1970,7 +2077,7 @@ function resolveTextNative(parsed, theme) {
1970
2077
  if (size !== null) return [decl("font-size", size)];
1971
2078
  const align = textAlign(parsed.value);
1972
2079
  if (align !== null) return [decl("text-align", align)];
1973
- } else if (parsed.isArbitrary && parsed.value !== null && looksLikeLength(parsed.value)) {
2080
+ } else if (parsed.isArbitrary && parsed.value !== null && isLength(parsed, parsed.value)) {
1974
2081
  return [decl("font-size", parsed.value)];
1975
2082
  }
1976
2083
  const hex = nativeHexColor(parsed, theme);
@@ -2017,6 +2124,13 @@ function nativeModifierState(modifier, theme, colorScheme, pressed, width) {
2017
2124
  const px = reduceConstantMath(`calc(${modifier.slice(5, -1).trim()})`);
2018
2125
  return px === null ? null : width <= px;
2019
2126
  }
2127
+ const screen = (name) => Object.prototype.hasOwnProperty.call(theme.screens, name) ? theme.screens[name] : void 0;
2128
+ const custom = screen(modifier);
2129
+ if (typeof custom === "number") return width >= custom;
2130
+ if (modifier.startsWith("max-")) {
2131
+ const max = screen(modifier.slice(4));
2132
+ if (typeof max === "number") return width < max;
2133
+ }
2020
2134
  return null;
2021
2135
  }
2022
2136
  function kebabToCamel(s) {
@@ -2180,7 +2294,7 @@ function resolveStyleJsWithWarnings(classString, theme, colorScheme, pressed, wi
2180
2294
  if (d.property.startsWith("__")) {
2181
2295
  continue;
2182
2296
  }
2183
- if (d.property.startsWith("--") || d.value.includes("var(") || d.property === "outline" || d.property === "object-position" || d.property === "container-type") {
2297
+ if (d.property.startsWith("--") || d.value.includes("var(") || d.property === "outline" || d.property === "object-position" || d.property === "container-type" || d.property === "container-name") {
2184
2298
  continue;
2185
2299
  }
2186
2300
  if (d.property === "shadow-offset-x" || d.property === "shadow-offset-y") {