/** * [WHO]: Public exports from this file (see implementation below). * [FROM]: See the import block immediately after this header. * [TO]: sparkdesign package consumers; output of CLI `add` when applicable. * [HERE]: src/lib/ThemeStyleContext.tsx — Spark Design source; keep aligned with the main library. * * [PROTOCOL]: * 1. Keep this P3 header in sync when the public contract changes. * 2. Update module AGENTS.md (P2) and root AGENTS.md (P1) when boundaries change. * 3. Follow design tokens and explicit type exports. */ import { type ReactNode } from 'react'; /** 亮暗色 */ export type Appearance = 'light' | 'dark'; /** 颜色主题预设 */ export type ThemePreset = 'mint' | 'parchment'; /** 自定义颜色主题 */ export interface CustomTheme { name: string; /** 任意 token 覆盖,键为 CSS 变量名(不含 --) */ tokens: { 'color-primary'?: string; 'color-primary-hover'?: string; 'color-primary-active'?: string; 'color-primary-bg'?: string; 'color-primary-bg-hover'?: string; 'color-primary-border'?: string; 'color-primary-border-hover'?: string; 'color-text-on-primary'?: string; 'color-text'?: string; 'color-text-secondary'?: string; 'color-text-tertiary'?: string; 'color-text-quaternary'?: string; 'color-text-base'?: string; 'color-border'?: string; 'color-border-secondary'?: string; 'color-border-tertiary'?: string; 'color-fill'?: string; 'color-fill-secondary'?: string; 'color-fill-tertiary'?: string; 'color-fill-quaternary'?: string; 'color-fill-disable'?: string; 'color-bg-container'?: string; 'color-bg-elevated'?: string; 'color-bg-layout'?: string; 'color-bg-spotlight'?: string; 'color-bg-mask'?: string; 'color-bg-base'?: string; 'color-bg-highlight'?: string; 'color-bg-highlight-hover'?: string; 'color-link'?: string; 'color-error'?: string; 'color-error-hover'?: string; 'color-error-bg'?: string; 'color-error-border'?: string; 'color-info'?: string; 'color-info-hover'?: string; 'color-info-bg'?: string; 'color-info-border'?: string; 'color-success'?: string; 'color-success-hover'?: string; 'color-success-bg'?: string; 'color-success-border'?: string; 'color-warning'?: string; 'color-warning-hover'?: string; 'color-warning-bg'?: string; 'color-warning-border'?: string; [key: string]: string | undefined; }; } /** 颜色主题:预设或自定义 */ export type Theme = ThemePreset | CustomTheme; /** 布局尺度预设 */ export type StylePreset = 'neutral' | 'compact' | 'soft' | 'sharp' | 'dense'; /** 自定义布局尺度 */ export interface CustomStyle { name: string; radius?: { sm?: string; default?: string; md?: string; lg?: string; xl?: string; '2xl'?: string; '3xl'?: string; }; spacing?: { '3'?: string; '4'?: string; '9'?: string; '11'?: string; }; fontSize?: { sm?: string; lg?: string; xl?: string; '2xl'?: string; '3xl'?: string; }; } /** 布局尺度:预设或自定义 */ export type Style = StylePreset | CustomStyle; export interface ThemeStyleContextValue { /** 亮暗色 */ appearance: Appearance; /** 颜色主题(原始值) */ themeConfig: Theme; /** 布局尺度(原始值) */ styleConfig: Style; /** 计算后的 data-theme 属性值 */ dataTheme: string; /** 计算后的 data-style 属性值 */ dataStyle: string; /** @deprecated 兼容旧 API,等于 dataTheme */ theme?: string; /** @deprecated 兼容旧 API,等于 dataStyle */ style?: string; } export interface ThemeStyleProviderProps { children: ReactNode; /** 亮暗色,默认 'light' */ appearance?: Appearance; /** 颜色主题,默认 'mint' */ theme?: Theme; /** 布局尺度,默认 'neutral' */ style?: Style; } export declare function ThemeStyleProvider({ children, appearance, theme, style, }: ThemeStyleProviderProps): import("react/jsx-runtime").JSX.Element; export declare function useThemeStyle(): ThemeStyleContextValue; /** @deprecated 使用新的 ThemeStyleProvider props 代替 */ export interface ThemeStyleValue { style?: string; theme?: string; }