@ufoui/core 0.0.4 → 0.0.12

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 (151) hide show
  1. package/README.md +9 -3
  2. package/assets/icons.d.ts +11 -0
  3. package/assets/index.d.ts +1 -0
  4. package/components/accordion/accordion.d.ts +52 -0
  5. package/components/accordion/accordionItem.d.ts +65 -0
  6. package/components/accordion/accordionItem.guards.d.ts +15 -0
  7. package/components/accordion/index.d.ts +2 -0
  8. package/components/avatar/avatar.d.ts +26 -29
  9. package/components/avatar/avatar.guards.d.ts +15 -0
  10. package/components/avatar/avatarGroup.d.ts +29 -0
  11. package/components/avatar/index.d.ts +2 -0
  12. package/components/badge/badge.d.ts +1 -1
  13. package/components/base/{boxBase/boxBase.d.ts → boxBase.d.ts} +18 -11
  14. package/components/base/{buttonBase/buttonBase.d.ts → buttonBase.d.ts} +2 -3
  15. package/components/base/{checkboxBase/checkboxBase.d.ts → checkboxBase.d.ts} +2 -3
  16. package/components/base/dialogBase.d.ts +34 -0
  17. package/components/base/{fieldBase/fieldBase.d.ts → fieldBase.d.ts} +2 -3
  18. package/components/base/index.d.ts +6 -0
  19. package/components/base/textBase.d.ts +44 -0
  20. package/components/breadcrumbs/breadcrumbs.d.ts +48 -0
  21. package/components/button/button.d.ts +1 -1
  22. package/components/calendar/calendar.d.ts +23 -0
  23. package/components/calendar/calendarUtils.d.ts +18 -0
  24. package/components/checkbox/checkbox.d.ts +1 -1
  25. package/components/chip/chip.d.ts +1 -1
  26. package/components/collapse/collapse.d.ts +33 -0
  27. package/components/dialogs/bottomSheet.d.ts +23 -0
  28. package/components/dialogs/dialog.d.ts +21 -0
  29. package/components/{dialog → dialogs}/dialogActions.d.ts +1 -2
  30. package/components/{dialog → dialogs}/dialogTitle.d.ts +2 -3
  31. package/components/dialogs/drawer.d.ts +23 -0
  32. package/components/dialogs/index.d.ts +6 -0
  33. package/components/divider/divider.d.ts +1 -1
  34. package/components/divider/divider.guards.d.ts +1 -1
  35. package/components/fab/fab.d.ts +1 -1
  36. package/components/fields/dateField.d.ts +24 -0
  37. package/components/fields/dateTimeField.d.ts +24 -0
  38. package/components/fields/emailField.d.ts +24 -0
  39. package/components/fields/index.d.ts +11 -0
  40. package/components/fields/monthField.d.ts +24 -0
  41. package/components/fields/numberField.d.ts +24 -0
  42. package/components/fields/passwordField.d.ts +24 -0
  43. package/components/fields/phoneField.d.ts +24 -0
  44. package/components/fields/textField.d.ts +24 -0
  45. package/components/fields/timeField.d.ts +24 -0
  46. package/components/fields/urlField.d.ts +24 -0
  47. package/components/fields/weekField.d.ts +24 -0
  48. package/components/fieldset/fieldset.d.ts +2 -1
  49. package/components/iconButton/iconButton.d.ts +1 -1
  50. package/components/{article → layout}/article.d.ts +1 -1
  51. package/components/{aside → layout}/aside.d.ts +1 -1
  52. package/components/{content → layout}/content.d.ts +1 -1
  53. package/components/{div → layout}/div.d.ts +1 -1
  54. package/components/{flex → layout}/flex.d.ts +1 -1
  55. package/components/{footer → layout}/footer.d.ts +1 -1
  56. package/components/{grid → layout}/grid.d.ts +1 -1
  57. package/components/{header → layout}/header.d.ts +1 -1
  58. package/components/layout/index.d.ts +11 -0
  59. package/components/{main → layout}/main.d.ts +1 -1
  60. package/components/{nav → layout}/nav.d.ts +1 -1
  61. package/components/{section → layout}/section.d.ts +1 -1
  62. package/components/link/link.d.ts +58 -0
  63. package/components/list/list.d.ts +8 -0
  64. package/components/{listItem → list}/listItem.d.ts +2 -3
  65. package/components/{listItem → list}/listItem.guards.d.ts +1 -1
  66. package/components/menu/menu.d.ts +2 -4
  67. package/components/menu/menu.guards.d.ts +1 -1
  68. package/components/menuItem/menuItem.d.ts +2 -3
  69. package/components/menuItem/menuItem.guards.d.ts +1 -1
  70. package/components/option/option.d.ts +1 -1
  71. package/components/option/option.guards.d.ts +1 -1
  72. package/components/progress/progress.d.ts +27 -0
  73. package/components/radio/radio.d.ts +1 -1
  74. package/components/radiogroup/radioGroup.d.ts +1 -1
  75. package/components/rating/rating.d.ts +68 -0
  76. package/components/select/select.d.ts +1 -1
  77. package/components/slider/slider.d.ts +11 -0
  78. package/components/switch/switch.d.ts +1 -10
  79. package/components/tabs/index.d.ts +2 -0
  80. package/components/tabs/tab.d.ts +37 -0
  81. package/components/tabs/tab.guards.d.ts +15 -0
  82. package/components/tabs/tabs.d.ts +7 -0
  83. package/components/toast/index.d.ts +2 -0
  84. package/components/toast/toast.d.ts +52 -0
  85. package/components/toast/toastViewport.d.ts +7 -0
  86. package/components/toggleButton/toggleButton.d.ts +1 -1
  87. package/components/toolbar/toolbar.d.ts +51 -0
  88. package/components/tooltip/tooltip.d.ts +1 -1
  89. package/components/typography/h1.d.ts +18 -0
  90. package/components/typography/h2.d.ts +18 -0
  91. package/components/typography/h3.d.ts +18 -0
  92. package/components/typography/h4.d.ts +18 -0
  93. package/components/typography/h5.d.ts +18 -0
  94. package/components/typography/h6.d.ts +18 -0
  95. package/components/typography/index.d.ts +9 -0
  96. package/components/typography/label.d.ts +18 -0
  97. package/components/typography/p.d.ts +18 -0
  98. package/components/typography/span.d.ts +18 -0
  99. package/context/index.d.ts +4 -0
  100. package/context/selectionContext.d.ts +32 -0
  101. package/context/themeContext.d.ts +2 -2
  102. package/hooks/index.d.ts +10 -0
  103. package/hooks/useAnimate.d.ts +38 -18
  104. package/hooks/useFocusTrap.d.ts +32 -0
  105. package/hooks/useFocusVisible.d.ts +16 -14
  106. package/hooks/useResizeObserver.d.ts +30 -0
  107. package/hooks/useRovingFocus.d.ts +30 -0
  108. package/hooks/useSelection.d.ts +16 -0
  109. package/hooks/useSelectionState.d.ts +29 -0
  110. package/hooks/useSliderKeys.d.ts +41 -0
  111. package/index.css +1 -1
  112. package/index.d.ts +22 -36
  113. package/index.js +4881 -0
  114. package/internal/controlGrid/controlGrid.d.ts +32 -0
  115. package/internal/controlLabel/controlLabel.d.ts +31 -0
  116. package/internal/description/description.d.ts +18 -0
  117. package/internal/index.d.ts +6 -0
  118. package/internal/inlineTooltip/index.d.ts +1 -0
  119. package/internal/inlineTooltip/inlineTooltipManager.d.ts +2 -2
  120. package/internal/slots/slot.d.ts +44 -0
  121. package/internal/stateLayer/stateLayer.d.ts +33 -0
  122. package/package.json +12 -3
  123. package/utils/calculateFloatingPosition.d.ts +1 -1
  124. package/utils/color.d.ts +2 -194
  125. package/utils/controlStyle.d.ts +67 -0
  126. package/utils/generateMaterialColors.d.ts +1 -1
  127. package/utils/generateSchemes.d.ts +1 -1
  128. package/utils/getWrapperStyle.d.ts +53 -0
  129. package/utils/index.d.ts +10 -0
  130. package/utils/{inputhMethod.d.ts → interactionMode.d.ts} +1 -1
  131. package/utils/toasts/ensureViewport.d.ts +7 -0
  132. package/utils/toasts/index.d.ts +1 -0
  133. package/utils/toasts/toast.d.ts +85 -0
  134. package/utils/toasts/toastStore.d.ts +65 -0
  135. package/utils/uniqueID.d.ts +14 -0
  136. package/utils/utils.d.ts +81 -81
  137. package/components/base/dialogBase/dialog.d.ts +0 -35
  138. package/components/base/inlineBase/inlineBase.d.ts +0 -62
  139. package/components/dateInput/dateInput.d.ts +0 -2
  140. package/components/dateTimeInput/dateTimeInput.d.ts +0 -2
  141. package/components/emailInput/emailInput.d.ts +0 -2
  142. package/components/numberInput/numberInput.d.ts +0 -2
  143. package/components/telInput/telInput.d.ts +0 -2
  144. package/components/textField/textField.d.ts +0 -9
  145. package/components/timeInput/timeInput.d.ts +0 -2
  146. package/components/urlInput/urlInput.d.ts +0 -2
  147. package/hooks/useFocusState.d.ts +0 -16
  148. package/index.mjs +0 -3832
  149. package/internal/inlineTooltip/inlineTooltip.d.ts +0 -11
  150. package/internal/inlineTooltip/inlineTooltip2.d.ts +0 -10
  151. /package/components/{dialog → dialogs}/dialogContent.d.ts +0 -0
@@ -1,5 +1,5 @@
1
- import { Theme } from '../types/index.ts';
2
- import { ThemeColor } from '../index.ts';
1
+ import { Theme } from '../types';
2
+ import { ThemeColor } from '../utils';
3
3
  /**
4
4
  * Provides shape for the theme context shared across the application.
5
5
  * Allows reading and updating theme configuration and resolving token values.
@@ -0,0 +1,10 @@
1
+ export * from './useAnimate';
2
+ export * from './useClickOutside';
3
+ export * from './useEscapeHandler';
4
+ export * from './useFocusVisible';
5
+ export * from './useResizeObserver';
6
+ export * from './useSelection';
7
+ export * from './useTheme';
8
+ export * from './useSliderKeys';
9
+ export * from './useSelectionState';
10
+ export * from './useFocusTrap';
@@ -10,8 +10,8 @@ export interface UseAnimateOptions {
10
10
  t2?: number;
11
11
  /** Enables one-shot animation behavior. */
12
12
  oneShot?: boolean;
13
- /** One-time start command executed on mount. */
14
- action?: 'idle' | 'open' | 'close';
13
+ /** Initial phase on mount. */
14
+ initial?: 'idle' | 'open' | 'closed';
15
15
  }
16
16
  /**
17
17
  * Result returned by the useAnimate hook.
@@ -19,36 +19,56 @@ export interface UseAnimateOptions {
19
19
  * @category Hooks
20
20
  */
21
21
  export interface UseAnimateResult {
22
- /** True while in the opening phase. */
22
+ /** True during the opening phase. */
23
23
  opening: boolean;
24
- /** True while in the closing phase. */
24
+ /** True during the closing phase. */
25
25
  closing: boolean;
26
- /** True while an animation is actively running. */
26
+ /** True when animation is running and not temporarily suppressed. */
27
27
  animating: boolean;
28
- /** True when no animation is active. */
28
+ /** True while animation is in progress (opening or closing). */
29
+ active: boolean;
30
+ /** True only before any animation has started. */
29
31
  idle: boolean;
30
32
  /** CSS variables controlling animation timing and direction. */
31
33
  animationVars: Record<string, string>;
32
- /** Triggers the next animation step or forces open or closed direction. */
34
+ /** Triggers animation towards open or closed state. */
33
35
  animate(next?: 'open' | 'closed'): void;
34
36
  }
35
37
  /**
36
- * Animation state hook supporting automatic, one-shot, and manual step modes.
38
+ * Handles open/close animation with interrupt support.
37
39
  *
38
- * Mode behavior:
39
- * - Automatic mode: when t1 is provided, animate runs a timed open or close sequence.
40
- * - One-shot mode: when enabled, only the opening transition is performed.
41
- * - Manual mode: when t1 is not provided, each animate call advances the phase by one step.
40
+ * Flow:
41
+ * - animate('open') sets phase to "opening" and starts a timer
42
+ * - after t1 phase becomes "open" and timer is cleared
43
+ * - animate('closed') sets phase to "closing" and starts a timer
44
+ * - after t2 → phase becomes "closed" and timer is cleared
42
45
  *
43
- * The hook handles animation interruption by clearing active timers and
44
- * temporarily suppressing visual animation to avoid glitches.
46
+ * Interrupt:
47
+ * - calling animate() during an active transition clears the current timer
48
+ * - a new transition starts immediately
49
+ * - for one render animating = false (reset frame)
45
50
  *
46
- * animationVars return CSS custom properties describing the active phase:
47
- * - --uui-duration defines the duration of the current phase in milliseconds.
48
- * - --uui-reverse indicates whether the animation direction should be reversed.
51
+ * State usage:
52
+ * - opening / closing current transition phase
53
+ * - active true while transition is in progress (used for mount/visibility)
54
+ * - animating → same as active, but disabled during reset frame (used for CSS classes)
55
+ * - idle → true only before the first animation
56
+ *
57
+ * Important:
58
+ * - use `active` to control visibility (mount/unmount)
59
+ * - use `animating` to apply or remove animation classes
60
+ *
61
+ * Timer:
62
+ * - created when transition starts
63
+ * - cleared on completion or interrupt
64
+ *
65
+ * Modes:
66
+ * - t1 defined → automatic timed transitions
67
+ * - t1 undefined → manual stepper (each call advances phase)
68
+ * - oneShot → only opening transition is executed
49
69
  *
50
70
  * @function
51
- * @param options Hook configuration options.
71
+ * @param options Hook configuration options
52
72
  *
53
73
  * @category Hooks
54
74
  */
@@ -0,0 +1,32 @@
1
+ import { RefObject } from 'react';
2
+ /**
3
+ * Options for the useFocusTrap hook.
4
+ *
5
+ * @category Hooks
6
+ */
7
+ export interface UseFocusTrapOptions {
8
+ /** Root element used as focus boundary. */
9
+ ref: RefObject<HTMLElement | null>;
10
+ /** Enables or disables the focus trap. */
11
+ enabled?: boolean;
12
+ /** Moves focus inside on mount when not already inside. */
13
+ autoFocus?: boolean;
14
+ }
15
+ /**
16
+ * Focus trap for modal containers.
17
+ *
18
+ * Keeps keyboard focus inside the given element.
19
+ * Handles Tab loop and restores focus on unmount.
20
+ * Also redirects focus back when returning from outside the document.
21
+ *
22
+ * Behavior:
23
+ * - traps Tab navigation within the root element
24
+ * - moves focus to element with data-autofocus or first focusable on mount
25
+ * - restores previous focus on cleanup
26
+ *
27
+ * @function
28
+ * @param options
29
+ *
30
+ * @category Hooks
31
+ */
32
+ export declare const useFocusTrap: ({ ref, enabled, autoFocus }: UseFocusTrapOptions) => void;
@@ -1,20 +1,22 @@
1
+ import { FocusEventHandler } from 'react';
1
2
  /**
2
- * Determines whether focus indicators (focus rings) should be visible.
3
+ * Tracks focus state and determines whether focus indicators
4
+ * should be visibly rendered.
3
5
  *
4
- * Returns `true` when the user is navigating with the keyboard and `false`
5
- * for pointer-based interactions (mouse, touch, pen).
6
+ * Automatically merges external focus handlers.
6
7
  *
7
- * Internally tracks global interaction modality and mirrors the behavior
8
- * of the `:focus-visible` specification.
9
- *
10
- * @returns `true` if focus should be visibly rendered
11
- *
12
- * @example
13
- * const focusVisible = useFocusVisible();
14
- *
15
- * @example
16
- * <button className={focusVisible ? 'uui-focus-visible' : undefined} />
8
+ * @function useFocusVisible
9
+ * @param onFocus External onFocus handler
10
+ * @param onBlur External onBlur handler
11
+ * @returns Object containing focus flags and merged handlers
17
12
  *
18
13
  * @category Hooks
19
14
  */
20
- export declare function useFocusVisible(): boolean;
15
+ export declare function useFocusVisible(onFocus?: FocusEventHandler<HTMLElement>, onBlur?: FocusEventHandler<HTMLElement>): {
16
+ focusVisible: boolean;
17
+ isFocused: boolean;
18
+ focusHandlers: {
19
+ onFocus: FocusEventHandler<HTMLElement>;
20
+ onBlur: FocusEventHandler<HTMLElement>;
21
+ };
22
+ };
@@ -0,0 +1,30 @@
1
+ import { RefObject } from 'react';
2
+ /**
3
+ * Size information reported by ResizeObserver (CSS pixels).
4
+ *
5
+ * @category Hooks
6
+ */
7
+ export interface ObservedElementSize {
8
+ /** Element width in pixels. */
9
+ width: number;
10
+ /** Element height in pixels. */
11
+ height: number;
12
+ }
13
+ /**
14
+ * Observes a single DOM element using ResizeObserver
15
+ * and invokes a callback when its size changes.
16
+ *
17
+ * Uses the content box by default, or the border box when `borderBox` is true
18
+ * (includes padding and border; excludes margin).
19
+ *
20
+ * Does not trigger component re-render.
21
+ *
22
+ * @function
23
+ * @param ref Reference to the observed HTMLElement.
24
+ * @param onResize Called when size changes.
25
+ * @param enabled Enables or disables observation. Default: true.
26
+ * @param borderBox When true, report border box size; when false, content box. Default: false.
27
+ *
28
+ * @category Hooks
29
+ */
30
+ export declare function useResizeObserver<T extends HTMLElement>(ref: RefObject<T>, onResize: (size: ObservedElementSize) => void, enabled?: boolean, borderBox?: boolean): void;
@@ -0,0 +1,30 @@
1
+ import { default as React } from 'react';
2
+ /**
3
+ * Defines the directional axis used for roving focus navigation.
4
+ *
5
+ * @category Hooks
6
+ */
7
+ export type RovingOrientation = 'vertical' | 'horizontal';
8
+ /**
9
+ * Provides roving focus keyboard navigation for a group of elements.
10
+ *
11
+ * Enables Arrow, Home, and End key navigation across registered items
12
+ * using vertical or horizontal orientation.
13
+ *
14
+ * @param orientation Navigation direction. Default: 'vertical'.
15
+ * @param loop Whether focus should wrap around. Default: true.
16
+ *
17
+ * @returns Object containing register, unregister, and onKeyDown handlers.
18
+ *
19
+ * @example
20
+ * const roving = useRovingFocus('vertical');
21
+ *
22
+ * <button ref={roving.register} onKeyDown={roving.onKeyDown} />
23
+ *
24
+ * @category Hooks
25
+ */
26
+ export declare function useRovingFocus(orientation?: RovingOrientation, loop?: boolean): {
27
+ register: (el: HTMLElement | null) => void;
28
+ unregister: (el: HTMLElement | null) => void;
29
+ onKeyDown: (e: React.KeyboardEvent<HTMLElement>) => void;
30
+ };
@@ -0,0 +1,16 @@
1
+ import { SelectionContextValue } from '../context';
2
+ /**
3
+ * Provides typed access to SelectionContext including selection state,
4
+ * optional configuration, and roving focus controller.
5
+ *
6
+ * @typeParam T Optional configuration object type provided by the parent.
7
+ *
8
+ * @returns The current selection context value.
9
+ *
10
+ * @example
11
+ * const { values, toggle, config, roving } =
12
+ * useSelection<MyConfig>();
13
+ *
14
+ * @category Hooks
15
+ */
16
+ export declare function useSelection<T = unknown>(): SelectionContextValue<T>;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Hook that provides shared selection state logic for components
3
+ * such as Accordion, Tabs or List.
4
+ *
5
+ * Manages selected values, exposes selection helpers and optionally
6
+ * enables roving focus for keyboard navigation.
7
+ *
8
+ * @function
9
+ *
10
+ * @param type Selection type controlling whether one or multiple values can be active.
11
+ * @param orientation Orientation used by roving focus navigation.
12
+ *
13
+ * @returns Object containing selection state, helper functions and roving focus controller.
14
+ *
15
+ * @category Hooks
16
+ */
17
+ export declare function useSelectionState(type: 'single' | 'multiple', orientation?: 'vertical' | 'horizontal'): {
18
+ values: string[];
19
+ toggle: (value: string) => void;
20
+ set: (value: string) => void;
21
+ clear: () => void;
22
+ roving: {
23
+ register: (el: HTMLElement | null) => void;
24
+ unregister: (el: HTMLElement | null) => void;
25
+ onKeyDown: (e: React.KeyboardEvent<HTMLElement>) => void;
26
+ };
27
+ type: "single" | "multiple";
28
+ orientation: "vertical" | "horizontal";
29
+ };
@@ -0,0 +1,41 @@
1
+ import { default as React } from 'react';
2
+ /**
3
+ * Configuration for slider keyboard navigation.
4
+ *
5
+ * @category Hooks
6
+ */
7
+ export interface UseSliderKeysOptions {
8
+ /** Current value. */
9
+ value: number;
10
+ /** Minimum value. */
11
+ min: number;
12
+ /** Maximum value. */
13
+ max: number;
14
+ /** Step applied by arrow keys. */
15
+ step: number;
16
+ /** Disables interaction. */
17
+ disabled?: boolean;
18
+ /** Prevents value changes. */
19
+ readOnly?: boolean;
20
+ /** Called when value changes. */
21
+ onChange: (value: number) => void;
22
+ }
23
+ /**
24
+ * Provides keyboard navigation for slider-like controls.
25
+ *
26
+ * Supports Arrow, Home and End keys to change the value.
27
+ *
28
+ * @param options Slider keyboard configuration.
29
+ *
30
+ * @returns Object containing onKeyDown handler.
31
+ *
32
+ * @example
33
+ * const keys = useSliderKeys({ value, min: 0, max: 5, step: 0.5, onChange });
34
+ *
35
+ * <div role="slider" onKeyDown={keys.onKeyDown} />
36
+ *
37
+ * @category Hooks
38
+ */
39
+ export declare function useSliderKeys({ value, min, max, step, disabled, readOnly, onChange }: UseSliderKeysOptions): {
40
+ onKeyDown: (e: React.KeyboardEvent<HTMLElement>) => void;
41
+ };