@ufoui/core 0.0.12 → 0.0.40

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.
Files changed (43) hide show
  1. package/assets/icons.d.ts +5 -2
  2. package/components/accordion/accordion.d.ts +2 -2
  3. package/components/badge/badge.d.ts +2 -2
  4. package/components/base/boxBase.d.ts +4 -4
  5. package/components/base/buttonBase.d.ts +5 -5
  6. package/components/base/checkboxBase.d.ts +2 -2
  7. package/components/base/dialogBase.d.ts +105 -9
  8. package/components/base/fieldBase.d.ts +1 -1
  9. package/components/card/card.d.ts +2 -2
  10. package/components/dialogs/dialogActions.d.ts +19 -7
  11. package/components/dialogs/dialogActions.guards.d.ts +15 -0
  12. package/components/dialogs/dialogContent.d.ts +7 -1
  13. package/components/dialogs/dialogHeader.d.ts +60 -0
  14. package/components/dialogs/dialogTitle.d.ts +9 -5
  15. package/components/dialogs/index.d.ts +1 -0
  16. package/components/menu/menu.d.ts +2 -2
  17. package/components/rating/rating.d.ts +2 -2
  18. package/components/switch/switch.d.ts +2 -2
  19. package/components/themeProvider/themeProvider.d.ts +10 -15
  20. package/components/toolbar/toolbar.d.ts +1 -1
  21. package/components/tooltip/tooltip.d.ts +2 -2
  22. package/index.css +1 -1
  23. package/index.js +2934 -3033
  24. package/internal/icon/icon.d.ts +28 -0
  25. package/internal/index.d.ts +1 -0
  26. package/internal/inlineTooltip/inlineTooltipManager.d.ts +3 -3
  27. package/internal/slots/slot.d.ts +1 -1
  28. package/package.json +1 -1
  29. package/types/dialog.d.ts +37 -0
  30. package/types/index.d.ts +1 -0
  31. package/types/motion.d.ts +2 -2
  32. package/types/theme.d.ts +0 -30
  33. package/utils/applyThemeTokens.d.ts +10 -0
  34. package/utils/calculateFloatingPosition.d.ts +3 -3
  35. package/utils/color.d.ts +78 -131
  36. package/utils/colorRegistry.d.ts +44 -0
  37. package/utils/controlStyle.d.ts +8 -8
  38. package/utils/flatChildren.d.ts +17 -0
  39. package/utils/generateMaterialColors.d.ts +7 -7
  40. package/utils/index.d.ts +4 -1
  41. package/utils/renderPortal.d.ts +30 -0
  42. package/utils/utils.d.ts +2 -2
  43. package/utils/generateSchemes.d.ts +0 -32
@@ -0,0 +1,28 @@
1
+ import { ReactNode } from 'react';
2
+ import { SurfaceColor } from '../../utils';
3
+ /**
4
+ * Props for the {@link Icon} wrapper.
5
+ *
6
+ * @category Internal components
7
+ */
8
+ export interface IconProps {
9
+ /** Icon graphic or element rendered inside the wrapper. */
10
+ icon: ReactNode;
11
+ /** Additional class names merged with the base `uui-icon` token. */
12
+ className?: string;
13
+ /** Theme surface token as CSS `color` (for `currentColor` SVG). */
14
+ color?: SurfaceColor;
15
+ }
16
+ /**
17
+ * Renders icon content with the shared `uui-icon` layout class.
18
+ *
19
+ *
20
+ * @function
21
+ * @param props Component properties.
22
+ *
23
+ * @category Internal components
24
+ */
25
+ export declare const Icon: {
26
+ ({ icon, className, color }: IconProps): import("react/jsx-runtime").JSX.Element | null;
27
+ displayName: string;
28
+ };
@@ -4,3 +4,4 @@ export * from './stateLayer/stateLayer';
4
4
  export * from './controlGrid/controlGrid';
5
5
  export * from './controlLabel/controlLabel';
6
6
  export * from './description/description';
7
+ export * from './icon/icon';
@@ -1,12 +1,12 @@
1
1
  import { default as React, HTMLProps, ReactElement } from 'react';
2
- import { ElementAlign } from '../../utils';
2
+ import { ElementPlacement } from '../../utils';
3
3
  interface InlineTooltipManagerProps extends HTMLProps<HTMLSpanElement> {
4
4
  triggerRef: React.RefObject<HTMLElement>;
5
5
  tooltip: ReactElement;
6
- align: ElementAlign;
6
+ align: ElementPlacement;
7
7
  }
8
8
  export declare const InlineTooltipManager: {
9
- ({ tooltip, align, triggerRef }: InlineTooltipManagerProps): React.ReactPortal;
9
+ ({ tooltip, align, triggerRef }: InlineTooltipManagerProps): React.ReactPortal | null;
10
10
  displayName: string;
11
11
  };
12
12
  export {};
@@ -22,7 +22,7 @@ interface SlotProps {
22
22
  *
23
23
  * @category Slot
24
24
  */
25
- export declare const Slot: ({ start, end, content, className }: SlotProps) => import("react/jsx-runtime").JSX.Element;
25
+ export declare const Slot: ({ start, end, content, className }: SlotProps) => import("react/jsx-runtime").JSX.Element | null;
26
26
  /**
27
27
  * Slot wrapper for leading content.
28
28
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ufoui/core",
3
- "version": "0.0.12",
3
+ "version": "0.0.40",
4
4
  "description": "Lightweight Material Design 3 UI components for React",
5
5
  "type": "module",
6
6
  "main": "./index.mjs",
@@ -0,0 +1,37 @@
1
+ import { MotionAnimation } from './motion';
2
+ /**
3
+ * Layout mode for the DialogBase component.
4
+ *
5
+ * @remarks
6
+ * Determines dialog placement and sizing:
7
+ * - `'basic'` - centered dialog
8
+ * - `'fullscreen'` - full viewport
9
+ * - `'dockLeft'` / `'dockRight'` / `'dockTop'` / `'dockBottom'` - edge-docked panels
10
+ *
11
+ * @category Dialog
12
+ */
13
+ export type DialogType = 'basic' | 'fullscreen' | 'dockRight' | 'dockLeft' | 'dockTop' | 'dockBottom';
14
+ /**
15
+ * Animation preset for open and close transitions.
16
+ *
17
+ * @remarks
18
+ * Use `'none'` to disable motion. Otherwise uses a {@link MotionAnimation} value.
19
+ * When omitted, a default animation is chosen for the current layout mode.
20
+ *
21
+ * @category Dialog
22
+ */
23
+ export type DialogAnimation = 'none' | MotionAnimation;
24
+ /**
25
+ * Icon slot within dialog layout.
26
+ *
27
+ * Defines where the icon is rendered inside the dialog structure.
28
+ *
29
+ * Slots:
30
+ * - **leading** – inline with the title
31
+ * - **top** – placed above the title in the header
32
+ * - **contentLeft** – placed on the left side of the content area
33
+ * - **contentRight** – placed on the right side of the content area
34
+ *
35
+ * @category Dialog
36
+ */
37
+ export type DialogIconSlot = 'leading' | 'top' | 'contentLeft' | 'contentRight';
package/types/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './theme';
2
2
  export * from './motion';
3
+ export * from './dialog';
package/types/motion.d.ts CHANGED
@@ -2,9 +2,9 @@ export type MotionAnimation = 'fade' | 'fadeBlur' | 'scale' | 'scaleBlur' | 'pop
2
2
  export declare const motionClassMap: Record<MotionAnimation, string>;
3
3
  /**
4
4
  * Returns CSS class name for given motion animation.
5
- * Returns empty string when animation is not defined.
5
+ * Returns empty string when animation is not defined or set to 'none'.
6
6
  */
7
- export declare function getAnimationClass(animation?: MotionAnimation): string;
7
+ export declare function getAnimationClass(animation?: MotionAnimation | 'none'): string;
8
8
  /**
9
9
  * Returns list of available motion animation names.
10
10
  */
package/types/theme.d.ts CHANGED
@@ -166,12 +166,8 @@ export interface ThemeScheme {
166
166
  surfaceDim: string;
167
167
  /** Pure black color used for contrast or background. */
168
168
  black: string;
169
- /** Foreground color displayed on black (typically white). */
170
- onBlack: string;
171
169
  /** Pure white color used for contrast or foreground. */
172
170
  white: string;
173
- /** Foreground color displayed on white (typically black). */
174
- onWhite: string;
175
171
  /** Allows for additional custom tokens. */
176
172
  [key: string]: string;
177
173
  }
@@ -218,29 +214,3 @@ export interface Theme {
218
214
  /** Collection of all available color schemes. */
219
215
  schemes: ThemeSchemes;
220
216
  }
221
- /**
222
- * Core subset of theme colors representing primary semantic intents
223
- * (e.g., primary, error, success).
224
- * Commonly referenced across UI components.
225
- *
226
- * Serves as the base for {@link SemanticColor} and {@link ThemeSchemeKeys}.
227
- *
228
- * @category Theme
229
- */
230
- export declare const ThemeSemanticColorKeys: readonly ["primary", "secondary", "tertiary", "warning", "info", "success", "error"];
231
- /**
232
- * Extended set of semantic theme colors.
233
- * @category Theme
234
- */
235
- export declare const ThemeExtendedColorKeys: readonly ["primary", "secondary", "tertiary", "warning", "info", "success", "error", "primaryContainer", "primaryFixed", "primaryFixedDim", "secondaryContainer", "secondaryFixed", "secondaryFixedDim", "tertiaryContainer", "tertiaryFixed", "tertiaryFixedDim", "warningContainer", "warningFixed", "warningFixedDim", "infoContainer", "infoFixed", "infoFixedDim", "successContainer", "successFixed", "successFixedDim", "errorContainer", "errorFixed", "errorFixedDim", "black", "white"];
236
- /**
237
- * Surface-level theme colors including extended and neutral tones.
238
- * @category Theme
239
- */
240
- export declare const ThemeSurfaceColorKeys: readonly ["primary", "secondary", "tertiary", "warning", "info", "success", "error", "primaryContainer", "primaryFixed", "primaryFixedDim", "secondaryContainer", "secondaryFixed", "secondaryFixedDim", "tertiaryContainer", "tertiaryFixed", "tertiaryFixedDim", "warningContainer", "warningFixed", "warningFixedDim", "infoContainer", "infoFixed", "infoFixedDim", "successContainer", "successFixed", "successFixedDim", "errorContainer", "errorFixed", "errorFixedDim", "black", "white", "outline", "outlineVariant", "surface", "surfaceVariant", "background", "inverseSurface", "inversePrimary", "surfaceContainerHighest", "surfaceContainerHigh", "surfaceContainer", "surfaceContainerLow", "surfaceContainerLowest", "surfaceBright", "surfaceDim"];
241
- /**
242
- * Complete set of color tokens defined in {@link ThemeScheme}.
243
- * Combines all semantic, extended, and surface color roles for full theme coverage.
244
- * @category Theme
245
- */
246
- export declare const ThemeSchemeKeys: readonly ["primary", "secondary", "tertiary", "warning", "info", "success", "error", "primaryContainer", "primaryFixed", "primaryFixedDim", "secondaryContainer", "secondaryFixed", "secondaryFixedDim", "tertiaryContainer", "tertiaryFixed", "tertiaryFixedDim", "warningContainer", "warningFixed", "warningFixedDim", "infoContainer", "infoFixed", "infoFixedDim", "successContainer", "successFixed", "successFixedDim", "errorContainer", "errorFixed", "errorFixedDim", "black", "white", "outline", "outlineVariant", "surface", "surfaceVariant", "background", "inverseSurface", "inversePrimary", "surfaceContainerHighest", "surfaceContainerHigh", "surfaceContainer", "surfaceContainerLow", "surfaceContainerLowest", "surfaceBright", "surfaceDim", "onPrimary", "onPrimaryContainer", "onPrimaryFixed", "onPrimaryFixedVariant", "onSecondary", "onSecondaryContainer", "onSecondaryFixed", "onSecondaryFixedVariant", "onTertiary", "onTertiaryContainer", "onTertiaryFixed", "onTertiaryFixedVariant", "onWarning", "onWarningContainer", "onWarningFixed", "onWarningFixedVariant", "onInfo", "onInfoContainer", "onInfoFixed", "onInfoFixedVariant", "onSuccess", "onSuccessContainer", "onSuccessFixed", "onSuccessFixedVariant", "onError", "onErrorContainer", "onErrorFixed", "onErrorFixedVariant", "onSurface", "onSurfaceVariant", "onBackground", "inverseOnSurface", "inversePrimary", "shadow", "surfaceTint", "scrim"];
@@ -0,0 +1,10 @@
1
+ import { ThemeSchemes } from '../types';
2
+ /**
3
+ * Applies resolved theme tokens as CSS custom properties.
4
+ *
5
+ * @param schemes - Fully resolved theme schemes.
6
+ * @returns The same input object for convenient chaining.
7
+ *
8
+ * @category Theme
9
+ */
10
+ export declare function applyThemeTokens(schemes: ThemeSchemes): ThemeSchemes;
@@ -1,5 +1,5 @@
1
1
  import { RefObject } from 'react';
2
- import { ElementAlign } from './utils';
2
+ import { ElementPlacement } from './utils';
3
3
  /**
4
4
  * Floating behavior presets used by `calculateFloatingPosition()`.
5
5
  *
@@ -23,7 +23,7 @@ export type ElementFloatingMode = 'tooltip' | 'dropdown' | 'menu' | 'submenu';
23
23
  * @category Utils
24
24
  */
25
25
  export interface CalculateFloatingPositionOptions {
26
- placement?: ElementAlign;
26
+ placement?: ElementPlacement;
27
27
  offset?: number;
28
28
  mode?: ElementFloatingMode;
29
29
  }
@@ -39,7 +39,7 @@ export interface CalculateFloatingPositionOptions {
39
39
  export interface ElementFloatingPosition {
40
40
  x: number;
41
41
  y: number;
42
- placement: ElementAlign;
42
+ placement: ElementPlacement;
43
43
  }
44
44
  /**
45
45
  * Computes the optimal on-screen position for tooltips, dropdowns, menus and submenus.
package/utils/color.d.ts CHANGED
@@ -1,158 +1,105 @@
1
- import { ThemeExtendedColorKeys, ThemeSchemeKeys, ThemeSemanticColorKeys, ThemeSurfaceColorKeys } from '../types';
2
1
  /**
3
- * Represents a high-level semantic color token (e.g. `primary`, `error`, `success`).
4
- * Derived from {@link ThemeSemanticColorKeys}.
2
+ * Built-in semantic color names available in every theme.
3
+ *
5
4
  * @category Color
6
5
  */
7
- export type SemanticColor = (typeof ThemeSemanticColorKeys)[number];
6
+ export type CoreSemanticColor = 'primary' | 'secondary' | 'tertiary' | 'warning' | 'info' | 'success' | 'error';
8
7
  /**
9
- * Represents tokens extending the {@link SemanticColor} set
10
- * with additional container and fixed variants.
11
- * Derived from {@link ThemeExtendedColorKeys}.
8
+ * Built-in surface color names intended for backgrounds, layers, and outlines.
9
+ *
12
10
  * @category Color
13
11
  */
14
- export type ExtendedColor = (typeof ThemeExtendedColorKeys)[number];
12
+ export type CoreSurfaceColor = 'surface' | 'surfaceVariant' | 'background' | 'inverseSurface' | 'outline' | 'outlineVariant' | 'surfaceContainerLowest' | 'surfaceContainerLow' | 'surfaceContainer' | 'surfaceContainerHigh' | 'surfaceContainerHighest' | 'surfaceBright' | 'surfaceDim';
15
13
  /**
16
- * Represents surface-related color tokens extending {@link ExtendedColor},
17
- * including background, outline, and container surface roles.
18
- * Derived from {@link ThemeSurfaceColorKeys}.
14
+ * Built-in technical color names not intended for direct usage.
15
+ *
19
16
  * @category Color
20
17
  */
21
- export type SurfaceColor = (typeof ThemeSurfaceColorKeys)[number];
18
+ export type CoreThemeColor = 'onSurface' | 'onSurfaceVariant' | 'onBackground' | 'inverseOnSurface' | 'inversePrimary' | 'surfaceTint' | 'scrim' | 'shadow' | 'black' | 'white';
19
+ /** * Empty custom-color map used as the default generic parameter. * * @category Color */
20
+ export type EmptyColors = Record<never, never>;
22
21
  /**
23
- * Represents any valid color token defined in the theme,
24
- * including semantic, extended, and surface roles.
25
- * Derived from {@link ThemeSchemeKeys}.
22
+ * Augmentation point for custom semantic colors.
23
+ *
24
+ * @example
25
+ * declare module '@ufoui/core' {
26
+ * interface CustomColors {
27
+ * myBlue: true;
28
+ * }
29
+ * }
30
+ *
26
31
  * @category Color
27
32
  */
28
- export type ThemeColor = (typeof ThemeSchemeKeys)[number];
33
+ export interface CustomColors {
34
+ }
29
35
  /**
30
- * Generates utility class names (`uui-*`) for a given **semantic color** and its variants.
36
+ * Base semantic color (core + augmented).
31
37
  *
32
- * @remarks
33
- * Produces `text`, `border`, and `background` class names for a semantic color and its
34
- * derived tokens (`on`, `container`, `fixed`, `fixedDim`, etc.).
35
- * If the provided key is invalid, `'primary'` is used as fallback.
38
+ * @category Color
39
+ */
40
+ export type SemanticBaseColor = CoreSemanticColor | keyof CustomColors;
41
+ /**
42
+ * Builds `on*` color name.
36
43
  *
37
- * All class names follow the pattern `uui-{type}-{kebab-case-color}`.
44
+ * @category Color
45
+ */
46
+ export type OnColor<T extends string> = `on${Capitalize<T>}`;
47
+ /**
48
+ * Semantic color used in component APIs.
38
49
  *
39
- * @param color - Semantic color name (e.g. `'primary'`, `'error'`, `'success'`).
40
- * @returns Object with `uui-text-*`, `uui-border-*`, and `uui-bg-*` class names for all variants.
50
+ * @category Color
51
+ */
52
+ export type SemanticColor = SemanticBaseColor;
53
+ /**
54
+ * Extended semantic colors.
41
55
  *
42
- * @example
43
- * ```ts
44
- * getSemanticColorClasses('primary');
45
- * // → { textColor: 'uui-text-primary', bgOnColor: 'uui-bg-on-primary', ... }
46
- * ```
47
56
  * @category Color
48
57
  */
49
- export declare const getSemanticColorClasses: (color: SemanticColor) => {
50
- textColor: string;
51
- borderColor: string;
52
- bgColor: string;
53
- textOnColor: string;
54
- borderOnColor: string;
55
- bgOnColor: string;
56
- textContainer: string;
57
- borderContainer: string;
58
- bgContainer: string;
59
- textOnContainer: string;
60
- borderOnContainer: string;
61
- bgOnContainer: string;
62
- textFixed: string;
63
- borderFixed: string;
64
- bgFixed: string;
65
- textOnFixed: string;
66
- borderOnFixed: string;
67
- bgOnFixed: string;
68
- textFixedDim: string;
69
- borderFixedDim: string;
70
- bgFixedDim: string;
71
- textOnFixedVariant: string;
72
- borderOnFixedVariant: string;
73
- bgOnFixedVariant: string;
74
- };
58
+ export type ExtendedColor = `${SemanticBaseColor}Container` | `${SemanticBaseColor}Fixed` | `${SemanticBaseColor}FixedDim`;
75
59
  /**
76
- * Bidirectional mapping between theme colors and their “on” counterparts.
60
+ * `on*` counterparts for extended colors.
77
61
  *
78
- * @remarks
79
- * Provides both directions — e.g. `'surface' → 'onSurface'` and `'onSurface' → 'surface'` —
80
- * for all semantic, extended, and surface tokens defined in {@link ThemeColor}.
81
- * Enables consistent inverse lookups for text/background pairings.
82
- *
83
- *
84
- * @category Color
85
- */
86
- export declare const inverseColorMap: {
87
- readonly surface: "onSurface";
88
- readonly surfaceVariant: "onSurfaceVariant";
89
- readonly surfaceContainerLowest: "onSurface";
90
- readonly surfaceContainerLow: "onSurface";
91
- readonly surfaceContainer: "onSurface";
92
- readonly surfaceContainerHigh: "onSurface";
93
- readonly surfaceContainerHighest: "onSurface";
94
- readonly surfaceDim: "onSurface";
95
- readonly surfaceBright: "onSurface";
96
- readonly background: "onBackground";
97
- readonly inverseSurface: "inverseOnSurface";
98
- readonly primary: "onPrimary";
99
- readonly secondary: "onSecondary";
100
- readonly tertiary: "onTertiary";
101
- readonly warning: "onWarning";
102
- readonly info: "onInfo";
103
- readonly success: "onSuccess";
104
- readonly error: "onError";
105
- readonly primaryContainer: "onPrimaryContainer";
106
- readonly primaryFixed: "onPrimaryFixed";
107
- readonly primaryFixedDim: "onPrimaryFixedVariant";
108
- readonly secondaryContainer: "onSecondaryContainer";
109
- readonly secondaryFixed: "onSecondaryFixed";
110
- readonly secondaryFixedDim: "onSecondaryFixedVariant";
111
- readonly tertiaryContainer: "onTertiaryContainer";
112
- readonly tertiaryFixed: "onTertiaryFixed";
113
- readonly tertiaryFixedDim: "onTertiaryFixedVariant";
114
- readonly warningContainer: "onWarningContainer";
115
- readonly warningFixed: "onWarningFixed";
116
- readonly warningFixedDim: "onWarningFixedVariant";
117
- readonly infoContainer: "onInfoContainer";
118
- readonly infoFixed: "onInfoFixed";
119
- readonly infoFixedDim: "onInfoFixedVariant";
120
- readonly successContainer: "onSuccessContainer";
121
- readonly successFixed: "onSuccessFixed";
122
- readonly successFixedDim: "onSuccessFixedVariant";
123
- readonly errorContainer: "onErrorContainer";
124
- readonly errorFixed: "onErrorFixed";
125
- readonly errorFixedDim: "onErrorFixedVariant";
126
- readonly outline: "surface";
127
- readonly outlineVariant: "inverseSurface";
128
- readonly inversePrimary: "onPrimaryContainer";
129
- readonly black: "white";
130
- readonly white: "black";
131
- readonly onSurface: "surface";
132
- readonly onSurfaceVariant: "surfaceVariant";
133
- readonly onBackground: "background";
134
- readonly inverseOnSurface: "inverseSurface";
135
- readonly onPrimary: "primary";
136
- readonly onSecondary: "secondary";
137
- readonly onTertiary: "tertiary";
138
- readonly onWarning: "warning";
139
- readonly onInfo: "info";
140
- readonly onSuccess: "success";
141
- readonly onError: "error";
142
- readonly onPrimaryContainer: "primaryContainer";
143
- readonly onSecondaryContainer: "secondaryContainer";
144
- readonly onTertiaryContainer: "tertiaryContainer";
145
- readonly onWarningContainer: "warningContainer";
146
- readonly onInfoContainer: "infoContainer";
147
- readonly onSuccessContainer: "successContainer";
148
- readonly onErrorContainer: "errorContainer";
149
- };
62
+ * @category Color
63
+ */
64
+ export type OnExtendedColor = OnColor<`${SemanticBaseColor}Container`> | OnColor<`${SemanticBaseColor}Fixed`> | OnColor<`${SemanticBaseColor}FixedVariant`>;
65
+ /**
66
+ * Surface colors.
67
+ *
68
+ * @category Color
69
+ */
70
+ export type SurfaceColor = CoreSurfaceColor | ExtendedColor;
150
71
  /**
151
- * Represents the available border color options.
72
+ * Colors allowed in component props.
152
73
  *
153
74
  * @category Color
154
75
  */
155
- export type BorderColor = SurfaceColor;
76
+ export type BaseColor = SemanticColor | SurfaceColor;
77
+ /**
78
+ * Full theme color set.
79
+ *
80
+ * @category Color
81
+ */
82
+ export type ThemeColor = BaseColor | OnColor<SemanticBaseColor> | OnExtendedColor | CoreThemeColor;
83
+ /**
84
+ * Border color.
85
+ *
86
+ * @category Color
87
+ */
88
+ export type BorderColor = BaseColor;
89
+ export declare function getOnColorName(colorName: ThemeColor): ThemeColor | undefined;
90
+ /**
91
+ * Returns all color names from the global registry for the selected type.
92
+ *
93
+ * @param type - Color type to filter by.
94
+ * @returns List of color names matching the requested type.
95
+ * @category Theme
96
+ */
97
+ export declare function getColorNames(type: 'semantic'): SemanticColor[];
98
+ export declare function getColorNames(type: 'extended'): ExtendedColor[];
99
+ export declare function getColorNames(type: 'surface'): SurfaceColor[];
100
+ export declare function getColorNames(type: 'theme'): ThemeColor[];
101
+ export declare function getColorNames(type: 'base'): BaseColor[];
102
+ export declare function getColorNames(type: 'border'): BorderColor[];
156
103
  /**
157
104
  * Returns basic CSS variable references for a **surface color**.
158
105
  *
@@ -171,7 +118,7 @@ export type BorderColor = SurfaceColor;
171
118
  * ```
172
119
  * @category Color
173
120
  */
174
- export declare const getSurfaceColorVar: (color: SurfaceColor) => {
121
+ export declare const getSurfaceColorVar: (color: BaseColor) => {
175
122
  color: string;
176
123
  onColor: string;
177
124
  };
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Runtime color type used by the generated color registry.
3
+ *
4
+ * @category Theme
5
+ */
6
+ export type ColorType = 'semantic' | 'surface' | 'extended' | 'base' | 'border' | 'theme';
7
+ /**
8
+ * Metadata entry describing how a color name should be used.
9
+ *
10
+ * @category Theme
11
+ */
12
+ export interface ColorRegistryEntry {
13
+ /** Usage type assigned to the color name. */
14
+ type: ColorType;
15
+ /** Paired contrast color name (e.g. `primary` -> `onPrimary`). */
16
+ onColor?: string;
17
+ }
18
+ /**
19
+ * Global color registry keyed by theme color names.
20
+ *
21
+ * @category Theme
22
+ */
23
+ export type ColorRegistry = Record<string, ColorRegistryEntry | undefined>;
24
+ /**
25
+ * Replaces the global color registry.
26
+ *
27
+ * @param registry - New registry produced by theme generation.
28
+ * @category Theme
29
+ */
30
+ export declare function setColorRegistry(registry: ColorRegistry): void;
31
+ /**
32
+ * Returns the current global color registry.
33
+ *
34
+ * @returns The last registry set by theme generation.
35
+ * @category Theme
36
+ */
37
+ export declare function getColorRegistry(): ColorRegistry;
38
+ /**
39
+ * Resolves the paired contrast color from the global color registry.
40
+ *
41
+ * @param colorName - Base color name from the registry.
42
+ * @returns Linked `onColor` value if present.
43
+ * @category Theme
44
+ */
@@ -1,5 +1,5 @@
1
1
  import { default as React } from 'react';
2
- import { SemanticColor, SurfaceColor, ThemeColor } from './color';
2
+ import { BaseColor, SemanticColor, ThemeColor } from './color';
3
3
  /**
4
4
  * Creates a strictly typed style builder for MD3 color tokens.
5
5
  *
@@ -9,49 +9,49 @@ type CSSPropertyKey = Extract<keyof React.CSSProperties, string>;
9
9
  type CSSVar = `--${string}`;
10
10
  export declare function ControlStyle(initial?: React.CSSProperties): {
11
11
  bg: ((color?: ThemeColor) => void) & {
12
- on(color?: SurfaceColor): void;
12
+ on(color?: BaseColor): void;
13
13
  container(color?: SemanticColor): void;
14
14
  onContainer(color?: SemanticColor): void;
15
15
  fixed(color?: SemanticColor): void;
16
16
  fixedDim(color?: SemanticColor): void;
17
17
  };
18
18
  text: ((color?: ThemeColor) => void) & {
19
- on(color?: SurfaceColor): void;
19
+ on(color?: BaseColor): void;
20
20
  container(color?: SemanticColor): void;
21
21
  onContainer(color?: SemanticColor): void;
22
22
  fixed(color?: SemanticColor): void;
23
23
  fixedDim(color?: SemanticColor): void;
24
24
  };
25
25
  border: ((color?: ThemeColor) => void) & {
26
- on(color?: SurfaceColor): void;
26
+ on(color?: BaseColor): void;
27
27
  container(color?: SemanticColor): void;
28
28
  onContainer(color?: SemanticColor): void;
29
29
  fixed(color?: SemanticColor): void;
30
30
  fixedDim(color?: SemanticColor): void;
31
31
  };
32
32
  outline: ((color?: ThemeColor) => void) & {
33
- on(color?: SurfaceColor): void;
33
+ on(color?: BaseColor): void;
34
34
  container(color?: SemanticColor): void;
35
35
  onContainer(color?: SemanticColor): void;
36
36
  fixed(color?: SemanticColor): void;
37
37
  fixedDim(color?: SemanticColor): void;
38
38
  };
39
39
  current: ((color?: ThemeColor) => void) & {
40
- on(color?: SurfaceColor): void;
40
+ on(color?: BaseColor): void;
41
41
  container(color?: SemanticColor): void;
42
42
  onContainer(color?: SemanticColor): void;
43
43
  fixed(color?: SemanticColor): void;
44
44
  fixedDim(color?: SemanticColor): void;
45
45
  };
46
46
  stroke: ((color?: ThemeColor) => void) & {
47
- on(color?: SurfaceColor): void;
47
+ on(color?: BaseColor): void;
48
48
  container(color?: SemanticColor): void;
49
49
  onContainer(color?: SemanticColor): void;
50
50
  fixed(color?: SemanticColor): void;
51
51
  fixedDim(color?: SemanticColor): void;
52
52
  };
53
53
  fill: ((color?: ThemeColor) => void) & {
54
- on(color?: SurfaceColor): void;
54
+ on(color?: BaseColor): void;
55
55
  container(color?: SemanticColor): void;
56
56
  onContainer(color?: SemanticColor): void;
57
57
  fixed(color?: SemanticColor): void;
@@ -0,0 +1,17 @@
1
+ import { ReactNode } from 'react';
2
+ /**
3
+ * Flattens a React node tree by one level, unwrapping Fragments.
4
+ *
5
+ * Accepts a single element, a Fragment, or an array and returns a flat array
6
+ * of `ReactNode` items. Useful in components that need to identify or count
7
+ * specific child types via type guards.
8
+ *
9
+ * @param node - React node to flatten.
10
+ * @returns Flat array of React nodes with top-level Fragments unwrapped.
11
+ *
12
+ * @example
13
+ * const items = flatChildren(actions).filter(isDialogAction);
14
+ *
15
+ * @category Utils
16
+ */
17
+ export declare const flatChildren: (node: ReactNode) => ReactNode[];
@@ -1,5 +1,5 @@
1
1
  import { PartialThemeSchemes, ThemeSchemes } from '../types';
2
- export type ExtraColorOverrides = Partial<Record<'info' | 'warning' | 'success', string>>;
2
+ export type UserColors = Record<string, string>;
3
3
  /**
4
4
  * Generates a full ThemeSchemes object (light and dark modes) based on a seed color,
5
5
  * optional token overrides, and custom semantic colors (info, warning, success).
@@ -12,20 +12,20 @@ export type ExtraColorOverrides = Partial<Record<'info' | 'warning' | 'success',
12
12
  *
13
13
  * @param seedColor - Optional seed color in hex (e.g. "#6200ee"). Used as the base for the primary palette.
14
14
  * Defaults to `#6750A4` if not provided.
15
- * @param customSchemes - Optional overrides for light and dark color values.
16
- * Partial values will be merged with generated ones.
17
- * @param extraColors - Optional custom base colors for `info`, `warning`, and `success`.
18
- * These will override the default values (`#03a9f4`, `#ffd600`, `#689f38`).
15
+ * @param colors - Optional map of custom base colors. Defaults include `info`, `warning`, and `success`.
16
+ * Any key can be provided (e.g. `brand`, `neutralStrong`, `secondary`).
17
+ * @param customSchemes - Optional skin overrides for schemes (e.g. light/dark/high-contrast).
18
+ * Applied as the final merge step.
19
19
  *
20
20
  * @returns A fully resolved ThemeSchemes object with all required color roles populated for light and dark modes.
21
+ * Also updates the global color registry via `setColorRegistry()`.
21
22
  *
22
23
  * @example
23
24
  * ```ts
24
25
  * const schemes = generateMaterialColors('#6200ee', { info: '#2196f3' }, {});
25
26
  * const primary = schemes.light.primary;
26
- * const infoContainer = schemes.dark.infoContainer;
27
27
  * ```
28
28
  *
29
29
  * @category Theme
30
30
  */
31
- export declare function generateMaterialColors(seedColor?: string, extraColors?: ExtraColorOverrides, customSchemes?: PartialThemeSchemes): ThemeSchemes;
31
+ export declare function generateMaterialColors(seedColor?: string, colors?: UserColors, customSchemes?: PartialThemeSchemes): ThemeSchemes;
package/utils/index.d.ts CHANGED
@@ -3,8 +3,11 @@ export * from './utils';
3
3
  export * from './calculateFloatingPosition';
4
4
  export * from './interactionMode';
5
5
  export * from './generateMaterialColors';
6
- export * from './generateSchemes';
6
+ export * from './applyThemeTokens';
7
7
  export * from './toasts';
8
8
  export * from './uniqueID';
9
9
  export * from './controlStyle';
10
10
  export * from './getWrapperStyle';
11
+ export * from './flatChildren';
12
+ export * from './renderPortal';
13
+ export * from './colorRegistry';