@ufoui/core 0.0.1

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 (83) hide show
  1. package/LICENSE +150 -0
  2. package/README.md +37 -0
  3. package/TRADEMARK.md +10 -0
  4. package/components/article/article.d.ts +25 -0
  5. package/components/aside/aside.d.ts +27 -0
  6. package/components/avatar/avatar.d.ts +35 -0
  7. package/components/badge/badge.d.ts +57 -0
  8. package/components/base/boxBase/boxBase.d.ts +126 -0
  9. package/components/base/buttonBase/buttonBase.d.ts +126 -0
  10. package/components/base/checkboxBase/checkboxBase.d.ts +124 -0
  11. package/components/base/dialogBase/dialog.d.ts +35 -0
  12. package/components/base/fieldBase/fieldBase.d.ts +50 -0
  13. package/components/base/inlineBase/inlineBase.d.ts +62 -0
  14. package/components/button/button.d.ts +24 -0
  15. package/components/card/card.d.ts +15 -0
  16. package/components/checkbox/checkbox.d.ts +31 -0
  17. package/components/chip/chip.d.ts +7 -0
  18. package/components/content/content.d.ts +28 -0
  19. package/components/dateInput/dateInput.d.ts +2 -0
  20. package/components/dateTimeInput/dateTimeInput.d.ts +2 -0
  21. package/components/dialog/dialogActions.d.ts +15 -0
  22. package/components/dialog/dialogContent.d.ts +9 -0
  23. package/components/dialog/dialogTitle.d.ts +16 -0
  24. package/components/div/div.d.ts +29 -0
  25. package/components/divider/divider.d.ts +70 -0
  26. package/components/divider/divider.guards.d.ts +15 -0
  27. package/components/emailInput/emailInput.d.ts +2 -0
  28. package/components/fab/fab.d.ts +29 -0
  29. package/components/fieldset/fieldset.d.ts +45 -0
  30. package/components/flex/flex.d.ts +36 -0
  31. package/components/footer/footer.d.ts +27 -0
  32. package/components/grid/grid.d.ts +38 -0
  33. package/components/header/header.d.ts +27 -0
  34. package/components/iconButton/iconButton.d.ts +27 -0
  35. package/components/listItem/listItem.d.ts +179 -0
  36. package/components/listItem/listItem.guards.d.ts +15 -0
  37. package/components/main/main.d.ts +27 -0
  38. package/components/menu/menu.d.ts +177 -0
  39. package/components/menu/menu.guards.d.ts +15 -0
  40. package/components/menuItem/menuItem.d.ts +179 -0
  41. package/components/menuItem/menuItem.guards.d.ts +15 -0
  42. package/components/nav/nav.d.ts +27 -0
  43. package/components/numberInput/numberInput.d.ts +2 -0
  44. package/components/option/option.d.ts +6 -0
  45. package/components/option/option.guards.d.ts +16 -0
  46. package/components/radio/radio.d.ts +31 -0
  47. package/components/radiogroup/radioGroup.d.ts +47 -0
  48. package/components/section/section.d.ts +27 -0
  49. package/components/select/select.d.ts +32 -0
  50. package/components/spinner/spinner.d.ts +7 -0
  51. package/components/switch/switch.d.ts +102 -0
  52. package/components/telInput/telInput.d.ts +2 -0
  53. package/components/textField/textField.d.ts +9 -0
  54. package/components/themeProvider/themeProvider.d.ts +54 -0
  55. package/components/timeInput/timeInput.d.ts +2 -0
  56. package/components/toggleButton/toggleButton.d.ts +6 -0
  57. package/components/tooltip/tooltip.d.ts +8 -0
  58. package/components/urlInput/urlInput.d.ts +2 -0
  59. package/context/fieldsetContext.d.ts +22 -0
  60. package/context/radioGroupContext.d.ts +28 -0
  61. package/context/themeContext.d.ts +61 -0
  62. package/hooks/useAnimate.d.ts +55 -0
  63. package/hooks/useClickOutside.d.ts +36 -0
  64. package/hooks/useEscapeHandler.d.ts +1 -0
  65. package/hooks/useFocusState.d.ts +16 -0
  66. package/hooks/useFocusVisible.d.ts +20 -0
  67. package/hooks/useTheme.d.ts +12 -0
  68. package/index.css +1 -0
  69. package/index.d.ts +53 -0
  70. package/index.mjs +3300 -0
  71. package/internal/inlineTooltip/inlineTooltip.d.ts +11 -0
  72. package/internal/inlineTooltip/inlineTooltip2.d.ts +10 -0
  73. package/internal/inlineTooltip/inlineTooltipManager.d.ts +12 -0
  74. package/package.json +38 -0
  75. package/types/index.d.ts +2 -0
  76. package/types/motion.d.ts +17 -0
  77. package/types/theme.d.ts +246 -0
  78. package/utils/calculateFloatingPosition.d.ts +68 -0
  79. package/utils/color.d.ts +415 -0
  80. package/utils/generateMaterialColors.d.ts +31 -0
  81. package/utils/generateSchemes.d.ts +32 -0
  82. package/utils/inputhMethod.d.ts +17 -0
  83. package/utils/utils.d.ts +202 -0
@@ -0,0 +1,202 @@
1
+ import { default as React, ReactNode } from 'react';
2
+ export type ElementSize = 'extraSmall' | 'small' | 'medium' | 'large' | 'extraLarge';
3
+ export type ElementInset = 'none' | 'left' | 'right' | 'top' | 'bottom' | 'middle';
4
+ export type ElementShape = 'square' | 'smooth' | 'rounded' | 'round';
5
+ /**
6
+ * Border width levels used across UUI components (0–4).
7
+ *
8
+ * @remarks
9
+ * Numeric scale mapped to design-token border thickness:
10
+ * - **0** – no border
11
+ * - **1** – thin (default)
12
+ * - **2–3** – medium / strong emphasis
13
+ * - **4** – maximum emphasis
14
+ *
15
+ * Used by inputs, buttons, menus, cards and other surface components.
16
+ *
17
+ * @category Utils
18
+ */
19
+ export type ElementBorder = 0 | 1 | 2 | 3 | 4;
20
+ export type ElementOutline = 0 | 1 | 2 | 3 | 4;
21
+ /**
22
+ * Elevation (shadow depth) levels used across UUI surfaces.
23
+ *
24
+ * @remarks
25
+ * Maps numeric values **0–5** to predefined shadow tokens (`--uui-elevation-*`):
26
+ * - **0** — no shadow
27
+ * - **1–2** — low elevation (small ambient + subtle directional shadow)
28
+ * - **3–4** — medium elevation (stronger spread, more depth)
29
+ * - **5** — highest elevation (max separation from background)
30
+ *
31
+ * Each level resolves to a CSS `box-shadow` defined in theme tokens.
32
+ * Supports hover/pressed elevation transitions via utility classes:
33
+ * - `.uui-hover-elevate`
34
+ * - `.uui-pressed-elevate`
35
+ *
36
+ * Used by menus, cards, buttons, popovers and all floating surfaces.
37
+ *
38
+ * @category Utils
39
+ */
40
+ export type ElementElevation = 0 | 1 | 2 | 3 | 4 | 5;
41
+ /**
42
+ * Alignment positions for floating and anchored UI components.
43
+ *
44
+ * @remarks
45
+ * Defines all relative placements between a reference element and its
46
+ * floating content (menus, tooltips, dropdowns, submenus).
47
+ *
48
+ * Standard positions:
49
+ * - **topLeft**, **topCenter**, **topRight**
50
+ * - **centerLeft**, **center**, **centerRight**
51
+ * - **bottomLeft**, **bottomCenter**, **bottomRight**
52
+ *
53
+ * Extended positions (used mainly for submenus):
54
+ * - **topRightOut** – flush to the right, outside the reference element.
55
+ * - **topLeftOut** – flush to the left, outside the reference element.
56
+ *
57
+ * Special:
58
+ * - **auto** – automatically selects the best fitting placement.
59
+ *
60
+ * @category Utils
61
+ */
62
+ export type ElementAlign = 'topLeft' | 'topCenter' | 'topRight' | 'centerLeft' | 'center' | 'centerRight' | 'bottomLeft' | 'bottomCenter' | 'bottomRight' | 'topRightOut' | 'topLeftOut' | 'auto';
63
+ export type ElementDensity = 'comfortable' | 'compact' | 'dense';
64
+ export type ElementFocusEffect = 'ring' | 'overlay';
65
+ export type ElementPressedEffect = 'elevate' | 'overlay' | 'scale';
66
+ export type ElementHoverEffect = 'elevate' | 'overlay' | 'color';
67
+ export type ElementSelectedEffect = 'color' | 'morph' | 'border' | 'overlay';
68
+ export type ElementTouchEffect = 'ripple';
69
+ export type ElementFont = 'displayLarge' | 'displayMedium' | 'displaySmall' | 'headlineLarge' | 'headlineMedium' | 'headlineSmall' | 'titleLarge' | 'titleMedium' | 'titleSmall' | 'labelLarge' | 'labelMedium' | 'labelSmall' | 'bodyLarge' | 'bodyMedium' | 'bodySmall' | 'caption' | 'overline';
70
+ export type ElementTextPlacement = 'start' | 'end' | 'top' | 'bottom';
71
+ export declare const getAlignClass: (position: ElementAlign) => string;
72
+ export declare const getShapeClass: (shape: ElementShape) => "uui-square" | "uui-smooth" | "uui-rounded" | "uui-round" | "";
73
+ export declare const getBodySizeClass: (size: ElementSize) => "uui-font-body-large" | "uui-font-body-medium" | "uui-font-body-small";
74
+ export declare const getSizeClass: (size: ElementSize) => "uui-extra-small" | "uui-small" | "uui-medium" | "uui-large" | "uui-extra-large";
75
+ /**
76
+ * Returns the appropriate CSS class for the given border size.
77
+ *
78
+ * @param border - Border size (0 to 4)
79
+ * @returns A class name like 'uui-border-2'
80
+ */
81
+ export declare const getBorderClass: (border?: ElementBorder) => string;
82
+ /**
83
+ * Returns the appropriate CSS class for the given outline size.
84
+ *
85
+ * @param size - Outline size (0 to 4)
86
+ * @returns A class name like 'uui-outline-2'
87
+ */
88
+ export declare const getOutlineClass: (size: ElementBorder) => string;
89
+ export declare const getElevationClass: (elevation?: ElementElevation) => "" | "uui-elevation-0" | "uui-elevation-1" | "uui-elevation-2" | "uui-elevation-3" | "uui-elevation-4" | "uui-elevation-5";
90
+ export declare const getDensityClass: (density?: ElementDensity) => "" | "uui-compact" | "uui-dense";
91
+ export declare const getFontClass: (font: ElementFont) => string;
92
+ /**
93
+ * Merges multiple React refs into a single ref callback.
94
+ *
95
+ * @param refs - List of refs (callback refs or `MutableRefObject`s) to update.
96
+ * @returns A ref callback that assigns the same value to all provided refs.
97
+ *
98
+ * @remarks
99
+ * - Supports both function refs and object refs.
100
+ * - Commonly used when forwarding a ref while also keeping a local one.
101
+ *
102
+ * @example
103
+ * const innerRef = useRef<HTMLDivElement>(null);
104
+ * const merged = mergeRefs(ref, innerRef);
105
+ *
106
+ * <div ref={merged} />
107
+ *
108
+ * @category Utils
109
+ */
110
+ export declare function mergeRefs<T>(...refs: React.Ref<T>[]): React.RefCallback<T>;
111
+ /**
112
+ * Creates a material-style ripple effect inside the given element.
113
+ *
114
+ * @param el - Target element that receives the ripple.
115
+ * @param event - Mouse event used to determine the ripple origin.
116
+ *
117
+ * @remarks
118
+ * - Automatically clears previous ripples.
119
+ * - Injects a `.ripple-container` and `.ripple` element.
120
+ * - Uses the element's client size and border radius.
121
+ * - Safe for buttons, icon buttons, list items, etc.
122
+ *
123
+ * @category Utils
124
+ */
125
+ export declare const createRipple: (el: HTMLElement, event: React.MouseEvent<HTMLElement>, host?: HTMLElement) => void;
126
+ /**
127
+ * Generates a fast, pseudo-random unique ID.
128
+ *
129
+ * @param prefix - String prepended to the generated ID.
130
+ * @returns A unique ID in the form `${prefix}_xxxx`.
131
+ *
132
+ * @remarks
133
+ * - Uses `Math.random()` → extremely fast, ideal for UI/runtime IDs.
134
+ * - Not cryptographically secure.
135
+ * - Suitable for components, form fields, ripple effects, etc.
136
+ *
137
+ * @category Utils
138
+ */
139
+ export declare const uniqueID: (prefix: string) => string;
140
+ /**
141
+ * Converts a camelCase, PascalCase, or acronym-based string into kebab-case.
142
+ *
143
+ * @param str - Input string to convert.
144
+ * @returns The kebab-case version of the string.
145
+ *
146
+ * @example
147
+ * toKebabCase("myVariableName"); // "my-variable-name"
148
+ * toKebabCase("URLParser"); // "url-parser"
149
+ *
150
+ * @category Utils
151
+ */
152
+ export declare function toKebabCase(str: string): string;
153
+ /**
154
+ * Returns the `displayName` of a React element if available.
155
+ *
156
+ * @param el - A React node to inspect.
157
+ * @returns The component's display name, or `undefined` if not found.
158
+ *
159
+ * @remarks
160
+ * - Works with function components, `memo()`, and `forwardRef()`.
161
+ * - Safe for any `ReactNode` (`string`, `null`, DOM elements, fragments, etc.).
162
+ *
163
+ * @category Utils
164
+ */
165
+ export declare function getElementDisplayName(el: ReactNode): string | undefined;
166
+ /**
167
+ * Forces focus to behave like :focus-visible on all browsers,
168
+ * including Safari which loses :focus-visible heuristics when
169
+ * focus is set programmatically (e.g., in menus or lists).
170
+ *
171
+ * Adds `.uui-focus-visible` to the element on focus, and
172
+ * removes it automatically on blur.
173
+ *
174
+ * Chrome/Firefox:
175
+ * - still rely on native :focus-visible
176
+ * - fallback class is ignored (lower specificity)
177
+ *
178
+ * Safari:
179
+ * - native :focus-visible is unreliable
180
+ * - fallback `.uui-focus-visible` replaces it
181
+ *
182
+ * @param el - HTMLElement to focus with visible highlighting.
183
+ *
184
+ * @category Utils
185
+ */
186
+ export declare function setFocusVisible(el: HTMLElement | null): void;
187
+ /**
188
+ * Clamps a numeric value to an integer range with a fallback.
189
+ *
190
+ * Converts the input to a number, rounds it to an integer,
191
+ * then clamps it between `min` and `max`.
192
+ * If the value is not a finite number, returns `fallback`.
193
+ *
194
+ * @param min - Minimum allowed value.
195
+ * @param max - Maximum allowed value.
196
+ * @param value - Input value to clamp. Can be any type.
197
+ * @param fallback - Value returned when input is invalid.
198
+ * @returns A clamped integer within the given range.
199
+ *
200
+ * @category Utils
201
+ */
202
+ export declare function clampInt(min: number, max: number, value: unknown, fallback?: number): number | undefined;