@kbach/react-native 1.0.0-beta.55 → 1.0.0-beta.57
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/AGENTS.md +11 -4
- package/android/src/main/jniLibs/arm64-v8a/libkbach_core_engine.so +0 -0
- package/android/src/main/jniLibs/x86_64/libkbach_core_engine.so +0 -0
- package/dist/chunk-APVTYFEK.mjs +623 -0
- package/dist/{chunk-WI7VGI2G.mjs → chunk-PLSCNADJ.mjs} +1 -1
- package/dist/{chunk-KAA2Y67Z.mjs → chunk-T6YWFA2C.mjs} +1 -1
- package/dist/index.js +330 -49
- package/dist/index.web.js +1 -1
- package/dist/index.web.mjs +2 -2
- package/dist/jsx-dev-runtime.js +826 -545
- package/dist/jsx-dev-runtime.web.js +1 -1
- package/dist/jsx-dev-runtime.web.mjs +3 -3
- package/dist/jsx-runtime.js +826 -545
- package/dist/jsx-runtime.web.js +1 -1
- package/dist/jsx-runtime.web.mjs +2 -2
- package/dist/theme.js +48 -0
- package/package.json +1 -1
- package/dist/chunk-CAD43NRG.mjs +0 -575
package/dist/index.js
CHANGED
|
@@ -153,6 +153,7 @@ var VALUE_PREFIXES = [
|
|
|
153
153
|
"leading-",
|
|
154
154
|
"tracking-",
|
|
155
155
|
"font-",
|
|
156
|
+
"align-",
|
|
156
157
|
"z-",
|
|
157
158
|
"inset-x-",
|
|
158
159
|
"inset-y-",
|
|
@@ -302,14 +303,143 @@ function normalizeMathWhitespace(raw) {
|
|
|
302
303
|
}
|
|
303
304
|
return out;
|
|
304
305
|
}
|
|
306
|
+
var TYPE_HINTS = /* @__PURE__ */ new Set([
|
|
307
|
+
"color",
|
|
308
|
+
"length",
|
|
309
|
+
"size",
|
|
310
|
+
"line-width",
|
|
311
|
+
"percentage",
|
|
312
|
+
"number",
|
|
313
|
+
"integer",
|
|
314
|
+
"image",
|
|
315
|
+
"url",
|
|
316
|
+
"position",
|
|
317
|
+
"bg-size",
|
|
318
|
+
"family-name",
|
|
319
|
+
"generic-name",
|
|
320
|
+
"absolute-size",
|
|
321
|
+
"relative-size",
|
|
322
|
+
"angle",
|
|
323
|
+
"shadow",
|
|
324
|
+
"any"
|
|
325
|
+
]);
|
|
326
|
+
function arbitraryModifier(modifier) {
|
|
327
|
+
const bracketed = parenVarShorthand(modifier) ?? modifier;
|
|
328
|
+
if (!(bracketed.length > 2 && bracketed.startsWith("[") && bracketed.endsWith("]"))) return null;
|
|
329
|
+
const raw = bracketed.slice(1, -1);
|
|
330
|
+
if (!isSafeArbitraryValue(raw)) return null;
|
|
331
|
+
return normalizeMathWhitespace(raw.replace(/_/g, " "));
|
|
332
|
+
}
|
|
333
|
+
function splitTypeHint(raw) {
|
|
334
|
+
const i = raw.indexOf(":");
|
|
335
|
+
if (i > 0 && i < raw.length - 1 && TYPE_HINTS.has(raw.slice(0, i))) return [raw.slice(0, i), raw.slice(i + 1)];
|
|
336
|
+
return [null, raw];
|
|
337
|
+
}
|
|
338
|
+
function parenVarShorthand(value) {
|
|
339
|
+
const m = /^\((?:([a-z-]+):)?--([A-Za-z0-9_-]+)\)(\/.*)?$/.exec(value);
|
|
340
|
+
if (!m) return null;
|
|
341
|
+
const [, hint, name, tail = ""] = m;
|
|
342
|
+
if (hint !== void 0 && !TYPE_HINTS.has(hint)) return null;
|
|
343
|
+
return hint ? `[${hint}:var(--${name})]${tail}` : `[var(--${name})]${tail}`;
|
|
344
|
+
}
|
|
345
|
+
function splitBracketModifier(value) {
|
|
346
|
+
if (!value.startsWith("[")) return [value, null];
|
|
347
|
+
let depth = 0;
|
|
348
|
+
for (let i = 0; i < value.length; i++) {
|
|
349
|
+
const ch = value[i];
|
|
350
|
+
if (ch === "[") depth += 1;
|
|
351
|
+
else if (ch === "]") {
|
|
352
|
+
depth -= 1;
|
|
353
|
+
if (depth === 0) {
|
|
354
|
+
const after = value.slice(i + 1);
|
|
355
|
+
return after.startsWith("/") && after.length > 1 ? [value.slice(0, i + 1), after.slice(1)] : [value, null];
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return [value, null];
|
|
360
|
+
}
|
|
361
|
+
function trimNumber(n) {
|
|
362
|
+
return `${Math.round(n * 1e6) / 1e6}`;
|
|
363
|
+
}
|
|
364
|
+
function parseAlpha(modifier) {
|
|
365
|
+
const raw = arbitraryModifier(modifier);
|
|
366
|
+
if (raw !== null) {
|
|
367
|
+
if (raw.endsWith("%")) {
|
|
368
|
+
const n3 = strictNumber(raw.slice(0, -1));
|
|
369
|
+
return n3 !== null && n3 >= 0 && n3 <= 100 ? { fraction: n3 / 100 } : null;
|
|
370
|
+
}
|
|
371
|
+
const n2 = strictNumber(raw);
|
|
372
|
+
if (n2 !== null) return n2 >= 0 && n2 <= 1 ? { fraction: n2 } : null;
|
|
373
|
+
return raw.startsWith("var(") || raw.startsWith("calc(") ? { raw } : null;
|
|
374
|
+
}
|
|
375
|
+
if (!/^(?:\d+\.?\d*|\.\d+)$/.test(modifier)) return null;
|
|
376
|
+
const n = Number(modifier);
|
|
377
|
+
return n <= 100 ? { fraction: n / 100 } : null;
|
|
378
|
+
}
|
|
379
|
+
function strictNumber(text) {
|
|
380
|
+
return /^[+-]?(?:\d+\.?\d*|\.\d+)$/.test(text) ? Number(text) : null;
|
|
381
|
+
}
|
|
382
|
+
function expandThemeFunctions(raw) {
|
|
383
|
+
if (!raw.includes("--spacing(") && !raw.includes("--alpha(")) return raw;
|
|
384
|
+
let out = "";
|
|
385
|
+
let rest = raw;
|
|
386
|
+
for (; ; ) {
|
|
387
|
+
const found = ["--spacing(", "--alpha("].map((name) => ({ name, at: rest.indexOf(name) })).filter((f) => f.at !== -1).sort((a, b) => a.at - b.at)[0];
|
|
388
|
+
if (found === void 0) break;
|
|
389
|
+
const argsFrom = found.at + found.name.length;
|
|
390
|
+
let depth = 1;
|
|
391
|
+
let close = -1;
|
|
392
|
+
for (let i = argsFrom; i < rest.length; i++) {
|
|
393
|
+
if (rest[i] === "(") depth += 1;
|
|
394
|
+
else if (rest[i] === ")") {
|
|
395
|
+
depth -= 1;
|
|
396
|
+
if (depth === 0) {
|
|
397
|
+
close = i;
|
|
398
|
+
break;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
if (close === -1) break;
|
|
403
|
+
const arg = expandThemeFunctions(rest.slice(argsFrom, close).trim());
|
|
404
|
+
out += rest.slice(0, found.at);
|
|
405
|
+
if (found.name === "--spacing(") {
|
|
406
|
+
const n = strictNumber(arg);
|
|
407
|
+
out += n !== null ? `${trimNumber(n * 4)}px` : `calc(4px * ${arg})`;
|
|
408
|
+
} else {
|
|
409
|
+
const slash = arg.lastIndexOf("/");
|
|
410
|
+
if (slash === -1) {
|
|
411
|
+
out += arg;
|
|
412
|
+
} else {
|
|
413
|
+
const alpha = arg.slice(slash + 1).trim();
|
|
414
|
+
const n = strictNumber(alpha);
|
|
415
|
+
out += `color-mix(in srgb, ${arg.slice(0, slash).trim()} ${n !== null ? `${trimNumber(n * 100)}%` : alpha}, transparent)`;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
rest = rest.slice(close + 1);
|
|
419
|
+
}
|
|
420
|
+
return out + rest;
|
|
421
|
+
}
|
|
422
|
+
var COLOR_FUNCTIONS = ["rgb(", "rgba(", "hsl(", "hsla(", "hwb(", "lab(", "lch(", "oklab(", "oklch(", "color(", "color-mix(", "var("];
|
|
423
|
+
function looksLikeColor(value) {
|
|
424
|
+
return value.startsWith("#") || COLOR_FUNCTIONS.some((f) => value.startsWith(f)) || /^[A-Za-z]+$/.test(value);
|
|
425
|
+
}
|
|
426
|
+
function colorWithOpacity(color, alpha) {
|
|
427
|
+
const m = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.exec(color);
|
|
428
|
+
if (m && "fraction" in alpha) {
|
|
429
|
+
const h = m[1].length === 3 ? m[1].split("").map((c) => c + c).join("") : m[1];
|
|
430
|
+
const [r, g, b] = [0, 2, 4].map((i) => parseInt(h.slice(i, i + 2), 16));
|
|
431
|
+
return `rgba(${r},${g},${b},${trimNumber(alpha.fraction)})`;
|
|
432
|
+
}
|
|
433
|
+
return `color-mix(in srgb, ${color} ${"fraction" in alpha ? `${trimNumber(alpha.fraction * 100)}%` : alpha.raw}, transparent)`;
|
|
434
|
+
}
|
|
305
435
|
function splitRespectingBrackets(token) {
|
|
306
436
|
const parts = [];
|
|
307
437
|
let depth = 0;
|
|
308
438
|
let start = 0;
|
|
309
439
|
for (let i = 0; i < token.length; i++) {
|
|
310
440
|
const ch = token[i];
|
|
311
|
-
if (ch === "[") depth += 1;
|
|
312
|
-
else if (ch === "]") depth -= 1;
|
|
441
|
+
if (ch === "[" || ch === "(") depth += 1;
|
|
442
|
+
else if (ch === "]" || ch === ")") depth -= 1;
|
|
313
443
|
else if (ch === ":" && depth <= 0) {
|
|
314
444
|
parts.push(token.slice(start, i));
|
|
315
445
|
start = i + 1;
|
|
@@ -322,9 +452,11 @@ function parseClass(token) {
|
|
|
322
452
|
const parts = splitRespectingBrackets(token);
|
|
323
453
|
let base = parts.pop() ?? token;
|
|
324
454
|
const modifiers = parts;
|
|
325
|
-
const important = base.startsWith("!");
|
|
326
|
-
if (
|
|
455
|
+
const important = base.startsWith("!") || base.length > 1 && base.endsWith("!");
|
|
456
|
+
if (base.startsWith("!")) {
|
|
327
457
|
base = base.slice(1);
|
|
458
|
+
} else if (important) {
|
|
459
|
+
base = base.slice(0, -1);
|
|
328
460
|
}
|
|
329
461
|
const negative = base.startsWith("-");
|
|
330
462
|
if (negative) {
|
|
@@ -337,7 +469,7 @@ function parseClass(token) {
|
|
|
337
469
|
const property = raw.slice(0, colonIdx);
|
|
338
470
|
const rawValue = raw.slice(colonIdx + 1);
|
|
339
471
|
if (property !== "" && rawValue !== "" && isSafeArbitraryValue(raw)) {
|
|
340
|
-
const value = normalizeMathWhitespace(rawValue.replace(/_/g, " "));
|
|
472
|
+
const value = normalizeMathWhitespace(expandThemeFunctions(rawValue.replace(/_/g, " ")));
|
|
341
473
|
return {
|
|
342
474
|
modifiers,
|
|
343
475
|
utility: ARBITRARY_PROPERTY_SENTINEL,
|
|
@@ -352,28 +484,46 @@ function parseClass(token) {
|
|
|
352
484
|
}
|
|
353
485
|
for (const prefix of VALUE_PREFIXES) {
|
|
354
486
|
if (!base.startsWith(prefix)) continue;
|
|
355
|
-
const
|
|
356
|
-
if (
|
|
487
|
+
const written = base.slice(prefix.length);
|
|
488
|
+
if (written === "") continue;
|
|
489
|
+
const [value, tail] = splitBracketModifier(parenVarShorthand(written) ?? written);
|
|
357
490
|
if (value.length >= 2 && value.startsWith("[") && value.endsWith("]")) {
|
|
358
491
|
const raw = value.slice(1, -1);
|
|
359
492
|
if (!isSafeArbitraryValue(raw)) {
|
|
360
493
|
continue;
|
|
361
494
|
}
|
|
362
|
-
const spaced = normalizeMathWhitespace(raw.replace(/_/g, " "));
|
|
495
|
+
const spaced = normalizeMathWhitespace(expandThemeFunctions(raw.replace(/_/g, " ")));
|
|
496
|
+
let [typeHint, hinted] = splitTypeHint(spaced);
|
|
497
|
+
let modifier = null;
|
|
498
|
+
if (tail !== null) {
|
|
499
|
+
const isColor = typeHint === "color" || typeHint === null && looksLikeColor(hinted);
|
|
500
|
+
const alpha = isColor ? parseAlpha(tail) : null;
|
|
501
|
+
if (alpha !== null) {
|
|
502
|
+
hinted = colorWithOpacity(hinted, alpha);
|
|
503
|
+
typeHint = "color";
|
|
504
|
+
} else if (prefix === "text-") {
|
|
505
|
+
modifier = tail;
|
|
506
|
+
} else {
|
|
507
|
+
continue;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
363
510
|
return {
|
|
364
511
|
modifiers,
|
|
365
512
|
utility: prefix.slice(0, -1),
|
|
366
|
-
value:
|
|
513
|
+
value: hinted,
|
|
514
|
+
typeHint,
|
|
367
515
|
isArbitrary: true,
|
|
368
516
|
important,
|
|
369
517
|
negative,
|
|
370
|
-
original: token
|
|
518
|
+
original: token,
|
|
519
|
+
modifier
|
|
371
520
|
};
|
|
372
521
|
}
|
|
373
522
|
return {
|
|
374
523
|
modifiers,
|
|
375
524
|
utility: prefix.slice(0, -1),
|
|
376
|
-
value
|
|
525
|
+
// a named value keeps its own /opacity (`bg-blue-6/50`)
|
|
526
|
+
value: tail === null ? value : `${value}/${tail}`,
|
|
377
527
|
isArbitrary: false,
|
|
378
528
|
important,
|
|
379
529
|
negative,
|
|
@@ -447,6 +597,11 @@ function resolveNegatableSize(theme, parsed) {
|
|
|
447
597
|
}
|
|
448
598
|
return resolveNegatableLength(theme, parsed);
|
|
449
599
|
}
|
|
600
|
+
function negate(value) {
|
|
601
|
+
const numeric = (v) => /^[\d.]/.test(v);
|
|
602
|
+
if (value.startsWith("-")) return numeric(value.slice(1)) ? value.slice(1) : `calc(${value} * -1)`;
|
|
603
|
+
return numeric(value) ? `-${value}` : `calc(${value} * -1)`;
|
|
604
|
+
}
|
|
450
605
|
function resolvePercent(parsed) {
|
|
451
606
|
if (parsed.negative) return null;
|
|
452
607
|
const value = parsed.value;
|
|
@@ -461,6 +616,8 @@ function resolvePercent(parsed) {
|
|
|
461
616
|
function negateRaw(value, negative) {
|
|
462
617
|
return negative ? `-${value}` : value;
|
|
463
618
|
}
|
|
619
|
+
var WHOLE = /^\d+$/;
|
|
620
|
+
var PLAIN_NUMBER = /^(?:\d+\.?\d*|\.\d+)$/;
|
|
464
621
|
function overflowAxisValue(property, value) {
|
|
465
622
|
switch (value) {
|
|
466
623
|
case "auto":
|
|
@@ -591,14 +748,29 @@ function resolve(parsed, theme) {
|
|
|
591
748
|
return [decl("position", "fixed")];
|
|
592
749
|
case "sticky":
|
|
593
750
|
return [decl("position", "sticky")];
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
751
|
+
// Only real values, mirroring layout.rs: a whole number, z-auto, the
|
|
752
|
+
// order-first/-last/-none keywords, or an arbitrary [...]. Anything
|
|
753
|
+
// else used to pass straight through (z-banana -> z-index: banana).
|
|
754
|
+
case "z": {
|
|
755
|
+
const v = parsed.value;
|
|
756
|
+
if (v === null || !(parsed.isArbitrary || v === "auto" || WHOLE.test(v))) return null;
|
|
757
|
+
return [decl("z-index", negateRaw(v, parsed.negative))];
|
|
758
|
+
}
|
|
759
|
+
case "order": {
|
|
760
|
+
const v = parsed.value;
|
|
761
|
+
if (v === null) return null;
|
|
762
|
+
if (v === "first") return [decl("order", "-9999")];
|
|
763
|
+
if (v === "last") return [decl("order", "9999")];
|
|
764
|
+
if (v === "none") return [decl("order", "0")];
|
|
765
|
+
if (!(parsed.isArbitrary || WHOLE.test(v))) return null;
|
|
766
|
+
return [decl("order", negateRaw(v, parsed.negative))];
|
|
767
|
+
}
|
|
598
768
|
case "grow":
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
769
|
+
case "shrink": {
|
|
770
|
+
const v = parsed.value ?? "1";
|
|
771
|
+
if (!(parsed.isArbitrary || PLAIN_NUMBER.test(v))) return null;
|
|
772
|
+
return [decl(parsed.utility === "grow" ? "flex-grow" : "flex-shrink", v)];
|
|
773
|
+
}
|
|
602
774
|
// top/right/bottom/left/inset support real Tailwind's negative-value
|
|
603
775
|
// convention ("-top-4") AND its percentage-fraction scale ("top-1/2",
|
|
604
776
|
// "-inset-1/3") — see resolveNegatableSize's own doc comment.
|
|
@@ -655,8 +827,10 @@ function resolve(parsed, theme) {
|
|
|
655
827
|
return [decl("aspect-ratio", "16 / 9")];
|
|
656
828
|
case "auto":
|
|
657
829
|
return [decl("aspect-ratio", "auto")];
|
|
658
|
-
default:
|
|
659
|
-
|
|
830
|
+
default: {
|
|
831
|
+
const m = /^(\d+(?:\.\d*)?|\.\d+)\/(\d+(?:\.\d*)?|\.\d+)$/.exec(value);
|
|
832
|
+
return m ? [decl("aspect-ratio", `${m[1]} / ${m[2]}`)] : null;
|
|
833
|
+
}
|
|
660
834
|
}
|
|
661
835
|
}
|
|
662
836
|
default:
|
|
@@ -889,9 +1063,8 @@ function findModeAwareColor(base, theme) {
|
|
|
889
1063
|
}
|
|
890
1064
|
function applyOpacityToHex(hex, opacity) {
|
|
891
1065
|
if (opacity === null) return hex;
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
return `rgba(${rgb.join(",")},${opacity / 100})`;
|
|
1066
|
+
if (hexToRgb(hex) === null) return hex;
|
|
1067
|
+
return colorWithOpacity(hex.trim(), opacity).replace(/ /g, "_");
|
|
895
1068
|
}
|
|
896
1069
|
function substituteModeAwareColorToken(token, theme, colorScheme) {
|
|
897
1070
|
const segments = token.split(":");
|
|
@@ -911,14 +1084,10 @@ function hexToRgb(hex) {
|
|
|
911
1084
|
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
912
1085
|
}
|
|
913
1086
|
function splitOpacity(value) {
|
|
914
|
-
const slash = value.
|
|
1087
|
+
const slash = value.indexOf("/");
|
|
915
1088
|
if (slash === -1) return [value, null];
|
|
916
|
-
const
|
|
917
|
-
|
|
918
|
-
if (opacityText !== "" && Number.isInteger(n) && n >= 0 && n <= 100) {
|
|
919
|
-
return [value.slice(0, slash), n];
|
|
920
|
-
}
|
|
921
|
-
return [value, null];
|
|
1089
|
+
const alpha = parseAlpha(value.slice(slash + 1));
|
|
1090
|
+
return alpha === null ? [value, null] : [value.slice(0, slash), alpha];
|
|
922
1091
|
}
|
|
923
1092
|
function colorValue(theme, parsed) {
|
|
924
1093
|
const value = parsed.value;
|
|
@@ -927,16 +1096,33 @@ function colorValue(theme, parsed) {
|
|
|
927
1096
|
const [name, opacity] = splitOpacity(value);
|
|
928
1097
|
const hex = lookupHex(theme, name);
|
|
929
1098
|
if (hex === null) return null;
|
|
930
|
-
|
|
931
|
-
const rgb = hexToRgb(hex);
|
|
932
|
-
if (rgb === null) return hex;
|
|
933
|
-
return `rgba(${rgb.join(",")},${opacity / 100})`;
|
|
1099
|
+
return opacity === null ? hex : colorWithOpacity(hex, opacity);
|
|
934
1100
|
}
|
|
935
1101
|
var LENGTH_UNITS = ["px", "rem", "em", "%", "vh", "vw"];
|
|
936
1102
|
function looksLikeLength(value) {
|
|
937
1103
|
const unit = LENGTH_UNITS.find((u) => value.endsWith(u));
|
|
938
1104
|
const withoutUnit = unit ? value.slice(0, value.length - unit.length) : value;
|
|
939
|
-
|
|
1105
|
+
if (withoutUnit !== "" && Number.isFinite(Number(withoutUnit))) return true;
|
|
1106
|
+
if (!["calc(", "clamp(", "min(", "max("].some((f) => value.startsWith(f))) return false;
|
|
1107
|
+
return MATH_LENGTH_UNIT.test(value);
|
|
1108
|
+
}
|
|
1109
|
+
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])/;
|
|
1110
|
+
function isLength(parsed, value) {
|
|
1111
|
+
switch (parsed.typeHint ?? null) {
|
|
1112
|
+
case null:
|
|
1113
|
+
return looksLikeLength(value);
|
|
1114
|
+
case "length":
|
|
1115
|
+
case "size":
|
|
1116
|
+
case "line-width":
|
|
1117
|
+
case "percentage":
|
|
1118
|
+
case "number":
|
|
1119
|
+
case "integer":
|
|
1120
|
+
case "absolute-size":
|
|
1121
|
+
case "relative-size":
|
|
1122
|
+
return true;
|
|
1123
|
+
default:
|
|
1124
|
+
return false;
|
|
1125
|
+
}
|
|
940
1126
|
}
|
|
941
1127
|
|
|
942
1128
|
// src/jsEngine/resolvers/border.ts
|
|
@@ -1007,7 +1193,7 @@ function borderValue(theme, parsed) {
|
|
|
1007
1193
|
if (value === "separate") return [decl("border-collapse", "separate")];
|
|
1008
1194
|
}
|
|
1009
1195
|
if (parsed.isArbitrary) {
|
|
1010
|
-
if (
|
|
1196
|
+
if (isLength(parsed, value)) return [decl("border-width", value)];
|
|
1011
1197
|
const color2 = colorValue(theme, parsed);
|
|
1012
1198
|
return color2 === null ? null : [decl("border-color", color2)];
|
|
1013
1199
|
}
|
|
@@ -1025,7 +1211,7 @@ function borderSideValue(theme, parsed, sideProperty) {
|
|
|
1025
1211
|
const value = parsed.value;
|
|
1026
1212
|
if (value === null) return null;
|
|
1027
1213
|
if (parsed.isArbitrary) {
|
|
1028
|
-
if (
|
|
1214
|
+
if (isLength(parsed, value)) return [decl(`${sideProperty}-width`, value)];
|
|
1029
1215
|
const color2 = colorValue(theme, parsed);
|
|
1030
1216
|
return color2 === null ? null : [decl(`${sideProperty}-color`, color2)];
|
|
1031
1217
|
}
|
|
@@ -1043,7 +1229,7 @@ function borderAxisValue(theme, parsed, sideA, sideB) {
|
|
|
1043
1229
|
const value = parsed.value;
|
|
1044
1230
|
if (value === null) return null;
|
|
1045
1231
|
if (parsed.isArbitrary) {
|
|
1046
|
-
if (
|
|
1232
|
+
if (isLength(parsed, value)) return [decl(`${sideA}-width`, value), decl(`${sideB}-width`, value)];
|
|
1047
1233
|
const color2 = colorValue(theme, parsed);
|
|
1048
1234
|
return color2 === null ? null : [decl(`${sideA}-color`, color2), decl(`${sideB}-color`, color2)];
|
|
1049
1235
|
}
|
|
@@ -1101,7 +1287,7 @@ function outlineValue(theme, parsed) {
|
|
|
1101
1287
|
const value = parsed.value;
|
|
1102
1288
|
if (value === null) return null;
|
|
1103
1289
|
if (parsed.isArbitrary) {
|
|
1104
|
-
if (
|
|
1290
|
+
if (isLength(parsed, value)) return [decl("outline-width", value)];
|
|
1105
1291
|
const color2 = colorValue(theme, parsed);
|
|
1106
1292
|
return color2 === null ? null : [decl("outline-color", color2)];
|
|
1107
1293
|
}
|
|
@@ -1114,9 +1300,9 @@ function outlineValue(theme, parsed) {
|
|
|
1114
1300
|
function outlineOffsetValue(parsed) {
|
|
1115
1301
|
const value = parsed.value;
|
|
1116
1302
|
if (value === null) return null;
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
return
|
|
1303
|
+
const v = parsed.isArbitrary ? value : outlineWidthValue(value);
|
|
1304
|
+
if (v === null) return null;
|
|
1305
|
+
return [decl("outline-offset", parsed.negative ? negate(v) : v)];
|
|
1120
1306
|
}
|
|
1121
1307
|
var RADIUS_SIDES = /* @__PURE__ */ new Set(["t", "r", "b", "l", "tl", "tr", "br", "bl"]);
|
|
1122
1308
|
function resolve3(parsed, theme) {
|
|
@@ -1209,6 +1395,55 @@ function lineHeightSize(key) {
|
|
|
1209
1395
|
const n = Number(key);
|
|
1210
1396
|
return Number.isFinite(n) && n >= 0 ? `${n * 0.25}rem` : null;
|
|
1211
1397
|
}
|
|
1398
|
+
function leadingNamed(key) {
|
|
1399
|
+
switch (key) {
|
|
1400
|
+
case "none":
|
|
1401
|
+
return 1;
|
|
1402
|
+
case "tight":
|
|
1403
|
+
return 1.25;
|
|
1404
|
+
case "snug":
|
|
1405
|
+
return 1.375;
|
|
1406
|
+
case "normal":
|
|
1407
|
+
return 1.5;
|
|
1408
|
+
case "relaxed":
|
|
1409
|
+
return 1.625;
|
|
1410
|
+
case "loose":
|
|
1411
|
+
return 2;
|
|
1412
|
+
default:
|
|
1413
|
+
return null;
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
function splitSizeLeading(value) {
|
|
1417
|
+
const i = value.indexOf("/");
|
|
1418
|
+
if (i === -1) return null;
|
|
1419
|
+
const size = textSize(value.slice(0, i));
|
|
1420
|
+
const leading = value.slice(i + 1);
|
|
1421
|
+
return size === null || leading === "" ? null : [size, leading];
|
|
1422
|
+
}
|
|
1423
|
+
function sizeLeadingNative(size, leading) {
|
|
1424
|
+
const rem = (n) => {
|
|
1425
|
+
const unit = size.endsWith("rem") ? "rem" : size.endsWith("px") ? "px" : null;
|
|
1426
|
+
if (unit === null) return null;
|
|
1427
|
+
const number = size.slice(0, -unit.length);
|
|
1428
|
+
const s = Number(number);
|
|
1429
|
+
return number.trim() !== "" && Number.isFinite(s) ? `${s * n}${unit}` : null;
|
|
1430
|
+
};
|
|
1431
|
+
const arbitrary = arbitraryModifier(leading);
|
|
1432
|
+
if (arbitrary !== null) {
|
|
1433
|
+
if (arbitrary.startsWith("var(")) return null;
|
|
1434
|
+
const n = Number(arbitrary);
|
|
1435
|
+
return arbitrary.trim() !== "" && Number.isFinite(n) ? rem(n) : arbitrary;
|
|
1436
|
+
}
|
|
1437
|
+
const scale = lineHeightSize(leading);
|
|
1438
|
+
if (scale !== null) return scale;
|
|
1439
|
+
const m = leadingNamed(leading);
|
|
1440
|
+
return m === null ? null : rem(m);
|
|
1441
|
+
}
|
|
1442
|
+
function arbitraryFontIsWeight(parsed, value) {
|
|
1443
|
+
const hint = parsed.typeHint ?? null;
|
|
1444
|
+
if (hint !== null) return hint === "number" || hint === "integer";
|
|
1445
|
+
return value.trim() !== "" && Number.isFinite(Number(value)) || value.startsWith("var(") && value.endsWith(")") && !value.includes(",");
|
|
1446
|
+
}
|
|
1212
1447
|
function textAlign(key) {
|
|
1213
1448
|
switch (key) {
|
|
1214
1449
|
case "left":
|
|
@@ -1312,14 +1547,20 @@ function nativeShadowDeclarations(parsed) {
|
|
|
1312
1547
|
|
|
1313
1548
|
// src/jsEngine/resolvers/transform.ts
|
|
1314
1549
|
function scaleFactor(parsed) {
|
|
1315
|
-
if (parsed.value === null) return null;
|
|
1550
|
+
if (parsed.value === null || parsed.value.trim() === "") return null;
|
|
1316
1551
|
const n = Number(parsed.value);
|
|
1317
1552
|
if (!Number.isFinite(n)) return null;
|
|
1318
|
-
|
|
1553
|
+
const factor = parsed.isArbitrary ? n : n / 100;
|
|
1554
|
+
return parsed.negative ? -factor : factor;
|
|
1319
1555
|
}
|
|
1320
1556
|
function angle(parsed) {
|
|
1321
1557
|
if (parsed.value === null) return null;
|
|
1322
|
-
if (parsed.isArbitrary)
|
|
1558
|
+
if (parsed.isArbitrary) {
|
|
1559
|
+
if (!parsed.negative) return parsed.value;
|
|
1560
|
+
if (parsed.value.startsWith("-")) return parsed.value.slice(1);
|
|
1561
|
+
if (/^[\d.]/.test(parsed.value)) return `-${parsed.value}`;
|
|
1562
|
+
return `calc(${parsed.value} * -1)`;
|
|
1563
|
+
}
|
|
1323
1564
|
const n = Number(parsed.value);
|
|
1324
1565
|
if (!Number.isFinite(n)) return null;
|
|
1325
1566
|
return `${parsed.negative ? -n : n}deg`;
|
|
@@ -1403,6 +1644,10 @@ function resolveTypographyNative(parsed, theme) {
|
|
|
1403
1644
|
case "font": {
|
|
1404
1645
|
if (parsed.value === null) return null;
|
|
1405
1646
|
if (parsed.isArbitrary) {
|
|
1647
|
+
if (arbitraryFontIsWeight(parsed, parsed.value)) {
|
|
1648
|
+
const n = Number(parsed.value);
|
|
1649
|
+
return /^\d+$/.test(parsed.value) && n % 100 === 0 && n >= 100 && n <= 900 ? [decl("font-weight", parsed.value)] : null;
|
|
1650
|
+
}
|
|
1406
1651
|
return [decl("font-family", firstFontName(parsed.value))];
|
|
1407
1652
|
}
|
|
1408
1653
|
const w = fontWeight(parsed.value);
|
|
@@ -1450,10 +1695,21 @@ function resolveTextNative(parsed, theme) {
|
|
|
1450
1695
|
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
1451
1696
|
const size = textSize(parsed.value);
|
|
1452
1697
|
if (size !== null) return [decl("font-size", size)];
|
|
1698
|
+
const sized = splitSizeLeading(parsed.value);
|
|
1699
|
+
if (sized !== null) {
|
|
1700
|
+
const lh = sizeLeadingNative(sized[0], sized[1]);
|
|
1701
|
+
return lh === null ? null : [decl("font-size", sized[0]), decl("line-height", lh)];
|
|
1702
|
+
}
|
|
1453
1703
|
const align = textAlign(parsed.value);
|
|
1454
1704
|
if (align !== null) return [decl("text-align", align)];
|
|
1455
|
-
} else if (parsed.isArbitrary && parsed.value !== null
|
|
1456
|
-
|
|
1705
|
+
} else if (parsed.isArbitrary && parsed.value !== null) {
|
|
1706
|
+
const leading = parsed.modifier ?? null;
|
|
1707
|
+
if (isLength(parsed, parsed.value)) {
|
|
1708
|
+
if (leading === null) return [decl("font-size", parsed.value)];
|
|
1709
|
+
const lh = sizeLeadingNative(parsed.value, leading);
|
|
1710
|
+
return lh === null ? null : [decl("font-size", parsed.value), decl("line-height", lh)];
|
|
1711
|
+
}
|
|
1712
|
+
if (leading !== null) return null;
|
|
1457
1713
|
}
|
|
1458
1714
|
const hex = nativeHexColor(parsed, theme);
|
|
1459
1715
|
return hex === null ? null : [decl("color", hex)];
|
|
@@ -1644,7 +1900,27 @@ function nativeModifierState(modifier, theme, colorScheme, pressed, width) {
|
|
|
1644
1900
|
}
|
|
1645
1901
|
if (modifier.startsWith("max-[") && modifier.endsWith("]")) {
|
|
1646
1902
|
const px = reduceConstantMath(`calc(${modifier.slice(5, -1).trim()})`);
|
|
1647
|
-
return px === null ? null : width
|
|
1903
|
+
return px === null ? null : width < px;
|
|
1904
|
+
}
|
|
1905
|
+
const screen = (name) => Object.prototype.hasOwnProperty.call(theme.screens, name) ? theme.screens[name] : void 0;
|
|
1906
|
+
const custom = screen(modifier);
|
|
1907
|
+
if (typeof custom === "number") return width >= custom;
|
|
1908
|
+
if (modifier.startsWith("max-")) {
|
|
1909
|
+
const max = screen(modifier.slice(4));
|
|
1910
|
+
if (typeof max === "number") return width < max;
|
|
1911
|
+
}
|
|
1912
|
+
if (modifier.startsWith("min-")) {
|
|
1913
|
+
const min = screen(modifier.slice(4));
|
|
1914
|
+
if (typeof min === "number") return width >= min;
|
|
1915
|
+
}
|
|
1916
|
+
if (modifier.startsWith("not-")) {
|
|
1917
|
+
const rest = modifier.slice(4);
|
|
1918
|
+
if (rest === "dark") return colorScheme !== "dark";
|
|
1919
|
+
const isBreakpoint = (name) => typeof screen(name) === "number";
|
|
1920
|
+
if (isBreakpoint(rest) || (rest.startsWith("max-") || rest.startsWith("min-")) && isBreakpoint(rest.slice(4))) {
|
|
1921
|
+
const holds = nativeModifierState(rest, theme, colorScheme, pressed, width);
|
|
1922
|
+
return holds === null ? null : !holds;
|
|
1923
|
+
}
|
|
1648
1924
|
}
|
|
1649
1925
|
return null;
|
|
1650
1926
|
}
|
|
@@ -1743,6 +2019,11 @@ function sanitizeForWarning(value) {
|
|
|
1743
2019
|
return `${escaped.slice(0, MAX_CHARS)}\u2026`;
|
|
1744
2020
|
}
|
|
1745
2021
|
function rnStyleValue(property, value) {
|
|
2022
|
+
if (value.startsWith("color-mix(in srgb, ") && value.endsWith(", transparent)")) {
|
|
2023
|
+
const inner = value.slice("color-mix(in srgb, ".length, -", transparent)".length);
|
|
2024
|
+
const space = inner.lastIndexOf(" ");
|
|
2025
|
+
if (space !== -1) return rnStyleValue(property, inner.slice(0, space));
|
|
2026
|
+
}
|
|
1746
2027
|
if (property === "aspect-ratio") {
|
|
1747
2028
|
if (value.trim() === "auto") return { value: null, warning: null };
|
|
1748
2029
|
const parts = value.split("/").map((s) => s.trim());
|
|
@@ -1809,7 +2090,7 @@ function resolveStyleJsWithWarnings(classString, theme, colorScheme, pressed, wi
|
|
|
1809
2090
|
if (d.property.startsWith("__")) {
|
|
1810
2091
|
continue;
|
|
1811
2092
|
}
|
|
1812
|
-
if (d.property.startsWith("--") || d.value.includes("var(") || d.property === "outline" || d.property === "object-position" || d.property === "container-type") {
|
|
2093
|
+
if (d.property.startsWith("--") || d.value.includes("var(") || d.property === "outline" || d.property === "object-position" || d.property === "container-type" || d.property === "container-name") {
|
|
1813
2094
|
continue;
|
|
1814
2095
|
}
|
|
1815
2096
|
if (d.property === "shadow-offset-x" || d.property === "shadow-offset-y") {
|