@kbach/react 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -0
- package/dist/{chunk-D4LJICWZ.mjs → chunk-36QRQNPL.mjs} +77 -73
- package/dist/{chunk-AAAI37Y4.mjs → chunk-6ZORO3BP.mjs} +6 -64
- package/dist/{chunk-6NED62DB.mjs → chunk-MPHPB357.mjs} +143 -162
- package/dist/index.d.mts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +344 -395
- package/dist/index.mjs +59 -87
- package/dist/jsx-dev-runtime.js +204 -289
- package/dist/jsx-dev-runtime.mjs +4 -4
- package/dist/jsx-runtime.js +203 -288
- package/dist/jsx-runtime.mjs +3 -3
- package/dist/vite-plugin.js +139 -163
- package/dist/vite-plugin.mjs +3 -2
- package/kbach-react.md +14 -0
- package/package.json +1 -1
package/dist/jsx-runtime.mjs
CHANGED
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
_invalidateDefaultFontCache,
|
|
4
4
|
jsx,
|
|
5
5
|
jsxs
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-6ZORO3BP.mjs";
|
|
7
7
|
import {
|
|
8
8
|
registerWebElement
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-36QRQNPL.mjs";
|
|
10
|
+
import "./chunk-MPHPB357.mjs";
|
|
11
11
|
export {
|
|
12
12
|
Fragment,
|
|
13
13
|
_invalidateDefaultFontCache,
|
package/dist/vite-plugin.js
CHANGED
|
@@ -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
|
|
43
|
+
var _resolveTargetOverride = null;
|
|
44
44
|
function setCSSGenMode(on) {
|
|
45
|
-
|
|
45
|
+
_resolveTargetOverride = on ? "web" : null;
|
|
46
46
|
}
|
|
47
47
|
function getEffectiveIsWeb() {
|
|
48
|
-
|
|
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
|
|
677
|
+
function parseHexRgb(hex) {
|
|
677
678
|
const h = hex.replace("#", "");
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
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(--
|
|
732
|
-
var BACKDROP_FILTER_COMPOSE = "var(--
|
|
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 ? { "--
|
|
995
|
-
invert: web ? { "--
|
|
996
|
-
sepia: web ? { "--
|
|
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
|
-
|
|
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
|
-
|
|
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 { "--
|
|
1444
|
+
if (value === "none") return { "--kb-blur": "", filter: FILTER_COMPOSE };
|
|
1495
1445
|
const v = isArbitrary ? `blur(${value})` : sizes[value];
|
|
1496
|
-
return v !== void 0 ? { "--
|
|
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 : { "--
|
|
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 : { "--
|
|
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 { "--
|
|
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 { "--
|
|
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 { "--
|
|
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 : { "--
|
|
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 { "--
|
|
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 { "--
|
|
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 ? { "--
|
|
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 { "--
|
|
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 ? { "--
|
|
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 : { "--
|
|
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 : { "--
|
|
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 { "--
|
|
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 { "--
|
|
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 { "--
|
|
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 : { "--
|
|
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 : { "--
|
|
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 { "--
|
|
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(--
|
|
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
|
-
"--
|
|
1641
|
-
"--
|
|
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
|
-
"--
|
|
1650
|
-
"--
|
|
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 { "--
|
|
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.
|
|
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
|
-
|
|
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 (
|
|
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 =
|
|
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
|
|
2804
|
-
if (
|
|
2805
|
-
const
|
|
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[
|
|
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 =
|
|
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
|
|
2967
|
+
for (const [val, varName] of sortedColorVars)
|
|
2992
2968
|
css = css.split(val).join(`var(${varName})`);
|
|
2993
2969
|
return css;
|
|
2994
2970
|
}
|
package/dist/vite-plugin.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
generateClassCSS,
|
|
5
5
|
setCSSGenMode,
|
|
6
6
|
splitClassTokens
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-MPHPB357.mjs";
|
|
8
8
|
|
|
9
9
|
// src/vite-plugin.ts
|
|
10
10
|
import { readFileSync, writeFileSync, readdirSync, statSync } from "fs";
|
|
@@ -58,8 +58,9 @@ function buildColorVarMap(theme, usedCSS) {
|
|
|
58
58
|
function formatKbachCSS(tokenCSS, theme, responsiveRe) {
|
|
59
59
|
const allRaw = [...tokenCSS.values()].filter(Boolean).join("\n");
|
|
60
60
|
const colorVars = buildColorVarMap(theme, allRaw);
|
|
61
|
+
const sortedColorVars = [...colorVars].sort(([a], [b]) => b.length - a.length);
|
|
61
62
|
function applyVars(css) {
|
|
62
|
-
for (const [val, varName] of
|
|
63
|
+
for (const [val, varName] of sortedColorVars)
|
|
63
64
|
css = css.split(val).join(`var(${varName})`);
|
|
64
65
|
return css;
|
|
65
66
|
}
|
package/kbach-react.md
CHANGED
|
@@ -14,6 +14,7 @@ Package: `@kbach/react`
|
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
### vite.config.ts
|
|
17
|
+
Requires `vite` and `@vitejs/plugin-react` as dev dependencies — not installed by `@kbach/react` itself: `npm install -D vite @vitejs/plugin-react`.
|
|
17
18
|
```ts
|
|
18
19
|
import { defineConfig } from 'vite';
|
|
19
20
|
import react from '@vitejs/plugin-react';
|
|
@@ -45,6 +46,19 @@ import { ThemeProvider } from '@kbach/react';
|
|
|
45
46
|
<ThemeProvider defaultMode="system"><App /></ThemeProvider>
|
|
46
47
|
```
|
|
47
48
|
|
|
49
|
+
### Next.js
|
|
50
|
+
tsconfig `jsxImportSource` setup above applies as-is. No Vite plugin for Next.js (webpack/Turbopack) — falls back to runtime CSS injection, which only runs client-side, so expect a brief flash of unstyled content on first paint before hydration. `@kbach/react` ships no `'use client'` directive, so wrap `ThemeProvider` in your own client component before using it in App Router:
|
|
51
|
+
```tsx
|
|
52
|
+
'use client';
|
|
53
|
+
import { ThemeProvider } from '@kbach/react';
|
|
54
|
+
export function Providers({ children }) {
|
|
55
|
+
return <ThemeProvider defaultMode="system">{children}</ThemeProvider>;
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### React Router
|
|
60
|
+
Framework mode (v7, SSR) builds with Vite, so the setup above works unchanged — default scan dirs include `app/`. Library mode (client-only) needs no special handling beyond the standard Vite setup.
|
|
61
|
+
|
|
48
62
|
---
|
|
49
63
|
|
|
50
64
|
## Vite Plugin
|