import * as React from 'react'; import React__default, { Context, ReactNode, ComponentType, ForwardRefExoticComponent } from 'react'; import * as __core from './core'; import { ThemeMode, ResolvedConfig, DefaultColorName, defaultColors, ThemeColors, DefaultSpacingKey, ThemeSpacing, FrameworkConfig, StyleValue, ResolvedStyle } from './core'; export { DefaultColorName, DefaultSpacingKey, FrameworkConfig, ParsedClass, PluginAPI, ResolvedConfig, ResolvedStyle, StyleValue, ThemeConfig, ThemeMode, buildConfig, clearCache, defaultColors, defaultTheme, disableRuntimeCSS, flatten, generateKbachTypesDts, getConfig, initConfig, normalizeClassString, parseClass, parseClasses, resolve, setResolveTarget, splitClassTokens, updateConfig } from './core'; export { r as registerWebElement } from './web-substitute-CfpYFnE7.js'; interface ThemeContextValue { /** The user-selected mode ('light' | 'dark' | 'system') */ mode: ThemeMode; /** The effective resolved mode (never 'system') */ resolvedMode: 'light' | 'dark'; /** Convenience boolean */ isDark: boolean; /** Change the theme mode programmatically */ setMode: (mode: ThemeMode) => void; /** Toggle between light and dark (ignores system) */ toggle: () => void; /** The fully resolved framework config (theme values, darkMode strategy, etc.) */ config: ResolvedConfig; } declare global { var __kbachThemeContext: Context | undefined; } declare const ThemeContext: Context; declare function useTheme(): ThemeContextValue; declare function useIsDark(): boolean; interface ColorScale { /** `colors.blue[6]` → raw hex string */ readonly [shade: number]: string; /** `colors.blue['6/50']` → shade 6 at 50% opacity */ readonly [key: string]: string; } /** * Empty on purpose — augment it via declaration merging so `useColors()` (and * `useSpacing()`'s equivalent, `KbachCustomSpacing`) know about a project's * `kbach.config.js` colors without repeating a type parameter at every call * site. `kbach.config.js` is a plain runtime-loaded .js file, so TypeScript * can't see into it on its own — this is the same declaration-merging pattern * styled-components' `DefaultTheme` and i18next's resource typing use for the * identical problem. Put this in any .d.ts your tsconfig includes: * * ```ts * import '@kbach/react'; // or '@kbach/native' — either works, native re-exports react's types * declare module '@kbach/react' { * interface KbachCustomColors { * primary: string; // a flat color, like the built-in `white`/`black` * brand: ColorScale; // a 1–12 shade scale, like the built-in `blue`/`red` * } * } * ``` * * A mode-aware `{ light, dark }` config color (see ColorValue) still resolves * to a flat `string` at read time — declare those as `string` here too, not * as the config shape. */ interface KbachCustomColors { } type ColorValueFor = K extends keyof typeof defaultColors ? (typeof defaultColors)[K] extends string ? string : ColorScale : K extends keyof KbachCustomColors ? KbachCustomColors[K] : ColorScale | string; /** Every color name TypeScript knows about without an explicit type parameter: the built-in theme plus whatever's been added via the KbachCustomColors augmentation above. */ type KnownColorName = DefaultColorName | Extract; /** * `ColorName` defaults to `KnownColorName` (the built-in theme's color names * plus anything augmented onto `KbachCustomColors` above), so `useColors()` * gets full autocomplete and typo-catching out of the box — including custom * `kbach.config.js` colors, once augmented once project-wide. Without that * augmentation, a project with extra colors can still widen per call instead: * `useColors()`. */ type ColorsAPI = { readonly [K in ColorName]: ColorValueFor; } & { /** * Pass any CSS color through, optionally applying an opacity (0–100). * - `colors.alpha('#3b82f6', 50)` → `'rgba(59,130,246,0.5)'` * - `colors.alpha('rgb(0,0,0)', 10)` → `'rgba(0,0,0,0.1)'` * - `colors.alpha('rgba(0,0,0,0.5)')` → `'rgba(0,0,0,0.5)'` (passthrough) */ readonly alpha: (color: string, opacity?: number) => string; }; declare function wrapColors(rawColors: ThemeColors, isDark?: boolean): ColorsAPI; declare function useColors(): ColorsAPI; /** * Empty on purpose — augment it via declaration merging so `useSpacing()` * (like `useColors()`'s `KbachCustomColors`) knows about a project's * `kbach.config.js` spacing keys without repeating a type parameter at every * call site: * * ```ts * import '@kbach/react'; // or '@kbach/native' * declare module '@kbach/react' { * interface KbachCustomSpacing { * 18: true; // value doesn't matter — only the key is read (see SpacingAPI) * } * } * ``` */ interface KbachCustomSpacing { } /** Every spacing key TypeScript knows about without an explicit type parameter. */ type KnownSpacingKey = DefaultSpacingKey | Extract; /** * `SpacingKey` defaults to `KnownSpacingKey` (the built-in theme's spacing keys * plus anything augmented onto `KbachCustomSpacing` above), so `useSpacing()` * gets full autocomplete and typo-catching out of the box — including custom * `kbach.config.js` keys, once augmented once project-wide. Without that * augmentation, a project with extra keys can still widen per call instead: * `useSpacing()`. */ type SpacingAPI = { readonly [K in SpacingKey]: number | string; }; declare function wrapSpacing(rawSpacing: ThemeSpacing): SpacingAPI; /** * Returns the active theme's spacing scale as a typed, autocomplete-friendly * object — useful anywhere a raw JS number/string is needed instead of a * className (Animated API distances, chart dimensions, FlatList separator * heights, etc.). Values match exactly what `p-`/`m-`/`w-`/`h-`/`gap-` and * other spacing-scale utilities resolve to. * * ```ts * const spacing = useSpacing(); * spacing[4] // 16 * spacing.full // '100%' * spacing['1/2'] // '50%' * ``` */ declare function useSpacing(): SpacingAPI; interface ThemeProviderProps { children: ReactNode; /** Initial mode. Falls back to persisted value, then 'system'. */ defaultMode?: ThemeMode; /** * System color scheme for native `defaultMode="system"`. * * Pass the value of `useColorScheme()` from `react-native`. When importing * `ThemeProvider` from `@kbach/react/native` this is handled automatically. * * @example * ```tsx * import { useColorScheme } from 'react-native'; * const colorScheme = useColorScheme(); * * ``` */ colorScheme?: 'light' | 'dark' | null; /** * Current window/screen width in pixels for responsive breakpoints. * On web this is read from `window.innerWidth` automatically. * When importing `ThemeProvider` from `@kbach/react/native` this is provided * automatically from `useWindowDimensions()`. */ windowWidth?: number; /** Override the config (useful for per-tree config). Defaults to global getConfig(). */ config?: FrameworkConfig; /** Disable persistence to localStorage */ disablePersistence?: boolean; } declare function ThemeProvider({ children, defaultMode, colorScheme, windowWidth: windowWidthProp, config: configOverride, disablePersistence, }: ThemeProviderProps): React__default.JSX.Element; /** * Renders Kbach's base browser-default reset (borderless button/input, * visible checkbox/radio, no arrow-less