@ufoui/core 0.0.12 → 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/assets/icons.d.ts +5 -2
- package/components/accordion/accordion.d.ts +2 -2
- package/components/avatar/avatar.d.ts +2 -2
- package/components/badge/badge.d.ts +2 -2
- package/components/base/boxBase.d.ts +4 -4
- package/components/base/buttonBase.d.ts +5 -5
- package/components/base/checkboxBase.d.ts +2 -2
- package/components/base/dialogBase.d.ts +105 -9
- package/components/base/fieldBase.d.ts +1 -1
- package/components/card/card.d.ts +78 -13
- 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/index.d.ts +1 -0
- package/components/link/link.d.ts +13 -14
- package/components/menu/menu.d.ts +2 -2
- package/components/rating/rating.d.ts +2 -2
- package/components/switch/switch.d.ts +2 -2
- package/components/themeProvider/themeProvider.d.ts +20 -15
- package/components/toolbar/toolbar.d.ts +1 -1
- package/components/tooltip/tooltip.d.ts +2 -2
- 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 +3186 -3023
- package/internal/icon/icon.d.ts +28 -0
- package/internal/index.d.ts +1 -0
- package/internal/inlineTooltip/inlineTooltipManager.d.ts +3 -3
- package/internal/slots/slot.d.ts +1 -1
- package/package.json +1 -1
- package/types/breakpoints.d.ts +38 -0
- package/types/color.d.ts +299 -0
- package/types/dialog.d.ts +37 -0
- package/types/fonts.d.ts +53 -0
- package/types/index.d.ts +4 -0
- package/types/motion.d.ts +2 -2
- package/types/theme.d.ts +8 -235
- package/utils/applyThemeColors.d.ts +10 -0
- 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/calculateFloatingPosition.d.ts +3 -3
- package/utils/color.d.ts +14 -153
- package/utils/colorRegistry.d.ts +37 -0
- package/utils/controlStyle.d.ts +8 -8
- package/utils/createRipple.d.ts +17 -0
- package/utils/flatChildren.d.ts +17 -0
- package/utils/fontRegistry.d.ts +29 -0
- package/utils/generateMaterialColors.d.ts +9 -12
- package/utils/index.d.ts +9 -1
- package/utils/mergeOverrides.d.ts +13 -0
- package/utils/renderPortal.d.ts +30 -0
- package/utils/utils.d.ts +3 -25
- package/utils/generateSchemes.d.ts +0 -32
|
@@ -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,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[];
|
|
@@ -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 ExtraColorOverrides = Partial<Record<'info' | 'warning' | 'success', 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 ExtraColorOverrides = Partial<Record<'info' | 'warning' | 'success',
|
|
|
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
|
|
16
|
-
*
|
|
17
|
-
* @param extraColors - Optional custom base colors for `info`, `warning`, and `success`.
|
|
18
|
-
* These will override the default values (`#03a9f4`, `#ffd600`, `#689f38`).
|
|
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.
|
|
18
|
+
* Also updates the global color registry via `setColorRegistry()`.
|
|
21
19
|
*
|
|
22
20
|
* @example
|
|
23
21
|
* ```ts
|
|
24
|
-
* const schemes = generateMaterialColors('#6200ee', { info: '#2196f3' }
|
|
22
|
+
* const schemes = generateMaterialColors('#6200ee', { info: '#2196f3' });
|
|
25
23
|
* const primary = schemes.light.primary;
|
|
26
|
-
* const infoContainer = schemes.dark.infoContainer;
|
|
27
24
|
* ```
|
|
28
25
|
*
|
|
29
26
|
* @category Theme
|
|
30
27
|
*/
|
|
31
|
-
export declare function generateMaterialColors(seedColor?: string,
|
|
28
|
+
export declare function generateMaterialColors(seedColor?: string, colors?: ThemeCustomColors): ThemeColorSchemes;
|
package/utils/index.d.ts
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
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';
|
|
10
13
|
export * from './getWrapperStyle';
|
|
14
|
+
export * from './flatChildren';
|
|
15
|
+
export * from './renderPortal';
|
|
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
|
+
};
|
|
@@ -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;
|
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';
|
|
@@ -74,14 +75,13 @@ export type ElementElevation = 0 | 1 | 2 | 3 | 4 | 5;
|
|
|
74
75
|
*
|
|
75
76
|
* @category Utils
|
|
76
77
|
*/
|
|
77
|
-
export type
|
|
78
|
+
export type ElementPlacement = 'topLeft' | 'topCenter' | 'topRight' | 'centerLeft' | 'center' | 'centerRight' | 'bottomLeft' | 'bottomCenter' | 'bottomRight' | 'topRightOut' | 'topLeftOut' | 'auto';
|
|
78
79
|
export type ElementDensity = 'comfortable' | 'compact' | 'dense';
|
|
79
80
|
export type ElementFocusEffect = 'ring' | 'overlay';
|
|
80
81
|
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.
|
|
@@ -112,7 +112,7 @@ export declare function toKebabCase(str: string): string;
|
|
|
112
112
|
* @category Utils
|
|
113
113
|
*/
|
|
114
114
|
export declare function clampInt(min: number, max: number, value: unknown, fallback?: number): number | undefined;
|
|
115
|
-
export declare const
|
|
115
|
+
export declare const getPlacementClass: (position: ElementPlacement) => string;
|
|
116
116
|
/**
|
|
117
117
|
* Returns the appropriate CSS class for the given shape token.
|
|
118
118
|
*
|
|
@@ -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
|
*
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { ExtraColorOverrides } from './generateMaterialColors';
|
|
2
|
-
import { PartialThemeSchemes, ThemeSchemes } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Generates and injects CSS custom properties for Material Design 3 theme colors.
|
|
5
|
-
*
|
|
6
|
-
* This function calls `generateMaterialColors()` to resolve a complete light/dark
|
|
7
|
-
* `ThemeSchemes` object based on a seed color, optional extra semantic colors
|
|
8
|
-
* (`info`, `warning`, `success`), and optional overrides for individual color tokens.
|
|
9
|
-
*
|
|
10
|
-
* All resolved tokens are converted to CSS variables using kebab-case, e.g.:
|
|
11
|
-
* `--uui-color-primary`, `--uui-color-on-surface`, etc.
|
|
12
|
-
*
|
|
13
|
-
* Light mode tokens are injected into `:root`, dark mode tokens into `.dark`.
|
|
14
|
-
* Variables are injected once into a single `<style>` tag with ID `ufo-ui-theme`.
|
|
15
|
-
*
|
|
16
|
-
* @param seedColor - The base seed color used to generate MD3 tonal palettes.
|
|
17
|
-
* Defaults to `#6750A4` if not provided.
|
|
18
|
-
* @param extraColors - Optional map of base semantic colors for `info`, `warning`, and `success`.
|
|
19
|
-
* These override the default values.
|
|
20
|
-
* @param schemes - Optional overrides for light and dark color tokens.
|
|
21
|
-
* Partial values will be merged with the generated ones.
|
|
22
|
-
*
|
|
23
|
-
* @returns A fully resolved `ThemeSchemes` object containing all tokens for light and dark modes.
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```ts
|
|
27
|
-
* const schemes = generateSchemes('#6200ee', { info: '#0288d1' }, { light: { primary: '#ff5722' } });
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* @category Theme
|
|
31
|
-
*/
|
|
32
|
-
export declare function generateSchemes(seedColor?: string, extraColors?: ExtraColorOverrides, schemes?: PartialThemeSchemes): ThemeSchemes;
|