@kbach/react 0.5.38 → 0.5.40

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.
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var jsx_runtime_exports = {};
32
32
  __export(jsx_runtime_exports, {
33
33
  Fragment: () => import_react5.Fragment,
34
+ _invalidateDefaultFontCache: () => _invalidateDefaultFontCache,
34
35
  jsx: () => jsx,
35
36
  jsxs: () => jsxs
36
37
  });
@@ -597,7 +598,11 @@ var LRUCache = class {
597
598
  return this;
598
599
  }
599
600
  has(key) {
600
- return this.cache.has(key);
601
+ if (!this.cache.has(key)) return false;
602
+ const value = this.cache.get(key);
603
+ this.cache.delete(key);
604
+ this.cache.set(key, value);
605
+ return true;
601
606
  }
602
607
  delete(key) {
603
608
  return this.cache.delete(key);
@@ -627,773 +632,116 @@ function escapeCSSSelector(cls) {
627
632
  return cls.replace(/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g, "\\$&");
628
633
  }
629
634
 
630
- // src/core/parser.ts
631
- var PLUGIN_MODIFIERS = /* @__PURE__ */ new Set();
632
- function registerModifier(name) {
633
- PLUGIN_MODIFIERS.add(name);
635
+ // src/core/registry.ts
636
+ var BUILTIN_MODIFIERS = {
637
+ // ── Mode ─────────────────────────────────────────────────────────────────
638
+ dark: { darkScheme: "dark", jsBehavior: "mode", jsMatch: (d) => d },
639
+ "not-light": { darkScheme: "dark", jsBehavior: "mode", jsMatch: (d) => d },
640
+ light: { darkScheme: "light", jsBehavior: "mode", jsMatch: (d) => !d },
641
+ "not-dark": { darkScheme: "light", jsBehavior: "mode", jsMatch: (d) => !d },
642
+ // ── Interactive — JS state + CSS pseudo ───────────────────────────────────
643
+ hover: { pseudo: ":hover", jsBehavior: "interactive", jsMatch: (_, s) => !!s.hover },
644
+ "not-hover": { pseudo: ":not(:hover)", jsBehavior: "interactive", jsMatch: (_, s) => !s.hover },
645
+ focus: { pseudo: ":focus", jsBehavior: "interactive", jsMatch: (_, s) => !!s.focus },
646
+ "not-focus": { pseudo: ":not(:focus)", jsBehavior: "interactive", jsMatch: (_, s) => !s.focus },
647
+ active: { pseudo: ":active", jsBehavior: "interactive", jsMatch: (_, s) => !!s.active || !!s.pressed },
648
+ "not-active": { pseudo: ":not(:active)", jsBehavior: "interactive", jsMatch: (_, s) => !s.active && !s.pressed },
649
+ pressed: { pseudo: ":active", jsBehavior: "interactive", jsMatch: (_, s) => !!s.pressed || !!s.active },
650
+ "not-pressed": { pseudo: ":not(:active)", jsBehavior: "interactive", jsMatch: (_, s) => !s.pressed && !s.active },
651
+ disabled: { pseudo: ":disabled", jsBehavior: "interactive", jsMatch: (_, s) => !!s.disabled },
652
+ "not-disabled": { pseudo: ":not(:disabled)", jsBehavior: "interactive", jsMatch: (_, s) => !s.disabled },
653
+ checked: { pseudo: ":checked", jsBehavior: "interactive", jsMatch: (_, s) => !!s.checked },
654
+ "not-checked": { pseudo: ":not(:checked)", jsBehavior: "interactive", jsMatch: (_, s) => !s.checked },
655
+ visited: { pseudo: ":visited", jsBehavior: "interactive", jsMatch: (_, s) => !!s.visited },
656
+ "not-visited": { pseudo: ":not(:visited)", jsBehavior: "interactive", jsMatch: (_, s) => !s.visited },
657
+ placeholder: { pseudo: "::placeholder", jsBehavior: "interactive", jsMatch: (_, s) => !!s.placeholder },
658
+ // ── CSS-only pseudo-classes (structural) ──────────────────────────────────
659
+ first: { pseudo: ":first-child", jsBehavior: "css-only", forcesImportant: true },
660
+ last: { pseudo: ":last-child", jsBehavior: "css-only", forcesImportant: true },
661
+ odd: { pseudo: ":nth-child(odd)", jsBehavior: "css-only", forcesImportant: true },
662
+ even: { pseudo: ":nth-child(even)", jsBehavior: "css-only", forcesImportant: true },
663
+ only: { pseudo: ":only-child", jsBehavior: "css-only", forcesImportant: true },
664
+ "focus-within": { pseudo: ":focus-within", jsBehavior: "css-only", forcesImportant: true },
665
+ "focus-visible": { pseudo: ":focus-visible", jsBehavior: "css-only", forcesImportant: true },
666
+ // ── CSS-only pseudo-elements ───────────────────────────────────────────────
667
+ before: { pseudo: "::before", jsBehavior: "css-only" },
668
+ after: { pseudo: "::after", jsBehavior: "css-only" },
669
+ selection: { pseudo: "::selection", jsBehavior: "css-only" },
670
+ "first-letter": { pseudo: "::first-letter", jsBehavior: "css-only" },
671
+ "first-line": { pseudo: "::first-line", jsBehavior: "css-only" },
672
+ marker: { pseudo: "::marker", jsBehavior: "css-only" },
673
+ // ── Group / peer ancestor selectors (CSS-only) ─────────────────────────────
674
+ "group-hover": { ancestorSelector: ".group:hover ", jsBehavior: "css-only", forcesImportant: true },
675
+ "group-focus": { ancestorSelector: ".group:focus ", jsBehavior: "css-only", forcesImportant: true },
676
+ "peer-hover": { ancestorSelector: ".peer:hover ~ ", jsBehavior: "css-only", forcesImportant: true },
677
+ "peer-focus": { ancestorSelector: ".peer:focus ~ ", jsBehavior: "css-only", forcesImportant: true },
678
+ // ── Responsive — both CSS (@media min-width) and JS (breakpoints set) ──────
679
+ sm: { isResponsive: true, jsBehavior: "responsive", jsMatch: (_, __, bp) => bp.has("sm") },
680
+ md: { isResponsive: true, jsBehavior: "responsive", jsMatch: (_, __, bp) => bp.has("md") },
681
+ lg: { isResponsive: true, jsBehavior: "responsive", jsMatch: (_, __, bp) => bp.has("lg") },
682
+ xl: { isResponsive: true, jsBehavior: "responsive", jsMatch: (_, __, bp) => bp.has("xl") },
683
+ "2xl": { isResponsive: true, jsBehavior: "responsive", jsMatch: (_, __, bp) => bp.has("2xl") },
684
+ // ── Print media (CSS-only) ─────────────────────────────────────────────────
685
+ print: { mediaQuery: "print", jsBehavior: "css-only", forcesImportant: true },
686
+ // ── Orientation / accessibility media (CSS-only) ───────────────────────────
687
+ landscape: { mediaQuery: "(orientation: landscape)", jsBehavior: "css-only", forcesImportant: true },
688
+ portrait: { mediaQuery: "(orientation: portrait)", jsBehavior: "css-only", forcesImportant: true },
689
+ "motion-reduce": { mediaQuery: "(prefers-reduced-motion: reduce)", jsBehavior: "css-only", forcesImportant: true },
690
+ "motion-safe": { mediaQuery: "(prefers-reduced-motion: no-preference)", jsBehavior: "css-only", forcesImportant: true },
691
+ "contrast-more": { mediaQuery: "(prefers-contrast: more)", jsBehavior: "css-only", forcesImportant: true },
692
+ "contrast-less": { mediaQuery: "(prefers-contrast: less)", jsBehavior: "css-only", forcesImportant: true },
693
+ // ── Directionality (CSS-only) ──────────────────────────────────────────────
694
+ rtl: { dirSelector: '[dir="rtl"] ', jsBehavior: "css-only", forcesImportant: true },
695
+ ltr: { dirSelector: '[dir="ltr"] ', jsBehavior: "css-only", forcesImportant: true }
696
+ };
697
+ var _pluginModifiers = {};
698
+ var _allNames = null;
699
+ var _interactiveNames = null;
700
+ var _modeNames = null;
701
+ var _responsiveNames = null;
702
+ function _invalidate() {
703
+ _allNames = null;
704
+ _interactiveNames = null;
705
+ _modeNames = null;
706
+ _responsiveNames = null;
707
+ }
708
+ function registerModifier(name, def) {
709
+ _pluginModifiers[name] = def;
710
+ _invalidate();
634
711
  }
635
712
  function clearPluginModifiers() {
636
- PLUGIN_MODIFIERS.clear();
637
- }
638
- var MODIFIERS = /* @__PURE__ */ new Set([
639
- // Theme
640
- "dark",
641
- "light",
642
- "not-dark",
643
- "not-light",
644
- // Interaction
645
- "hover",
646
- "focus",
647
- "active",
648
- "visited",
649
- "disabled",
650
- "checked",
651
- "pressed",
652
- "placeholder",
653
- "focus-within",
654
- "focus-visible",
655
- // Negated interaction
656
- "not-hover",
657
- "not-focus",
658
- "not-active",
659
- "not-visited",
660
- "not-disabled",
661
- "not-checked",
662
- "not-pressed",
663
- // Structural
664
- "first",
665
- "last",
666
- "odd",
667
- "even",
668
- "only",
669
- // Group / peer
670
- "group-hover",
671
- "group-focus",
672
- "peer-hover",
673
- "peer-focus",
674
- // Responsive (handled separately but accepted)
675
- "sm",
676
- "md",
677
- "lg",
678
- "xl",
679
- "2xl",
680
- // Pseudo-elements (CSS-injection only; matchesMods returns false for these)
681
- "before",
682
- "after",
683
- "selection",
684
- "first-letter",
685
- "first-line",
686
- "marker",
687
- // Print media modifier
688
- "print",
689
- // Orientation media modifiers (CSS-injection only)
690
- "landscape",
691
- "portrait",
692
- // Accessibility media modifiers (CSS-injection only)
693
- "motion-reduce",
694
- "motion-safe",
695
- "contrast-more",
696
- "contrast-less",
697
- // Directionality modifiers (CSS-injection only)
698
- "rtl",
699
- "ltr"
700
- ]);
701
- var UTILITY_PREFIXES = [
702
- // Multi-word flex
703
- "flex-row-reverse",
704
- "flex-col-reverse",
705
- "flex-row",
706
- "flex-col",
707
- "flex-wrap-reverse",
708
- "flex-wrap",
709
- "flex-nowrap",
710
- "flex-shrink-0",
711
- "flex-shrink",
712
- "flex-grow-0",
713
- "flex-grow",
714
- "items-start",
715
- "items-end",
716
- "items-center",
717
- "items-baseline",
718
- "items-stretch",
719
- "justify-start",
720
- "justify-end",
721
- "justify-center",
722
- "justify-between",
723
- "justify-around",
724
- "justify-evenly",
725
- "content-start",
726
- "content-end",
727
- "content-center",
728
- "content-between",
729
- "content-around",
730
- "content-evenly",
731
- "self-start",
732
- "self-end",
733
- "self-center",
734
- "self-auto",
735
- "self-stretch",
736
- "text-left",
737
- "text-right",
738
- "text-center",
739
- "text-justify",
740
- "font-thin",
741
- "font-extralight",
742
- "font-light",
743
- "font-normal",
744
- "font-medium",
745
- "font-semibold",
746
- "font-bold",
747
- "font-extrabold",
748
- "font-black",
749
- "overflow-hidden",
750
- "overflow-visible",
751
- "overflow-scroll",
752
- "overflow-auto",
753
- "overflow-x-hidden",
754
- "overflow-x-scroll",
755
- "overflow-x-auto",
756
- "overflow-y-hidden",
757
- "overflow-y-scroll",
758
- "overflow-y-auto",
759
- "object-contain",
760
- "object-cover",
761
- "object-fill",
762
- "object-none",
763
- "object-scale-down",
764
- "border-solid",
765
- "border-dashed",
766
- "border-dotted",
767
- "border-none",
768
- "border-t",
769
- "border-r",
770
- "border-b",
771
- "border-l",
772
- "rounded-tl",
773
- "rounded-tr",
774
- "rounded-bl",
775
- "rounded-br",
776
- "rounded-t",
777
- "rounded-r",
778
- "rounded-b",
779
- "rounded-l",
780
- "list-none",
781
- "list-disc",
782
- "list-decimal",
783
- "cursor-auto",
784
- "cursor-default",
785
- "cursor-pointer",
786
- "cursor-wait",
787
- "cursor-text",
788
- "cursor-move",
789
- "cursor-not-allowed",
790
- "select-none",
791
- "select-text",
792
- "select-all",
793
- "select-auto",
794
- "pointer-events-none",
795
- "pointer-events-auto",
796
- "whitespace-normal",
797
- "whitespace-nowrap",
798
- "whitespace-pre-wrap",
799
- "whitespace-pre-line",
800
- "whitespace-pre",
801
- "break-normal",
802
- "break-words",
803
- "break-all",
804
- "break-keep",
805
- "bg-clip-border",
806
- "bg-clip-padding",
807
- "bg-clip-content",
808
- "bg-clip-text",
809
- "bg-gradient-to",
810
- "resize-none",
811
- "resize-y",
812
- "resize-x",
813
- "box-border",
814
- "box-content",
815
- "gap-x",
816
- "gap-y",
817
- "inset-x",
818
- "inset-y",
819
- "divide-x",
820
- "divide-y",
821
- "space-x",
822
- "space-y",
823
- "translate-x",
824
- "translate-y",
825
- "scale-x",
826
- "scale-y",
827
- "skew-x",
828
- "skew-y",
829
- // Transform origin (single prefix, value carries direction)
830
- "origin",
831
- "min-w",
832
- "min-h",
833
- "max-w",
834
- "max-h",
835
- "ring-offset",
836
- "bg-opacity",
837
- "text-opacity",
838
- "border-opacity",
839
- // Grid placement
840
- "col-span",
841
- "col-start",
842
- "col-end",
843
- "row-span",
844
- "row-start",
845
- "row-end",
846
- "grid-cols",
847
- "grid-rows",
848
- "grid-flow",
849
- "auto-cols",
850
- "auto-rows",
851
- // Grid alignment
852
- "place-items",
853
- "place-content",
854
- "place-self",
855
- "justify-items",
856
- "justify-self",
857
- // Backdrop filters (longer than 'backdrop' alone)
858
- "backdrop-blur",
859
- "backdrop-brightness",
860
- "backdrop-contrast",
861
- "backdrop-grayscale",
862
- "backdrop-hue-rotate",
863
- "backdrop-invert",
864
- "backdrop-opacity",
865
- "backdrop-saturate",
866
- "backdrop-sepia",
867
- "backdrop-filter",
868
- // Filters
869
- "drop-shadow",
870
- "hue-rotate",
871
- "text-shadow",
872
- "underline-offset",
873
- "outline-offset",
874
- "will-change",
875
- "mix-blend",
876
- "bg-blend",
877
- "decoration",
878
- "perspective",
879
- "tint",
880
- "animate",
881
- // Single-word prefixes last
882
- "appearance-none",
883
- "outline-none",
884
- "outline",
885
- "inline-flex",
886
- "inline-block",
887
- "inline-grid",
888
- "italic",
889
- "non-italic",
890
- "underline",
891
- "overline",
892
- "line-through",
893
- "no-underline",
894
- "uppercase",
895
- "lowercase",
896
- "capitalize",
897
- "normal-case",
898
- "antialiased",
899
- "subpixel-antialiased",
900
- "overflow-ellipsis",
901
- "truncate",
902
- "sr-only",
903
- "not-sr-only",
904
- "relative",
905
- "absolute",
906
- "fixed",
907
- "sticky",
908
- "static",
909
- "visible",
910
- "invisible",
911
- "hidden",
912
- "contents",
913
- "flow-root",
914
- "block",
915
- "inline",
916
- "flex",
917
- "grid",
918
- "resize",
919
- "appearance",
920
- "border",
921
- "rounded",
922
- "shadow",
923
- "size",
924
- "opacity",
925
- "leading",
926
- "tracking",
927
- "line-clamp",
928
- "basis",
929
- "grow",
930
- "shrink",
931
- "order",
932
- "delay",
933
- "duration",
934
- "scale",
935
- "rotate",
936
- "aspect",
937
- "columns",
938
- "ring",
939
- "gap",
940
- "inset",
941
- "filter",
942
- "transform",
943
- "blur",
944
- "brightness",
945
- "contrast",
946
- "grayscale",
947
- "invert",
948
- "saturate",
949
- "sepia",
950
- "bg",
951
- "text",
952
- "font",
953
- "caret",
954
- "accent",
955
- "from",
956
- "via",
957
- "to",
958
- "divide",
959
- "space",
960
- "transition",
961
- "px",
962
- "py",
963
- "pt",
964
- "pr",
965
- "pb",
966
- "pl",
967
- "p",
968
- "mx",
969
- "my",
970
- "mt",
971
- "mr",
972
- "mb",
973
- "ml",
974
- "m",
975
- "w",
976
- "h",
977
- "top",
978
- "right",
979
- "bottom",
980
- "left",
981
- "z",
982
- "col",
983
- "row"
984
- ];
985
- var SORTED_PREFIXES = [...new Set(UTILITY_PREFIXES)].sort((a, b) => b.length - a.length);
986
- var STANDALONE_UTILITIES = /* @__PURE__ */ new Set([
987
- // Display
988
- "flex",
989
- "block",
990
- "inline-block",
991
- "inline",
992
- "grid",
993
- "inline-flex",
994
- "inline-grid",
995
- "grd",
996
- "hidden",
997
- "contents",
998
- "flow-root",
999
- // Position
1000
- "relative",
1001
- "absolute",
1002
- "fixed",
1003
- "sticky",
1004
- "static",
1005
- // Visibility
1006
- "visible",
1007
- "invisible",
1008
- // Typography
1009
- "uppercase",
1010
- "lowercase",
1011
- "capitalize",
1012
- "normal-case",
1013
- "italic",
1014
- "non-italic",
1015
- "underline",
1016
- "overline",
1017
- "line-through",
1018
- "no-underline",
1019
- "truncate",
1020
- "antialiased",
1021
- "sr-only",
1022
- "not-sr-only",
1023
- // Font variant numeric
1024
- "normal-nums",
1025
- "ordinal",
1026
- "slashed-zero",
1027
- "lining-nums",
1028
- "oldstyle-nums",
1029
- "proportional-nums",
1030
- "tabular-nums",
1031
- "diagonal-fractions",
1032
- "stacked-fractions",
1033
- // Flexbox
1034
- "flex-row",
1035
- "flex-col",
1036
- "flex-row-reverse",
1037
- "flex-col-reverse",
1038
- "flex-wrap",
1039
- "flex-wrap-reverse",
1040
- "flex-nowrap",
1041
- "flex-shrink",
1042
- "flex-shrink-0",
1043
- "flex-grow",
1044
- "flex-grow-0",
1045
- "items-start",
1046
- "items-end",
1047
- "items-center",
1048
- "items-baseline",
1049
- "items-stretch",
1050
- "justify-start",
1051
- "justify-end",
1052
- "justify-center",
1053
- "justify-between",
1054
- "justify-around",
1055
- "justify-evenly",
1056
- "content-start",
1057
- "content-end",
1058
- "content-center",
1059
- "content-between",
1060
- "content-around",
1061
- "content-evenly",
1062
- "content-stretch",
1063
- "self-start",
1064
- "self-end",
1065
- "self-center",
1066
- "self-auto",
1067
- "self-stretch",
1068
- "self-baseline",
1069
- // Text align
1070
- "text-left",
1071
- "text-right",
1072
- "text-center",
1073
- "text-justify",
1074
- // Font weight shortcuts
1075
- "font-thin",
1076
- "font-extralight",
1077
- "font-light",
1078
- "font-normal",
1079
- "font-medium",
1080
- "font-semibold",
1081
- "font-bold",
1082
- "font-extrabold",
1083
- "font-black",
1084
- // Overflow
1085
- "overflow-hidden",
1086
- "overflow-visible",
1087
- "overflow-scroll",
1088
- "overflow-auto",
1089
- "overflow-x-hidden",
1090
- "overflow-x-scroll",
1091
- "overflow-x-auto",
1092
- "overflow-y-hidden",
1093
- "overflow-y-scroll",
1094
- "overflow-y-auto",
1095
- // Object fit
1096
- "object-contain",
1097
- "object-cover",
1098
- "object-fill",
1099
- "object-none",
1100
- "object-scale-down",
1101
- // Object position
1102
- "object-center",
1103
- "object-top",
1104
- "object-bottom",
1105
- "object-left",
1106
- "object-right",
1107
- "object-left-top",
1108
- "object-left-bottom",
1109
- "object-right-top",
1110
- "object-right-bottom",
1111
- // Border
1112
- "border-solid",
1113
- "border-dashed",
1114
- "border-dotted",
1115
- "border-none",
1116
- "border-t",
1117
- "border-r",
1118
- "border-b",
1119
- "border-l",
1120
- "border-collapse",
1121
- "border-separate",
1122
- // Lists
1123
- "list-none",
1124
- "list-disc",
1125
- "list-decimal",
1126
- "list-inside",
1127
- "list-outside",
1128
- // Cursor / select
1129
- "cursor-auto",
1130
- "cursor-default",
1131
- "cursor-pointer",
1132
- "cursor-wait",
1133
- "cursor-text",
1134
- "cursor-move",
1135
- "cursor-not-allowed",
1136
- "select-none",
1137
- "select-text",
1138
- "select-all",
1139
- "select-auto",
1140
- "pointer-events-none",
1141
- "pointer-events-auto",
1142
- // Whitespace / word break
1143
- "whitespace-normal",
1144
- "whitespace-nowrap",
1145
- "whitespace-pre",
1146
- "whitespace-pre-wrap",
1147
- "whitespace-pre-line",
1148
- "break-normal",
1149
- "break-words",
1150
- "break-all",
1151
- // Background clip
1152
- "bg-clip-border",
1153
- "bg-clip-padding",
1154
- "bg-clip-content",
1155
- "bg-clip-text",
1156
- // Background size
1157
- "bg-auto",
1158
- "bg-cover",
1159
- "bg-contain",
1160
- // Background position
1161
- "bg-center",
1162
- "bg-top",
1163
- "bg-bottom",
1164
- "bg-left",
1165
- "bg-right",
1166
- "bg-left-top",
1167
- "bg-left-bottom",
1168
- "bg-right-top",
1169
- "bg-right-bottom",
1170
- // Background repeat
1171
- "bg-repeat",
1172
- "bg-no-repeat",
1173
- "bg-repeat-x",
1174
- "bg-repeat-y",
1175
- "bg-repeat-round",
1176
- "bg-repeat-space",
1177
- // Background attachment
1178
- "bg-fixed",
1179
- "bg-local",
1180
- "bg-scroll",
1181
- // Background image
1182
- "bg-none",
1183
- // Box sizing
1184
- "box-border",
1185
- "box-content",
1186
- // Resize
1187
- "resize",
1188
- "resize-none",
1189
- "resize-y",
1190
- "resize-x",
1191
- // Outline
1192
- "appearance-none",
1193
- "outline-none",
1194
- "outline",
1195
- // Table
1196
- "table",
1197
- "table-auto",
1198
- "table-fixed",
1199
- "caption-top",
1200
- "caption-bottom",
1201
- // CSS filters (standalone = default/full effect)
1202
- "grayscale",
1203
- "invert",
1204
- "sepia",
1205
- // Isolation
1206
- "isolate",
1207
- "isolation-auto",
1208
- // Backface visibility (both platforms)
1209
- "backface-visible",
1210
- "backface-hidden",
1211
- // Divide none
1212
- "divide-none",
1213
- // Group / peer markers (no-op style; needed so isKnownUtility recognises them)
1214
- "group",
1215
- "peer",
1216
- // Text-wrap (web-only)
1217
- "text-wrap",
1218
- "text-nowrap",
1219
- "text-balance",
1220
- "text-pretty",
1221
- // Screen sizing
1222
- "w-screen",
1223
- "min-h-screen",
1224
- "max-h-screen",
1225
- "min-w-screen",
1226
- "max-w-screen",
1227
- // max-w named container sizes (Tailwind compat)
1228
- "max-w-none",
1229
- "max-w-xs",
1230
- "max-w-sm",
1231
- "max-w-md",
1232
- "max-w-lg",
1233
- "max-w-xl",
1234
- "max-w-2xl",
1235
- "max-w-3xl",
1236
- "max-w-4xl",
1237
- "max-w-5xl",
1238
- "max-w-6xl",
1239
- "max-w-7xl",
1240
- "max-w-prose",
1241
- // Extended cursors (web-only)
1242
- "cursor-grab",
1243
- "cursor-grabbing",
1244
- "cursor-zoom-in",
1245
- "cursor-zoom-out",
1246
- "cursor-crosshair",
1247
- "cursor-help",
1248
- "cursor-none",
1249
- // Overflow clip (web-only)
1250
- "overflow-clip",
1251
- "overflow-x-clip",
1252
- "overflow-y-clip",
1253
- // Scroll behavior (web-only)
1254
- "scroll-smooth",
1255
- "scroll-auto",
1256
- // Float & clear (web-only)
1257
- "float-left",
1258
- "float-right",
1259
- "float-start",
1260
- "float-end",
1261
- "float-none",
1262
- "clear-left",
1263
- "clear-right",
1264
- "clear-both",
1265
- "clear-start",
1266
- "clear-end",
1267
- "clear-none",
1268
- // Vertical align (web-only)
1269
- "align-baseline",
1270
- "align-top",
1271
- "align-middle",
1272
- "align-bottom",
1273
- "align-text-top",
1274
- "align-text-bottom",
1275
- "align-sub",
1276
- "align-super",
1277
- // Touch action (web-only)
1278
- "touch-auto",
1279
- "touch-none",
1280
- "touch-pan-x",
1281
- "touch-pan-y",
1282
- "touch-pan-left",
1283
- "touch-pan-right",
1284
- "touch-pan-up",
1285
- "touch-pan-down",
1286
- "touch-pinch-zoom",
1287
- "touch-manipulation"
1288
- ]);
1289
- function parseClass(className) {
1290
- const trimmed = className.trim();
1291
- if (!trimmed) return null;
1292
- const modifiers = [];
1293
- let remaining = trimmed;
1294
- for (let i = 0; i < 3; i++) {
1295
- const colonIdx = findOuterColon(remaining);
1296
- if (colonIdx === -1) break;
1297
- const candidate = remaining.slice(0, colonIdx);
1298
- if (MODIFIERS.has(candidate) || PLUGIN_MODIFIERS.has(candidate)) {
1299
- modifiers.push(candidate);
1300
- remaining = remaining.slice(colonIdx + 1);
1301
- } else {
1302
- break;
1303
- }
1304
- }
1305
- let important = false;
1306
- if (remaining.startsWith("!") && remaining.length > 1) {
1307
- important = true;
1308
- remaining = remaining.slice(1);
1309
- }
1310
- let negative = false;
1311
- if (remaining.startsWith("-") && remaining.length > 1 && remaining[1] !== "-") {
1312
- negative = true;
1313
- remaining = remaining.slice(1);
1314
- }
1315
- const bracketStart = remaining.lastIndexOf("-[");
1316
- if (bracketStart > 0 && remaining.endsWith("]")) {
1317
- const utility = remaining.slice(0, bracketStart);
1318
- const value = remaining.slice(bracketStart + 2, -1).replace(/_/g, " ");
1319
- return { original: trimmed, modifiers, negative, important, utility, value, isArbitrary: true };
1320
- }
1321
- if (STANDALONE_UTILITIES.has(remaining)) {
1322
- return { original: trimmed, modifiers, negative, important, utility: remaining, value: "", isArbitrary: false };
1323
- }
1324
- for (const prefix of SORTED_PREFIXES) {
1325
- if (remaining === prefix) {
1326
- return { original: trimmed, modifiers, negative, important, utility: prefix, value: "", isArbitrary: false };
1327
- }
1328
- if (remaining.startsWith(prefix + "-")) {
1329
- const value = remaining.slice(prefix.length + 1);
1330
- return { original: trimmed, modifiers, negative, important, utility: prefix, value, isArbitrary: false };
1331
- }
1332
- }
1333
- const firstDash = remaining.indexOf("-");
1334
- if (firstDash > 0) {
1335
- return {
1336
- original: trimmed,
1337
- modifiers,
1338
- negative,
1339
- important,
1340
- utility: remaining.slice(0, firstDash),
1341
- value: remaining.slice(firstDash + 1),
1342
- isArbitrary: false
1343
- };
1344
- }
1345
- return { original: trimmed, modifiers, negative, important, utility: remaining, value: "", isArbitrary: false };
713
+ for (const k of Object.keys(_pluginModifiers)) delete _pluginModifiers[k];
714
+ _invalidate();
1346
715
  }
1347
- function splitClassTokens(classString) {
1348
- const tokens = [];
1349
- let current = "";
1350
- let depth = 0;
1351
- for (let i = 0; i < classString.length; i++) {
1352
- const ch = classString[i];
1353
- if (ch === "[") {
1354
- depth++;
1355
- current += ch;
1356
- continue;
1357
- }
1358
- if (ch === "]") {
1359
- depth--;
1360
- current += ch;
1361
- continue;
1362
- }
1363
- if (/\s/.test(ch)) {
1364
- if (depth === 0) {
1365
- if (current) {
1366
- tokens.push(current);
1367
- current = "";
1368
- }
1369
- }
1370
- } else {
1371
- current += ch;
1372
- }
1373
- }
1374
- if (current) tokens.push(current);
1375
- return tokens;
716
+ function getModifier(name) {
717
+ return BUILTIN_MODIFIERS[name] ?? _pluginModifiers[name];
1376
718
  }
1377
- function normalizeClassString(classString) {
1378
- return splitClassTokens(classString).join(" ");
719
+ function isKnownModifier(name) {
720
+ return name in BUILTIN_MODIFIERS || name in _pluginModifiers;
1379
721
  }
1380
- function parseClasses(classString) {
1381
- const results = [];
1382
- for (const token of splitClassTokens(classString)) {
1383
- const parsed = parseClass(token);
1384
- if (parsed) results.push(parsed);
722
+ function _allEntries() {
723
+ return [...Object.entries(BUILTIN_MODIFIERS), ...Object.entries(_pluginModifiers)];
724
+ }
725
+ function getInteractiveModifiers() {
726
+ if (!_interactiveNames) {
727
+ _interactiveNames = new Set(_allEntries().filter(([, d]) => d.jsBehavior === "interactive").map(([k]) => k));
1385
728
  }
1386
- return results;
729
+ return _interactiveNames;
1387
730
  }
1388
- function findOuterColon(s) {
1389
- let depth = 0;
1390
- for (let i = 0; i < s.length; i++) {
1391
- const ch = s[i];
1392
- if (ch === "[") depth++;
1393
- else if (ch === "]") depth--;
1394
- else if (ch === ":" && depth === 0) return i;
731
+ function getModeModifiers() {
732
+ if (!_modeNames) {
733
+ _modeNames = new Set(_allEntries().filter(([, d]) => d.jsBehavior === "mode").map(([k]) => k));
1395
734
  }
1396
- return -1;
735
+ return _modeNames;
736
+ }
737
+ function getResponsiveModifiers() {
738
+ if (!_responsiveNames) {
739
+ _responsiveNames = new Set(_allEntries().filter(([, d]) => d.jsBehavior === "responsive").map(([k]) => k));
740
+ }
741
+ return _responsiveNames;
742
+ }
743
+ function matchModifier(name, isDark, state, breakpoints) {
744
+ return getModifier(name)?.jsMatch?.(isDark, state, breakpoints) ?? false;
1397
745
  }
1398
746
 
1399
747
  // src/core/utilities.ts
@@ -1487,6 +835,7 @@ function resolveSizing(value, spacing, isArbitrary) {
1487
835
  if (raw !== void 0) return raw;
1488
836
  if (/^\d+\/\d+$/.test(value)) {
1489
837
  const [num, den] = value.split("/").map(Number);
838
+ if (!den) return null;
1490
839
  return `${(num / den * 100).toFixed(6)}%`;
1491
840
  }
1492
841
  return null;
@@ -3001,10 +2350,10 @@ function resolveUtility(parsed, theme) {
3001
2350
  if (!parsed.value) {
3002
2351
  if (parsed.utility in PLUGIN_STANDALONE) return PLUGIN_STANDALONE[parsed.utility] ?? null;
3003
2352
  if (parsed.utility === "grd" || parsed.utility === "grid") {
3004
- return { display: "grid" };
2353
+ return getEffectiveIsWeb() ? { display: "grid" } : null;
3005
2354
  }
3006
2355
  if (parsed.utility === "inline-grid") {
3007
- return { display: "inline-grid" };
2356
+ return getEffectiveIsWeb() ? { display: "inline-grid" } : null;
3008
2357
  }
3009
2358
  if (parsed.utility in getStandalone()) return getStandalone()[parsed.utility] ?? null;
3010
2359
  }
@@ -3017,6 +2366,8 @@ var PLUGIN_RESOLVERS = {};
3017
2366
  function clearPluginUtilities() {
3018
2367
  for (const key of Object.keys(PLUGIN_STANDALONE)) delete PLUGIN_STANDALONE[key];
3019
2368
  for (const key of Object.keys(PLUGIN_RESOLVERS)) delete PLUGIN_RESOLVERS[key];
2369
+ _sortedPrefixes = null;
2370
+ _standaloneNames = null;
3020
2371
  }
3021
2372
  function getPluginStandaloneMap() {
3022
2373
  return PLUGIN_STANDALONE;
@@ -3024,6 +2375,129 @@ function getPluginStandaloneMap() {
3024
2375
  function isKnownUtility(utility) {
3025
2376
  return utility in getStandalone() || utility in RESOLVERS || utility in PLUGIN_STANDALONE || utility in PLUGIN_RESOLVERS;
3026
2377
  }
2378
+ var _sortedPrefixes = null;
2379
+ var _standaloneNames = null;
2380
+ function getBuiltinUtilityPrefixes() {
2381
+ if (!_sortedPrefixes) {
2382
+ const all = [.../* @__PURE__ */ new Set([...Object.keys(RESOLVERS), ...Object.keys(PLUGIN_RESOLVERS)])];
2383
+ _sortedPrefixes = all.sort((a, b) => b.length - a.length);
2384
+ }
2385
+ return _sortedPrefixes;
2386
+ }
2387
+ function getBuiltinStandaloneNames() {
2388
+ if (!_standaloneNames) {
2389
+ _standaloneNames = /* @__PURE__ */ new Set([...Object.keys(getStandalone()), ...Object.keys(PLUGIN_STANDALONE)]);
2390
+ }
2391
+ return _standaloneNames;
2392
+ }
2393
+
2394
+ // src/core/parser.ts
2395
+ function parseClass(className) {
2396
+ const trimmed = className.trim();
2397
+ if (!trimmed) return null;
2398
+ const modifiers = [];
2399
+ let remaining = trimmed;
2400
+ while (true) {
2401
+ const colonIdx = findOuterColon(remaining);
2402
+ if (colonIdx === -1) break;
2403
+ const candidate = remaining.slice(0, colonIdx);
2404
+ if (!isKnownModifier(candidate)) break;
2405
+ modifiers.push(candidate);
2406
+ remaining = remaining.slice(colonIdx + 1);
2407
+ }
2408
+ let important = false;
2409
+ if (remaining.startsWith("!") && remaining.length > 1) {
2410
+ important = true;
2411
+ remaining = remaining.slice(1);
2412
+ }
2413
+ let negative = false;
2414
+ if (remaining.startsWith("-") && remaining.length > 1 && remaining[1] !== "-") {
2415
+ negative = true;
2416
+ remaining = remaining.slice(1);
2417
+ }
2418
+ const bracketStart = remaining.lastIndexOf("-[");
2419
+ if (bracketStart > 0 && remaining.endsWith("]")) {
2420
+ const utility = remaining.slice(0, bracketStart);
2421
+ const value = remaining.slice(bracketStart + 2, -1).replace(/_/g, " ");
2422
+ return { original: trimmed, modifiers, negative, important, utility, value, isArbitrary: true };
2423
+ }
2424
+ if (getBuiltinStandaloneNames().has(remaining)) {
2425
+ return { original: trimmed, modifiers, negative, important, utility: remaining, value: "", isArbitrary: false };
2426
+ }
2427
+ for (const prefix of getBuiltinUtilityPrefixes()) {
2428
+ if (remaining === prefix) {
2429
+ return { original: trimmed, modifiers, negative, important, utility: prefix, value: "", isArbitrary: false };
2430
+ }
2431
+ if (remaining.startsWith(prefix + "-")) {
2432
+ const value = remaining.slice(prefix.length + 1);
2433
+ return { original: trimmed, modifiers, negative, important, utility: prefix, value, isArbitrary: false };
2434
+ }
2435
+ }
2436
+ const firstDash = remaining.indexOf("-");
2437
+ if (firstDash > 0) {
2438
+ return {
2439
+ original: trimmed,
2440
+ modifiers,
2441
+ negative,
2442
+ important,
2443
+ utility: remaining.slice(0, firstDash),
2444
+ value: remaining.slice(firstDash + 1),
2445
+ isArbitrary: false
2446
+ };
2447
+ }
2448
+ return { original: trimmed, modifiers, negative, important, utility: remaining, value: "", isArbitrary: false };
2449
+ }
2450
+ function splitClassTokens(classString) {
2451
+ const tokens = [];
2452
+ let current = "";
2453
+ let depth = 0;
2454
+ for (let i = 0; i < classString.length; i++) {
2455
+ const ch = classString[i];
2456
+ if (ch === "[") {
2457
+ depth++;
2458
+ current += ch;
2459
+ continue;
2460
+ }
2461
+ if (ch === "]") {
2462
+ depth--;
2463
+ current += ch;
2464
+ continue;
2465
+ }
2466
+ if (/\s/.test(ch)) {
2467
+ if (depth === 0) {
2468
+ if (current) {
2469
+ tokens.push(current);
2470
+ current = "";
2471
+ }
2472
+ }
2473
+ } else {
2474
+ current += ch;
2475
+ }
2476
+ }
2477
+ if (current) tokens.push(current);
2478
+ return tokens;
2479
+ }
2480
+ function normalizeClassString(classString) {
2481
+ return splitClassTokens(classString).join(" ");
2482
+ }
2483
+ function parseClasses(classString) {
2484
+ const results = [];
2485
+ for (const token of splitClassTokens(classString)) {
2486
+ const parsed = parseClass(token);
2487
+ if (parsed) results.push(parsed);
2488
+ }
2489
+ return results;
2490
+ }
2491
+ function findOuterColon(s) {
2492
+ let depth = 0;
2493
+ for (let i = 0; i < s.length; i++) {
2494
+ const ch = s[i];
2495
+ if (ch === "[") depth++;
2496
+ else if (ch === "]") depth--;
2497
+ else if (ch === ":" && depth === 0) return i;
2498
+ }
2499
+ return -1;
2500
+ }
3027
2501
 
3028
2502
  // src/core/responsiveStore.ts
3029
2503
  var RESPONSIVE_KEY = "__kbach_responsive__";
@@ -3056,7 +2530,30 @@ function getActiveBreakpoints(width) {
3056
2530
  }
3057
2531
 
3058
2532
  // src/core/resolver.ts
3059
- var styleCache = new LRUCache(1e4);
2533
+ var _themeCache = /* @__PURE__ */ new WeakMap();
2534
+ function getThemeCache(theme) {
2535
+ let cache = _themeCache.get(theme);
2536
+ if (!cache) {
2537
+ cache = new LRUCache(1e4);
2538
+ _themeCache.set(theme, cache);
2539
+ }
2540
+ return cache;
2541
+ }
2542
+ var _sortCache = /* @__PURE__ */ new WeakMap();
2543
+ function getSortedEntries(resolved) {
2544
+ let sorted = _sortCache.get(resolved);
2545
+ if (!sorted) {
2546
+ const entries = Object.entries(resolved);
2547
+ entries.sort((a, b) => {
2548
+ const pa = a[0] === "base" ? -1 : a[0].split(":").length;
2549
+ const pb = b[0] === "base" ? -1 : b[0].split(":").length;
2550
+ return pa - pb;
2551
+ });
2552
+ sorted = entries;
2553
+ _sortCache.set(resolved, sorted);
2554
+ }
2555
+ return sorted;
2556
+ }
3060
2557
  var FONT_KEY = "__kbach_default_font__";
3061
2558
  function setDefaultFontFamily(font) {
3062
2559
  globalThis[FONT_KEY] = font;
@@ -3065,7 +2562,7 @@ function getDefaultFontFamily() {
3065
2562
  return globalThis[FONT_KEY];
3066
2563
  }
3067
2564
  var _styleEl = null;
3068
- var _injectedRules = /* @__PURE__ */ new Set();
2565
+ var _injectedRules = new LRUCache(5e4);
3069
2566
  function getStyleEl() {
3070
2567
  if (_styleEl) return _styleEl;
3071
2568
  _styleEl = document.createElement("style");
@@ -3075,7 +2572,7 @@ function getStyleEl() {
3075
2572
  }
3076
2573
  function injectRule(rule) {
3077
2574
  if (_injectedRules.has(rule)) return;
3078
- _injectedRules.add(rule);
2575
+ _injectedRules.set(rule, true);
3079
2576
  try {
3080
2577
  getStyleEl().sheet?.insertRule(rule, getStyleEl().sheet.cssRules.length);
3081
2578
  } catch {
@@ -3099,150 +2596,20 @@ function injectGlobalStyles(theme) {
3099
2596
  }
3100
2597
  getGlobalStyleEl().textContent = rules.join("\n");
3101
2598
  }
3102
- var MODIFIER_TO_PSEUDO = {
3103
- hover: ":hover",
3104
- focus: ":focus",
3105
- "focus-within": ":focus-within",
3106
- "focus-visible": ":focus-visible",
3107
- active: ":active",
3108
- pressed: ":active",
3109
- disabled: ":disabled",
3110
- checked: ":checked",
3111
- visited: ":visited",
3112
- placeholder: "::placeholder",
3113
- first: ":first-child",
3114
- last: ":last-child",
3115
- odd: ":nth-child(odd)",
3116
- even: ":nth-child(even)",
3117
- only: ":only-child",
3118
- "not-hover": ":not(:hover)",
3119
- "not-focus": ":not(:focus)",
3120
- "not-active": ":not(:active)",
3121
- "not-pressed": ":not(:active)",
3122
- "not-disabled": ":not(:disabled)",
3123
- "not-checked": ":not(:checked)",
3124
- "not-visited": ":not(:visited)",
3125
- // Pseudo-elements (CSS-injection only; never applied as inline styles)
3126
- before: "::before",
3127
- after: "::after",
3128
- selection: "::selection",
3129
- "first-letter": "::first-letter",
3130
- "first-line": "::first-line",
3131
- marker: "::marker"
3132
- };
3133
- var GROUP_PEER_PREFIX = {
3134
- "group-hover": ".group:hover",
3135
- "group-focus": ".group:focus",
3136
- "peer-hover": ".peer:hover ~",
3137
- "peer-focus": ".peer:focus ~"
3138
- };
3139
- var MODE_MODS = /* @__PURE__ */ new Set(["dark", "light", "not-dark", "not-light"]);
3140
- var RESPONSIVE_MODS = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
3141
- var PRINT_MODS = /* @__PURE__ */ new Set(["print"]);
3142
- var MEDIA_MODS = {
3143
- landscape: "(orientation: landscape)",
3144
- portrait: "(orientation: portrait)",
3145
- "motion-reduce": "(prefers-reduced-motion: reduce)",
3146
- "motion-safe": "(prefers-reduced-motion: no-preference)",
3147
- "contrast-more": "(prefers-contrast: more)",
3148
- "contrast-less": "(prefers-contrast: less)"
3149
- };
3150
- var DIR_MODS = {
3151
- rtl: '[dir="rtl"]',
3152
- ltr: '[dir="ltr"]'
3153
- };
3154
2599
  function buildDivideDecls(styles) {
3155
2600
  const parts = [];
3156
2601
  if ("__divideX" in styles) {
3157
2602
  const w = Number(styles.__divideX);
3158
- parts.push(`border-left-width: ${w}px`);
3159
- parts.push("border-right-width: 0px");
2603
+ parts.push(`border-left-width: ${w}px`, "border-right-width: 0px");
3160
2604
  }
3161
2605
  if ("__divideY" in styles) {
3162
2606
  const w = Number(styles.__divideY);
3163
- parts.push(`border-top-width: ${w}px`);
3164
- parts.push("border-bottom-width: 0px");
2607
+ parts.push(`border-top-width: ${w}px`, "border-bottom-width: 0px");
3165
2608
  }
3166
2609
  if ("__divideColor" in styles) parts.push(`border-color: ${String(styles.__divideColor)}`);
3167
2610
  if ("__divideStyle" in styles) parts.push(`border-style: ${String(styles.__divideStyle)}`);
3168
2611
  return parts.join("; ");
3169
2612
  }
3170
- function buildClassCSSRules(cls, bucketKey, styles, darkMode, important, screens) {
3171
- const rules = [];
3172
- if ("__keyframe" in styles && typeof styles.__keyframe === "string") {
3173
- rules.push(styles.__keyframe);
3174
- }
3175
- const isDivide = "__divideX" in styles || "__divideY" in styles || "__divideColor" in styles || "__divideStyle" in styles;
3176
- const escaped = escapeCSSSelector(cls);
3177
- const childSuffix = isDivide ? " > * + *" : "";
3178
- if (bucketKey === "base") {
3179
- const baseCssDecls = isDivide ? buildDivideDecls(styles) : styleValueToCSS(styles, important);
3180
- if (!baseCssDecls) return rules;
3181
- rules.push(`.${escaped}${childSuffix} { ${baseCssDecls} }`);
3182
- return rules;
3183
- }
3184
- const mods = bucketKey.split(":");
3185
- const responsiveMods = mods.filter((m) => RESPONSIVE_MODS.has(m));
3186
- const nonResponsiveMods = mods.filter((m) => !RESPONSIVE_MODS.has(m));
3187
- const hasDark = nonResponsiveMods.includes("dark") || nonResponsiveMods.includes("not-light");
3188
- const hasLight = nonResponsiveMods.includes("light") || nonResponsiveMods.includes("not-dark");
3189
- const hasPrint = nonResponsiveMods.includes("print");
3190
- const mediaMods = nonResponsiveMods.filter((m) => m in MEDIA_MODS);
3191
- const dirMods = nonResponsiveMods.filter((m) => m in DIR_MODS);
3192
- const ancestorMods = nonResponsiveMods.filter((m) => m in GROUP_PEER_PREFIX);
3193
- const pseudoMods = nonResponsiveMods.filter(
3194
- (m) => !MODE_MODS.has(m) && !(m in GROUP_PEER_PREFIX) && !PRINT_MODS.has(m) && !(m in MEDIA_MODS) && !(m in DIR_MODS)
3195
- );
3196
- const pseudoSuffix = pseudoMods.map((p) => MODIFIER_TO_PSEUDO[p] ?? `:${p}`).join("");
3197
- const elementSelector = `.${escaped}${pseudoSuffix}${childSuffix}`;
3198
- const ancestorPrefix = ancestorMods.length ? ancestorMods.map((m) => GROUP_PEER_PREFIX[m]).join(" ") + " " : "";
3199
- const dirPrefix = dirMods.length ? dirMods.map((m) => DIR_MODS[m]).join(" ") + " " : "";
3200
- const selector = `${dirPrefix}${ancestorPrefix}${elementSelector}`;
3201
- const CSS_ONLY_PSEUDOS = /* @__PURE__ */ new Set([
3202
- "first",
3203
- "last",
3204
- "odd",
3205
- "even",
3206
- "only",
3207
- "focus-within",
3208
- "focus-visible"
3209
- ]);
3210
- const needsImportant = important || hasPrint || mediaMods.length > 0 || dirMods.length > 0 || ancestorMods.length > 0 || pseudoMods.some((m) => CSS_ONLY_PSEUDOS.has(m));
3211
- const cssDecls = isDivide ? buildDivideDecls(styles) : styleValueToCSS(styles, needsImportant);
3212
- if (!cssDecls) return rules;
3213
- let rule;
3214
- if (hasDark) {
3215
- if (darkMode === "media") {
3216
- rule = `@media (prefers-color-scheme: dark) { ${selector} { ${cssDecls} } }`;
3217
- } else if (darkMode === "class") {
3218
- rule = `.dark ${selector} { ${cssDecls} }`;
3219
- } else {
3220
- rule = `[data-theme="dark"] ${selector} { ${cssDecls} }`;
3221
- }
3222
- } else if (hasLight) {
3223
- if (darkMode === "media") {
3224
- rule = `@media (prefers-color-scheme: light) { ${selector} { ${cssDecls} } }`;
3225
- } else if (darkMode === "class") {
3226
- rule = `:not(.dark) ${selector} { ${cssDecls} }`;
3227
- } else {
3228
- rule = `[data-theme="light"] ${selector} { ${cssDecls} }`;
3229
- }
3230
- } else {
3231
- rule = `${selector} { ${cssDecls} }`;
3232
- }
3233
- if (hasPrint) rule = `@media print { ${rule} }`;
3234
- for (const m of mediaMods) rule = `@media ${MEDIA_MODS[m]} { ${rule} }`;
3235
- if (responsiveMods.length > 0) {
3236
- const minWidth = Math.max(...responsiveMods.map((m) => screens[m] ?? 0));
3237
- if (minWidth > 0) rule = `@media (min-width: ${minWidth}px) { ${rule} }`;
3238
- }
3239
- rules.push(rule);
3240
- return rules;
3241
- }
3242
- function injectClassRule(cls, bucketKey, styles, darkMode, important = false) {
3243
- const cssRules = buildClassCSSRules(cls, bucketKey, styles, darkMode, important, getGlobalScreens());
3244
- for (const r of cssRules) injectRule(r);
3245
- }
3246
2613
  var RN_ONLY_PROPS = /* @__PURE__ */ new Set([
3247
2614
  "shadowColor",
3248
2615
  "shadowOffset",
@@ -3252,13 +2619,10 @@ var RN_ONLY_PROPS = /* @__PURE__ */ new Set([
3252
2619
  "includeFontPadding",
3253
2620
  "textAlignVertical",
3254
2621
  "writingDirection",
3255
- // Text shadow native props — web uses the textShadow CSS shorthand instead
3256
2622
  "textShadowColor",
3257
2623
  "textShadowOffset",
3258
2624
  "textShadowRadius",
3259
- // tintColor is native-only (Image/icon tinting)
3260
2625
  "tintColor",
3261
- // Internal markers — handled specially, never serialized as CSS props
3262
2626
  "__divideX",
3263
2627
  "__divideY",
3264
2628
  "__divideColor",
@@ -3300,8 +2664,7 @@ function styleValueToCSS(styles, forceImportant = false) {
3300
2664
  const imp = forceImportant || prop === "display" && (cssVal === "grid" || cssVal === "inline-grid") || prop === "position" && (cssVal === "sticky" || cssVal === "fixed" || cssVal === "static") ? " !important" : "";
3301
2665
  if (prop in RN_SHORTHAND_EXPAND) {
3302
2666
  const [p1, p2] = RN_SHORTHAND_EXPAND[prop];
3303
- parts.push(`${p1}: ${cssVal}${imp}`);
3304
- parts.push(`${p2}: ${cssVal}${imp}`);
2667
+ parts.push(`${p1}: ${cssVal}${imp}`, `${p2}: ${cssVal}${imp}`);
3305
2668
  continue;
3306
2669
  }
3307
2670
  parts.push(`${camelToKebab(prop)}: ${cssVal}${imp}`);
@@ -3311,14 +2674,87 @@ function styleValueToCSS(styles, forceImportant = false) {
3311
2674
  function camelToKebab(str) {
3312
2675
  return str.replace(/([A-Z])/g, "-$1").toLowerCase();
3313
2676
  }
2677
+ function buildClassCSSRules(cls, bucketKey, styles, darkMode, important, screens) {
2678
+ const rules = [];
2679
+ if ("__keyframe" in styles && typeof styles.__keyframe === "string") {
2680
+ rules.push(styles.__keyframe);
2681
+ }
2682
+ const isDivide = "__divideX" in styles || "__divideY" in styles || "__divideColor" in styles || "__divideStyle" in styles;
2683
+ const escaped = escapeCSSSelector(cls);
2684
+ const childSuffix = isDivide ? " > * + *" : "";
2685
+ if (bucketKey === "base") {
2686
+ const decls2 = isDivide ? buildDivideDecls(styles) : styleValueToCSS(styles, important);
2687
+ if (!decls2) return rules;
2688
+ rules.push(`.${escaped}${childSuffix} { ${decls2} }`);
2689
+ return rules;
2690
+ }
2691
+ const mods = bucketKey.split(":");
2692
+ let darkScheme;
2693
+ let needsImportant = important;
2694
+ const pseudoParts = [];
2695
+ const ancestorParts = [];
2696
+ const dirParts = [];
2697
+ const mediaWrappers = [];
2698
+ let minWidth = 0;
2699
+ for (const mod of mods) {
2700
+ const def = getModifier(mod);
2701
+ if (!def) continue;
2702
+ if (def.darkScheme) darkScheme = def.darkScheme;
2703
+ if (def.pseudo) pseudoParts.push(def.pseudo);
2704
+ if (def.ancestorSelector) {
2705
+ ancestorParts.push(def.ancestorSelector);
2706
+ needsImportant = true;
2707
+ }
2708
+ if (def.dirSelector) {
2709
+ dirParts.push(def.dirSelector);
2710
+ needsImportant = true;
2711
+ }
2712
+ if (def.mediaQuery) {
2713
+ mediaWrappers.push(`@media ${def.mediaQuery}`);
2714
+ needsImportant = true;
2715
+ }
2716
+ if (def.isResponsive) {
2717
+ const w = screens[mod] ?? 0;
2718
+ if (w > minWidth) minWidth = w;
2719
+ }
2720
+ if (def.forcesImportant) needsImportant = true;
2721
+ }
2722
+ const pseudoSuffix = pseudoParts.join("");
2723
+ const elementSelector = `.${escaped}${pseudoSuffix}${childSuffix}`;
2724
+ const ancestorPrefix = ancestorParts.join("");
2725
+ const dirPrefix = dirParts.join("");
2726
+ const selector = `${dirPrefix}${ancestorPrefix}${elementSelector}`;
2727
+ const decls = isDivide ? buildDivideDecls(styles) : styleValueToCSS(styles, needsImportant);
2728
+ if (!decls) return rules;
2729
+ let rule;
2730
+ if (darkScheme === "dark") {
2731
+ if (darkMode === "media") rule = `@media (prefers-color-scheme: dark) { ${selector} { ${decls} } }`;
2732
+ else if (darkMode === "class") rule = `.dark ${selector} { ${decls} }`;
2733
+ else rule = `[data-theme="dark"] ${selector} { ${decls} }`;
2734
+ } else if (darkScheme === "light") {
2735
+ if (darkMode === "media") rule = `@media (prefers-color-scheme: light) { ${selector} { ${decls} } }`;
2736
+ else if (darkMode === "class") rule = `:not(.dark) ${selector} { ${decls} }`;
2737
+ else rule = `[data-theme="light"] ${selector} { ${decls} }`;
2738
+ } else {
2739
+ rule = `${selector} { ${decls} }`;
2740
+ }
2741
+ for (const mw of mediaWrappers) rule = `${mw} { ${rule} }`;
2742
+ if (minWidth > 0) rule = `@media (min-width: ${minWidth}px) { ${rule} }`;
2743
+ rules.push(rule);
2744
+ return rules;
2745
+ }
2746
+ function injectClassRule(cls, bucketKey, styles, darkMode, important) {
2747
+ const cssRules = buildClassCSSRules(cls, bucketKey, styles, darkMode, important, getGlobalScreens());
2748
+ for (const r of cssRules) injectRule(r);
2749
+ }
3314
2750
  function resolve(classString, theme, darkMode = "attribute") {
2751
+ const cache = getThemeCache(theme);
3315
2752
  const cacheKey = `${classString}::${darkMode}`;
3316
- const cached = styleCache.get(cacheKey);
2753
+ const cached = cache.get(cacheKey);
3317
2754
  if (cached) return cached;
3318
2755
  const result = {};
3319
- const parsedClasses = parseClasses(classString);
3320
- const injectQueue = [];
3321
- for (const parsed of parsedClasses) {
2756
+ const onWeb = typeof document !== "undefined";
2757
+ for (const parsed of parseClasses(classString)) {
3322
2758
  const styles = resolveUtility(parsed, theme);
3323
2759
  if (!styles) {
3324
2760
  if (process.env.NODE_ENV !== "production" && !parsed.isArbitrary && !isKnownUtility(parsed.utility)) {
@@ -3329,130 +2765,59 @@ function resolve(classString, theme, darkMode = "attribute") {
3329
2765
  const bucketKey = parsed.modifiers.length === 0 ? "base" : parsed.modifiers.join(":");
3330
2766
  if (!result[bucketKey]) result[bucketKey] = {};
3331
2767
  Object.assign(result[bucketKey], styles);
3332
- if (typeof document !== "undefined") {
3333
- injectQueue.push({ cls: parsed.original, bucketKey, styles, important: parsed.important });
3334
- }
3335
- }
3336
- styleCache.set(cacheKey, result);
3337
- if (typeof document !== "undefined") {
3338
- for (const { cls, bucketKey, styles, important } of injectQueue) {
3339
- injectClassRule(cls, bucketKey, styles, darkMode, important);
2768
+ if (onWeb) {
2769
+ injectClassRule(parsed.original, bucketKey, styles, darkMode, parsed.important);
3340
2770
  }
3341
2771
  }
2772
+ cache.set(cacheKey, result);
3342
2773
  return result;
3343
2774
  }
3344
2775
  function flatten(resolved, isDark, state = {}, breakpoints = /* @__PURE__ */ new Set()) {
3345
2776
  const result = {};
3346
- const entries = Object.entries(resolved);
3347
- entries.sort((a, b) => {
3348
- const pa = a[0] === "base" ? -1 : a[0].split(":").length;
3349
- const pb = b[0] === "base" ? -1 : b[0].split(":").length;
3350
- return pa - pb;
3351
- });
3352
- for (const [key, styles] of entries) {
2777
+ for (const [key, styles] of getSortedEntries(resolved)) {
3353
2778
  if (!styles) continue;
3354
2779
  if (key === "base") {
3355
2780
  Object.assign(result, styles);
3356
2781
  continue;
3357
2782
  }
3358
2783
  const mods = key.split(":");
3359
- if (matchesMods(mods, isDark, state, breakpoints)) {
2784
+ if (mods.every((mod) => matchModifier(mod, isDark, state, breakpoints))) {
3360
2785
  Object.assign(result, styles);
3361
2786
  }
3362
2787
  }
3363
- const _df = getDefaultFontFamily();
3364
- if (_df && !("fontFamily" in result)) {
3365
- result.fontFamily = _df;
2788
+ const defaultFont = getDefaultFontFamily();
2789
+ if (defaultFont && !("fontFamily" in result)) {
2790
+ result.fontFamily = defaultFont;
3366
2791
  }
3367
2792
  if (isWeb) {
3368
2793
  const r = result;
3369
- const v0 = r.paddingHorizontal;
3370
- if (v0 !== void 0) {
3371
- r.paddingLeft = v0;
3372
- r.paddingRight = v0;
2794
+ const ph = r.paddingHorizontal;
2795
+ if (ph !== void 0) {
2796
+ r.paddingLeft = ph;
2797
+ r.paddingRight = ph;
3373
2798
  delete r.paddingHorizontal;
3374
2799
  }
3375
- const v1 = r.paddingVertical;
3376
- if (v1 !== void 0) {
3377
- r.paddingTop = v1;
3378
- r.paddingBottom = v1;
2800
+ const pv = r.paddingVertical;
2801
+ if (pv !== void 0) {
2802
+ r.paddingTop = pv;
2803
+ r.paddingBottom = pv;
3379
2804
  delete r.paddingVertical;
3380
2805
  }
3381
- const v2 = r.marginHorizontal;
3382
- if (v2 !== void 0) {
3383
- r.marginLeft = v2;
3384
- r.marginRight = v2;
2806
+ const mh = r.marginHorizontal;
2807
+ if (mh !== void 0) {
2808
+ r.marginLeft = mh;
2809
+ r.marginRight = mh;
3385
2810
  delete r.marginHorizontal;
3386
2811
  }
3387
- const v3 = r.marginVertical;
3388
- if (v3 !== void 0) {
3389
- r.marginTop = v3;
3390
- r.marginBottom = v3;
2812
+ const mv = r.marginVertical;
2813
+ if (mv !== void 0) {
2814
+ r.marginTop = mv;
2815
+ r.marginBottom = mv;
3391
2816
  delete r.marginVertical;
3392
2817
  }
3393
2818
  }
3394
2819
  return result;
3395
2820
  }
3396
- function matchesMods(mods, isDark, state, breakpoints) {
3397
- return mods.every((mod) => {
3398
- switch (mod) {
3399
- case "dark":
3400
- return isDark;
3401
- case "light":
3402
- case "not-dark":
3403
- return !isDark;
3404
- case "not-light":
3405
- return isDark;
3406
- case "hover":
3407
- return !!state.hover;
3408
- case "not-hover":
3409
- return !state.hover;
3410
- case "focus":
3411
- return !!state.focus;
3412
- case "not-focus":
3413
- return !state.focus;
3414
- case "pressed":
3415
- case "active":
3416
- return !!state.pressed || !!state.active;
3417
- case "not-pressed":
3418
- case "not-active":
3419
- return !state.pressed && !state.active;
3420
- case "disabled":
3421
- return !!state.disabled;
3422
- case "not-disabled":
3423
- return !state.disabled;
3424
- case "checked":
3425
- return !!state.checked;
3426
- case "not-checked":
3427
- return !state.checked;
3428
- case "visited":
3429
- return !!state.visited;
3430
- case "not-visited":
3431
- return !state.visited;
3432
- case "placeholder":
3433
- return !!state.placeholder;
3434
- case "sm":
3435
- case "md":
3436
- case "lg":
3437
- case "xl":
3438
- case "2xl":
3439
- return breakpoints.has(mod);
3440
- // CSS-only modifiers — never applied as inline styles
3441
- case "print":
3442
- case "landscape":
3443
- case "portrait":
3444
- case "motion-reduce":
3445
- case "motion-safe":
3446
- case "contrast-more":
3447
- case "contrast-less":
3448
- case "rtl":
3449
- case "ltr":
3450
- return false;
3451
- default:
3452
- return false;
3453
- }
3454
- });
3455
- }
3456
2821
 
3457
2822
  // src/core/config.ts
3458
2823
  function deepMerge(base, override) {
@@ -3493,14 +2858,24 @@ function resolveOneRef(ref, colors) {
3493
2858
  return entry[m[2]] ?? null;
3494
2859
  }
3495
2860
  function resolveColorRefs(colors) {
2861
+ const MAX_DEPTH = 5;
2862
+ function resolveChain(raw) {
2863
+ let current = raw;
2864
+ for (let i = 0; i < MAX_DEPTH; i++) {
2865
+ const next = resolveOneRef(current, colors);
2866
+ if (!next || next === current) break;
2867
+ current = next;
2868
+ }
2869
+ return current;
2870
+ }
3496
2871
  const out = {};
3497
2872
  for (const [key, val] of Object.entries(colors)) {
3498
2873
  if (typeof val === "string") {
3499
- out[key] = resolveOneRef(val, colors) ?? val;
2874
+ out[key] = resolveChain(val);
3500
2875
  } else {
3501
2876
  const shades = {};
3502
2877
  for (const [shade, hex] of Object.entries(val)) {
3503
- shades[shade] = resolveOneRef(hex, colors) ?? hex;
2878
+ shades[shade] = resolveChain(hex);
3504
2879
  }
3505
2880
  out[key] = shades;
3506
2881
  }
@@ -3548,15 +2923,26 @@ function buildConfig(userConfig) {
3548
2923
  injectGlobalStyles(resolved.theme);
3549
2924
  return resolved;
3550
2925
  }
2926
+ function _selectorToModifierDef(selector) {
2927
+ const s = selector.trim();
2928
+ if (s.startsWith("@media ")) {
2929
+ return { mediaQuery: s.slice(7), jsBehavior: "css-only", forcesImportant: true };
2930
+ }
2931
+ if (s.startsWith("::") || s.startsWith(":")) {
2932
+ return { pseudo: s, jsBehavior: "css-only", forcesImportant: true };
2933
+ }
2934
+ return { ancestorSelector: s.endsWith(" ") ? s : `${s} `, jsBehavior: "css-only", forcesImportant: true };
2935
+ }
3551
2936
  function makePluginAPI(theme) {
3552
2937
  const standalone = getPluginStandaloneMap();
3553
2938
  return {
3554
2939
  addUtility(name, styles) {
3555
2940
  standalone[name] = styles;
3556
2941
  },
3557
- addVariant(name, selector) {
3558
- customVariants[name] = selector;
3559
- registerModifier(name);
2942
+ addVariant(name, selectorOrDef) {
2943
+ const def = typeof selectorOrDef === "string" ? _selectorToModifierDef(selectorOrDef) : selectorOrDef;
2944
+ customVariants[name] = typeof selectorOrDef === "string" ? selectorOrDef : name;
2945
+ registerModifier(name, def);
3560
2946
  },
3561
2947
  theme(path, defaultValue) {
3562
2948
  const parts = path.replace(/\[([^\]]+)\]/g, ".$1").split(".");
@@ -3677,23 +3063,26 @@ function useConditionalWidth(active) {
3677
3063
  );
3678
3064
  }
3679
3065
 
3680
- // src/InteractiveWrapper.tsx
3681
- function chain(original, extra) {
3682
- return (...args) => {
3683
- original?.(...args);
3684
- extra();
3685
- };
3686
- }
3687
- var RESPONSIVE_MODS2 = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
3066
+ // src/shared-utils.ts
3688
3067
  function hasResponsiveBuckets(resolved) {
3068
+ const responsiveMods = getResponsiveModifiers();
3689
3069
  for (const key of Object.keys(resolved)) {
3690
3070
  if (key === "base") continue;
3691
3071
  for (const mod of key.split(":")) {
3692
- if (RESPONSIVE_MODS2.has(mod)) return true;
3072
+ if (responsiveMods.has(mod)) return true;
3693
3073
  }
3694
3074
  }
3695
3075
  return false;
3696
3076
  }
3077
+ var EMPTY_BREAKPOINTS2 = /* @__PURE__ */ new Set();
3078
+
3079
+ // src/InteractiveWrapper.tsx
3080
+ function chain(original, extra) {
3081
+ return (...args) => {
3082
+ original?.(...args);
3083
+ extra();
3084
+ };
3085
+ }
3697
3086
  var InteractiveWrapper = (0, import_react3.forwardRef)(
3698
3087
  function InteractiveWrapper2({
3699
3088
  Component,
@@ -3785,22 +3174,12 @@ InteractiveWrapper.displayName = "Kbach.InteractiveWrapper";
3785
3174
 
3786
3175
  // src/DarkWrapper.tsx
3787
3176
  var import_react4 = __toESM(require("react"));
3788
- var RESPONSIVE_MODS3 = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
3789
- function hasResponsiveBuckets2(resolved) {
3790
- for (const key of Object.keys(resolved)) {
3791
- if (key === "base") continue;
3792
- for (const mod of key.split(":")) {
3793
- if (RESPONSIVE_MODS3.has(mod)) return true;
3794
- }
3795
- }
3796
- return false;
3797
- }
3798
3177
  var DarkWrapper = import_react4.default.forwardRef(
3799
3178
  function DarkWrapper2({ Component, resolvedStyle, style: styleProp, children, ...rest }, ref) {
3800
3179
  const isDark = useGlobalDarkMode();
3801
- const needsWidth = hasResponsiveBuckets2(resolvedStyle);
3180
+ const needsWidth = hasResponsiveBuckets(resolvedStyle);
3802
3181
  const width = useConditionalWidth(needsWidth);
3803
- const breakpoints = needsWidth ? getActiveBreakpoints(width) : EMPTY_BREAKPOINTS;
3182
+ const breakpoints = needsWidth ? getActiveBreakpoints(width) : EMPTY_BREAKPOINTS2;
3804
3183
  const computedStyle = flatten(resolvedStyle, isDark, {}, breakpoints);
3805
3184
  stripInternalMarkers(computedStyle);
3806
3185
  if (typeof Component !== "string") stripWebOnlyProps(computedStyle);
@@ -3842,51 +3221,39 @@ function stripWebOnlyProps(s) {
3842
3221
  }
3843
3222
 
3844
3223
  // src/jsx-runtime.tsx
3845
- var INTERACTIVE_MODS = /* @__PURE__ */ new Set([
3846
- "hover",
3847
- "not-hover",
3848
- "focus",
3849
- "not-focus",
3850
- "active",
3851
- "not-active",
3852
- "pressed",
3853
- "not-pressed",
3854
- "disabled",
3855
- "not-disabled",
3856
- "checked",
3857
- "not-checked",
3858
- "visited",
3859
- "not-visited",
3860
- "placeholder",
3861
- "group-hover",
3862
- "group-focus",
3863
- "peer-hover",
3864
- "peer-focus"
3865
- // focus-within / focus-visible / first / last / odd / even / only are CSS-only —
3866
- // they have no JS state to track, so they don't need InteractiveWrapper.
3867
- ]);
3868
- var RESPONSIVE_MODS4 = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
3869
- var MODE_MODS_JSX = /* @__PURE__ */ new Set(["dark", "light", "not-dark", "not-light"]);
3224
+ var _cachedDefaultFont = void 0;
3225
+ var _defaultFontVersion = 0;
3226
+ var _lastFontVersion = -1;
3227
+ function _invalidateDefaultFontCache() {
3228
+ _defaultFontVersion++;
3229
+ }
3230
+ function getCachedDefaultFont() {
3231
+ if (_lastFontVersion !== _defaultFontVersion) {
3232
+ _cachedDefaultFont = getDefaultFontFamily();
3233
+ _lastFontVersion = _defaultFontVersion;
3234
+ }
3235
+ return _cachedDefaultFont;
3236
+ }
3237
+ var _bucketModsCache = /* @__PURE__ */ new WeakMap();
3870
3238
  function bucketMods(resolved) {
3239
+ const cached = _bucketModsCache.get(resolved);
3240
+ if (cached) return cached;
3241
+ const interactiveMods = getInteractiveModifiers();
3242
+ const modeMods = getModeModifiers();
3243
+ const responsiveMods = getResponsiveModifiers();
3871
3244
  let interactive = false;
3872
3245
  let modeOrResponsive = false;
3873
3246
  for (const key of Object.keys(resolved)) {
3874
3247
  if (key === "base") continue;
3875
- const parts = key.split(":");
3876
- for (const mod of parts) {
3877
- if (INTERACTIVE_MODS.has(mod)) {
3878
- interactive = true;
3879
- break;
3880
- }
3881
- }
3882
- for (const mod of parts) {
3883
- if (MODE_MODS_JSX.has(mod) || RESPONSIVE_MODS4.has(mod)) {
3884
- modeOrResponsive = true;
3885
- break;
3886
- }
3248
+ for (const mod of key.split(":")) {
3249
+ if (!interactive && interactiveMods.has(mod)) interactive = true;
3250
+ if (!modeOrResponsive && (modeMods.has(mod) || responsiveMods.has(mod))) modeOrResponsive = true;
3887
3251
  }
3252
+ if (interactive && modeOrResponsive) break;
3888
3253
  }
3889
- return { interactive, modeOrResponsive };
3254
+ const result = { interactive, modeOrResponsive };
3255
+ _bucketModsCache.set(resolved, result);
3256
+ return result;
3890
3257
  }
3891
3258
  var CONSUMED_PROPS = /* @__PURE__ */ new Set(["className", "kb", "__kbachStyles", "__kbachClasses"]);
3892
3259
  function omitConsumed(props) {
@@ -3961,10 +3328,8 @@ function processElement(type, rawProps, key, isStaticChildren) {
3961
3328
  const { className, kb: kbProp, __kbachStyles, __kbachClasses } = rawProps;
3962
3329
  const classStr = className ?? kbProp ?? __kbachClasses;
3963
3330
  if (!classStr && !__kbachStyles) {
3964
- const defaultFont = getDefaultFontFamily();
3965
- if (!defaultFont) {
3966
- return makeElement(isStaticChildren, type, rawProps, key);
3967
- }
3331
+ const defaultFont = getCachedDefaultFont();
3332
+ if (!defaultFont) return makeElement(isStaticChildren, type, rawProps, key);
3968
3333
  const { style: userStyle2, ...passProps2 } = omitConsumed(rawProps);
3969
3334
  const finalStyle2 = userStyle2 ? Array.isArray(userStyle2) ? { fontFamily: defaultFont, ...Object.assign({}, ...userStyle2) } : { fontFamily: defaultFont, ...userStyle2 } : { fontFamily: defaultFont };
3970
3335
  return makeElement(isStaticChildren, type, { ...passProps2, style: finalStyle2 }, key);
@@ -4013,6 +3378,7 @@ function jsxs(type, props, key) {
4013
3378
  // Annotate the CommonJS export names for ESM import in node:
4014
3379
  0 && (module.exports = {
4015
3380
  Fragment,
3381
+ _invalidateDefaultFontCache,
4016
3382
  jsx,
4017
3383
  jsxs
4018
3384
  });