@ufoui/core 0.0.88 → 0.0.124

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ufoui/core",
3
- "version": "0.0.88",
3
+ "version": "0.0.124",
4
4
  "description": "Lightweight Material Design 3 UI components for React",
5
5
  "type": "module",
6
6
  "main": "./index.mjs",
package/types/color.d.ts CHANGED
@@ -258,7 +258,7 @@ export type SemanticColor = SemanticBaseColor;
258
258
  *
259
259
  * @category Color
260
260
  */
261
- export type ExtendedColor = `${SemanticBaseColor}Container` | `${SemanticBaseColor}Fixed` | `${SemanticBaseColor}FixedDim`;
261
+ export type ExtendedColor = `${SemanticBaseColor}Container` | `${SemanticBaseColor}Fixed`;
262
262
  /**
263
263
  * `on*` counterparts for extended colors.
264
264
  *
@@ -282,13 +282,55 @@ export type BaseColor = SemanticColor | SurfaceColor;
282
282
  *
283
283
  * @category Color
284
284
  */
285
- export type BorderColor = BaseColor | CoreBorderColor;
285
+ export type BorderColor = BaseColor | CoreBorderColor | `${SemanticBaseColor}FixedDim`;
286
+ /**
287
+ * Colors allowed for plain text content.
288
+ *
289
+ * @category Color
290
+ */
291
+ export type TextColor = SemanticColor | 'onSurface' | 'onBackground' | 'onSurfaceVariant' | OnColor<`${SemanticBaseColor}Container`>;
286
292
  /**
287
293
  * Full theme color set.
288
294
  *
289
295
  * @category Color
290
296
  */
291
297
  export type ThemeColor = BorderColor | OnColor<SemanticBaseColor> | OnExtendedColor | CoreThemeColor;
298
+ /**
299
+ * Value for a single color role — either a plain hex string or an explicit color/on pair.
300
+ *
301
+ * @category Theme
302
+ */
303
+ export type ColorRoleValue = string | {
304
+ color: string;
305
+ on?: string;
306
+ };
307
+ /**
308
+ * Full configuration for a custom semantic color token.
309
+ *
310
+ * @remarks
311
+ * - **Plain string** — seed hex for standard MD3 tonal generation. All roles are MD3-computed.
312
+ * - **Object** — exact color overrides per mode:
313
+ * - `main.light` / `main.dark` set the primary role token. `dark` defaults to `light` if omitted.
314
+ * - Each value is either a plain hex string or `{ color, on? }`. When `on` is omitted,
315
+ * the counterpart is derived from the overridden color's luminance (HCT tone < 50 → white, ≥ 50 → near-black).
316
+ * - `fixed` controls the `Fixed` / `onFixed` tokens:
317
+ * - omitted: inherited from the resolved `main` values
318
+ * - `'preserve'`: keeps MD3-generated values unchanged
319
+ * - object `{ light, dark? }`: explicit override, same rules as `main`
320
+ * - `Container` roles are always MD3-generated and are not affected by this config.
321
+ *
322
+ * @category Theme
323
+ */
324
+ export type CustomColorConfig = string | {
325
+ main: {
326
+ light: ColorRoleValue;
327
+ dark?: ColorRoleValue;
328
+ };
329
+ fixed?: 'preserve' | {
330
+ light: ColorRoleValue;
331
+ dark?: ColorRoleValue;
332
+ };
333
+ };
292
334
  /**
293
335
  * Input color map used to seed/generate theme schemes.
294
336
  *
@@ -297,4 +339,4 @@ export type ThemeColor = BorderColor | OnColor<SemanticBaseColor> | OnExtendedCo
297
339
  *
298
340
  * @category Theme
299
341
  */
300
- export type ThemeCustomColors = Partial<Record<SemanticBaseColor, string>>;
342
+ export type ThemeCustomColors = Partial<Record<SemanticBaseColor, CustomColorConfig>>;
package/types/motion.d.ts CHANGED
@@ -37,6 +37,30 @@ export declare function getAnimationClass(animation?: MotionAnimation): string;
37
37
  */
38
38
  export declare function getAnimationList(): MotionAnimation[];
39
39
  export type MotionStyle = 'regular' | 'expressive';
40
+ /**
41
+ * Motion configuration.
42
+ *
43
+ * Allows passing either:
44
+ * - animation preset name (`MotionAnimation`)
45
+ * - full config object with animation, duration and style
46
+ */
47
+ export interface MotionConfig {
48
+ /** Motion animation preset. */
49
+ animation: MotionAnimation;
50
+ /** Animation duration in milliseconds. */
51
+ duration?: number;
52
+ /** Motion style variant. */
53
+ style?: MotionStyle;
54
+ /** First-render behaviour: `'animate'` plays the open transition on mount, `'skip'` shows the final state immediately. Defaults to the component's own UX default when omitted. */
55
+ initial?: 'animate' | 'skip';
56
+ }
57
+ /**
58
+ * Motion value.
59
+ *
60
+ * Can be provided as a shorthand animation preset name
61
+ * or as a full {@link MotionConfig} object.
62
+ */
63
+ export type ElementAnimation = MotionAnimation | MotionConfig;
40
64
  /**
41
65
  * Returns CSS class name for motion style.
42
66
  * Expressive enables extended motion parameters.
package/utils/color.d.ts CHANGED
@@ -1,5 +1,5 @@
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';
1
+ import { BaseColor, BorderColor, ExtendedColor, SemanticColor, SurfaceColor, TextColor, ThemeColor } from '../types';
2
+ export type { CoreSemanticColor, CoreSurfaceColor, CoreThemeColor, CustomColors, SemanticBaseColor, OnColor, SemanticColor, ExtendedColor, OnExtendedColor, SurfaceColor, BaseColor, ThemeColor, BorderColor, TextColor, } from '../types';
3
3
  export declare function getOnColorName(colorName: ThemeColor): ThemeColor | undefined;
4
4
  /**
5
5
  * Returns all color names from the global registry for the selected type.
@@ -13,6 +13,7 @@ export declare function getColorNames(type: 'extended'): ExtendedColor[];
13
13
  export declare function getColorNames(type: 'surface'): SurfaceColor[];
14
14
  export declare function getColorNames(type: 'base'): BaseColor[];
15
15
  export declare function getColorNames(type: 'border'): BorderColor[];
16
+ export declare function getColorNames(type: 'text'): TextColor[];
16
17
  export declare function getColorNames(type: 'theme'): ThemeColor[];
17
18
  /**
18
19
  * Returns basic CSS variable references for a **surface color**.
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @category Theme
5
5
  */
6
- export type ColorType = 'semantic' | 'surface' | 'extended' | 'base' | 'border' | 'theme';
6
+ export type ColorType = 'semantic' | 'surface' | 'extended' | 'base' | 'border' | 'text' | 'theme';
7
7
  /**
8
8
  * Metadata entry describing how a color name should be used.
9
9
  *
@@ -1,26 +1,52 @@
1
1
  import { ThemeColorSchemes, ThemeCustomColors } from '../types';
2
2
  /**
3
- * Generates a full ThemeColorSchemes object (light and dark modes) based on a seed color,
4
- * and optional semantic seed colors.
3
+ * Generates a full ThemeColorSchemes object (light and dark modes) based on a seed color
4
+ * and optional custom semantic colors.
5
5
  *
6
- * Internally uses the Material Design 3 `themeFromSourceColor()` generator and applies
7
- * full resolution of all MD3 roles as defined in ThemeSchemeKeys.
6
+ * Internally uses the Material Design 3 `themeFromSourceColor()` generator. Each color is blended
7
+ * toward the source hue and expanded into a full set of roles: main, `on*`, `Container`,
8
+ * `onContainer`, `Fixed`, `onFixed`, `FixedDim`, and `onFixedVariant`.
8
9
  *
9
- * Custom semantic colors (e.g. `info`, `warning`, `success`) are blended into the palette
10
- * and expanded to support `Container`, `Fixed`, `Dim`, and `on*` roles.
10
+ * Built-in defaults (`info`, `warning`, `success`) are always included unless overridden.
11
11
  *
12
- * @param seedColor - Optional seed color in hex (e.g. "#6200ee"). Used as the base for the primary palette.
13
- * Defaults to `#6750A4` if not provided.
14
- * @param colors - Optional map of semantic base colors (core + augmented).
15
- * Defaults include `info`, `warning`, and `success`.
12
+ * @remarks
13
+ * Each entry in `colors` accepts two forms:
16
14
  *
17
- * @returns A fully resolved ThemeColorSchemes object with all required color roles populated for light and dark modes.
15
+ * - **String** seed hex used to generate the full MD3 tonal palette. All roles are MD3-computed.
16
+ * ```ts
17
+ * { info: '#2196f3' }
18
+ * ```
19
+ *
20
+ * - **Object** — allows exact color overrides per mode:
21
+ * - `main.light` / `main.dark` — overrides the primary role token. `dark` defaults to `light` if omitted.
22
+ * - `on` color is derived automatically from the overridden color's luminance (HCT tone < 50 → white, ≥ 50 → near-black)
23
+ * unless provided explicitly via `{ color, on }`.
24
+ * - `fixed` — controls the `Fixed` / `onFixed` tokens:
25
+ * - omitted: inherited from `main` override
26
+ * - `'preserve'`: keeps the MD3-generated values
27
+ * - object `{ light, dark? }`: explicit override, same rules as `main`
28
+ * - `Container` roles are always MD3-generated and cannot be overridden here.
29
+ * ```ts
30
+ * { brandBlue: { main: { light: '#0057FF' }, fixed: 'preserve' } }
31
+ * { brandBlue: { main: { light: { color: '#0057FF', on: '#FFD600' } } } }
32
+ * ```
33
+ *
34
+ * @param seedColor - Hex string used as the MD3 source color for the primary palette. Defaults to `#6750A4`.
35
+ * @param colors - Optional map of semantic color configs (core + augmented via `CustomColors`).
36
+ *
37
+ * @returns A fully resolved `ThemeColorSchemes` object for light and dark modes.
18
38
  * Also updates the global color registry via `setColorRegistry()`.
19
39
  *
20
40
  * @example
21
41
  * ```ts
22
- * const schemes = generateMaterialColors('#6200ee', { info: '#2196f3' });
42
+ * const schemes = generateMaterialColors('#6200ee', {
43
+ * info: '#2196f3',
44
+ * brandBlue: { main: { light: '#0057FF', dark: '#0057FF' } },
45
+ * brandBlueYellow: { main: { light: { color: '#0057FF', on: '#FFD600' } } },
46
+ * });
23
47
  * const primary = schemes.light.primary;
48
+ * const brandBlue = schemes.dark.brandBlue;
49
+ * const onBrandBlueYellow = schemes.light.onBrandBlueYellow; // '#FFD600'
24
50
  * ```
25
51
  *
26
52
  * @category Theme
package/utils/index.d.ts CHANGED
@@ -8,7 +8,7 @@ export * from './generateMaterialColors';
8
8
  export * from './applyThemeColors';
9
9
  export * from './breakpoints';
10
10
  export * from './toasts';
11
- export * from './uniqueID';
11
+ export * from './useUniqueId';
12
12
  export * from './controlStyle';
13
13
  export * from './getWrapperStyle';
14
14
  export * from './flatChildren';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Generates a stable React component ID safe for SSR and hydration.
3
+ *
4
+ * @param prefix - String prepended to the generated ID.
5
+ * @returns A unique ID in the form `${prefix}_xxxx`.
6
+ *
7
+ * @category Utils
8
+ */
9
+ export declare const useUniqueId: (prefix: string) => string;
@@ -1,14 +0,0 @@
1
- /**
2
- * Generates a fast, pseudo-random unique ID.
3
- *
4
- * @param prefix - String prepended to the generated ID.
5
- * @returns A unique ID in the form `${prefix}_xxxx`.
6
- *
7
- * @remarks
8
- * - Uses `Math.random()` → extremely fast, ideal for UI/runtime IDs.
9
- * - Not cryptographically secure.
10
- * - Suitable for components, form fields, ripple effects, etc.
11
- *
12
- * @category Utils
13
- */
14
- export declare const uniqueID: (prefix: string) => string;