@kbach/react 0.5.43 → 0.5.44
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-IBAKFGFG.mjs → chunk-52N32L7A.mjs} +11 -1
- package/dist/{chunk-SX43SDOD.mjs → chunk-BBI6IU22.mjs} +3 -2
- package/dist/{chunk-4NTWFAHW.mjs → chunk-MIBPTKXT.mjs} +26 -34
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +13 -2
- package/dist/index.mjs +4 -2
- package/dist/jsx-dev-runtime.js +31 -34
- package/dist/jsx-dev-runtime.mjs +3 -3
- package/dist/jsx-runtime.js +31 -34
- package/dist/jsx-runtime.mjs +3 -3
- package/dist/vite-plugin.js +17 -1
- package/dist/vite-plugin.mjs +13 -1
- package/package.json +1 -1
|
@@ -2549,6 +2549,13 @@ function getDefaultFontFamily() {
|
|
|
2549
2549
|
}
|
|
2550
2550
|
var _styleEl = null;
|
|
2551
2551
|
var _injectedRules = new LRUCache(5e4);
|
|
2552
|
+
var _CSS_DISABLED_KEY = "__kbach_runtime_css_disabled__";
|
|
2553
|
+
function disableRuntimeCSS() {
|
|
2554
|
+
globalThis[_CSS_DISABLED_KEY] = true;
|
|
2555
|
+
}
|
|
2556
|
+
function isRuntimeCSSDisabled() {
|
|
2557
|
+
return !!globalThis[_CSS_DISABLED_KEY];
|
|
2558
|
+
}
|
|
2552
2559
|
function getStyleEl() {
|
|
2553
2560
|
if (_styleEl) return _styleEl;
|
|
2554
2561
|
_styleEl = document.createElement("style");
|
|
@@ -2557,6 +2564,7 @@ function getStyleEl() {
|
|
|
2557
2564
|
return _styleEl;
|
|
2558
2565
|
}
|
|
2559
2566
|
function injectRule(rule) {
|
|
2567
|
+
if (isRuntimeCSSDisabled()) return;
|
|
2560
2568
|
if (_injectedRules.has(rule)) return;
|
|
2561
2569
|
_injectedRules.set(rule, true);
|
|
2562
2570
|
try {
|
|
@@ -2573,7 +2581,7 @@ function getGlobalStyleEl() {
|
|
|
2573
2581
|
return _globalStyleEl;
|
|
2574
2582
|
}
|
|
2575
2583
|
function injectGlobalStyles(theme) {
|
|
2576
|
-
if (typeof document === "undefined") return;
|
|
2584
|
+
if (typeof document === "undefined" || isRuntimeCSSDisabled()) return;
|
|
2577
2585
|
const rules = [];
|
|
2578
2586
|
const ff = theme.fontFamily;
|
|
2579
2587
|
if (ff.sans && ff.sans !== "System") {
|
|
@@ -3022,6 +3030,8 @@ export {
|
|
|
3022
3030
|
subscribeGlobalWidth,
|
|
3023
3031
|
getActiveBreakpoints,
|
|
3024
3032
|
getDefaultFontFamily,
|
|
3033
|
+
disableRuntimeCSS,
|
|
3034
|
+
isRuntimeCSSDisabled,
|
|
3025
3035
|
generateClassCSS,
|
|
3026
3036
|
resolve,
|
|
3027
3037
|
flatten,
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
isNative,
|
|
7
7
|
isWeb,
|
|
8
8
|
subscribeGlobalWidth
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-52N32L7A.mjs";
|
|
10
10
|
|
|
11
11
|
// src/core/darkModeStore.ts
|
|
12
12
|
var KEY = "__kbach_dark_store__";
|
|
@@ -198,7 +198,8 @@ var InteractiveWrapper = forwardRef(
|
|
|
198
198
|
[resolvedStyle, isDark, pressed, hovered, focused, width]
|
|
199
199
|
// eslint-disable-line react-hooks/exhaustive-deps
|
|
200
200
|
);
|
|
201
|
-
const
|
|
201
|
+
const isWebHTMLElement = !isNative && typeof Component === "string";
|
|
202
|
+
const finalStyle = isWebHTMLElement ? styleProp ?? void 0 : styleProp ? Array.isArray(styleProp) ? Object.assign({}, computedStyle, ...styleProp) : { ...computedStyle, ...styleProp } : computedStyle;
|
|
202
203
|
const { children, ...restWithoutChildren } = rest;
|
|
203
204
|
const componentProps = {
|
|
204
205
|
ref,
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
hasResponsiveBuckets,
|
|
5
5
|
useConditionalWidth,
|
|
6
6
|
useGlobalDarkMode
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-BBI6IU22.mjs";
|
|
8
8
|
import {
|
|
9
9
|
flatten,
|
|
10
10
|
getActiveBreakpoints,
|
|
@@ -14,9 +14,10 @@ import {
|
|
|
14
14
|
getModeModifiers,
|
|
15
15
|
getResponsiveModifiers,
|
|
16
16
|
isNative,
|
|
17
|
+
isRuntimeCSSDisabled,
|
|
17
18
|
normalizeClassString,
|
|
18
19
|
resolve
|
|
19
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-52N32L7A.mjs";
|
|
20
21
|
|
|
21
22
|
// src/jsx-runtime.tsx
|
|
22
23
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -33,7 +34,8 @@ var DarkWrapper = React.forwardRef(
|
|
|
33
34
|
const computedStyle = flatten(resolvedStyle, isDark, {}, breakpoints);
|
|
34
35
|
stripInternalMarkers(computedStyle);
|
|
35
36
|
if (typeof Component !== "string") stripWebOnlyProps(computedStyle);
|
|
36
|
-
const
|
|
37
|
+
const isWebHTMLElement = !isNative && typeof Component === "string";
|
|
38
|
+
const finalStyle = isWebHTMLElement ? styleProp ?? void 0 : styleProp ? Array.isArray(styleProp) ? Object.assign({}, computedStyle, ...styleProp) : { ...computedStyle, ...styleProp } : computedStyle;
|
|
37
39
|
const props = { ref, ...rest, style: finalStyle };
|
|
38
40
|
return Array.isArray(children) ? React.createElement(Component, props, ...children) : React.createElement(Component, props, children);
|
|
39
41
|
}
|
|
@@ -121,27 +123,6 @@ function mergeStyle(computed, userStyle) {
|
|
|
121
123
|
function makeElement(isStaticChildren, type, props, key) {
|
|
122
124
|
return (isStaticChildren ? _jsxs : _jsx)(type, props, key);
|
|
123
125
|
}
|
|
124
|
-
function hasGridStyles(resolved) {
|
|
125
|
-
for (const styles of Object.values(resolved)) {
|
|
126
|
-
if (!styles) continue;
|
|
127
|
-
if (styles.display === "grid" || styles.display === "inline-grid") return true;
|
|
128
|
-
if ("gridTemplateColumns" in styles || "gridTemplateRows" in styles) return true;
|
|
129
|
-
if ("gridColumn" in styles || "gridRow" in styles) return true;
|
|
130
|
-
if ("gridColumnStart" in styles || "gridColumnEnd" in styles) return true;
|
|
131
|
-
if ("gridRowStart" in styles || "gridRowEnd" in styles) return true;
|
|
132
|
-
if ("gridAutoFlow" in styles || "gridAutoColumns" in styles || "gridAutoRows" in styles) return true;
|
|
133
|
-
if ("placeItems" in styles || "placeContent" in styles || "justifyItems" in styles) return true;
|
|
134
|
-
if ("placeSelf" in styles || "justifySelf" in styles) return true;
|
|
135
|
-
}
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
|
-
function hasWebPositionStyles(resolved) {
|
|
139
|
-
for (const styles of Object.values(resolved)) {
|
|
140
|
-
if (!styles) continue;
|
|
141
|
-
if (styles.position === "sticky" || styles.position === "fixed" || styles.position === "static") return true;
|
|
142
|
-
}
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
145
126
|
function stripInternalMarkers2(s) {
|
|
146
127
|
delete s.__divideX;
|
|
147
128
|
delete s.__divideY;
|
|
@@ -177,6 +158,14 @@ function processElement(type, rawProps, key, isStaticChildren) {
|
|
|
177
158
|
if (!rawProps) return _jsx(type, null, key);
|
|
178
159
|
const { className, kb: kbProp, __kbachStyles, __kbachClasses } = rawProps;
|
|
179
160
|
const classStr = className ?? kbProp ?? __kbachClasses;
|
|
161
|
+
if (!isNative && isRuntimeCSSDisabled() && classStr && !__kbachStyles) {
|
|
162
|
+
const { style: userStyle2, ...passProps2 } = omitConsumed(rawProps);
|
|
163
|
+
return makeElement(isStaticChildren, type, {
|
|
164
|
+
...passProps2,
|
|
165
|
+
className: normalizeClassString(classStr),
|
|
166
|
+
...userStyle2 !== void 0 ? { style: userStyle2 } : {}
|
|
167
|
+
}, key);
|
|
168
|
+
}
|
|
180
169
|
if (!classStr && !__kbachStyles) {
|
|
181
170
|
const defaultFont = getCachedDefaultFont();
|
|
182
171
|
if (!defaultFont) return makeElement(isStaticChildren, type, rawProps, key);
|
|
@@ -188,12 +177,9 @@ function processElement(type, rawProps, key, isStaticChildren) {
|
|
|
188
177
|
const resolved = __kbachStyles ?? (classStr ? resolve(classStr, config.theme, config.darkMode) : {});
|
|
189
178
|
const { style: userStyle, ...passProps } = omitConsumed(rawProps);
|
|
190
179
|
const { interactive, modeOrResponsive } = bucketMods(resolved);
|
|
191
|
-
const onWeb = typeof document !== "undefined";
|
|
192
|
-
const needsDiv = onWeb && (hasGridStyles(resolved) || hasWebPositionStyles(resolved));
|
|
193
|
-
const actualType = needsDiv ? "div" : type;
|
|
194
180
|
if (interactive) {
|
|
195
181
|
return _jsx(InteractiveWrapper, {
|
|
196
|
-
Component:
|
|
182
|
+
Component: type,
|
|
197
183
|
resolvedStyle: resolved,
|
|
198
184
|
...!isNative && classStr ? { className: normalizeClassString(classStr) } : {},
|
|
199
185
|
style: userStyle,
|
|
@@ -202,18 +188,24 @@ function processElement(type, rawProps, key, isStaticChildren) {
|
|
|
202
188
|
}
|
|
203
189
|
if (modeOrResponsive) {
|
|
204
190
|
return _jsx(DarkWrapper, {
|
|
205
|
-
Component:
|
|
191
|
+
Component: type,
|
|
206
192
|
resolvedStyle: resolved,
|
|
207
193
|
...!isNative && classStr ? { className: normalizeClassString(classStr) } : {},
|
|
208
194
|
style: userStyle,
|
|
209
195
|
...passProps
|
|
210
196
|
}, key);
|
|
211
197
|
}
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
if (
|
|
215
|
-
|
|
216
|
-
|
|
198
|
+
const isWebHTMLElement = !isNative && typeof type === "string";
|
|
199
|
+
let finalStyle;
|
|
200
|
+
if (!isWebHTMLElement) {
|
|
201
|
+
const computedStyle = flatten(resolved, false);
|
|
202
|
+
stripInternalMarkers2(computedStyle);
|
|
203
|
+
if (typeof type !== "string") stripWebOnlyInlineProps(computedStyle);
|
|
204
|
+
finalStyle = mergeStyle(computedStyle, userStyle);
|
|
205
|
+
} else {
|
|
206
|
+
finalStyle = userStyle ?? void 0;
|
|
207
|
+
}
|
|
208
|
+
return makeElement(isStaticChildren, type, {
|
|
217
209
|
...passProps,
|
|
218
210
|
style: finalStyle,
|
|
219
211
|
...!isNative && classStr ? { className: normalizeClassString(classStr) } : {}
|
package/dist/index.d.mts
CHANGED
|
@@ -21,6 +21,7 @@ declare function normalizeClassString(classString: string): string;
|
|
|
21
21
|
/** Parse a space-separated class string into individual ParsedClass objects. */
|
|
22
22
|
declare function parseClasses(classString: string): ParsedClass[];
|
|
23
23
|
|
|
24
|
+
declare function disableRuntimeCSS(): void;
|
|
24
25
|
/**
|
|
25
26
|
* Resolve a class string to a ResolvedStyle object.
|
|
26
27
|
*
|
|
@@ -304,4 +305,4 @@ declare function kb(classString: string, isDark?: boolean): StyleValue | string;
|
|
|
304
305
|
*/
|
|
305
306
|
declare function cx(...classes: Array<string | false | null | undefined>): string;
|
|
306
307
|
|
|
307
|
-
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, ThemeToggle, type ThemeToggleProps, type ToggleVariant, buildConfig, cx, defaultColors, defaultTheme, flatten, getConfig, initConfig, kb, normalizeClassString, parseClass, parseClasses, resolve, splitClassTokens, styled, updateConfig, useBreakpoint, useColors, useGlobalDarkMode, useIsDark, useResolvedStyle, useResponsive, useStyles, useTheme, wrapColors };
|
|
308
|
+
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, ThemeToggle, type ThemeToggleProps, type ToggleVariant, buildConfig, cx, defaultColors, defaultTheme, disableRuntimeCSS, flatten, getConfig, initConfig, kb, normalizeClassString, parseClass, parseClasses, resolve, splitClassTokens, styled, updateConfig, useBreakpoint, useColors, useGlobalDarkMode, useIsDark, useResolvedStyle, useResponsive, useStyles, useTheme, wrapColors };
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ declare function normalizeClassString(classString: string): string;
|
|
|
21
21
|
/** Parse a space-separated class string into individual ParsedClass objects. */
|
|
22
22
|
declare function parseClasses(classString: string): ParsedClass[];
|
|
23
23
|
|
|
24
|
+
declare function disableRuntimeCSS(): void;
|
|
24
25
|
/**
|
|
25
26
|
* Resolve a class string to a ResolvedStyle object.
|
|
26
27
|
*
|
|
@@ -304,4 +305,4 @@ declare function kb(classString: string, isDark?: boolean): StyleValue | string;
|
|
|
304
305
|
*/
|
|
305
306
|
declare function cx(...classes: Array<string | false | null | undefined>): string;
|
|
306
307
|
|
|
307
|
-
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, ThemeToggle, type ThemeToggleProps, type ToggleVariant, buildConfig, cx, defaultColors, defaultTheme, flatten, getConfig, initConfig, kb, normalizeClassString, parseClass, parseClasses, resolve, splitClassTokens, styled, updateConfig, useBreakpoint, useColors, useGlobalDarkMode, useIsDark, useResolvedStyle, useResponsive, useStyles, useTheme, wrapColors };
|
|
308
|
+
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, ThemeToggle, type ThemeToggleProps, type ToggleVariant, buildConfig, cx, defaultColors, defaultTheme, disableRuntimeCSS, flatten, getConfig, initConfig, kb, normalizeClassString, parseClass, parseClasses, resolve, splitClassTokens, styled, updateConfig, useBreakpoint, useColors, useGlobalDarkMode, useIsDark, useResolvedStyle, useResponsive, useStyles, useTheme, wrapColors };
|
package/dist/index.js
CHANGED
|
@@ -38,6 +38,7 @@ __export(index_exports, {
|
|
|
38
38
|
cx: () => cx,
|
|
39
39
|
defaultColors: () => defaultColors,
|
|
40
40
|
defaultTheme: () => defaultTheme,
|
|
41
|
+
disableRuntimeCSS: () => disableRuntimeCSS,
|
|
41
42
|
flatten: () => flatten,
|
|
42
43
|
getConfig: () => getConfig,
|
|
43
44
|
initConfig: () => initConfig,
|
|
@@ -2679,6 +2680,13 @@ function getDefaultFontFamily() {
|
|
|
2679
2680
|
}
|
|
2680
2681
|
var _styleEl = null;
|
|
2681
2682
|
var _injectedRules = new LRUCache(5e4);
|
|
2683
|
+
var _CSS_DISABLED_KEY = "__kbach_runtime_css_disabled__";
|
|
2684
|
+
function disableRuntimeCSS() {
|
|
2685
|
+
globalThis[_CSS_DISABLED_KEY] = true;
|
|
2686
|
+
}
|
|
2687
|
+
function isRuntimeCSSDisabled() {
|
|
2688
|
+
return !!globalThis[_CSS_DISABLED_KEY];
|
|
2689
|
+
}
|
|
2682
2690
|
function getStyleEl() {
|
|
2683
2691
|
if (_styleEl) return _styleEl;
|
|
2684
2692
|
_styleEl = document.createElement("style");
|
|
@@ -2687,6 +2695,7 @@ function getStyleEl() {
|
|
|
2687
2695
|
return _styleEl;
|
|
2688
2696
|
}
|
|
2689
2697
|
function injectRule(rule) {
|
|
2698
|
+
if (isRuntimeCSSDisabled()) return;
|
|
2690
2699
|
if (_injectedRules.has(rule)) return;
|
|
2691
2700
|
_injectedRules.set(rule, true);
|
|
2692
2701
|
try {
|
|
@@ -2703,7 +2712,7 @@ function getGlobalStyleEl() {
|
|
|
2703
2712
|
return _globalStyleEl;
|
|
2704
2713
|
}
|
|
2705
2714
|
function injectGlobalStyles(theme) {
|
|
2706
|
-
if (typeof document === "undefined") return;
|
|
2715
|
+
if (typeof document === "undefined" || isRuntimeCSSDisabled()) return;
|
|
2707
2716
|
const rules = [];
|
|
2708
2717
|
const ff = theme.fontFamily;
|
|
2709
2718
|
if (ff.sans && ff.sans !== "System") {
|
|
@@ -3718,7 +3727,8 @@ var InteractiveWrapper = (0, import_react10.forwardRef)(
|
|
|
3718
3727
|
[resolvedStyle, isDark, pressed, hovered, focused, width]
|
|
3719
3728
|
// eslint-disable-line react-hooks/exhaustive-deps
|
|
3720
3729
|
);
|
|
3721
|
-
const
|
|
3730
|
+
const isWebHTMLElement = !isNative && typeof Component === "string";
|
|
3731
|
+
const finalStyle = isWebHTMLElement ? styleProp ?? void 0 : styleProp ? Array.isArray(styleProp) ? Object.assign({}, computedStyle, ...styleProp) : { ...computedStyle, ...styleProp } : computedStyle;
|
|
3722
3732
|
const { children, ...restWithoutChildren } = rest;
|
|
3723
3733
|
const componentProps = {
|
|
3724
3734
|
ref,
|
|
@@ -3760,6 +3770,7 @@ function cx(...classes) {
|
|
|
3760
3770
|
cx,
|
|
3761
3771
|
defaultColors,
|
|
3762
3772
|
defaultTheme,
|
|
3773
|
+
disableRuntimeCSS,
|
|
3763
3774
|
flatten,
|
|
3764
3775
|
getConfig,
|
|
3765
3776
|
initConfig,
|
package/dist/index.mjs
CHANGED
|
@@ -7,12 +7,13 @@ import {
|
|
|
7
7
|
useConditionalWidth,
|
|
8
8
|
useGlobalDarkMode,
|
|
9
9
|
useGlobalWidth
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-BBI6IU22.mjs";
|
|
11
11
|
import {
|
|
12
12
|
__require,
|
|
13
13
|
buildConfig,
|
|
14
14
|
defaultColors,
|
|
15
15
|
defaultTheme,
|
|
16
|
+
disableRuntimeCSS,
|
|
16
17
|
flatten,
|
|
17
18
|
getActiveBreakpoints,
|
|
18
19
|
getConfig,
|
|
@@ -28,7 +29,7 @@ import {
|
|
|
28
29
|
syncGlobalScreens,
|
|
29
30
|
syncGlobalWidth,
|
|
30
31
|
updateConfig
|
|
31
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-52N32L7A.mjs";
|
|
32
33
|
|
|
33
34
|
// src/context.tsx
|
|
34
35
|
import { createContext, useContext } from "react";
|
|
@@ -557,6 +558,7 @@ export {
|
|
|
557
558
|
cx,
|
|
558
559
|
defaultColors,
|
|
559
560
|
defaultTheme,
|
|
561
|
+
disableRuntimeCSS,
|
|
560
562
|
flatten,
|
|
561
563
|
getConfig,
|
|
562
564
|
initConfig,
|
package/dist/jsx-dev-runtime.js
CHANGED
|
@@ -2568,6 +2568,10 @@ function getDefaultFontFamily() {
|
|
|
2568
2568
|
}
|
|
2569
2569
|
var _styleEl = null;
|
|
2570
2570
|
var _injectedRules = new LRUCache(5e4);
|
|
2571
|
+
var _CSS_DISABLED_KEY = "__kbach_runtime_css_disabled__";
|
|
2572
|
+
function isRuntimeCSSDisabled() {
|
|
2573
|
+
return !!globalThis[_CSS_DISABLED_KEY];
|
|
2574
|
+
}
|
|
2571
2575
|
function getStyleEl() {
|
|
2572
2576
|
if (_styleEl) return _styleEl;
|
|
2573
2577
|
_styleEl = document.createElement("style");
|
|
@@ -2576,6 +2580,7 @@ function getStyleEl() {
|
|
|
2576
2580
|
return _styleEl;
|
|
2577
2581
|
}
|
|
2578
2582
|
function injectRule(rule) {
|
|
2583
|
+
if (isRuntimeCSSDisabled()) return;
|
|
2579
2584
|
if (_injectedRules.has(rule)) return;
|
|
2580
2585
|
_injectedRules.set(rule, true);
|
|
2581
2586
|
try {
|
|
@@ -2592,7 +2597,7 @@ function getGlobalStyleEl() {
|
|
|
2592
2597
|
return _globalStyleEl;
|
|
2593
2598
|
}
|
|
2594
2599
|
function injectGlobalStyles(theme) {
|
|
2595
|
-
if (typeof document === "undefined") return;
|
|
2600
|
+
if (typeof document === "undefined" || isRuntimeCSSDisabled()) return;
|
|
2596
2601
|
const rules = [];
|
|
2597
2602
|
const ff = theme.fontFamily;
|
|
2598
2603
|
if (ff.sans && ff.sans !== "System") {
|
|
@@ -3158,7 +3163,8 @@ var InteractiveWrapper = (0, import_react3.forwardRef)(
|
|
|
3158
3163
|
[resolvedStyle, isDark, pressed, hovered, focused, width]
|
|
3159
3164
|
// eslint-disable-line react-hooks/exhaustive-deps
|
|
3160
3165
|
);
|
|
3161
|
-
const
|
|
3166
|
+
const isWebHTMLElement = !isNative && typeof Component === "string";
|
|
3167
|
+
const finalStyle = isWebHTMLElement ? styleProp ?? void 0 : styleProp ? Array.isArray(styleProp) ? Object.assign({}, computedStyle, ...styleProp) : { ...computedStyle, ...styleProp } : computedStyle;
|
|
3162
3168
|
const { children, ...restWithoutChildren } = rest;
|
|
3163
3169
|
const componentProps = {
|
|
3164
3170
|
ref,
|
|
@@ -3189,7 +3195,8 @@ var DarkWrapper = import_react4.default.forwardRef(
|
|
|
3189
3195
|
const computedStyle = flatten(resolvedStyle, isDark, {}, breakpoints);
|
|
3190
3196
|
stripInternalMarkers(computedStyle);
|
|
3191
3197
|
if (typeof Component !== "string") stripWebOnlyProps(computedStyle);
|
|
3192
|
-
const
|
|
3198
|
+
const isWebHTMLElement = !isNative && typeof Component === "string";
|
|
3199
|
+
const finalStyle = isWebHTMLElement ? styleProp ?? void 0 : styleProp ? Array.isArray(styleProp) ? Object.assign({}, computedStyle, ...styleProp) : { ...computedStyle, ...styleProp } : computedStyle;
|
|
3193
3200
|
const props = { ref, ...rest, style: finalStyle };
|
|
3194
3201
|
return Array.isArray(children) ? import_react4.default.createElement(Component, props, ...children) : import_react4.default.createElement(Component, props, children);
|
|
3195
3202
|
}
|
|
@@ -3274,27 +3281,6 @@ function mergeStyle(computed, userStyle) {
|
|
|
3274
3281
|
function makeElement(isStaticChildren, type, props, key) {
|
|
3275
3282
|
return (isStaticChildren ? import_jsx_runtime.jsxs : import_jsx_runtime.jsx)(type, props, key);
|
|
3276
3283
|
}
|
|
3277
|
-
function hasGridStyles(resolved) {
|
|
3278
|
-
for (const styles of Object.values(resolved)) {
|
|
3279
|
-
if (!styles) continue;
|
|
3280
|
-
if (styles.display === "grid" || styles.display === "inline-grid") return true;
|
|
3281
|
-
if ("gridTemplateColumns" in styles || "gridTemplateRows" in styles) return true;
|
|
3282
|
-
if ("gridColumn" in styles || "gridRow" in styles) return true;
|
|
3283
|
-
if ("gridColumnStart" in styles || "gridColumnEnd" in styles) return true;
|
|
3284
|
-
if ("gridRowStart" in styles || "gridRowEnd" in styles) return true;
|
|
3285
|
-
if ("gridAutoFlow" in styles || "gridAutoColumns" in styles || "gridAutoRows" in styles) return true;
|
|
3286
|
-
if ("placeItems" in styles || "placeContent" in styles || "justifyItems" in styles) return true;
|
|
3287
|
-
if ("placeSelf" in styles || "justifySelf" in styles) return true;
|
|
3288
|
-
}
|
|
3289
|
-
return false;
|
|
3290
|
-
}
|
|
3291
|
-
function hasWebPositionStyles(resolved) {
|
|
3292
|
-
for (const styles of Object.values(resolved)) {
|
|
3293
|
-
if (!styles) continue;
|
|
3294
|
-
if (styles.position === "sticky" || styles.position === "fixed" || styles.position === "static") return true;
|
|
3295
|
-
}
|
|
3296
|
-
return false;
|
|
3297
|
-
}
|
|
3298
3284
|
function stripInternalMarkers2(s) {
|
|
3299
3285
|
delete s.__divideX;
|
|
3300
3286
|
delete s.__divideY;
|
|
@@ -3330,6 +3316,14 @@ function processElement(type, rawProps, key, isStaticChildren) {
|
|
|
3330
3316
|
if (!rawProps) return (0, import_jsx_runtime.jsx)(type, null, key);
|
|
3331
3317
|
const { className, kb: kbProp, __kbachStyles, __kbachClasses } = rawProps;
|
|
3332
3318
|
const classStr = className ?? kbProp ?? __kbachClasses;
|
|
3319
|
+
if (!isNative && isRuntimeCSSDisabled() && classStr && !__kbachStyles) {
|
|
3320
|
+
const { style: userStyle2, ...passProps2 } = omitConsumed(rawProps);
|
|
3321
|
+
return makeElement(isStaticChildren, type, {
|
|
3322
|
+
...passProps2,
|
|
3323
|
+
className: normalizeClassString(classStr),
|
|
3324
|
+
...userStyle2 !== void 0 ? { style: userStyle2 } : {}
|
|
3325
|
+
}, key);
|
|
3326
|
+
}
|
|
3333
3327
|
if (!classStr && !__kbachStyles) {
|
|
3334
3328
|
const defaultFont = getCachedDefaultFont();
|
|
3335
3329
|
if (!defaultFont) return makeElement(isStaticChildren, type, rawProps, key);
|
|
@@ -3341,12 +3335,9 @@ function processElement(type, rawProps, key, isStaticChildren) {
|
|
|
3341
3335
|
const resolved = __kbachStyles ?? (classStr ? resolve(classStr, config.theme, config.darkMode) : {});
|
|
3342
3336
|
const { style: userStyle, ...passProps } = omitConsumed(rawProps);
|
|
3343
3337
|
const { interactive, modeOrResponsive } = bucketMods(resolved);
|
|
3344
|
-
const onWeb = typeof document !== "undefined";
|
|
3345
|
-
const needsDiv = onWeb && (hasGridStyles(resolved) || hasWebPositionStyles(resolved));
|
|
3346
|
-
const actualType = needsDiv ? "div" : type;
|
|
3347
3338
|
if (interactive) {
|
|
3348
3339
|
return (0, import_jsx_runtime.jsx)(InteractiveWrapper, {
|
|
3349
|
-
Component:
|
|
3340
|
+
Component: type,
|
|
3350
3341
|
resolvedStyle: resolved,
|
|
3351
3342
|
...!isNative && classStr ? { className: normalizeClassString(classStr) } : {},
|
|
3352
3343
|
style: userStyle,
|
|
@@ -3355,18 +3346,24 @@ function processElement(type, rawProps, key, isStaticChildren) {
|
|
|
3355
3346
|
}
|
|
3356
3347
|
if (modeOrResponsive) {
|
|
3357
3348
|
return (0, import_jsx_runtime.jsx)(DarkWrapper, {
|
|
3358
|
-
Component:
|
|
3349
|
+
Component: type,
|
|
3359
3350
|
resolvedStyle: resolved,
|
|
3360
3351
|
...!isNative && classStr ? { className: normalizeClassString(classStr) } : {},
|
|
3361
3352
|
style: userStyle,
|
|
3362
3353
|
...passProps
|
|
3363
3354
|
}, key);
|
|
3364
3355
|
}
|
|
3365
|
-
const
|
|
3366
|
-
|
|
3367
|
-
if (
|
|
3368
|
-
|
|
3369
|
-
|
|
3356
|
+
const isWebHTMLElement = !isNative && typeof type === "string";
|
|
3357
|
+
let finalStyle;
|
|
3358
|
+
if (!isWebHTMLElement) {
|
|
3359
|
+
const computedStyle = flatten(resolved, false);
|
|
3360
|
+
stripInternalMarkers2(computedStyle);
|
|
3361
|
+
if (typeof type !== "string") stripWebOnlyInlineProps(computedStyle);
|
|
3362
|
+
finalStyle = mergeStyle(computedStyle, userStyle);
|
|
3363
|
+
} else {
|
|
3364
|
+
finalStyle = userStyle ?? void 0;
|
|
3365
|
+
}
|
|
3366
|
+
return makeElement(isStaticChildren, type, {
|
|
3370
3367
|
...passProps,
|
|
3371
3368
|
style: finalStyle,
|
|
3372
3369
|
...!isNative && classStr ? { className: normalizeClassString(classStr) } : {}
|
package/dist/jsx-dev-runtime.mjs
CHANGED
|
@@ -2,9 +2,9 @@ import {
|
|
|
2
2
|
Fragment,
|
|
3
3
|
jsx,
|
|
4
4
|
jsxs
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-MIBPTKXT.mjs";
|
|
6
|
+
import "./chunk-BBI6IU22.mjs";
|
|
7
|
+
import "./chunk-52N32L7A.mjs";
|
|
8
8
|
|
|
9
9
|
// src/jsx-dev-runtime.tsx
|
|
10
10
|
function jsxDEV(type, props, key, isStaticChildren, source, self) {
|
package/dist/jsx-runtime.js
CHANGED
|
@@ -2568,6 +2568,10 @@ function getDefaultFontFamily() {
|
|
|
2568
2568
|
}
|
|
2569
2569
|
var _styleEl = null;
|
|
2570
2570
|
var _injectedRules = new LRUCache(5e4);
|
|
2571
|
+
var _CSS_DISABLED_KEY = "__kbach_runtime_css_disabled__";
|
|
2572
|
+
function isRuntimeCSSDisabled() {
|
|
2573
|
+
return !!globalThis[_CSS_DISABLED_KEY];
|
|
2574
|
+
}
|
|
2571
2575
|
function getStyleEl() {
|
|
2572
2576
|
if (_styleEl) return _styleEl;
|
|
2573
2577
|
_styleEl = document.createElement("style");
|
|
@@ -2576,6 +2580,7 @@ function getStyleEl() {
|
|
|
2576
2580
|
return _styleEl;
|
|
2577
2581
|
}
|
|
2578
2582
|
function injectRule(rule) {
|
|
2583
|
+
if (isRuntimeCSSDisabled()) return;
|
|
2579
2584
|
if (_injectedRules.has(rule)) return;
|
|
2580
2585
|
_injectedRules.set(rule, true);
|
|
2581
2586
|
try {
|
|
@@ -2592,7 +2597,7 @@ function getGlobalStyleEl() {
|
|
|
2592
2597
|
return _globalStyleEl;
|
|
2593
2598
|
}
|
|
2594
2599
|
function injectGlobalStyles(theme) {
|
|
2595
|
-
if (typeof document === "undefined") return;
|
|
2600
|
+
if (typeof document === "undefined" || isRuntimeCSSDisabled()) return;
|
|
2596
2601
|
const rules = [];
|
|
2597
2602
|
const ff = theme.fontFamily;
|
|
2598
2603
|
if (ff.sans && ff.sans !== "System") {
|
|
@@ -3158,7 +3163,8 @@ var InteractiveWrapper = (0, import_react3.forwardRef)(
|
|
|
3158
3163
|
[resolvedStyle, isDark, pressed, hovered, focused, width]
|
|
3159
3164
|
// eslint-disable-line react-hooks/exhaustive-deps
|
|
3160
3165
|
);
|
|
3161
|
-
const
|
|
3166
|
+
const isWebHTMLElement = !isNative && typeof Component === "string";
|
|
3167
|
+
const finalStyle = isWebHTMLElement ? styleProp ?? void 0 : styleProp ? Array.isArray(styleProp) ? Object.assign({}, computedStyle, ...styleProp) : { ...computedStyle, ...styleProp } : computedStyle;
|
|
3162
3168
|
const { children, ...restWithoutChildren } = rest;
|
|
3163
3169
|
const componentProps = {
|
|
3164
3170
|
ref,
|
|
@@ -3189,7 +3195,8 @@ var DarkWrapper = import_react4.default.forwardRef(
|
|
|
3189
3195
|
const computedStyle = flatten(resolvedStyle, isDark, {}, breakpoints);
|
|
3190
3196
|
stripInternalMarkers(computedStyle);
|
|
3191
3197
|
if (typeof Component !== "string") stripWebOnlyProps(computedStyle);
|
|
3192
|
-
const
|
|
3198
|
+
const isWebHTMLElement = !isNative && typeof Component === "string";
|
|
3199
|
+
const finalStyle = isWebHTMLElement ? styleProp ?? void 0 : styleProp ? Array.isArray(styleProp) ? Object.assign({}, computedStyle, ...styleProp) : { ...computedStyle, ...styleProp } : computedStyle;
|
|
3193
3200
|
const props = { ref, ...rest, style: finalStyle };
|
|
3194
3201
|
return Array.isArray(children) ? import_react4.default.createElement(Component, props, ...children) : import_react4.default.createElement(Component, props, children);
|
|
3195
3202
|
}
|
|
@@ -3277,27 +3284,6 @@ function mergeStyle(computed, userStyle) {
|
|
|
3277
3284
|
function makeElement(isStaticChildren, type, props, key) {
|
|
3278
3285
|
return (isStaticChildren ? import_jsx_runtime.jsxs : import_jsx_runtime.jsx)(type, props, key);
|
|
3279
3286
|
}
|
|
3280
|
-
function hasGridStyles(resolved) {
|
|
3281
|
-
for (const styles of Object.values(resolved)) {
|
|
3282
|
-
if (!styles) continue;
|
|
3283
|
-
if (styles.display === "grid" || styles.display === "inline-grid") return true;
|
|
3284
|
-
if ("gridTemplateColumns" in styles || "gridTemplateRows" in styles) return true;
|
|
3285
|
-
if ("gridColumn" in styles || "gridRow" in styles) return true;
|
|
3286
|
-
if ("gridColumnStart" in styles || "gridColumnEnd" in styles) return true;
|
|
3287
|
-
if ("gridRowStart" in styles || "gridRowEnd" in styles) return true;
|
|
3288
|
-
if ("gridAutoFlow" in styles || "gridAutoColumns" in styles || "gridAutoRows" in styles) return true;
|
|
3289
|
-
if ("placeItems" in styles || "placeContent" in styles || "justifyItems" in styles) return true;
|
|
3290
|
-
if ("placeSelf" in styles || "justifySelf" in styles) return true;
|
|
3291
|
-
}
|
|
3292
|
-
return false;
|
|
3293
|
-
}
|
|
3294
|
-
function hasWebPositionStyles(resolved) {
|
|
3295
|
-
for (const styles of Object.values(resolved)) {
|
|
3296
|
-
if (!styles) continue;
|
|
3297
|
-
if (styles.position === "sticky" || styles.position === "fixed" || styles.position === "static") return true;
|
|
3298
|
-
}
|
|
3299
|
-
return false;
|
|
3300
|
-
}
|
|
3301
3287
|
function stripInternalMarkers2(s) {
|
|
3302
3288
|
delete s.__divideX;
|
|
3303
3289
|
delete s.__divideY;
|
|
@@ -3333,6 +3319,14 @@ function processElement(type, rawProps, key, isStaticChildren) {
|
|
|
3333
3319
|
if (!rawProps) return (0, import_jsx_runtime.jsx)(type, null, key);
|
|
3334
3320
|
const { className, kb: kbProp, __kbachStyles, __kbachClasses } = rawProps;
|
|
3335
3321
|
const classStr = className ?? kbProp ?? __kbachClasses;
|
|
3322
|
+
if (!isNative && isRuntimeCSSDisabled() && classStr && !__kbachStyles) {
|
|
3323
|
+
const { style: userStyle2, ...passProps2 } = omitConsumed(rawProps);
|
|
3324
|
+
return makeElement(isStaticChildren, type, {
|
|
3325
|
+
...passProps2,
|
|
3326
|
+
className: normalizeClassString(classStr),
|
|
3327
|
+
...userStyle2 !== void 0 ? { style: userStyle2 } : {}
|
|
3328
|
+
}, key);
|
|
3329
|
+
}
|
|
3336
3330
|
if (!classStr && !__kbachStyles) {
|
|
3337
3331
|
const defaultFont = getCachedDefaultFont();
|
|
3338
3332
|
if (!defaultFont) return makeElement(isStaticChildren, type, rawProps, key);
|
|
@@ -3344,12 +3338,9 @@ function processElement(type, rawProps, key, isStaticChildren) {
|
|
|
3344
3338
|
const resolved = __kbachStyles ?? (classStr ? resolve(classStr, config.theme, config.darkMode) : {});
|
|
3345
3339
|
const { style: userStyle, ...passProps } = omitConsumed(rawProps);
|
|
3346
3340
|
const { interactive, modeOrResponsive } = bucketMods(resolved);
|
|
3347
|
-
const onWeb = typeof document !== "undefined";
|
|
3348
|
-
const needsDiv = onWeb && (hasGridStyles(resolved) || hasWebPositionStyles(resolved));
|
|
3349
|
-
const actualType = needsDiv ? "div" : type;
|
|
3350
3341
|
if (interactive) {
|
|
3351
3342
|
return (0, import_jsx_runtime.jsx)(InteractiveWrapper, {
|
|
3352
|
-
Component:
|
|
3343
|
+
Component: type,
|
|
3353
3344
|
resolvedStyle: resolved,
|
|
3354
3345
|
...!isNative && classStr ? { className: normalizeClassString(classStr) } : {},
|
|
3355
3346
|
style: userStyle,
|
|
@@ -3358,18 +3349,24 @@ function processElement(type, rawProps, key, isStaticChildren) {
|
|
|
3358
3349
|
}
|
|
3359
3350
|
if (modeOrResponsive) {
|
|
3360
3351
|
return (0, import_jsx_runtime.jsx)(DarkWrapper, {
|
|
3361
|
-
Component:
|
|
3352
|
+
Component: type,
|
|
3362
3353
|
resolvedStyle: resolved,
|
|
3363
3354
|
...!isNative && classStr ? { className: normalizeClassString(classStr) } : {},
|
|
3364
3355
|
style: userStyle,
|
|
3365
3356
|
...passProps
|
|
3366
3357
|
}, key);
|
|
3367
3358
|
}
|
|
3368
|
-
const
|
|
3369
|
-
|
|
3370
|
-
if (
|
|
3371
|
-
|
|
3372
|
-
|
|
3359
|
+
const isWebHTMLElement = !isNative && typeof type === "string";
|
|
3360
|
+
let finalStyle;
|
|
3361
|
+
if (!isWebHTMLElement) {
|
|
3362
|
+
const computedStyle = flatten(resolved, false);
|
|
3363
|
+
stripInternalMarkers2(computedStyle);
|
|
3364
|
+
if (typeof type !== "string") stripWebOnlyInlineProps(computedStyle);
|
|
3365
|
+
finalStyle = mergeStyle(computedStyle, userStyle);
|
|
3366
|
+
} else {
|
|
3367
|
+
finalStyle = userStyle ?? void 0;
|
|
3368
|
+
}
|
|
3369
|
+
return makeElement(isStaticChildren, type, {
|
|
3373
3370
|
...passProps,
|
|
3374
3371
|
style: finalStyle,
|
|
3375
3372
|
...!isNative && classStr ? { className: normalizeClassString(classStr) } : {}
|
package/dist/jsx-runtime.mjs
CHANGED
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
_invalidateDefaultFontCache,
|
|
4
4
|
jsx,
|
|
5
5
|
jsxs
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-MIBPTKXT.mjs";
|
|
7
|
+
import "./chunk-BBI6IU22.mjs";
|
|
8
|
+
import "./chunk-52N32L7A.mjs";
|
|
9
9
|
export {
|
|
10
10
|
Fragment,
|
|
11
11
|
_invalidateDefaultFontCache,
|
package/dist/vite-plugin.js
CHANGED
|
@@ -2471,6 +2471,10 @@ function setDefaultFontFamily(font) {
|
|
|
2471
2471
|
}
|
|
2472
2472
|
var _styleEl = null;
|
|
2473
2473
|
var _injectedRules = new LRUCache(5e4);
|
|
2474
|
+
var _CSS_DISABLED_KEY = "__kbach_runtime_css_disabled__";
|
|
2475
|
+
function isRuntimeCSSDisabled() {
|
|
2476
|
+
return !!globalThis[_CSS_DISABLED_KEY];
|
|
2477
|
+
}
|
|
2474
2478
|
function getStyleEl() {
|
|
2475
2479
|
if (_styleEl) return _styleEl;
|
|
2476
2480
|
_styleEl = document.createElement("style");
|
|
@@ -2487,7 +2491,7 @@ function getGlobalStyleEl() {
|
|
|
2487
2491
|
return _globalStyleEl;
|
|
2488
2492
|
}
|
|
2489
2493
|
function injectGlobalStyles(theme) {
|
|
2490
|
-
if (typeof document === "undefined") return;
|
|
2494
|
+
if (typeof document === "undefined" || isRuntimeCSSDisabled()) return;
|
|
2491
2495
|
const rules = [];
|
|
2492
2496
|
const ff = theme.fontFamily;
|
|
2493
2497
|
if (ff.sans && ff.sans !== "System") {
|
|
@@ -3072,6 +3076,18 @@ function kbach(userConfig) {
|
|
|
3072
3076
|
configResolved(resolved) {
|
|
3073
3077
|
root = resolved.root;
|
|
3074
3078
|
},
|
|
3079
|
+
// When any JS/TS file imports kbach.css, prepend a disableRuntimeCSS() call
|
|
3080
|
+
// so styles come solely from the static stylesheet — no duplicate injection.
|
|
3081
|
+
transform(code, id) {
|
|
3082
|
+
if (!/\.(tsx?|jsx?|mjs?)$/.test(id)) return;
|
|
3083
|
+
if (!/['"].*kbach\.css['"]/i.test(code)) return;
|
|
3084
|
+
return {
|
|
3085
|
+
code: `import { disableRuntimeCSS } from '@kbach/react';
|
|
3086
|
+
disableRuntimeCSS();
|
|
3087
|
+
${code}`,
|
|
3088
|
+
map: null
|
|
3089
|
+
};
|
|
3090
|
+
},
|
|
3075
3091
|
buildStart() {
|
|
3076
3092
|
mainCSSFile = findKbachCSS(root);
|
|
3077
3093
|
initialScan();
|
package/dist/vite-plugin.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
generateClassCSS,
|
|
4
4
|
setCSSGenMode,
|
|
5
5
|
splitClassTokens
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-52N32L7A.mjs";
|
|
7
7
|
|
|
8
8
|
// src/vite-plugin.ts
|
|
9
9
|
import { readFileSync, writeFileSync, readdirSync, statSync } from "fs";
|
|
@@ -270,6 +270,18 @@ function kbach(userConfig) {
|
|
|
270
270
|
configResolved(resolved) {
|
|
271
271
|
root = resolved.root;
|
|
272
272
|
},
|
|
273
|
+
// When any JS/TS file imports kbach.css, prepend a disableRuntimeCSS() call
|
|
274
|
+
// so styles come solely from the static stylesheet — no duplicate injection.
|
|
275
|
+
transform(code, id) {
|
|
276
|
+
if (!/\.(tsx?|jsx?|mjs?)$/.test(id)) return;
|
|
277
|
+
if (!/['"].*kbach\.css['"]/i.test(code)) return;
|
|
278
|
+
return {
|
|
279
|
+
code: `import { disableRuntimeCSS } from '@kbach/react';
|
|
280
|
+
disableRuntimeCSS();
|
|
281
|
+
${code}`,
|
|
282
|
+
map: null
|
|
283
|
+
};
|
|
284
|
+
},
|
|
273
285
|
buildStart() {
|
|
274
286
|
mainCSSFile = findKbachCSS(root);
|
|
275
287
|
initialScan();
|