@ufoui/core 0.0.40 → 0.0.58
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/components/avatar/avatar.d.ts +2 -2
- package/components/badge/badge.d.ts +1 -1
- package/components/card/card.d.ts +78 -13
- package/components/link/link.d.ts +13 -14
- package/components/themeProvider/themeProvider.d.ts +14 -4
- package/hooks/index.d.ts +1 -0
- package/hooks/useResponsive.d.ts +60 -0
- package/hooks/useTheme.d.ts +1 -1
- package/index.css +1 -1
- package/index.js +2860 -2598
- package/package.json +1 -1
- package/types/breakpoints.d.ts +38 -0
- package/types/color.d.ts +299 -0
- package/types/fonts.d.ts +53 -0
- package/types/index.d.ts +3 -0
- package/types/theme.d.ts +8 -205
- package/utils/{applyThemeTokens.d.ts → applyThemeColors.d.ts} +2 -2
- package/utils/breakpoints/breakpoint.d.ts +59 -0
- package/utils/breakpoints/breakpointStore.d.ts +32 -0
- package/utils/breakpoints/index.d.ts +2 -0
- package/utils/color.d.ts +2 -88
- package/utils/colorRegistry.d.ts +0 -7
- package/utils/createRipple.d.ts +17 -0
- package/utils/fontRegistry.d.ts +29 -0
- package/utils/generateMaterialColors.d.ts +8 -11
- package/utils/index.d.ts +6 -1
- package/utils/mergeOverrides.d.ts +13 -0
- package/utils/utils.d.ts +1 -23
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ThemeBreakpoints } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Viewport snapshot used by the breakpoint store.
|
|
4
|
+
*
|
|
5
|
+
* @category Breakpoints
|
|
6
|
+
*/
|
|
7
|
+
export type ViewportSnapshot = {
|
|
8
|
+
width: number;
|
|
9
|
+
isPrint: boolean;
|
|
10
|
+
};
|
|
11
|
+
type BreakpointEntry = {
|
|
12
|
+
key: string;
|
|
13
|
+
minWidth: number;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Converts a CSS length value to pixels.
|
|
17
|
+
*
|
|
18
|
+
* Supports `px`, `rem`, and unitless numeric strings.
|
|
19
|
+
*
|
|
20
|
+
* @function
|
|
21
|
+
* @param value CSS length value to convert.
|
|
22
|
+
*
|
|
23
|
+
* @category Breakpoints
|
|
24
|
+
*/
|
|
25
|
+
export declare const toPx: (value: string) => number;
|
|
26
|
+
/**
|
|
27
|
+
* Returns the ordered list of theme breakpoints sorted by width.
|
|
28
|
+
*
|
|
29
|
+
* @function
|
|
30
|
+
* @param breakpoints Breakpoint map from the active theme.
|
|
31
|
+
*
|
|
32
|
+
* @category Breakpoints
|
|
33
|
+
*/
|
|
34
|
+
export declare const getOrderedBreakpoints: (breakpoints: ThemeBreakpoints) => BreakpointEntry[];
|
|
35
|
+
/**
|
|
36
|
+
* Resolves the active breakpoint key for a viewport width.
|
|
37
|
+
*
|
|
38
|
+
* @function
|
|
39
|
+
* @param breakpoints Ordered breakpoint entries.
|
|
40
|
+
* @param width Current viewport width.
|
|
41
|
+
*
|
|
42
|
+
* @category Breakpoints
|
|
43
|
+
*/
|
|
44
|
+
export declare const resolveBreakpoint: (breakpoints: BreakpointEntry[], width: number) => string;
|
|
45
|
+
/**
|
|
46
|
+
* Resolves a responsive value map against the current viewport state.
|
|
47
|
+
*
|
|
48
|
+
* @function
|
|
49
|
+
* @param values Responsive values keyed by breakpoint.
|
|
50
|
+
* @param breakpoints Ordered breakpoint entries.
|
|
51
|
+
* @param snapshot Current viewport snapshot.
|
|
52
|
+
*
|
|
53
|
+
* @category Breakpoints
|
|
54
|
+
*/
|
|
55
|
+
export declare const resolveResponsiveValue: <T>(values: {
|
|
56
|
+
base?: T;
|
|
57
|
+
print?: T;
|
|
58
|
+
} & Record<string, T | undefined>, breakpoints: BreakpointEntry[], snapshot: ViewportSnapshot) => T | undefined;
|
|
59
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ViewportSnapshot } from './breakpoint';
|
|
2
|
+
/**
|
|
3
|
+
* Subscriber function used by the breakpoint store.
|
|
4
|
+
*
|
|
5
|
+
* @category Hooks
|
|
6
|
+
*/
|
|
7
|
+
export type BreakpointStoreSubscriber = () => void;
|
|
8
|
+
/**
|
|
9
|
+
* Shared viewport store used by responsive hooks.
|
|
10
|
+
*
|
|
11
|
+
* @category Hooks
|
|
12
|
+
*/
|
|
13
|
+
export declare const breakpointStore: {
|
|
14
|
+
/**
|
|
15
|
+
* Subscribes to viewport state updates.
|
|
16
|
+
*
|
|
17
|
+
* @function
|
|
18
|
+
*/
|
|
19
|
+
subscribe(listener: BreakpointStoreSubscriber): () => void;
|
|
20
|
+
/**
|
|
21
|
+
* Returns the current viewport snapshot.
|
|
22
|
+
*
|
|
23
|
+
* @function
|
|
24
|
+
*/
|
|
25
|
+
getSnapshot(): ViewportSnapshot;
|
|
26
|
+
/**
|
|
27
|
+
* Returns the server-side fallback snapshot.
|
|
28
|
+
*
|
|
29
|
+
* @function
|
|
30
|
+
*/
|
|
31
|
+
getServerSnapshot(): ViewportSnapshot;
|
|
32
|
+
};
|
package/utils/color.d.ts
CHANGED
|
@@ -1,91 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* @category Color
|
|
5
|
-
*/
|
|
6
|
-
export type CoreSemanticColor = 'primary' | 'secondary' | 'tertiary' | 'warning' | 'info' | 'success' | 'error';
|
|
7
|
-
/**
|
|
8
|
-
* Built-in surface color names intended for backgrounds, layers, and outlines.
|
|
9
|
-
*
|
|
10
|
-
* @category Color
|
|
11
|
-
*/
|
|
12
|
-
export type CoreSurfaceColor = 'surface' | 'surfaceVariant' | 'background' | 'inverseSurface' | 'outline' | 'outlineVariant' | 'surfaceContainerLowest' | 'surfaceContainerLow' | 'surfaceContainer' | 'surfaceContainerHigh' | 'surfaceContainerHighest' | 'surfaceBright' | 'surfaceDim';
|
|
13
|
-
/**
|
|
14
|
-
* Built-in technical color names not intended for direct usage.
|
|
15
|
-
*
|
|
16
|
-
* @category Color
|
|
17
|
-
*/
|
|
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>;
|
|
21
|
-
/**
|
|
22
|
-
* Augmentation point for custom semantic colors.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* declare module '@ufoui/core' {
|
|
26
|
-
* interface CustomColors {
|
|
27
|
-
* myBlue: true;
|
|
28
|
-
* }
|
|
29
|
-
* }
|
|
30
|
-
*
|
|
31
|
-
* @category Color
|
|
32
|
-
*/
|
|
33
|
-
export interface CustomColors {
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Base semantic color (core + augmented).
|
|
37
|
-
*
|
|
38
|
-
* @category Color
|
|
39
|
-
*/
|
|
40
|
-
export type SemanticBaseColor = CoreSemanticColor | keyof CustomColors;
|
|
41
|
-
/**
|
|
42
|
-
* Builds `on*` color name.
|
|
43
|
-
*
|
|
44
|
-
* @category Color
|
|
45
|
-
*/
|
|
46
|
-
export type OnColor<T extends string> = `on${Capitalize<T>}`;
|
|
47
|
-
/**
|
|
48
|
-
* Semantic color used in component APIs.
|
|
49
|
-
*
|
|
50
|
-
* @category Color
|
|
51
|
-
*/
|
|
52
|
-
export type SemanticColor = SemanticBaseColor;
|
|
53
|
-
/**
|
|
54
|
-
* Extended semantic colors.
|
|
55
|
-
*
|
|
56
|
-
* @category Color
|
|
57
|
-
*/
|
|
58
|
-
export type ExtendedColor = `${SemanticBaseColor}Container` | `${SemanticBaseColor}Fixed` | `${SemanticBaseColor}FixedDim`;
|
|
59
|
-
/**
|
|
60
|
-
* `on*` counterparts for extended colors.
|
|
61
|
-
*
|
|
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;
|
|
71
|
-
/**
|
|
72
|
-
* Colors allowed in component props.
|
|
73
|
-
*
|
|
74
|
-
* @category Color
|
|
75
|
-
*/
|
|
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;
|
|
1
|
+
import { BaseColor, BorderColor, ExtendedColor, SemanticColor, SurfaceColor, ThemeColor } from '../types';
|
|
2
|
+
export type { CoreSemanticColor, CoreSurfaceColor, CoreThemeColor, CustomColors, SemanticBaseColor, OnColor, SemanticColor, ExtendedColor, OnExtendedColor, SurfaceColor, BaseColor, ThemeColor, BorderColor, } from '../types';
|
|
89
3
|
export declare function getOnColorName(colorName: ThemeColor): ThemeColor | undefined;
|
|
90
4
|
/**
|
|
91
5
|
* Returns all color names from the global registry for the selected type.
|
package/utils/colorRegistry.d.ts
CHANGED
|
@@ -35,10 +35,3 @@ export declare function setColorRegistry(registry: ColorRegistry): void;
|
|
|
35
35
|
* @category Theme
|
|
36
36
|
*/
|
|
37
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
|
-
*/
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a material-style ripple effect inside the given element.
|
|
4
|
+
*
|
|
5
|
+
* @param el - Target element that receives the ripple.
|
|
6
|
+
* @param event - Mouse event used to determine the ripple origin.
|
|
7
|
+
* @param host - Optional host element that receives the ripple container instead of `el`.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* - Automatically clears previous ripples.
|
|
11
|
+
* - Injects a `.ripple-container` and `.ripple` element.
|
|
12
|
+
* - Uses the element's client size and border radius.
|
|
13
|
+
* - Safe for buttons, icon buttons, list items, etc.
|
|
14
|
+
*
|
|
15
|
+
* @category Utils
|
|
16
|
+
*/
|
|
17
|
+
export declare const createRipple: (el: HTMLElement, event: React.MouseEvent<HTMLElement>, host?: HTMLElement) => void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ElementFont, PartialThemeFonts, ThemeFont } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Built-in font names available in the default font registry.
|
|
4
|
+
*
|
|
5
|
+
* @category Theme
|
|
6
|
+
*/
|
|
7
|
+
export declare const coreFonts: readonly ["displayLarge", "displayMedium", "displaySmall", "headlineLarge", "headlineMedium", "headlineSmall", "titleLarge", "titleMedium", "titleSmall", "labelLarge", "labelMedium", "labelSmall", "bodyLarge", "bodyMedium", "bodySmall", "caption", "overline"];
|
|
8
|
+
/**
|
|
9
|
+
* Replaces the runtime font registry with core fonts plus provided overrides.
|
|
10
|
+
*
|
|
11
|
+
* @param fonts - Optional font class overrides keyed by font name.
|
|
12
|
+
* @category Theme
|
|
13
|
+
*/
|
|
14
|
+
export declare const setFontRegistry: (fonts?: PartialThemeFonts) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Returns all font names currently registered at runtime.
|
|
17
|
+
*
|
|
18
|
+
* @returns List of registered font names.
|
|
19
|
+
* @category Theme
|
|
20
|
+
*/
|
|
21
|
+
export declare const getFontNames: () => ThemeFont[];
|
|
22
|
+
/**
|
|
23
|
+
* Returns the CSS class registered for the given font name.
|
|
24
|
+
*
|
|
25
|
+
* @param font - Font name key.
|
|
26
|
+
* @returns Registered CSS class or empty string when key is not registered.
|
|
27
|
+
* @category Theme
|
|
28
|
+
*/
|
|
29
|
+
export declare const getFontClass: (font: ElementFont) => string;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export type UserColors = Record<string, string>;
|
|
1
|
+
import { ThemeColorSchemes, ThemeCustomColors } from '../types';
|
|
3
2
|
/**
|
|
4
|
-
* Generates a full
|
|
5
|
-
*
|
|
3
|
+
* Generates a full ThemeColorSchemes object (light and dark modes) based on a seed color,
|
|
4
|
+
* and optional semantic seed colors.
|
|
6
5
|
*
|
|
7
6
|
* Internally uses the Material Design 3 `themeFromSourceColor()` generator and applies
|
|
8
7
|
* full resolution of all MD3 roles as defined in ThemeSchemeKeys.
|
|
@@ -12,20 +11,18 @@ export type UserColors = Record<string, string>;
|
|
|
12
11
|
*
|
|
13
12
|
* @param seedColor - Optional seed color in hex (e.g. "#6200ee"). Used as the base for the primary palette.
|
|
14
13
|
* Defaults to `#6750A4` if not provided.
|
|
15
|
-
* @param colors - Optional map of
|
|
16
|
-
*
|
|
17
|
-
* @param customSchemes - Optional skin overrides for schemes (e.g. light/dark/high-contrast).
|
|
18
|
-
* Applied as the final merge step.
|
|
14
|
+
* @param colors - Optional map of semantic base colors (core + augmented).
|
|
15
|
+
* Defaults include `info`, `warning`, and `success`.
|
|
19
16
|
*
|
|
20
|
-
* @returns A fully resolved
|
|
17
|
+
* @returns A fully resolved ThemeColorSchemes object with all required color roles populated for light and dark modes.
|
|
21
18
|
* Also updates the global color registry via `setColorRegistry()`.
|
|
22
19
|
*
|
|
23
20
|
* @example
|
|
24
21
|
* ```ts
|
|
25
|
-
* const schemes = generateMaterialColors('#6200ee', { info: '#2196f3' }
|
|
22
|
+
* const schemes = generateMaterialColors('#6200ee', { info: '#2196f3' });
|
|
26
23
|
* const primary = schemes.light.primary;
|
|
27
24
|
* ```
|
|
28
25
|
*
|
|
29
26
|
* @category Theme
|
|
30
27
|
*/
|
|
31
|
-
export declare function generateMaterialColors(seedColor?: string, colors?:
|
|
28
|
+
export declare function generateMaterialColors(seedColor?: string, colors?: ThemeCustomColors): ThemeColorSchemes;
|
package/utils/index.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
export * from './color';
|
|
2
|
+
export { getFontNames, getFontClass, setFontRegistry } from './fontRegistry';
|
|
3
|
+
export type { ElementFont } from '../types/fonts';
|
|
2
4
|
export * from './utils';
|
|
3
5
|
export * from './calculateFloatingPosition';
|
|
4
6
|
export * from './interactionMode';
|
|
5
7
|
export * from './generateMaterialColors';
|
|
6
|
-
export * from './
|
|
8
|
+
export * from './applyThemeColors';
|
|
9
|
+
export * from './breakpoints';
|
|
7
10
|
export * from './toasts';
|
|
8
11
|
export * from './uniqueID';
|
|
9
12
|
export * from './controlStyle';
|
|
@@ -11,3 +14,5 @@ export * from './getWrapperStyle';
|
|
|
11
14
|
export * from './flatChildren';
|
|
12
15
|
export * from './renderPortal';
|
|
13
16
|
export * from './colorRegistry';
|
|
17
|
+
export * from './mergeOverrides';
|
|
18
|
+
export { createRipple } from './createRipple';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Merges override values into a base string map, skipping `undefined` entries.
|
|
3
|
+
*
|
|
4
|
+
* @typeParam TBase - Base map type to preserve in the merged result.
|
|
5
|
+
* @param base - Base key/value map.
|
|
6
|
+
* @param overrides - Optional override map where `undefined` means "no change".
|
|
7
|
+
* @returns Object with merged map and list of keys that were actually applied.
|
|
8
|
+
* @category Theme
|
|
9
|
+
*/
|
|
10
|
+
export declare function mergeOverrides<TBase extends Record<string, string>>(base: TBase, overrides?: Record<string, string | undefined>): {
|
|
11
|
+
merged: TBase;
|
|
12
|
+
appliedKeys: string[];
|
|
13
|
+
};
|
package/utils/utils.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
1
2
|
export type ElementSize = 'extraSmall' | 'small' | 'medium' | 'large' | 'extraLarge';
|
|
2
3
|
export type ElementInset = 'none' | 'left' | 'right' | 'top' | 'bottom' | 'middle';
|
|
3
4
|
export type ElementShape = 'square' | 'smooth' | 'rounded' | 'round';
|
|
@@ -81,7 +82,6 @@ export type ElementPressedEffect = 'elevate' | 'overlay' | 'scale';
|
|
|
81
82
|
export type ElementHoverEffect = 'elevate' | 'overlay' | 'color';
|
|
82
83
|
export type ElementSelectedEffect = 'color' | 'morph' | 'border' | 'overlay';
|
|
83
84
|
export type ElementTouchEffect = 'ripple';
|
|
84
|
-
export type ElementFont = 'displayLarge' | 'displayMedium' | 'displaySmall' | 'headlineLarge' | 'headlineMedium' | 'headlineSmall' | 'titleLarge' | 'titleMedium' | 'titleSmall' | 'labelLarge' | 'labelMedium' | 'labelSmall' | 'bodyLarge' | 'bodyMedium' | 'bodySmall' | 'caption' | 'overline';
|
|
85
85
|
export type ElementTextPlacement = 'start' | 'end' | 'top' | 'bottom';
|
|
86
86
|
/**
|
|
87
87
|
* Converts a camelCase, PascalCase, or acronym-based string into kebab-case.
|
|
@@ -148,13 +148,6 @@ export declare const getElevationClass: (elevation?: ElementElevation) => string
|
|
|
148
148
|
* @returns CSS class for density variant.
|
|
149
149
|
*/
|
|
150
150
|
export declare const getDensityClass: (density?: ElementDensity) => string;
|
|
151
|
-
/**
|
|
152
|
-
* Returns the CSS class for the given typography token.
|
|
153
|
-
*
|
|
154
|
-
* @param font Typography token.
|
|
155
|
-
* @returns CSS class in the form uui-font-<token>.
|
|
156
|
-
*/
|
|
157
|
-
export declare const getFontClass: (font: ElementFont) => string;
|
|
158
151
|
/**
|
|
159
152
|
* Merges multiple React refs into a single ref callback.
|
|
160
153
|
*
|
|
@@ -174,21 +167,6 @@ export declare const getFontClass: (font: ElementFont) => string;
|
|
|
174
167
|
* @category Utils
|
|
175
168
|
*/
|
|
176
169
|
export declare function mergeRefs<T>(...refs: React.Ref<T>[]): React.RefCallback<T>;
|
|
177
|
-
/**
|
|
178
|
-
* Creates a material-style ripple effect inside the given element.
|
|
179
|
-
*
|
|
180
|
-
* @param el - Target element that receives the ripple.
|
|
181
|
-
* @param event - Mouse event used to determine the ripple origin.
|
|
182
|
-
*
|
|
183
|
-
* @remarks
|
|
184
|
-
* - Automatically clears previous ripples.
|
|
185
|
-
* - Injects a `.ripple-container` and `.ripple` element.
|
|
186
|
-
* - Uses the element's client size and border radius.
|
|
187
|
-
* - Safe for buttons, icon buttons, list items, etc.
|
|
188
|
-
*
|
|
189
|
-
* @category Utils
|
|
190
|
-
*/
|
|
191
|
-
export declare const createRipple: (el: HTMLElement, event: React.MouseEvent<HTMLElement>, host?: HTMLElement) => void;
|
|
192
170
|
/**
|
|
193
171
|
* Joins class names into a single string.
|
|
194
172
|
*
|