@kbach/react-native 1.0.0-beta.1 → 1.0.0-beta.11

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.
Files changed (46) hide show
  1. package/README.md +87 -66
  2. package/android/build.gradle +36 -0
  3. package/android/src/main/AndroidManifest.xml +14 -0
  4. package/android/src/main/java/com/kbachnative/KbachModule.kt +83 -0
  5. package/android/src/main/java/com/kbachnative/KbachPackage.kt +54 -0
  6. package/android/src/main/jniLibs/arm64-v8a/libkbach_core_engine.so +0 -0
  7. package/android/src/main/jniLibs/x86_64/libkbach_core_engine.so +0 -0
  8. package/dist/chunk-4DQXTAM3.mjs +63 -0
  9. package/dist/chunk-5MU6PEXV.mjs +14 -0
  10. package/dist/chunk-H5Z24XX5.mjs +192 -0
  11. package/dist/{chunk-YHF3QLRL.mjs → chunk-HK6PDJJK.mjs} +61 -68
  12. package/dist/chunk-RBJXE32L.mjs +73 -0
  13. package/dist/chunk-TDWBXJH5.mjs +186 -0
  14. package/dist/chunk-XHL653X2.mjs +1211 -0
  15. package/dist/chunk-YOC3SHF5.mjs +40 -0
  16. package/dist/index.d.mts +37 -102
  17. package/dist/index.d.ts +37 -102
  18. package/dist/index.js +1411 -38
  19. package/dist/index.mjs +19 -61
  20. package/dist/index.web.d.mts +15 -0
  21. package/dist/index.web.d.ts +15 -0
  22. package/dist/index.web.js +829 -0
  23. package/dist/index.web.mjs +38 -0
  24. package/dist/jsx-dev-runtime.d.mts +3 -12
  25. package/dist/jsx-dev-runtime.d.ts +3 -12
  26. package/dist/jsx-dev-runtime.js +1313 -36
  27. package/dist/jsx-dev-runtime.mjs +9 -11
  28. package/dist/jsx-dev-runtime.web.d.mts +10 -0
  29. package/dist/jsx-dev-runtime.web.d.ts +10 -0
  30. package/dist/jsx-dev-runtime.web.js +659 -0
  31. package/dist/jsx-dev-runtime.web.mjs +18 -0
  32. package/dist/jsx-runtime.d.mts +3 -23
  33. package/dist/jsx-runtime.d.ts +3 -23
  34. package/dist/jsx-runtime.js +1304 -28
  35. package/dist/jsx-runtime.mjs +7 -3
  36. package/dist/jsx-runtime.web.d.mts +7 -0
  37. package/dist/jsx-runtime.web.d.ts +7 -0
  38. package/dist/jsx-runtime.web.js +602 -0
  39. package/dist/jsx-runtime.web.mjs +12 -0
  40. package/dist/useColors-C6jyCLuG.d.mts +239 -0
  41. package/dist/useColors-C6jyCLuG.d.ts +239 -0
  42. package/package.json +57 -8
  43. package/react-native.config.js +29 -0
  44. package/specs/NativeKbachModule.ts +31 -0
  45. package/src/babel-plugin.js +74 -2
  46. package/dist/chunk-SVMYVXY6.mjs +0 -44
package/dist/index.js CHANGED
@@ -21,16 +21,18 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
23
  ThemeProvider: () => ThemeProvider,
24
+ applyKbachConfig: () => applyKbachConfig,
24
25
  defaultTheme: () => defaultTheme,
25
26
  getGlobalDarkMode: () => getGlobalDarkMode,
26
27
  getGlobalThemeMode: () => getGlobalThemeMode,
27
28
  getTheme: () => getTheme,
29
+ resolveKbachConfig: () => resolveKbachConfig,
28
30
  resolveStyle: () => resolveStyle,
29
31
  setGlobalThemeMode: () => setGlobalThemeMode,
30
32
  setTheme: () => setTheme,
31
33
  subscribeGlobalDarkMode: () => subscribeGlobalDarkMode,
32
34
  toggleGlobalDarkMode: () => toggleGlobalDarkMode,
33
- useGlobalDarkMode: () => useGlobalDarkMode,
35
+ useColors: () => useColors,
34
36
  useTheme: () => useTheme
35
37
  });
36
38
  module.exports = __toCommonJS(src_exports);
@@ -315,19 +317,73 @@ var PALETTE = {
315
317
  // src/theme.ts
316
318
  var defaultTheme = {
317
319
  colors: PALETTE,
320
+ // Real Tailwind's default spacing scale in full — every step is exactly
321
+ // `n * 4px`, including the fractional `.5` steps (`1.5` -> 6px, `2.5` ->
322
+ // 10px, `3.5` -> 14px) and the "px" literal (a bare 1px). Only the
323
+ // "usual stops", though — `jsEngine/shared.ts`'s `spacingPx` (and the
324
+ // native Rust dispatcher's own `spacing_px`) falls back to Tailwind v4's
325
+ // live `n * 4px` formula for any bare numeric step not listed here
326
+ // (`p-0.25`, `w-13`, ...), so this table names the common values and
327
+ // gives a theme override something to target, not the full resolvable
328
+ // set. Mirrors @kbach/react's theme.ts exactly.
318
329
  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
330
  "0": 0,
331
+ "px": 1,
332
+ "0.5": 2,
323
333
  "1": 4,
334
+ "1.5": 6,
324
335
  "2": 8,
336
+ "2.5": 10,
337
+ "3": 12,
338
+ "3.5": 14,
325
339
  "4": 16,
340
+ "5": 20,
326
341
  "6": 24,
327
- "8": 32
342
+ "7": 28,
343
+ "8": 32,
344
+ "9": 36,
345
+ "10": 40,
346
+ "11": 44,
347
+ "12": 48,
348
+ "14": 56,
349
+ "16": 64,
350
+ "20": 80,
351
+ "24": 96,
352
+ "28": 112,
353
+ "32": 128,
354
+ "36": 144,
355
+ "40": 160,
356
+ "44": 176,
357
+ "48": 192,
358
+ "52": 208,
359
+ "56": 224,
360
+ "60": 240,
361
+ "64": 256,
362
+ "72": 288,
363
+ "80": 320,
364
+ "96": 384
328
365
  },
329
- screens: {},
330
- darkMode: "attribute"
366
+ screens: {
367
+ sm: 640,
368
+ md: 768,
369
+ lg: 1024,
370
+ xl: 1280,
371
+ "2xl": 1536
372
+ },
373
+ // Byte-for-byte the same three stacks
374
+ // packages/core-engine/src/resolvers/typography.rs's `font_family_value`
375
+ // falls back to. On native these three still effectively no-op (see
376
+ // `first_font_name`'s own doc comment for why a generic CSS keyword
377
+ // isn't a real loadable font) — only a caller-configured custom name
378
+ // changes native rendering; Expo Web uses the full stack as-is.
379
+ fontFamily: {
380
+ sans: 'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',
381
+ serif: 'ui-serif, Georgia, Cambria, "Times New Roman", Times, serif',
382
+ mono: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'
383
+ },
384
+ darkMode: "attribute",
385
+ // Empty by default, matching real Tailwind's own defaults.
386
+ container: {}
331
387
  };
332
388
  var activeTheme = defaultTheme;
333
389
  var activeThemeJson = JSON.stringify(defaultTheme);
@@ -354,12 +410,25 @@ function systemPrefersDark() {
354
410
  function resolveIsDark(m) {
355
411
  return m === "system" ? systemPrefersDark() : m === "dark";
356
412
  }
413
+ function applyToDom(dark) {
414
+ if (typeof document === "undefined") return;
415
+ const root = document.documentElement;
416
+ const strategy = getTheme().darkMode;
417
+ if (strategy === "class") {
418
+ root.classList.toggle("dark", dark);
419
+ root.classList.toggle("light", !dark);
420
+ } else if (strategy === "attribute") {
421
+ root.setAttribute("data-theme", dark ? "dark" : "light");
422
+ }
423
+ }
357
424
  var mode = "system";
358
425
  var isDark = resolveIsDark(mode);
426
+ applyToDom(isDark);
359
427
  var hasExplicitChoice = false;
360
428
  var subscription = import_react_native.Appearance.addChangeListener(({ colorScheme }) => {
361
429
  if (mode !== "system") return;
362
430
  isDark = colorScheme === "dark";
431
+ applyToDom(isDark);
363
432
  notify();
364
433
  });
365
434
  function notify() {
@@ -375,6 +444,7 @@ function setGlobalThemeMode(nextMode) {
375
444
  mode = nextMode;
376
445
  isDark = resolveIsDark(nextMode);
377
446
  hasExplicitChoice = true;
447
+ applyToDom(isDark);
378
448
  notify();
379
449
  }
380
450
  function toggleGlobalDarkMode() {
@@ -388,82 +458,1385 @@ function seedDefaultMode(fallback) {
388
458
  if (hasExplicitChoice || mode === fallback) return;
389
459
  mode = fallback;
390
460
  isDark = resolveIsDark(fallback);
461
+ applyToDom(isDark);
391
462
  notify();
392
463
  }
393
464
 
465
+ // src/jsEngine/parser.ts
466
+ var VALUE_PREFIXES = [
467
+ "bg-opacity-",
468
+ "text-opacity-",
469
+ "bg-blend-",
470
+ "text-shadow-",
471
+ "bg-",
472
+ "text-",
473
+ "border-x-",
474
+ "border-y-",
475
+ "border-t-",
476
+ "border-r-",
477
+ "border-b-",
478
+ "border-l-",
479
+ "border-",
480
+ "caret-",
481
+ "accent-",
482
+ "fill-",
483
+ "stroke-width-",
484
+ "stroke-",
485
+ "resize-",
486
+ "touch-",
487
+ "will-change-",
488
+ "scroll-mx-",
489
+ "scroll-my-",
490
+ "scroll-mt-",
491
+ "scroll-mr-",
492
+ "scroll-mb-",
493
+ "scroll-ml-",
494
+ "scroll-m-",
495
+ "scroll-px-",
496
+ "scroll-py-",
497
+ "scroll-pt-",
498
+ "scroll-pr-",
499
+ "scroll-pb-",
500
+ "scroll-pl-",
501
+ "scroll-p-",
502
+ "px-",
503
+ "py-",
504
+ "pt-",
505
+ "pr-",
506
+ "pb-",
507
+ "pl-",
508
+ "p-",
509
+ "mx-",
510
+ "my-",
511
+ "mt-",
512
+ "mr-",
513
+ "mb-",
514
+ "ml-",
515
+ "m-",
516
+ "gap-x-",
517
+ "gap-y-",
518
+ "gap-",
519
+ "min-w-",
520
+ "max-w-",
521
+ "w-",
522
+ "min-h-",
523
+ "max-h-",
524
+ "h-",
525
+ "size-",
526
+ "basis-",
527
+ "rounded-tl-",
528
+ "rounded-tr-",
529
+ "rounded-br-",
530
+ "rounded-bl-",
531
+ "rounded-t-",
532
+ "rounded-r-",
533
+ "rounded-b-",
534
+ "rounded-l-",
535
+ "rounded-",
536
+ "ring-offset-",
537
+ "ring-",
538
+ "outline-offset-",
539
+ "outline-",
540
+ "shadow-",
541
+ "opacity-",
542
+ "duration-",
543
+ "delay-",
544
+ "ease-",
545
+ "cursor-",
546
+ "mix-blend-",
547
+ "animate-",
548
+ "leading-",
549
+ "tracking-",
550
+ "font-",
551
+ "z-",
552
+ "inset-",
553
+ "top-",
554
+ "right-",
555
+ "bottom-",
556
+ "left-",
557
+ "divide-color-",
558
+ "space-x-",
559
+ "space-y-",
560
+ "flex-",
561
+ "grow-",
562
+ "shrink-",
563
+ "order-",
564
+ "grid-cols-",
565
+ "grid-rows-",
566
+ "grid-flow-",
567
+ "auto-cols-",
568
+ "auto-rows-",
569
+ "col-span-",
570
+ "col-start-",
571
+ "col-end-",
572
+ "col-",
573
+ "row-span-",
574
+ "row-start-",
575
+ "row-end-",
576
+ "row-",
577
+ "place-items-",
578
+ "place-content-",
579
+ "place-self-",
580
+ "justify-items-",
581
+ "justify-self-",
582
+ "scale-x-",
583
+ "scale-y-",
584
+ "scale-",
585
+ "rotate-",
586
+ "translate-x-",
587
+ "translate-y-",
588
+ "skew-x-",
589
+ "skew-y-",
590
+ "origin-",
591
+ "blur-",
592
+ "brightness-",
593
+ "contrast-",
594
+ "grayscale-",
595
+ "hue-rotate-",
596
+ "invert-",
597
+ "saturate-",
598
+ "sepia-",
599
+ "drop-shadow-",
600
+ "filter-",
601
+ "backdrop-blur-",
602
+ "backdrop-brightness-",
603
+ "backdrop-contrast-",
604
+ "backdrop-grayscale-",
605
+ "backdrop-hue-rotate-",
606
+ "backdrop-invert-",
607
+ "backdrop-opacity-",
608
+ "backdrop-saturate-",
609
+ "backdrop-sepia-",
610
+ "backdrop-filter-",
611
+ "decoration-",
612
+ "underline-offset-",
613
+ "indent-",
614
+ "from-",
615
+ "via-",
616
+ "to-"
617
+ ];
618
+ var ARBITRARY_PROPERTY_SENTINEL = "[arbitrary-property]";
619
+ function isSafeArbitraryValue(value) {
620
+ return !value.includes("{") && !value.includes("}") && !value.includes(";");
621
+ }
622
+ function splitRespectingBrackets(token) {
623
+ const parts = [];
624
+ let depth = 0;
625
+ let start = 0;
626
+ for (let i = 0; i < token.length; i++) {
627
+ const ch = token[i];
628
+ if (ch === "[") depth += 1;
629
+ else if (ch === "]") depth -= 1;
630
+ else if (ch === ":" && depth <= 0) {
631
+ parts.push(token.slice(start, i));
632
+ start = i + 1;
633
+ }
634
+ }
635
+ parts.push(token.slice(start));
636
+ return parts;
637
+ }
638
+ function parseClass(token) {
639
+ const parts = splitRespectingBrackets(token);
640
+ let base = parts.pop() ?? token;
641
+ const modifiers = parts;
642
+ const important = base.startsWith("!");
643
+ if (important) {
644
+ base = base.slice(1);
645
+ }
646
+ const negative = base.startsWith("-");
647
+ if (negative) {
648
+ base = base.slice(1);
649
+ }
650
+ if (base.length >= 2 && base.startsWith("[") && base.endsWith("]")) {
651
+ const raw = base.slice(1, -1);
652
+ const colonIdx = raw.indexOf(":");
653
+ if (colonIdx !== -1) {
654
+ const property = raw.slice(0, colonIdx);
655
+ const rawValue = raw.slice(colonIdx + 1);
656
+ if (property !== "" && rawValue !== "" && isSafeArbitraryValue(raw)) {
657
+ const value = rawValue.replace(/_/g, " ");
658
+ return {
659
+ modifiers,
660
+ utility: ARBITRARY_PROPERTY_SENTINEL,
661
+ value: `${property}:${value}`,
662
+ isArbitrary: true,
663
+ important,
664
+ negative,
665
+ original: token
666
+ };
667
+ }
668
+ }
669
+ }
670
+ for (const prefix of VALUE_PREFIXES) {
671
+ if (!base.startsWith(prefix)) continue;
672
+ const value = base.slice(prefix.length);
673
+ if (value === "") continue;
674
+ if (value.length >= 2 && value.startsWith("[") && value.endsWith("]")) {
675
+ const raw = value.slice(1, -1);
676
+ if (!isSafeArbitraryValue(raw)) {
677
+ continue;
678
+ }
679
+ const spaced = raw.replace(/_/g, " ");
680
+ return {
681
+ modifiers,
682
+ utility: prefix.slice(0, -1),
683
+ value: spaced,
684
+ isArbitrary: true,
685
+ important,
686
+ negative,
687
+ original: token
688
+ };
689
+ }
690
+ return {
691
+ modifiers,
692
+ utility: prefix.slice(0, -1),
693
+ value,
694
+ isArbitrary: false,
695
+ important,
696
+ negative,
697
+ original: token
698
+ };
699
+ }
700
+ return {
701
+ modifiers,
702
+ utility: base,
703
+ value: null,
704
+ isArbitrary: false,
705
+ important,
706
+ negative,
707
+ original: token
708
+ };
709
+ }
710
+
711
+ // src/jsEngine/shared.ts
712
+ function decl(property, value) {
713
+ return { property, value };
714
+ }
715
+ function spacingPx(theme, value) {
716
+ const fromTable = theme.spacing[value];
717
+ if (fromTable !== void 0) return fromTable;
718
+ const n = Number(value);
719
+ return Number.isFinite(n) && value.trim() !== "" ? n * 4 : void 0;
720
+ }
721
+ function resolveLength(theme, parsed) {
722
+ if (parsed.negative) return null;
723
+ const value = parsed.value;
724
+ if (value === null) return null;
725
+ if (parsed.isArbitrary) return value;
726
+ if (value === "full") return "100%";
727
+ if (value === "auto") return "auto";
728
+ const px = spacingPx(theme, value);
729
+ return px === void 0 ? null : `${px}px`;
730
+ }
731
+ function resolveNegatableLength(theme, parsed) {
732
+ if (!parsed.negative) return resolveLength(theme, parsed);
733
+ if (parsed.isArbitrary) return null;
734
+ const value = parsed.value;
735
+ if (value === null) return null;
736
+ const px = spacingPx(theme, value);
737
+ if (px === void 0) return null;
738
+ if (px === 0) return "0px";
739
+ return `-${px}px`;
740
+ }
741
+
742
+ // src/jsEngine/resolvers/layout.ts
743
+ function negateRaw(value, negative) {
744
+ return negative ? `-${value}` : value;
745
+ }
746
+ function resolve(parsed, theme) {
747
+ switch (parsed.utility) {
748
+ case "flex":
749
+ return parsed.value === null ? [decl("display", "flex")] : null;
750
+ case "grid":
751
+ return [decl("display", "grid")];
752
+ case "block":
753
+ return [decl("display", "block")];
754
+ case "inline-block":
755
+ return [decl("display", "inline-block")];
756
+ case "inline":
757
+ return [decl("display", "inline")];
758
+ case "inline-flex":
759
+ return [decl("display", "inline-flex")];
760
+ case "inline-grid":
761
+ return [decl("display", "inline-grid")];
762
+ case "contents":
763
+ return [decl("display", "contents")];
764
+ case "flow-root":
765
+ return [decl("display", "flow-root")];
766
+ case "hidden":
767
+ return [decl("display", "none")];
768
+ case "@container":
769
+ return [decl("container-type", "inline-size")];
770
+ case "items-center":
771
+ return [decl("align-items", "center")];
772
+ case "items-start":
773
+ return [decl("align-items", "flex-start")];
774
+ case "items-end":
775
+ return [decl("align-items", "flex-end")];
776
+ case "items-baseline":
777
+ return [decl("align-items", "baseline")];
778
+ case "items-stretch":
779
+ return [decl("align-items", "stretch")];
780
+ case "justify-center":
781
+ return [decl("justify-content", "center")];
782
+ case "justify-start":
783
+ return [decl("justify-content", "flex-start")];
784
+ case "justify-end":
785
+ return [decl("justify-content", "flex-end")];
786
+ case "justify-between":
787
+ return [decl("justify-content", "space-between")];
788
+ case "justify-around":
789
+ return [decl("justify-content", "space-around")];
790
+ case "justify-evenly":
791
+ return [decl("justify-content", "space-evenly")];
792
+ case "content-start":
793
+ return [decl("align-content", "flex-start")];
794
+ case "content-end":
795
+ return [decl("align-content", "flex-end")];
796
+ case "content-center":
797
+ return [decl("align-content", "center")];
798
+ case "content-between":
799
+ return [decl("align-content", "space-between")];
800
+ case "content-around":
801
+ return [decl("align-content", "space-around")];
802
+ case "content-evenly":
803
+ return [decl("align-content", "space-evenly")];
804
+ case "content-stretch":
805
+ return [decl("align-content", "stretch")];
806
+ case "self-auto":
807
+ return [decl("align-self", "auto")];
808
+ case "self-center":
809
+ return [decl("align-self", "center")];
810
+ case "self-start":
811
+ return [decl("align-self", "flex-start")];
812
+ case "self-end":
813
+ return [decl("align-self", "flex-end")];
814
+ case "self-stretch":
815
+ return [decl("align-self", "stretch")];
816
+ case "self-baseline":
817
+ return [decl("align-self", "baseline")];
818
+ case "overflow-hidden":
819
+ return [decl("overflow", "hidden")];
820
+ case "overflow-auto":
821
+ return [decl("overflow", "auto")];
822
+ case "overflow-scroll":
823
+ return [decl("overflow", "scroll")];
824
+ case "overflow-visible":
825
+ return [decl("overflow", "visible")];
826
+ case "static":
827
+ return [decl("position", "static")];
828
+ case "relative":
829
+ return [decl("position", "relative")];
830
+ case "absolute":
831
+ return [decl("position", "absolute")];
832
+ case "fixed":
833
+ return [decl("position", "fixed")];
834
+ case "sticky":
835
+ return [decl("position", "sticky")];
836
+ case "z":
837
+ return parsed.value === null ? null : [decl("z-index", negateRaw(parsed.value, parsed.negative))];
838
+ case "order":
839
+ return parsed.value === null ? null : [decl("order", negateRaw(parsed.value, parsed.negative))];
840
+ case "grow":
841
+ return [decl("flex-grow", parsed.value ?? "1")];
842
+ case "shrink":
843
+ return [decl("flex-shrink", parsed.value ?? "1")];
844
+ // top/right/bottom/left/inset support real Tailwind's negative-value
845
+ // convention ("-top-4") — see resolveNegatableLength's own doc comment.
846
+ case "top": {
847
+ const v = resolveNegatableLength(theme, parsed);
848
+ return v === null ? null : [decl("top", v)];
849
+ }
850
+ case "right": {
851
+ const v = resolveNegatableLength(theme, parsed);
852
+ return v === null ? null : [decl("right", v)];
853
+ }
854
+ case "bottom": {
855
+ const v = resolveNegatableLength(theme, parsed);
856
+ return v === null ? null : [decl("bottom", v)];
857
+ }
858
+ case "left": {
859
+ const v = resolveNegatableLength(theme, parsed);
860
+ return v === null ? null : [decl("left", v)];
861
+ }
862
+ case "inset": {
863
+ const v = resolveNegatableLength(theme, parsed);
864
+ return v === null ? null : [decl("inset", v)];
865
+ }
866
+ case "aspect-square":
867
+ return [decl("aspect-ratio", "1 / 1")];
868
+ case "aspect-video":
869
+ return [decl("aspect-ratio", "16 / 9")];
870
+ default:
871
+ return null;
872
+ }
873
+ }
874
+ function resolveFlex(parsed, web) {
875
+ if (parsed.utility !== "flex") return null;
876
+ const value = parsed.value;
877
+ if (value === null) return null;
878
+ if (parsed.isArbitrary) return [decl("flex", value)];
879
+ switch (value) {
880
+ case "row":
881
+ return [decl("flex-direction", "row")];
882
+ case "col":
883
+ return [decl("flex-direction", "column")];
884
+ case "row-reverse":
885
+ return [decl("flex-direction", "row-reverse")];
886
+ case "col-reverse":
887
+ return [decl("flex-direction", "column-reverse")];
888
+ case "wrap":
889
+ return [decl("flex-wrap", "wrap")];
890
+ case "wrap-reverse":
891
+ return [decl("flex-wrap", "wrap-reverse")];
892
+ case "nowrap":
893
+ return [decl("flex-wrap", "nowrap")];
894
+ case "1":
895
+ return [decl("flex", "1")];
896
+ case "auto":
897
+ return [decl("flex", web ? "auto" : "1")];
898
+ case "initial":
899
+ return [decl("flex", web ? "initial" : "1")];
900
+ case "none":
901
+ return [decl("flex", web ? "none" : "0")];
902
+ case "grow":
903
+ return [decl("flex-grow", "1")];
904
+ case "grow-0":
905
+ return [decl("flex-grow", "0")];
906
+ case "shrink":
907
+ return [decl("flex-shrink", "1")];
908
+ case "shrink-0":
909
+ return [decl("flex-shrink", "0")];
910
+ default:
911
+ return null;
912
+ }
913
+ }
914
+
915
+ // src/jsEngine/resolvers/spacing.ts
916
+ function namedSize(key) {
917
+ switch (key) {
918
+ case "sm":
919
+ return "24rem";
920
+ case "md":
921
+ return "28rem";
922
+ case "lg":
923
+ return "32rem";
924
+ case "xl":
925
+ return "36rem";
926
+ case "2xl":
927
+ return "42rem";
928
+ case "3xl":
929
+ return "48rem";
930
+ case "4xl":
931
+ return "56rem";
932
+ case "5xl":
933
+ return "64rem";
934
+ case "6xl":
935
+ return "72rem";
936
+ case "7xl":
937
+ return "80rem";
938
+ case "8xl":
939
+ return "88rem";
940
+ case "9xl":
941
+ return "96rem";
942
+ default:
943
+ return null;
944
+ }
945
+ }
946
+ function fractionPercent(value) {
947
+ const slashIdx = value.indexOf("/");
948
+ if (slashIdx === -1) return null;
949
+ const numStr = value.slice(0, slashIdx);
950
+ const denStr = value.slice(slashIdx + 1);
951
+ const num = Number(numStr);
952
+ const den = Number(denStr);
953
+ if (!Number.isFinite(num) || !Number.isFinite(den) || numStr.trim() === "" || denStr.trim() === "") return null;
954
+ if (den === 0) return null;
955
+ const pct = num / den * 100;
956
+ const formatted = pct.toFixed(6);
957
+ const trimmed = formatted.replace(/0+$/, "").replace(/\.$/, "");
958
+ return `${trimmed}%`;
959
+ }
960
+ function cssSizeKeyword(key) {
961
+ switch (key) {
962
+ case "min":
963
+ return "min-content";
964
+ case "max":
965
+ return "max-content";
966
+ case "fit":
967
+ return "fit-content";
968
+ default:
969
+ return null;
970
+ }
971
+ }
972
+ function resolveSize(theme, parsed) {
973
+ if (!parsed.isArbitrary && parsed.value !== null) {
974
+ const named = namedSize(parsed.value);
975
+ if (named !== null) return named;
976
+ const kw = cssSizeKeyword(parsed.value);
977
+ if (kw !== null) return kw;
978
+ const fraction = fractionPercent(parsed.value);
979
+ if (fraction !== null) return fraction;
980
+ }
981
+ return resolveLength(theme, parsed);
982
+ }
983
+ function resolve2(parsed, theme) {
984
+ const length = () => resolveLength(theme, parsed);
985
+ const size = () => resolveSize(theme, parsed);
986
+ const negatableLength = () => resolveNegatableLength(theme, parsed);
987
+ switch (parsed.utility) {
988
+ case "p": {
989
+ const v = length();
990
+ return v === null ? null : [decl("padding", v)];
991
+ }
992
+ case "px": {
993
+ const v = length();
994
+ return v === null ? null : [decl("padding-left", v), decl("padding-right", v)];
995
+ }
996
+ case "py": {
997
+ const v = length();
998
+ return v === null ? null : [decl("padding-top", v), decl("padding-bottom", v)];
999
+ }
1000
+ case "pt": {
1001
+ const v = length();
1002
+ return v === null ? null : [decl("padding-top", v)];
1003
+ }
1004
+ case "pr": {
1005
+ const v = length();
1006
+ return v === null ? null : [decl("padding-right", v)];
1007
+ }
1008
+ case "pb": {
1009
+ const v = length();
1010
+ return v === null ? null : [decl("padding-bottom", v)];
1011
+ }
1012
+ case "pl": {
1013
+ const v = length();
1014
+ return v === null ? null : [decl("padding-left", v)];
1015
+ }
1016
+ case "m": {
1017
+ const v = negatableLength();
1018
+ return v === null ? null : [decl("margin", v)];
1019
+ }
1020
+ case "mx": {
1021
+ const v = negatableLength();
1022
+ return v === null ? null : [decl("margin-left", v), decl("margin-right", v)];
1023
+ }
1024
+ case "my": {
1025
+ const v = negatableLength();
1026
+ return v === null ? null : [decl("margin-top", v), decl("margin-bottom", v)];
1027
+ }
1028
+ case "mt": {
1029
+ const v = negatableLength();
1030
+ return v === null ? null : [decl("margin-top", v)];
1031
+ }
1032
+ case "mr": {
1033
+ const v = negatableLength();
1034
+ return v === null ? null : [decl("margin-right", v)];
1035
+ }
1036
+ case "mb": {
1037
+ const v = negatableLength();
1038
+ return v === null ? null : [decl("margin-bottom", v)];
1039
+ }
1040
+ case "ml": {
1041
+ const v = negatableLength();
1042
+ return v === null ? null : [decl("margin-left", v)];
1043
+ }
1044
+ case "gap": {
1045
+ const v = length();
1046
+ return v === null ? null : [decl("gap", v)];
1047
+ }
1048
+ case "gap-x": {
1049
+ const v = length();
1050
+ return v === null ? null : [decl("column-gap", v)];
1051
+ }
1052
+ case "gap-y": {
1053
+ const v = length();
1054
+ return v === null ? null : [decl("row-gap", v)];
1055
+ }
1056
+ case "w": {
1057
+ const v = size();
1058
+ return v === null ? null : [decl("width", v)];
1059
+ }
1060
+ case "h": {
1061
+ const v = size();
1062
+ return v === null ? null : [decl("height", v)];
1063
+ }
1064
+ case "min-w": {
1065
+ const v = size();
1066
+ return v === null ? null : [decl("min-width", v)];
1067
+ }
1068
+ case "max-w": {
1069
+ const v = size();
1070
+ return v === null ? null : [decl("max-width", v)];
1071
+ }
1072
+ case "min-h": {
1073
+ const v = size();
1074
+ return v === null ? null : [decl("min-height", v)];
1075
+ }
1076
+ case "max-h": {
1077
+ const v = size();
1078
+ return v === null ? null : [decl("max-height", v)];
1079
+ }
1080
+ case "size": {
1081
+ const v = size();
1082
+ return v === null ? null : [decl("width", v), decl("height", v)];
1083
+ }
1084
+ case "basis": {
1085
+ const v = size();
1086
+ return v === null ? null : [decl("flex-basis", v)];
1087
+ }
1088
+ default:
1089
+ return null;
1090
+ }
1091
+ }
1092
+
1093
+ // src/jsEngine/resolvers/color.ts
1094
+ function lookupHex(theme, key) {
1095
+ const entry = theme.colors[key];
1096
+ return typeof entry === "string" ? entry : null;
1097
+ }
1098
+
1099
+ // src/jsEngine/resolvers/border.ts
1100
+ function radiusSize(key) {
1101
+ switch (key) {
1102
+ case "none":
1103
+ return "0px";
1104
+ case "sm":
1105
+ return "0.125rem";
1106
+ case "md":
1107
+ return "0.375rem";
1108
+ case "lg":
1109
+ return "0.5rem";
1110
+ case "xl":
1111
+ return "0.75rem";
1112
+ case "2xl":
1113
+ return "1rem";
1114
+ case "3xl":
1115
+ return "1.5rem";
1116
+ case "full":
1117
+ return "9999px";
1118
+ default:
1119
+ return null;
1120
+ }
1121
+ }
1122
+ function borderSideProperty(side) {
1123
+ switch (side) {
1124
+ case "t":
1125
+ return "border-top";
1126
+ case "r":
1127
+ return "border-right";
1128
+ case "b":
1129
+ return "border-bottom";
1130
+ case "l":
1131
+ return "border-left";
1132
+ default:
1133
+ return null;
1134
+ }
1135
+ }
1136
+ function borderValue(theme, parsed) {
1137
+ const value = parsed.value;
1138
+ if (value === null) return null;
1139
+ if (!parsed.isArbitrary) {
1140
+ const side = borderSideProperty(value);
1141
+ if (side !== null) {
1142
+ return [decl(`${side}-width`, "1px"), decl(`${side}-style`, "solid")];
1143
+ }
1144
+ if (value === "collapse") return [decl("border-collapse", "collapse")];
1145
+ if (value === "separate") return [decl("border-collapse", "separate")];
1146
+ }
1147
+ if (parsed.isArbitrary) {
1148
+ return [decl("border-width", value)];
1149
+ }
1150
+ if (Number.isFinite(Number(value)) && value.trim() !== "") {
1151
+ const v = resolveLength(theme, parsed);
1152
+ return v === null ? null : [decl("border-width", v)];
1153
+ }
1154
+ if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
1155
+ return [decl("border-style", value)];
1156
+ }
1157
+ const hex = lookupHex(theme, value);
1158
+ return hex === null ? null : [decl("border-color", hex)];
1159
+ }
1160
+ function borderSideValue(theme, parsed, sideProperty) {
1161
+ const value = parsed.value;
1162
+ if (value === null) return null;
1163
+ if (parsed.isArbitrary) return [decl(`${sideProperty}-width`, value)];
1164
+ if (Number.isFinite(Number(value)) && value.trim() !== "") {
1165
+ const v = resolveLength(theme, parsed);
1166
+ return v === null ? null : [decl(`${sideProperty}-width`, v)];
1167
+ }
1168
+ if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
1169
+ return [decl(`${sideProperty}-style`, value)];
1170
+ }
1171
+ const hex = lookupHex(theme, value);
1172
+ return hex === null ? null : [decl(`${sideProperty}-color`, hex)];
1173
+ }
1174
+ function borderAxisValue(theme, parsed, sideA, sideB) {
1175
+ const value = parsed.value;
1176
+ if (value === null) return null;
1177
+ if (parsed.isArbitrary) return [decl(`${sideA}-width`, value), decl(`${sideB}-width`, value)];
1178
+ if (Number.isFinite(Number(value)) && value.trim() !== "") {
1179
+ const v = resolveLength(theme, parsed);
1180
+ return v === null ? null : [decl(`${sideA}-width`, v), decl(`${sideB}-width`, v)];
1181
+ }
1182
+ if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
1183
+ return [decl(`${sideA}-style`, value), decl(`${sideB}-style`, value)];
1184
+ }
1185
+ const hex = lookupHex(theme, value);
1186
+ return hex === null ? null : [decl(`${sideA}-color`, hex), decl(`${sideB}-color`, hex)];
1187
+ }
1188
+ function radiusProperties(side) {
1189
+ switch (side) {
1190
+ case "t":
1191
+ return ["border-top-left-radius", "border-top-right-radius"];
1192
+ case "r":
1193
+ return ["border-top-right-radius", "border-bottom-right-radius"];
1194
+ case "b":
1195
+ return ["border-bottom-right-radius", "border-bottom-left-radius"];
1196
+ case "l":
1197
+ return ["border-top-left-radius", "border-bottom-left-radius"];
1198
+ case "tl":
1199
+ return ["border-top-left-radius"];
1200
+ case "tr":
1201
+ return ["border-top-right-radius"];
1202
+ case "br":
1203
+ return ["border-bottom-right-radius"];
1204
+ case "bl":
1205
+ return ["border-bottom-left-radius"];
1206
+ default:
1207
+ return null;
1208
+ }
1209
+ }
1210
+ function resolveRadiusValue(theme, parsed) {
1211
+ if (!parsed.isArbitrary && parsed.value !== null) {
1212
+ const size = radiusSize(parsed.value);
1213
+ if (size !== null) return size;
1214
+ }
1215
+ return resolveLength(theme, parsed);
1216
+ }
1217
+ function resolveRadiusSide(theme, parsed, side) {
1218
+ const properties = radiusProperties(side);
1219
+ if (properties === null) return null;
1220
+ const value = resolveRadiusValue(theme, parsed);
1221
+ if (value === null) return null;
1222
+ return properties.map((p) => decl(p, value));
1223
+ }
1224
+ var OUTLINE_STYLES = ["solid", "dashed", "dotted", "double"];
1225
+ function outlineWidthValue(key) {
1226
+ switch (key) {
1227
+ case "0":
1228
+ return "0px";
1229
+ case "1":
1230
+ return "1px";
1231
+ case "2":
1232
+ return "2px";
1233
+ case "4":
1234
+ return "4px";
1235
+ case "8":
1236
+ return "8px";
1237
+ default:
1238
+ return null;
1239
+ }
1240
+ }
1241
+ function outlineValue(theme, parsed) {
1242
+ const value = parsed.value;
1243
+ if (value === null) return null;
1244
+ if (parsed.isArbitrary) return [decl("outline-width", value)];
1245
+ const w = outlineWidthValue(value);
1246
+ if (w !== null) return [decl("outline-width", w)];
1247
+ if (OUTLINE_STYLES.includes(value)) return [decl("outline-style", value)];
1248
+ const hex = lookupHex(theme, value);
1249
+ return hex === null ? null : [decl("outline-color", hex)];
1250
+ }
1251
+ function outlineOffsetValue(parsed) {
1252
+ const value = parsed.value;
1253
+ if (value === null) return null;
1254
+ if (parsed.isArbitrary) return [decl("outline-offset", value)];
1255
+ const w = outlineWidthValue(value);
1256
+ return w === null ? null : [decl("outline-offset", w)];
1257
+ }
1258
+ 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))";
1259
+ function ringWidth(key) {
1260
+ switch (key) {
1261
+ case "0":
1262
+ return "0px";
1263
+ case "1":
1264
+ return "1px";
1265
+ case "2":
1266
+ return "2px";
1267
+ case "4":
1268
+ return "4px";
1269
+ case "8":
1270
+ return "8px";
1271
+ default:
1272
+ return null;
1273
+ }
1274
+ }
1275
+ function ringValue(theme, parsed) {
1276
+ const value = parsed.value;
1277
+ if (value === null) return null;
1278
+ if (value === "inset") {
1279
+ return [decl("--kb-ring-inset", "inset"), decl("box-shadow", RING_BOX_SHADOW)];
1280
+ }
1281
+ if (!parsed.isArbitrary) {
1282
+ const w = ringWidth(value);
1283
+ if (w !== null) return [decl("--kb-ring-width", w), decl("box-shadow", RING_BOX_SHADOW)];
1284
+ }
1285
+ const color = parsed.isArbitrary ? value : lookupHex(theme, value);
1286
+ if (color === null) return null;
1287
+ return [decl("--kb-ring-color", color), decl("box-shadow", RING_BOX_SHADOW)];
1288
+ }
1289
+ function ringOffsetValue(theme, parsed) {
1290
+ const value = parsed.value;
1291
+ if (value === null) return null;
1292
+ if (!parsed.isArbitrary) {
1293
+ const w = ringWidth(value);
1294
+ if (w !== null) return [decl("--kb-ring-offset-width", w), decl("box-shadow", RING_BOX_SHADOW)];
1295
+ }
1296
+ const color = parsed.isArbitrary ? value : lookupHex(theme, value);
1297
+ if (color === null) return null;
1298
+ return [decl("--kb-ring-offset-color", color), decl("box-shadow", RING_BOX_SHADOW)];
1299
+ }
1300
+ var RADIUS_SIDES = /* @__PURE__ */ new Set(["t", "r", "b", "l", "tl", "tr", "br", "bl"]);
1301
+ function resolve3(parsed, theme) {
1302
+ switch (parsed.utility) {
1303
+ case "border":
1304
+ if (parsed.value === null) return [decl("border-width", "1px"), decl("border-style", "solid")];
1305
+ return borderValue(theme, parsed);
1306
+ case "border-t":
1307
+ return borderSideValue(theme, parsed, "border-top");
1308
+ case "border-r":
1309
+ return borderSideValue(theme, parsed, "border-right");
1310
+ case "border-b":
1311
+ return borderSideValue(theme, parsed, "border-bottom");
1312
+ case "border-l":
1313
+ return borderSideValue(theme, parsed, "border-left");
1314
+ case "border-x":
1315
+ return borderAxisValue(theme, parsed, "border-left", "border-right");
1316
+ case "border-y":
1317
+ return borderAxisValue(theme, parsed, "border-top", "border-bottom");
1318
+ case "rounded": {
1319
+ if (parsed.value === null) return [decl("border-radius", "0.25rem")];
1320
+ const value = parsed.value;
1321
+ if (!parsed.isArbitrary) {
1322
+ const size = radiusSize(value);
1323
+ if (size !== null) return [decl("border-radius", size)];
1324
+ }
1325
+ const v = resolveLength(theme, parsed);
1326
+ return v === null ? null : [decl("border-radius", v)];
1327
+ }
1328
+ case "ring":
1329
+ if (parsed.value === null) return [decl("--kb-ring-width", "3px"), decl("box-shadow", RING_BOX_SHADOW)];
1330
+ return ringValue(theme, parsed);
1331
+ case "ring-offset":
1332
+ return ringOffsetValue(theme, parsed);
1333
+ case "outline":
1334
+ if (parsed.value === null) return [decl("outline-style", "solid")];
1335
+ if (parsed.value === "none") return [decl("outline", "none")];
1336
+ return outlineValue(theme, parsed);
1337
+ case "outline-offset":
1338
+ return outlineOffsetValue(parsed);
1339
+ default:
1340
+ if (parsed.utility.startsWith("rounded-") && RADIUS_SIDES.has(parsed.utility.slice("rounded-".length))) {
1341
+ return resolveRadiusSide(theme, parsed, parsed.utility.slice("rounded-".length));
1342
+ }
1343
+ return null;
1344
+ }
1345
+ }
1346
+
1347
+ // src/jsEngine/resolvers/typography.ts
1348
+ function textSize(key) {
1349
+ switch (key) {
1350
+ case "xs":
1351
+ return "0.75rem";
1352
+ case "sm":
1353
+ return "0.875rem";
1354
+ case "base":
1355
+ return "1rem";
1356
+ case "lg":
1357
+ return "1.125rem";
1358
+ case "xl":
1359
+ return "1.25rem";
1360
+ case "2xl":
1361
+ return "1.5rem";
1362
+ case "3xl":
1363
+ return "1.875rem";
1364
+ case "4xl":
1365
+ return "2.25rem";
1366
+ default:
1367
+ return null;
1368
+ }
1369
+ }
1370
+ function lineHeightSize(key) {
1371
+ switch (key) {
1372
+ case "3":
1373
+ return "0.75rem";
1374
+ case "4":
1375
+ return "1rem";
1376
+ case "5":
1377
+ return "1.25rem";
1378
+ case "6":
1379
+ return "1.5rem";
1380
+ case "7":
1381
+ return "1.75rem";
1382
+ case "8":
1383
+ return "2rem";
1384
+ case "9":
1385
+ return "2.25rem";
1386
+ case "10":
1387
+ return "2.5rem";
1388
+ default:
1389
+ return null;
1390
+ }
1391
+ }
1392
+ function textAlign(key) {
1393
+ switch (key) {
1394
+ case "left":
1395
+ return "left";
1396
+ case "center":
1397
+ return "center";
1398
+ case "right":
1399
+ return "right";
1400
+ case "justify":
1401
+ return "justify";
1402
+ default:
1403
+ return null;
1404
+ }
1405
+ }
1406
+ function fontWeight(key) {
1407
+ switch (key) {
1408
+ case "thin":
1409
+ return "100";
1410
+ case "normal":
1411
+ return "400";
1412
+ case "medium":
1413
+ return "500";
1414
+ case "semibold":
1415
+ return "600";
1416
+ case "bold":
1417
+ return "700";
1418
+ case "extrabold":
1419
+ return "800";
1420
+ default:
1421
+ return null;
1422
+ }
1423
+ }
1424
+
1425
+ // src/jsEngine/resolvers/effects.ts
1426
+ function nativeShadowValue(key) {
1427
+ switch (key) {
1428
+ case "sm":
1429
+ return { offsetY: 1, radius: 2, opacity: 0.05, elevation: 1 };
1430
+ case "DEFAULT":
1431
+ return { offsetY: 1, radius: 3, opacity: 0.1, elevation: 2 };
1432
+ case "md":
1433
+ return { offsetY: 4, radius: 6, opacity: 0.1, elevation: 4 };
1434
+ case "lg":
1435
+ return { offsetY: 10, radius: 15, opacity: 0.1, elevation: 8 };
1436
+ case "xl":
1437
+ return { offsetY: 20, radius: 25, opacity: 0.1, elevation: 12 };
1438
+ case "2xl":
1439
+ return { offsetY: 25, radius: 50, opacity: 0.25, elevation: 16 };
1440
+ case "none":
1441
+ return { offsetY: 0, radius: 0, opacity: 0, elevation: 0 };
1442
+ default:
1443
+ return null;
1444
+ }
1445
+ }
1446
+ function nativeShadowDeclarations(parsed) {
1447
+ if (parsed.utility !== "shadow" || parsed.isArbitrary) return null;
1448
+ const key = parsed.value ?? "DEFAULT";
1449
+ const s = nativeShadowValue(key);
1450
+ if (s === null) return null;
1451
+ return [
1452
+ decl("shadow-color", "#000000"),
1453
+ decl("shadow-offset-x", "0"),
1454
+ decl("shadow-offset-y", String(s.offsetY)),
1455
+ decl("shadow-opacity", String(s.opacity)),
1456
+ decl("shadow-radius", String(s.radius)),
1457
+ decl("elevation", String(s.elevation))
1458
+ ];
1459
+ }
1460
+
1461
+ // src/jsEngine/resolveUtilityNative.ts
1462
+ function resolveTypographyNative(parsed) {
1463
+ switch (parsed.utility) {
1464
+ case "font": {
1465
+ if (parsed.value === null) return null;
1466
+ const w = fontWeight(parsed.value);
1467
+ return w === null ? null : [decl("font-weight", w)];
1468
+ }
1469
+ case "uppercase":
1470
+ return [decl("text-transform", "uppercase")];
1471
+ case "lowercase":
1472
+ return [decl("text-transform", "lowercase")];
1473
+ case "capitalize":
1474
+ return [decl("text-transform", "capitalize")];
1475
+ case "underline":
1476
+ return [decl("text-decoration-line", "underline")];
1477
+ case "line-through":
1478
+ return [decl("text-decoration-line", "line-through")];
1479
+ case "no-underline":
1480
+ return [decl("text-decoration-line", "none")];
1481
+ case "italic":
1482
+ return [decl("font-style", "italic")];
1483
+ case "not-italic":
1484
+ return [decl("font-style", "normal")];
1485
+ default:
1486
+ return null;
1487
+ }
1488
+ }
1489
+ function resolveLeadingTrackingNative(parsed) {
1490
+ const value = parsed.value;
1491
+ if (value === null) return null;
1492
+ if (parsed.utility === "leading") {
1493
+ if (parsed.isArbitrary) return [decl("line-height", value)];
1494
+ const v = lineHeightSize(value);
1495
+ return v === null ? null : [decl("line-height", v)];
1496
+ }
1497
+ if (parsed.utility === "tracking" && parsed.isArbitrary) {
1498
+ return [decl("letter-spacing", value)];
1499
+ }
1500
+ return null;
1501
+ }
1502
+ function nativeHexColor(parsed, theme) {
1503
+ const value = parsed.value;
1504
+ if (value === null) return null;
1505
+ return parsed.isArbitrary ? value : lookupHex(theme, value);
1506
+ }
1507
+ function resolveTextNative(parsed, theme) {
1508
+ if (!parsed.isArbitrary && parsed.value !== null) {
1509
+ const size = textSize(parsed.value);
1510
+ if (size !== null) return [decl("font-size", size)];
1511
+ const align = textAlign(parsed.value);
1512
+ if (align !== null) return [decl("text-align", align)];
1513
+ }
1514
+ const hex = nativeHexColor(parsed, theme);
1515
+ return hex === null ? null : [decl("color", hex)];
1516
+ }
1517
+ function resolveColorNative(parsed, theme) {
1518
+ switch (parsed.utility) {
1519
+ case "bg": {
1520
+ const hex = nativeHexColor(parsed, theme);
1521
+ return hex === null ? null : [decl("background-color", hex)];
1522
+ }
1523
+ case "text":
1524
+ return resolveTextNative(parsed, theme);
1525
+ default:
1526
+ return null;
1527
+ }
1528
+ }
1529
+ function resolveUtilityNative(parsed, theme) {
1530
+ return resolveFlex(parsed, false) ?? resolve(parsed, theme) ?? resolve2(parsed, theme) ?? resolve3(parsed, theme) ?? resolveColorNative(parsed, theme) ?? resolveLeadingTrackingNative(parsed) ?? resolveTypographyNative(parsed) ?? nativeShadowDeclarations(parsed);
1531
+ }
1532
+
1533
+ // src/jsEngine/resolveStyle.ts
1534
+ var RESPONSIVE_BREAKPOINTS = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
1535
+ function nativeModifierState(modifier, theme, colorScheme, pressed, width) {
1536
+ if (modifier === "dark") return colorScheme === "dark";
1537
+ if (modifier === "active") return pressed;
1538
+ if (RESPONSIVE_BREAKPOINTS.has(modifier)) {
1539
+ const minWidth = theme.screens[modifier];
1540
+ if (minWidth === void 0) return null;
1541
+ return width >= minWidth;
1542
+ }
1543
+ return null;
1544
+ }
1545
+ function kebabToCamel(s) {
1546
+ return s.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
1547
+ }
1548
+ var NUMERIC_LENGTH_PROPS = /* @__PURE__ */ new Set([
1549
+ "padding",
1550
+ "padding-top",
1551
+ "padding-right",
1552
+ "padding-bottom",
1553
+ "padding-left",
1554
+ "margin",
1555
+ "margin-top",
1556
+ "margin-right",
1557
+ "margin-bottom",
1558
+ "margin-left",
1559
+ "gap",
1560
+ "column-gap",
1561
+ "row-gap",
1562
+ "width",
1563
+ "height",
1564
+ "min-width",
1565
+ "max-width",
1566
+ "min-height",
1567
+ "max-height",
1568
+ "top",
1569
+ "right",
1570
+ "bottom",
1571
+ "left",
1572
+ "inset",
1573
+ "border-radius",
1574
+ "border-width",
1575
+ "font-size",
1576
+ "z-index",
1577
+ "line-height",
1578
+ "letter-spacing",
1579
+ "flex",
1580
+ "flex-grow",
1581
+ "flex-shrink",
1582
+ "order",
1583
+ "flex-basis",
1584
+ "shadow-opacity",
1585
+ "shadow-radius",
1586
+ "elevation",
1587
+ // Per-side border width + per-corner radius — see resolvers/border.ts's
1588
+ // new borderSideValue/borderAxisValue/resolveRadiusSide additions; RN's
1589
+ // style system wants plain numbers for these exactly like the generic
1590
+ // "border-width"/"border-radius" forms above.
1591
+ "border-top-width",
1592
+ "border-right-width",
1593
+ "border-bottom-width",
1594
+ "border-left-width",
1595
+ "border-top-left-radius",
1596
+ "border-top-right-radius",
1597
+ "border-bottom-right-radius",
1598
+ "border-bottom-left-radius",
1599
+ "outline-width",
1600
+ "outline-offset"
1601
+ ]);
1602
+ function rnStyleValue(property, value) {
1603
+ if (NUMERIC_LENGTH_PROPS.has(property)) {
1604
+ let px = null;
1605
+ if (value.endsWith("px")) {
1606
+ const n = Number(value.slice(0, -2));
1607
+ px = Number.isFinite(n) ? n : null;
1608
+ } else if (value.endsWith("rem")) {
1609
+ const n = Number(value.slice(0, -3));
1610
+ px = Number.isFinite(n) ? n * 16 : null;
1611
+ } else {
1612
+ const n = Number(value);
1613
+ px = value.trim() !== "" && Number.isFinite(n) ? n : null;
1614
+ }
1615
+ if (px !== null) return px;
1616
+ }
1617
+ return value;
1618
+ }
1619
+ function resolveStyleJs(classString, theme, colorScheme, pressed, width) {
1620
+ const style = {};
1621
+ let shadowOffset = null;
1622
+ for (const token of classString.split(/\s+/).filter(Boolean)) {
1623
+ const parsed = parseClass(token);
1624
+ const allModifiersHold = parsed.modifiers.every(
1625
+ (m) => nativeModifierState(m, theme, colorScheme, pressed, width) === true
1626
+ );
1627
+ if (!allModifiersHold) continue;
1628
+ const decls = resolveUtilityNative(parsed, theme);
1629
+ if (decls === null) continue;
1630
+ for (const d of decls) {
1631
+ if (d.property.startsWith("__")) {
1632
+ continue;
1633
+ }
1634
+ if (d.property === "shadow-offset-x" || d.property === "shadow-offset-y") {
1635
+ const n = Number(d.value);
1636
+ if (!Number.isFinite(n)) continue;
1637
+ if (shadowOffset === null) shadowOffset = {};
1638
+ shadowOffset[d.property === "shadow-offset-x" ? "width" : "height"] = n;
1639
+ continue;
1640
+ }
1641
+ style[kebabToCamel(d.property)] = rnStyleValue(d.property, d.value);
1642
+ }
1643
+ }
1644
+ if (shadowOffset !== null) {
1645
+ style.shadowOffset = { width: shadowOffset.width ?? 0, height: shadowOffset.height ?? 0 };
1646
+ }
1647
+ return style;
1648
+ }
1649
+
394
1650
  // src/nativeBridge.ts
395
1651
  function resolveStyle(classString, pressed = false) {
396
- const KbachModule = import_react_native2.TurboModuleRegistry.getEnforcing("KbachModule");
397
1652
  const colorScheme = getGlobalDarkMode() ? "dark" : "light";
398
- const json = KbachModule.resolveStyle(classString, getThemeJson(), colorScheme, pressed);
1653
+ const width = import_react_native2.Dimensions.get("window").width;
1654
+ const KbachModule = import_react_native2.TurboModuleRegistry.get("KbachModule");
1655
+ if (!KbachModule) {
1656
+ return resolveStyleJs(classString, getTheme(), colorScheme, pressed, width);
1657
+ }
1658
+ const json = KbachModule.resolveStyle(classString, getThemeJson(), colorScheme, pressed, width);
399
1659
  return JSON.parse(json);
400
1660
  }
401
1661
 
402
- // src/useGlobalDarkMode.ts
403
- var import_react = require("react");
404
- function useGlobalDarkMode() {
405
- return (0, import_react.useSyncExternalStore)(subscribeGlobalDarkMode, getGlobalDarkMode);
1662
+ // src/config.ts
1663
+ function parseHexRgb(hex) {
1664
+ const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
1665
+ if (!m) return null;
1666
+ let h = m[1];
1667
+ if (h.length === 3) h = h.split("").map((c) => c + c).join("");
1668
+ const n = parseInt(h, 16);
1669
+ return [n >> 16 & 255, n >> 8 & 255, n & 255];
1670
+ }
1671
+ function applyOpacityToHex(hex, opacityText) {
1672
+ const rgb = parseHexRgb(hex);
1673
+ if (!rgb) return hex;
1674
+ const a = Number(opacityText) / 100;
1675
+ const clamped = Number.isFinite(a) ? Math.min(1, Math.max(0, a)) : 1;
1676
+ return `rgba(${rgb.join(",")},${clamped})`;
1677
+ }
1678
+ function resolveColorEntry(value, lookup) {
1679
+ const slash = value.indexOf("/");
1680
+ const name = slash === -1 ? value : value.slice(0, slash);
1681
+ const opacity = slash === -1 ? void 0 : value.slice(slash + 1);
1682
+ const base = lookup(name);
1683
+ if (base === void 0) return value;
1684
+ return opacity === void 0 ? base : applyOpacityToHex(base, opacity);
1685
+ }
1686
+ function resolveColors(extend, existing) {
1687
+ const resolved = {};
1688
+ const lookup = (name) => {
1689
+ const found = resolved[name] ?? existing[name];
1690
+ return typeof found === "string" ? found : void 0;
1691
+ };
1692
+ for (const [name, value] of Object.entries(extend)) {
1693
+ resolved[name] = resolveColorEntry(value, lookup);
1694
+ }
1695
+ return resolved;
1696
+ }
1697
+ function resolveKbachConfig(config) {
1698
+ let theme = { ...defaultTheme, ...config.theme };
1699
+ if (config.extend?.colors) {
1700
+ theme = { ...theme, colors: { ...theme.colors, ...resolveColors(config.extend.colors, theme.colors) } };
1701
+ }
1702
+ if (config.extend?.spacing) {
1703
+ theme = { ...theme, spacing: { ...theme.spacing, ...config.extend.spacing } };
1704
+ }
1705
+ if (config.extend?.screens) {
1706
+ theme = { ...theme, screens: { ...theme.screens, ...config.extend.screens } };
1707
+ }
1708
+ if (config.extend?.fontFamily) {
1709
+ theme = { ...theme, fontFamily: { ...theme.fontFamily, ...config.extend.fontFamily } };
1710
+ }
1711
+ if (config.extend?.container) {
1712
+ theme = { ...theme, container: { ...theme.container, ...config.extend.container } };
1713
+ }
1714
+ if (config.darkMode) {
1715
+ theme = { ...theme, darkMode: config.darkMode };
1716
+ }
1717
+ return theme;
1718
+ }
1719
+ function applyKbachConfig(config) {
1720
+ const theme = resolveKbachConfig(config);
1721
+ setTheme(theme);
1722
+ return theme;
406
1723
  }
407
1724
 
408
- // src/ThemeProvider.tsx
409
- var import_react3 = require("react");
410
-
411
- // src/ThemeContext.tsx
412
- var import_react2 = require("react");
413
- var ThemeContext = (0, import_react2.createContext)(null);
1725
+ // src/useTheme.ts
1726
+ var import_react = require("react");
414
1727
  function useTheme() {
415
- const ctx = (0, import_react2.useContext)(ThemeContext);
416
- if (!ctx) {
417
- throw new Error(
418
- 'useTheme() must be called within a <ThemeProvider>. For dark-mode state without a provider, use useGlobalDarkMode() (read) or toggleGlobalDarkMode()/setGlobalThemeMode() (write) from "@kbach/react-native" instead.'
419
- );
420
- }
421
- return ctx;
1728
+ const isDark2 = (0, import_react.useSyncExternalStore)(subscribeGlobalDarkMode, getGlobalDarkMode);
1729
+ const mode2 = (0, import_react.useSyncExternalStore)(subscribeGlobalDarkMode, getGlobalThemeMode);
1730
+ return (0, import_react.useMemo)(
1731
+ () => ({ mode: mode2, isDark: isDark2, setMode: setGlobalThemeMode, toggle: toggleGlobalDarkMode }),
1732
+ [mode2, isDark2]
1733
+ );
422
1734
  }
423
1735
 
424
1736
  // src/ThemeProvider.tsx
1737
+ var import_react2 = require("react");
425
1738
  var import_jsx_runtime = require("react/jsx-runtime");
426
1739
  var mountedProviderCount = 0;
427
1740
  var warnedMultipleProviders = false;
428
1741
  function ThemeProvider({ children, defaultMode = "system" }) {
429
- (0, import_react3.useEffect)(() => {
1742
+ (0, import_react2.useEffect)(() => {
430
1743
  mountedProviderCount++;
431
1744
  if (mountedProviderCount > 1 && !warnedMultipleProviders) {
432
1745
  warnedMultipleProviders = true;
433
1746
  console.warn(
434
- "[kbach] Multiple <ThemeProvider> instances are mounted at once. Dark-mode state is one global store (the same one useGlobalDarkMode()/toggleGlobalDarkMode() read and write), not scoped per-provider, so they will fight over the same state instead of each getting their own."
1747
+ "[kbach] Multiple <ThemeProvider> instances are mounted at once. Dark-mode state is one global store useTheme() reads everywhere, not scoped per-provider, so their defaultMode seeds will fight over the same state."
435
1748
  );
436
1749
  }
437
1750
  return () => {
438
1751
  mountedProviderCount--;
439
1752
  };
440
1753
  }, []);
441
- const seeded = (0, import_react3.useRef)(false);
442
- (0, import_react3.useEffect)(() => {
1754
+ const seeded = (0, import_react2.useRef)(false);
1755
+ (0, import_react2.useEffect)(() => {
443
1756
  if (seeded.current) return;
444
1757
  seeded.current = true;
445
1758
  seedDefaultMode(defaultMode);
446
1759
  }, []);
447
- const isDark2 = (0, import_react3.useSyncExternalStore)(subscribeGlobalDarkMode, getGlobalDarkMode);
448
- const mode2 = (0, import_react3.useSyncExternalStore)(subscribeGlobalDarkMode, getGlobalThemeMode);
449
- const value = (0, import_react3.useMemo)(
450
- () => ({ mode: mode2, isDark: isDark2, setMode: setGlobalThemeMode, toggle: toggleGlobalDarkMode }),
451
- [mode2, isDark2]
452
- );
453
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeContext.Provider, { value, children });
1760
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
1761
+ }
1762
+
1763
+ // src/useColors.ts
1764
+ function parseHexRgb2(hex) {
1765
+ const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
1766
+ if (!m) return null;
1767
+ let h = m[1];
1768
+ if (h.length === 3) h = h.split("").map((c) => c + c).join("");
1769
+ const n = parseInt(h, 16);
1770
+ return [n >> 16 & 255, n >> 8 & 255, n & 255];
1771
+ }
1772
+ function applyOpacity(color, opacity) {
1773
+ const a = Math.max(0, Math.min(1, opacity / 100));
1774
+ if (color.startsWith("#")) {
1775
+ const rgb = parseHexRgb2(color);
1776
+ return rgb ? `rgba(${rgb.join(",")},${a})` : color;
1777
+ }
1778
+ if (color.startsWith("rgb(")) return color.replace("rgb(", "rgba(").replace(")", `,${a})`);
1779
+ if (color.startsWith("rgba(")) return color.replace(/,\s*[\d.]+\)$/, `,${a})`);
1780
+ return color;
1781
+ }
1782
+ function resolveEntry(entry, isDark2) {
1783
+ return typeof entry === "string" ? entry : isDark2 ? entry.dark : entry.light;
1784
+ }
1785
+ function makeColorsProxy(theme, isDark2) {
1786
+ const alpha = (color, opacity) => opacity === void 0 ? color : applyOpacity(color, opacity);
1787
+ const cache = /* @__PURE__ */ new Map();
1788
+ function resolveNamed(key) {
1789
+ let name = key;
1790
+ let opacity;
1791
+ if (key.includes("/")) {
1792
+ const slash = key.indexOf("/");
1793
+ name = key.slice(0, slash);
1794
+ opacity = Number(key.slice(slash + 1));
1795
+ }
1796
+ const entry = theme.colors[name];
1797
+ if (entry === void 0) return void 0;
1798
+ const value = resolveEntry(entry, isDark2);
1799
+ return opacity === void 0 ? value : applyOpacity(value, opacity);
1800
+ }
1801
+ function makeFamilyProxy(family) {
1802
+ return new Proxy({}, {
1803
+ get(_, prop) {
1804
+ const key = String(prop);
1805
+ if (key === "then") return void 0;
1806
+ return resolveNamed(`${family}-${key}`);
1807
+ }
1808
+ });
1809
+ }
1810
+ return new Proxy({ alpha }, {
1811
+ get(_, prop) {
1812
+ const key = String(prop);
1813
+ if (key === "then") return void 0;
1814
+ if (key === "alpha") return alpha;
1815
+ const direct = resolveNamed(key);
1816
+ if (direct !== void 0) return direct;
1817
+ if (!cache.has(key)) cache.set(key, makeFamilyProxy(key));
1818
+ return cache.get(key);
1819
+ }
1820
+ });
1821
+ }
1822
+ function useColors() {
1823
+ const { isDark: isDark2 } = useTheme();
1824
+ return makeColorsProxy(getTheme(), isDark2);
454
1825
  }
455
1826
  // Annotate the CommonJS export names for ESM import in node:
456
1827
  0 && (module.exports = {
457
1828
  ThemeProvider,
1829
+ applyKbachConfig,
458
1830
  defaultTheme,
459
1831
  getGlobalDarkMode,
460
1832
  getGlobalThemeMode,
461
1833
  getTheme,
1834
+ resolveKbachConfig,
462
1835
  resolveStyle,
463
1836
  setGlobalThemeMode,
464
1837
  setTheme,
465
1838
  subscribeGlobalDarkMode,
466
1839
  toggleGlobalDarkMode,
467
- useGlobalDarkMode,
1840
+ useColors,
468
1841
  useTheme
469
1842
  });