@kbach/react-native 1.0.0-beta.6 → 1.0.0-beta.8
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/README.md +154 -39
- package/dist/ThemeContext-Dc5AC-m0.d.mts +98 -0
- package/dist/ThemeContext-Dc5AC-m0.d.ts +98 -0
- package/dist/{chunk-AEVOM2NB.mjs → chunk-4BXM3QUV.mjs} +38 -57
- package/dist/{chunk-4KCCEMEN.mjs → chunk-CGU7UM2F.mjs} +1 -1
- package/dist/chunk-JR3BLUAV.mjs +1204 -0
- package/dist/chunk-JS5KIGAB.mjs +192 -0
- package/dist/{chunk-OJQAJLYT.mjs → chunk-KV3ZIXSH.mjs} +1 -1
- package/dist/chunk-OIW7OQWO.mjs +40 -0
- package/dist/chunk-Z664AKW7.mjs +54 -0
- package/dist/index.d.mts +21 -98
- package/dist/index.d.ts +21 -98
- package/dist/index.js +1219 -5
- package/dist/index.mjs +8 -6
- package/dist/index.web.d.mts +12 -4
- package/dist/index.web.d.ts +12 -4
- package/dist/index.web.js +101 -36
- package/dist/index.web.mjs +11 -9
- package/dist/jsx-dev-runtime.js +1223 -5
- package/dist/jsx-dev-runtime.mjs +4 -3
- package/dist/jsx-dev-runtime.web.js +108 -71
- package/dist/jsx-dev-runtime.web.mjs +4 -4
- package/dist/jsx-runtime.js +1223 -5
- package/dist/jsx-runtime.mjs +4 -3
- package/dist/jsx-runtime.web.js +93 -61
- package/dist/jsx-runtime.web.mjs +4 -6
- package/package.json +22 -4
- package/dist/chunk-5WK55Z56.mjs +0 -14
- package/dist/chunk-FG5E4NLJ.mjs +0 -18
- package/dist/chunk-T3HPTH62.mjs +0 -161
package/dist/index.js
CHANGED
|
@@ -315,16 +315,49 @@ var PALETTE = {
|
|
|
315
315
|
// src/theme.ts
|
|
316
316
|
var defaultTheme = {
|
|
317
317
|
colors: PALETTE,
|
|
318
|
+
// Real Tailwind's default spacing scale in full — every step is exactly
|
|
319
|
+
// `n * 4px`, including the fractional `.5` steps (`1.5` -> 6px, `2.5` ->
|
|
320
|
+
// 10px, `3.5` -> 14px) and the "px" literal (a bare 1px). Previously
|
|
321
|
+
// this only had {0,1,2,4,6,8} — a handful of spot-checked values, not
|
|
322
|
+
// the real scale — so anything else (`p-3`, `w-5`, `border-2`,
|
|
323
|
+
// `gap-10`, ...) silently failed to resolve. Mirrors @kbach/react's
|
|
324
|
+
// theme.ts exactly.
|
|
318
325
|
spacing: {
|
|
319
|
-
// "0" is always a hardcoded zero in real Tailwind's own scale too,
|
|
320
|
-
// regardless of the base spacing unit — needed for `p-0`/`m-0`/etc.
|
|
321
|
-
// Mirrors the identical fix in @kbach/react's theme.ts.
|
|
322
326
|
"0": 0,
|
|
327
|
+
"px": 1,
|
|
328
|
+
"0.5": 2,
|
|
323
329
|
"1": 4,
|
|
330
|
+
"1.5": 6,
|
|
324
331
|
"2": 8,
|
|
332
|
+
"2.5": 10,
|
|
333
|
+
"3": 12,
|
|
334
|
+
"3.5": 14,
|
|
325
335
|
"4": 16,
|
|
336
|
+
"5": 20,
|
|
326
337
|
"6": 24,
|
|
327
|
-
"
|
|
338
|
+
"7": 28,
|
|
339
|
+
"8": 32,
|
|
340
|
+
"9": 36,
|
|
341
|
+
"10": 40,
|
|
342
|
+
"11": 44,
|
|
343
|
+
"12": 48,
|
|
344
|
+
"14": 56,
|
|
345
|
+
"16": 64,
|
|
346
|
+
"20": 80,
|
|
347
|
+
"24": 96,
|
|
348
|
+
"28": 112,
|
|
349
|
+
"32": 128,
|
|
350
|
+
"36": 144,
|
|
351
|
+
"40": 160,
|
|
352
|
+
"44": 176,
|
|
353
|
+
"48": 192,
|
|
354
|
+
"52": 208,
|
|
355
|
+
"56": 224,
|
|
356
|
+
"60": 240,
|
|
357
|
+
"64": 256,
|
|
358
|
+
"72": 288,
|
|
359
|
+
"80": 320,
|
|
360
|
+
"96": 384
|
|
328
361
|
},
|
|
329
362
|
screens: {
|
|
330
363
|
sm: 640,
|
|
@@ -397,11 +430,1192 @@ function seedDefaultMode(fallback) {
|
|
|
397
430
|
notify();
|
|
398
431
|
}
|
|
399
432
|
|
|
433
|
+
// src/jsEngine/parser.ts
|
|
434
|
+
var VALUE_PREFIXES = [
|
|
435
|
+
"bg-opacity-",
|
|
436
|
+
"text-opacity-",
|
|
437
|
+
"bg-blend-",
|
|
438
|
+
"text-shadow-",
|
|
439
|
+
"bg-",
|
|
440
|
+
"text-",
|
|
441
|
+
"border-x-",
|
|
442
|
+
"border-y-",
|
|
443
|
+
"border-t-",
|
|
444
|
+
"border-r-",
|
|
445
|
+
"border-b-",
|
|
446
|
+
"border-l-",
|
|
447
|
+
"border-",
|
|
448
|
+
"caret-",
|
|
449
|
+
"accent-",
|
|
450
|
+
"fill-",
|
|
451
|
+
"stroke-width-",
|
|
452
|
+
"stroke-",
|
|
453
|
+
"resize-",
|
|
454
|
+
"touch-",
|
|
455
|
+
"will-change-",
|
|
456
|
+
"scroll-mx-",
|
|
457
|
+
"scroll-my-",
|
|
458
|
+
"scroll-mt-",
|
|
459
|
+
"scroll-mr-",
|
|
460
|
+
"scroll-mb-",
|
|
461
|
+
"scroll-ml-",
|
|
462
|
+
"scroll-m-",
|
|
463
|
+
"scroll-px-",
|
|
464
|
+
"scroll-py-",
|
|
465
|
+
"scroll-pt-",
|
|
466
|
+
"scroll-pr-",
|
|
467
|
+
"scroll-pb-",
|
|
468
|
+
"scroll-pl-",
|
|
469
|
+
"scroll-p-",
|
|
470
|
+
"px-",
|
|
471
|
+
"py-",
|
|
472
|
+
"pt-",
|
|
473
|
+
"pr-",
|
|
474
|
+
"pb-",
|
|
475
|
+
"pl-",
|
|
476
|
+
"p-",
|
|
477
|
+
"mx-",
|
|
478
|
+
"my-",
|
|
479
|
+
"mt-",
|
|
480
|
+
"mr-",
|
|
481
|
+
"mb-",
|
|
482
|
+
"ml-",
|
|
483
|
+
"m-",
|
|
484
|
+
"gap-x-",
|
|
485
|
+
"gap-y-",
|
|
486
|
+
"gap-",
|
|
487
|
+
"min-w-",
|
|
488
|
+
"max-w-",
|
|
489
|
+
"w-",
|
|
490
|
+
"min-h-",
|
|
491
|
+
"max-h-",
|
|
492
|
+
"h-",
|
|
493
|
+
"size-",
|
|
494
|
+
"basis-",
|
|
495
|
+
"rounded-tl-",
|
|
496
|
+
"rounded-tr-",
|
|
497
|
+
"rounded-br-",
|
|
498
|
+
"rounded-bl-",
|
|
499
|
+
"rounded-t-",
|
|
500
|
+
"rounded-r-",
|
|
501
|
+
"rounded-b-",
|
|
502
|
+
"rounded-l-",
|
|
503
|
+
"rounded-",
|
|
504
|
+
"ring-offset-",
|
|
505
|
+
"ring-",
|
|
506
|
+
"outline-offset-",
|
|
507
|
+
"outline-",
|
|
508
|
+
"shadow-",
|
|
509
|
+
"opacity-",
|
|
510
|
+
"duration-",
|
|
511
|
+
"delay-",
|
|
512
|
+
"ease-",
|
|
513
|
+
"cursor-",
|
|
514
|
+
"mix-blend-",
|
|
515
|
+
"animate-",
|
|
516
|
+
"leading-",
|
|
517
|
+
"tracking-",
|
|
518
|
+
"font-",
|
|
519
|
+
"z-",
|
|
520
|
+
"inset-",
|
|
521
|
+
"top-",
|
|
522
|
+
"right-",
|
|
523
|
+
"bottom-",
|
|
524
|
+
"left-",
|
|
525
|
+
"divide-color-",
|
|
526
|
+
"space-x-",
|
|
527
|
+
"space-y-",
|
|
528
|
+
"flex-",
|
|
529
|
+
"grow-",
|
|
530
|
+
"shrink-",
|
|
531
|
+
"order-",
|
|
532
|
+
"grid-cols-",
|
|
533
|
+
"grid-rows-",
|
|
534
|
+
"grid-flow-",
|
|
535
|
+
"auto-cols-",
|
|
536
|
+
"auto-rows-",
|
|
537
|
+
"col-span-",
|
|
538
|
+
"col-start-",
|
|
539
|
+
"col-end-",
|
|
540
|
+
"col-",
|
|
541
|
+
"row-span-",
|
|
542
|
+
"row-start-",
|
|
543
|
+
"row-end-",
|
|
544
|
+
"row-",
|
|
545
|
+
"place-items-",
|
|
546
|
+
"place-content-",
|
|
547
|
+
"place-self-",
|
|
548
|
+
"justify-items-",
|
|
549
|
+
"justify-self-",
|
|
550
|
+
"scale-x-",
|
|
551
|
+
"scale-y-",
|
|
552
|
+
"scale-",
|
|
553
|
+
"rotate-",
|
|
554
|
+
"translate-x-",
|
|
555
|
+
"translate-y-",
|
|
556
|
+
"skew-x-",
|
|
557
|
+
"skew-y-",
|
|
558
|
+
"origin-",
|
|
559
|
+
"blur-",
|
|
560
|
+
"brightness-",
|
|
561
|
+
"contrast-",
|
|
562
|
+
"grayscale-",
|
|
563
|
+
"hue-rotate-",
|
|
564
|
+
"invert-",
|
|
565
|
+
"saturate-",
|
|
566
|
+
"sepia-",
|
|
567
|
+
"drop-shadow-",
|
|
568
|
+
"filter-",
|
|
569
|
+
"backdrop-blur-",
|
|
570
|
+
"backdrop-brightness-",
|
|
571
|
+
"backdrop-contrast-",
|
|
572
|
+
"backdrop-grayscale-",
|
|
573
|
+
"backdrop-hue-rotate-",
|
|
574
|
+
"backdrop-invert-",
|
|
575
|
+
"backdrop-opacity-",
|
|
576
|
+
"backdrop-saturate-",
|
|
577
|
+
"backdrop-sepia-",
|
|
578
|
+
"backdrop-filter-",
|
|
579
|
+
"decoration-",
|
|
580
|
+
"underline-offset-",
|
|
581
|
+
"indent-",
|
|
582
|
+
"from-",
|
|
583
|
+
"via-",
|
|
584
|
+
"to-"
|
|
585
|
+
];
|
|
586
|
+
var ARBITRARY_PROPERTY_SENTINEL = "[arbitrary-property]";
|
|
587
|
+
function isSafeArbitraryValue(value) {
|
|
588
|
+
return !value.includes("{") && !value.includes("}") && !value.includes(";");
|
|
589
|
+
}
|
|
590
|
+
function splitRespectingBrackets(token) {
|
|
591
|
+
const parts = [];
|
|
592
|
+
let depth = 0;
|
|
593
|
+
let start = 0;
|
|
594
|
+
for (let i = 0; i < token.length; i++) {
|
|
595
|
+
const ch = token[i];
|
|
596
|
+
if (ch === "[") depth += 1;
|
|
597
|
+
else if (ch === "]") depth -= 1;
|
|
598
|
+
else if (ch === ":" && depth <= 0) {
|
|
599
|
+
parts.push(token.slice(start, i));
|
|
600
|
+
start = i + 1;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
parts.push(token.slice(start));
|
|
604
|
+
return parts;
|
|
605
|
+
}
|
|
606
|
+
function parseClass(token) {
|
|
607
|
+
const parts = splitRespectingBrackets(token);
|
|
608
|
+
let base = parts.pop() ?? token;
|
|
609
|
+
const modifiers = parts;
|
|
610
|
+
const important = base.startsWith("!");
|
|
611
|
+
if (important) {
|
|
612
|
+
base = base.slice(1);
|
|
613
|
+
}
|
|
614
|
+
const negative = base.startsWith("-");
|
|
615
|
+
if (negative) {
|
|
616
|
+
base = base.slice(1);
|
|
617
|
+
}
|
|
618
|
+
if (base.length >= 2 && base.startsWith("[") && base.endsWith("]")) {
|
|
619
|
+
const raw = base.slice(1, -1);
|
|
620
|
+
const colonIdx = raw.indexOf(":");
|
|
621
|
+
if (colonIdx !== -1) {
|
|
622
|
+
const property = raw.slice(0, colonIdx);
|
|
623
|
+
const rawValue = raw.slice(colonIdx + 1);
|
|
624
|
+
if (property !== "" && rawValue !== "" && isSafeArbitraryValue(raw)) {
|
|
625
|
+
const value = rawValue.replace(/_/g, " ");
|
|
626
|
+
return {
|
|
627
|
+
modifiers,
|
|
628
|
+
utility: ARBITRARY_PROPERTY_SENTINEL,
|
|
629
|
+
value: `${property}:${value}`,
|
|
630
|
+
isArbitrary: true,
|
|
631
|
+
important,
|
|
632
|
+
negative,
|
|
633
|
+
original: token
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
for (const prefix of VALUE_PREFIXES) {
|
|
639
|
+
if (!base.startsWith(prefix)) continue;
|
|
640
|
+
const value = base.slice(prefix.length);
|
|
641
|
+
if (value === "") continue;
|
|
642
|
+
if (value.length >= 2 && value.startsWith("[") && value.endsWith("]")) {
|
|
643
|
+
const raw = value.slice(1, -1);
|
|
644
|
+
if (!isSafeArbitraryValue(raw)) {
|
|
645
|
+
continue;
|
|
646
|
+
}
|
|
647
|
+
const spaced = raw.replace(/_/g, " ");
|
|
648
|
+
return {
|
|
649
|
+
modifiers,
|
|
650
|
+
utility: prefix.slice(0, -1),
|
|
651
|
+
value: spaced,
|
|
652
|
+
isArbitrary: true,
|
|
653
|
+
important,
|
|
654
|
+
negative,
|
|
655
|
+
original: token
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
return {
|
|
659
|
+
modifiers,
|
|
660
|
+
utility: prefix.slice(0, -1),
|
|
661
|
+
value,
|
|
662
|
+
isArbitrary: false,
|
|
663
|
+
important,
|
|
664
|
+
negative,
|
|
665
|
+
original: token
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
return {
|
|
669
|
+
modifiers,
|
|
670
|
+
utility: base,
|
|
671
|
+
value: null,
|
|
672
|
+
isArbitrary: false,
|
|
673
|
+
important,
|
|
674
|
+
negative,
|
|
675
|
+
original: token
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
// src/jsEngine/shared.ts
|
|
680
|
+
function decl(property, value) {
|
|
681
|
+
return { property, value };
|
|
682
|
+
}
|
|
683
|
+
function resolveLength(theme, parsed) {
|
|
684
|
+
if (parsed.negative) return null;
|
|
685
|
+
const value = parsed.value;
|
|
686
|
+
if (value === null) return null;
|
|
687
|
+
if (parsed.isArbitrary) return value;
|
|
688
|
+
if (value === "full") return "100%";
|
|
689
|
+
if (value === "auto") return "auto";
|
|
690
|
+
const px = theme.spacing[value];
|
|
691
|
+
return px === void 0 ? null : `${px}px`;
|
|
692
|
+
}
|
|
693
|
+
function resolveNegatableLength(theme, parsed) {
|
|
694
|
+
if (!parsed.negative) return resolveLength(theme, parsed);
|
|
695
|
+
if (parsed.isArbitrary) return null;
|
|
696
|
+
const value = parsed.value;
|
|
697
|
+
if (value === null) return null;
|
|
698
|
+
const px = theme.spacing[value];
|
|
699
|
+
if (px === void 0) return null;
|
|
700
|
+
if (px === 0) return "0px";
|
|
701
|
+
return `-${px}px`;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
// src/jsEngine/resolvers/layout.ts
|
|
705
|
+
function negateRaw(value, negative) {
|
|
706
|
+
return negative ? `-${value}` : value;
|
|
707
|
+
}
|
|
708
|
+
function resolve(parsed, theme) {
|
|
709
|
+
switch (parsed.utility) {
|
|
710
|
+
case "flex":
|
|
711
|
+
return parsed.value === null ? [decl("display", "flex")] : null;
|
|
712
|
+
case "grid":
|
|
713
|
+
return [decl("display", "grid")];
|
|
714
|
+
case "block":
|
|
715
|
+
return [decl("display", "block")];
|
|
716
|
+
case "inline-block":
|
|
717
|
+
return [decl("display", "inline-block")];
|
|
718
|
+
case "inline":
|
|
719
|
+
return [decl("display", "inline")];
|
|
720
|
+
case "inline-flex":
|
|
721
|
+
return [decl("display", "inline-flex")];
|
|
722
|
+
case "inline-grid":
|
|
723
|
+
return [decl("display", "inline-grid")];
|
|
724
|
+
case "contents":
|
|
725
|
+
return [decl("display", "contents")];
|
|
726
|
+
case "flow-root":
|
|
727
|
+
return [decl("display", "flow-root")];
|
|
728
|
+
case "hidden":
|
|
729
|
+
return [decl("display", "none")];
|
|
730
|
+
case "@container":
|
|
731
|
+
return [decl("container-type", "inline-size")];
|
|
732
|
+
case "items-center":
|
|
733
|
+
return [decl("align-items", "center")];
|
|
734
|
+
case "items-start":
|
|
735
|
+
return [decl("align-items", "flex-start")];
|
|
736
|
+
case "items-end":
|
|
737
|
+
return [decl("align-items", "flex-end")];
|
|
738
|
+
case "items-baseline":
|
|
739
|
+
return [decl("align-items", "baseline")];
|
|
740
|
+
case "items-stretch":
|
|
741
|
+
return [decl("align-items", "stretch")];
|
|
742
|
+
case "justify-center":
|
|
743
|
+
return [decl("justify-content", "center")];
|
|
744
|
+
case "justify-start":
|
|
745
|
+
return [decl("justify-content", "flex-start")];
|
|
746
|
+
case "justify-end":
|
|
747
|
+
return [decl("justify-content", "flex-end")];
|
|
748
|
+
case "justify-between":
|
|
749
|
+
return [decl("justify-content", "space-between")];
|
|
750
|
+
case "justify-around":
|
|
751
|
+
return [decl("justify-content", "space-around")];
|
|
752
|
+
case "justify-evenly":
|
|
753
|
+
return [decl("justify-content", "space-evenly")];
|
|
754
|
+
case "content-start":
|
|
755
|
+
return [decl("align-content", "flex-start")];
|
|
756
|
+
case "content-end":
|
|
757
|
+
return [decl("align-content", "flex-end")];
|
|
758
|
+
case "content-center":
|
|
759
|
+
return [decl("align-content", "center")];
|
|
760
|
+
case "content-between":
|
|
761
|
+
return [decl("align-content", "space-between")];
|
|
762
|
+
case "content-around":
|
|
763
|
+
return [decl("align-content", "space-around")];
|
|
764
|
+
case "content-evenly":
|
|
765
|
+
return [decl("align-content", "space-evenly")];
|
|
766
|
+
case "content-stretch":
|
|
767
|
+
return [decl("align-content", "stretch")];
|
|
768
|
+
case "self-auto":
|
|
769
|
+
return [decl("align-self", "auto")];
|
|
770
|
+
case "self-center":
|
|
771
|
+
return [decl("align-self", "center")];
|
|
772
|
+
case "self-start":
|
|
773
|
+
return [decl("align-self", "flex-start")];
|
|
774
|
+
case "self-end":
|
|
775
|
+
return [decl("align-self", "flex-end")];
|
|
776
|
+
case "self-stretch":
|
|
777
|
+
return [decl("align-self", "stretch")];
|
|
778
|
+
case "self-baseline":
|
|
779
|
+
return [decl("align-self", "baseline")];
|
|
780
|
+
case "overflow-hidden":
|
|
781
|
+
return [decl("overflow", "hidden")];
|
|
782
|
+
case "overflow-auto":
|
|
783
|
+
return [decl("overflow", "auto")];
|
|
784
|
+
case "overflow-scroll":
|
|
785
|
+
return [decl("overflow", "scroll")];
|
|
786
|
+
case "overflow-visible":
|
|
787
|
+
return [decl("overflow", "visible")];
|
|
788
|
+
case "static":
|
|
789
|
+
return [decl("position", "static")];
|
|
790
|
+
case "relative":
|
|
791
|
+
return [decl("position", "relative")];
|
|
792
|
+
case "absolute":
|
|
793
|
+
return [decl("position", "absolute")];
|
|
794
|
+
case "fixed":
|
|
795
|
+
return [decl("position", "fixed")];
|
|
796
|
+
case "sticky":
|
|
797
|
+
return [decl("position", "sticky")];
|
|
798
|
+
case "z":
|
|
799
|
+
return parsed.value === null ? null : [decl("z-index", negateRaw(parsed.value, parsed.negative))];
|
|
800
|
+
case "order":
|
|
801
|
+
return parsed.value === null ? null : [decl("order", negateRaw(parsed.value, parsed.negative))];
|
|
802
|
+
case "grow":
|
|
803
|
+
return [decl("flex-grow", parsed.value ?? "1")];
|
|
804
|
+
case "shrink":
|
|
805
|
+
return [decl("flex-shrink", parsed.value ?? "1")];
|
|
806
|
+
// top/right/bottom/left/inset support real Tailwind's negative-value
|
|
807
|
+
// convention ("-top-4") — see resolveNegatableLength's own doc comment.
|
|
808
|
+
case "top": {
|
|
809
|
+
const v = resolveNegatableLength(theme, parsed);
|
|
810
|
+
return v === null ? null : [decl("top", v)];
|
|
811
|
+
}
|
|
812
|
+
case "right": {
|
|
813
|
+
const v = resolveNegatableLength(theme, parsed);
|
|
814
|
+
return v === null ? null : [decl("right", v)];
|
|
815
|
+
}
|
|
816
|
+
case "bottom": {
|
|
817
|
+
const v = resolveNegatableLength(theme, parsed);
|
|
818
|
+
return v === null ? null : [decl("bottom", v)];
|
|
819
|
+
}
|
|
820
|
+
case "left": {
|
|
821
|
+
const v = resolveNegatableLength(theme, parsed);
|
|
822
|
+
return v === null ? null : [decl("left", v)];
|
|
823
|
+
}
|
|
824
|
+
case "inset": {
|
|
825
|
+
const v = resolveNegatableLength(theme, parsed);
|
|
826
|
+
return v === null ? null : [decl("inset", v)];
|
|
827
|
+
}
|
|
828
|
+
case "aspect-square":
|
|
829
|
+
return [decl("aspect-ratio", "1 / 1")];
|
|
830
|
+
case "aspect-video":
|
|
831
|
+
return [decl("aspect-ratio", "16 / 9")];
|
|
832
|
+
default:
|
|
833
|
+
return null;
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
function resolveFlex(parsed, web) {
|
|
837
|
+
if (parsed.utility !== "flex") return null;
|
|
838
|
+
const value = parsed.value;
|
|
839
|
+
if (value === null) return null;
|
|
840
|
+
if (parsed.isArbitrary) return [decl("flex", value)];
|
|
841
|
+
switch (value) {
|
|
842
|
+
case "row":
|
|
843
|
+
return [decl("flex-direction", "row")];
|
|
844
|
+
case "col":
|
|
845
|
+
return [decl("flex-direction", "column")];
|
|
846
|
+
case "row-reverse":
|
|
847
|
+
return [decl("flex-direction", "row-reverse")];
|
|
848
|
+
case "col-reverse":
|
|
849
|
+
return [decl("flex-direction", "column-reverse")];
|
|
850
|
+
case "wrap":
|
|
851
|
+
return [decl("flex-wrap", "wrap")];
|
|
852
|
+
case "wrap-reverse":
|
|
853
|
+
return [decl("flex-wrap", "wrap-reverse")];
|
|
854
|
+
case "nowrap":
|
|
855
|
+
return [decl("flex-wrap", "nowrap")];
|
|
856
|
+
case "1":
|
|
857
|
+
return [decl("flex", "1")];
|
|
858
|
+
case "auto":
|
|
859
|
+
return [decl("flex", web ? "auto" : "1")];
|
|
860
|
+
case "initial":
|
|
861
|
+
return [decl("flex", web ? "initial" : "1")];
|
|
862
|
+
case "none":
|
|
863
|
+
return [decl("flex", web ? "none" : "0")];
|
|
864
|
+
case "grow":
|
|
865
|
+
return [decl("flex-grow", "1")];
|
|
866
|
+
case "grow-0":
|
|
867
|
+
return [decl("flex-grow", "0")];
|
|
868
|
+
case "shrink":
|
|
869
|
+
return [decl("flex-shrink", "1")];
|
|
870
|
+
case "shrink-0":
|
|
871
|
+
return [decl("flex-shrink", "0")];
|
|
872
|
+
default:
|
|
873
|
+
return null;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
// src/jsEngine/resolvers/spacing.ts
|
|
878
|
+
function namedSize(key) {
|
|
879
|
+
switch (key) {
|
|
880
|
+
case "sm":
|
|
881
|
+
return "24rem";
|
|
882
|
+
case "md":
|
|
883
|
+
return "28rem";
|
|
884
|
+
case "lg":
|
|
885
|
+
return "32rem";
|
|
886
|
+
case "xl":
|
|
887
|
+
return "36rem";
|
|
888
|
+
case "2xl":
|
|
889
|
+
return "42rem";
|
|
890
|
+
case "3xl":
|
|
891
|
+
return "48rem";
|
|
892
|
+
case "4xl":
|
|
893
|
+
return "56rem";
|
|
894
|
+
case "5xl":
|
|
895
|
+
return "64rem";
|
|
896
|
+
case "6xl":
|
|
897
|
+
return "72rem";
|
|
898
|
+
case "7xl":
|
|
899
|
+
return "80rem";
|
|
900
|
+
case "8xl":
|
|
901
|
+
return "88rem";
|
|
902
|
+
case "9xl":
|
|
903
|
+
return "96rem";
|
|
904
|
+
default:
|
|
905
|
+
return null;
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
function fractionPercent(value) {
|
|
909
|
+
const slashIdx = value.indexOf("/");
|
|
910
|
+
if (slashIdx === -1) return null;
|
|
911
|
+
const numStr = value.slice(0, slashIdx);
|
|
912
|
+
const denStr = value.slice(slashIdx + 1);
|
|
913
|
+
const num = Number(numStr);
|
|
914
|
+
const den = Number(denStr);
|
|
915
|
+
if (!Number.isFinite(num) || !Number.isFinite(den) || numStr.trim() === "" || denStr.trim() === "") return null;
|
|
916
|
+
if (den === 0) return null;
|
|
917
|
+
const pct = num / den * 100;
|
|
918
|
+
const formatted = pct.toFixed(6);
|
|
919
|
+
const trimmed = formatted.replace(/0+$/, "").replace(/\.$/, "");
|
|
920
|
+
return `${trimmed}%`;
|
|
921
|
+
}
|
|
922
|
+
function cssSizeKeyword(key) {
|
|
923
|
+
switch (key) {
|
|
924
|
+
case "min":
|
|
925
|
+
return "min-content";
|
|
926
|
+
case "max":
|
|
927
|
+
return "max-content";
|
|
928
|
+
case "fit":
|
|
929
|
+
return "fit-content";
|
|
930
|
+
default:
|
|
931
|
+
return null;
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
function resolveSize(theme, parsed) {
|
|
935
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
936
|
+
const named = namedSize(parsed.value);
|
|
937
|
+
if (named !== null) return named;
|
|
938
|
+
const kw = cssSizeKeyword(parsed.value);
|
|
939
|
+
if (kw !== null) return kw;
|
|
940
|
+
const fraction = fractionPercent(parsed.value);
|
|
941
|
+
if (fraction !== null) return fraction;
|
|
942
|
+
}
|
|
943
|
+
return resolveLength(theme, parsed);
|
|
944
|
+
}
|
|
945
|
+
function resolve2(parsed, theme) {
|
|
946
|
+
const length = () => resolveLength(theme, parsed);
|
|
947
|
+
const size = () => resolveSize(theme, parsed);
|
|
948
|
+
const negatableLength = () => resolveNegatableLength(theme, parsed);
|
|
949
|
+
switch (parsed.utility) {
|
|
950
|
+
case "p": {
|
|
951
|
+
const v = length();
|
|
952
|
+
return v === null ? null : [decl("padding", v)];
|
|
953
|
+
}
|
|
954
|
+
case "px": {
|
|
955
|
+
const v = length();
|
|
956
|
+
return v === null ? null : [decl("padding-left", v), decl("padding-right", v)];
|
|
957
|
+
}
|
|
958
|
+
case "py": {
|
|
959
|
+
const v = length();
|
|
960
|
+
return v === null ? null : [decl("padding-top", v), decl("padding-bottom", v)];
|
|
961
|
+
}
|
|
962
|
+
case "pt": {
|
|
963
|
+
const v = length();
|
|
964
|
+
return v === null ? null : [decl("padding-top", v)];
|
|
965
|
+
}
|
|
966
|
+
case "pr": {
|
|
967
|
+
const v = length();
|
|
968
|
+
return v === null ? null : [decl("padding-right", v)];
|
|
969
|
+
}
|
|
970
|
+
case "pb": {
|
|
971
|
+
const v = length();
|
|
972
|
+
return v === null ? null : [decl("padding-bottom", v)];
|
|
973
|
+
}
|
|
974
|
+
case "pl": {
|
|
975
|
+
const v = length();
|
|
976
|
+
return v === null ? null : [decl("padding-left", v)];
|
|
977
|
+
}
|
|
978
|
+
case "m": {
|
|
979
|
+
const v = negatableLength();
|
|
980
|
+
return v === null ? null : [decl("margin", v)];
|
|
981
|
+
}
|
|
982
|
+
case "mx": {
|
|
983
|
+
const v = negatableLength();
|
|
984
|
+
return v === null ? null : [decl("margin-left", v), decl("margin-right", v)];
|
|
985
|
+
}
|
|
986
|
+
case "my": {
|
|
987
|
+
const v = negatableLength();
|
|
988
|
+
return v === null ? null : [decl("margin-top", v), decl("margin-bottom", v)];
|
|
989
|
+
}
|
|
990
|
+
case "mt": {
|
|
991
|
+
const v = negatableLength();
|
|
992
|
+
return v === null ? null : [decl("margin-top", v)];
|
|
993
|
+
}
|
|
994
|
+
case "mr": {
|
|
995
|
+
const v = negatableLength();
|
|
996
|
+
return v === null ? null : [decl("margin-right", v)];
|
|
997
|
+
}
|
|
998
|
+
case "mb": {
|
|
999
|
+
const v = negatableLength();
|
|
1000
|
+
return v === null ? null : [decl("margin-bottom", v)];
|
|
1001
|
+
}
|
|
1002
|
+
case "ml": {
|
|
1003
|
+
const v = negatableLength();
|
|
1004
|
+
return v === null ? null : [decl("margin-left", v)];
|
|
1005
|
+
}
|
|
1006
|
+
case "gap": {
|
|
1007
|
+
const v = length();
|
|
1008
|
+
return v === null ? null : [decl("gap", v)];
|
|
1009
|
+
}
|
|
1010
|
+
case "gap-x": {
|
|
1011
|
+
const v = length();
|
|
1012
|
+
return v === null ? null : [decl("column-gap", v)];
|
|
1013
|
+
}
|
|
1014
|
+
case "gap-y": {
|
|
1015
|
+
const v = length();
|
|
1016
|
+
return v === null ? null : [decl("row-gap", v)];
|
|
1017
|
+
}
|
|
1018
|
+
case "w": {
|
|
1019
|
+
const v = size();
|
|
1020
|
+
return v === null ? null : [decl("width", v)];
|
|
1021
|
+
}
|
|
1022
|
+
case "h": {
|
|
1023
|
+
const v = size();
|
|
1024
|
+
return v === null ? null : [decl("height", v)];
|
|
1025
|
+
}
|
|
1026
|
+
case "min-w": {
|
|
1027
|
+
const v = size();
|
|
1028
|
+
return v === null ? null : [decl("min-width", v)];
|
|
1029
|
+
}
|
|
1030
|
+
case "max-w": {
|
|
1031
|
+
const v = size();
|
|
1032
|
+
return v === null ? null : [decl("max-width", v)];
|
|
1033
|
+
}
|
|
1034
|
+
case "min-h": {
|
|
1035
|
+
const v = size();
|
|
1036
|
+
return v === null ? null : [decl("min-height", v)];
|
|
1037
|
+
}
|
|
1038
|
+
case "max-h": {
|
|
1039
|
+
const v = size();
|
|
1040
|
+
return v === null ? null : [decl("max-height", v)];
|
|
1041
|
+
}
|
|
1042
|
+
case "size": {
|
|
1043
|
+
const v = size();
|
|
1044
|
+
return v === null ? null : [decl("width", v), decl("height", v)];
|
|
1045
|
+
}
|
|
1046
|
+
case "basis": {
|
|
1047
|
+
const v = size();
|
|
1048
|
+
return v === null ? null : [decl("flex-basis", v)];
|
|
1049
|
+
}
|
|
1050
|
+
default:
|
|
1051
|
+
return null;
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
// src/jsEngine/resolvers/color.ts
|
|
1056
|
+
function lookupHex(theme, key) {
|
|
1057
|
+
return theme.colors[key] ?? null;
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
// src/jsEngine/resolvers/border.ts
|
|
1061
|
+
function radiusSize(key) {
|
|
1062
|
+
switch (key) {
|
|
1063
|
+
case "none":
|
|
1064
|
+
return "0px";
|
|
1065
|
+
case "sm":
|
|
1066
|
+
return "0.125rem";
|
|
1067
|
+
case "md":
|
|
1068
|
+
return "0.375rem";
|
|
1069
|
+
case "lg":
|
|
1070
|
+
return "0.5rem";
|
|
1071
|
+
case "xl":
|
|
1072
|
+
return "0.75rem";
|
|
1073
|
+
case "2xl":
|
|
1074
|
+
return "1rem";
|
|
1075
|
+
case "3xl":
|
|
1076
|
+
return "1.5rem";
|
|
1077
|
+
case "full":
|
|
1078
|
+
return "9999px";
|
|
1079
|
+
default:
|
|
1080
|
+
return null;
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
function borderSideProperty(side) {
|
|
1084
|
+
switch (side) {
|
|
1085
|
+
case "t":
|
|
1086
|
+
return "border-top";
|
|
1087
|
+
case "r":
|
|
1088
|
+
return "border-right";
|
|
1089
|
+
case "b":
|
|
1090
|
+
return "border-bottom";
|
|
1091
|
+
case "l":
|
|
1092
|
+
return "border-left";
|
|
1093
|
+
default:
|
|
1094
|
+
return null;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
function borderValue(theme, parsed) {
|
|
1098
|
+
const value = parsed.value;
|
|
1099
|
+
if (value === null) return null;
|
|
1100
|
+
if (!parsed.isArbitrary) {
|
|
1101
|
+
const side = borderSideProperty(value);
|
|
1102
|
+
if (side !== null) {
|
|
1103
|
+
return [decl(`${side}-width`, "1px"), decl(`${side}-style`, "solid")];
|
|
1104
|
+
}
|
|
1105
|
+
if (value === "collapse") return [decl("border-collapse", "collapse")];
|
|
1106
|
+
if (value === "separate") return [decl("border-collapse", "separate")];
|
|
1107
|
+
}
|
|
1108
|
+
if (parsed.isArbitrary) {
|
|
1109
|
+
return [decl("border-width", value)];
|
|
1110
|
+
}
|
|
1111
|
+
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
1112
|
+
const v = resolveLength(theme, parsed);
|
|
1113
|
+
return v === null ? null : [decl("border-width", v)];
|
|
1114
|
+
}
|
|
1115
|
+
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
1116
|
+
return [decl("border-style", value)];
|
|
1117
|
+
}
|
|
1118
|
+
const hex = lookupHex(theme, value);
|
|
1119
|
+
return hex === null ? null : [decl("border-color", hex)];
|
|
1120
|
+
}
|
|
1121
|
+
function borderSideValue(theme, parsed, sideProperty) {
|
|
1122
|
+
const value = parsed.value;
|
|
1123
|
+
if (value === null) return null;
|
|
1124
|
+
if (parsed.isArbitrary) return [decl(`${sideProperty}-width`, value)];
|
|
1125
|
+
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
1126
|
+
const v = resolveLength(theme, parsed);
|
|
1127
|
+
return v === null ? null : [decl(`${sideProperty}-width`, v)];
|
|
1128
|
+
}
|
|
1129
|
+
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
1130
|
+
return [decl(`${sideProperty}-style`, value)];
|
|
1131
|
+
}
|
|
1132
|
+
const hex = lookupHex(theme, value);
|
|
1133
|
+
return hex === null ? null : [decl(`${sideProperty}-color`, hex)];
|
|
1134
|
+
}
|
|
1135
|
+
function borderAxisValue(theme, parsed, sideA, sideB) {
|
|
1136
|
+
const value = parsed.value;
|
|
1137
|
+
if (value === null) return null;
|
|
1138
|
+
if (parsed.isArbitrary) return [decl(`${sideA}-width`, value), decl(`${sideB}-width`, value)];
|
|
1139
|
+
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
1140
|
+
const v = resolveLength(theme, parsed);
|
|
1141
|
+
return v === null ? null : [decl(`${sideA}-width`, v), decl(`${sideB}-width`, v)];
|
|
1142
|
+
}
|
|
1143
|
+
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
1144
|
+
return [decl(`${sideA}-style`, value), decl(`${sideB}-style`, value)];
|
|
1145
|
+
}
|
|
1146
|
+
const hex = lookupHex(theme, value);
|
|
1147
|
+
return hex === null ? null : [decl(`${sideA}-color`, hex), decl(`${sideB}-color`, hex)];
|
|
1148
|
+
}
|
|
1149
|
+
function radiusProperties(side) {
|
|
1150
|
+
switch (side) {
|
|
1151
|
+
case "t":
|
|
1152
|
+
return ["border-top-left-radius", "border-top-right-radius"];
|
|
1153
|
+
case "r":
|
|
1154
|
+
return ["border-top-right-radius", "border-bottom-right-radius"];
|
|
1155
|
+
case "b":
|
|
1156
|
+
return ["border-bottom-right-radius", "border-bottom-left-radius"];
|
|
1157
|
+
case "l":
|
|
1158
|
+
return ["border-top-left-radius", "border-bottom-left-radius"];
|
|
1159
|
+
case "tl":
|
|
1160
|
+
return ["border-top-left-radius"];
|
|
1161
|
+
case "tr":
|
|
1162
|
+
return ["border-top-right-radius"];
|
|
1163
|
+
case "br":
|
|
1164
|
+
return ["border-bottom-right-radius"];
|
|
1165
|
+
case "bl":
|
|
1166
|
+
return ["border-bottom-left-radius"];
|
|
1167
|
+
default:
|
|
1168
|
+
return null;
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
function resolveRadiusValue(theme, parsed) {
|
|
1172
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
1173
|
+
const size = radiusSize(parsed.value);
|
|
1174
|
+
if (size !== null) return size;
|
|
1175
|
+
}
|
|
1176
|
+
return resolveLength(theme, parsed);
|
|
1177
|
+
}
|
|
1178
|
+
function resolveRadiusSide(theme, parsed, side) {
|
|
1179
|
+
const properties = radiusProperties(side);
|
|
1180
|
+
if (properties === null) return null;
|
|
1181
|
+
const value = resolveRadiusValue(theme, parsed);
|
|
1182
|
+
if (value === null) return null;
|
|
1183
|
+
return properties.map((p) => decl(p, value));
|
|
1184
|
+
}
|
|
1185
|
+
var OUTLINE_STYLES = ["solid", "dashed", "dotted", "double"];
|
|
1186
|
+
function outlineWidthValue(key) {
|
|
1187
|
+
switch (key) {
|
|
1188
|
+
case "0":
|
|
1189
|
+
return "0px";
|
|
1190
|
+
case "1":
|
|
1191
|
+
return "1px";
|
|
1192
|
+
case "2":
|
|
1193
|
+
return "2px";
|
|
1194
|
+
case "4":
|
|
1195
|
+
return "4px";
|
|
1196
|
+
case "8":
|
|
1197
|
+
return "8px";
|
|
1198
|
+
default:
|
|
1199
|
+
return null;
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
function outlineValue(theme, parsed) {
|
|
1203
|
+
const value = parsed.value;
|
|
1204
|
+
if (value === null) return null;
|
|
1205
|
+
if (parsed.isArbitrary) return [decl("outline-width", value)];
|
|
1206
|
+
const w = outlineWidthValue(value);
|
|
1207
|
+
if (w !== null) return [decl("outline-width", w)];
|
|
1208
|
+
if (OUTLINE_STYLES.includes(value)) return [decl("outline-style", value)];
|
|
1209
|
+
const hex = lookupHex(theme, value);
|
|
1210
|
+
return hex === null ? null : [decl("outline-color", hex)];
|
|
1211
|
+
}
|
|
1212
|
+
function outlineOffsetValue(parsed) {
|
|
1213
|
+
const value = parsed.value;
|
|
1214
|
+
if (value === null) return null;
|
|
1215
|
+
if (parsed.isArbitrary) return [decl("outline-offset", value)];
|
|
1216
|
+
const w = outlineWidthValue(value);
|
|
1217
|
+
return w === null ? null : [decl("outline-offset", w)];
|
|
1218
|
+
}
|
|
1219
|
+
var RING_BOX_SHADOW = "var(--kb-ring-inset,) 0 0 0 var(--kb-ring-offset-width, 0px) var(--kb-ring-offset-color, #fff), var(--kb-ring-inset,) 0 0 0 calc(var(--kb-ring-width, 0px) + var(--kb-ring-offset-width, 0px)) var(--kb-ring-color, rgba(59,130,246,0.5))";
|
|
1220
|
+
function ringWidth(key) {
|
|
1221
|
+
switch (key) {
|
|
1222
|
+
case "0":
|
|
1223
|
+
return "0px";
|
|
1224
|
+
case "1":
|
|
1225
|
+
return "1px";
|
|
1226
|
+
case "2":
|
|
1227
|
+
return "2px";
|
|
1228
|
+
case "4":
|
|
1229
|
+
return "4px";
|
|
1230
|
+
case "8":
|
|
1231
|
+
return "8px";
|
|
1232
|
+
default:
|
|
1233
|
+
return null;
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
function ringValue(theme, parsed) {
|
|
1237
|
+
const value = parsed.value;
|
|
1238
|
+
if (value === null) return null;
|
|
1239
|
+
if (value === "inset") {
|
|
1240
|
+
return [decl("--kb-ring-inset", "inset"), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1241
|
+
}
|
|
1242
|
+
if (!parsed.isArbitrary) {
|
|
1243
|
+
const w = ringWidth(value);
|
|
1244
|
+
if (w !== null) return [decl("--kb-ring-width", w), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1245
|
+
}
|
|
1246
|
+
const color = parsed.isArbitrary ? value : lookupHex(theme, value);
|
|
1247
|
+
if (color === null) return null;
|
|
1248
|
+
return [decl("--kb-ring-color", color), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1249
|
+
}
|
|
1250
|
+
function ringOffsetValue(theme, parsed) {
|
|
1251
|
+
const value = parsed.value;
|
|
1252
|
+
if (value === null) return null;
|
|
1253
|
+
if (!parsed.isArbitrary) {
|
|
1254
|
+
const w = ringWidth(value);
|
|
1255
|
+
if (w !== null) return [decl("--kb-ring-offset-width", w), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1256
|
+
}
|
|
1257
|
+
const color = parsed.isArbitrary ? value : lookupHex(theme, value);
|
|
1258
|
+
if (color === null) return null;
|
|
1259
|
+
return [decl("--kb-ring-offset-color", color), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1260
|
+
}
|
|
1261
|
+
var RADIUS_SIDES = /* @__PURE__ */ new Set(["t", "r", "b", "l", "tl", "tr", "br", "bl"]);
|
|
1262
|
+
function resolve3(parsed, theme) {
|
|
1263
|
+
switch (parsed.utility) {
|
|
1264
|
+
case "border":
|
|
1265
|
+
if (parsed.value === null) return [decl("border-width", "1px"), decl("border-style", "solid")];
|
|
1266
|
+
return borderValue(theme, parsed);
|
|
1267
|
+
case "border-t":
|
|
1268
|
+
return borderSideValue(theme, parsed, "border-top");
|
|
1269
|
+
case "border-r":
|
|
1270
|
+
return borderSideValue(theme, parsed, "border-right");
|
|
1271
|
+
case "border-b":
|
|
1272
|
+
return borderSideValue(theme, parsed, "border-bottom");
|
|
1273
|
+
case "border-l":
|
|
1274
|
+
return borderSideValue(theme, parsed, "border-left");
|
|
1275
|
+
case "border-x":
|
|
1276
|
+
return borderAxisValue(theme, parsed, "border-left", "border-right");
|
|
1277
|
+
case "border-y":
|
|
1278
|
+
return borderAxisValue(theme, parsed, "border-top", "border-bottom");
|
|
1279
|
+
case "rounded": {
|
|
1280
|
+
if (parsed.value === null) return [decl("border-radius", "0.25rem")];
|
|
1281
|
+
const value = parsed.value;
|
|
1282
|
+
if (!parsed.isArbitrary) {
|
|
1283
|
+
const size = radiusSize(value);
|
|
1284
|
+
if (size !== null) return [decl("border-radius", size)];
|
|
1285
|
+
}
|
|
1286
|
+
const v = resolveLength(theme, parsed);
|
|
1287
|
+
return v === null ? null : [decl("border-radius", v)];
|
|
1288
|
+
}
|
|
1289
|
+
case "ring":
|
|
1290
|
+
if (parsed.value === null) return [decl("--kb-ring-width", "3px"), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1291
|
+
return ringValue(theme, parsed);
|
|
1292
|
+
case "ring-offset":
|
|
1293
|
+
return ringOffsetValue(theme, parsed);
|
|
1294
|
+
case "outline":
|
|
1295
|
+
if (parsed.value === null) return [decl("outline-style", "solid")];
|
|
1296
|
+
if (parsed.value === "none") return [decl("outline", "none")];
|
|
1297
|
+
return outlineValue(theme, parsed);
|
|
1298
|
+
case "outline-offset":
|
|
1299
|
+
return outlineOffsetValue(parsed);
|
|
1300
|
+
default:
|
|
1301
|
+
if (parsed.utility.startsWith("rounded-") && RADIUS_SIDES.has(parsed.utility.slice("rounded-".length))) {
|
|
1302
|
+
return resolveRadiusSide(theme, parsed, parsed.utility.slice("rounded-".length));
|
|
1303
|
+
}
|
|
1304
|
+
return null;
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
// src/jsEngine/resolvers/typography.ts
|
|
1309
|
+
function textSize(key) {
|
|
1310
|
+
switch (key) {
|
|
1311
|
+
case "xs":
|
|
1312
|
+
return "0.75rem";
|
|
1313
|
+
case "sm":
|
|
1314
|
+
return "0.875rem";
|
|
1315
|
+
case "base":
|
|
1316
|
+
return "1rem";
|
|
1317
|
+
case "lg":
|
|
1318
|
+
return "1.125rem";
|
|
1319
|
+
case "xl":
|
|
1320
|
+
return "1.25rem";
|
|
1321
|
+
case "2xl":
|
|
1322
|
+
return "1.5rem";
|
|
1323
|
+
case "3xl":
|
|
1324
|
+
return "1.875rem";
|
|
1325
|
+
case "4xl":
|
|
1326
|
+
return "2.25rem";
|
|
1327
|
+
default:
|
|
1328
|
+
return null;
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
function lineHeightSize(key) {
|
|
1332
|
+
switch (key) {
|
|
1333
|
+
case "3":
|
|
1334
|
+
return "0.75rem";
|
|
1335
|
+
case "4":
|
|
1336
|
+
return "1rem";
|
|
1337
|
+
case "5":
|
|
1338
|
+
return "1.25rem";
|
|
1339
|
+
case "6":
|
|
1340
|
+
return "1.5rem";
|
|
1341
|
+
case "7":
|
|
1342
|
+
return "1.75rem";
|
|
1343
|
+
case "8":
|
|
1344
|
+
return "2rem";
|
|
1345
|
+
case "9":
|
|
1346
|
+
return "2.25rem";
|
|
1347
|
+
case "10":
|
|
1348
|
+
return "2.5rem";
|
|
1349
|
+
default:
|
|
1350
|
+
return null;
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
function textAlign(key) {
|
|
1354
|
+
switch (key) {
|
|
1355
|
+
case "left":
|
|
1356
|
+
return "left";
|
|
1357
|
+
case "center":
|
|
1358
|
+
return "center";
|
|
1359
|
+
case "right":
|
|
1360
|
+
return "right";
|
|
1361
|
+
case "justify":
|
|
1362
|
+
return "justify";
|
|
1363
|
+
default:
|
|
1364
|
+
return null;
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
function fontWeight(key) {
|
|
1368
|
+
switch (key) {
|
|
1369
|
+
case "thin":
|
|
1370
|
+
return "100";
|
|
1371
|
+
case "normal":
|
|
1372
|
+
return "400";
|
|
1373
|
+
case "medium":
|
|
1374
|
+
return "500";
|
|
1375
|
+
case "semibold":
|
|
1376
|
+
return "600";
|
|
1377
|
+
case "bold":
|
|
1378
|
+
return "700";
|
|
1379
|
+
case "extrabold":
|
|
1380
|
+
return "800";
|
|
1381
|
+
default:
|
|
1382
|
+
return null;
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
// src/jsEngine/resolvers/effects.ts
|
|
1387
|
+
function nativeShadowValue(key) {
|
|
1388
|
+
switch (key) {
|
|
1389
|
+
case "sm":
|
|
1390
|
+
return { offsetY: 1, radius: 2, opacity: 0.05, elevation: 1 };
|
|
1391
|
+
case "DEFAULT":
|
|
1392
|
+
return { offsetY: 1, radius: 3, opacity: 0.1, elevation: 2 };
|
|
1393
|
+
case "md":
|
|
1394
|
+
return { offsetY: 4, radius: 6, opacity: 0.1, elevation: 4 };
|
|
1395
|
+
case "lg":
|
|
1396
|
+
return { offsetY: 10, radius: 15, opacity: 0.1, elevation: 8 };
|
|
1397
|
+
case "xl":
|
|
1398
|
+
return { offsetY: 20, radius: 25, opacity: 0.1, elevation: 12 };
|
|
1399
|
+
case "2xl":
|
|
1400
|
+
return { offsetY: 25, radius: 50, opacity: 0.25, elevation: 16 };
|
|
1401
|
+
case "none":
|
|
1402
|
+
return { offsetY: 0, radius: 0, opacity: 0, elevation: 0 };
|
|
1403
|
+
default:
|
|
1404
|
+
return null;
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
function nativeShadowDeclarations(parsed) {
|
|
1408
|
+
if (parsed.utility !== "shadow" || parsed.isArbitrary) return null;
|
|
1409
|
+
const key = parsed.value ?? "DEFAULT";
|
|
1410
|
+
const s = nativeShadowValue(key);
|
|
1411
|
+
if (s === null) return null;
|
|
1412
|
+
return [
|
|
1413
|
+
decl("shadow-color", "#000000"),
|
|
1414
|
+
decl("shadow-offset-x", "0"),
|
|
1415
|
+
decl("shadow-offset-y", String(s.offsetY)),
|
|
1416
|
+
decl("shadow-opacity", String(s.opacity)),
|
|
1417
|
+
decl("shadow-radius", String(s.radius)),
|
|
1418
|
+
decl("elevation", String(s.elevation))
|
|
1419
|
+
];
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
// src/jsEngine/resolveUtilityNative.ts
|
|
1423
|
+
function resolveTypographyNative(parsed) {
|
|
1424
|
+
switch (parsed.utility) {
|
|
1425
|
+
case "font": {
|
|
1426
|
+
if (parsed.value === null) return null;
|
|
1427
|
+
const w = fontWeight(parsed.value);
|
|
1428
|
+
return w === null ? null : [decl("font-weight", w)];
|
|
1429
|
+
}
|
|
1430
|
+
case "uppercase":
|
|
1431
|
+
return [decl("text-transform", "uppercase")];
|
|
1432
|
+
case "lowercase":
|
|
1433
|
+
return [decl("text-transform", "lowercase")];
|
|
1434
|
+
case "capitalize":
|
|
1435
|
+
return [decl("text-transform", "capitalize")];
|
|
1436
|
+
case "underline":
|
|
1437
|
+
return [decl("text-decoration-line", "underline")];
|
|
1438
|
+
case "line-through":
|
|
1439
|
+
return [decl("text-decoration-line", "line-through")];
|
|
1440
|
+
case "no-underline":
|
|
1441
|
+
return [decl("text-decoration-line", "none")];
|
|
1442
|
+
case "italic":
|
|
1443
|
+
return [decl("font-style", "italic")];
|
|
1444
|
+
case "not-italic":
|
|
1445
|
+
return [decl("font-style", "normal")];
|
|
1446
|
+
default:
|
|
1447
|
+
return null;
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
function resolveLeadingTrackingNative(parsed) {
|
|
1451
|
+
const value = parsed.value;
|
|
1452
|
+
if (value === null) return null;
|
|
1453
|
+
if (parsed.utility === "leading") {
|
|
1454
|
+
if (parsed.isArbitrary) return [decl("line-height", value)];
|
|
1455
|
+
const v = lineHeightSize(value);
|
|
1456
|
+
return v === null ? null : [decl("line-height", v)];
|
|
1457
|
+
}
|
|
1458
|
+
if (parsed.utility === "tracking" && parsed.isArbitrary) {
|
|
1459
|
+
return [decl("letter-spacing", value)];
|
|
1460
|
+
}
|
|
1461
|
+
return null;
|
|
1462
|
+
}
|
|
1463
|
+
function nativeHexColor(parsed, theme) {
|
|
1464
|
+
const value = parsed.value;
|
|
1465
|
+
if (value === null) return null;
|
|
1466
|
+
return parsed.isArbitrary ? value : lookupHex(theme, value);
|
|
1467
|
+
}
|
|
1468
|
+
function resolveTextNative(parsed, theme) {
|
|
1469
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
1470
|
+
const size = textSize(parsed.value);
|
|
1471
|
+
if (size !== null) return [decl("font-size", size)];
|
|
1472
|
+
const align = textAlign(parsed.value);
|
|
1473
|
+
if (align !== null) return [decl("text-align", align)];
|
|
1474
|
+
}
|
|
1475
|
+
const hex = nativeHexColor(parsed, theme);
|
|
1476
|
+
return hex === null ? null : [decl("color", hex)];
|
|
1477
|
+
}
|
|
1478
|
+
function resolveColorNative(parsed, theme) {
|
|
1479
|
+
switch (parsed.utility) {
|
|
1480
|
+
case "bg": {
|
|
1481
|
+
const hex = nativeHexColor(parsed, theme);
|
|
1482
|
+
return hex === null ? null : [decl("background-color", hex)];
|
|
1483
|
+
}
|
|
1484
|
+
case "text":
|
|
1485
|
+
return resolveTextNative(parsed, theme);
|
|
1486
|
+
default:
|
|
1487
|
+
return null;
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
function resolveUtilityNative(parsed, theme) {
|
|
1491
|
+
return resolveFlex(parsed, false) ?? resolve(parsed, theme) ?? resolve2(parsed, theme) ?? resolve3(parsed, theme) ?? resolveColorNative(parsed, theme) ?? resolveLeadingTrackingNative(parsed) ?? resolveTypographyNative(parsed) ?? nativeShadowDeclarations(parsed);
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
// src/jsEngine/resolveStyle.ts
|
|
1495
|
+
var RESPONSIVE_BREAKPOINTS = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
|
|
1496
|
+
function nativeModifierState(modifier, theme, colorScheme, pressed, width) {
|
|
1497
|
+
if (modifier === "dark") return colorScheme === "dark";
|
|
1498
|
+
if (modifier === "active") return pressed;
|
|
1499
|
+
if (RESPONSIVE_BREAKPOINTS.has(modifier)) {
|
|
1500
|
+
const minWidth = theme.screens[modifier];
|
|
1501
|
+
if (minWidth === void 0) return null;
|
|
1502
|
+
return width >= minWidth;
|
|
1503
|
+
}
|
|
1504
|
+
return null;
|
|
1505
|
+
}
|
|
1506
|
+
function kebabToCamel(s) {
|
|
1507
|
+
return s.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
1508
|
+
}
|
|
1509
|
+
var NUMERIC_LENGTH_PROPS = /* @__PURE__ */ new Set([
|
|
1510
|
+
"padding",
|
|
1511
|
+
"padding-top",
|
|
1512
|
+
"padding-right",
|
|
1513
|
+
"padding-bottom",
|
|
1514
|
+
"padding-left",
|
|
1515
|
+
"margin",
|
|
1516
|
+
"margin-top",
|
|
1517
|
+
"margin-right",
|
|
1518
|
+
"margin-bottom",
|
|
1519
|
+
"margin-left",
|
|
1520
|
+
"gap",
|
|
1521
|
+
"column-gap",
|
|
1522
|
+
"row-gap",
|
|
1523
|
+
"width",
|
|
1524
|
+
"height",
|
|
1525
|
+
"min-width",
|
|
1526
|
+
"max-width",
|
|
1527
|
+
"min-height",
|
|
1528
|
+
"max-height",
|
|
1529
|
+
"top",
|
|
1530
|
+
"right",
|
|
1531
|
+
"bottom",
|
|
1532
|
+
"left",
|
|
1533
|
+
"inset",
|
|
1534
|
+
"border-radius",
|
|
1535
|
+
"border-width",
|
|
1536
|
+
"font-size",
|
|
1537
|
+
"z-index",
|
|
1538
|
+
"line-height",
|
|
1539
|
+
"letter-spacing",
|
|
1540
|
+
"flex",
|
|
1541
|
+
"flex-grow",
|
|
1542
|
+
"flex-shrink",
|
|
1543
|
+
"order",
|
|
1544
|
+
"flex-basis",
|
|
1545
|
+
"shadow-opacity",
|
|
1546
|
+
"shadow-radius",
|
|
1547
|
+
"elevation",
|
|
1548
|
+
// Per-side border width + per-corner radius — see resolvers/border.ts's
|
|
1549
|
+
// new borderSideValue/borderAxisValue/resolveRadiusSide additions; RN's
|
|
1550
|
+
// style system wants plain numbers for these exactly like the generic
|
|
1551
|
+
// "border-width"/"border-radius" forms above.
|
|
1552
|
+
"border-top-width",
|
|
1553
|
+
"border-right-width",
|
|
1554
|
+
"border-bottom-width",
|
|
1555
|
+
"border-left-width",
|
|
1556
|
+
"border-top-left-radius",
|
|
1557
|
+
"border-top-right-radius",
|
|
1558
|
+
"border-bottom-right-radius",
|
|
1559
|
+
"border-bottom-left-radius",
|
|
1560
|
+
"outline-width",
|
|
1561
|
+
"outline-offset"
|
|
1562
|
+
]);
|
|
1563
|
+
function rnStyleValue(property, value) {
|
|
1564
|
+
if (NUMERIC_LENGTH_PROPS.has(property)) {
|
|
1565
|
+
let px = null;
|
|
1566
|
+
if (value.endsWith("px")) {
|
|
1567
|
+
const n = Number(value.slice(0, -2));
|
|
1568
|
+
px = Number.isFinite(n) ? n : null;
|
|
1569
|
+
} else if (value.endsWith("rem")) {
|
|
1570
|
+
const n = Number(value.slice(0, -3));
|
|
1571
|
+
px = Number.isFinite(n) ? n * 16 : null;
|
|
1572
|
+
} else {
|
|
1573
|
+
const n = Number(value);
|
|
1574
|
+
px = value.trim() !== "" && Number.isFinite(n) ? n : null;
|
|
1575
|
+
}
|
|
1576
|
+
if (px !== null) return px;
|
|
1577
|
+
}
|
|
1578
|
+
return value;
|
|
1579
|
+
}
|
|
1580
|
+
function resolveStyleJs(classString, theme, colorScheme, pressed, width) {
|
|
1581
|
+
const style = {};
|
|
1582
|
+
let shadowOffset = null;
|
|
1583
|
+
for (const token of classString.split(/\s+/).filter(Boolean)) {
|
|
1584
|
+
const parsed = parseClass(token);
|
|
1585
|
+
const allModifiersHold = parsed.modifiers.every(
|
|
1586
|
+
(m) => nativeModifierState(m, theme, colorScheme, pressed, width) === true
|
|
1587
|
+
);
|
|
1588
|
+
if (!allModifiersHold) continue;
|
|
1589
|
+
const decls = resolveUtilityNative(parsed, theme);
|
|
1590
|
+
if (decls === null) continue;
|
|
1591
|
+
for (const d of decls) {
|
|
1592
|
+
if (d.property.startsWith("__")) {
|
|
1593
|
+
continue;
|
|
1594
|
+
}
|
|
1595
|
+
if (d.property === "shadow-offset-x" || d.property === "shadow-offset-y") {
|
|
1596
|
+
const n = Number(d.value);
|
|
1597
|
+
if (!Number.isFinite(n)) continue;
|
|
1598
|
+
if (shadowOffset === null) shadowOffset = {};
|
|
1599
|
+
shadowOffset[d.property === "shadow-offset-x" ? "width" : "height"] = n;
|
|
1600
|
+
continue;
|
|
1601
|
+
}
|
|
1602
|
+
style[kebabToCamel(d.property)] = rnStyleValue(d.property, d.value);
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
if (shadowOffset !== null) {
|
|
1606
|
+
style.shadowOffset = { width: shadowOffset.width ?? 0, height: shadowOffset.height ?? 0 };
|
|
1607
|
+
}
|
|
1608
|
+
return style;
|
|
1609
|
+
}
|
|
1610
|
+
|
|
400
1611
|
// src/nativeBridge.ts
|
|
401
1612
|
function resolveStyle(classString, pressed = false) {
|
|
402
|
-
const KbachModule = import_react_native2.TurboModuleRegistry.getEnforcing("KbachModule");
|
|
403
1613
|
const colorScheme = getGlobalDarkMode() ? "dark" : "light";
|
|
404
1614
|
const width = import_react_native2.Dimensions.get("window").width;
|
|
1615
|
+
const KbachModule = import_react_native2.TurboModuleRegistry.get("KbachModule");
|
|
1616
|
+
if (!KbachModule) {
|
|
1617
|
+
return resolveStyleJs(classString, getTheme(), colorScheme, pressed, width);
|
|
1618
|
+
}
|
|
405
1619
|
const json = KbachModule.resolveStyle(classString, getThemeJson(), colorScheme, pressed, width);
|
|
406
1620
|
return JSON.parse(json);
|
|
407
1621
|
}
|