@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/index.js
CHANGED
|
@@ -34,6 +34,7 @@ __export(index_exports, {
|
|
|
34
34
|
ThemeContext: () => ThemeContext,
|
|
35
35
|
ThemeProvider: () => ThemeProvider,
|
|
36
36
|
buildConfig: () => buildConfig,
|
|
37
|
+
clearCache: () => clearCache,
|
|
37
38
|
cx: () => cx,
|
|
38
39
|
defaultColors: () => defaultColors,
|
|
39
40
|
defaultTheme: () => defaultTheme,
|
|
@@ -47,6 +48,7 @@ __export(index_exports, {
|
|
|
47
48
|
parseClasses: () => parseClasses,
|
|
48
49
|
registerWebElement: () => registerWebElement,
|
|
49
50
|
resolve: () => resolve,
|
|
51
|
+
setResolveTarget: () => setResolveTarget,
|
|
50
52
|
splitClassTokens: () => splitClassTokens,
|
|
51
53
|
styled: () => styled,
|
|
52
54
|
updateConfig: () => updateConfig,
|
|
@@ -80,76 +82,6 @@ function useIsDark() {
|
|
|
80
82
|
|
|
81
83
|
// src/useColors.ts
|
|
82
84
|
var import_react2 = require("react");
|
|
83
|
-
function applyOpacity(color, opacity) {
|
|
84
|
-
const a = Math.max(0, Math.min(1, opacity / 100));
|
|
85
|
-
if (color.startsWith("#")) {
|
|
86
|
-
const h = color.slice(1);
|
|
87
|
-
let rs, gs, bs;
|
|
88
|
-
if (h.length === 3 || h.length === 4) {
|
|
89
|
-
rs = h[0] + h[0];
|
|
90
|
-
gs = h[1] + h[1];
|
|
91
|
-
bs = h[2] + h[2];
|
|
92
|
-
} else if (h.length === 8) {
|
|
93
|
-
rs = h.slice(0, 2);
|
|
94
|
-
gs = h.slice(2, 4);
|
|
95
|
-
bs = h.slice(4, 6);
|
|
96
|
-
} else {
|
|
97
|
-
rs = h.slice(0, 2);
|
|
98
|
-
gs = h.slice(2, 4);
|
|
99
|
-
bs = h.slice(4, 6);
|
|
100
|
-
}
|
|
101
|
-
return `rgba(${parseInt(rs, 16)},${parseInt(gs, 16)},${parseInt(bs, 16)},${a})`;
|
|
102
|
-
}
|
|
103
|
-
if (color.startsWith("rgb(")) return color.replace("rgb(", "rgba(").replace(")", `,${a})`);
|
|
104
|
-
if (color.startsWith("rgba(")) return color.replace(/,\s*[\d.]+\)$/, `,${a})`);
|
|
105
|
-
return color;
|
|
106
|
-
}
|
|
107
|
-
function makeShadeProxy(shades) {
|
|
108
|
-
return new Proxy(shades, {
|
|
109
|
-
get(target, prop) {
|
|
110
|
-
const key = String(prop);
|
|
111
|
-
if (key === "then") return void 0;
|
|
112
|
-
if (key.includes("/")) {
|
|
113
|
-
const slash = key.indexOf("/");
|
|
114
|
-
const shade = key.slice(0, slash);
|
|
115
|
-
const op = Number(key.slice(slash + 1));
|
|
116
|
-
const color = target[shade];
|
|
117
|
-
return typeof color === "string" ? applyOpacity(color, op) : void 0;
|
|
118
|
-
}
|
|
119
|
-
return target[key];
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
function wrapColors(rawColors) {
|
|
124
|
-
const cache = /* @__PURE__ */ new Map();
|
|
125
|
-
const alpha = (color, opacity) => opacity === void 0 ? color : applyOpacity(color, opacity);
|
|
126
|
-
return new Proxy({ alpha }, {
|
|
127
|
-
get(_, prop) {
|
|
128
|
-
const key = String(prop);
|
|
129
|
-
if (key === "then") return void 0;
|
|
130
|
-
if (key === "alpha") return alpha;
|
|
131
|
-
if (key.includes("/")) {
|
|
132
|
-
const slash = key.indexOf("/");
|
|
133
|
-
const name = key.slice(0, slash);
|
|
134
|
-
const op = Number(key.slice(slash + 1));
|
|
135
|
-
const entry2 = rawColors[name];
|
|
136
|
-
return typeof entry2 === "string" ? applyOpacity(entry2, op) : void 0;
|
|
137
|
-
}
|
|
138
|
-
const entry = rawColors[key];
|
|
139
|
-
if (entry === void 0) return void 0;
|
|
140
|
-
if (typeof entry === "string") return entry;
|
|
141
|
-
if (!cache.has(key)) cache.set(key, makeShadeProxy(entry));
|
|
142
|
-
return cache.get(key);
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
function useColors() {
|
|
147
|
-
const { config } = useTheme();
|
|
148
|
-
return (0, import_react2.useMemo)(() => wrapColors(config.theme.colors), [config.theme.colors]);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// src/ThemeProvider.tsx
|
|
152
|
-
var import_react3 = require("react");
|
|
153
85
|
|
|
154
86
|
// src/core/theme.ts
|
|
155
87
|
var defaultColors = {
|
|
@@ -693,10 +625,11 @@ var defaultTheme = {
|
|
|
693
625
|
|
|
694
626
|
// src/core/cache.ts
|
|
695
627
|
var LRUCache = class {
|
|
696
|
-
constructor(capacity = 1e4) {
|
|
628
|
+
constructor(capacity = 1e4, onEvict) {
|
|
697
629
|
this.capacity = capacity;
|
|
698
630
|
if (capacity <= 0) throw new Error("LRUCache: capacity must be a positive integer");
|
|
699
631
|
this.cache = /* @__PURE__ */ new Map();
|
|
632
|
+
this.onEvict = onEvict;
|
|
700
633
|
}
|
|
701
634
|
get(key) {
|
|
702
635
|
if (!this.cache.has(key)) return void 0;
|
|
@@ -709,7 +642,10 @@ var LRUCache = class {
|
|
|
709
642
|
if (this.cache.has(key)) {
|
|
710
643
|
this.cache.delete(key);
|
|
711
644
|
} else if (this.cache.size >= this.capacity) {
|
|
712
|
-
this.cache.
|
|
645
|
+
const oldestKey = this.cache.keys().next().value;
|
|
646
|
+
const oldestValue = this.cache.get(oldestKey);
|
|
647
|
+
this.cache.delete(oldestKey);
|
|
648
|
+
this.onEvict?.(oldestKey, oldestValue);
|
|
713
649
|
}
|
|
714
650
|
this.cache.set(key, value);
|
|
715
651
|
return this;
|
|
@@ -731,9 +667,13 @@ var LRUCache = class {
|
|
|
731
667
|
// src/core/platform.ts
|
|
732
668
|
var isWeb = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
733
669
|
var isNative = !isWeb && (typeof globalThis.HermesInternal !== "undefined" || typeof globalThis.__fbBatchedBridge !== "undefined" || typeof navigator !== "undefined" && navigator.product === "ReactNative" || typeof globalThis.__REACT_NATIVE__ !== "undefined");
|
|
734
|
-
var
|
|
670
|
+
var _resolveTargetOverride = null;
|
|
671
|
+
function setResolveTarget(target) {
|
|
672
|
+
_resolveTargetOverride = target;
|
|
673
|
+
}
|
|
735
674
|
function getEffectiveIsWeb() {
|
|
736
|
-
|
|
675
|
+
if (_resolveTargetOverride) return _resolveTargetOverride === "web";
|
|
676
|
+
return isWeb || !isNative;
|
|
737
677
|
}
|
|
738
678
|
function toNativeValue(raw) {
|
|
739
679
|
if (/^-?\d+(\.\d+)?px$/.test(raw)) return parseFloat(raw);
|
|
@@ -914,18 +854,28 @@ function resolveColor(value, colors, isArbitrary) {
|
|
|
914
854
|
if (isNaN(alpha)) return hex;
|
|
915
855
|
return hexToRgba(hex, alpha);
|
|
916
856
|
}
|
|
917
|
-
function
|
|
857
|
+
function parseHexRgb(hex) {
|
|
918
858
|
const h = hex.replace("#", "");
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
r = parseInt(h.slice(0, 2), 16);
|
|
926
|
-
g = parseInt(h.slice(2, 4), 16);
|
|
927
|
-
b = parseInt(h.slice(4, 6), 16);
|
|
859
|
+
if (h.length === 3 || h.length === 4) {
|
|
860
|
+
return [
|
|
861
|
+
parseInt(h[0] + h[0], 16),
|
|
862
|
+
parseInt(h[1] + h[1], 16),
|
|
863
|
+
parseInt(h[2] + h[2], 16)
|
|
864
|
+
];
|
|
928
865
|
}
|
|
866
|
+
if (h.length === 6 || h.length === 8) {
|
|
867
|
+
return [
|
|
868
|
+
parseInt(h.slice(0, 2), 16),
|
|
869
|
+
parseInt(h.slice(2, 4), 16),
|
|
870
|
+
parseInt(h.slice(4, 6), 16)
|
|
871
|
+
];
|
|
872
|
+
}
|
|
873
|
+
return null;
|
|
874
|
+
}
|
|
875
|
+
function hexToRgba(hex, alpha) {
|
|
876
|
+
const rgb = parseHexRgb(hex);
|
|
877
|
+
if (!rgb) return hex;
|
|
878
|
+
const [r, g, b] = rgb;
|
|
929
879
|
return `rgba(${r},${g},${b},${alpha})`;
|
|
930
880
|
}
|
|
931
881
|
function resolveSpacing(value, negative, spacing, isArbitrary) {
|
|
@@ -969,8 +919,8 @@ function resolveFontSize(value, fontSizes, isArbitrary) {
|
|
|
969
919
|
if (isArbitrary) return getEffectiveIsWeb() ? value : toNativeValue(value);
|
|
970
920
|
return fontSizes[value] ?? null;
|
|
971
921
|
}
|
|
972
|
-
var FILTER_COMPOSE = "var(--
|
|
973
|
-
var BACKDROP_FILTER_COMPOSE = "var(--
|
|
922
|
+
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,)";
|
|
923
|
+
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,)";
|
|
974
924
|
var _standalone = null;
|
|
975
925
|
function buildStandalone() {
|
|
976
926
|
const web = getEffectiveIsWeb();
|
|
@@ -1232,9 +1182,9 @@ function buildStandalone() {
|
|
|
1232
1182
|
"backface-visible": { backfaceVisibility: "visible" },
|
|
1233
1183
|
"backface-hidden": { backfaceVisibility: "hidden" },
|
|
1234
1184
|
// CSS filters — standalone = default/full effect (web-only)
|
|
1235
|
-
grayscale: web ? { "--
|
|
1236
|
-
invert: web ? { "--
|
|
1237
|
-
sepia: web ? { "--
|
|
1185
|
+
grayscale: web ? { "--kb-grayscale": "grayscale(100%)", filter: FILTER_COMPOSE } : null,
|
|
1186
|
+
invert: web ? { "--kb-invert": "invert(100%)", filter: FILTER_COMPOSE } : null,
|
|
1187
|
+
sepia: web ? { "--kb-sepia": "sepia(100%)", filter: FILTER_COMPOSE } : null,
|
|
1238
1188
|
// Divide none
|
|
1239
1189
|
"divide-none": web ? { __divideX: 0, __divideY: 0 } : null,
|
|
1240
1190
|
// Group / peer markers (no-op: no style emitted; just ensures isKnownUtility returns true)
|
|
@@ -1319,6 +1269,48 @@ function getStandalone() {
|
|
|
1319
1269
|
if (!_standalone) _standalone = buildStandalone();
|
|
1320
1270
|
return _standalone;
|
|
1321
1271
|
}
|
|
1272
|
+
function makeSpacingResolver(prop) {
|
|
1273
|
+
return ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1274
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1275
|
+
return v !== null ? { [prop]: v } : null;
|
|
1276
|
+
};
|
|
1277
|
+
}
|
|
1278
|
+
var PADDING_MARGIN_PROPS = {
|
|
1279
|
+
p: "padding",
|
|
1280
|
+
px: "paddingHorizontal",
|
|
1281
|
+
py: "paddingVertical",
|
|
1282
|
+
pt: "paddingTop",
|
|
1283
|
+
pr: "paddingRight",
|
|
1284
|
+
pb: "paddingBottom",
|
|
1285
|
+
pl: "paddingLeft",
|
|
1286
|
+
m: "margin",
|
|
1287
|
+
mx: "marginHorizontal",
|
|
1288
|
+
my: "marginVertical",
|
|
1289
|
+
mt: "marginTop",
|
|
1290
|
+
mr: "marginRight",
|
|
1291
|
+
mb: "marginBottom",
|
|
1292
|
+
ml: "marginLeft"
|
|
1293
|
+
};
|
|
1294
|
+
function makeBorderSideResolver(widthProp, colorProp) {
|
|
1295
|
+
return ({ value, isArbitrary }, { colors, borderWidth }) => {
|
|
1296
|
+
if (!value) return { [widthProp]: 1 };
|
|
1297
|
+
if (isArbitrary) {
|
|
1298
|
+
const w2 = toNativeValue(value);
|
|
1299
|
+
if (typeof w2 === "number") return { [widthProp]: w2 };
|
|
1300
|
+
return { [colorProp]: value };
|
|
1301
|
+
}
|
|
1302
|
+
const color = resolveColor(value, colors, false);
|
|
1303
|
+
if (color) return { [colorProp]: color };
|
|
1304
|
+
const w = borderWidth[value];
|
|
1305
|
+
return w !== void 0 ? { [widthProp]: w } : null;
|
|
1306
|
+
};
|
|
1307
|
+
}
|
|
1308
|
+
var BORDER_SIDE_PROPS = {
|
|
1309
|
+
"border-t": ["borderTopWidth", "borderTopColor"],
|
|
1310
|
+
"border-r": ["borderRightWidth", "borderRightColor"],
|
|
1311
|
+
"border-b": ["borderBottomWidth", "borderBottomColor"],
|
|
1312
|
+
"border-l": ["borderLeftWidth", "borderLeftColor"]
|
|
1313
|
+
};
|
|
1322
1314
|
var RESOLVERS = {
|
|
1323
1315
|
// ── Background ─────────────────────────────────────────────────────────────
|
|
1324
1316
|
bg: ({ value, isArbitrary }, { colors }) => {
|
|
@@ -1352,64 +1344,8 @@ var RESOLVERS = {
|
|
|
1352
1344
|
const v = isArbitrary ? n > 1 ? n / 100 : n : n / 100;
|
|
1353
1345
|
return { "--text-opacity": v };
|
|
1354
1346
|
},
|
|
1355
|
-
// ── Padding
|
|
1356
|
-
|
|
1357
|
-
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1358
|
-
return v !== null ? { padding: v } : null;
|
|
1359
|
-
},
|
|
1360
|
-
px: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1361
|
-
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1362
|
-
return v !== null ? { paddingHorizontal: v } : null;
|
|
1363
|
-
},
|
|
1364
|
-
py: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1365
|
-
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1366
|
-
return v !== null ? { paddingVertical: v } : null;
|
|
1367
|
-
},
|
|
1368
|
-
pt: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1369
|
-
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1370
|
-
return v !== null ? { paddingTop: v } : null;
|
|
1371
|
-
},
|
|
1372
|
-
pr: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1373
|
-
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1374
|
-
return v !== null ? { paddingRight: v } : null;
|
|
1375
|
-
},
|
|
1376
|
-
pb: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1377
|
-
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1378
|
-
return v !== null ? { paddingBottom: v } : null;
|
|
1379
|
-
},
|
|
1380
|
-
pl: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1381
|
-
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1382
|
-
return v !== null ? { paddingLeft: v } : null;
|
|
1383
|
-
},
|
|
1384
|
-
// ── Margin ─────────────────────────────────────────────────────────────────
|
|
1385
|
-
m: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1386
|
-
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1387
|
-
return v !== null ? { margin: v } : null;
|
|
1388
|
-
},
|
|
1389
|
-
mx: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1390
|
-
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1391
|
-
return v !== null ? { marginHorizontal: v } : null;
|
|
1392
|
-
},
|
|
1393
|
-
my: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1394
|
-
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1395
|
-
return v !== null ? { marginVertical: v } : null;
|
|
1396
|
-
},
|
|
1397
|
-
mt: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1398
|
-
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1399
|
-
return v !== null ? { marginTop: v } : null;
|
|
1400
|
-
},
|
|
1401
|
-
mr: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1402
|
-
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1403
|
-
return v !== null ? { marginRight: v } : null;
|
|
1404
|
-
},
|
|
1405
|
-
mb: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1406
|
-
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1407
|
-
return v !== null ? { marginBottom: v } : null;
|
|
1408
|
-
},
|
|
1409
|
-
ml: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1410
|
-
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1411
|
-
return v !== null ? { marginLeft: v } : null;
|
|
1412
|
-
},
|
|
1347
|
+
// ── Padding & margin ───────────────────────────────────────────────────────
|
|
1348
|
+
// Generated below via makeSpacingResolver() — see PADDING_MARGIN_PROPS.
|
|
1413
1349
|
// ── Sizing ─────────────────────────────────────────────────────────────────
|
|
1414
1350
|
w: ({ value, isArbitrary }, { spacing }) => {
|
|
1415
1351
|
const v = resolveSizing(value, spacing, isArbitrary);
|
|
@@ -1453,54 +1389,7 @@ var RESOLVERS = {
|
|
|
1453
1389
|
}
|
|
1454
1390
|
return null;
|
|
1455
1391
|
},
|
|
1456
|
-
|
|
1457
|
-
if (!value) return { borderTopWidth: 1 };
|
|
1458
|
-
if (isArbitrary) {
|
|
1459
|
-
const w2 = toNativeValue(value);
|
|
1460
|
-
if (typeof w2 === "number") return { borderTopWidth: w2 };
|
|
1461
|
-
return { borderTopColor: value };
|
|
1462
|
-
}
|
|
1463
|
-
const color = resolveColor(value, colors, false);
|
|
1464
|
-
if (color) return { borderTopColor: color };
|
|
1465
|
-
const w = borderWidth[value];
|
|
1466
|
-
return w !== void 0 ? { borderTopWidth: w } : null;
|
|
1467
|
-
},
|
|
1468
|
-
"border-r": ({ value, isArbitrary }, { colors, borderWidth }) => {
|
|
1469
|
-
if (!value) return { borderRightWidth: 1 };
|
|
1470
|
-
if (isArbitrary) {
|
|
1471
|
-
const w2 = toNativeValue(value);
|
|
1472
|
-
if (typeof w2 === "number") return { borderRightWidth: w2 };
|
|
1473
|
-
return { borderRightColor: value };
|
|
1474
|
-
}
|
|
1475
|
-
const color = resolveColor(value, colors, false);
|
|
1476
|
-
if (color) return { borderRightColor: color };
|
|
1477
|
-
const w = borderWidth[value];
|
|
1478
|
-
return w !== void 0 ? { borderRightWidth: w } : null;
|
|
1479
|
-
},
|
|
1480
|
-
"border-b": ({ value, isArbitrary }, { colors, borderWidth }) => {
|
|
1481
|
-
if (!value) return { borderBottomWidth: 1 };
|
|
1482
|
-
if (isArbitrary) {
|
|
1483
|
-
const w2 = toNativeValue(value);
|
|
1484
|
-
if (typeof w2 === "number") return { borderBottomWidth: w2 };
|
|
1485
|
-
return { borderBottomColor: value };
|
|
1486
|
-
}
|
|
1487
|
-
const color = resolveColor(value, colors, false);
|
|
1488
|
-
if (color) return { borderBottomColor: color };
|
|
1489
|
-
const w = borderWidth[value];
|
|
1490
|
-
return w !== void 0 ? { borderBottomWidth: w } : null;
|
|
1491
|
-
},
|
|
1492
|
-
"border-l": ({ value, isArbitrary }, { colors, borderWidth }) => {
|
|
1493
|
-
if (!value) return { borderLeftWidth: 1 };
|
|
1494
|
-
if (isArbitrary) {
|
|
1495
|
-
const w2 = toNativeValue(value);
|
|
1496
|
-
if (typeof w2 === "number") return { borderLeftWidth: w2 };
|
|
1497
|
-
return { borderLeftColor: value };
|
|
1498
|
-
}
|
|
1499
|
-
const color = resolveColor(value, colors, false);
|
|
1500
|
-
if (color) return { borderLeftColor: color };
|
|
1501
|
-
const w = borderWidth[value];
|
|
1502
|
-
return w !== void 0 ? { borderLeftWidth: w } : null;
|
|
1503
|
-
},
|
|
1392
|
+
// border-t/-r/-b/-l generated below via makeBorderSideResolver() — see BORDER_SIDE_PROPS.
|
|
1504
1393
|
// ── Border radius ──────────────────────────────────────────────────────────
|
|
1505
1394
|
rounded: ({ value, isArbitrary }, { borderRadius }) => {
|
|
1506
1395
|
const r = resolveRadius(value, borderRadius, isArbitrary);
|
|
@@ -1732,49 +1621,49 @@ var RESOLVERS = {
|
|
|
1732
1621
|
"2xl": "blur(40px)",
|
|
1733
1622
|
"3xl": "blur(64px)"
|
|
1734
1623
|
};
|
|
1735
|
-
if (value === "none") return { "--
|
|
1624
|
+
if (value === "none") return { "--kb-blur": "", filter: FILTER_COMPOSE };
|
|
1736
1625
|
const v = isArbitrary ? `blur(${value})` : sizes[value];
|
|
1737
|
-
return v !== void 0 ? { "--
|
|
1626
|
+
return v !== void 0 ? { "--kb-blur": v, filter: FILTER_COMPOSE } : null;
|
|
1738
1627
|
},
|
|
1739
1628
|
brightness: ({ value, isArbitrary }) => {
|
|
1740
1629
|
if (!getEffectiveIsWeb()) return null;
|
|
1741
1630
|
const v = isArbitrary ? `brightness(${value})` : `brightness(${parseFloat(value) / 100})`;
|
|
1742
|
-
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--
|
|
1631
|
+
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--kb-brightness": v, filter: FILTER_COMPOSE };
|
|
1743
1632
|
},
|
|
1744
1633
|
contrast: ({ value, isArbitrary }) => {
|
|
1745
1634
|
if (!getEffectiveIsWeb()) return null;
|
|
1746
1635
|
const v = isArbitrary ? `contrast(${value})` : `contrast(${parseFloat(value) / 100})`;
|
|
1747
|
-
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--
|
|
1636
|
+
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--kb-contrast": v, filter: FILTER_COMPOSE };
|
|
1748
1637
|
},
|
|
1749
1638
|
grayscale: ({ value }) => {
|
|
1750
1639
|
if (!getEffectiveIsWeb()) return null;
|
|
1751
1640
|
const v = value === "0" ? "grayscale(0)" : "grayscale(100%)";
|
|
1752
|
-
return { "--
|
|
1641
|
+
return { "--kb-grayscale": v, filter: FILTER_COMPOSE };
|
|
1753
1642
|
},
|
|
1754
1643
|
"hue-rotate": ({ value, negative, isArbitrary }) => {
|
|
1755
1644
|
if (!getEffectiveIsWeb()) return null;
|
|
1756
1645
|
const deg = isArbitrary ? value : `${(negative ? -1 : 1) * parseFloat(value)}deg`;
|
|
1757
1646
|
if (isNaN(parseFloat(deg)) && !isArbitrary) return null;
|
|
1758
|
-
return { "--
|
|
1647
|
+
return { "--kb-hue-rotate": `hue-rotate(${deg})`, filter: FILTER_COMPOSE };
|
|
1759
1648
|
},
|
|
1760
1649
|
invert: ({ value }) => {
|
|
1761
1650
|
if (!getEffectiveIsWeb()) return null;
|
|
1762
1651
|
const v = value === "0" ? "invert(0)" : "invert(100%)";
|
|
1763
|
-
return { "--
|
|
1652
|
+
return { "--kb-invert": v, filter: FILTER_COMPOSE };
|
|
1764
1653
|
},
|
|
1765
1654
|
saturate: ({ value, isArbitrary }) => {
|
|
1766
1655
|
if (!getEffectiveIsWeb()) return null;
|
|
1767
1656
|
const v = isArbitrary ? `saturate(${value})` : `saturate(${parseFloat(value) / 100})`;
|
|
1768
|
-
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--
|
|
1657
|
+
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--kb-saturate": v, filter: FILTER_COMPOSE };
|
|
1769
1658
|
},
|
|
1770
1659
|
sepia: ({ value }) => {
|
|
1771
1660
|
if (!getEffectiveIsWeb()) return null;
|
|
1772
1661
|
const v = value === "0" ? "sepia(0)" : "sepia(100%)";
|
|
1773
|
-
return { "--
|
|
1662
|
+
return { "--kb-sepia": v, filter: FILTER_COMPOSE };
|
|
1774
1663
|
},
|
|
1775
1664
|
"drop-shadow": ({ value, isArbitrary }) => {
|
|
1776
1665
|
if (!getEffectiveIsWeb()) return null;
|
|
1777
|
-
if (isArbitrary) return { "--
|
|
1666
|
+
if (isArbitrary) return { "--kb-drop-shadow": `drop-shadow(${value.replace(/_/g, " ")})`, filter: FILTER_COMPOSE };
|
|
1778
1667
|
const presets = {
|
|
1779
1668
|
"": "drop-shadow(0 1px 2px rgb(0 0 0/0.1)) drop-shadow(0 1px 1px rgb(0 0 0/0.06))",
|
|
1780
1669
|
sm: "drop-shadow(0 1px 1px rgb(0 0 0/0.05))",
|
|
@@ -1785,7 +1674,7 @@ var RESOLVERS = {
|
|
|
1785
1674
|
none: "drop-shadow(0 0 #0000)"
|
|
1786
1675
|
};
|
|
1787
1676
|
const v = presets[value];
|
|
1788
|
-
return v !== void 0 ? { "--
|
|
1677
|
+
return v !== void 0 ? { "--kb-drop-shadow": v, filter: FILTER_COMPOSE } : null;
|
|
1789
1678
|
},
|
|
1790
1679
|
// Arbitrary full filter string: filter-[blur(4px)_grayscale(1)]
|
|
1791
1680
|
filter: ({ value, isArbitrary }) => {
|
|
@@ -1806,47 +1695,47 @@ var RESOLVERS = {
|
|
|
1806
1695
|
"2xl": "blur(40px)",
|
|
1807
1696
|
"3xl": "blur(64px)"
|
|
1808
1697
|
};
|
|
1809
|
-
if (value === "none") return { "--
|
|
1698
|
+
if (value === "none") return { "--kb-backdrop-blur": "", backdropFilter: BACKDROP_FILTER_COMPOSE };
|
|
1810
1699
|
const v = isArbitrary ? `blur(${value})` : sizes[value];
|
|
1811
|
-
return v !== void 0 ? { "--
|
|
1700
|
+
return v !== void 0 ? { "--kb-backdrop-blur": v, backdropFilter: BACKDROP_FILTER_COMPOSE } : null;
|
|
1812
1701
|
},
|
|
1813
1702
|
"backdrop-brightness": ({ value, isArbitrary }) => {
|
|
1814
1703
|
if (!getEffectiveIsWeb()) return null;
|
|
1815
1704
|
const v = isArbitrary ? `brightness(${value})` : `brightness(${parseFloat(value) / 100})`;
|
|
1816
|
-
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--
|
|
1705
|
+
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--kb-backdrop-brightness": v, backdropFilter: BACKDROP_FILTER_COMPOSE };
|
|
1817
1706
|
},
|
|
1818
1707
|
"backdrop-contrast": ({ value, isArbitrary }) => {
|
|
1819
1708
|
if (!getEffectiveIsWeb()) return null;
|
|
1820
1709
|
const v = isArbitrary ? `contrast(${value})` : `contrast(${parseFloat(value) / 100})`;
|
|
1821
|
-
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--
|
|
1710
|
+
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--kb-backdrop-contrast": v, backdropFilter: BACKDROP_FILTER_COMPOSE };
|
|
1822
1711
|
},
|
|
1823
1712
|
"backdrop-grayscale": ({ value }) => {
|
|
1824
1713
|
if (!getEffectiveIsWeb()) return null;
|
|
1825
|
-
return { "--
|
|
1714
|
+
return { "--kb-backdrop-grayscale": value === "0" ? "grayscale(0)" : "grayscale(100%)", backdropFilter: BACKDROP_FILTER_COMPOSE };
|
|
1826
1715
|
},
|
|
1827
1716
|
"backdrop-hue-rotate": ({ value, negative, isArbitrary }) => {
|
|
1828
1717
|
if (!getEffectiveIsWeb()) return null;
|
|
1829
1718
|
const deg = isArbitrary ? value : `${(negative ? -1 : 1) * parseFloat(value)}deg`;
|
|
1830
1719
|
if (isNaN(parseFloat(deg)) && !isArbitrary) return null;
|
|
1831
|
-
return { "--
|
|
1720
|
+
return { "--kb-backdrop-hue-rotate": `hue-rotate(${deg})`, backdropFilter: BACKDROP_FILTER_COMPOSE };
|
|
1832
1721
|
},
|
|
1833
1722
|
"backdrop-invert": ({ value }) => {
|
|
1834
1723
|
if (!getEffectiveIsWeb()) return null;
|
|
1835
|
-
return { "--
|
|
1724
|
+
return { "--kb-backdrop-invert": value === "0" ? "invert(0)" : "invert(100%)", backdropFilter: BACKDROP_FILTER_COMPOSE };
|
|
1836
1725
|
},
|
|
1837
1726
|
"backdrop-opacity": ({ value, isArbitrary }) => {
|
|
1838
1727
|
if (!getEffectiveIsWeb()) return null;
|
|
1839
1728
|
const v = isArbitrary ? `opacity(${value})` : `opacity(${parseFloat(value) / 100})`;
|
|
1840
|
-
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--
|
|
1729
|
+
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--kb-backdrop-opacity": v, backdropFilter: BACKDROP_FILTER_COMPOSE };
|
|
1841
1730
|
},
|
|
1842
1731
|
"backdrop-saturate": ({ value, isArbitrary }) => {
|
|
1843
1732
|
if (!getEffectiveIsWeb()) return null;
|
|
1844
1733
|
const v = isArbitrary ? `saturate(${value})` : `saturate(${parseFloat(value) / 100})`;
|
|
1845
|
-
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--
|
|
1734
|
+
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--kb-backdrop-saturate": v, backdropFilter: BACKDROP_FILTER_COMPOSE };
|
|
1846
1735
|
},
|
|
1847
1736
|
"backdrop-sepia": ({ value }) => {
|
|
1848
1737
|
if (!getEffectiveIsWeb()) return null;
|
|
1849
|
-
return { "--
|
|
1738
|
+
return { "--kb-backdrop-sepia": value === "0" ? "sepia(0)" : "sepia(100%)", backdropFilter: BACKDROP_FILTER_COMPOSE };
|
|
1850
1739
|
},
|
|
1851
1740
|
"backdrop-filter": ({ value, isArbitrary }) => {
|
|
1852
1741
|
if (!getEffectiveIsWeb()) return null;
|
|
@@ -1870,7 +1759,7 @@ var RESOLVERS = {
|
|
|
1870
1759
|
const dir = directions[value];
|
|
1871
1760
|
if (!dir) return null;
|
|
1872
1761
|
return {
|
|
1873
|
-
backgroundImage: `linear-gradient(${dir}, var(--
|
|
1762
|
+
backgroundImage: `linear-gradient(${dir}, var(--kb-gradient-from, transparent), var(--kb-gradient-stops, transparent))`
|
|
1874
1763
|
};
|
|
1875
1764
|
},
|
|
1876
1765
|
from: ({ value, isArbitrary }, { colors }) => {
|
|
@@ -1878,8 +1767,8 @@ var RESOLVERS = {
|
|
|
1878
1767
|
const color = resolveColor(value, colors, isArbitrary);
|
|
1879
1768
|
if (!color) return null;
|
|
1880
1769
|
return {
|
|
1881
|
-
"--
|
|
1882
|
-
"--
|
|
1770
|
+
"--kb-gradient-from": color,
|
|
1771
|
+
"--kb-gradient-stops": `var(--kb-gradient-from), var(--kb-gradient-to, transparent)`
|
|
1883
1772
|
};
|
|
1884
1773
|
},
|
|
1885
1774
|
via: ({ value, isArbitrary }, { colors }) => {
|
|
@@ -1887,15 +1776,15 @@ var RESOLVERS = {
|
|
|
1887
1776
|
const color = resolveColor(value, colors, isArbitrary);
|
|
1888
1777
|
if (!color) return null;
|
|
1889
1778
|
return {
|
|
1890
|
-
"--
|
|
1891
|
-
"--
|
|
1779
|
+
"--kb-gradient-via": color,
|
|
1780
|
+
"--kb-gradient-stops": `var(--kb-gradient-from), var(--kb-gradient-via), var(--kb-gradient-to, transparent)`
|
|
1892
1781
|
};
|
|
1893
1782
|
},
|
|
1894
1783
|
to: ({ value, isArbitrary }, { colors }) => {
|
|
1895
1784
|
if (!getEffectiveIsWeb()) return null;
|
|
1896
1785
|
const color = resolveColor(value, colors, isArbitrary);
|
|
1897
1786
|
if (!color) return null;
|
|
1898
|
-
return { "--
|
|
1787
|
+
return { "--kb-gradient-to": color };
|
|
1899
1788
|
},
|
|
1900
1789
|
// ── Transform extras (web-only) ───────────────────────────────────────────
|
|
1901
1790
|
"skew-x": ({ value, negative, isArbitrary }) => {
|
|
@@ -2499,6 +2388,12 @@ var RESOLVERS = {
|
|
|
2499
2388
|
return { rowGap: v };
|
|
2500
2389
|
}
|
|
2501
2390
|
};
|
|
2391
|
+
for (const [utility, prop] of Object.entries(PADDING_MARGIN_PROPS)) {
|
|
2392
|
+
RESOLVERS[utility] = makeSpacingResolver(prop);
|
|
2393
|
+
}
|
|
2394
|
+
for (const [utility, [widthProp, colorProp]] of Object.entries(BORDER_SIDE_PROPS)) {
|
|
2395
|
+
RESOLVERS[utility] = makeBorderSideResolver(widthProp, colorProp);
|
|
2396
|
+
}
|
|
2502
2397
|
function resolveUtility(parsed, theme) {
|
|
2503
2398
|
if (!parsed.value) {
|
|
2504
2399
|
if (parsed.utility in PLUGIN_STANDALONE) return PLUGIN_STANDALONE[parsed.utility] ?? null;
|
|
@@ -2769,7 +2664,20 @@ function getDefaultFontFamily() {
|
|
|
2769
2664
|
return globalThis[FONT_KEY];
|
|
2770
2665
|
}
|
|
2771
2666
|
var _styleEl = null;
|
|
2772
|
-
|
|
2667
|
+
function evictInjectedRule(rule) {
|
|
2668
|
+
const sheet = _styleEl?.sheet;
|
|
2669
|
+
if (!sheet) return;
|
|
2670
|
+
for (let i = 0; i < sheet.cssRules.length; i++) {
|
|
2671
|
+
if (sheet.cssRules[i].cssText === rule) {
|
|
2672
|
+
try {
|
|
2673
|
+
sheet.deleteRule(i);
|
|
2674
|
+
} catch {
|
|
2675
|
+
}
|
|
2676
|
+
return;
|
|
2677
|
+
}
|
|
2678
|
+
}
|
|
2679
|
+
}
|
|
2680
|
+
var _injectedRules = new LRUCache(5e4, evictInjectedRule);
|
|
2773
2681
|
var _CSS_DISABLED_KEY = "__kbach_runtime_css_disabled__";
|
|
2774
2682
|
function disableRuntimeCSS() {
|
|
2775
2683
|
globalThis[_CSS_DISABLED_KEY] = true;
|
|
@@ -2806,8 +2714,7 @@ function injectGlobalStyles(theme) {
|
|
|
2806
2714
|
if (typeof document === "undefined" || isRuntimeCSSDisabled()) return;
|
|
2807
2715
|
const rules = [BASE_RESET];
|
|
2808
2716
|
const ff = theme.fontFamily;
|
|
2809
|
-
if (
|
|
2810
|
-
if (ff.sans && ff.sans !== "System") {
|
|
2717
|
+
if (ff?.sans && ff.sans !== "System") {
|
|
2811
2718
|
const family = Array.isArray(ff.sans) ? ff.sans.join(", ") : ff.sans;
|
|
2812
2719
|
rules.push(`body { font-family: ${family}; }`);
|
|
2813
2720
|
}
|
|
@@ -2970,7 +2877,7 @@ function buildClassCSSRules(cls, bucketKey, styles, darkMode, important, screens
|
|
|
2970
2877
|
else rule = `[data-theme="dark"] ${selector} { ${decls} }`;
|
|
2971
2878
|
} else if (darkScheme === "light") {
|
|
2972
2879
|
if (darkMode === "media") rule = `@media (prefers-color-scheme: light) { ${selector} { ${decls} } }`;
|
|
2973
|
-
else if (darkMode === "class") rule =
|
|
2880
|
+
else if (darkMode === "class") rule = `.light ${selector} { ${decls} }`;
|
|
2974
2881
|
else rule = `[data-theme="light"] ${selector} { ${decls} }`;
|
|
2975
2882
|
} else {
|
|
2976
2883
|
rule = `${selector} { ${decls} }`;
|
|
@@ -3101,11 +3008,14 @@ function getConfig() {
|
|
|
3101
3008
|
return store.resolved;
|
|
3102
3009
|
}
|
|
3103
3010
|
function resolveOneRef(ref, colors) {
|
|
3104
|
-
const
|
|
3105
|
-
if (
|
|
3106
|
-
const
|
|
3011
|
+
const lastDash = ref.lastIndexOf("-");
|
|
3012
|
+
if (lastDash <= 0) return null;
|
|
3013
|
+
const name = ref.slice(0, lastDash);
|
|
3014
|
+
const shade = ref.slice(lastDash + 1);
|
|
3015
|
+
if (!/^\d+$/.test(shade)) return null;
|
|
3016
|
+
const entry = colors[name];
|
|
3107
3017
|
if (!entry || typeof entry !== "object") return null;
|
|
3108
|
-
return entry[
|
|
3018
|
+
return entry[shade] ?? null;
|
|
3109
3019
|
}
|
|
3110
3020
|
function resolveColorRefs(colors) {
|
|
3111
3021
|
const MAX_DEPTH = 5;
|
|
@@ -3135,7 +3045,7 @@ function resolveColorRefs(colors) {
|
|
|
3135
3045
|
function buildConfig(userConfig) {
|
|
3136
3046
|
let theme = { ...defaultTheme };
|
|
3137
3047
|
if (userConfig.theme) {
|
|
3138
|
-
theme =
|
|
3048
|
+
theme = { ...theme, ...userConfig.theme };
|
|
3139
3049
|
}
|
|
3140
3050
|
if (userConfig.extend) {
|
|
3141
3051
|
const extendConfig = userConfig.extend;
|
|
@@ -3284,6 +3194,74 @@ function subscribeGlobalDarkMode(callback) {
|
|
|
3284
3194
|
return () => store.subscribers.delete(callback);
|
|
3285
3195
|
}
|
|
3286
3196
|
|
|
3197
|
+
// src/useColors.ts
|
|
3198
|
+
function applyOpacity(color, opacity) {
|
|
3199
|
+
const a = Math.max(0, Math.min(1, opacity / 100));
|
|
3200
|
+
if (color.startsWith("#")) {
|
|
3201
|
+
const rgb = parseHexRgb(color);
|
|
3202
|
+
if (!rgb) return color;
|
|
3203
|
+
const [r, g, b] = rgb;
|
|
3204
|
+
return `rgba(${r},${g},${b},${a})`;
|
|
3205
|
+
}
|
|
3206
|
+
if (color.startsWith("rgb(")) return color.replace("rgb(", "rgba(").replace(")", `,${a})`);
|
|
3207
|
+
if (color.startsWith("rgba(")) return color.replace(/,\s*[\d.]+\)$/, `,${a})`);
|
|
3208
|
+
return color;
|
|
3209
|
+
}
|
|
3210
|
+
function makeShadeProxy(shades) {
|
|
3211
|
+
return new Proxy(shades, {
|
|
3212
|
+
get(target, prop) {
|
|
3213
|
+
const key = String(prop);
|
|
3214
|
+
if (key === "then") return void 0;
|
|
3215
|
+
if (key.includes("/")) {
|
|
3216
|
+
const slash = key.indexOf("/");
|
|
3217
|
+
const shade = key.slice(0, slash);
|
|
3218
|
+
const op = Number(key.slice(slash + 1));
|
|
3219
|
+
const color = target[shade];
|
|
3220
|
+
return typeof color === "string" ? applyOpacity(color, op) : void 0;
|
|
3221
|
+
}
|
|
3222
|
+
return target[key];
|
|
3223
|
+
}
|
|
3224
|
+
});
|
|
3225
|
+
}
|
|
3226
|
+
function wrapColors(rawColors) {
|
|
3227
|
+
const cache = /* @__PURE__ */ new Map();
|
|
3228
|
+
const alpha = (color, opacity) => opacity === void 0 ? color : applyOpacity(color, opacity);
|
|
3229
|
+
return new Proxy({ alpha }, {
|
|
3230
|
+
get(_, prop) {
|
|
3231
|
+
const key = String(prop);
|
|
3232
|
+
if (key === "then") return void 0;
|
|
3233
|
+
if (key === "alpha") return alpha;
|
|
3234
|
+
if (key.includes("/")) {
|
|
3235
|
+
const slash = key.indexOf("/");
|
|
3236
|
+
const name = key.slice(0, slash);
|
|
3237
|
+
const op = Number(key.slice(slash + 1));
|
|
3238
|
+
const entry2 = rawColors[name];
|
|
3239
|
+
return typeof entry2 === "string" ? applyOpacity(entry2, op) : void 0;
|
|
3240
|
+
}
|
|
3241
|
+
const entry = rawColors[key];
|
|
3242
|
+
if (entry === void 0) return void 0;
|
|
3243
|
+
if (typeof entry === "string") return entry;
|
|
3244
|
+
if (!cache.has(key)) cache.set(key, makeShadeProxy(entry));
|
|
3245
|
+
return cache.get(key);
|
|
3246
|
+
}
|
|
3247
|
+
});
|
|
3248
|
+
}
|
|
3249
|
+
function useColors() {
|
|
3250
|
+
const { config } = useTheme();
|
|
3251
|
+
return (0, import_react2.useMemo)(() => wrapColors(config.theme.colors), [config.theme.colors]);
|
|
3252
|
+
}
|
|
3253
|
+
|
|
3254
|
+
// src/ThemeProvider.tsx
|
|
3255
|
+
var import_react4 = require("react");
|
|
3256
|
+
|
|
3257
|
+
// src/useSyncExternalStoreShim.ts
|
|
3258
|
+
var import_react3 = __toESM(require("react"));
|
|
3259
|
+
var useSyncExternalStore = import_react3.default.useSyncExternalStore ?? function useSyncExternalStoreFallback(subscribe, getSnapshot, _getServerSnapshot) {
|
|
3260
|
+
const [, forceUpdate] = import_react3.default.useReducer((n) => n + 1, 0);
|
|
3261
|
+
import_react3.default.useEffect(() => subscribe(forceUpdate), [subscribe]);
|
|
3262
|
+
return getSnapshot();
|
|
3263
|
+
};
|
|
3264
|
+
|
|
3287
3265
|
// src/ThemeProvider.tsx
|
|
3288
3266
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
3289
3267
|
var STORAGE_KEY = "kbach-theme";
|
|
@@ -3301,6 +3279,22 @@ function persistMode(mode) {
|
|
|
3301
3279
|
} catch {
|
|
3302
3280
|
}
|
|
3303
3281
|
}
|
|
3282
|
+
function subscribeSystemScheme(callback) {
|
|
3283
|
+
if (!isWeb || typeof window === "undefined") return () => {
|
|
3284
|
+
};
|
|
3285
|
+
const mq = window.matchMedia?.("(prefers-color-scheme: dark)");
|
|
3286
|
+
if (!mq) return () => {
|
|
3287
|
+
};
|
|
3288
|
+
mq.addEventListener("change", callback);
|
|
3289
|
+
return () => mq.removeEventListener("change", callback);
|
|
3290
|
+
}
|
|
3291
|
+
function getSystemScheme() {
|
|
3292
|
+
if (!isWeb || typeof window === "undefined") return "light";
|
|
3293
|
+
return window.matchMedia?.("(prefers-color-scheme: dark)")?.matches ? "dark" : "light";
|
|
3294
|
+
}
|
|
3295
|
+
function getSystemSchemeServerSnapshot() {
|
|
3296
|
+
return "light";
|
|
3297
|
+
}
|
|
3304
3298
|
function applyWebTheme(resolvedMode, strategy) {
|
|
3305
3299
|
if (!isWeb) return;
|
|
3306
3300
|
const root = document.documentElement;
|
|
@@ -3319,35 +3313,34 @@ function ThemeProvider({
|
|
|
3319
3313
|
config: configOverride,
|
|
3320
3314
|
disablePersistence = false
|
|
3321
3315
|
}) {
|
|
3322
|
-
const [resolvedConfig, setResolvedConfig] = (0,
|
|
3316
|
+
const [resolvedConfig, setResolvedConfig] = (0, import_react4.useState)(
|
|
3323
3317
|
() => configOverride ? buildConfig(configOverride) : getConfig()
|
|
3324
3318
|
);
|
|
3325
|
-
const [webWidth, setWebWidth] = (0,
|
|
3326
|
-
() => isWeb && typeof window !== "undefined" ? window.innerWidth : 0
|
|
3327
|
-
);
|
|
3319
|
+
const [webWidth, setWebWidth] = (0, import_react4.useState)(0);
|
|
3328
3320
|
const effectiveWidth = windowWidthProp ?? (isWeb ? webWidth : 0);
|
|
3329
|
-
const numericScreens = (0,
|
|
3321
|
+
const numericScreens = (0, import_react4.useMemo)(() => {
|
|
3330
3322
|
const out = {};
|
|
3331
3323
|
for (const [k, v] of Object.entries(resolvedConfig.theme.screens ?? {})) {
|
|
3332
3324
|
out[k] = typeof v === "number" ? v : parseInt(String(v), 10);
|
|
3333
3325
|
}
|
|
3334
3326
|
return out;
|
|
3335
3327
|
}, [resolvedConfig.theme.screens]);
|
|
3336
|
-
const _prevWidthRef = (0,
|
|
3328
|
+
const _prevWidthRef = (0, import_react4.useRef)(-1);
|
|
3337
3329
|
if (_prevWidthRef.current !== effectiveWidth) {
|
|
3338
3330
|
_prevWidthRef.current = effectiveWidth;
|
|
3339
3331
|
syncGlobalWidth(effectiveWidth);
|
|
3340
3332
|
}
|
|
3341
|
-
const _prevScreensRef = (0,
|
|
3333
|
+
const _prevScreensRef = (0, import_react4.useRef)(null);
|
|
3342
3334
|
if (_prevScreensRef.current !== numericScreens) {
|
|
3343
3335
|
_prevScreensRef.current = numericScreens;
|
|
3344
3336
|
syncGlobalScreens(numericScreens);
|
|
3345
3337
|
}
|
|
3346
|
-
(0,
|
|
3338
|
+
(0, import_react4.useEffect)(() => {
|
|
3347
3339
|
setGlobalWidth(effectiveWidth);
|
|
3348
3340
|
}, [effectiveWidth]);
|
|
3349
|
-
(0,
|
|
3341
|
+
(0, import_react4.useEffect)(() => {
|
|
3350
3342
|
if (!isWeb || typeof window === "undefined") return;
|
|
3343
|
+
setWebWidth(window.innerWidth);
|
|
3351
3344
|
let raf = 0;
|
|
3352
3345
|
const update = () => {
|
|
3353
3346
|
cancelAnimationFrame(raf);
|
|
@@ -3363,52 +3356,38 @@ function ThemeProvider({
|
|
|
3363
3356
|
cancelAnimationFrame(raf);
|
|
3364
3357
|
};
|
|
3365
3358
|
}, []);
|
|
3366
|
-
const
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
});
|
|
3359
|
+
const webScheme = useSyncExternalStore(
|
|
3360
|
+
subscribeSystemScheme,
|
|
3361
|
+
getSystemScheme,
|
|
3362
|
+
getSystemSchemeServerSnapshot
|
|
3363
|
+
);
|
|
3372
3364
|
const systemScheme = isWeb ? webScheme : colorScheme === "dark" ? "dark" : "light";
|
|
3373
|
-
const [mode, _setMode] = (0,
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
const setMode = (0, import_react3.useCallback)((next) => {
|
|
3365
|
+
const [mode, _setMode] = (0, import_react4.useState)(defaultMode);
|
|
3366
|
+
(0, import_react4.useEffect)(() => {
|
|
3367
|
+
if (disablePersistence) return;
|
|
3368
|
+
const persisted = loadPersistedMode();
|
|
3369
|
+
if (persisted) _setMode(persisted);
|
|
3370
|
+
}, []);
|
|
3371
|
+
const setMode = (0, import_react4.useCallback)((next) => {
|
|
3381
3372
|
_setMode(next);
|
|
3382
3373
|
if (!disablePersistence) persistMode(next);
|
|
3383
3374
|
}, [disablePersistence]);
|
|
3384
|
-
const toggle = (0,
|
|
3375
|
+
const toggle = (0, import_react4.useCallback)(() => {
|
|
3385
3376
|
setMode(mode === "dark" || mode === "system" && systemScheme === "dark" ? "light" : "dark");
|
|
3386
3377
|
}, [mode, systemScheme, setMode]);
|
|
3387
3378
|
const resolvedMode = mode === "system" ? systemScheme : mode;
|
|
3388
3379
|
const isDark = resolvedMode === "dark";
|
|
3389
3380
|
syncGlobalDarkMode(isDark);
|
|
3390
|
-
(0,
|
|
3381
|
+
(0, import_react4.useEffect)(() => {
|
|
3391
3382
|
applyWebTheme(resolvedMode, resolvedConfig.darkMode);
|
|
3392
3383
|
setGlobalDarkMode(isDark);
|
|
3393
3384
|
}, [isDark, resolvedMode, resolvedConfig.darkMode]);
|
|
3394
|
-
|
|
3395
|
-
setWebSchemeRef.current = setWebScheme;
|
|
3396
|
-
(0, import_react3.useEffect)(() => {
|
|
3397
|
-
if (!isWeb || typeof window === "undefined") return;
|
|
3398
|
-
const mq = window.matchMedia?.("(prefers-color-scheme: dark)");
|
|
3399
|
-
if (!mq) return;
|
|
3400
|
-
const handler = (e) => {
|
|
3401
|
-
setWebSchemeRef.current(e.matches ? "dark" : "light");
|
|
3402
|
-
};
|
|
3403
|
-
mq.addEventListener("change", handler);
|
|
3404
|
-
return () => mq.removeEventListener("change", handler);
|
|
3405
|
-
}, []);
|
|
3406
|
-
(0, import_react3.useEffect)(() => {
|
|
3385
|
+
(0, import_react4.useEffect)(() => {
|
|
3407
3386
|
if (!configOverride) return;
|
|
3408
3387
|
updateConfig(configOverride);
|
|
3409
3388
|
setResolvedConfig(getConfig());
|
|
3410
3389
|
}, [configOverride]);
|
|
3411
|
-
(0,
|
|
3390
|
+
(0, import_react4.useEffect)(() => {
|
|
3412
3391
|
if (configOverride) return;
|
|
3413
3392
|
let mounted = true;
|
|
3414
3393
|
const unsub = onConfigChange((config) => {
|
|
@@ -3419,7 +3398,7 @@ function ThemeProvider({
|
|
|
3419
3398
|
unsub();
|
|
3420
3399
|
};
|
|
3421
3400
|
}, [configOverride]);
|
|
3422
|
-
const contextValue = (0,
|
|
3401
|
+
const contextValue = (0, import_react4.useMemo)(
|
|
3423
3402
|
() => ({ mode, resolvedMode, isDark, setMode, toggle, config: resolvedConfig }),
|
|
3424
3403
|
[mode, resolvedMode, isDark, setMode, toggle, resolvedConfig]
|
|
3425
3404
|
);
|
|
@@ -3427,15 +3406,9 @@ function ThemeProvider({
|
|
|
3427
3406
|
}
|
|
3428
3407
|
|
|
3429
3408
|
// src/styled.tsx
|
|
3430
|
-
var
|
|
3409
|
+
var import_react5 = __toESM(require("react"));
|
|
3431
3410
|
|
|
3432
3411
|
// src/useGlobalDarkMode.ts
|
|
3433
|
-
var import_react4 = __toESM(require("react"));
|
|
3434
|
-
var useSyncExternalStore = import_react4.default.useSyncExternalStore ?? function useSyncExternalStoreFallback(subscribe, getSnapshot, _getServerSnapshot) {
|
|
3435
|
-
const [, forceUpdate] = import_react4.default.useReducer((n) => n + 1, 0);
|
|
3436
|
-
import_react4.default.useEffect(() => subscribe(forceUpdate), [subscribe]);
|
|
3437
|
-
return getSnapshot();
|
|
3438
|
-
};
|
|
3439
3412
|
function useGlobalDarkMode() {
|
|
3440
3413
|
return useSyncExternalStore(
|
|
3441
3414
|
subscribeGlobalDarkMode,
|
|
@@ -3446,12 +3419,6 @@ function useGlobalDarkMode() {
|
|
|
3446
3419
|
}
|
|
3447
3420
|
|
|
3448
3421
|
// src/useGlobalWidth.ts
|
|
3449
|
-
var import_react5 = __toESM(require("react"));
|
|
3450
|
-
var useSyncExternalStore2 = import_react5.default.useSyncExternalStore ?? function useSyncExternalStoreFallback2(subscribe, getSnapshot, _getServerSnapshot) {
|
|
3451
|
-
const [, forceUpdate] = import_react5.default.useReducer((n) => n + 1, 0);
|
|
3452
|
-
import_react5.default.useEffect(() => subscribe(forceUpdate), [subscribe]);
|
|
3453
|
-
return getSnapshot();
|
|
3454
|
-
};
|
|
3455
3422
|
var NOOP_SUB = (_) => () => {
|
|
3456
3423
|
};
|
|
3457
3424
|
var ZERO_SNAP = () => 0;
|
|
@@ -3485,14 +3452,14 @@ function getWebWidth() {
|
|
|
3485
3452
|
return typeof window !== "undefined" ? window.innerWidth : 0;
|
|
3486
3453
|
}
|
|
3487
3454
|
function useGlobalWidth() {
|
|
3488
|
-
return
|
|
3455
|
+
return useSyncExternalStore(
|
|
3489
3456
|
isWeb ? subscribeWebWidth : subscribeGlobalWidth,
|
|
3490
3457
|
isWeb ? getWebWidth : getGlobalWidth,
|
|
3491
3458
|
ZERO_SNAP
|
|
3492
3459
|
);
|
|
3493
3460
|
}
|
|
3494
3461
|
function useConditionalWidth(active) {
|
|
3495
|
-
return
|
|
3462
|
+
return useSyncExternalStore(
|
|
3496
3463
|
active ? isWeb ? subscribeWebWidth : subscribeGlobalWidth : NOOP_SUB,
|
|
3497
3464
|
active ? isWeb ? getWebWidth : getGlobalWidth : ZERO_SNAP,
|
|
3498
3465
|
ZERO_SNAP
|
|
@@ -3520,6 +3487,42 @@ function hasInteractiveBuckets(resolved) {
|
|
|
3520
3487
|
}
|
|
3521
3488
|
return false;
|
|
3522
3489
|
}
|
|
3490
|
+
function chain(original, extra) {
|
|
3491
|
+
return (...args) => {
|
|
3492
|
+
original?.(...args);
|
|
3493
|
+
extra();
|
|
3494
|
+
};
|
|
3495
|
+
}
|
|
3496
|
+
function stripInternalMarkers(s) {
|
|
3497
|
+
delete s.__divideX;
|
|
3498
|
+
delete s.__divideY;
|
|
3499
|
+
delete s.__divideColor;
|
|
3500
|
+
delete s.__divideStyle;
|
|
3501
|
+
delete s.__keyframe;
|
|
3502
|
+
}
|
|
3503
|
+
function stripWebOnlyProps(s) {
|
|
3504
|
+
if (s.display === "grid" || s.display === "inline-grid") delete s.display;
|
|
3505
|
+
delete s.gridTemplateColumns;
|
|
3506
|
+
delete s.gridTemplateRows;
|
|
3507
|
+
delete s.gridColumn;
|
|
3508
|
+
delete s.gridRow;
|
|
3509
|
+
delete s.gridArea;
|
|
3510
|
+
delete s.gridColumnStart;
|
|
3511
|
+
delete s.gridColumnEnd;
|
|
3512
|
+
delete s.gridRowStart;
|
|
3513
|
+
delete s.gridRowEnd;
|
|
3514
|
+
delete s.gridAutoFlow;
|
|
3515
|
+
delete s.gridAutoColumns;
|
|
3516
|
+
delete s.gridAutoRows;
|
|
3517
|
+
delete s.placeItems;
|
|
3518
|
+
delete s.placeContent;
|
|
3519
|
+
delete s.justifyItems;
|
|
3520
|
+
delete s.placeSelf;
|
|
3521
|
+
delete s.justifySelf;
|
|
3522
|
+
if (s.position === "sticky" || s.position === "fixed" || s.position === "static") {
|
|
3523
|
+
delete s.position;
|
|
3524
|
+
}
|
|
3525
|
+
}
|
|
3523
3526
|
|
|
3524
3527
|
// src/web-substitute.ts
|
|
3525
3528
|
var _rnToHtml = {
|
|
@@ -3769,13 +3772,11 @@ function transformToWebProps(originalName, tag, props) {
|
|
|
3769
3772
|
continue;
|
|
3770
3773
|
}
|
|
3771
3774
|
if (k === "resizeMode") {
|
|
3772
|
-
|
|
3773
|
-
out.style = { ...existing, objectFit: _resizeModeMap[v] ?? "cover" };
|
|
3775
|
+
pendingStyle = { ...pendingStyle ?? {}, objectFit: _resizeModeMap[v] ?? "cover" };
|
|
3774
3776
|
continue;
|
|
3775
3777
|
}
|
|
3776
3778
|
if (k === "contentFit") {
|
|
3777
|
-
|
|
3778
|
-
out.style = { ...existing, objectFit: v };
|
|
3779
|
+
pendingStyle = { ...pendingStyle ?? {}, objectFit: v };
|
|
3779
3780
|
continue;
|
|
3780
3781
|
}
|
|
3781
3782
|
if (k === "defaultSource") continue;
|
|
@@ -3800,7 +3801,7 @@ function transformToWebProps(originalName, tag, props) {
|
|
|
3800
3801
|
|
|
3801
3802
|
// src/styled.tsx
|
|
3802
3803
|
function styled(Component, baseClasses = "") {
|
|
3803
|
-
const Styled = (0,
|
|
3804
|
+
const Styled = (0, import_react5.forwardRef)(
|
|
3804
3805
|
(props, ref) => {
|
|
3805
3806
|
const {
|
|
3806
3807
|
kb: extraClasses,
|
|
@@ -3810,6 +3811,7 @@ function styled(Component, baseClasses = "") {
|
|
|
3810
3811
|
onPointerDown,
|
|
3811
3812
|
onPointerUp,
|
|
3812
3813
|
onPointerLeave,
|
|
3814
|
+
onPointerCancel,
|
|
3813
3815
|
onMouseEnter,
|
|
3814
3816
|
onMouseLeave,
|
|
3815
3817
|
onFocus,
|
|
@@ -3820,52 +3822,26 @@ function styled(Component, baseClasses = "") {
|
|
|
3820
3822
|
const checked = !!props.checked;
|
|
3821
3823
|
const { config } = useTheme();
|
|
3822
3824
|
const isDark = useGlobalDarkMode();
|
|
3823
|
-
const [pressed, setPressed] = (0,
|
|
3824
|
-
const [hovered, setHovered] = (0,
|
|
3825
|
-
const [focused, setFocused] = (0,
|
|
3826
|
-
const handlePressIn = (0,
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
const
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
const
|
|
3835
|
-
|
|
3836
|
-
onPointerDown?.(e);
|
|
3837
|
-
}, [onPointerDown]);
|
|
3838
|
-
const handlePointerUp = (0, import_react6.useCallback)((e) => {
|
|
3839
|
-
setPressed(false);
|
|
3840
|
-
onPointerUp?.(e);
|
|
3841
|
-
}, [onPointerUp]);
|
|
3842
|
-
const handlePointerLeave = (0, import_react6.useCallback)((e) => {
|
|
3843
|
-
setPressed(false);
|
|
3844
|
-
onPointerLeave?.(e);
|
|
3845
|
-
}, [onPointerLeave]);
|
|
3846
|
-
const handleMouseEnter = (0, import_react6.useCallback)((e) => {
|
|
3847
|
-
setHovered(true);
|
|
3848
|
-
onMouseEnter?.(e);
|
|
3849
|
-
}, [onMouseEnter]);
|
|
3850
|
-
const handleMouseLeave = (0, import_react6.useCallback)((e) => {
|
|
3851
|
-
setHovered(false);
|
|
3852
|
-
onMouseLeave?.(e);
|
|
3853
|
-
}, [onMouseLeave]);
|
|
3854
|
-
const handleFocus = (0, import_react6.useCallback)((e) => {
|
|
3855
|
-
setFocused(true);
|
|
3856
|
-
onFocus?.(e);
|
|
3857
|
-
}, [onFocus]);
|
|
3858
|
-
const handleBlur = (0, import_react6.useCallback)((e) => {
|
|
3859
|
-
setFocused(false);
|
|
3860
|
-
onBlur?.(e);
|
|
3861
|
-
}, [onBlur]);
|
|
3825
|
+
const [pressed, setPressed] = (0, import_react5.useState)(false);
|
|
3826
|
+
const [hovered, setHovered] = (0, import_react5.useState)(false);
|
|
3827
|
+
const [focused, setFocused] = (0, import_react5.useState)(false);
|
|
3828
|
+
const handlePressIn = (0, import_react5.useCallback)(chain(onPressIn, () => setPressed(true)), [onPressIn]);
|
|
3829
|
+
const handlePressOut = (0, import_react5.useCallback)(chain(onPressOut, () => setPressed(false)), [onPressOut]);
|
|
3830
|
+
const handlePointerDown = (0, import_react5.useCallback)(chain(onPointerDown, () => setPressed(true)), [onPointerDown]);
|
|
3831
|
+
const handlePointerUp = (0, import_react5.useCallback)(chain(onPointerUp, () => setPressed(false)), [onPointerUp]);
|
|
3832
|
+
const handlePointerLeave = (0, import_react5.useCallback)(chain(onPointerLeave, () => setPressed(false)), [onPointerLeave]);
|
|
3833
|
+
const handlePointerCancel = (0, import_react5.useCallback)(chain(onPointerCancel, () => setPressed(false)), [onPointerCancel]);
|
|
3834
|
+
const handleMouseEnter = (0, import_react5.useCallback)(chain(onMouseEnter, () => setHovered(true)), [onMouseEnter]);
|
|
3835
|
+
const handleMouseLeave = (0, import_react5.useCallback)(chain(onMouseLeave, () => setHovered(false)), [onMouseLeave]);
|
|
3836
|
+
const handleFocus = (0, import_react5.useCallback)(chain(onFocus, () => setFocused(true)), [onFocus]);
|
|
3837
|
+
const handleBlur = (0, import_react5.useCallback)(chain(onBlur, () => setFocused(false)), [onBlur]);
|
|
3862
3838
|
const combined = extraClasses ? `${baseClasses} ${extraClasses}` : baseClasses;
|
|
3863
|
-
const resolved = (0,
|
|
3864
|
-
const hasInteractive = (0,
|
|
3839
|
+
const resolved = (0, import_react5.useMemo)(() => resolve(combined, config.theme, config.darkMode), [combined, config.theme, config.darkMode]);
|
|
3840
|
+
const hasInteractive = (0, import_react5.useMemo)(() => hasInteractiveBuckets(resolved), [resolved]);
|
|
3865
3841
|
const needsWidth = hasResponsiveBuckets(resolved);
|
|
3866
3842
|
const width = useConditionalWidth(needsWidth);
|
|
3867
3843
|
const breakpoints = needsWidth ? getActiveBreakpoints(width) : EMPTY_BREAKPOINTS;
|
|
3868
|
-
const computedStyle = (0,
|
|
3844
|
+
const computedStyle = (0, import_react5.useMemo)(
|
|
3869
3845
|
() => isWeb ? {} : flatten(resolved, isDark, { pressed, hover: hovered, focus: focused, disabled, checked }, breakpoints),
|
|
3870
3846
|
[resolved, isDark, pressed, hovered, focused, disabled, checked, width]
|
|
3871
3847
|
// eslint-disable-line react-hooks/exhaustive-deps
|
|
@@ -3876,7 +3852,7 @@ function styled(Component, baseClasses = "") {
|
|
|
3876
3852
|
const effectiveComponent = webTag ?? Component;
|
|
3877
3853
|
const componentName2 = Component.displayName ?? Component.name ?? "";
|
|
3878
3854
|
const effectiveRest = webTag && componentName2 ? transformToWebProps(componentName2, webTag, rest) : rest;
|
|
3879
|
-
return
|
|
3855
|
+
return import_react5.default.createElement(effectiveComponent, {
|
|
3880
3856
|
ref,
|
|
3881
3857
|
...effectiveRest,
|
|
3882
3858
|
style: finalStyle,
|
|
@@ -3886,7 +3862,7 @@ function styled(Component, baseClasses = "") {
|
|
|
3886
3862
|
// Always forward user-provided handlers to avoid silently swallowing them.
|
|
3887
3863
|
// onPressIn/onPressOut are forwarded on web too (not just native) since
|
|
3888
3864
|
// react-native-web components rely on receiving them directly.
|
|
3889
|
-
...isWeb ? hasInteractive ? { onPointerDown: handlePointerDown, onPointerUp: handlePointerUp, onPointerLeave: handlePointerLeave, onPointerCancel:
|
|
3865
|
+
...isWeb ? hasInteractive ? { onPointerDown: handlePointerDown, onPointerUp: handlePointerUp, onPointerLeave: handlePointerLeave, onPointerCancel: handlePointerCancel, onPressIn, onPressOut } : { onPointerDown, onPointerUp, onPointerLeave, onPointerCancel, onPressIn, onPressOut } : hasInteractive ? { onPressIn: handlePressIn, onPressOut: handlePressOut } : { onPressIn, onPressOut },
|
|
3890
3866
|
onMouseEnter: hasInteractive ? handleMouseEnter : onMouseEnter,
|
|
3891
3867
|
onMouseLeave: hasInteractive ? handleMouseLeave : onMouseLeave,
|
|
3892
3868
|
onFocus: hasInteractive ? handleFocus : onFocus,
|
|
@@ -3900,12 +3876,12 @@ function styled(Component, baseClasses = "") {
|
|
|
3900
3876
|
}
|
|
3901
3877
|
|
|
3902
3878
|
// src/useStyles.ts
|
|
3903
|
-
var
|
|
3879
|
+
var import_react6 = require("react");
|
|
3904
3880
|
function useStyles(classString, state = {}) {
|
|
3905
3881
|
const { isDark, config } = useTheme();
|
|
3906
3882
|
const width = useGlobalWidth();
|
|
3907
3883
|
const normalised = Array.isArray(classString) ? classString.join(" ") : classString;
|
|
3908
|
-
return (0,
|
|
3884
|
+
return (0, import_react6.useMemo)(() => {
|
|
3909
3885
|
const resolved = resolve(normalised, config.theme, config.darkMode);
|
|
3910
3886
|
const breakpoints = getActiveBreakpoints(width);
|
|
3911
3887
|
return flatten(resolved, isDark, state, breakpoints);
|
|
@@ -3914,20 +3890,20 @@ function useStyles(classString, state = {}) {
|
|
|
3914
3890
|
function useResolvedStyle(classString) {
|
|
3915
3891
|
const { config } = useTheme();
|
|
3916
3892
|
const normalised = Array.isArray(classString) ? classString.join(" ") : classString;
|
|
3917
|
-
return (0,
|
|
3893
|
+
return (0, import_react6.useMemo)(
|
|
3918
3894
|
() => resolve(normalised, config.theme, config.darkMode),
|
|
3919
3895
|
[normalised, config]
|
|
3920
3896
|
);
|
|
3921
3897
|
}
|
|
3922
3898
|
|
|
3923
3899
|
// src/useBreakpoint.ts
|
|
3924
|
-
var
|
|
3900
|
+
var import_react7 = require("react");
|
|
3925
3901
|
function useBreakpoint() {
|
|
3926
3902
|
const { config } = useTheme();
|
|
3927
3903
|
const width = useGlobalWidth();
|
|
3928
3904
|
const screens = config.theme.screens;
|
|
3929
|
-
const sorted = (0,
|
|
3930
|
-
() => Object.entries(screens).
|
|
3905
|
+
const sorted = (0, import_react7.useMemo)(
|
|
3906
|
+
() => Object.entries(screens).map(([name, v]) => [name, typeof v === "number" ? v : parseInt(String(v), 10)]).filter(([, minW]) => !Number.isNaN(minW)).sort(([, a], [, b]) => b - a),
|
|
3931
3907
|
[screens]
|
|
3932
3908
|
);
|
|
3933
3909
|
for (const [name, minW] of sorted) {
|
|
@@ -3939,24 +3915,19 @@ function useResponsive() {
|
|
|
3939
3915
|
const { config } = useTheme();
|
|
3940
3916
|
const width = useGlobalWidth();
|
|
3941
3917
|
const screens = config.theme.screens;
|
|
3942
|
-
return (0,
|
|
3918
|
+
return (0, import_react7.useMemo)(() => {
|
|
3943
3919
|
const result = {};
|
|
3944
|
-
for (const [name,
|
|
3945
|
-
|
|
3920
|
+
for (const [name, v] of Object.entries(screens)) {
|
|
3921
|
+
const minW = typeof v === "number" ? v : parseInt(String(v), 10);
|
|
3922
|
+
if (!Number.isNaN(minW)) result[name] = width >= minW;
|
|
3946
3923
|
}
|
|
3947
3924
|
return result;
|
|
3948
3925
|
}, [screens, width]);
|
|
3949
3926
|
}
|
|
3950
3927
|
|
|
3951
3928
|
// src/InteractiveWrapper.tsx
|
|
3952
|
-
var
|
|
3953
|
-
|
|
3954
|
-
return (...args) => {
|
|
3955
|
-
original?.(...args);
|
|
3956
|
-
extra();
|
|
3957
|
-
};
|
|
3958
|
-
}
|
|
3959
|
-
var InteractiveWrapper = (0, import_react9.forwardRef)(
|
|
3929
|
+
var import_react8 = __toESM(require("react"));
|
|
3930
|
+
var InteractiveWrapper = (0, import_react8.forwardRef)(
|
|
3960
3931
|
function InteractiveWrapper2({
|
|
3961
3932
|
Component,
|
|
3962
3933
|
resolvedStyle,
|
|
@@ -3967,6 +3938,7 @@ var InteractiveWrapper = (0, import_react9.forwardRef)(
|
|
|
3967
3938
|
onPointerDown,
|
|
3968
3939
|
onPointerUp,
|
|
3969
3940
|
onPointerLeave,
|
|
3941
|
+
onPointerCancel,
|
|
3970
3942
|
onMouseEnter,
|
|
3971
3943
|
onMouseLeave,
|
|
3972
3944
|
onFocus,
|
|
@@ -3977,51 +3949,26 @@ var InteractiveWrapper = (0, import_react9.forwardRef)(
|
|
|
3977
3949
|
const needsWidth = hasResponsiveBuckets(resolvedStyle);
|
|
3978
3950
|
const width = useConditionalWidth(needsWidth);
|
|
3979
3951
|
const breakpoints = needsWidth ? getActiveBreakpoints(width) : EMPTY_BREAKPOINTS;
|
|
3980
|
-
const [pressed, setPressed] = (0,
|
|
3981
|
-
const [hovered, setHovered] = (0,
|
|
3982
|
-
const [focused, setFocused] = (0,
|
|
3983
|
-
const handlePressIn = (0,
|
|
3984
|
-
const handlePressOut = (0,
|
|
3985
|
-
const handlePointerDown = (0,
|
|
3986
|
-
const handlePointerUp = (0,
|
|
3987
|
-
const handlePointerLeave = (0,
|
|
3988
|
-
const
|
|
3989
|
-
const
|
|
3990
|
-
const
|
|
3991
|
-
const
|
|
3952
|
+
const [pressed, setPressed] = (0, import_react8.useState)(false);
|
|
3953
|
+
const [hovered, setHovered] = (0, import_react8.useState)(false);
|
|
3954
|
+
const [focused, setFocused] = (0, import_react8.useState)(false);
|
|
3955
|
+
const handlePressIn = (0, import_react8.useCallback)(chain(onPressIn, () => setPressed(true)), [onPressIn]);
|
|
3956
|
+
const handlePressOut = (0, import_react8.useCallback)(chain(onPressOut, () => setPressed(false)), [onPressOut]);
|
|
3957
|
+
const handlePointerDown = (0, import_react8.useCallback)(chain(onPointerDown, () => setPressed(true)), [onPointerDown]);
|
|
3958
|
+
const handlePointerUp = (0, import_react8.useCallback)(chain(onPointerUp, () => setPressed(false)), [onPointerUp]);
|
|
3959
|
+
const handlePointerLeave = (0, import_react8.useCallback)(chain(onPointerLeave, () => setPressed(false)), [onPointerLeave]);
|
|
3960
|
+
const handlePointerCancel = (0, import_react8.useCallback)(chain(onPointerCancel, () => setPressed(false)), [onPointerCancel]);
|
|
3961
|
+
const handleMouseEnter = (0, import_react8.useCallback)(chain(onMouseEnter, () => setHovered(true)), [onMouseEnter]);
|
|
3962
|
+
const handleMouseLeave = (0, import_react8.useCallback)(chain(onMouseLeave, () => setHovered(false)), [onMouseLeave]);
|
|
3963
|
+
const handleFocus = (0, import_react8.useCallback)(chain(onFocus, () => setFocused(true)), [onFocus]);
|
|
3964
|
+
const handleBlur = (0, import_react8.useCallback)(chain(onBlur, () => setFocused(false)), [onBlur]);
|
|
3992
3965
|
const { children, disabled, checked, ...restForComponent } = rest;
|
|
3993
|
-
const computedStyle = (0,
|
|
3966
|
+
const computedStyle = (0, import_react8.useMemo)(
|
|
3994
3967
|
() => {
|
|
3995
3968
|
if (isWeb) return {};
|
|
3996
3969
|
const s = flatten(resolvedStyle, isDark, { pressed, hover: hovered, focus: focused, disabled: !!disabled, checked: !!checked }, breakpoints);
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
delete s.__divideColor;
|
|
4000
|
-
delete s.__divideStyle;
|
|
4001
|
-
delete s.__keyframe;
|
|
4002
|
-
if (typeof Component !== "string") {
|
|
4003
|
-
if (s.display === "grid" || s.display === "inline-grid") delete s.display;
|
|
4004
|
-
delete s.gridTemplateColumns;
|
|
4005
|
-
delete s.gridTemplateRows;
|
|
4006
|
-
delete s.gridColumn;
|
|
4007
|
-
delete s.gridRow;
|
|
4008
|
-
delete s.gridArea;
|
|
4009
|
-
delete s.gridColumnStart;
|
|
4010
|
-
delete s.gridColumnEnd;
|
|
4011
|
-
delete s.gridRowStart;
|
|
4012
|
-
delete s.gridRowEnd;
|
|
4013
|
-
delete s.gridAutoFlow;
|
|
4014
|
-
delete s.gridAutoColumns;
|
|
4015
|
-
delete s.gridAutoRows;
|
|
4016
|
-
delete s.placeItems;
|
|
4017
|
-
delete s.placeContent;
|
|
4018
|
-
delete s.justifyItems;
|
|
4019
|
-
delete s.placeSelf;
|
|
4020
|
-
delete s.justifySelf;
|
|
4021
|
-
if (s.position === "sticky" || s.position === "fixed" || s.position === "static") {
|
|
4022
|
-
delete s.position;
|
|
4023
|
-
}
|
|
4024
|
-
}
|
|
3970
|
+
stripInternalMarkers(s);
|
|
3971
|
+
if (typeof Component !== "string") stripWebOnlyProps(s);
|
|
4025
3972
|
return s;
|
|
4026
3973
|
},
|
|
4027
3974
|
[resolvedStyle, isDark, pressed, hovered, focused, width, disabled, checked]
|
|
@@ -4038,13 +3985,13 @@ var InteractiveWrapper = (0, import_react9.forwardRef)(
|
|
|
4038
3985
|
// On web, onPointerDown/Up drive the wrapper's own pressed state (covers mouse + touch),
|
|
4039
3986
|
// but onPressIn/onPressOut are still forwarded unchanged — react-native-web components
|
|
4040
3987
|
// (and any component that accepts both prop names) depend on receiving them directly.
|
|
4041
|
-
...!isNative ? { onPointerDown: handlePointerDown, onPointerUp: handlePointerUp, onPointerLeave: handlePointerLeave, onPointerCancel:
|
|
3988
|
+
...!isNative ? { onPointerDown: handlePointerDown, onPointerUp: handlePointerUp, onPointerLeave: handlePointerLeave, onPointerCancel: handlePointerCancel, onPressIn, onPressOut } : { onPressIn: handlePressIn, onPressOut: handlePressOut },
|
|
4042
3989
|
onMouseEnter: handleMouseEnter,
|
|
4043
3990
|
onMouseLeave: handleMouseLeave,
|
|
4044
3991
|
onFocus: handleFocus,
|
|
4045
3992
|
onBlur: handleBlur
|
|
4046
3993
|
};
|
|
4047
|
-
return Array.isArray(children) ?
|
|
3994
|
+
return Array.isArray(children) ? import_react8.default.createElement(Component, componentProps, ...children) : import_react8.default.createElement(Component, componentProps, children);
|
|
4048
3995
|
}
|
|
4049
3996
|
);
|
|
4050
3997
|
InteractiveWrapper.displayName = "Kbach.InteractiveWrapper";
|
|
@@ -4067,6 +4014,7 @@ function cx(...classes) {
|
|
|
4067
4014
|
ThemeContext,
|
|
4068
4015
|
ThemeProvider,
|
|
4069
4016
|
buildConfig,
|
|
4017
|
+
clearCache,
|
|
4070
4018
|
cx,
|
|
4071
4019
|
defaultColors,
|
|
4072
4020
|
defaultTheme,
|
|
@@ -4080,6 +4028,7 @@ function cx(...classes) {
|
|
|
4080
4028
|
parseClasses,
|
|
4081
4029
|
registerWebElement,
|
|
4082
4030
|
resolve,
|
|
4031
|
+
setResolveTarget,
|
|
4083
4032
|
splitClassTokens,
|
|
4084
4033
|
styled,
|
|
4085
4034
|
updateConfig,
|