@kbach/react 0.6.30 → 0.6.32
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-TKBIGAR2.mjs → chunk-E322MVGC.mjs} +1370 -1298
- package/dist/{chunk-FF4AZQIQ.mjs → chunk-JUGDQQQ4.mjs} +12 -11
- package/dist/core/index.d.ts +40 -3
- package/dist/core/index.js +1465 -1391
- package/dist/index.d.ts +1 -1
- package/dist/index.js +18 -14
- package/dist/index.mjs +19 -14
- package/dist/jsx-dev-runtime.js +11 -11
- package/dist/jsx-dev-runtime.mjs +2 -2
- package/dist/jsx-runtime.js +11 -11
- package/dist/jsx-runtime.mjs +2 -2
- package/dist/vite-plugin.d.mts +11 -2
- package/dist/vite-plugin.d.ts +11 -2
- package/dist/vite-plugin.js +80 -10
- package/dist/vite-plugin.mjs +80 -10
- package/kbach-react.md +23 -0
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
EMPTY_BREAKPOINTS,
|
|
4
4
|
InteractiveWrapper,
|
|
5
|
+
expandModeAwareColorClasses,
|
|
5
6
|
flatten,
|
|
6
7
|
getActiveBreakpoints,
|
|
7
8
|
getConfig,
|
|
@@ -24,7 +25,7 @@ import {
|
|
|
24
25
|
transformToWebProps,
|
|
25
26
|
useConditionalGlobalDarkMode,
|
|
26
27
|
useConditionalWidth
|
|
27
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-E322MVGC.mjs";
|
|
28
29
|
|
|
29
30
|
// src/jsx-runtime.tsx
|
|
30
31
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -49,7 +50,7 @@ var DarkWrapper = React.forwardRef(
|
|
|
49
50
|
return s;
|
|
50
51
|
}, [resolvedStyle, isDark, width, screens, isNonStringComponent]);
|
|
51
52
|
const skipComputedInline = isWebPlatform;
|
|
52
|
-
const finalStyle = skipComputedInline ? styleProp ?? void 0 : styleProp ? Array.isArray(styleProp) ?
|
|
53
|
+
const finalStyle = skipComputedInline ? styleProp ?? void 0 : styleProp ? Array.isArray(styleProp) ? [computedStyle, ...styleProp] : [computedStyle, styleProp] : computedStyle;
|
|
53
54
|
const props = { ref, ...rest, style: finalStyle };
|
|
54
55
|
return Array.isArray(children) ? React.createElement(Component, props, ...children) : React.createElement(Component, props, children);
|
|
55
56
|
}
|
|
@@ -107,8 +108,7 @@ function omitConsumed(props) {
|
|
|
107
108
|
}
|
|
108
109
|
function mergeStyle(computed, userStyle) {
|
|
109
110
|
if (!userStyle) return computed;
|
|
110
|
-
|
|
111
|
-
return { ...computed, ...userStyle };
|
|
111
|
+
return Array.isArray(userStyle) ? [computed, ...userStyle] : [computed, userStyle];
|
|
112
112
|
}
|
|
113
113
|
function withImpliedFlexIfNeeded(webTag, resolvedBase, userStyle) {
|
|
114
114
|
if (!webTag || !resolvedBase) return userStyle;
|
|
@@ -138,11 +138,13 @@ function processElement(type, rawProps, key, isStaticChildren) {
|
|
|
138
138
|
return makeElement(isStaticChildren, effectiveType, workingProps, key);
|
|
139
139
|
}
|
|
140
140
|
const classStr = classStrRaw;
|
|
141
|
-
|
|
141
|
+
const config = getConfig();
|
|
142
|
+
const expandedClassStr = classStr ? expandModeAwareColorClasses(classStr, config.theme.colors) : classStr;
|
|
143
|
+
if (!isNative && isRuntimeCSSDisabled() && expandedClassStr && !__kbachStyles) {
|
|
142
144
|
const { style: userStyle2, ...passProps2 } = omitConsumed(workingProps);
|
|
143
145
|
return makeElement(isStaticChildren, effectiveType, {
|
|
144
146
|
...passProps2,
|
|
145
|
-
className: normalizeClassString(
|
|
147
|
+
className: normalizeClassString(expandedClassStr),
|
|
146
148
|
...userStyle2 !== void 0 ? { style: userStyle2 } : {}
|
|
147
149
|
}, key);
|
|
148
150
|
}
|
|
@@ -162,8 +164,7 @@ function processElement(type, rawProps, key, isStaticChildren) {
|
|
|
162
164
|
const finalStyle2 = userStyle2 ? Array.isArray(userStyle2) ? { fontFamily: defaultFont, ...Object.assign({}, ...userStyle2) } : { fontFamily: defaultFont, ...userStyle2 } : { fontFamily: defaultFont };
|
|
163
165
|
return makeElement(isStaticChildren, effectiveType, { ...passProps2, style: finalStyle2 }, key);
|
|
164
166
|
}
|
|
165
|
-
const
|
|
166
|
-
const resolved = !isWeb && __kbachStyles != null ? __kbachStyles : classStr ? resolve(classStr, config.theme, config.darkMode) : {};
|
|
167
|
+
const resolved = !isWeb && __kbachStyles != null ? __kbachStyles : expandedClassStr ? resolve(expandedClassStr, config.theme, config.darkMode) : {};
|
|
167
168
|
const { style: rawUserStyle, ...passProps } = omitConsumed(workingProps);
|
|
168
169
|
const userStyle = withImpliedFlexIfNeeded(webTag, resolved.base, rawUserStyle);
|
|
169
170
|
const { interactive, modeOrResponsive } = bucketMods(resolved);
|
|
@@ -171,7 +172,7 @@ function processElement(type, rawProps, key, isStaticChildren) {
|
|
|
171
172
|
return _jsx(InteractiveWrapper, {
|
|
172
173
|
Component: effectiveType,
|
|
173
174
|
resolvedStyle: resolved,
|
|
174
|
-
...!isNative &&
|
|
175
|
+
...!isNative && expandedClassStr ? { className: normalizeClassString(expandedClassStr) } : {},
|
|
175
176
|
style: userStyle,
|
|
176
177
|
...passProps
|
|
177
178
|
}, key);
|
|
@@ -180,7 +181,7 @@ function processElement(type, rawProps, key, isStaticChildren) {
|
|
|
180
181
|
return _jsx(DarkWrapper, {
|
|
181
182
|
Component: effectiveType,
|
|
182
183
|
resolvedStyle: resolved,
|
|
183
|
-
...!isNative &&
|
|
184
|
+
...!isNative && expandedClassStr ? { className: normalizeClassString(expandedClassStr) } : {},
|
|
184
185
|
style: userStyle,
|
|
185
186
|
...passProps
|
|
186
187
|
}, key);
|
|
@@ -198,7 +199,7 @@ function processElement(type, rawProps, key, isStaticChildren) {
|
|
|
198
199
|
return makeElement(isStaticChildren, effectiveType, {
|
|
199
200
|
...passProps,
|
|
200
201
|
...finalStyle !== void 0 ? { style: finalStyle } : {},
|
|
201
|
-
...!isNative &&
|
|
202
|
+
...!isNative && expandedClassStr ? { className: normalizeClassString(expandedClassStr) } : {}
|
|
202
203
|
}, key);
|
|
203
204
|
}
|
|
204
205
|
function jsx(type, props, key) {
|
package/dist/core/index.d.ts
CHANGED
|
@@ -86,8 +86,17 @@ interface ResolvedStyle {
|
|
|
86
86
|
/** Styles keyed by modifier or modifier combo, e.g. 'dark', 'hover', 'dark:hover' */
|
|
87
87
|
[modifierKey: string]: StyleValue | undefined;
|
|
88
88
|
}
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
/**
|
|
90
|
+
* A color value is either a plain string (hex/rgb/alias-to-another-color-name)
|
|
91
|
+
* or a mode-aware pair — resolved to `light` or `dark` per the active theme
|
|
92
|
+
* mode wherever it's actually used (className resolution, useColors()).
|
|
93
|
+
*/
|
|
94
|
+
type ColorValue = string | {
|
|
95
|
+
light: string;
|
|
96
|
+
dark: string;
|
|
97
|
+
};
|
|
98
|
+
type ColorShades = Record<string, ColorValue>;
|
|
99
|
+
type ThemeColors = Record<string, ColorValue | ColorShades>;
|
|
91
100
|
type ThemeSpacing = Record<string, number | string>;
|
|
92
101
|
interface ThemeConfig {
|
|
93
102
|
colors: ThemeColors;
|
|
@@ -163,6 +172,34 @@ interface ResolvedConfig {
|
|
|
163
172
|
plugins: Array<(api: PluginAPI) => void>;
|
|
164
173
|
}
|
|
165
174
|
|
|
175
|
+
/**
|
|
176
|
+
* True for a mode-aware color pair (`{ light, dark }`), as opposed to a plain
|
|
177
|
+
* hex/rgb/alias string. Shared by config.ts (alias-chain resolution),
|
|
178
|
+
* resolvers/color.ts (direct lookups), and modeAwareColors.ts (className
|
|
179
|
+
* expansion) so all three agree on exactly one definition. Real shade keys
|
|
180
|
+
* are always numeric strings ('1'–'12'), so this can never collide with one.
|
|
181
|
+
*/
|
|
182
|
+
declare function isModeAwareColor(v: unknown): v is {
|
|
183
|
+
light: string;
|
|
184
|
+
dark: string;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Expand every class referencing a mode-aware color (a kbach.config.js color
|
|
189
|
+
* value shaped `{ light, dark }`) into an explicit base + dark: pair BEFORE
|
|
190
|
+
* normal parsing — e.g. `bg-surface` becomes `bg-[#ffffff] dark:bg-[#111827]`.
|
|
191
|
+
* `bg-surface/50` becomes `bg-[#ffffff]/50 dark:bg-[#111827]/50` (the arbitrary-
|
|
192
|
+
* color-plus-opacity composition already resolveColor() already supports).
|
|
193
|
+
*
|
|
194
|
+
* Runs once, upfront, purely as a string rewrite — everything downstream
|
|
195
|
+
* (CSS generation, native bucketing/flatten(), the existing dark: reactivity
|
|
196
|
+
* machinery: DarkWrapper, bucketMods()) then handles the result exactly like
|
|
197
|
+
* a hand-written dark: pair, with zero further changes needed anywhere else.
|
|
198
|
+
* That also means resolve()'s cache (keyed on the ORIGINAL, unexpanded string
|
|
199
|
+
* — see resolver.ts) stays correct without any changes to its cache key.
|
|
200
|
+
*/
|
|
201
|
+
declare function expandModeAwareColorClasses(classString: string, colors: ThemeColors): string;
|
|
202
|
+
|
|
166
203
|
declare const defaultColors: {
|
|
167
204
|
transparent: string;
|
|
168
205
|
current: string;
|
|
@@ -1271,4 +1308,4 @@ declare function subscribeGlobalWidth(listener: WidthListener): () => void;
|
|
|
1271
1308
|
*/
|
|
1272
1309
|
declare function getActiveBreakpoints(width?: number, screens?: Record<string, number>): Set<string>;
|
|
1273
1310
|
|
|
1274
|
-
export { BASE_RESET, type ColorShades, type DarkMode, type DefaultColorName, type DefaultSpacingKey, type FrameworkConfig, LRUCache, type ParsedClass, type Platform, type PluginAPI, RESET_STYLE_ID, type ResolvedConfig, type ResolvedStyle, type StyleValue, type ThemeColors, type ThemeConfig, type ThemeMode, type ThemeSpacing, buildConfig, clearCache, clearPluginModifiers, customVariants, defaultColors, defaultTheme, disableRuntimeCSS, escapeCSSSelector, flatten, generateClassCSS, getActiveBreakpoints, getAllModifierNames, getBuiltinStandaloneNames, getBuiltinUtilityPrefixes, getConfig, getDefaultFontFamily, getEffectiveIsWeb, getGlobalDarkMode, getGlobalScreens, getGlobalWidth, getInteractiveModifiers, getModeModifiers, getModifier, getResponsiveModifiers, initConfig, isKnownModifier, isKnownUtility, isNative, isRuntimeCSSDisabled, isWeb, kbachWarn, matchModifier, normalizeClassString, onConfigChange, parseClass, parseClasses, parseHexRgb, registerModifier, resetConfig, resolve, resolveColor, resolveSizing, resolveSpacing, resolveUtility, setDefaultFontFamily, setGlobalDarkMode, setGlobalWidth, setResolveTarget, splitClassTokens, subscribeGlobalDarkMode, subscribeGlobalWidth, syncGlobalDarkMode, syncGlobalScreens, syncGlobalWidth, toNativeValue, updateConfig };
|
|
1311
|
+
export { BASE_RESET, type ColorShades, type ColorValue, type DarkMode, type DefaultColorName, type DefaultSpacingKey, type FrameworkConfig, LRUCache, type ParsedClass, type Platform, type PluginAPI, RESET_STYLE_ID, type ResolvedConfig, type ResolvedStyle, type StyleValue, type ThemeColors, type ThemeConfig, type ThemeMode, type ThemeSpacing, buildConfig, clearCache, clearPluginModifiers, customVariants, defaultColors, defaultTheme, disableRuntimeCSS, escapeCSSSelector, expandModeAwareColorClasses, flatten, generateClassCSS, getActiveBreakpoints, getAllModifierNames, getBuiltinStandaloneNames, getBuiltinUtilityPrefixes, getConfig, getDefaultFontFamily, getEffectiveIsWeb, getGlobalDarkMode, getGlobalScreens, getGlobalWidth, getInteractiveModifiers, getModeModifiers, getModifier, getResponsiveModifiers, initConfig, isKnownModifier, isKnownUtility, isModeAwareColor, isNative, isRuntimeCSSDisabled, isWeb, kbachWarn, matchModifier, normalizeClassString, onConfigChange, parseClass, parseClasses, parseHexRgb, registerModifier, resetConfig, resolve, resolveColor, resolveSizing, resolveSpacing, resolveUtility, setDefaultFontFamily, setGlobalDarkMode, setGlobalWidth, setResolveTarget, splitClassTokens, subscribeGlobalDarkMode, subscribeGlobalWidth, syncGlobalDarkMode, syncGlobalScreens, syncGlobalWidth, toNativeValue, updateConfig };
|