burne-ui 1.5.9 → 1.6.0

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.
@@ -1,7 +1,7 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { MotionConfig } from '../components/core/utils/motionConfig';
3
3
  import { ToastProviderProps } from '../components/core/Toast/toastTypes';
4
- import { BurneThemeConfig, BurneThemeMode, ThemeTokenOverrides } from './themeConfig';
4
+ import { BurneThemeConfig, BurneThemeMode, CustomThemeTokens, ThemeTokenOverrides } from './themeConfig';
5
5
  import { ThemeProviderProps } from './ThemeProvider';
6
6
  export type BurneUIProviderProps = {
7
7
  children: ReactNode;
@@ -14,6 +14,7 @@ export type BurneUIProviderProps = {
14
14
  defaultTheme?: BurneThemeMode;
15
15
  storageKey?: string | null;
16
16
  tokens?: ThemeTokenOverrides;
17
+ customTokens?: CustomThemeTokens;
17
18
  motion?: Partial<MotionConfig>;
18
19
  /**
19
20
  * Wrap with `Toast.Provider`.
@@ -1,5 +1,6 @@
1
1
  export { applyThemeTokens, clearThemeInlineTokens, createDefaultThemeState, ensureModePalettes, activateThemeModePalette, patchThemeColor, exportThemeCss, COLOR_CSS_VAR, DEFAULT_FONT, DEFAULT_FONT_MONO, FONT_WEIGHT_CSS_VAR, FONT_WEIGHT_DEFAULTS, MOTION_DEFAULTS, SCALE_DEFAULTS, TEXT_SCALE_BASES, type ThemeColorKey, type ThemeColors, type ThemeDerivedColorKey, type ThemeFontWeightKey, type ThemeFontWeights, type ThemeMode, type ThemeStatusForegroundKey, type ThemeStatusForegrounds, type ThemeTokenState, } from './themeDefaults';
2
2
  export { DARK_COLORS, LIGHT_COLORS } from './themePalettes';
3
- export { applyBurneThemeConfig, applyTokens, exportBurneThemeConfigSource, exportBurneThemeCss, mergeThemeTokenOverrides, resolveTheme, resolveThemeTokenState, createDefaultBurneThemeConfig, exportDefaultBurneThemeConfigSource, themeTokenStateToConfig, type BurneThemeConfig, type BurneThemeMode, type ThemeModeColorOverrides, type ThemeTokenOverrides, } from './themeConfig';
3
+ export { applyBurneThemeConfig, applyCustomThemeTokens, applyTokens, clearCustomThemeTokens, exportBurneThemeConfigSource, exportBurneThemeCss, mergeThemeTokenOverrides, resolveTheme, resolveCustomThemeTokens, resolveThemeTokenState, createDefaultBurneThemeConfig, exportDefaultBurneThemeConfigSource, themeTokenStateToConfig, type BurneThemeConfig, type BurneThemeMode, type CustomThemeTokenControl, type CustomThemeTokenDefinition, type CustomThemeTokens, type CustomThemeTokenValue, type ThemeModeColorOverrides, type ThemeTokenOverrides, } from './themeConfig';
4
4
  export { ThemeProvider, applyThemeMode, useBurneTheme, useBurneThemeOptional, type BurneThemeContextValue, type ThemeProviderProps, } from './ThemeProvider';
5
5
  export { BurneUIProvider, type BurneUIProviderProps } from './BurneUIProvider';
6
+ export { useBurneThemeRuntime, useBurneThemeRuntimeOptional, type BurneThemeRuntimeContextValue, } from './themeRuntimeContext';
@@ -23,6 +23,30 @@ export type ThemeTokenOverrides = {
23
23
  };
24
24
  /** Per-mode flat palette (status + hover included as regular keys). */
25
25
  export type ThemeModeColorOverrides = ThemeColors | Partial<ThemeColors>;
26
+ export type CustomThemeTokenValue = string | number | boolean;
27
+ export type CustomThemeTokenControl = "color" | "number" | "select" | "slider" | "switch" | "text";
28
+ export type CustomThemeTokenDefinition = {
29
+ /** Shared value. Use `values` when light and dark need different values. */
30
+ value?: CustomThemeTokenValue;
31
+ values?: Partial<Record<ThemeMode, CustomThemeTokenValue>>;
32
+ label?: string;
33
+ group?: string;
34
+ control?: CustomThemeTokenControl;
35
+ description?: string;
36
+ min?: number;
37
+ max?: number;
38
+ step?: number;
39
+ unit?: string;
40
+ options?: readonly (string | {
41
+ label: string;
42
+ value: string;
43
+ })[];
44
+ };
45
+ /**
46
+ * Project-specific CSS variables. Keys must be valid custom properties (`--*`).
47
+ * Primitive values get an inferred devtools control; use a definition for metadata.
48
+ */
49
+ export type CustomThemeTokens = Record<`--${string}`, CustomThemeTokenValue | CustomThemeTokenDefinition>;
26
50
  /**
27
51
  * Serializable theme config for `BurneUIProvider`.
28
52
  * Generate via `exportBurneThemeConfigSource()` from the playground.
@@ -37,6 +61,7 @@ export type BurneThemeConfig = {
37
61
  storageKey?: string | null;
38
62
  tokens?: ThemeTokenOverrides;
39
63
  colors?: Partial<Record<ThemeMode, ThemeModeColorOverrides>>;
64
+ customTokens?: CustomThemeTokens;
40
65
  motion?: Partial<MotionConfig>;
41
66
  /** Wrap children with `Toast.Provider`. @default true */
42
67
  toast?: boolean | Omit<ToastProviderProps, "children">;
@@ -45,6 +70,12 @@ export type BurneThemeConfig = {
45
70
  export declare function resolveThemeTokenState(config: Pick<BurneThemeConfig, "tokens" | "colors">, mode: ThemeMode): ThemeTokenState;
46
71
  /** Build a `BurneThemeConfig` snapshot from live playground state. */
47
72
  export declare function themeTokenStateToConfig(state: ThemeTokenState): BurneThemeConfig;
73
+ /** Resolve custom token definitions to CSS-ready values for the active mode. */
74
+ export declare function resolveCustomThemeTokens(customTokens: CustomThemeTokens | undefined, mode: ThemeMode): Record<`--${string}`, string>;
75
+ /** Apply custom CSS variables and remove stale variables previously owned by Burne UI. */
76
+ export declare function applyCustomThemeTokens(customTokens: CustomThemeTokens | undefined, root: HTMLElement, mode: ThemeMode): void;
77
+ /** Remove all custom variables last applied by Burne UI on this root. */
78
+ export declare function clearCustomThemeTokens(root?: HTMLElement): void;
48
79
  /**
49
80
  * Default app theme snapshot (shared tokens + light/dark colors + motion).
50
81
  * Used by scaffolds / `burne-ui init` and as a starting point for Copy config edits.
@@ -0,0 +1,19 @@
1
+ import { Dispatch, ReactNode, SetStateAction } from 'react';
2
+ import { BurneThemeConfig } from './themeConfig';
3
+ import { ThemeMode } from './themeDefaults';
4
+ export type BurneThemeRuntimeContextValue = {
5
+ /** Config supplied to BurneUIProvider before a temporary preview is applied. */
6
+ baseConfig: BurneThemeConfig;
7
+ /** Config currently rendered by BurneUIProvider. */
8
+ config: BurneThemeConfig;
9
+ previewConfig: BurneThemeConfig | null;
10
+ resolvedTheme: ThemeMode;
11
+ setPreviewConfig: Dispatch<SetStateAction<BurneThemeConfig | null>>;
12
+ clearPreview: () => void;
13
+ };
14
+ export declare function BurneThemeRuntimeContextProvider({ children, value, }: {
15
+ children: ReactNode;
16
+ value: BurneThemeRuntimeContextValue;
17
+ }): import('react').FunctionComponentElement<import('react').ProviderProps<BurneThemeRuntimeContextValue | null>>;
18
+ export declare function useBurneThemeRuntime(): BurneThemeRuntimeContextValue;
19
+ export declare function useBurneThemeRuntimeOptional(): BurneThemeRuntimeContextValue | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "burne-ui",
3
- "version": "1.5.9",
3
+ "version": "1.6.0",
4
4
  "description": "React UI kit (Burne UI)",
5
5
  "type": "module",
6
6
  "sideEffects": [