@kbach/react 0.6.0 → 0.6.2

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.
@@ -40,12 +40,13 @@ var import_node_process = __toESM(require("process"));
40
40
  // src/core/platform.ts
41
41
  var isWeb = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
42
42
  var isNative = !isWeb && (typeof globalThis.HermesInternal !== "undefined" || typeof globalThis.__fbBatchedBridge !== "undefined" || typeof navigator !== "undefined" && navigator.product === "ReactNative" || typeof globalThis.__REACT_NATIVE__ !== "undefined");
43
- var _cssGenMode = false;
43
+ var _resolveTargetOverride = null;
44
44
  function setCSSGenMode(on) {
45
- _cssGenMode = on;
45
+ _resolveTargetOverride = on ? "web" : null;
46
46
  }
47
47
  function getEffectiveIsWeb() {
48
- return isWeb || _cssGenMode || !isNative;
48
+ if (_resolveTargetOverride) return _resolveTargetOverride === "web";
49
+ return isWeb || !isNative;
49
50
  }
50
51
  function toNativeValue(raw) {
51
52
  if (/^-?\d+(\.\d+)?px$/.test(raw)) return parseFloat(raw);
@@ -673,18 +674,28 @@ function resolveColor(value, colors, isArbitrary) {
673
674
  if (isNaN(alpha)) return hex;
674
675
  return hexToRgba(hex, alpha);
675
676
  }
676
- function hexToRgba(hex, alpha) {
677
+ function parseHexRgb(hex) {
677
678
  const h = hex.replace("#", "");
678
- let r, g, b;
679
- if (h.length === 3) {
680
- r = parseInt(h[0] + h[0], 16);
681
- g = parseInt(h[1] + h[1], 16);
682
- b = parseInt(h[2] + h[2], 16);
683
- } else {
684
- r = parseInt(h.slice(0, 2), 16);
685
- g = parseInt(h.slice(2, 4), 16);
686
- b = parseInt(h.slice(4, 6), 16);
679
+ if (h.length === 3 || h.length === 4) {
680
+ return [
681
+ parseInt(h[0] + h[0], 16),
682
+ parseInt(h[1] + h[1], 16),
683
+ parseInt(h[2] + h[2], 16)
684
+ ];
687
685
  }
686
+ if (h.length === 6 || h.length === 8) {
687
+ return [
688
+ parseInt(h.slice(0, 2), 16),
689
+ parseInt(h.slice(2, 4), 16),
690
+ parseInt(h.slice(4, 6), 16)
691
+ ];
692
+ }
693
+ return null;
694
+ }
695
+ function hexToRgba(hex, alpha) {
696
+ const rgb = parseHexRgb(hex);
697
+ if (!rgb) return hex;
698
+ const [r, g, b] = rgb;
688
699
  return `rgba(${r},${g},${b},${alpha})`;
689
700
  }
690
701
  function resolveSpacing(value, negative, spacing, isArbitrary) {
@@ -728,8 +739,8 @@ function resolveFontSize(value, fontSizes, isArbitrary) {
728
739
  if (isArbitrary) return getEffectiveIsWeb() ? value : toNativeValue(value);
729
740
  return fontSizes[value] ?? null;
730
741
  }
731
- var FILTER_COMPOSE = "var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)";
732
- var BACKDROP_FILTER_COMPOSE = "var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,)";
742
+ var FILTER_COMPOSE = "var(--kb-blur,) var(--kb-brightness,) var(--kb-contrast,) var(--kb-grayscale,) var(--kb-hue-rotate,) var(--kb-invert,) var(--kb-saturate,) var(--kb-sepia,) var(--kb-drop-shadow,)";
743
+ var BACKDROP_FILTER_COMPOSE = "var(--kb-backdrop-blur,) var(--kb-backdrop-brightness,) var(--kb-backdrop-contrast,) var(--kb-backdrop-grayscale,) var(--kb-backdrop-hue-rotate,) var(--kb-backdrop-invert,) var(--kb-backdrop-opacity,) var(--kb-backdrop-saturate,) var(--kb-backdrop-sepia,)";
733
744
  var _standalone = null;
734
745
  function buildStandalone() {
735
746
  const web = getEffectiveIsWeb();
@@ -991,9 +1002,9 @@ function buildStandalone() {
991
1002
  "backface-visible": { backfaceVisibility: "visible" },
992
1003
  "backface-hidden": { backfaceVisibility: "hidden" },
993
1004
  // CSS filters — standalone = default/full effect (web-only)
994
- grayscale: web ? { "--tw-grayscale": "grayscale(100%)", filter: FILTER_COMPOSE } : null,
995
- invert: web ? { "--tw-invert": "invert(100%)", filter: FILTER_COMPOSE } : null,
996
- sepia: web ? { "--tw-sepia": "sepia(100%)", filter: FILTER_COMPOSE } : null,
1005
+ grayscale: web ? { "--kb-grayscale": "grayscale(100%)", filter: FILTER_COMPOSE } : null,
1006
+ invert: web ? { "--kb-invert": "invert(100%)", filter: FILTER_COMPOSE } : null,
1007
+ sepia: web ? { "--kb-sepia": "sepia(100%)", filter: FILTER_COMPOSE } : null,
997
1008
  // Divide none
998
1009
  "divide-none": web ? { __divideX: 0, __divideY: 0 } : null,
999
1010
  // Group / peer markers (no-op: no style emitted; just ensures isKnownUtility returns true)
@@ -1078,6 +1089,48 @@ function getStandalone() {
1078
1089
  if (!_standalone) _standalone = buildStandalone();
1079
1090
  return _standalone;
1080
1091
  }
1092
+ function makeSpacingResolver(prop) {
1093
+ return ({ value, negative, isArbitrary }, { spacing }) => {
1094
+ const v = resolveSpacing(value, negative, spacing, isArbitrary);
1095
+ return v !== null ? { [prop]: v } : null;
1096
+ };
1097
+ }
1098
+ var PADDING_MARGIN_PROPS = {
1099
+ p: "padding",
1100
+ px: "paddingHorizontal",
1101
+ py: "paddingVertical",
1102
+ pt: "paddingTop",
1103
+ pr: "paddingRight",
1104
+ pb: "paddingBottom",
1105
+ pl: "paddingLeft",
1106
+ m: "margin",
1107
+ mx: "marginHorizontal",
1108
+ my: "marginVertical",
1109
+ mt: "marginTop",
1110
+ mr: "marginRight",
1111
+ mb: "marginBottom",
1112
+ ml: "marginLeft"
1113
+ };
1114
+ function makeBorderSideResolver(widthProp, colorProp) {
1115
+ return ({ value, isArbitrary }, { colors, borderWidth }) => {
1116
+ if (!value) return { [widthProp]: 1 };
1117
+ if (isArbitrary) {
1118
+ const w2 = toNativeValue(value);
1119
+ if (typeof w2 === "number") return { [widthProp]: w2 };
1120
+ return { [colorProp]: value };
1121
+ }
1122
+ const color = resolveColor(value, colors, false);
1123
+ if (color) return { [colorProp]: color };
1124
+ const w = borderWidth[value];
1125
+ return w !== void 0 ? { [widthProp]: w } : null;
1126
+ };
1127
+ }
1128
+ var BORDER_SIDE_PROPS = {
1129
+ "border-t": ["borderTopWidth", "borderTopColor"],
1130
+ "border-r": ["borderRightWidth", "borderRightColor"],
1131
+ "border-b": ["borderBottomWidth", "borderBottomColor"],
1132
+ "border-l": ["borderLeftWidth", "borderLeftColor"]
1133
+ };
1081
1134
  var RESOLVERS = {
1082
1135
  // ── Background ─────────────────────────────────────────────────────────────
1083
1136
  bg: ({ value, isArbitrary }, { colors }) => {
@@ -1111,64 +1164,8 @@ var RESOLVERS = {
1111
1164
  const v = isArbitrary ? n > 1 ? n / 100 : n : n / 100;
1112
1165
  return { "--text-opacity": v };
1113
1166
  },
1114
- // ── Padding ────────────────────────────────────────────────────────────────
1115
- p: ({ value, negative, isArbitrary }, { spacing }) => {
1116
- const v = resolveSpacing(value, negative, spacing, isArbitrary);
1117
- return v !== null ? { padding: v } : null;
1118
- },
1119
- px: ({ value, negative, isArbitrary }, { spacing }) => {
1120
- const v = resolveSpacing(value, negative, spacing, isArbitrary);
1121
- return v !== null ? { paddingHorizontal: v } : null;
1122
- },
1123
- py: ({ value, negative, isArbitrary }, { spacing }) => {
1124
- const v = resolveSpacing(value, negative, spacing, isArbitrary);
1125
- return v !== null ? { paddingVertical: v } : null;
1126
- },
1127
- pt: ({ value, negative, isArbitrary }, { spacing }) => {
1128
- const v = resolveSpacing(value, negative, spacing, isArbitrary);
1129
- return v !== null ? { paddingTop: v } : null;
1130
- },
1131
- pr: ({ value, negative, isArbitrary }, { spacing }) => {
1132
- const v = resolveSpacing(value, negative, spacing, isArbitrary);
1133
- return v !== null ? { paddingRight: v } : null;
1134
- },
1135
- pb: ({ value, negative, isArbitrary }, { spacing }) => {
1136
- const v = resolveSpacing(value, negative, spacing, isArbitrary);
1137
- return v !== null ? { paddingBottom: v } : null;
1138
- },
1139
- pl: ({ value, negative, isArbitrary }, { spacing }) => {
1140
- const v = resolveSpacing(value, negative, spacing, isArbitrary);
1141
- return v !== null ? { paddingLeft: v } : null;
1142
- },
1143
- // ── Margin ─────────────────────────────────────────────────────────────────
1144
- m: ({ value, negative, isArbitrary }, { spacing }) => {
1145
- const v = resolveSpacing(value, negative, spacing, isArbitrary);
1146
- return v !== null ? { margin: v } : null;
1147
- },
1148
- mx: ({ value, negative, isArbitrary }, { spacing }) => {
1149
- const v = resolveSpacing(value, negative, spacing, isArbitrary);
1150
- return v !== null ? { marginHorizontal: v } : null;
1151
- },
1152
- my: ({ value, negative, isArbitrary }, { spacing }) => {
1153
- const v = resolveSpacing(value, negative, spacing, isArbitrary);
1154
- return v !== null ? { marginVertical: v } : null;
1155
- },
1156
- mt: ({ value, negative, isArbitrary }, { spacing }) => {
1157
- const v = resolveSpacing(value, negative, spacing, isArbitrary);
1158
- return v !== null ? { marginTop: v } : null;
1159
- },
1160
- mr: ({ value, negative, isArbitrary }, { spacing }) => {
1161
- const v = resolveSpacing(value, negative, spacing, isArbitrary);
1162
- return v !== null ? { marginRight: v } : null;
1163
- },
1164
- mb: ({ value, negative, isArbitrary }, { spacing }) => {
1165
- const v = resolveSpacing(value, negative, spacing, isArbitrary);
1166
- return v !== null ? { marginBottom: v } : null;
1167
- },
1168
- ml: ({ value, negative, isArbitrary }, { spacing }) => {
1169
- const v = resolveSpacing(value, negative, spacing, isArbitrary);
1170
- return v !== null ? { marginLeft: v } : null;
1171
- },
1167
+ // ── Padding & margin ───────────────────────────────────────────────────────
1168
+ // Generated below via makeSpacingResolver() — see PADDING_MARGIN_PROPS.
1172
1169
  // ── Sizing ─────────────────────────────────────────────────────────────────
1173
1170
  w: ({ value, isArbitrary }, { spacing }) => {
1174
1171
  const v = resolveSizing(value, spacing, isArbitrary);
@@ -1212,54 +1209,7 @@ var RESOLVERS = {
1212
1209
  }
1213
1210
  return null;
1214
1211
  },
1215
- "border-t": ({ value, isArbitrary }, { colors, borderWidth }) => {
1216
- if (!value) return { borderTopWidth: 1 };
1217
- if (isArbitrary) {
1218
- const w2 = toNativeValue(value);
1219
- if (typeof w2 === "number") return { borderTopWidth: w2 };
1220
- return { borderTopColor: value };
1221
- }
1222
- const color = resolveColor(value, colors, false);
1223
- if (color) return { borderTopColor: color };
1224
- const w = borderWidth[value];
1225
- return w !== void 0 ? { borderTopWidth: w } : null;
1226
- },
1227
- "border-r": ({ value, isArbitrary }, { colors, borderWidth }) => {
1228
- if (!value) return { borderRightWidth: 1 };
1229
- if (isArbitrary) {
1230
- const w2 = toNativeValue(value);
1231
- if (typeof w2 === "number") return { borderRightWidth: w2 };
1232
- return { borderRightColor: value };
1233
- }
1234
- const color = resolveColor(value, colors, false);
1235
- if (color) return { borderRightColor: color };
1236
- const w = borderWidth[value];
1237
- return w !== void 0 ? { borderRightWidth: w } : null;
1238
- },
1239
- "border-b": ({ value, isArbitrary }, { colors, borderWidth }) => {
1240
- if (!value) return { borderBottomWidth: 1 };
1241
- if (isArbitrary) {
1242
- const w2 = toNativeValue(value);
1243
- if (typeof w2 === "number") return { borderBottomWidth: w2 };
1244
- return { borderBottomColor: value };
1245
- }
1246
- const color = resolveColor(value, colors, false);
1247
- if (color) return { borderBottomColor: color };
1248
- const w = borderWidth[value];
1249
- return w !== void 0 ? { borderBottomWidth: w } : null;
1250
- },
1251
- "border-l": ({ value, isArbitrary }, { colors, borderWidth }) => {
1252
- if (!value) return { borderLeftWidth: 1 };
1253
- if (isArbitrary) {
1254
- const w2 = toNativeValue(value);
1255
- if (typeof w2 === "number") return { borderLeftWidth: w2 };
1256
- return { borderLeftColor: value };
1257
- }
1258
- const color = resolveColor(value, colors, false);
1259
- if (color) return { borderLeftColor: color };
1260
- const w = borderWidth[value];
1261
- return w !== void 0 ? { borderLeftWidth: w } : null;
1262
- },
1212
+ // border-t/-r/-b/-l generated below via makeBorderSideResolver() — see BORDER_SIDE_PROPS.
1263
1213
  // ── Border radius ──────────────────────────────────────────────────────────
1264
1214
  rounded: ({ value, isArbitrary }, { borderRadius }) => {
1265
1215
  const r = resolveRadius(value, borderRadius, isArbitrary);
@@ -1491,49 +1441,49 @@ var RESOLVERS = {
1491
1441
  "2xl": "blur(40px)",
1492
1442
  "3xl": "blur(64px)"
1493
1443
  };
1494
- if (value === "none") return { "--tw-blur": "", filter: FILTER_COMPOSE };
1444
+ if (value === "none") return { "--kb-blur": "", filter: FILTER_COMPOSE };
1495
1445
  const v = isArbitrary ? `blur(${value})` : sizes[value];
1496
- return v !== void 0 ? { "--tw-blur": v, filter: FILTER_COMPOSE } : null;
1446
+ return v !== void 0 ? { "--kb-blur": v, filter: FILTER_COMPOSE } : null;
1497
1447
  },
1498
1448
  brightness: ({ value, isArbitrary }) => {
1499
1449
  if (!getEffectiveIsWeb()) return null;
1500
1450
  const v = isArbitrary ? `brightness(${value})` : `brightness(${parseFloat(value) / 100})`;
1501
- return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--tw-brightness": v, filter: FILTER_COMPOSE };
1451
+ return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--kb-brightness": v, filter: FILTER_COMPOSE };
1502
1452
  },
1503
1453
  contrast: ({ value, isArbitrary }) => {
1504
1454
  if (!getEffectiveIsWeb()) return null;
1505
1455
  const v = isArbitrary ? `contrast(${value})` : `contrast(${parseFloat(value) / 100})`;
1506
- return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--tw-contrast": v, filter: FILTER_COMPOSE };
1456
+ return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--kb-contrast": v, filter: FILTER_COMPOSE };
1507
1457
  },
1508
1458
  grayscale: ({ value }) => {
1509
1459
  if (!getEffectiveIsWeb()) return null;
1510
1460
  const v = value === "0" ? "grayscale(0)" : "grayscale(100%)";
1511
- return { "--tw-grayscale": v, filter: FILTER_COMPOSE };
1461
+ return { "--kb-grayscale": v, filter: FILTER_COMPOSE };
1512
1462
  },
1513
1463
  "hue-rotate": ({ value, negative, isArbitrary }) => {
1514
1464
  if (!getEffectiveIsWeb()) return null;
1515
1465
  const deg = isArbitrary ? value : `${(negative ? -1 : 1) * parseFloat(value)}deg`;
1516
1466
  if (isNaN(parseFloat(deg)) && !isArbitrary) return null;
1517
- return { "--tw-hue-rotate": `hue-rotate(${deg})`, filter: FILTER_COMPOSE };
1467
+ return { "--kb-hue-rotate": `hue-rotate(${deg})`, filter: FILTER_COMPOSE };
1518
1468
  },
1519
1469
  invert: ({ value }) => {
1520
1470
  if (!getEffectiveIsWeb()) return null;
1521
1471
  const v = value === "0" ? "invert(0)" : "invert(100%)";
1522
- return { "--tw-invert": v, filter: FILTER_COMPOSE };
1472
+ return { "--kb-invert": v, filter: FILTER_COMPOSE };
1523
1473
  },
1524
1474
  saturate: ({ value, isArbitrary }) => {
1525
1475
  if (!getEffectiveIsWeb()) return null;
1526
1476
  const v = isArbitrary ? `saturate(${value})` : `saturate(${parseFloat(value) / 100})`;
1527
- return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--tw-saturate": v, filter: FILTER_COMPOSE };
1477
+ return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--kb-saturate": v, filter: FILTER_COMPOSE };
1528
1478
  },
1529
1479
  sepia: ({ value }) => {
1530
1480
  if (!getEffectiveIsWeb()) return null;
1531
1481
  const v = value === "0" ? "sepia(0)" : "sepia(100%)";
1532
- return { "--tw-sepia": v, filter: FILTER_COMPOSE };
1482
+ return { "--kb-sepia": v, filter: FILTER_COMPOSE };
1533
1483
  },
1534
1484
  "drop-shadow": ({ value, isArbitrary }) => {
1535
1485
  if (!getEffectiveIsWeb()) return null;
1536
- if (isArbitrary) return { "--tw-drop-shadow": `drop-shadow(${value.replace(/_/g, " ")})`, filter: FILTER_COMPOSE };
1486
+ if (isArbitrary) return { "--kb-drop-shadow": `drop-shadow(${value.replace(/_/g, " ")})`, filter: FILTER_COMPOSE };
1537
1487
  const presets = {
1538
1488
  "": "drop-shadow(0 1px 2px rgb(0 0 0/0.1)) drop-shadow(0 1px 1px rgb(0 0 0/0.06))",
1539
1489
  sm: "drop-shadow(0 1px 1px rgb(0 0 0/0.05))",
@@ -1544,7 +1494,7 @@ var RESOLVERS = {
1544
1494
  none: "drop-shadow(0 0 #0000)"
1545
1495
  };
1546
1496
  const v = presets[value];
1547
- return v !== void 0 ? { "--tw-drop-shadow": v, filter: FILTER_COMPOSE } : null;
1497
+ return v !== void 0 ? { "--kb-drop-shadow": v, filter: FILTER_COMPOSE } : null;
1548
1498
  },
1549
1499
  // Arbitrary full filter string: filter-[blur(4px)_grayscale(1)]
1550
1500
  filter: ({ value, isArbitrary }) => {
@@ -1565,47 +1515,47 @@ var RESOLVERS = {
1565
1515
  "2xl": "blur(40px)",
1566
1516
  "3xl": "blur(64px)"
1567
1517
  };
1568
- if (value === "none") return { "--tw-backdrop-blur": "", backdropFilter: BACKDROP_FILTER_COMPOSE };
1518
+ if (value === "none") return { "--kb-backdrop-blur": "", backdropFilter: BACKDROP_FILTER_COMPOSE };
1569
1519
  const v = isArbitrary ? `blur(${value})` : sizes[value];
1570
- return v !== void 0 ? { "--tw-backdrop-blur": v, backdropFilter: BACKDROP_FILTER_COMPOSE } : null;
1520
+ return v !== void 0 ? { "--kb-backdrop-blur": v, backdropFilter: BACKDROP_FILTER_COMPOSE } : null;
1571
1521
  },
1572
1522
  "backdrop-brightness": ({ value, isArbitrary }) => {
1573
1523
  if (!getEffectiveIsWeb()) return null;
1574
1524
  const v = isArbitrary ? `brightness(${value})` : `brightness(${parseFloat(value) / 100})`;
1575
- return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--tw-backdrop-brightness": v, backdropFilter: BACKDROP_FILTER_COMPOSE };
1525
+ return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--kb-backdrop-brightness": v, backdropFilter: BACKDROP_FILTER_COMPOSE };
1576
1526
  },
1577
1527
  "backdrop-contrast": ({ value, isArbitrary }) => {
1578
1528
  if (!getEffectiveIsWeb()) return null;
1579
1529
  const v = isArbitrary ? `contrast(${value})` : `contrast(${parseFloat(value) / 100})`;
1580
- return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--tw-backdrop-contrast": v, backdropFilter: BACKDROP_FILTER_COMPOSE };
1530
+ return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--kb-backdrop-contrast": v, backdropFilter: BACKDROP_FILTER_COMPOSE };
1581
1531
  },
1582
1532
  "backdrop-grayscale": ({ value }) => {
1583
1533
  if (!getEffectiveIsWeb()) return null;
1584
- return { "--tw-backdrop-grayscale": value === "0" ? "grayscale(0)" : "grayscale(100%)", backdropFilter: BACKDROP_FILTER_COMPOSE };
1534
+ return { "--kb-backdrop-grayscale": value === "0" ? "grayscale(0)" : "grayscale(100%)", backdropFilter: BACKDROP_FILTER_COMPOSE };
1585
1535
  },
1586
1536
  "backdrop-hue-rotate": ({ value, negative, isArbitrary }) => {
1587
1537
  if (!getEffectiveIsWeb()) return null;
1588
1538
  const deg = isArbitrary ? value : `${(negative ? -1 : 1) * parseFloat(value)}deg`;
1589
1539
  if (isNaN(parseFloat(deg)) && !isArbitrary) return null;
1590
- return { "--tw-backdrop-hue-rotate": `hue-rotate(${deg})`, backdropFilter: BACKDROP_FILTER_COMPOSE };
1540
+ return { "--kb-backdrop-hue-rotate": `hue-rotate(${deg})`, backdropFilter: BACKDROP_FILTER_COMPOSE };
1591
1541
  },
1592
1542
  "backdrop-invert": ({ value }) => {
1593
1543
  if (!getEffectiveIsWeb()) return null;
1594
- return { "--tw-backdrop-invert": value === "0" ? "invert(0)" : "invert(100%)", backdropFilter: BACKDROP_FILTER_COMPOSE };
1544
+ return { "--kb-backdrop-invert": value === "0" ? "invert(0)" : "invert(100%)", backdropFilter: BACKDROP_FILTER_COMPOSE };
1595
1545
  },
1596
1546
  "backdrop-opacity": ({ value, isArbitrary }) => {
1597
1547
  if (!getEffectiveIsWeb()) return null;
1598
1548
  const v = isArbitrary ? `opacity(${value})` : `opacity(${parseFloat(value) / 100})`;
1599
- return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--tw-backdrop-opacity": v, backdropFilter: BACKDROP_FILTER_COMPOSE };
1549
+ return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--kb-backdrop-opacity": v, backdropFilter: BACKDROP_FILTER_COMPOSE };
1600
1550
  },
1601
1551
  "backdrop-saturate": ({ value, isArbitrary }) => {
1602
1552
  if (!getEffectiveIsWeb()) return null;
1603
1553
  const v = isArbitrary ? `saturate(${value})` : `saturate(${parseFloat(value) / 100})`;
1604
- return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--tw-backdrop-saturate": v, backdropFilter: BACKDROP_FILTER_COMPOSE };
1554
+ return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--kb-backdrop-saturate": v, backdropFilter: BACKDROP_FILTER_COMPOSE };
1605
1555
  },
1606
1556
  "backdrop-sepia": ({ value }) => {
1607
1557
  if (!getEffectiveIsWeb()) return null;
1608
- return { "--tw-backdrop-sepia": value === "0" ? "sepia(0)" : "sepia(100%)", backdropFilter: BACKDROP_FILTER_COMPOSE };
1558
+ return { "--kb-backdrop-sepia": value === "0" ? "sepia(0)" : "sepia(100%)", backdropFilter: BACKDROP_FILTER_COMPOSE };
1609
1559
  },
1610
1560
  "backdrop-filter": ({ value, isArbitrary }) => {
1611
1561
  if (!getEffectiveIsWeb()) return null;
@@ -1629,7 +1579,7 @@ var RESOLVERS = {
1629
1579
  const dir = directions[value];
1630
1580
  if (!dir) return null;
1631
1581
  return {
1632
- backgroundImage: `linear-gradient(${dir}, var(--tw-gradient-from, transparent), var(--tw-gradient-stops, transparent))`
1582
+ backgroundImage: `linear-gradient(${dir}, var(--kb-gradient-from, transparent), var(--kb-gradient-stops, transparent))`
1633
1583
  };
1634
1584
  },
1635
1585
  from: ({ value, isArbitrary }, { colors }) => {
@@ -1637,8 +1587,8 @@ var RESOLVERS = {
1637
1587
  const color = resolveColor(value, colors, isArbitrary);
1638
1588
  if (!color) return null;
1639
1589
  return {
1640
- "--tw-gradient-from": color,
1641
- "--tw-gradient-stops": `var(--tw-gradient-from), var(--tw-gradient-to, transparent)`
1590
+ "--kb-gradient-from": color,
1591
+ "--kb-gradient-stops": `var(--kb-gradient-from), var(--kb-gradient-to, transparent)`
1642
1592
  };
1643
1593
  },
1644
1594
  via: ({ value, isArbitrary }, { colors }) => {
@@ -1646,15 +1596,15 @@ var RESOLVERS = {
1646
1596
  const color = resolveColor(value, colors, isArbitrary);
1647
1597
  if (!color) return null;
1648
1598
  return {
1649
- "--tw-gradient-via": color,
1650
- "--tw-gradient-stops": `var(--tw-gradient-from), var(--tw-gradient-via), var(--tw-gradient-to, transparent)`
1599
+ "--kb-gradient-via": color,
1600
+ "--kb-gradient-stops": `var(--kb-gradient-from), var(--kb-gradient-via), var(--kb-gradient-to, transparent)`
1651
1601
  };
1652
1602
  },
1653
1603
  to: ({ value, isArbitrary }, { colors }) => {
1654
1604
  if (!getEffectiveIsWeb()) return null;
1655
1605
  const color = resolveColor(value, colors, isArbitrary);
1656
1606
  if (!color) return null;
1657
- return { "--tw-gradient-to": color };
1607
+ return { "--kb-gradient-to": color };
1658
1608
  },
1659
1609
  // ── Transform extras (web-only) ───────────────────────────────────────────
1660
1610
  "skew-x": ({ value, negative, isArbitrary }) => {
@@ -2258,6 +2208,12 @@ var RESOLVERS = {
2258
2208
  return { rowGap: v };
2259
2209
  }
2260
2210
  };
2211
+ for (const [utility, prop] of Object.entries(PADDING_MARGIN_PROPS)) {
2212
+ RESOLVERS[utility] = makeSpacingResolver(prop);
2213
+ }
2214
+ for (const [utility, [widthProp, colorProp]] of Object.entries(BORDER_SIDE_PROPS)) {
2215
+ RESOLVERS[utility] = makeBorderSideResolver(widthProp, colorProp);
2216
+ }
2261
2217
  function resolveUtility(parsed, theme) {
2262
2218
  if (!parsed.value) {
2263
2219
  if (parsed.utility in PLUGIN_STANDALONE) return PLUGIN_STANDALONE[parsed.utility] ?? null;
@@ -2524,10 +2480,11 @@ function findOuterColon(s) {
2524
2480
 
2525
2481
  // src/core/cache.ts
2526
2482
  var LRUCache = class {
2527
- constructor(capacity = 1e4) {
2483
+ constructor(capacity = 1e4, onEvict) {
2528
2484
  this.capacity = capacity;
2529
2485
  if (capacity <= 0) throw new Error("LRUCache: capacity must be a positive integer");
2530
2486
  this.cache = /* @__PURE__ */ new Map();
2487
+ this.onEvict = onEvict;
2531
2488
  }
2532
2489
  get(key) {
2533
2490
  if (!this.cache.has(key)) return void 0;
@@ -2540,7 +2497,10 @@ var LRUCache = class {
2540
2497
  if (this.cache.has(key)) {
2541
2498
  this.cache.delete(key);
2542
2499
  } else if (this.cache.size >= this.capacity) {
2543
- this.cache.delete(this.cache.keys().next().value);
2500
+ const oldestKey = this.cache.keys().next().value;
2501
+ const oldestValue = this.cache.get(oldestKey);
2502
+ this.cache.delete(oldestKey);
2503
+ this.onEvict?.(oldestKey, oldestValue);
2544
2504
  }
2545
2505
  this.cache.set(key, value);
2546
2506
  return this;
@@ -2565,7 +2525,20 @@ function setDefaultFontFamily(font) {
2565
2525
  globalThis[FONT_KEY] = font;
2566
2526
  }
2567
2527
  var _styleEl = null;
2568
- var _injectedRules = new LRUCache(5e4);
2528
+ function evictInjectedRule(rule) {
2529
+ const sheet = _styleEl?.sheet;
2530
+ if (!sheet) return;
2531
+ for (let i = 0; i < sheet.cssRules.length; i++) {
2532
+ if (sheet.cssRules[i].cssText === rule) {
2533
+ try {
2534
+ sheet.deleteRule(i);
2535
+ } catch {
2536
+ }
2537
+ return;
2538
+ }
2539
+ }
2540
+ }
2541
+ var _injectedRules = new LRUCache(5e4, evictInjectedRule);
2569
2542
  var _CSS_DISABLED_KEY = "__kbach_runtime_css_disabled__";
2570
2543
  function isRuntimeCSSDisabled() {
2571
2544
  return !!globalThis[_CSS_DISABLED_KEY];
@@ -2589,8 +2562,7 @@ function injectGlobalStyles(theme) {
2589
2562
  if (typeof document === "undefined" || isRuntimeCSSDisabled()) return;
2590
2563
  const rules = [BASE_RESET];
2591
2564
  const ff = theme.fontFamily;
2592
- if (!ff) return;
2593
- if (ff.sans && ff.sans !== "System") {
2565
+ if (ff?.sans && ff.sans !== "System") {
2594
2566
  const family = Array.isArray(ff.sans) ? ff.sans.join(", ") : ff.sans;
2595
2567
  rules.push(`body { font-family: ${family}; }`);
2596
2568
  }
@@ -2753,7 +2725,7 @@ function buildClassCSSRules(cls, bucketKey, styles, darkMode, important, screens
2753
2725
  else rule = `[data-theme="dark"] ${selector} { ${decls} }`;
2754
2726
  } else if (darkScheme === "light") {
2755
2727
  if (darkMode === "media") rule = `@media (prefers-color-scheme: light) { ${selector} { ${decls} } }`;
2756
- else if (darkMode === "class") rule = `:not(.dark) ${selector} { ${decls} }`;
2728
+ else if (darkMode === "class") rule = `.light ${selector} { ${decls} }`;
2757
2729
  else rule = `[data-theme="light"] ${selector} { ${decls} }`;
2758
2730
  } else {
2759
2731
  rule = `${selector} { ${decls} }`;
@@ -2800,11 +2772,14 @@ function getConfigStore() {
2800
2772
  return g[CONFIG_KEY];
2801
2773
  }
2802
2774
  function resolveOneRef(ref, colors) {
2803
- const m = /^([a-z][a-z0-9]*)-(\d+)$/.exec(ref);
2804
- if (!m) return null;
2805
- const entry = colors[m[1]];
2775
+ const lastDash = ref.lastIndexOf("-");
2776
+ if (lastDash <= 0) return null;
2777
+ const name = ref.slice(0, lastDash);
2778
+ const shade = ref.slice(lastDash + 1);
2779
+ if (!/^\d+$/.test(shade)) return null;
2780
+ const entry = colors[name];
2806
2781
  if (!entry || typeof entry !== "object") return null;
2807
- return entry[m[2]] ?? null;
2782
+ return entry[shade] ?? null;
2808
2783
  }
2809
2784
  function resolveColorRefs(colors) {
2810
2785
  const MAX_DEPTH = 5;
@@ -2834,7 +2809,7 @@ function resolveColorRefs(colors) {
2834
2809
  function buildConfig(userConfig) {
2835
2810
  let theme = { ...defaultTheme };
2836
2811
  if (userConfig.theme) {
2837
- theme = deepMerge(theme, userConfig.theme);
2812
+ theme = { ...theme, ...userConfig.theme };
2838
2813
  }
2839
2814
  if (userConfig.extend) {
2840
2815
  const extendConfig = userConfig.extend;
@@ -2987,8 +2962,9 @@ function buildColorVarMap(theme, usedCSS) {
2987
2962
  function formatKbachCSS(tokenCSS, theme, responsiveRe) {
2988
2963
  const allRaw = [...tokenCSS.values()].filter(Boolean).join("\n");
2989
2964
  const colorVars = buildColorVarMap(theme, allRaw);
2965
+ const sortedColorVars = [...colorVars].sort(([a], [b]) => b.length - a.length);
2990
2966
  function applyVars(css) {
2991
- for (const [val, varName] of colorVars)
2967
+ for (const [val, varName] of sortedColorVars)
2992
2968
  css = css.split(val).join(`var(${varName})`);
2993
2969
  return css;
2994
2970
  }