@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.
- package/assets/icons.d.ts +8 -2
- package/components/accordion/accordion.d.ts +31 -3
- package/components/accordion/accordionItem.d.ts +31 -3
- package/components/badge/badge.d.ts +2 -2
- package/components/base/boxBase.d.ts +14 -36
- package/components/base/buttonBase.d.ts +4 -4
- package/components/base/checkboxBase.d.ts +2 -2
- package/components/base/dialogBase.d.ts +111 -13
- package/components/base/fieldBase.d.ts +1 -2
- package/components/base/textBase.d.ts +1 -2
- package/components/breadcrumbs/breadcrumbs.d.ts +48 -0
- package/components/calendar/calendar.d.ts +23 -0
- package/components/calendar/calendarUtils.d.ts +18 -0
- package/components/card/card.d.ts +2 -2
- package/components/collapse/collapse.d.ts +15 -20
- package/components/dialogs/dialog.d.ts +1 -1
- package/components/dialogs/dialogActions.d.ts +19 -7
- package/components/dialogs/dialogActions.guards.d.ts +15 -0
- package/components/dialogs/dialogContent.d.ts +7 -1
- package/components/dialogs/dialogHeader.d.ts +60 -0
- package/components/dialogs/dialogTitle.d.ts +9 -5
- package/components/dialogs/drawer.d.ts +1 -1
- package/components/dialogs/index.d.ts +1 -0
- package/components/fieldset/fieldset.d.ts +1 -1
- package/components/link/link.d.ts +58 -0
- package/components/list/list.d.ts +1 -1
- package/components/menu/menu.d.ts +2 -2
- package/components/rating/rating.d.ts +68 -0
- package/components/slider/slider.d.ts +11 -0
- package/components/switch/switch.d.ts +2 -10
- package/components/themeProvider/themeProvider.d.ts +10 -15
- package/components/toast/toast.d.ts +18 -4
- package/components/toast/toastViewport.d.ts +4 -3
- package/components/tooltip/tooltip.d.ts +2 -2
- package/context/selectionContext.d.ts +18 -17
- package/hooks/index.d.ts +3 -1
- package/hooks/useAnimate.d.ts +36 -16
- package/hooks/useFocusTrap.d.ts +32 -0
- package/hooks/useFocusVisible.d.ts +16 -14
- package/hooks/useResizeObserver.d.ts +7 -3
- package/hooks/useRovingFocus.d.ts +30 -0
- package/hooks/useSelection.d.ts +10 -7
- package/hooks/useSelectionState.d.ts +29 -0
- package/hooks/useSliderKeys.d.ts +41 -0
- package/index.css +1 -1
- package/index.d.ts +4 -8
- package/index.js +4782 -0
- package/internal/controlGrid/controlGrid.d.ts +32 -0
- package/internal/controlLabel/controlLabel.d.ts +31 -0
- package/internal/description/description.d.ts +18 -0
- package/internal/icon/icon.d.ts +28 -0
- package/internal/index.d.ts +7 -0
- package/internal/inlineTooltip/index.d.ts +1 -0
- package/internal/inlineTooltip/inlineTooltipManager.d.ts +3 -3
- package/internal/slots/slot.d.ts +44 -0
- package/internal/stateLayer/stateLayer.d.ts +33 -0
- package/package.json +12 -3
- package/types/dialog.d.ts +37 -0
- package/types/index.d.ts +1 -0
- package/types/motion.d.ts +2 -2
- package/types/theme.d.ts +0 -30
- package/utils/applyThemeTokens.d.ts +10 -0
- package/utils/calculateFloatingPosition.d.ts +3 -3
- package/utils/color.d.ts +61 -216
- package/utils/colorRegistry.d.ts +44 -0
- package/utils/controlStyle.d.ts +8 -8
- package/utils/flatChildren.d.ts +17 -0
- package/utils/generateMaterialColors.d.ts +7 -7
- package/utils/getWrapperStyle.d.ts +53 -0
- package/utils/index.d.ts +5 -1
- package/utils/renderPortal.d.ts +30 -0
- package/utils/toasts/ensureViewport.d.ts +6 -1
- package/utils/toasts/toast.d.ts +66 -10
- package/utils/toasts/toastStore.d.ts +55 -1
- package/utils/utils.d.ts +67 -55
- package/hooks/useFocusState.d.ts +0 -16
- package/index.mjs +0 -4649
- package/internal/inlineTooltip/inlineTooltip.d.ts +0 -11
- package/internal/inlineTooltip/inlineTooltip2.d.ts +0 -10
- 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
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Built-in semantic color names available in every theme.
|
|
3
|
+
*
|
|
5
4
|
* @category Color
|
|
6
5
|
*/
|
|
7
|
-
export type
|
|
6
|
+
export type CoreSemanticColor = 'primary' | 'secondary' | 'tertiary' | 'warning' | 'info' | 'success' | 'error';
|
|
8
7
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
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
|
|
12
|
+
export type CoreSurfaceColor = 'surface' | 'surfaceVariant' | 'background' | 'inverseSurface' | 'outline' | 'outlineVariant' | 'surfaceContainerLowest' | 'surfaceContainerLow' | 'surfaceContainer' | 'surfaceContainerHigh' | 'surfaceContainerHighest' | 'surfaceBright' | 'surfaceDim';
|
|
15
13
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
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
|
|
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
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
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
|
|
33
|
+
export interface CustomColors {
|
|
34
|
+
}
|
|
29
35
|
/**
|
|
30
|
-
*
|
|
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
|
|
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
|
-
*
|
|
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
|
|
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
|
-
*
|
|
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
|
|
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
|
-
*
|
|
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
|
|
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
|
-
*
|
|
60
|
+
* `on*` counterparts for extended colors.
|
|
202
61
|
*
|
|
203
62
|
* @category Color
|
|
204
63
|
*/
|
|
205
|
-
export type
|
|
64
|
+
export type OnExtendedColor = OnColor<`${SemanticBaseColor}Container`> | OnColor<`${SemanticBaseColor}Fixed`> | OnColor<`${SemanticBaseColor}FixedVariant`>;
|
|
206
65
|
/**
|
|
207
|
-
*
|
|
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
|
|
70
|
+
export type SurfaceColor = CoreSurfaceColor | ExtendedColor;
|
|
221
71
|
/**
|
|
222
|
-
*
|
|
72
|
+
* Colors allowed in component props.
|
|
223
73
|
*
|
|
224
|
-
* @
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
74
|
+
* @category Color
|
|
75
|
+
*/
|
|
76
|
+
export type BaseColor = SemanticColor | SurfaceColor;
|
|
77
|
+
/**
|
|
78
|
+
* Full theme color set.
|
|
228
79
|
*
|
|
229
|
-
* @
|
|
230
|
-
|
|
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
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
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:
|
|
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
|
+
*/
|
package/utils/controlStyle.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import {
|
|
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?:
|
|
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?:
|
|
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?:
|
|
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?:
|
|
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?:
|
|
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?:
|
|
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?:
|
|
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
|
|
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
|
|
16
|
-
*
|
|
17
|
-
* @param
|
|
18
|
-
*
|
|
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,
|
|
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 './
|
|
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
|
-
|
|
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;
|