@ufoui/core 0.0.88 → 0.0.125
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/spinners.d.ts +70 -0
- package/components/accordion/accordion.d.ts +4 -8
- package/components/accordion/accordionItem.d.ts +3 -5
- package/components/base/checkboxBase.d.ts +3 -7
- package/components/base/dialogBase.d.ts +3 -7
- package/components/base/textBase.d.ts +4 -3
- package/components/breadcrumbs/breadcrumbs.d.ts +2 -4
- package/components/card/card.d.ts +3 -7
- package/components/collapse/collapse.d.ts +4 -8
- package/components/item/item.d.ts +43 -0
- package/components/item/item.guards.d.ts +12 -0
- package/components/list/list.d.ts +45 -4
- package/components/listbox/listBox.d.ts +25 -0
- package/components/progress/progress.d.ts +35 -11
- package/components/select/select.d.ts +26 -17
- package/components/slider/slider.d.ts +86 -8
- package/components/slider/sliderHandle.d.ts +24 -0
- package/components/spinner/spinner.d.ts +19 -3
- package/components/toast/toast.d.ts +3 -7
- package/hooks/index.d.ts +2 -0
- package/hooks/useAnimate.d.ts +4 -0
- package/hooks/useMotion.d.ts +27 -0
- package/hooks/useUpdateEffect.d.ts +26 -0
- package/index.css +1 -1
- package/index.d.ts +4 -0
- package/index.js +3464 -2979
- package/package.json +6 -5
- package/types/color.d.ts +45 -3
- package/types/motion.d.ts +24 -0
- package/utils/color.d.ts +3 -2
- package/utils/colorRegistry.d.ts +1 -1
- package/utils/generateMaterialColors.d.ts +38 -12
- package/utils/index.d.ts +1 -1
- package/utils/useUniqueId.d.ts +9 -0
- package/utils/uniqueID.d.ts +0 -14
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ufoui/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.125",
|
|
4
4
|
"description": "Lightweight Material Design 3 UI components for React",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./index.
|
|
7
|
-
"module": "./index.
|
|
6
|
+
"main": "./index.js",
|
|
7
|
+
"module": "./index.js",
|
|
8
8
|
"types": "./index.d.ts",
|
|
9
9
|
"license": "Apache-2.0",
|
|
10
10
|
"author": "ufoui",
|
|
@@ -38,8 +38,9 @@
|
|
|
38
38
|
],
|
|
39
39
|
"exports": {
|
|
40
40
|
".": {
|
|
41
|
-
"
|
|
42
|
-
"
|
|
41
|
+
"types": "./index.d.ts",
|
|
42
|
+
"import": "./index.js",
|
|
43
|
+
"default": "./index.js"
|
|
43
44
|
},
|
|
44
45
|
"./style.css": "./index.css",
|
|
45
46
|
"./style": "./index.css"
|
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
|
|
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,
|
|
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**.
|
package/utils/colorRegistry.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
7
|
-
* full
|
|
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
|
-
*
|
|
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
|
-
* @
|
|
13
|
-
*
|
|
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
|
-
*
|
|
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', {
|
|
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 './
|
|
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;
|
package/utils/uniqueID.d.ts
DELETED
|
@@ -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;
|