@kbach/react 0.6.30 → 0.6.31

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.
@@ -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
- type ColorShades = Record<string, string>;
90
- type ThemeColors = Record<string, string | ColorShades>;
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 };