@ufoui/core 0.0.5 → 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 (80) hide show
  1. package/assets/icons.d.ts +8 -2
  2. package/components/accordion/accordion.d.ts +31 -3
  3. package/components/accordion/accordionItem.d.ts +31 -3
  4. package/components/badge/badge.d.ts +2 -2
  5. package/components/base/boxBase.d.ts +14 -36
  6. package/components/base/buttonBase.d.ts +4 -4
  7. package/components/base/checkboxBase.d.ts +2 -2
  8. package/components/base/dialogBase.d.ts +111 -13
  9. package/components/base/fieldBase.d.ts +1 -2
  10. package/components/base/textBase.d.ts +1 -2
  11. package/components/breadcrumbs/breadcrumbs.d.ts +48 -0
  12. package/components/calendar/calendar.d.ts +23 -0
  13. package/components/calendar/calendarUtils.d.ts +18 -0
  14. package/components/card/card.d.ts +2 -2
  15. package/components/collapse/collapse.d.ts +15 -20
  16. package/components/dialogs/dialog.d.ts +1 -1
  17. package/components/dialogs/dialogActions.d.ts +19 -7
  18. package/components/dialogs/dialogActions.guards.d.ts +15 -0
  19. package/components/dialogs/dialogContent.d.ts +7 -1
  20. package/components/dialogs/dialogHeader.d.ts +60 -0
  21. package/components/dialogs/dialogTitle.d.ts +9 -5
  22. package/components/dialogs/drawer.d.ts +1 -1
  23. package/components/dialogs/index.d.ts +1 -0
  24. package/components/fieldset/fieldset.d.ts +1 -1
  25. package/components/link/link.d.ts +58 -0
  26. package/components/list/list.d.ts +1 -1
  27. package/components/menu/menu.d.ts +2 -2
  28. package/components/rating/rating.d.ts +68 -0
  29. package/components/slider/slider.d.ts +11 -0
  30. package/components/switch/switch.d.ts +2 -10
  31. package/components/themeProvider/themeProvider.d.ts +10 -15
  32. package/components/toast/toast.d.ts +18 -4
  33. package/components/toast/toastViewport.d.ts +4 -3
  34. package/components/tooltip/tooltip.d.ts +2 -2
  35. package/context/selectionContext.d.ts +18 -17
  36. package/hooks/index.d.ts +3 -1
  37. package/hooks/useAnimate.d.ts +36 -16
  38. package/hooks/useFocusTrap.d.ts +32 -0
  39. package/hooks/useFocusVisible.d.ts +16 -14
  40. package/hooks/useResizeObserver.d.ts +7 -3
  41. package/hooks/useRovingFocus.d.ts +30 -0
  42. package/hooks/useSelection.d.ts +10 -7
  43. package/hooks/useSelectionState.d.ts +29 -0
  44. package/hooks/useSliderKeys.d.ts +41 -0
  45. package/index.css +1 -1
  46. package/index.d.ts +4 -8
  47. package/index.js +4782 -0
  48. package/internal/controlGrid/controlGrid.d.ts +32 -0
  49. package/internal/controlLabel/controlLabel.d.ts +31 -0
  50. package/internal/description/description.d.ts +18 -0
  51. package/internal/icon/icon.d.ts +28 -0
  52. package/internal/index.d.ts +7 -0
  53. package/internal/inlineTooltip/index.d.ts +1 -0
  54. package/internal/inlineTooltip/inlineTooltipManager.d.ts +3 -3
  55. package/internal/slots/slot.d.ts +44 -0
  56. package/internal/stateLayer/stateLayer.d.ts +33 -0
  57. package/package.json +12 -3
  58. package/types/dialog.d.ts +37 -0
  59. package/types/index.d.ts +1 -0
  60. package/types/motion.d.ts +2 -2
  61. package/types/theme.d.ts +0 -30
  62. package/utils/applyThemeTokens.d.ts +10 -0
  63. package/utils/calculateFloatingPosition.d.ts +3 -3
  64. package/utils/color.d.ts +61 -216
  65. package/utils/colorRegistry.d.ts +44 -0
  66. package/utils/controlStyle.d.ts +8 -8
  67. package/utils/flatChildren.d.ts +17 -0
  68. package/utils/generateMaterialColors.d.ts +7 -7
  69. package/utils/getWrapperStyle.d.ts +53 -0
  70. package/utils/index.d.ts +5 -1
  71. package/utils/renderPortal.d.ts +30 -0
  72. package/utils/toasts/ensureViewport.d.ts +6 -1
  73. package/utils/toasts/toast.d.ts +66 -10
  74. package/utils/toasts/toastStore.d.ts +55 -1
  75. package/utils/utils.d.ts +67 -55
  76. package/hooks/useFocusState.d.ts +0 -16
  77. package/index.mjs +0 -4649
  78. package/internal/inlineTooltip/inlineTooltip.d.ts +0 -11
  79. package/internal/inlineTooltip/inlineTooltip2.d.ts +0 -10
  80. package/utils/generateSchemes.d.ts +0 -32
package/utils/color.d.ts CHANGED
@@ -1,251 +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.
31
- *
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.
36
+ * Base semantic color (core + augmented).
36
37
  *
37
- * All class names follow the pattern `uui-{type}-{kebab-case-color}`.
38
- *
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.
41
- *
42
- * @example
43
- * ```ts
44
- * getSemanticColorClasses('primary');
45
- * // → { textColor: 'uui-text-primary', bgOnColor: 'uui-bg-on-primary', ... }
46
- * ```
47
38
  * @category Color
48
39
  */
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
- };
40
+ export type SemanticBaseColor = CoreSemanticColor | keyof CustomColors;
75
41
  /**
76
- * Bidirectional mapping between theme colors and their “on” counterparts.
77
- *
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
- * Commonly used by {@link getSurfaceColorClasses}.
42
+ * Builds `on*` color name.
84
43
  *
85
44
  * @category Color
86
45
  */
87
- export declare const inverseColorMap: {
88
- readonly surface: "onSurface";
89
- readonly surfaceVariant: "onSurfaceVariant";
90
- readonly surfaceContainerLowest: "onSurface";
91
- readonly surfaceContainerLow: "onSurface";
92
- readonly surfaceContainer: "onSurface";
93
- readonly surfaceContainerHigh: "onSurface";
94
- readonly surfaceContainerHighest: "onSurface";
95
- readonly surfaceDim: "onSurface";
96
- readonly surfaceBright: "onSurface";
97
- readonly background: "onBackground";
98
- readonly inverseSurface: "inverseOnSurface";
99
- readonly primary: "onPrimary";
100
- readonly secondary: "onSecondary";
101
- readonly tertiary: "onTertiary";
102
- readonly warning: "onWarning";
103
- readonly info: "onInfo";
104
- readonly success: "onSuccess";
105
- readonly error: "onError";
106
- readonly primaryContainer: "onPrimaryContainer";
107
- readonly primaryFixed: "onPrimaryFixed";
108
- readonly primaryFixedDim: "onPrimaryFixedVariant";
109
- readonly secondaryContainer: "onSecondaryContainer";
110
- readonly secondaryFixed: "onSecondaryFixed";
111
- readonly secondaryFixedDim: "onSecondaryFixedVariant";
112
- readonly tertiaryContainer: "onTertiaryContainer";
113
- readonly tertiaryFixed: "onTertiaryFixed";
114
- readonly tertiaryFixedDim: "onTertiaryFixedVariant";
115
- readonly warningContainer: "onWarningContainer";
116
- readonly warningFixed: "onWarningFixed";
117
- readonly warningFixedDim: "onWarningFixedVariant";
118
- readonly infoContainer: "onInfoContainer";
119
- readonly infoFixed: "onInfoFixed";
120
- readonly infoFixedDim: "onInfoFixedVariant";
121
- readonly successContainer: "onSuccessContainer";
122
- readonly successFixed: "onSuccessFixed";
123
- readonly successFixedDim: "onSuccessFixedVariant";
124
- readonly errorContainer: "onErrorContainer";
125
- readonly errorFixed: "onErrorFixed";
126
- readonly errorFixedDim: "onErrorFixedVariant";
127
- readonly outline: "surface";
128
- readonly outlineVariant: "inverseSurface";
129
- readonly inversePrimary: "onPrimaryContainer";
130
- readonly black: "white";
131
- readonly white: "black";
132
- readonly onSurface: "surface";
133
- readonly onSurfaceVariant: "surfaceVariant";
134
- readonly onBackground: "background";
135
- readonly inverseOnSurface: "inverseSurface";
136
- readonly onPrimary: "primary";
137
- readonly onSecondary: "secondary";
138
- readonly onTertiary: "tertiary";
139
- readonly onWarning: "warning";
140
- readonly onInfo: "info";
141
- readonly onSuccess: "success";
142
- readonly onError: "error";
143
- readonly onPrimaryContainer: "primaryContainer";
144
- readonly onSecondaryContainer: "secondaryContainer";
145
- readonly onTertiaryContainer: "tertiaryContainer";
146
- readonly onWarningContainer: "warningContainer";
147
- readonly onInfoContainer: "infoContainer";
148
- readonly onSuccessContainer: "successContainer";
149
- readonly onErrorContainer: "errorContainer";
150
- };
46
+ export type OnColor<T extends string> = `on${Capitalize<T>}`;
151
47
  /**
152
- * Returns utility class names (`uui-*`) for a given surface color and its mapped “on” color.
48
+ * Semantic color used in component APIs.
153
49
  *
154
- * @remarks
155
- * Uses the {@link inverseColorMap} to find the related “on” color
156
- * (e.g. `'surfaceContainer'` → `'onSurface'`).
157
- * Produces `text`, `border`, and `background` variants for both.
158
- * All names are kebab-cased (e.g. `'surfaceContainerHigh'` → `'surface-container-high'`).
159
- *
160
- * @param color - Surface color key (e.g. `'surfaceContainerHigh'`).
161
- * @returns Object with `uui-text-*`, `uui-border-*`, and `uui-bg-*` class names for base and on-color.
162
- *
163
- * @example
164
- * ```ts
165
- * getSurfaceColorClasses('surfaceContainer');
166
- * // → { textColor: 'uui-text-surface-container', textOnColor: 'uui-text-on-surface', ... }
167
- * ```
168
50
  * @category Color
169
51
  */
170
- export declare const getSurfaceColorClasses: (color: SurfaceColor) => {
171
- readonly textColor: `uui-text-${string}`;
172
- readonly textOnColor: `uui-text-${string}`;
173
- readonly borderColor: `uui-border-${string}`;
174
- readonly borderOnColor: `uui-border-${string}`;
175
- readonly bgColor: `uui-bg-${string}`;
176
- readonly bgOnColor: `uui-bg-${string}`;
177
- };
52
+ export type SemanticColor = SemanticBaseColor;
178
53
  /**
179
- * Returns utility class names (`uui-*`) for any theme color token.
54
+ * Extended semantic colors.
180
55
  *
181
- * @remarks
182
- * Generates `text`, `border`, and `background` class names based on the provided
183
- * {@link ThemeColor}. If the color key is invalid, `'primary'` is used as fallback.
184
- *
185
- * @param color - Theme color token (e.g. `'primary'`, `'surfaceContainerHigh'`, `'error'`).
186
- * @returns An object with `uui-text-*`, `uui-border-*`, and `uui-bg-*` class names.
187
- *
188
- * @example
189
- * ```ts
190
- * getColorClasses('error');
191
- * // → { textColor: 'uui-text-error', borderColor: 'uui-border-error', bgColor: 'uui-bg-error' }
192
- * ```
193
56
  * @category Color
194
57
  */
195
- export declare const getColorClasses: (color: ThemeColor) => {
196
- readonly textColor: `uui-text-${string}`;
197
- readonly borderColor: `uui-border-${string}`;
198
- readonly bgColor: `uui-bg-${string}`;
199
- };
58
+ export type ExtendedColor = `${SemanticBaseColor}Container` | `${SemanticBaseColor}Fixed` | `${SemanticBaseColor}FixedDim`;
200
59
  /**
201
- * Represents the available border color options.
60
+ * `on*` counterparts for extended colors.
202
61
  *
203
62
  * @category Color
204
63
  */
205
- export type BorderColor = SurfaceColor;
64
+ export type OnExtendedColor = OnColor<`${SemanticBaseColor}Container`> | OnColor<`${SemanticBaseColor}Fixed`> | OnColor<`${SemanticBaseColor}FixedVariant`>;
206
65
  /**
207
- * Returns the appropriate border color class for a given configuration.
66
+ * Surface colors.
208
67
  *
209
- * @remarks
210
- * Typical border colors are `'outline'` and `'outlineVariant'`, matching MD3 tokens.
211
- * @param borderColor - Border color keyword or surface color token.
212
- * @returns The resolved border color class (e.g. `'uui-border-surface-container-high'`).
213
- *
214
- * @example
215
- * ```ts
216
- * getBorderColorClass('surfaceContainer'); // → 'uui-border-surface-container'
217
- * ```
218
68
  * @category Color
219
69
  */
220
- export declare function getBorderColorClass(borderColor: BorderColor): `uui-border-${string}`;
70
+ export type SurfaceColor = CoreSurfaceColor | ExtendedColor;
221
71
  /**
222
- * Returns all CSS variable references for a **semantic color**.
72
+ * Colors allowed in component props.
223
73
  *
224
- * @remarks
225
- * Generates `var(--uui-color-*)` tokens only for semantic colors
226
- * defined in {@link SemanticColor} (e.g. `primary`, `error`, `success`).
227
- * Useful for dynamic component theming and inline styles.
74
+ * @category Color
75
+ */
76
+ export type BaseColor = SemanticColor | SurfaceColor;
77
+ /**
78
+ * Full theme color set.
228
79
  *
229
- * @param color - Semantic color key (e.g. `'primary'`, `'error'`, `'info'`).
230
- * @returns Object containing `var(--uui-color-...)` references for all variants.
80
+ * @category Color
81
+ */
82
+ export type ThemeColor = BaseColor | OnColor<SemanticBaseColor> | OnExtendedColor | CoreThemeColor;
83
+ /**
84
+ * Border color.
231
85
  *
232
- * @example
233
- * ```ts
234
- * const vars = getSemanticColorVar('primary');
235
- * // → "var(--uui-color-primary)", "var(--uui-color-on-primary)"
236
- * ```
237
86
  * @category Color
238
87
  */
239
- export declare const getSemanticColorVar: (color: SemanticColor) => {
240
- color: string;
241
- onColor: string;
242
- container: string;
243
- onContainer: string;
244
- fixed: string;
245
- fixedDim: string;
246
- onFixed: string;
247
- onFixedVariant: string;
248
- };
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[];
249
103
  /**
250
104
  * Returns basic CSS variable references for a **surface color**.
251
105
  *
@@ -264,7 +118,7 @@ export declare const getSemanticColorVar: (color: SemanticColor) => {
264
118
  * ```
265
119
  * @category Color
266
120
  */
267
- export declare const getSurfaceColorVar: (color: SurfaceColor) => {
121
+ export declare const getSurfaceColorVar: (color: BaseColor) => {
268
122
  color: string;
269
123
  onColor: string;
270
124
  };
@@ -312,14 +166,5 @@ export declare const hexToRgb: (colorValue: string) => string;
312
166
  * @category Color
313
167
  */
314
168
  export declare function getTintOverlayColor(elevation: number, tintColor: string): string;
315
- /**
316
- * Returns a set of predefined utility class names for fixed theme colors.
317
- *
318
- * Each entry maps text, border, outline, and background variants like:
319
- * `textSurface`, `bgOnSurface`, `borderOutlineVariant`, etc.
320
- *
321
- * @returns Object with fixed color class mappings.
322
- */
323
- export declare const getFixedColorClasses: () => Record<string, string>;
324
169
  export declare function capitalize(s: string): string;
325
170
  export declare function getBorderColor(borderColor?: BorderColor): BorderColor;
@@ -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;
@@ -0,0 +1,53 @@
1
+ import { CSSProperties } from 'react';
2
+ /**
3
+ * Props for wrapper-level behavior.
4
+ *
5
+ * Applies outer layout such as margin, positioning and stacking.
6
+ * Does not affect internal layout or content.
7
+ *
8
+ * @category Utils
9
+ */
10
+ export type WrapperProps = {
11
+ /** Margin on all sides. */
12
+ m?: number | string;
13
+ /** Horizontal margin (left + right). */
14
+ mx?: number | string;
15
+ /** Vertical margin (top + bottom). */
16
+ my?: number | string;
17
+ /** Margin top. */
18
+ mt?: number | string;
19
+ /** Margin bottom. */
20
+ mb?: number | string;
21
+ /** Margin left. */
22
+ ml?: number | string;
23
+ /** Margin right. */
24
+ mr?: number | string;
25
+ /** Top offset. */
26
+ top?: number | string;
27
+ /** Right offset. */
28
+ right?: number | string;
29
+ /** Bottom offset. */
30
+ bottom?: number | string;
31
+ /** Left offset. */
32
+ left?: number | string;
33
+ /** Stacking order. */
34
+ zIndex?: number;
35
+ /** CSS position value. */
36
+ position?: CSSProperties['position'];
37
+ };
38
+ /**
39
+ * Resolves wrapper props into style and remaining props.
40
+ *
41
+ * Margin shorthands priority:
42
+ * mt/ml/... overrides mx/my, which overrides m.
43
+ *
44
+ * @function
45
+ * @param props Wrapper configuration.
46
+ * @returns Object containing wrapperStyle and otherProps.
47
+ *
48
+ * @category Utils
49
+ */
50
+ export declare function getWrapperStyle(props: WrapperProps): {
51
+ wrapperStyle: CSSProperties;
52
+ otherProps: {};
53
+ };
package/utils/index.d.ts CHANGED
@@ -3,7 +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
+ export * from './getWrapperStyle';
11
+ export * from './flatChildren';
12
+ export * from './renderPortal';
13
+ export * from './colorRegistry';
@@ -0,0 +1,30 @@
1
+ import { ReactNode, ReactPortal } from 'react';
2
+ /**
3
+ * Returns the portal host element `#id`, creating it when missing.
4
+ *
5
+ * @remarks
6
+ * If the element is missing, a `div` with the given `id` is appended to `document.body`.
7
+ * The portal mounts **into** that host — `document.body` itself is never used as the
8
+ * direct portal container.
9
+ *
10
+ * @param rootId - `id` of the root node (e.g. `'dialog-root'`).
11
+ *
12
+ * @returns The host element, or `null` when `document` is unavailable (e.g. SSR).
13
+ *
14
+ * @category Utils
15
+ */
16
+ export declare function ensurePortalRoot(rootId: string): HTMLElement | null;
17
+ /**
18
+ * Renders children into a dedicated portal root, creating that node when absent.
19
+ *
20
+ * @remarks
21
+ * Uses {@link ensurePortalRoot}; returns `null` when the document is not available.
22
+ *
23
+ * @param rootId - `id` of the portal host (e.g. `'dialog-root'`).
24
+ * @param children - Tree to render into the host.
25
+ *
26
+ * @returns A {@link https://react.dev/reference/react-dom/createPortal | React portal}, or `null`.
27
+ *
28
+ * @category Utils
29
+ */
30
+ export declare function renderPortal(rootId: string, children: ReactNode): ReactPortal | null;
@@ -1,2 +1,7 @@
1
- export declare const TOAST_VIEWPORT_ID = "uui-toast-viewport-root";
1
+ /**
2
+ * Ensures that a global toast viewport exists.
3
+ *
4
+ * If the user already rendered ToastViewport manually,
5
+ * no additional viewport is created.
6
+ */
2
7
  export declare function ensureViewport(): void;