@kbach/react 0.5.56 → 0.5.58
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/dist/{chunk-JBV2R655.mjs → chunk-2HWRNTJG.mjs} +144 -53
- package/dist/{chunk-O4EKWQSX.mjs → chunk-EMSB47ES.mjs} +9 -5
- package/dist/{chunk-PESA3FMP.mjs → chunk-F5NQX5YO.mjs} +48 -34
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +218 -113
- package/dist/index.mjs +7 -6
- package/dist/jsx-dev-runtime.js +181 -70
- package/dist/jsx-dev-runtime.mjs +4 -4
- package/dist/jsx-runtime.js +177 -69
- package/dist/jsx-runtime.mjs +3 -3
- package/dist/{types-D-24rbXu.d.ts → types-BESBQANS.d.mts} +7 -2
- package/dist/{types-D-24rbXu.d.mts → types-BESBQANS.d.ts} +7 -2
- package/dist/vite-plugin.d.mts +8 -3
- package/dist/vite-plugin.d.ts +8 -3
- package/dist/vite-plugin.js +144 -55
- package/dist/vite-plugin.mjs +10 -6
- package/package.json +1 -1
|
@@ -445,14 +445,15 @@ var defaultTheme = {
|
|
|
445
445
|
normal: 1.5,
|
|
446
446
|
relaxed: 1.625,
|
|
447
447
|
loose: 2,
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
448
|
+
// Pixel values stored as strings; styleValueToCSS passes them through, toNativeValue strips the unit
|
|
449
|
+
3: "12px",
|
|
450
|
+
4: "16px",
|
|
451
|
+
5: "20px",
|
|
452
|
+
6: "24px",
|
|
453
|
+
7: "28px",
|
|
454
|
+
8: "32px",
|
|
455
|
+
9: "36px",
|
|
456
|
+
10: "40px"
|
|
456
457
|
},
|
|
457
458
|
letterSpacing: {
|
|
458
459
|
tighter: -0.8,
|
|
@@ -473,9 +474,12 @@ var defaultTheme = {
|
|
|
473
474
|
},
|
|
474
475
|
flex: {
|
|
475
476
|
1: 1,
|
|
476
|
-
auto:
|
|
477
|
-
|
|
478
|
-
|
|
477
|
+
auto: "auto",
|
|
478
|
+
// CSS: flex: auto = 1 1 auto; native: mapped to 1 in resolver
|
|
479
|
+
initial: "initial",
|
|
480
|
+
// CSS: flex: initial = 0 1 auto; native: mapped to 1
|
|
481
|
+
none: "none"
|
|
482
|
+
// CSS: flex: none = 0 0 auto; native: mapped to 0
|
|
479
483
|
},
|
|
480
484
|
shadow: {
|
|
481
485
|
sm: {
|
|
@@ -543,7 +547,7 @@ var defaultTheme = {
|
|
|
543
547
|
|
|
544
548
|
// src/core/platform.ts
|
|
545
549
|
var isWeb = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
546
|
-
var isNative = !isWeb && (typeof globalThis.HermesInternal !== "undefined" || typeof globalThis.__fbBatchedBridge !== "undefined" || typeof navigator !== "undefined" && navigator.product === "ReactNative");
|
|
550
|
+
var isNative = !isWeb && (typeof globalThis.HermesInternal !== "undefined" || typeof globalThis.__fbBatchedBridge !== "undefined" || typeof navigator !== "undefined" && navigator.product === "ReactNative" || typeof globalThis.__REACT_NATIVE__ !== "undefined");
|
|
547
551
|
var _cssGenMode = false;
|
|
548
552
|
function setCSSGenMode(on) {
|
|
549
553
|
_cssGenMode = on;
|
|
@@ -559,7 +563,7 @@ function toNativeValue(raw) {
|
|
|
559
563
|
return raw;
|
|
560
564
|
}
|
|
561
565
|
function escapeCSSSelector(cls) {
|
|
562
|
-
return cls.replace(/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g, "\\$&");
|
|
566
|
+
return cls.replace(/[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g, "\\$&");
|
|
563
567
|
}
|
|
564
568
|
|
|
565
569
|
// src/core/registry.ts
|
|
@@ -636,6 +640,10 @@ function _invalidate() {
|
|
|
636
640
|
_responsiveNames = null;
|
|
637
641
|
}
|
|
638
642
|
function registerModifier(name, def) {
|
|
643
|
+
if (process.env.NODE_ENV !== "production" && name in BUILTIN_MODIFIERS) {
|
|
644
|
+
console.warn(`[kbach] registerModifier: "${name}" is a built-in modifier and cannot be overridden. Use a different name.`);
|
|
645
|
+
return;
|
|
646
|
+
}
|
|
639
647
|
_pluginModifiers[name] = def;
|
|
640
648
|
_invalidate();
|
|
641
649
|
}
|
|
@@ -717,7 +725,7 @@ function resolveColor(value, colors, isArbitrary) {
|
|
|
717
725
|
}
|
|
718
726
|
if (!hex) return null;
|
|
719
727
|
if (!opacityPart) {
|
|
720
|
-
if (!
|
|
728
|
+
if (!getEffectiveIsWeb() && hex.startsWith("#") && hex.length === 9) {
|
|
721
729
|
return hexToRgba(hex, Math.round(parseInt(hex.slice(7, 9), 16) / 255 * 1e3) / 1e3);
|
|
722
730
|
}
|
|
723
731
|
return hex;
|
|
@@ -751,7 +759,10 @@ function resolveSpacing(value, negative, spacing, isArbitrary) {
|
|
|
751
759
|
const resolved = getEffectiveIsWeb() ? value : toNativeValue(value);
|
|
752
760
|
if (negative) {
|
|
753
761
|
if (typeof resolved === "number") return -resolved;
|
|
754
|
-
if (typeof resolved === "string"
|
|
762
|
+
if (typeof resolved === "string") {
|
|
763
|
+
if (/^\d/.test(resolved)) return `-${resolved}`;
|
|
764
|
+
if (/^(calc|var|min|max|clamp|env)\s*\(/.test(resolved)) return `calc(-1 * (${resolved}))`;
|
|
765
|
+
}
|
|
755
766
|
}
|
|
756
767
|
return resolved;
|
|
757
768
|
}
|
|
@@ -1257,7 +1268,11 @@ var RESOLVERS = {
|
|
|
1257
1268
|
const color = resolveColor(value, colors, false);
|
|
1258
1269
|
if (color) return { borderColor: color };
|
|
1259
1270
|
const w = borderWidth[value] ?? spacing[value];
|
|
1260
|
-
if (w !== void 0)
|
|
1271
|
+
if (w !== void 0) {
|
|
1272
|
+
const numW = typeof w === "number" ? w : parseFloat(String(w));
|
|
1273
|
+
if (isNaN(numW)) return null;
|
|
1274
|
+
return { borderWidth: numW };
|
|
1275
|
+
}
|
|
1261
1276
|
return null;
|
|
1262
1277
|
},
|
|
1263
1278
|
"border-t": ({ value, isArbitrary }, { colors, borderWidth }) => {
|
|
@@ -1960,7 +1975,7 @@ var RESOLVERS = {
|
|
|
1960
1975
|
},
|
|
1961
1976
|
// ── Tint color (native-only, for Image and icon components) ──────────────
|
|
1962
1977
|
tint: ({ value, isArbitrary }, { colors }) => {
|
|
1963
|
-
if (
|
|
1978
|
+
if (getEffectiveIsWeb()) return null;
|
|
1964
1979
|
const color = resolveColor(value, colors, isArbitrary);
|
|
1965
1980
|
return color ? { tintColor: color } : null;
|
|
1966
1981
|
},
|
|
@@ -2032,7 +2047,15 @@ var RESOLVERS = {
|
|
|
2032
2047
|
const v = parseFloat(value);
|
|
2033
2048
|
return isNaN(v) ? null : { flex: v };
|
|
2034
2049
|
}
|
|
2035
|
-
if (value in flex)
|
|
2050
|
+
if (value in flex) {
|
|
2051
|
+
const v = flex[value];
|
|
2052
|
+
if (typeof v === "string" && !getEffectiveIsWeb()) {
|
|
2053
|
+
if (v === "auto" || v === "initial") return { flex: 1 };
|
|
2054
|
+
if (v === "none") return { flex: 0 };
|
|
2055
|
+
return null;
|
|
2056
|
+
}
|
|
2057
|
+
return { flex: v };
|
|
2058
|
+
}
|
|
2036
2059
|
const n = parseFloat(value);
|
|
2037
2060
|
return isNaN(n) ? null : { flex: n };
|
|
2038
2061
|
},
|
|
@@ -2135,7 +2158,9 @@ var RESOLVERS = {
|
|
|
2135
2158
|
leading: ({ value, isArbitrary }, { lineHeight }) => {
|
|
2136
2159
|
if (isArbitrary) return { lineHeight: getEffectiveIsWeb() ? value : toNativeValue(value) };
|
|
2137
2160
|
const v = lineHeight[value];
|
|
2138
|
-
|
|
2161
|
+
if (v === void 0) return null;
|
|
2162
|
+
if (typeof v === "string" && !getEffectiveIsWeb()) return { lineHeight: toNativeValue(v) };
|
|
2163
|
+
return { lineHeight: v };
|
|
2139
2164
|
},
|
|
2140
2165
|
// ── Letter spacing ─────────────────────────────────────────────────────────
|
|
2141
2166
|
tracking: ({ value, isArbitrary }, { letterSpacing }) => {
|
|
@@ -2211,7 +2236,7 @@ var RESOLVERS = {
|
|
|
2211
2236
|
transition: ({ value }) => {
|
|
2212
2237
|
if (!getEffectiveIsWeb()) return null;
|
|
2213
2238
|
const presets = {
|
|
2214
|
-
"": "color 150ms, background-color 150ms, border-color 150ms, opacity 150ms, box-shadow 150ms",
|
|
2239
|
+
"": "color 150ms, background-color 150ms, border-color 150ms, text-decoration-color 150ms, fill 150ms, stroke 150ms, opacity 150ms, box-shadow 150ms, transform 150ms, filter 150ms, backdrop-filter 150ms",
|
|
2215
2240
|
all: "all 150ms",
|
|
2216
2241
|
none: "none",
|
|
2217
2242
|
colors: "color 150ms, background-color 150ms, border-color 150ms",
|
|
@@ -2224,11 +2249,13 @@ var RESOLVERS = {
|
|
|
2224
2249
|
},
|
|
2225
2250
|
duration: ({ value, isArbitrary }) => {
|
|
2226
2251
|
if (!getEffectiveIsWeb()) return null;
|
|
2252
|
+
if (!isArbitrary && isNaN(parseFloat(value))) return null;
|
|
2227
2253
|
const ms = isArbitrary ? value : `${value}ms`;
|
|
2228
2254
|
return { transitionDuration: ms };
|
|
2229
2255
|
},
|
|
2230
2256
|
delay: ({ value, isArbitrary }) => {
|
|
2231
2257
|
if (!getEffectiveIsWeb()) return null;
|
|
2258
|
+
if (!isArbitrary && isNaN(parseFloat(value))) return null;
|
|
2232
2259
|
const ms = isArbitrary ? value : `${value}ms`;
|
|
2233
2260
|
return { transitionDelay: ms };
|
|
2234
2261
|
},
|
|
@@ -2271,14 +2298,20 @@ var RESOLVERS = {
|
|
|
2271
2298
|
boxShadow: offsetWidth === 0 ? `0 0 0 ${DEFAULT_RING_WIDTH}px ${DEFAULT_RING_COLOR}` : `0 0 0 ${offsetWidth}px #fff, 0 0 0 ${offsetWidth + DEFAULT_RING_WIDTH}px ${DEFAULT_RING_COLOR}`
|
|
2272
2299
|
};
|
|
2273
2300
|
},
|
|
2274
|
-
// ── Space between
|
|
2301
|
+
// ── Space between ─────────────────────────────────────────────────────────
|
|
2302
|
+
// On web: emits __spaceX/__spaceY markers → resolver generates > * + * CSS rules.
|
|
2303
|
+
// On native (RN 0.71+): uses columnGap/rowGap directly.
|
|
2275
2304
|
"space-x": ({ value, negative, isArbitrary }, { spacing }) => {
|
|
2276
2305
|
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
2277
|
-
|
|
2306
|
+
if (v === null) return null;
|
|
2307
|
+
if (getEffectiveIsWeb()) return { __spaceX: v };
|
|
2308
|
+
return { columnGap: v };
|
|
2278
2309
|
},
|
|
2279
2310
|
"space-y": ({ value, negative, isArbitrary }, { spacing }) => {
|
|
2280
2311
|
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
2281
|
-
|
|
2312
|
+
if (v === null) return null;
|
|
2313
|
+
if (getEffectiveIsWeb()) return { __spaceY: v };
|
|
2314
|
+
return { rowGap: v };
|
|
2282
2315
|
}
|
|
2283
2316
|
};
|
|
2284
2317
|
function resolveUtility(parsed, theme) {
|
|
@@ -2344,12 +2377,28 @@ function parseClass(className) {
|
|
|
2344
2377
|
negative = true;
|
|
2345
2378
|
remaining = remaining.slice(1);
|
|
2346
2379
|
}
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2380
|
+
let bracketDepth = 0;
|
|
2381
|
+
let bracketStart = -1;
|
|
2382
|
+
for (let i = remaining.length - 1; i >= 0; i--) {
|
|
2383
|
+
if (remaining[i] === "]") bracketDepth++;
|
|
2384
|
+
else if (remaining[i] === "[") {
|
|
2385
|
+
bracketDepth--;
|
|
2386
|
+
if (bracketDepth === 0) {
|
|
2387
|
+
bracketStart = i;
|
|
2388
|
+
break;
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2391
|
+
}
|
|
2392
|
+
if (bracketStart > 0 && remaining[bracketStart - 1] === "-" && remaining.endsWith("]")) {
|
|
2393
|
+
const utility = remaining.slice(0, bracketStart - 1);
|
|
2394
|
+
const value = remaining.slice(bracketStart + 1, -1).replace(/_/g, " ");
|
|
2351
2395
|
return { original: trimmed, modifiers, negative, important, utility, value, isArbitrary: true };
|
|
2352
2396
|
}
|
|
2397
|
+
if (remaining.endsWith("]") && bracketStart === -1) {
|
|
2398
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2399
|
+
console.warn(`[kbach] Malformed class string: "${trimmed}" \u2014 unbalanced brackets`);
|
|
2400
|
+
}
|
|
2401
|
+
}
|
|
2353
2402
|
if (remaining.startsWith("[") && remaining.endsWith("]")) {
|
|
2354
2403
|
const value = remaining.slice(1, -1).replace(/_/g, " ");
|
|
2355
2404
|
return { original: trimmed, modifiers, negative, important, utility: "", value, isArbitrary: true };
|
|
@@ -2384,6 +2433,7 @@ function splitClassTokens(classString) {
|
|
|
2384
2433
|
const tokens = [];
|
|
2385
2434
|
let current = "";
|
|
2386
2435
|
let depth = 0;
|
|
2436
|
+
let parenDepth = 0;
|
|
2387
2437
|
for (let i = 0; i < classString.length; i++) {
|
|
2388
2438
|
const ch = classString[i];
|
|
2389
2439
|
if (ch === "[") {
|
|
@@ -2396,8 +2446,18 @@ function splitClassTokens(classString) {
|
|
|
2396
2446
|
current += ch;
|
|
2397
2447
|
continue;
|
|
2398
2448
|
}
|
|
2449
|
+
if (ch === "(") {
|
|
2450
|
+
parenDepth++;
|
|
2451
|
+
current += ch;
|
|
2452
|
+
continue;
|
|
2453
|
+
}
|
|
2454
|
+
if (ch === ")") {
|
|
2455
|
+
parenDepth--;
|
|
2456
|
+
current += ch;
|
|
2457
|
+
continue;
|
|
2458
|
+
}
|
|
2399
2459
|
if (/\s/.test(ch)) {
|
|
2400
|
-
if (depth === 0) {
|
|
2460
|
+
if (depth === 0 && parenDepth === 0) {
|
|
2401
2461
|
if (current) {
|
|
2402
2462
|
tokens.push(current);
|
|
2403
2463
|
current = "";
|
|
@@ -2453,6 +2513,7 @@ var BASE_RESET = [
|
|
|
2453
2513
|
var LRUCache = class {
|
|
2454
2514
|
constructor(capacity = 1e4) {
|
|
2455
2515
|
this.capacity = capacity;
|
|
2516
|
+
if (capacity <= 0) throw new Error("LRUCache: capacity must be a positive integer");
|
|
2456
2517
|
this.cache = /* @__PURE__ */ new Map();
|
|
2457
2518
|
}
|
|
2458
2519
|
get(key) {
|
|
@@ -2472,11 +2533,7 @@ var LRUCache = class {
|
|
|
2472
2533
|
return this;
|
|
2473
2534
|
}
|
|
2474
2535
|
has(key) {
|
|
2475
|
-
|
|
2476
|
-
const value = this.cache.get(key);
|
|
2477
|
-
this.cache.delete(key);
|
|
2478
|
-
this.cache.set(key, value);
|
|
2479
|
-
return true;
|
|
2536
|
+
return this.cache.has(key);
|
|
2480
2537
|
}
|
|
2481
2538
|
delete(key) {
|
|
2482
2539
|
return this.cache.delete(key);
|
|
@@ -2511,7 +2568,7 @@ function setGlobalWidth(width) {
|
|
|
2511
2568
|
const store = getStore();
|
|
2512
2569
|
if (store.width === width) return;
|
|
2513
2570
|
store.width = width;
|
|
2514
|
-
for (const l of store.listeners) l(
|
|
2571
|
+
for (const l of store.listeners) l();
|
|
2515
2572
|
}
|
|
2516
2573
|
function getGlobalWidth() {
|
|
2517
2574
|
return getStore().width;
|
|
@@ -2584,7 +2641,8 @@ function injectRule(rule) {
|
|
|
2584
2641
|
if (_injectedRules.has(rule)) return;
|
|
2585
2642
|
_injectedRules.set(rule, true);
|
|
2586
2643
|
try {
|
|
2587
|
-
|
|
2644
|
+
const sheet = getStyleEl().sheet;
|
|
2645
|
+
if (sheet) sheet.insertRule(rule, sheet.cssRules.length);
|
|
2588
2646
|
} catch {
|
|
2589
2647
|
}
|
|
2590
2648
|
}
|
|
@@ -2600,24 +2658,41 @@ function injectGlobalStyles(theme) {
|
|
|
2600
2658
|
if (typeof document === "undefined" || isRuntimeCSSDisabled()) return;
|
|
2601
2659
|
const rules = [BASE_RESET];
|
|
2602
2660
|
const ff = theme.fontFamily;
|
|
2661
|
+
if (!ff) return;
|
|
2603
2662
|
if (ff.sans && ff.sans !== "System") {
|
|
2604
2663
|
const family = Array.isArray(ff.sans) ? ff.sans.join(", ") : ff.sans;
|
|
2605
2664
|
rules.push(`body { font-family: ${family}; }`);
|
|
2606
2665
|
}
|
|
2607
2666
|
getGlobalStyleEl().textContent = rules.join("\n");
|
|
2608
2667
|
}
|
|
2609
|
-
function buildDivideDecls(styles) {
|
|
2668
|
+
function buildDivideDecls(styles, forceImportant) {
|
|
2669
|
+
const imp = forceImportant ? " !important" : "";
|
|
2610
2670
|
const parts = [];
|
|
2611
2671
|
if ("__divideX" in styles) {
|
|
2612
2672
|
const w = Number(styles.__divideX);
|
|
2613
|
-
parts.push(`border-left-width: ${w}px`,
|
|
2673
|
+
parts.push(`border-left-width: ${w}px${imp}`, `border-right-width: 0px${imp}`);
|
|
2614
2674
|
}
|
|
2615
2675
|
if ("__divideY" in styles) {
|
|
2616
2676
|
const w = Number(styles.__divideY);
|
|
2617
|
-
parts.push(`border-top-width: ${w}px`,
|
|
2677
|
+
parts.push(`border-top-width: ${w}px${imp}`, `border-bottom-width: 0px${imp}`);
|
|
2678
|
+
}
|
|
2679
|
+
if ("__divideColor" in styles) parts.push(`border-color: ${String(styles.__divideColor)}${imp}`);
|
|
2680
|
+
if ("__divideStyle" in styles) parts.push(`border-style: ${String(styles.__divideStyle)}${imp}`);
|
|
2681
|
+
return parts.join("; ");
|
|
2682
|
+
}
|
|
2683
|
+
function buildSpaceDecls(styles, forceImportant) {
|
|
2684
|
+
const imp = forceImportant ? " !important" : "";
|
|
2685
|
+
const parts = [];
|
|
2686
|
+
if ("__spaceX" in styles) {
|
|
2687
|
+
const v = styles.__spaceX;
|
|
2688
|
+
const val = typeof v === "number" ? `${v}px` : String(v);
|
|
2689
|
+
parts.push(`margin-left: ${val}${imp}`);
|
|
2690
|
+
}
|
|
2691
|
+
if ("__spaceY" in styles) {
|
|
2692
|
+
const v = styles.__spaceY;
|
|
2693
|
+
const val = typeof v === "number" ? `${v}px` : String(v);
|
|
2694
|
+
parts.push(`margin-top: ${val}${imp}`);
|
|
2618
2695
|
}
|
|
2619
|
-
if ("__divideColor" in styles) parts.push(`border-color: ${String(styles.__divideColor)}`);
|
|
2620
|
-
if ("__divideStyle" in styles) parts.push(`border-style: ${String(styles.__divideStyle)}`);
|
|
2621
2696
|
return parts.join("; ");
|
|
2622
2697
|
}
|
|
2623
2698
|
var RN_ONLY_PROPS = /* @__PURE__ */ new Set([
|
|
@@ -2637,7 +2712,9 @@ var RN_ONLY_PROPS = /* @__PURE__ */ new Set([
|
|
|
2637
2712
|
"__divideY",
|
|
2638
2713
|
"__divideColor",
|
|
2639
2714
|
"__divideStyle",
|
|
2640
|
-
"__keyframe"
|
|
2715
|
+
"__keyframe",
|
|
2716
|
+
"__spaceX",
|
|
2717
|
+
"__spaceY"
|
|
2641
2718
|
]);
|
|
2642
2719
|
var CSS_UNITLESS = /* @__PURE__ */ new Set([
|
|
2643
2720
|
"opacity",
|
|
@@ -2690,10 +2767,12 @@ function buildClassCSSRules(cls, bucketKey, styles, darkMode, important, screens
|
|
|
2690
2767
|
rules.push(styles.__keyframe);
|
|
2691
2768
|
}
|
|
2692
2769
|
const isDivide = "__divideX" in styles || "__divideY" in styles || "__divideColor" in styles || "__divideStyle" in styles;
|
|
2770
|
+
const isSpace = "__spaceX" in styles || "__spaceY" in styles;
|
|
2771
|
+
const isChildCombinator = isDivide || isSpace;
|
|
2693
2772
|
const escaped = escapeCSSSelector(cls);
|
|
2694
|
-
const childSuffix =
|
|
2773
|
+
const childSuffix = isChildCombinator ? " > * + *" : "";
|
|
2695
2774
|
if (bucketKey === "base") {
|
|
2696
|
-
const decls2 = isDivide ? buildDivideDecls(styles) : styleValueToCSS(styles, important);
|
|
2775
|
+
const decls2 = isDivide ? buildDivideDecls(styles, important) : isSpace ? buildSpaceDecls(styles, important) : styleValueToCSS(styles, important);
|
|
2697
2776
|
if (!decls2) return rules;
|
|
2698
2777
|
rules.push(`.${escaped}${childSuffix} { ${decls2} }`);
|
|
2699
2778
|
return rules;
|
|
@@ -2734,7 +2813,7 @@ function buildClassCSSRules(cls, bucketKey, styles, darkMode, important, screens
|
|
|
2734
2813
|
const ancestorPrefix = ancestorParts.join("");
|
|
2735
2814
|
const dirPrefix = dirParts.join("");
|
|
2736
2815
|
const selector = `${dirPrefix}${ancestorPrefix}${elementSelector}`;
|
|
2737
|
-
const decls = isDivide ? buildDivideDecls(styles) : styleValueToCSS(styles, needsImportant);
|
|
2816
|
+
const decls = isDivide ? buildDivideDecls(styles, needsImportant) : isSpace ? buildSpaceDecls(styles, needsImportant) : styleValueToCSS(styles, needsImportant);
|
|
2738
2817
|
if (!decls) return rules;
|
|
2739
2818
|
let rule;
|
|
2740
2819
|
if (darkScheme === "dark") {
|
|
@@ -2773,7 +2852,7 @@ function resolve(classString, theme, darkMode = "attribute") {
|
|
|
2773
2852
|
const cached = cache.get(cacheKey);
|
|
2774
2853
|
if (cached) return cached;
|
|
2775
2854
|
const result = {};
|
|
2776
|
-
const onWeb =
|
|
2855
|
+
const onWeb = isWeb;
|
|
2777
2856
|
for (const parsed of parseClasses(classString)) {
|
|
2778
2857
|
const styles = resolveUtility(parsed, theme);
|
|
2779
2858
|
if (!styles) {
|
|
@@ -2846,6 +2925,10 @@ function clearCache() {
|
|
|
2846
2925
|
_styleEl.remove();
|
|
2847
2926
|
_styleEl = null;
|
|
2848
2927
|
}
|
|
2928
|
+
if (_globalStyleEl) {
|
|
2929
|
+
_globalStyleEl.remove();
|
|
2930
|
+
_globalStyleEl = null;
|
|
2931
|
+
}
|
|
2849
2932
|
}
|
|
2850
2933
|
|
|
2851
2934
|
// src/core/config.ts
|
|
@@ -2917,19 +3000,24 @@ function buildConfig(userConfig) {
|
|
|
2917
3000
|
theme = deepMerge(theme, userConfig.theme);
|
|
2918
3001
|
}
|
|
2919
3002
|
if (userConfig.extend) {
|
|
2920
|
-
const
|
|
3003
|
+
const extendConfig = userConfig.extend;
|
|
3004
|
+
const { theme: nestedTheme, ...directKeys } = extendConfig;
|
|
2921
3005
|
const extSources = [];
|
|
2922
3006
|
if (nestedTheme) extSources.push(nestedTheme);
|
|
2923
3007
|
if (Object.keys(directKeys).length) extSources.push(directKeys);
|
|
2924
3008
|
for (const ext of extSources) {
|
|
2925
3009
|
for (const [key, value] of Object.entries(ext)) {
|
|
3010
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
3011
|
+
if (process.env.NODE_ENV !== "production") {
|
|
3012
|
+
console.warn(`[kbach] config.extend.${key} must be a plain object, got ${typeof value}. Skipping.`);
|
|
3013
|
+
}
|
|
3014
|
+
continue;
|
|
3015
|
+
}
|
|
2926
3016
|
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
2927
3017
|
theme[key] = deepMerge(
|
|
2928
3018
|
theme[key] ?? {},
|
|
2929
3019
|
value
|
|
2930
3020
|
);
|
|
2931
|
-
} else if (value !== void 0) {
|
|
2932
|
-
theme[key] = value;
|
|
2933
3021
|
}
|
|
2934
3022
|
}
|
|
2935
3023
|
}
|
|
@@ -2940,8 +3028,10 @@ function buildConfig(userConfig) {
|
|
|
2940
3028
|
theme,
|
|
2941
3029
|
plugins: userConfig.plugins ?? []
|
|
2942
3030
|
};
|
|
2943
|
-
|
|
2944
|
-
|
|
3031
|
+
if (userConfig.plugins !== void 0) {
|
|
3032
|
+
clearPluginUtilities();
|
|
3033
|
+
clearPluginModifiers();
|
|
3034
|
+
}
|
|
2945
3035
|
const _store = getConfigStore();
|
|
2946
3036
|
for (const k of Object.keys(_store.customVariants)) delete _store.customVariants[k];
|
|
2947
3037
|
const pluginAPI = makePluginAPI(resolved.theme);
|
|
@@ -2959,7 +3049,7 @@ function _selectorToModifierDef(selector) {
|
|
|
2959
3049
|
if (s.startsWith("@media ")) {
|
|
2960
3050
|
return { mediaQuery: s.slice(7), jsBehavior: "css-only", forcesImportant: true };
|
|
2961
3051
|
}
|
|
2962
|
-
if (s.startsWith("::") || s.startsWith(":")) {
|
|
3052
|
+
if (s.startsWith("::") || s.startsWith(":") && !s.includes(" ") && !s.includes("&") && !s.includes("(")) {
|
|
2963
3053
|
return { pseudo: s, jsBehavior: "css-only", forcesImportant: true };
|
|
2964
3054
|
}
|
|
2965
3055
|
return { ancestorSelector: s.endsWith(" ") ? s : `${s} `, jsBehavior: "css-only", forcesImportant: true };
|
|
@@ -2972,8 +3062,8 @@ function makePluginAPI(theme) {
|
|
|
2972
3062
|
},
|
|
2973
3063
|
addVariant(name, selectorOrDef) {
|
|
2974
3064
|
const def = typeof selectorOrDef === "string" ? _selectorToModifierDef(selectorOrDef) : selectorOrDef;
|
|
2975
|
-
const selector = typeof selectorOrDef === "string" ? selectorOrDef : selectorOrDef.pseudo ?? selectorOrDef.mediaQuery ?? selectorOrDef.ancestorSelector ??
|
|
2976
|
-
customVariants[name] = selector;
|
|
3065
|
+
const selector = typeof selectorOrDef === "string" ? selectorOrDef : selectorOrDef.pseudo ?? selectorOrDef.mediaQuery ?? selectorOrDef.ancestorSelector ?? null;
|
|
3066
|
+
if (selector !== null && selector !== name) customVariants[name] = selector;
|
|
2977
3067
|
registerModifier(name, def);
|
|
2978
3068
|
},
|
|
2979
3069
|
theme(path, defaultValue) {
|
|
@@ -3046,6 +3136,7 @@ export {
|
|
|
3046
3136
|
BASE_RESET,
|
|
3047
3137
|
syncGlobalWidth,
|
|
3048
3138
|
syncGlobalScreens,
|
|
3139
|
+
getGlobalScreens,
|
|
3049
3140
|
setGlobalWidth,
|
|
3050
3141
|
getGlobalWidth,
|
|
3051
3142
|
subscribeGlobalWidth,
|
|
@@ -6,12 +6,13 @@ import {
|
|
|
6
6
|
transformToWebProps,
|
|
7
7
|
useConditionalWidth,
|
|
8
8
|
useGlobalDarkMode
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-F5NQX5YO.mjs";
|
|
10
10
|
import {
|
|
11
11
|
flatten,
|
|
12
12
|
getActiveBreakpoints,
|
|
13
13
|
getConfig,
|
|
14
14
|
getDefaultFontFamily,
|
|
15
|
+
getGlobalScreens,
|
|
15
16
|
getInteractiveModifiers,
|
|
16
17
|
getModeModifiers,
|
|
17
18
|
getResponsiveModifiers,
|
|
@@ -19,8 +20,9 @@ import {
|
|
|
19
20
|
isRuntimeCSSDisabled,
|
|
20
21
|
isWeb,
|
|
21
22
|
normalizeClassString,
|
|
23
|
+
onConfigChange,
|
|
22
24
|
resolve
|
|
23
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-2HWRNTJG.mjs";
|
|
24
26
|
|
|
25
27
|
// src/jsx-runtime.tsx
|
|
26
28
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -34,6 +36,7 @@ var DarkWrapper = React.forwardRef(
|
|
|
34
36
|
const needsWidth = hasResponsiveBuckets(resolvedStyle);
|
|
35
37
|
const width = useConditionalWidth(needsWidth);
|
|
36
38
|
const breakpoints = needsWidth ? getActiveBreakpoints(width) : EMPTY_BREAKPOINTS;
|
|
39
|
+
const screens = getGlobalScreens();
|
|
37
40
|
const isNonStringComponent = typeof Component !== "string";
|
|
38
41
|
const computedStyle = useMemo(() => {
|
|
39
42
|
if (isWeb) return {};
|
|
@@ -41,7 +44,7 @@ var DarkWrapper = React.forwardRef(
|
|
|
41
44
|
stripInternalMarkers(s);
|
|
42
45
|
if (isNonStringComponent) stripWebOnlyProps(s);
|
|
43
46
|
return s;
|
|
44
|
-
}, [resolvedStyle, isDark, width, isNonStringComponent]);
|
|
47
|
+
}, [resolvedStyle, isDark, width, screens, isNonStringComponent]);
|
|
45
48
|
const skipComputedInline = isWeb || !isNative && typeof Component === "string";
|
|
46
49
|
const finalStyle = skipComputedInline ? styleProp ?? void 0 : styleProp ? Array.isArray(styleProp) ? Object.assign({}, computedStyle, ...styleProp) : { ...computedStyle, ...styleProp } : computedStyle;
|
|
47
50
|
const props = { ref, ...rest, style: finalStyle };
|
|
@@ -87,6 +90,7 @@ var _lastFontVersion = -1;
|
|
|
87
90
|
function _invalidateDefaultFontCache() {
|
|
88
91
|
_defaultFontVersion++;
|
|
89
92
|
}
|
|
93
|
+
onConfigChange(_invalidateDefaultFontCache);
|
|
90
94
|
function getCachedDefaultFont() {
|
|
91
95
|
if (_lastFontVersion !== _defaultFontVersion) {
|
|
92
96
|
_cachedDefaultFont = getDefaultFontFamily();
|
|
@@ -162,7 +166,7 @@ function stripWebOnlyInlineProps(s) {
|
|
|
162
166
|
}
|
|
163
167
|
}
|
|
164
168
|
function processElement(type, rawProps, key, isStaticChildren) {
|
|
165
|
-
if (typeof type === "symbol") return makeElement(isStaticChildren, type, rawProps ?? {}, key);
|
|
169
|
+
if (type === null || typeof type === "symbol") return makeElement(isStaticChildren, type, rawProps ?? {}, key);
|
|
166
170
|
const webTag = isWeb ? getWebTag(type, rawProps ?? void 0) : null;
|
|
167
171
|
const effectiveType = webTag ?? type;
|
|
168
172
|
const originalName = webTag ? type?.displayName ?? type?.name : void 0;
|
|
@@ -220,7 +224,7 @@ function processElement(type, rawProps, key, isStaticChildren) {
|
|
|
220
224
|
}
|
|
221
225
|
return makeElement(isStaticChildren, effectiveType, {
|
|
222
226
|
...passProps,
|
|
223
|
-
style: finalStyle,
|
|
227
|
+
...finalStyle !== void 0 ? { style: finalStyle } : {},
|
|
224
228
|
...!isNative && classStr ? { className: normalizeClassString(classStr) } : {}
|
|
225
229
|
}, key);
|
|
226
230
|
}
|