@kbach/react 0.5.62 → 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 +51 -9
- package/dist/{chunk-5MX3E4OL.mjs → chunk-36QRQNPL.mjs} +77 -73
- package/dist/{chunk-MZKQ7H67.mjs → chunk-6ZORO3BP.mjs} +6 -64
- package/dist/{chunk-BRCQK5DA.mjs → chunk-MPHPB357.mjs} +143 -170
- package/dist/index.d.mts +12 -29
- package/dist/index.d.ts +12 -29
- package/dist/index.js +344 -536
- package/dist/index.mjs +62 -231
- 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 -8
- package/package.json +1 -1
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
-
});
|
|
7
|
-
|
|
8
1
|
// src/core/theme.ts
|
|
9
2
|
var defaultColors = {
|
|
10
3
|
transparent: "transparent",
|
|
@@ -548,12 +541,16 @@ var defaultTheme = {
|
|
|
548
541
|
// src/core/platform.ts
|
|
549
542
|
var isWeb = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
550
543
|
var isNative = !isWeb && (typeof globalThis.HermesInternal !== "undefined" || typeof globalThis.__fbBatchedBridge !== "undefined" || typeof navigator !== "undefined" && navigator.product === "ReactNative" || typeof globalThis.__REACT_NATIVE__ !== "undefined");
|
|
551
|
-
var
|
|
544
|
+
var _resolveTargetOverride = null;
|
|
545
|
+
function setResolveTarget(target) {
|
|
546
|
+
_resolveTargetOverride = target;
|
|
547
|
+
}
|
|
552
548
|
function setCSSGenMode(on) {
|
|
553
|
-
|
|
549
|
+
_resolveTargetOverride = on ? "web" : null;
|
|
554
550
|
}
|
|
555
551
|
function getEffectiveIsWeb() {
|
|
556
|
-
|
|
552
|
+
if (_resolveTargetOverride) return _resolveTargetOverride === "web";
|
|
553
|
+
return isWeb || !isNative;
|
|
557
554
|
}
|
|
558
555
|
function toNativeValue(raw) {
|
|
559
556
|
if (/^-?\d+(\.\d+)?px$/.test(raw)) return parseFloat(raw);
|
|
@@ -740,18 +737,28 @@ function resolveColor(value, colors, isArbitrary) {
|
|
|
740
737
|
if (isNaN(alpha)) return hex;
|
|
741
738
|
return hexToRgba(hex, alpha);
|
|
742
739
|
}
|
|
743
|
-
function
|
|
740
|
+
function parseHexRgb(hex) {
|
|
744
741
|
const h = hex.replace("#", "");
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
r = parseInt(h.slice(0, 2), 16);
|
|
752
|
-
g = parseInt(h.slice(2, 4), 16);
|
|
753
|
-
b = parseInt(h.slice(4, 6), 16);
|
|
742
|
+
if (h.length === 3 || h.length === 4) {
|
|
743
|
+
return [
|
|
744
|
+
parseInt(h[0] + h[0], 16),
|
|
745
|
+
parseInt(h[1] + h[1], 16),
|
|
746
|
+
parseInt(h[2] + h[2], 16)
|
|
747
|
+
];
|
|
754
748
|
}
|
|
749
|
+
if (h.length === 6 || h.length === 8) {
|
|
750
|
+
return [
|
|
751
|
+
parseInt(h.slice(0, 2), 16),
|
|
752
|
+
parseInt(h.slice(2, 4), 16),
|
|
753
|
+
parseInt(h.slice(4, 6), 16)
|
|
754
|
+
];
|
|
755
|
+
}
|
|
756
|
+
return null;
|
|
757
|
+
}
|
|
758
|
+
function hexToRgba(hex, alpha) {
|
|
759
|
+
const rgb = parseHexRgb(hex);
|
|
760
|
+
if (!rgb) return hex;
|
|
761
|
+
const [r, g, b] = rgb;
|
|
755
762
|
return `rgba(${r},${g},${b},${alpha})`;
|
|
756
763
|
}
|
|
757
764
|
function resolveSpacing(value, negative, spacing, isArbitrary) {
|
|
@@ -795,8 +802,8 @@ function resolveFontSize(value, fontSizes, isArbitrary) {
|
|
|
795
802
|
if (isArbitrary) return getEffectiveIsWeb() ? value : toNativeValue(value);
|
|
796
803
|
return fontSizes[value] ?? null;
|
|
797
804
|
}
|
|
798
|
-
var FILTER_COMPOSE = "var(--
|
|
799
|
-
var BACKDROP_FILTER_COMPOSE = "var(--
|
|
805
|
+
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,)";
|
|
806
|
+
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,)";
|
|
800
807
|
var _standalone = null;
|
|
801
808
|
function buildStandalone() {
|
|
802
809
|
const web = getEffectiveIsWeb();
|
|
@@ -1058,9 +1065,9 @@ function buildStandalone() {
|
|
|
1058
1065
|
"backface-visible": { backfaceVisibility: "visible" },
|
|
1059
1066
|
"backface-hidden": { backfaceVisibility: "hidden" },
|
|
1060
1067
|
// CSS filters — standalone = default/full effect (web-only)
|
|
1061
|
-
grayscale: web ? { "--
|
|
1062
|
-
invert: web ? { "--
|
|
1063
|
-
sepia: web ? { "--
|
|
1068
|
+
grayscale: web ? { "--kb-grayscale": "grayscale(100%)", filter: FILTER_COMPOSE } : null,
|
|
1069
|
+
invert: web ? { "--kb-invert": "invert(100%)", filter: FILTER_COMPOSE } : null,
|
|
1070
|
+
sepia: web ? { "--kb-sepia": "sepia(100%)", filter: FILTER_COMPOSE } : null,
|
|
1064
1071
|
// Divide none
|
|
1065
1072
|
"divide-none": web ? { __divideX: 0, __divideY: 0 } : null,
|
|
1066
1073
|
// Group / peer markers (no-op: no style emitted; just ensures isKnownUtility returns true)
|
|
@@ -1145,6 +1152,48 @@ function getStandalone() {
|
|
|
1145
1152
|
if (!_standalone) _standalone = buildStandalone();
|
|
1146
1153
|
return _standalone;
|
|
1147
1154
|
}
|
|
1155
|
+
function makeSpacingResolver(prop) {
|
|
1156
|
+
return ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1157
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1158
|
+
return v !== null ? { [prop]: v } : null;
|
|
1159
|
+
};
|
|
1160
|
+
}
|
|
1161
|
+
var PADDING_MARGIN_PROPS = {
|
|
1162
|
+
p: "padding",
|
|
1163
|
+
px: "paddingHorizontal",
|
|
1164
|
+
py: "paddingVertical",
|
|
1165
|
+
pt: "paddingTop",
|
|
1166
|
+
pr: "paddingRight",
|
|
1167
|
+
pb: "paddingBottom",
|
|
1168
|
+
pl: "paddingLeft",
|
|
1169
|
+
m: "margin",
|
|
1170
|
+
mx: "marginHorizontal",
|
|
1171
|
+
my: "marginVertical",
|
|
1172
|
+
mt: "marginTop",
|
|
1173
|
+
mr: "marginRight",
|
|
1174
|
+
mb: "marginBottom",
|
|
1175
|
+
ml: "marginLeft"
|
|
1176
|
+
};
|
|
1177
|
+
function makeBorderSideResolver(widthProp, colorProp) {
|
|
1178
|
+
return ({ value, isArbitrary }, { colors, borderWidth }) => {
|
|
1179
|
+
if (!value) return { [widthProp]: 1 };
|
|
1180
|
+
if (isArbitrary) {
|
|
1181
|
+
const w2 = toNativeValue(value);
|
|
1182
|
+
if (typeof w2 === "number") return { [widthProp]: w2 };
|
|
1183
|
+
return { [colorProp]: value };
|
|
1184
|
+
}
|
|
1185
|
+
const color = resolveColor(value, colors, false);
|
|
1186
|
+
if (color) return { [colorProp]: color };
|
|
1187
|
+
const w = borderWidth[value];
|
|
1188
|
+
return w !== void 0 ? { [widthProp]: w } : null;
|
|
1189
|
+
};
|
|
1190
|
+
}
|
|
1191
|
+
var BORDER_SIDE_PROPS = {
|
|
1192
|
+
"border-t": ["borderTopWidth", "borderTopColor"],
|
|
1193
|
+
"border-r": ["borderRightWidth", "borderRightColor"],
|
|
1194
|
+
"border-b": ["borderBottomWidth", "borderBottomColor"],
|
|
1195
|
+
"border-l": ["borderLeftWidth", "borderLeftColor"]
|
|
1196
|
+
};
|
|
1148
1197
|
var RESOLVERS = {
|
|
1149
1198
|
// ── Background ─────────────────────────────────────────────────────────────
|
|
1150
1199
|
bg: ({ value, isArbitrary }, { colors }) => {
|
|
@@ -1178,64 +1227,8 @@ var RESOLVERS = {
|
|
|
1178
1227
|
const v = isArbitrary ? n > 1 ? n / 100 : n : n / 100;
|
|
1179
1228
|
return { "--text-opacity": v };
|
|
1180
1229
|
},
|
|
1181
|
-
// ── Padding
|
|
1182
|
-
|
|
1183
|
-
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1184
|
-
return v !== null ? { padding: v } : null;
|
|
1185
|
-
},
|
|
1186
|
-
px: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1187
|
-
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1188
|
-
return v !== null ? { paddingHorizontal: v } : null;
|
|
1189
|
-
},
|
|
1190
|
-
py: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1191
|
-
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1192
|
-
return v !== null ? { paddingVertical: v } : null;
|
|
1193
|
-
},
|
|
1194
|
-
pt: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1195
|
-
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1196
|
-
return v !== null ? { paddingTop: v } : null;
|
|
1197
|
-
},
|
|
1198
|
-
pr: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1199
|
-
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1200
|
-
return v !== null ? { paddingRight: v } : null;
|
|
1201
|
-
},
|
|
1202
|
-
pb: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1203
|
-
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1204
|
-
return v !== null ? { paddingBottom: v } : null;
|
|
1205
|
-
},
|
|
1206
|
-
pl: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1207
|
-
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1208
|
-
return v !== null ? { paddingLeft: v } : null;
|
|
1209
|
-
},
|
|
1210
|
-
// ── Margin ─────────────────────────────────────────────────────────────────
|
|
1211
|
-
m: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1212
|
-
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1213
|
-
return v !== null ? { margin: v } : null;
|
|
1214
|
-
},
|
|
1215
|
-
mx: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1216
|
-
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1217
|
-
return v !== null ? { marginHorizontal: v } : null;
|
|
1218
|
-
},
|
|
1219
|
-
my: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1220
|
-
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1221
|
-
return v !== null ? { marginVertical: v } : null;
|
|
1222
|
-
},
|
|
1223
|
-
mt: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1224
|
-
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1225
|
-
return v !== null ? { marginTop: v } : null;
|
|
1226
|
-
},
|
|
1227
|
-
mr: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1228
|
-
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1229
|
-
return v !== null ? { marginRight: v } : null;
|
|
1230
|
-
},
|
|
1231
|
-
mb: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1232
|
-
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1233
|
-
return v !== null ? { marginBottom: v } : null;
|
|
1234
|
-
},
|
|
1235
|
-
ml: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1236
|
-
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1237
|
-
return v !== null ? { marginLeft: v } : null;
|
|
1238
|
-
},
|
|
1230
|
+
// ── Padding & margin ───────────────────────────────────────────────────────
|
|
1231
|
+
// Generated below via makeSpacingResolver() — see PADDING_MARGIN_PROPS.
|
|
1239
1232
|
// ── Sizing ─────────────────────────────────────────────────────────────────
|
|
1240
1233
|
w: ({ value, isArbitrary }, { spacing }) => {
|
|
1241
1234
|
const v = resolveSizing(value, spacing, isArbitrary);
|
|
@@ -1279,54 +1272,7 @@ var RESOLVERS = {
|
|
|
1279
1272
|
}
|
|
1280
1273
|
return null;
|
|
1281
1274
|
},
|
|
1282
|
-
|
|
1283
|
-
if (!value) return { borderTopWidth: 1 };
|
|
1284
|
-
if (isArbitrary) {
|
|
1285
|
-
const w2 = toNativeValue(value);
|
|
1286
|
-
if (typeof w2 === "number") return { borderTopWidth: w2 };
|
|
1287
|
-
return { borderTopColor: value };
|
|
1288
|
-
}
|
|
1289
|
-
const color = resolveColor(value, colors, false);
|
|
1290
|
-
if (color) return { borderTopColor: color };
|
|
1291
|
-
const w = borderWidth[value];
|
|
1292
|
-
return w !== void 0 ? { borderTopWidth: w } : null;
|
|
1293
|
-
},
|
|
1294
|
-
"border-r": ({ value, isArbitrary }, { colors, borderWidth }) => {
|
|
1295
|
-
if (!value) return { borderRightWidth: 1 };
|
|
1296
|
-
if (isArbitrary) {
|
|
1297
|
-
const w2 = toNativeValue(value);
|
|
1298
|
-
if (typeof w2 === "number") return { borderRightWidth: w2 };
|
|
1299
|
-
return { borderRightColor: value };
|
|
1300
|
-
}
|
|
1301
|
-
const color = resolveColor(value, colors, false);
|
|
1302
|
-
if (color) return { borderRightColor: color };
|
|
1303
|
-
const w = borderWidth[value];
|
|
1304
|
-
return w !== void 0 ? { borderRightWidth: w } : null;
|
|
1305
|
-
},
|
|
1306
|
-
"border-b": ({ value, isArbitrary }, { colors, borderWidth }) => {
|
|
1307
|
-
if (!value) return { borderBottomWidth: 1 };
|
|
1308
|
-
if (isArbitrary) {
|
|
1309
|
-
const w2 = toNativeValue(value);
|
|
1310
|
-
if (typeof w2 === "number") return { borderBottomWidth: w2 };
|
|
1311
|
-
return { borderBottomColor: value };
|
|
1312
|
-
}
|
|
1313
|
-
const color = resolveColor(value, colors, false);
|
|
1314
|
-
if (color) return { borderBottomColor: color };
|
|
1315
|
-
const w = borderWidth[value];
|
|
1316
|
-
return w !== void 0 ? { borderBottomWidth: w } : null;
|
|
1317
|
-
},
|
|
1318
|
-
"border-l": ({ value, isArbitrary }, { colors, borderWidth }) => {
|
|
1319
|
-
if (!value) return { borderLeftWidth: 1 };
|
|
1320
|
-
if (isArbitrary) {
|
|
1321
|
-
const w2 = toNativeValue(value);
|
|
1322
|
-
if (typeof w2 === "number") return { borderLeftWidth: w2 };
|
|
1323
|
-
return { borderLeftColor: value };
|
|
1324
|
-
}
|
|
1325
|
-
const color = resolveColor(value, colors, false);
|
|
1326
|
-
if (color) return { borderLeftColor: color };
|
|
1327
|
-
const w = borderWidth[value];
|
|
1328
|
-
return w !== void 0 ? { borderLeftWidth: w } : null;
|
|
1329
|
-
},
|
|
1275
|
+
// border-t/-r/-b/-l generated below via makeBorderSideResolver() — see BORDER_SIDE_PROPS.
|
|
1330
1276
|
// ── Border radius ──────────────────────────────────────────────────────────
|
|
1331
1277
|
rounded: ({ value, isArbitrary }, { borderRadius }) => {
|
|
1332
1278
|
const r = resolveRadius(value, borderRadius, isArbitrary);
|
|
@@ -1558,49 +1504,49 @@ var RESOLVERS = {
|
|
|
1558
1504
|
"2xl": "blur(40px)",
|
|
1559
1505
|
"3xl": "blur(64px)"
|
|
1560
1506
|
};
|
|
1561
|
-
if (value === "none") return { "--
|
|
1507
|
+
if (value === "none") return { "--kb-blur": "", filter: FILTER_COMPOSE };
|
|
1562
1508
|
const v = isArbitrary ? `blur(${value})` : sizes[value];
|
|
1563
|
-
return v !== void 0 ? { "--
|
|
1509
|
+
return v !== void 0 ? { "--kb-blur": v, filter: FILTER_COMPOSE } : null;
|
|
1564
1510
|
},
|
|
1565
1511
|
brightness: ({ value, isArbitrary }) => {
|
|
1566
1512
|
if (!getEffectiveIsWeb()) return null;
|
|
1567
1513
|
const v = isArbitrary ? `brightness(${value})` : `brightness(${parseFloat(value) / 100})`;
|
|
1568
|
-
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--
|
|
1514
|
+
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--kb-brightness": v, filter: FILTER_COMPOSE };
|
|
1569
1515
|
},
|
|
1570
1516
|
contrast: ({ value, isArbitrary }) => {
|
|
1571
1517
|
if (!getEffectiveIsWeb()) return null;
|
|
1572
1518
|
const v = isArbitrary ? `contrast(${value})` : `contrast(${parseFloat(value) / 100})`;
|
|
1573
|
-
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--
|
|
1519
|
+
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--kb-contrast": v, filter: FILTER_COMPOSE };
|
|
1574
1520
|
},
|
|
1575
1521
|
grayscale: ({ value }) => {
|
|
1576
1522
|
if (!getEffectiveIsWeb()) return null;
|
|
1577
1523
|
const v = value === "0" ? "grayscale(0)" : "grayscale(100%)";
|
|
1578
|
-
return { "--
|
|
1524
|
+
return { "--kb-grayscale": v, filter: FILTER_COMPOSE };
|
|
1579
1525
|
},
|
|
1580
1526
|
"hue-rotate": ({ value, negative, isArbitrary }) => {
|
|
1581
1527
|
if (!getEffectiveIsWeb()) return null;
|
|
1582
1528
|
const deg = isArbitrary ? value : `${(negative ? -1 : 1) * parseFloat(value)}deg`;
|
|
1583
1529
|
if (isNaN(parseFloat(deg)) && !isArbitrary) return null;
|
|
1584
|
-
return { "--
|
|
1530
|
+
return { "--kb-hue-rotate": `hue-rotate(${deg})`, filter: FILTER_COMPOSE };
|
|
1585
1531
|
},
|
|
1586
1532
|
invert: ({ value }) => {
|
|
1587
1533
|
if (!getEffectiveIsWeb()) return null;
|
|
1588
1534
|
const v = value === "0" ? "invert(0)" : "invert(100%)";
|
|
1589
|
-
return { "--
|
|
1535
|
+
return { "--kb-invert": v, filter: FILTER_COMPOSE };
|
|
1590
1536
|
},
|
|
1591
1537
|
saturate: ({ value, isArbitrary }) => {
|
|
1592
1538
|
if (!getEffectiveIsWeb()) return null;
|
|
1593
1539
|
const v = isArbitrary ? `saturate(${value})` : `saturate(${parseFloat(value) / 100})`;
|
|
1594
|
-
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--
|
|
1540
|
+
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--kb-saturate": v, filter: FILTER_COMPOSE };
|
|
1595
1541
|
},
|
|
1596
1542
|
sepia: ({ value }) => {
|
|
1597
1543
|
if (!getEffectiveIsWeb()) return null;
|
|
1598
1544
|
const v = value === "0" ? "sepia(0)" : "sepia(100%)";
|
|
1599
|
-
return { "--
|
|
1545
|
+
return { "--kb-sepia": v, filter: FILTER_COMPOSE };
|
|
1600
1546
|
},
|
|
1601
1547
|
"drop-shadow": ({ value, isArbitrary }) => {
|
|
1602
1548
|
if (!getEffectiveIsWeb()) return null;
|
|
1603
|
-
if (isArbitrary) return { "--
|
|
1549
|
+
if (isArbitrary) return { "--kb-drop-shadow": `drop-shadow(${value.replace(/_/g, " ")})`, filter: FILTER_COMPOSE };
|
|
1604
1550
|
const presets = {
|
|
1605
1551
|
"": "drop-shadow(0 1px 2px rgb(0 0 0/0.1)) drop-shadow(0 1px 1px rgb(0 0 0/0.06))",
|
|
1606
1552
|
sm: "drop-shadow(0 1px 1px rgb(0 0 0/0.05))",
|
|
@@ -1611,7 +1557,7 @@ var RESOLVERS = {
|
|
|
1611
1557
|
none: "drop-shadow(0 0 #0000)"
|
|
1612
1558
|
};
|
|
1613
1559
|
const v = presets[value];
|
|
1614
|
-
return v !== void 0 ? { "--
|
|
1560
|
+
return v !== void 0 ? { "--kb-drop-shadow": v, filter: FILTER_COMPOSE } : null;
|
|
1615
1561
|
},
|
|
1616
1562
|
// Arbitrary full filter string: filter-[blur(4px)_grayscale(1)]
|
|
1617
1563
|
filter: ({ value, isArbitrary }) => {
|
|
@@ -1632,47 +1578,47 @@ var RESOLVERS = {
|
|
|
1632
1578
|
"2xl": "blur(40px)",
|
|
1633
1579
|
"3xl": "blur(64px)"
|
|
1634
1580
|
};
|
|
1635
|
-
if (value === "none") return { "--
|
|
1581
|
+
if (value === "none") return { "--kb-backdrop-blur": "", backdropFilter: BACKDROP_FILTER_COMPOSE };
|
|
1636
1582
|
const v = isArbitrary ? `blur(${value})` : sizes[value];
|
|
1637
|
-
return v !== void 0 ? { "--
|
|
1583
|
+
return v !== void 0 ? { "--kb-backdrop-blur": v, backdropFilter: BACKDROP_FILTER_COMPOSE } : null;
|
|
1638
1584
|
},
|
|
1639
1585
|
"backdrop-brightness": ({ value, isArbitrary }) => {
|
|
1640
1586
|
if (!getEffectiveIsWeb()) return null;
|
|
1641
1587
|
const v = isArbitrary ? `brightness(${value})` : `brightness(${parseFloat(value) / 100})`;
|
|
1642
|
-
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--
|
|
1588
|
+
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--kb-backdrop-brightness": v, backdropFilter: BACKDROP_FILTER_COMPOSE };
|
|
1643
1589
|
},
|
|
1644
1590
|
"backdrop-contrast": ({ value, isArbitrary }) => {
|
|
1645
1591
|
if (!getEffectiveIsWeb()) return null;
|
|
1646
1592
|
const v = isArbitrary ? `contrast(${value})` : `contrast(${parseFloat(value) / 100})`;
|
|
1647
|
-
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--
|
|
1593
|
+
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--kb-backdrop-contrast": v, backdropFilter: BACKDROP_FILTER_COMPOSE };
|
|
1648
1594
|
},
|
|
1649
1595
|
"backdrop-grayscale": ({ value }) => {
|
|
1650
1596
|
if (!getEffectiveIsWeb()) return null;
|
|
1651
|
-
return { "--
|
|
1597
|
+
return { "--kb-backdrop-grayscale": value === "0" ? "grayscale(0)" : "grayscale(100%)", backdropFilter: BACKDROP_FILTER_COMPOSE };
|
|
1652
1598
|
},
|
|
1653
1599
|
"backdrop-hue-rotate": ({ value, negative, isArbitrary }) => {
|
|
1654
1600
|
if (!getEffectiveIsWeb()) return null;
|
|
1655
1601
|
const deg = isArbitrary ? value : `${(negative ? -1 : 1) * parseFloat(value)}deg`;
|
|
1656
1602
|
if (isNaN(parseFloat(deg)) && !isArbitrary) return null;
|
|
1657
|
-
return { "--
|
|
1603
|
+
return { "--kb-backdrop-hue-rotate": `hue-rotate(${deg})`, backdropFilter: BACKDROP_FILTER_COMPOSE };
|
|
1658
1604
|
},
|
|
1659
1605
|
"backdrop-invert": ({ value }) => {
|
|
1660
1606
|
if (!getEffectiveIsWeb()) return null;
|
|
1661
|
-
return { "--
|
|
1607
|
+
return { "--kb-backdrop-invert": value === "0" ? "invert(0)" : "invert(100%)", backdropFilter: BACKDROP_FILTER_COMPOSE };
|
|
1662
1608
|
},
|
|
1663
1609
|
"backdrop-opacity": ({ value, isArbitrary }) => {
|
|
1664
1610
|
if (!getEffectiveIsWeb()) return null;
|
|
1665
1611
|
const v = isArbitrary ? `opacity(${value})` : `opacity(${parseFloat(value) / 100})`;
|
|
1666
|
-
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--
|
|
1612
|
+
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--kb-backdrop-opacity": v, backdropFilter: BACKDROP_FILTER_COMPOSE };
|
|
1667
1613
|
},
|
|
1668
1614
|
"backdrop-saturate": ({ value, isArbitrary }) => {
|
|
1669
1615
|
if (!getEffectiveIsWeb()) return null;
|
|
1670
1616
|
const v = isArbitrary ? `saturate(${value})` : `saturate(${parseFloat(value) / 100})`;
|
|
1671
|
-
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--
|
|
1617
|
+
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--kb-backdrop-saturate": v, backdropFilter: BACKDROP_FILTER_COMPOSE };
|
|
1672
1618
|
},
|
|
1673
1619
|
"backdrop-sepia": ({ value }) => {
|
|
1674
1620
|
if (!getEffectiveIsWeb()) return null;
|
|
1675
|
-
return { "--
|
|
1621
|
+
return { "--kb-backdrop-sepia": value === "0" ? "sepia(0)" : "sepia(100%)", backdropFilter: BACKDROP_FILTER_COMPOSE };
|
|
1676
1622
|
},
|
|
1677
1623
|
"backdrop-filter": ({ value, isArbitrary }) => {
|
|
1678
1624
|
if (!getEffectiveIsWeb()) return null;
|
|
@@ -1696,7 +1642,7 @@ var RESOLVERS = {
|
|
|
1696
1642
|
const dir = directions[value];
|
|
1697
1643
|
if (!dir) return null;
|
|
1698
1644
|
return {
|
|
1699
|
-
backgroundImage: `linear-gradient(${dir}, var(--
|
|
1645
|
+
backgroundImage: `linear-gradient(${dir}, var(--kb-gradient-from, transparent), var(--kb-gradient-stops, transparent))`
|
|
1700
1646
|
};
|
|
1701
1647
|
},
|
|
1702
1648
|
from: ({ value, isArbitrary }, { colors }) => {
|
|
@@ -1704,8 +1650,8 @@ var RESOLVERS = {
|
|
|
1704
1650
|
const color = resolveColor(value, colors, isArbitrary);
|
|
1705
1651
|
if (!color) return null;
|
|
1706
1652
|
return {
|
|
1707
|
-
"--
|
|
1708
|
-
"--
|
|
1653
|
+
"--kb-gradient-from": color,
|
|
1654
|
+
"--kb-gradient-stops": `var(--kb-gradient-from), var(--kb-gradient-to, transparent)`
|
|
1709
1655
|
};
|
|
1710
1656
|
},
|
|
1711
1657
|
via: ({ value, isArbitrary }, { colors }) => {
|
|
@@ -1713,15 +1659,15 @@ var RESOLVERS = {
|
|
|
1713
1659
|
const color = resolveColor(value, colors, isArbitrary);
|
|
1714
1660
|
if (!color) return null;
|
|
1715
1661
|
return {
|
|
1716
|
-
"--
|
|
1717
|
-
"--
|
|
1662
|
+
"--kb-gradient-via": color,
|
|
1663
|
+
"--kb-gradient-stops": `var(--kb-gradient-from), var(--kb-gradient-via), var(--kb-gradient-to, transparent)`
|
|
1718
1664
|
};
|
|
1719
1665
|
},
|
|
1720
1666
|
to: ({ value, isArbitrary }, { colors }) => {
|
|
1721
1667
|
if (!getEffectiveIsWeb()) return null;
|
|
1722
1668
|
const color = resolveColor(value, colors, isArbitrary);
|
|
1723
1669
|
if (!color) return null;
|
|
1724
|
-
return { "--
|
|
1670
|
+
return { "--kb-gradient-to": color };
|
|
1725
1671
|
},
|
|
1726
1672
|
// ── Transform extras (web-only) ───────────────────────────────────────────
|
|
1727
1673
|
"skew-x": ({ value, negative, isArbitrary }) => {
|
|
@@ -2325,6 +2271,12 @@ var RESOLVERS = {
|
|
|
2325
2271
|
return { rowGap: v };
|
|
2326
2272
|
}
|
|
2327
2273
|
};
|
|
2274
|
+
for (const [utility, prop] of Object.entries(PADDING_MARGIN_PROPS)) {
|
|
2275
|
+
RESOLVERS[utility] = makeSpacingResolver(prop);
|
|
2276
|
+
}
|
|
2277
|
+
for (const [utility, [widthProp, colorProp]] of Object.entries(BORDER_SIDE_PROPS)) {
|
|
2278
|
+
RESOLVERS[utility] = makeBorderSideResolver(widthProp, colorProp);
|
|
2279
|
+
}
|
|
2328
2280
|
function resolveUtility(parsed, theme) {
|
|
2329
2281
|
if (!parsed.value) {
|
|
2330
2282
|
if (parsed.utility in PLUGIN_STANDALONE) return PLUGIN_STANDALONE[parsed.utility] ?? null;
|
|
@@ -2522,10 +2474,11 @@ var BASE_RESET = [
|
|
|
2522
2474
|
|
|
2523
2475
|
// src/core/cache.ts
|
|
2524
2476
|
var LRUCache = class {
|
|
2525
|
-
constructor(capacity = 1e4) {
|
|
2477
|
+
constructor(capacity = 1e4, onEvict) {
|
|
2526
2478
|
this.capacity = capacity;
|
|
2527
2479
|
if (capacity <= 0) throw new Error("LRUCache: capacity must be a positive integer");
|
|
2528
2480
|
this.cache = /* @__PURE__ */ new Map();
|
|
2481
|
+
this.onEvict = onEvict;
|
|
2529
2482
|
}
|
|
2530
2483
|
get(key) {
|
|
2531
2484
|
if (!this.cache.has(key)) return void 0;
|
|
@@ -2538,7 +2491,10 @@ var LRUCache = class {
|
|
|
2538
2491
|
if (this.cache.has(key)) {
|
|
2539
2492
|
this.cache.delete(key);
|
|
2540
2493
|
} else if (this.cache.size >= this.capacity) {
|
|
2541
|
-
this.cache.
|
|
2494
|
+
const oldestKey = this.cache.keys().next().value;
|
|
2495
|
+
const oldestValue = this.cache.get(oldestKey);
|
|
2496
|
+
this.cache.delete(oldestKey);
|
|
2497
|
+
this.onEvict?.(oldestKey, oldestValue);
|
|
2542
2498
|
}
|
|
2543
2499
|
this.cache.set(key, value);
|
|
2544
2500
|
return this;
|
|
@@ -2632,7 +2588,20 @@ function getDefaultFontFamily() {
|
|
|
2632
2588
|
return globalThis[FONT_KEY];
|
|
2633
2589
|
}
|
|
2634
2590
|
var _styleEl = null;
|
|
2635
|
-
|
|
2591
|
+
function evictInjectedRule(rule) {
|
|
2592
|
+
const sheet = _styleEl?.sheet;
|
|
2593
|
+
if (!sheet) return;
|
|
2594
|
+
for (let i = 0; i < sheet.cssRules.length; i++) {
|
|
2595
|
+
if (sheet.cssRules[i].cssText === rule) {
|
|
2596
|
+
try {
|
|
2597
|
+
sheet.deleteRule(i);
|
|
2598
|
+
} catch {
|
|
2599
|
+
}
|
|
2600
|
+
return;
|
|
2601
|
+
}
|
|
2602
|
+
}
|
|
2603
|
+
}
|
|
2604
|
+
var _injectedRules = new LRUCache(5e4, evictInjectedRule);
|
|
2636
2605
|
var _CSS_DISABLED_KEY = "__kbach_runtime_css_disabled__";
|
|
2637
2606
|
function disableRuntimeCSS() {
|
|
2638
2607
|
globalThis[_CSS_DISABLED_KEY] = true;
|
|
@@ -2669,8 +2638,7 @@ function injectGlobalStyles(theme) {
|
|
|
2669
2638
|
if (typeof document === "undefined" || isRuntimeCSSDisabled()) return;
|
|
2670
2639
|
const rules = [BASE_RESET];
|
|
2671
2640
|
const ff = theme.fontFamily;
|
|
2672
|
-
if (
|
|
2673
|
-
if (ff.sans && ff.sans !== "System") {
|
|
2641
|
+
if (ff?.sans && ff.sans !== "System") {
|
|
2674
2642
|
const family = Array.isArray(ff.sans) ? ff.sans.join(", ") : ff.sans;
|
|
2675
2643
|
rules.push(`body { font-family: ${family}; }`);
|
|
2676
2644
|
}
|
|
@@ -2833,7 +2801,7 @@ function buildClassCSSRules(cls, bucketKey, styles, darkMode, important, screens
|
|
|
2833
2801
|
else rule = `[data-theme="dark"] ${selector} { ${decls} }`;
|
|
2834
2802
|
} else if (darkScheme === "light") {
|
|
2835
2803
|
if (darkMode === "media") rule = `@media (prefers-color-scheme: light) { ${selector} { ${decls} } }`;
|
|
2836
|
-
else if (darkMode === "class") rule =
|
|
2804
|
+
else if (darkMode === "class") rule = `.light ${selector} { ${decls} }`;
|
|
2837
2805
|
else rule = `[data-theme="light"] ${selector} { ${decls} }`;
|
|
2838
2806
|
} else {
|
|
2839
2807
|
rule = `${selector} { ${decls} }`;
|
|
@@ -2974,11 +2942,14 @@ function getConfig() {
|
|
|
2974
2942
|
return store.resolved;
|
|
2975
2943
|
}
|
|
2976
2944
|
function resolveOneRef(ref, colors) {
|
|
2977
|
-
const
|
|
2978
|
-
if (
|
|
2979
|
-
const
|
|
2945
|
+
const lastDash = ref.lastIndexOf("-");
|
|
2946
|
+
if (lastDash <= 0) return null;
|
|
2947
|
+
const name = ref.slice(0, lastDash);
|
|
2948
|
+
const shade = ref.slice(lastDash + 1);
|
|
2949
|
+
if (!/^\d+$/.test(shade)) return null;
|
|
2950
|
+
const entry = colors[name];
|
|
2980
2951
|
if (!entry || typeof entry !== "object") return null;
|
|
2981
|
-
return entry[
|
|
2952
|
+
return entry[shade] ?? null;
|
|
2982
2953
|
}
|
|
2983
2954
|
function resolveColorRefs(colors) {
|
|
2984
2955
|
const MAX_DEPTH = 5;
|
|
@@ -3008,7 +2979,7 @@ function resolveColorRefs(colors) {
|
|
|
3008
2979
|
function buildConfig(userConfig) {
|
|
3009
2980
|
let theme = { ...defaultTheme };
|
|
3010
2981
|
if (userConfig.theme) {
|
|
3011
|
-
theme =
|
|
2982
|
+
theme = { ...theme, ...userConfig.theme };
|
|
3012
2983
|
}
|
|
3013
2984
|
if (userConfig.extend) {
|
|
3014
2985
|
const extendConfig = userConfig.extend;
|
|
@@ -3131,15 +3102,16 @@ var customVariants = new Proxy(
|
|
|
3131
3102
|
);
|
|
3132
3103
|
|
|
3133
3104
|
export {
|
|
3134
|
-
__require,
|
|
3135
3105
|
defaultColors,
|
|
3136
3106
|
defaultTheme,
|
|
3137
3107
|
isWeb,
|
|
3138
3108
|
isNative,
|
|
3109
|
+
setResolveTarget,
|
|
3139
3110
|
setCSSGenMode,
|
|
3140
3111
|
getInteractiveModifiers,
|
|
3141
3112
|
getModeModifiers,
|
|
3142
3113
|
getResponsiveModifiers,
|
|
3114
|
+
parseHexRgb,
|
|
3143
3115
|
parseClass,
|
|
3144
3116
|
splitClassTokens,
|
|
3145
3117
|
normalizeClassString,
|
|
@@ -3158,6 +3130,7 @@ export {
|
|
|
3158
3130
|
generateClassCSS,
|
|
3159
3131
|
resolve,
|
|
3160
3132
|
flatten,
|
|
3133
|
+
clearCache,
|
|
3161
3134
|
getConfig,
|
|
3162
3135
|
buildConfig,
|
|
3163
3136
|
onConfigChange,
|
package/dist/index.d.mts
CHANGED
|
@@ -7,6 +7,8 @@ export { r as registerWebElement } from './web-substitute-CfpYFnE7.mjs';
|
|
|
7
7
|
declare const defaultColors: ThemeColors;
|
|
8
8
|
declare const defaultTheme: ThemeConfig;
|
|
9
9
|
|
|
10
|
+
declare function setResolveTarget(target: 'web' | 'native' | null): void;
|
|
11
|
+
|
|
10
12
|
declare function parseClass(className: string): ParsedClass | null;
|
|
11
13
|
/**
|
|
12
14
|
* Split a class string into tokens. Whitespace at bracket depth > 0 is STRIPPED
|
|
@@ -48,6 +50,14 @@ declare function flatten(resolved: ResolvedStyle, isDark: boolean, state?: {
|
|
|
48
50
|
visited?: boolean;
|
|
49
51
|
placeholder?: boolean;
|
|
50
52
|
}, breakpoints?: Set<string>): StyleValue;
|
|
53
|
+
/**
|
|
54
|
+
* Clear CSS injection state so stale rules are re-injected when the theme changes.
|
|
55
|
+
*
|
|
56
|
+
* The per-theme style cache (WeakMap) does not need to be cleared manually:
|
|
57
|
+
* updateConfig() creates a new theme object, making the old cache entry
|
|
58
|
+
* automatically unreachable for GC.
|
|
59
|
+
*/
|
|
60
|
+
declare function clearCache(): void;
|
|
51
61
|
|
|
52
62
|
/**
|
|
53
63
|
* Load, merge, and cache the resolved config.
|
|
@@ -133,34 +143,6 @@ interface ThemeProviderProps {
|
|
|
133
143
|
}
|
|
134
144
|
declare function ThemeProvider({ children, defaultMode, colorScheme, windowWidth: windowWidthProp, config: configOverride, disablePersistence, }: ThemeProviderProps): React__default.JSX.Element;
|
|
135
145
|
|
|
136
|
-
type ToggleVariant = 'button' | 'switch' | 'icon-button';
|
|
137
|
-
interface ThemeToggleProps {
|
|
138
|
-
/** Visual variant. Default: 'button' */
|
|
139
|
-
variant?: ToggleVariant;
|
|
140
|
-
/** Override label text (button variant) */
|
|
141
|
-
label?: string;
|
|
142
|
-
/** Custom light-mode label */
|
|
143
|
-
lightLabel?: string;
|
|
144
|
-
/** Custom dark-mode label */
|
|
145
|
-
darkLabel?: string;
|
|
146
|
-
/** Show system mode option */
|
|
147
|
-
includeSystem?: boolean;
|
|
148
|
-
/** Custom styles applied to the root container */
|
|
149
|
-
style?: object;
|
|
150
|
-
/** Custom styles for the label text */
|
|
151
|
-
labelStyle?: object;
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Drop-in theme toggle. Works on web and React Native.
|
|
155
|
-
*
|
|
156
|
-
* ```tsx
|
|
157
|
-
* <ThemeToggle />
|
|
158
|
-
* <ThemeToggle variant="switch" />
|
|
159
|
-
* <ThemeToggle variant="icon-button" lightLabel="☀️" darkLabel="🌙" />
|
|
160
|
-
* ```
|
|
161
|
-
*/
|
|
162
|
-
declare function ThemeToggle({ variant, label, lightLabel, darkLabel, includeSystem, style, labelStyle, }: ThemeToggleProps): React__default.JSX.Element;
|
|
163
|
-
|
|
164
146
|
interface StyledProps {
|
|
165
147
|
/** Additional utility classes applied on top of the base classes */
|
|
166
148
|
kb?: string;
|
|
@@ -257,6 +239,7 @@ interface InteractiveWrapperProps {
|
|
|
257
239
|
onPointerDown?: (...args: any[]) => void;
|
|
258
240
|
onPointerUp?: (...args: any[]) => void;
|
|
259
241
|
onPointerLeave?: (...args: any[]) => void;
|
|
242
|
+
onPointerCancel?: (...args: any[]) => void;
|
|
260
243
|
onMouseEnter?: (...args: any[]) => void;
|
|
261
244
|
onMouseLeave?: (...args: any[]) => void;
|
|
262
245
|
onFocus?: (...args: any[]) => void;
|
|
@@ -306,4 +289,4 @@ declare function kb(classString: string, isDark?: boolean): StyleValue | string;
|
|
|
306
289
|
*/
|
|
307
290
|
declare function cx(...classes: Array<string | false | null | undefined>): string;
|
|
308
291
|
|
|
309
|
-
export { type ColorScale, type ColorsAPI, FrameworkConfig, type InteractionState, InteractiveWrapper, type InteractiveWrapperProps, ParsedClass, ResolvedConfig, ResolvedStyle, StyleValue, type StyledProps, ThemeConfig, ThemeContext, type ThemeContextValue, ThemeMode, ThemeProvider, type ThemeProviderProps,
|
|
292
|
+
export { type ColorScale, type ColorsAPI, FrameworkConfig, type InteractionState, InteractiveWrapper, type InteractiveWrapperProps, ParsedClass, ResolvedConfig, ResolvedStyle, StyleValue, type StyledProps, ThemeConfig, ThemeContext, type ThemeContextValue, ThemeMode, ThemeProvider, type ThemeProviderProps, buildConfig, clearCache, cx, defaultColors, defaultTheme, disableRuntimeCSS, flatten, getConfig, initConfig, kb, normalizeClassString, parseClass, parseClasses, resolve, setResolveTarget, splitClassTokens, styled, updateConfig, useBreakpoint, useColors, useGlobalDarkMode, useIsDark, useResolvedStyle, useResponsive, useStyles, useTheme, wrapColors };
|