@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.
Files changed (80) hide show
  1. package/assets/icons.d.ts +8 -2
  2. package/components/accordion/accordion.d.ts +31 -3
  3. package/components/accordion/accordionItem.d.ts +31 -3
  4. package/components/badge/badge.d.ts +2 -2
  5. package/components/base/boxBase.d.ts +14 -36
  6. package/components/base/buttonBase.d.ts +4 -4
  7. package/components/base/checkboxBase.d.ts +2 -2
  8. package/components/base/dialogBase.d.ts +111 -13
  9. package/components/base/fieldBase.d.ts +1 -2
  10. package/components/base/textBase.d.ts +1 -2
  11. package/components/breadcrumbs/breadcrumbs.d.ts +48 -0
  12. package/components/calendar/calendar.d.ts +23 -0
  13. package/components/calendar/calendarUtils.d.ts +18 -0
  14. package/components/card/card.d.ts +2 -2
  15. package/components/collapse/collapse.d.ts +15 -20
  16. package/components/dialogs/dialog.d.ts +1 -1
  17. package/components/dialogs/dialogActions.d.ts +19 -7
  18. package/components/dialogs/dialogActions.guards.d.ts +15 -0
  19. package/components/dialogs/dialogContent.d.ts +7 -1
  20. package/components/dialogs/dialogHeader.d.ts +60 -0
  21. package/components/dialogs/dialogTitle.d.ts +9 -5
  22. package/components/dialogs/drawer.d.ts +1 -1
  23. package/components/dialogs/index.d.ts +1 -0
  24. package/components/fieldset/fieldset.d.ts +1 -1
  25. package/components/link/link.d.ts +58 -0
  26. package/components/list/list.d.ts +1 -1
  27. package/components/menu/menu.d.ts +2 -2
  28. package/components/rating/rating.d.ts +68 -0
  29. package/components/slider/slider.d.ts +11 -0
  30. package/components/switch/switch.d.ts +2 -10
  31. package/components/themeProvider/themeProvider.d.ts +10 -15
  32. package/components/toast/toast.d.ts +18 -4
  33. package/components/toast/toastViewport.d.ts +4 -3
  34. package/components/tooltip/tooltip.d.ts +2 -2
  35. package/context/selectionContext.d.ts +18 -17
  36. package/hooks/index.d.ts +3 -1
  37. package/hooks/useAnimate.d.ts +36 -16
  38. package/hooks/useFocusTrap.d.ts +32 -0
  39. package/hooks/useFocusVisible.d.ts +16 -14
  40. package/hooks/useResizeObserver.d.ts +7 -3
  41. package/hooks/useRovingFocus.d.ts +30 -0
  42. package/hooks/useSelection.d.ts +10 -7
  43. package/hooks/useSelectionState.d.ts +29 -0
  44. package/hooks/useSliderKeys.d.ts +41 -0
  45. package/index.css +1 -1
  46. package/index.d.ts +4 -8
  47. package/index.js +4782 -0
  48. package/internal/controlGrid/controlGrid.d.ts +32 -0
  49. package/internal/controlLabel/controlLabel.d.ts +31 -0
  50. package/internal/description/description.d.ts +18 -0
  51. package/internal/icon/icon.d.ts +28 -0
  52. package/internal/index.d.ts +7 -0
  53. package/internal/inlineTooltip/index.d.ts +1 -0
  54. package/internal/inlineTooltip/inlineTooltipManager.d.ts +3 -3
  55. package/internal/slots/slot.d.ts +44 -0
  56. package/internal/stateLayer/stateLayer.d.ts +33 -0
  57. package/package.json +12 -3
  58. package/types/dialog.d.ts +37 -0
  59. package/types/index.d.ts +1 -0
  60. package/types/motion.d.ts +2 -2
  61. package/types/theme.d.ts +0 -30
  62. package/utils/applyThemeTokens.d.ts +10 -0
  63. package/utils/calculateFloatingPosition.d.ts +3 -3
  64. package/utils/color.d.ts +61 -216
  65. package/utils/colorRegistry.d.ts +44 -0
  66. package/utils/controlStyle.d.ts +8 -8
  67. package/utils/flatChildren.d.ts +17 -0
  68. package/utils/generateMaterialColors.d.ts +7 -7
  69. package/utils/getWrapperStyle.d.ts +53 -0
  70. package/utils/index.d.ts +5 -1
  71. package/utils/renderPortal.d.ts +30 -0
  72. package/utils/toasts/ensureViewport.d.ts +6 -1
  73. package/utils/toasts/toast.d.ts +66 -10
  74. package/utils/toasts/toastStore.d.ts +55 -1
  75. package/utils/utils.d.ts +67 -55
  76. package/hooks/useFocusState.d.ts +0 -16
  77. package/index.mjs +0 -4649
  78. package/internal/inlineTooltip/inlineTooltip.d.ts +0 -11
  79. package/internal/inlineTooltip/inlineTooltip2.d.ts +0 -10
  80. package/utils/generateSchemes.d.ts +0 -32
@@ -1,29 +1,85 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { SurfaceColor } from '../index';
3
+ /**
4
+ * Status variant applied to a toast.
5
+ *
6
+ * @category Toast
7
+ */
3
8
  export type ToastStatus = 'success' | 'error' | 'warning' | 'info';
9
+ /**
10
+ * Options used to create or update a toast.
11
+ *
12
+ * @category Toast
13
+ */
4
14
  export interface ToastOptions {
5
- id?: string;
6
- title?: string;
7
- description?: string;
15
+ /** Action element rendered inside the toast. */
16
+ action?: ReactNode | ((id: string) => ReactNode);
17
+ /** Surface color token overriding background and text colors. */
8
18
  color?: SurfaceColor;
9
- status?: ToastStatus;
19
+ /** Full custom content replacing default layout. */
20
+ content?: ReactNode;
21
+ /** Supporting message text. */
22
+ description?: string;
23
+ /** Leading visual element such as an icon. */
10
24
  icon?: ReactNode;
11
- action?: ReactNode | ((id: string) => ReactNode);
12
- duration?: number;
25
+ /** Optional identifier. Generated automatically if not provided. */
26
+ id?: string;
27
+ /** Priority toasts appear before normal queued toasts. */
28
+ priority?: boolean;
29
+ /** Status variant applied as CSS modifier class. */
30
+ status?: ToastStatus;
31
+ /** Time in milliseconds before the toast is automatically dismissed. */
32
+ timeout?: number;
33
+ /** Primary heading text. */
34
+ title?: string;
13
35
  }
36
+ /**
37
+ * Message descriptor used by promise helper.
38
+ *
39
+ * @category Toast
40
+ */
41
+ type ToastPromiseMessage<T> = string | ToastOptions | ((v: T) => string | ToastOptions);
42
+ /**
43
+ * Creates and displays a toast.
44
+ *
45
+ * Accepts either a message string or a ToastOptions object.
46
+ *
47
+ * @function
48
+ */
14
49
  declare function show(input: string | ToastOptions): string;
50
+ /**
51
+ * Toast API used to create, update and manage notifications.
52
+ *
53
+ * @category Toast
54
+ */
15
55
  export declare const toast: typeof show & {
16
- update: (id: string, partial: Partial<ToastOptions>) => void;
56
+ /** Updates an existing toast. */
57
+ update: (id: string, partial: import('./toastStore').ToastUpdate) => void;
58
+ /** Removes a toast by id. */
17
59
  dismiss: (id: string) => void;
60
+ /** Removes all toasts. */
18
61
  clear: () => void;
62
+ /** Creates a success toast. */
19
63
  success: (description: string, o?: ToastOptions) => string;
64
+ /** Creates an error toast. */
20
65
  error: (description: string, o?: ToastOptions) => string;
66
+ /** Creates an informational toast. */
21
67
  info: (description: string, o?: ToastOptions) => string;
68
+ /** Creates a warning toast. */
22
69
  warning: (description: string, o?: ToastOptions) => string;
70
+ /**
71
+ * Displays toast lifecycle bound to a promise.
72
+ *
73
+ * Promise toasts use priority so the user immediately
74
+ * sees feedback for the triggered action.
75
+ *
76
+ * @category Toast
77
+ * @function
78
+ */
23
79
  promise<T>(p: Promise<T>, m: {
24
- loading: string;
25
- success: string | ((v: T) => string);
26
- error: string | ((e: unknown) => string);
80
+ loading: ToastPromiseMessage<void>;
81
+ success: ToastPromiseMessage<T>;
82
+ error: ToastPromiseMessage<unknown>;
27
83
  }): Promise<T>;
28
84
  };
29
85
  export {};
@@ -1,11 +1,65 @@
1
1
  import { ToastOptions } from './toast';
2
+ /**
3
+ * Internal toast state stored in the toast store.
4
+ *
5
+ * @category Toast
6
+ */
2
7
  export type ToastState = Required<Pick<ToastOptions, 'id'>> & Omit<ToastOptions, 'id'>;
8
+ /**
9
+ * Partial update object used when modifying a toast.
10
+ *
11
+ * @category Toast
12
+ */
13
+ export type ToastUpdate = Partial<Omit<ToastOptions, 'id'>>;
14
+ /**
15
+ * Subscriber function receiving current toast list.
16
+ *
17
+ * @category Toast
18
+ */
3
19
  export type ToastStoreSubscriber = (toasts: ToastState[]) => void;
20
+ /**
21
+ * Internal store managing toast lifecycle and subscriptions.
22
+ *
23
+ * @category Toast
24
+ */
4
25
  export declare const toastStore: {
26
+ /**
27
+ * Subscribes to toast state updates.
28
+ *
29
+ * @function
30
+ */
5
31
  subscribe(subscriber: ToastStoreSubscriber): () => void;
32
+ /**
33
+ * Adds a new toast to the store.
34
+ *
35
+ * Priority toasts are inserted at the beginning
36
+ * so they appear before normal queued toasts.
37
+ *
38
+ * @function
39
+ */
6
40
  add(toast: ToastState): void;
7
- update(id: string, partial: Partial<ToastOptions>): void;
41
+ /**
42
+ * Updates an existing toast.
43
+ *
44
+ * @function
45
+ */
46
+ update(id: string, partial: ToastUpdate): void;
47
+ /**
48
+ * Removes a toast from the store.
49
+ *
50
+ * @function
51
+ */
8
52
  remove(id: string): void;
53
+ /**
54
+ * Removes all toasts.
55
+ *
56
+ * @function
57
+ */
9
58
  clear(): void;
59
+ /**
60
+ * Returns current toast list snapshot.
61
+ *
62
+ * @function
63
+ */
10
64
  getState(): ToastState[];
11
65
  };
package/utils/utils.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { default as React } from 'react';
2
1
  export type ElementSize = 'extraSmall' | 'small' | 'medium' | 'large' | 'extraLarge';
3
2
  export type ElementInset = 'none' | 'left' | 'right' | 'top' | 'bottom' | 'middle';
4
3
  export type ElementShape = 'square' | 'smooth' | 'rounded' | 'round';
@@ -75,7 +74,7 @@ export type ElementElevation = 0 | 1 | 2 | 3 | 4 | 5;
75
74
  *
76
75
  * @category Utils
77
76
  */
78
- export type ElementAlign = 'topLeft' | 'topCenter' | 'topRight' | 'centerLeft' | 'center' | 'centerRight' | 'bottomLeft' | 'bottomCenter' | 'bottomRight' | 'topRightOut' | 'topLeftOut' | 'auto';
77
+ export type ElementPlacement = 'topLeft' | 'topCenter' | 'topRight' | 'centerLeft' | 'center' | 'centerRight' | 'bottomLeft' | 'bottomCenter' | 'bottomRight' | 'topRightOut' | 'topLeftOut' | 'auto';
79
78
  export type ElementDensity = 'comfortable' | 'compact' | 'dense';
80
79
  export type ElementFocusEffect = 'ring' | 'overlay';
81
80
  export type ElementPressedEffect = 'elevate' | 'overlay' | 'scale';
@@ -84,9 +83,50 @@ export type ElementSelectedEffect = 'color' | 'morph' | 'border' | 'overlay';
84
83
  export type ElementTouchEffect = 'ripple';
85
84
  export type ElementFont = 'displayLarge' | 'displayMedium' | 'displaySmall' | 'headlineLarge' | 'headlineMedium' | 'headlineSmall' | 'titleLarge' | 'titleMedium' | 'titleSmall' | 'labelLarge' | 'labelMedium' | 'labelSmall' | 'bodyLarge' | 'bodyMedium' | 'bodySmall' | 'caption' | 'overline';
86
85
  export type ElementTextPlacement = 'start' | 'end' | 'top' | 'bottom';
87
- export declare const getAlignClass: (position: ElementAlign) => string;
88
- export declare const getShapeClass: (shape: ElementShape) => "uui-square" | "uui-smooth" | "uui-rounded" | "uui-round" | "";
89
- export declare const getSizeClass: (size: ElementSize) => "uui-extra-small" | "uui-small" | "uui-medium" | "uui-large" | "uui-extra-large";
86
+ /**
87
+ * Converts a camelCase, PascalCase, or acronym-based string into kebab-case.
88
+ *
89
+ * @param str - Input string to convert.
90
+ * @returns The kebab-case version of the string.
91
+ *
92
+ * @example
93
+ * toKebabCase("myVariableName"); // "my-variable-name"
94
+ * toKebabCase("URLParser"); // "url-parser"
95
+ *
96
+ * @category Utils
97
+ */
98
+ export declare function toKebabCase(str: string): string;
99
+ /**
100
+ * Clamps a numeric value to an integer range with a fallback.
101
+ *
102
+ * Converts the input to a number, rounds it to an integer,
103
+ * then clamps it between `min` and `max`.
104
+ * If the value is not a finite number, returns `fallback`.
105
+ *
106
+ * @param min - Minimum allowed value.
107
+ * @param max - Maximum allowed value.
108
+ * @param value - Input value to clamp. Can be any type.
109
+ * @param fallback - Value returned when input is invalid.
110
+ * @returns A clamped integer within the given range.
111
+ *
112
+ * @category Utils
113
+ */
114
+ export declare function clampInt(min: number, max: number, value: unknown, fallback?: number): number | undefined;
115
+ export declare const getPlacementClass: (position: ElementPlacement) => string;
116
+ /**
117
+ * Returns the appropriate CSS class for the given shape token.
118
+ *
119
+ * @param shape Shape token.
120
+ * @returns CSS class for shape variant.
121
+ */
122
+ export declare const getShapeClass: (shape?: ElementShape) => string;
123
+ /**
124
+ * Returns the CSS class for the given size token.
125
+ *
126
+ * @param size Size token.
127
+ * @returns CSS class for size variant.
128
+ */
129
+ export declare const getSizeClass: (size: ElementSize) => string;
90
130
  /**
91
131
  * Returns the appropriate CSS class for the given border size.
92
132
  *
@@ -95,14 +135,25 @@ export declare const getSizeClass: (size: ElementSize) => "uui-extra-small" | "u
95
135
  */
96
136
  export declare const getBorderClass: (border?: ElementBorder) => string;
97
137
  /**
98
- * Returns the appropriate CSS class for the given outline size.
138
+ * Returns the appropriate CSS class for the given elevation level.
139
+ *
140
+ * @param elevation Elevation token.
141
+ * @returns CSS class in the form uui-elevation-X.
142
+ */
143
+ export declare const getElevationClass: (elevation?: ElementElevation) => string;
144
+ /**
145
+ * Returns the appropriate CSS class for the given density token.
146
+ *
147
+ * @param density Density token.
148
+ * @returns CSS class for density variant.
149
+ */
150
+ export declare const getDensityClass: (density?: ElementDensity) => string;
151
+ /**
152
+ * Returns the CSS class for the given typography token.
99
153
  *
100
- * @param size - Outline size (0 to 4)
101
- * @returns A class name like 'uui-outline-2'
154
+ * @param font Typography token.
155
+ * @returns CSS class in the form uui-font-<token>.
102
156
  */
103
- export declare const getOutlineClass: (size: ElementBorder) => string;
104
- export declare const getElevationClass: (elevation?: ElementElevation) => "" | "uui-elevation-0" | "uui-elevation-1" | "uui-elevation-2" | "uui-elevation-3" | "uui-elevation-4" | "uui-elevation-5";
105
- export declare const getDensityClass: (density?: ElementDensity) => "" | "uui-compact" | "uui-dense";
106
157
  export declare const getFontClass: (font: ElementFont) => string;
107
158
  /**
108
159
  * Merges multiple React refs into a single ref callback.
@@ -139,52 +190,13 @@ export declare function mergeRefs<T>(...refs: React.Ref<T>[]): React.RefCallback
139
190
  */
140
191
  export declare const createRipple: (el: HTMLElement, event: React.MouseEvent<HTMLElement>, host?: HTMLElement) => void;
141
192
  /**
142
- * Converts a camelCase, PascalCase, or acronym-based string into kebab-case.
143
- *
144
- * @param str - Input string to convert.
145
- * @returns The kebab-case version of the string.
146
- *
147
- * @example
148
- * toKebabCase("myVariableName"); // "my-variable-name"
149
- * toKebabCase("URLParser"); // "url-parser"
150
- *
151
- * @category Utils
152
- */
153
- export declare function toKebabCase(str: string): string;
154
- /**
155
- * Forces focus to behave like :focus-visible on all browsers,
156
- * including Safari which loses :focus-visible heuristics when
157
- * focus is set programmatically (e.g., in menus or lists).
193
+ * Joins class names into a single string.
158
194
  *
159
- * Adds `.uui-focus-visible` to the element on focus, and
160
- * removes it automatically on blur.
195
+ * Accepts strings or arrays of strings and filters out falsy values.
161
196
  *
162
- * Chrome/Firefox:
163
- * - still rely on native :focus-visible
164
- * - fallback class is ignored (lower specificity)
165
- *
166
- * Safari:
167
- * - native :focus-visible is unreliable
168
- * - fallback `.uui-focus-visible` replaces it
169
- *
170
- * @param el - HTMLElement to focus with visible highlighting.
171
- *
172
- * @category Utils
173
- */
174
- export declare function setFocusVisible(el: HTMLElement | null): void;
175
- /**
176
- * Clamps a numeric value to an integer range with a fallback.
177
- *
178
- * Converts the input to a number, rounds it to an integer,
179
- * then clamps it between `min` and `max`.
180
- * If the value is not a finite number, returns `fallback`.
181
- *
182
- * @param min - Minimum allowed value.
183
- * @param max - Maximum allowed value.
184
- * @param value - Input value to clamp. Can be any type.
185
- * @param fallback - Value returned when input is invalid.
186
- * @returns A clamped integer within the given range.
197
+ * @function
198
+ * @param classes Class names to combine.
187
199
  *
188
200
  * @category Utils
189
201
  */
190
- export declare function clampInt(min: number, max: number, value: unknown, fallback?: number): number | undefined;
202
+ export declare function cn(...classes: (string | false | null | undefined | string[])[]): string;
@@ -1,16 +0,0 @@
1
- /**
2
- * Tracks focus state for a DOM element.
3
- *
4
- * Provides technical focus state and visual focus visibility.
5
- * Designed for components that need focus styling without
6
- * interfering with user-provided focus handlers.
7
- *
8
- * @param ref Reference to the target DOM element.
9
- * @returns Object containing focus state flags.
10
- *
11
- * @category Hooks
12
- */
13
- export declare function useFocusState<T extends HTMLElement>(ref: React.RefObject<T>): {
14
- isFocused: boolean;
15
- focusVisible: boolean;
16
- };