@actview/floating-ui 0.1.0

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 (64) hide show
  1. package/LICENSE +21 -0
  2. package/dist/_deprecated-inner.d.ts +82 -0
  3. package/dist/components/Composite.d.ts +109 -0
  4. package/dist/components/FloatingArrow.d.ts +66 -0
  5. package/dist/components/FloatingDelayGroup.d.ts +70 -0
  6. package/dist/components/FloatingFocusManager.d.ts +92 -0
  7. package/dist/components/FloatingList.d.ts +43 -0
  8. package/dist/components/FloatingOverlay.d.ts +18 -0
  9. package/dist/components/FloatingPortal.d.ts +63 -0
  10. package/dist/components/FloatingTree.d.ts +45 -0
  11. package/dist/components/FocusGuard.d.ts +19 -0
  12. package/dist/components/NextFloatingDelayGroup.d.ts +57 -0
  13. package/dist/floating-ui.actview.d.mts +37 -0
  14. package/dist/floating-ui.actview.d.ts +37 -0
  15. package/dist/floating-ui.actview.esm.js +6688 -0
  16. package/dist/floating-ui.actview.mjs +6688 -0
  17. package/dist/floating-ui.actview.umd.js +6772 -0
  18. package/dist/floating-ui.actview.umd.min.js +1 -0
  19. package/dist/floating-ui.actview.utils.d.mts +7 -0
  20. package/dist/floating-ui.actview.utils.d.ts +7 -0
  21. package/dist/floating-ui.actview.utils.esm.js +587 -0
  22. package/dist/floating-ui.actview.utils.mjs +587 -0
  23. package/dist/floating-ui.actview.utils.umd.js +634 -0
  24. package/dist/floating-ui.actview.utils.umd.min.js +1 -0
  25. package/dist/hooks/gridNavigation.d.ts +39 -0
  26. package/dist/hooks/useClick.d.ts +45 -0
  27. package/dist/hooks/useClientPoint.d.ts +32 -0
  28. package/dist/hooks/useDismiss.d.ts +80 -0
  29. package/dist/hooks/useFloating.d.ts +18 -0
  30. package/dist/hooks/useFloatingRootContext.d.ts +22 -0
  31. package/dist/hooks/useFocus.d.ts +21 -0
  32. package/dist/hooks/useHover.d.ts +57 -0
  33. package/dist/hooks/useId.d.ts +11 -0
  34. package/dist/hooks/useInteractions.d.ts +13 -0
  35. package/dist/hooks/useListNavigation.d.ts +176 -0
  36. package/dist/hooks/useMergeRefs.d.ts +20 -0
  37. package/dist/hooks/useRole.d.ts +33 -0
  38. package/dist/hooks/useTransition.d.ts +68 -0
  39. package/dist/hooks/useTypeahead.d.ts +66 -0
  40. package/dist/index.d.ts +37 -0
  41. package/dist/safePolygon.d.ts +12 -0
  42. package/dist/types.d.ts +140 -0
  43. package/dist/useFloating.d.ts +57 -0
  44. package/dist/utils/clearTimeoutIfSet.d.ts +2 -0
  45. package/dist/utils/composite.d.ts +41 -0
  46. package/dist/utils/constants.d.ts +8 -0
  47. package/dist/utils/createAttribute.d.ts +1 -0
  48. package/dist/utils/createEventEmitter.d.ts +5 -0
  49. package/dist/utils/deepEqual.d.ts +1 -0
  50. package/dist/utils/element.d.ts +10 -0
  51. package/dist/utils/enqueueFocus.d.ts +8 -0
  52. package/dist/utils/event.d.ts +10 -0
  53. package/dist/utils/getDPR.d.ts +1 -0
  54. package/dist/utils/hooks.d.ts +16 -0
  55. package/dist/utils/log.d.ts +2 -0
  56. package/dist/utils/markOthers.d.ts +4 -0
  57. package/dist/utils/nodes.d.ts +4 -0
  58. package/dist/utils/platform.d.ts +6 -0
  59. package/dist/utils/roundByDPR.d.ts +1 -0
  60. package/dist/utils/safeReact.d.ts +8 -0
  61. package/dist/utils/tabbable.d.ts +13 -0
  62. package/dist/utils/useLiteMergeRefs.d.ts +14 -0
  63. package/dist/utils.d.ts +7 -0
  64. package/package.json +83 -0
@@ -0,0 +1,45 @@
1
+ import type { ElementProps, FloatingRootContext } from '../types';
2
+ export interface UseClickProps {
3
+ /**
4
+ * Whether the Hook is enabled, including all internal Effects and event
5
+ * handlers.
6
+ * @default true
7
+ */
8
+ enabled?: boolean | undefined;
9
+ /**
10
+ * The type of event to use to determine a “click” with mouse input.
11
+ * Keyboard clicks work as normal.
12
+ * @default 'click'
13
+ */
14
+ event?: 'click' | 'mousedown' | undefined;
15
+ /**
16
+ * Whether to toggle the open state with repeated clicks.
17
+ * @default true
18
+ */
19
+ toggle?: boolean | undefined;
20
+ /**
21
+ * Whether to ignore the logic for mouse input (for example, if `useHover()`
22
+ * is also being used).
23
+ * @default false
24
+ */
25
+ ignoreMouse?: boolean | undefined;
26
+ /**
27
+ * Whether to add keyboard handlers (Enter and Space key functionality) for
28
+ * non-button elements (to open/close the floating element via keyboard
29
+ * “click”).
30
+ * @default true
31
+ */
32
+ keyboardHandlers?: boolean | undefined;
33
+ /**
34
+ * If already open from another event such as the `useHover()` Hook,
35
+ * determines whether to keep the floating element open when clicking the
36
+ * reference element for the first time.
37
+ * @default true
38
+ */
39
+ stickIfOpen?: boolean | undefined;
40
+ }
41
+ /**
42
+ * Opens or closes the floating element when clicking the reference element.
43
+ * @see https://floating-ui.com/docs/useClick
44
+ */
45
+ export declare function useClick(context: FloatingRootContext, props?: UseClickProps): ElementProps;
@@ -0,0 +1,32 @@
1
+ import type { ElementProps, FloatingRootContext } from '../types';
2
+ export interface UseClientPointProps {
3
+ /**
4
+ * Whether the Hook is enabled, including all internal Effects and event
5
+ * handlers.
6
+ * @default true
7
+ */
8
+ enabled?: boolean | undefined;
9
+ /**
10
+ * Whether to restrict the client point to an axis and use the reference
11
+ * element (if it exists) as the other axis. This can be useful if the
12
+ * floating element is also interactive.
13
+ * @default 'both'
14
+ */
15
+ axis?: 'x' | 'y' | 'both' | undefined;
16
+ /**
17
+ * An explicitly defined `x` client coordinate.
18
+ * @default null
19
+ */
20
+ x?: number | null | undefined;
21
+ /**
22
+ * An explicitly defined `y` client coordinate.
23
+ * @default null
24
+ */
25
+ y?: number | null | undefined;
26
+ }
27
+ /**
28
+ * Positions the floating element relative to a client point (in the viewport),
29
+ * such as the mouse position. By default, it follows the mouse cursor.
30
+ * @see https://floating-ui.com/docs/useClientPoint
31
+ */
32
+ export declare function useClientPoint(context: FloatingRootContext, props?: UseClientPointProps): ElementProps;
@@ -0,0 +1,80 @@
1
+ import type { ElementProps, FloatingRootContext } from '../types';
2
+ export declare const normalizeProp: (normalizable?: boolean | {
3
+ escapeKey?: boolean | undefined;
4
+ outsidePress?: boolean | undefined;
5
+ }) => {
6
+ escapeKey: boolean;
7
+ outsidePress: boolean;
8
+ };
9
+ export interface UseDismissProps {
10
+ /**
11
+ * Whether the Hook is enabled, including all internal Effects and event
12
+ * handlers.
13
+ * @default true
14
+ */
15
+ enabled?: boolean | undefined;
16
+ /**
17
+ * Whether to dismiss the floating element upon pressing the `esc` key.
18
+ * @default true
19
+ */
20
+ escapeKey?: boolean | undefined;
21
+ /**
22
+ * Whether to dismiss the floating element upon pressing the reference
23
+ * element. You likely want to ensure the `move` option in the `useHover()`
24
+ * Hook has been disabled when this is in use.
25
+ * @default false
26
+ */
27
+ referencePress?: boolean | undefined;
28
+ /**
29
+ * The type of event to use to determine a “press”.
30
+ * - `pointerdown` is eager on both mouse + touch input.
31
+ * - `mousedown` is eager on mouse input, but lazy on touch input.
32
+ * - `click` is lazy on both mouse + touch input.
33
+ * @default 'pointerdown'
34
+ */
35
+ referencePressEvent?: 'pointerdown' | 'mousedown' | 'click' | undefined;
36
+ /**
37
+ * Whether to dismiss the floating element upon pressing outside of the
38
+ * floating element.
39
+ * If you have another element, like a toast, that is rendered outside the
40
+ * floating element’s React tree and don’t want the floating element to close
41
+ * when pressing it, you can guard the check like so:
42
+ * ```jsx
43
+ * useDismiss(context, {
44
+ * outsidePress: (event) => !event.target.closest('.toast'),
45
+ * });
46
+ * ```
47
+ * @default true
48
+ */
49
+ outsidePress?: boolean | ((event: MouseEvent) => boolean) | undefined;
50
+ /**
51
+ * The type of event to use to determine an outside “press”.
52
+ * - `pointerdown` is eager on both mouse + touch input.
53
+ * - `mousedown` is eager on mouse input, but lazy on touch input.
54
+ * - `click` is lazy on both mouse + touch input.
55
+ * @default 'pointerdown'
56
+ */
57
+ outsidePressEvent?: 'pointerdown' | 'mousedown' | 'click' | undefined;
58
+ /**
59
+ * Whether to dismiss the floating element upon scrolling an overflow
60
+ * ancestor.
61
+ * @default false
62
+ */
63
+ ancestorScroll?: boolean | undefined;
64
+ /**
65
+ * Determines whether event listeners bubble upwards through a tree of
66
+ * floating elements.
67
+ */
68
+ bubbles?: boolean | {
69
+ escapeKey?: boolean | undefined;
70
+ outsidePress?: boolean | undefined;
71
+ } | undefined;
72
+ /**
73
+ * Determines whether to use capture phase event listeners.
74
+ */
75
+ capture?: boolean | {
76
+ escapeKey?: boolean | undefined;
77
+ outsidePress?: boolean | undefined;
78
+ } | undefined;
79
+ }
80
+ export declare function useDismiss(context: FloatingRootContext, props?: UseDismissProps): ElementProps;
@@ -0,0 +1,18 @@
1
+ import type { ReferenceType, UseFloatingOptions, UseFloatingReturn } from '../types';
2
+ /**
3
+ * actview 版(upstream 为 @floating-ui/react 的 useFloating)。
4
+ *
5
+ * 与 upstream 的差异:
6
+ * - 定位核心直接调用 `@floating-ui/dom` 的 computePosition(actview 版
7
+ * `src/useFloating.ts`,无 @floating-ui/react-dom 依赖)
8
+ * - `React.useState` → `ref()`;`useModernLayoutEffect` → `watch`
9
+ * - `computedElements`(rootContext.elements)字段为 `Ref` → `.value` /
10
+ * 直接传 Ref 给定位核心(内部 toValue)
11
+ * - `nodeId` 支持 `string | Ref<string | undefined>`(toValue 读取)
12
+ * - 无 React 合成事件 / useCallback / useMemo
13
+ */
14
+ /**
15
+ * Provides data to position a floating element and context to add interactions.
16
+ * @see https://floating-ui.com/docs/useFloating
17
+ */
18
+ export declare function useFloating<RT extends ReferenceType = ReferenceType>({ elements: elementsOption, ...options }?: UseFloatingOptions<RT>): UseFloatingReturn<RT>;
@@ -0,0 +1,22 @@
1
+ import { type Ref } from '@actview/core';
2
+ import type { FloatingRootContext, OpenChangeReason } from '../types';
3
+ /**
4
+ * actview 版(upstream 为 React hook)。
5
+ *
6
+ * 与 upstream 的差异:
7
+ * - `React.useRef` → `ref()`;`React.useState` → `ref()` / 直接创建
8
+ * - `open` 为 `computed(() => toValue(options.open) ?? false)`——options.open
9
+ * 支持 boolean 或 `Ref<boolean>`(useFloating 传 Ref 时响应式追踪)
10
+ * - `elements` 字段为 `Ref`(reference / domReference 用 computed 派生,
11
+ * floating 固定为首次值——elementsProp 在 setup 解构固定)
12
+ * - `useEffectEvent` 从 `../utils` 导入
13
+ */
14
+ export interface UseFloatingRootContextOptions {
15
+ open?: boolean | Ref<boolean> | undefined;
16
+ onOpenChange?: ((open: boolean, event?: Event, reason?: OpenChangeReason) => void) | undefined;
17
+ elements: {
18
+ reference: Element | null;
19
+ floating: HTMLElement | null;
20
+ };
21
+ }
22
+ export declare function useFloatingRootContext(options: UseFloatingRootContextOptions): FloatingRootContext;
@@ -0,0 +1,21 @@
1
+ import type { ElementProps, FloatingRootContext } from '../types';
2
+ export interface UseFocusProps {
3
+ /**
4
+ * Whether the Hook is enabled, including all internal Effects and event
5
+ * handlers.
6
+ * @default true
7
+ */
8
+ enabled?: boolean | undefined;
9
+ /**
10
+ * Whether the open state only changes if the focus event is considered
11
+ * visible (`:focus-visible` CSS selector).
12
+ * @default true
13
+ */
14
+ visibleOnly?: boolean | undefined;
15
+ }
16
+ /**
17
+ * Opens the floating element while the reference element has focus, like CSS
18
+ * `:focus`.
19
+ * @see https://floating-ui.com/docs/useFocus
20
+ */
21
+ export declare function useFocus(context: FloatingRootContext, props?: UseFocusProps): ElementProps;
@@ -0,0 +1,57 @@
1
+ import type { Delay, ElementProps, FloatingContext, FloatingRootContext, FloatingTreeType, SafePolygonOptions } from '../types';
2
+ export interface HandleCloseContext extends Omit<FloatingContext, 'x' | 'y'> {
3
+ onClose: () => void;
4
+ tree?: FloatingTreeType | null | undefined;
5
+ leave?: boolean | undefined;
6
+ x: number;
7
+ y: number;
8
+ }
9
+ export interface HandleClose {
10
+ (context: HandleCloseContext): (event: MouseEvent) => void;
11
+ __options?: SafePolygonOptions | undefined;
12
+ }
13
+ export declare function getDelay(value: UseHoverProps['delay'], prop: 'open' | 'close', pointerType?: PointerEvent['pointerType']): number | undefined;
14
+ export interface UseHoverProps {
15
+ /**
16
+ * Whether the Hook is enabled, including all internal Effects and event
17
+ * handlers.
18
+ * @default true
19
+ */
20
+ enabled?: boolean | undefined;
21
+ /**
22
+ * Accepts an event handler that runs on `mousemove` to control when the
23
+ * floating element closes once the cursor leaves the reference element.
24
+ * @default null
25
+ */
26
+ handleClose?: HandleClose | null | undefined;
27
+ /**
28
+ * Waits until the user’s cursor is at “rest” over the reference element
29
+ * before changing the `open` state.
30
+ * @default 0
31
+ */
32
+ restMs?: number | (() => number) | undefined;
33
+ /**
34
+ * Waits for the specified time when the event listener runs before changing
35
+ * the `open` state.
36
+ * @default 0
37
+ */
38
+ delay?: Delay | (() => Delay) | undefined;
39
+ /**
40
+ * Whether the logic only runs for mouse input, ignoring touch input.
41
+ * Note: due to a bug with Linux Chrome, "pen" inputs are considered "mouse".
42
+ * @default false
43
+ */
44
+ mouseOnly?: boolean | undefined;
45
+ /**
46
+ * Whether moving the cursor over the floating element will open it, without a
47
+ * regular hover event required.
48
+ * @default true
49
+ */
50
+ move?: boolean | undefined;
51
+ }
52
+ /**
53
+ * Opens the floating element while hovering over the reference element, like
54
+ * CSS `:hover`.
55
+ * @see https://floating-ui.com/docs/useHover
56
+ */
57
+ export declare function useHover(context: FloatingRootContext, props?: UseHoverProps): ElementProps;
@@ -0,0 +1,11 @@
1
+ import { type Ref } from '@actview/core';
2
+ /**
3
+ * Returns a stable unique id for the floating element.
4
+ * @see https://floating-ui.com/docs/react-utils#useid
5
+ *
6
+ * actview 为客户端渲染(无 hydration 匹配需求),id 在 setup 同步生成,
7
+ * 保证父组件的 nodeId 在子组件挂载前就绪(FloatingNode 的 value.id /
8
+ * useFloatingParentNodeId 依赖它;延迟到 onMounted 会让嵌套 FloatingTree
9
+ * 判断读到 null,产生双 FloatingTree)。
10
+ */
11
+ export declare function useId(): Ref<string | undefined>;
@@ -0,0 +1,13 @@
1
+ import type { ElementProps, ExtendedUserProps } from '../types';
2
+ export interface UseInteractionsReturn {
3
+ getReferenceProps: (userProps?: Record<string, unknown>) => Record<string, unknown>;
4
+ getFloatingProps: (userProps?: Record<string, unknown>) => Record<string, unknown>;
5
+ getItemProps: (userProps?: Omit<Record<string, unknown>, 'selected' | 'active'> & ExtendedUserProps) => Record<string, unknown>;
6
+ }
7
+ /**
8
+ * Merges an array of interaction hooks' props into prop getters, allowing
9
+ * event handler functions to be composed together without overwriting one
10
+ * another.
11
+ * @see https://floating-ui.com/docs/useInteractions
12
+ */
13
+ export declare function useInteractions(propsList?: Array<ElementProps | void>): UseInteractionsReturn;
@@ -0,0 +1,176 @@
1
+ import { type Ref } from '@actview/core';
2
+ import type { Dimensions, ElementProps, FloatingRootContext } from '../types';
3
+ import { gridNavigation } from './gridNavigation';
4
+ /**
5
+ * actview 版(upstream 为 React hook)。
6
+ *
7
+ * 与 upstream 的差异:
8
+ * - `React.useRef` → `ref()`;`React.useState` → `ref()`(activeId / virtualId)
9
+ * - `useModernLayoutEffect` → `watch`(依赖追踪;previous* 状态同步放在
10
+ * 最后注册的 watch,保持"读上次值"语义)
11
+ * - `activeIndex` / `selectedIndex` 接受 `Ref<number | null> | number | null`,
12
+ * 内部用 `toValue` 统一读取(传 Ref 时 watch 响应式同步)
13
+ * - reference / floating 为 `computed`(响应式 aria 派生),mergeProps 用
14
+ * `unref` 解包;`floatingFocusElement` / `typeableComboboxReference` 也用
15
+ * computed(floating / domReference 挂载后才非空)
16
+ * - `virtualItemRef` 为 `Ref<HTMLElement | null>`(.value)
17
+ * - 无 React 合成事件:`event.nativeEvent` → 直接传 `event`;
18
+ * `event.currentTarget` 为 `EventTarget | null`(断言为 HTMLElement)
19
+ * - `tree.nodesRef.current` → `.value`;`deepestNode.context.elements.*` → `.value`
20
+ * - props 标量在 setup 解构固定
21
+ */
22
+ export declare const ESCAPE = "Escape";
23
+ export interface UseListNavigationProps {
24
+ /**
25
+ * A ref that holds an array of list items.
26
+ * @default empty list
27
+ */
28
+ listRef: Ref<Array<HTMLElement | null>>;
29
+ /**
30
+ * The index of the currently active (focused or highlighted) item, which may
31
+ * or may not be selected.
32
+ * @default null
33
+ */
34
+ activeIndex: Ref<number | null> | number | null;
35
+ /**
36
+ * A callback that is called when the user navigates to a new active item,
37
+ * passed in a new `activeIndex`.
38
+ */
39
+ onNavigate?: ((activeIndex: number | null) => void) | undefined;
40
+ /**
41
+ * Whether the Hook is enabled, including all internal Effects and event
42
+ * handlers.
43
+ * @default true
44
+ */
45
+ enabled?: boolean | undefined;
46
+ /**
47
+ * The currently selected item index, which may or may not be active.
48
+ * @default null
49
+ */
50
+ selectedIndex?: Ref<number | null> | number | null | undefined;
51
+ /**
52
+ * Whether to focus the item upon opening the floating element. 'auto' infers
53
+ * what to do based on the input type (keyboard vs. pointer), while a boolean
54
+ * value will force the value.
55
+ * @default 'auto'
56
+ */
57
+ focusItemOnOpen?: boolean | 'auto' | undefined;
58
+ /**
59
+ * Whether hovering an item synchronizes the focus.
60
+ * @default true
61
+ */
62
+ focusItemOnHover?: boolean | undefined;
63
+ /**
64
+ * Whether pressing an arrow key on the navigation’s main axis opens the
65
+ * floating element.
66
+ * @default true
67
+ */
68
+ openOnArrowKeyDown?: boolean | undefined;
69
+ /**
70
+ * By default elements with either a `disabled` or `aria-disabled` attribute
71
+ * are skipped in the list navigation — however, this requires the items to
72
+ * be rendered.
73
+ * This prop allows you to manually specify indices which should be disabled,
74
+ * overriding the default logic.
75
+ * For Windows-style select menus, where the menu does not open when
76
+ * navigating via arrow keys, specify an empty array.
77
+ * @default undefined
78
+ */
79
+ disabledIndices?: Array<number> | ((index: number) => boolean) | undefined;
80
+ /**
81
+ * Determines whether focus can escape the list, such that nothing is selected
82
+ * after navigating beyond the boundary of the list. In some
83
+ * autocomplete/combobox components, this may be desired, as screen
84
+ * readers will return to the input.
85
+ * `loop` must be `true`.
86
+ * @default false
87
+ */
88
+ allowEscape?: boolean | undefined;
89
+ /**
90
+ * Determines whether focus should loop around when navigating past the first
91
+ * or last item.
92
+ * @default false
93
+ */
94
+ loop?: boolean | undefined;
95
+ /**
96
+ * If the list is nested within another one (e.g. a nested submenu), the
97
+ * navigation semantics change.
98
+ * @default false
99
+ */
100
+ nested?: boolean | undefined;
101
+ /**
102
+ * Allows to specify the orientation of the parent list, which is used to
103
+ * determine the direction of the navigation.
104
+ * This is useful when list navigation is used within a Composite,
105
+ * as the hook can't determine the orientation of the parent list automatically.
106
+ */
107
+ parentOrientation?: UseListNavigationProps['orientation'] | undefined;
108
+ /**
109
+ * Whether the direction of the floating element’s navigation is in RTL
110
+ * layout.
111
+ * @default false
112
+ */
113
+ rtl?: boolean | undefined;
114
+ /**
115
+ * Whether the focus is virtual (using `aria-activedescendant`).
116
+ * Use this if you need focus to remain on the reference element
117
+ * (such as an input), but allow arrow keys to navigate list items.
118
+ * This is common in autocomplete listbox components.
119
+ * Your virtually-focused list items must have a unique `id` set on them.
120
+ * If you’re using a component role with the `useRole()` Hook, then an `id` is
121
+ * generated automatically.
122
+ * @default false
123
+ */
124
+ virtual?: boolean | undefined;
125
+ /**
126
+ * The orientation in which navigation occurs.
127
+ * @default 'vertical'
128
+ */
129
+ orientation?: 'vertical' | 'horizontal' | 'both' | undefined;
130
+ /**
131
+ * Specifies how many columns the list has (i.e., it’s a grid). Use an
132
+ * orientation of 'horizontal' (e.g. for an emoji picker/date picker, where
133
+ * pressing ArrowRight or ArrowLeft can change rows), or 'both' (where the
134
+ * current row cannot be escaped with ArrowRight or ArrowLeft, only ArrowUp
135
+ * and ArrowDown).
136
+ * @default 1
137
+ */
138
+ cols?: number | undefined;
139
+ /**
140
+ * base-ui 变体:注入式网格导航(grid-capable consumers 传入)。
141
+ * 替代上游 `cols` 的单元格映射,支持 DOM 行结构检测(`role="row"`)、
142
+ * 虚拟化间隙与部分行回退。传入后优先于 `cols` 生效。
143
+ * 位置参数签名与 `gridNavigation` 锁定(经 `typeof`)。
144
+ */
145
+ grid?: typeof gridNavigation | null | undefined;
146
+ /**
147
+ * Whether to scroll the active item into view when navigating. The default
148
+ * value uses nearest options.
149
+ */
150
+ scrollItemIntoView?: boolean | ScrollIntoViewOptions | undefined;
151
+ /**
152
+ * When using virtual focus management, this holds a ref to the
153
+ * virtually-focused item. This allows nested virtual navigation to be
154
+ * enabled, and lets you know when a nested element is virtually focused from
155
+ * the root reference handling the events. Requires `FloatingTree` to be
156
+ * setup.
157
+ */
158
+ virtualItemRef?: Ref<HTMLElement | null> | undefined;
159
+ /**
160
+ * Only for `cols > 1`, specify sizes for grid items.
161
+ * `{ width: 2, height: 2 }` means an item is 2 columns wide and 2 rows tall.
162
+ */
163
+ itemSizes?: Dimensions[] | undefined;
164
+ /**
165
+ * Only relevant for `cols > 1` and items with different sizes, specify if
166
+ * the grid is dense (as defined in the CSS spec for `grid-auto-flow`).
167
+ * @default false
168
+ */
169
+ dense?: boolean | undefined;
170
+ }
171
+ /**
172
+ * Adds arrow key-based navigation of a list of items, either using real DOM
173
+ * focus or virtual focus.
174
+ * @see https://floating-ui.com/docs/useListNavigation
175
+ */
176
+ export declare function useListNavigation(context: FloatingRootContext, props: UseListNavigationProps): ElementProps;
@@ -0,0 +1,20 @@
1
+ import { type Ref } from '@actview/core';
2
+ /**
3
+ * actview 版(upstream 为 React hook:useRef/useCallback/useMemo 缓存 + ref cleanup)。
4
+ *
5
+ * 与 upstream 的差异:
6
+ * - 对象 ref 为 actview 框架类型 `Ref<T>`(.value,非 React 的 .current)
7
+ * - 无 useMemo/useCallback:每次调用返回新闭包,需要稳定引用的调用方自行缓存
8
+ * (如在 setup 中调用一次)
9
+ * - React 18 的 ref cleanup 由合并函数自行管理:函数 ref 的返回值(cleanup)
10
+ * 在下次调用同位置 ref 前执行(React 语义:先 cleanup 再 ref 新值);
11
+ * 卸载(value 为 null)且存在 cleanup 时只调 cleanup、不调 ref(null)
12
+ * (对齐 React 的 commitDetachRef:有 cleanup 的 ref 卸载时不再收到 null)
13
+ */
14
+ type MergeableRef<Instance> = ((instance: Instance | null) => void | (() => void)) | Ref<Instance | null>;
15
+ /**
16
+ * Merges an array of refs into a single callback ref or `null`.
17
+ * @see https://floating-ui.com/docs/react-utils#usemergerefs
18
+ */
19
+ export declare function useMergeRefs<Instance>(refs: Array<MergeableRef<Instance> | undefined>): null | ((instance: Instance | null) => void);
20
+ export {};
@@ -0,0 +1,33 @@
1
+ import type { ElementProps, FloatingRootContext } from '../types';
2
+ /**
3
+ * actview 版(upstream 为 React hook)。
4
+ *
5
+ * 与 upstream 的差异:
6
+ * - reference / floating 为 `computed`(响应式派生:open / floatingId / referenceId
7
+ * 变化时重建),mergeProps 用 `unref` 解包
8
+ * - item 为普通函数(闭包读 `floatingId.value`,每次调用取最新值)
9
+ * - `useId` 返回 `Ref<string | undefined>`(.value)
10
+ * - props 标量(enabled / role)在 setup 解构固定
11
+ */
12
+ type AriaRole = 'tooltip' | 'dialog' | 'alertdialog' | 'menu' | 'listbox' | 'grid' | 'tree';
13
+ type ComponentRole = 'select' | 'label' | 'combobox';
14
+ export interface UseRoleProps {
15
+ /**
16
+ * Whether the Hook is enabled, including all internal Effects and event
17
+ * handlers.
18
+ * @default true
19
+ */
20
+ enabled?: boolean | undefined;
21
+ /**
22
+ * The role of the floating element.
23
+ * @default 'dialog'
24
+ */
25
+ role?: AriaRole | ComponentRole | undefined;
26
+ }
27
+ /**
28
+ * Adds base screen reader props to the reference and floating elements for a
29
+ * given floating element `role`.
30
+ * @see https://floating-ui.com/docs/useRole
31
+ */
32
+ export declare function useRole(context: FloatingRootContext, props?: UseRoleProps): ElementProps;
33
+ export {};
@@ -0,0 +1,68 @@
1
+ import { type Ref } from '@actview/core';
2
+ import type { FloatingContext, Placement, ReferenceType, Side } from '../types';
3
+ /**
4
+ * actview 版(upstream 为 React hook)。
5
+ *
6
+ * 与 upstream 的差异:
7
+ * - `React.useState` → `ref()`;状态机(status / isMounted / styles)返回 `Ref<T>`,
8
+ * 调用方渲染期读 `.value`
9
+ * - `React.useEffect` / `useModernLayoutEffect` → `watch`(依赖追踪 + immediate)
10
+ * - 无 ReactDOM.flushSync:rAF 回调里直接赋值,actview 自行调度渲染
11
+ * - `useLatestRef` 从 `../utils` 导入
12
+ * - `React.CSSProperties` → `Record<string, string | number>`(actview 样式对象)
13
+ */
14
+ type Duration = number | {
15
+ open?: number | undefined;
16
+ close?: number | undefined;
17
+ };
18
+ export interface UseTransitionStatusProps {
19
+ /**
20
+ * The duration of the transition in milliseconds, or an object containing
21
+ * `open` and `close` keys for different durations.
22
+ */
23
+ duration?: Duration | undefined;
24
+ }
25
+ type TransitionStatus = 'unmounted' | 'initial' | 'open' | 'close';
26
+ /**
27
+ * Provides a status string to apply CSS transitions to a floating element,
28
+ * correctly handling placement-aware transitions.
29
+ * @see https://floating-ui.com/docs/useTransition#usetransitionstatus
30
+ */
31
+ export declare function useTransitionStatus(context: FloatingContext, props?: UseTransitionStatusProps): {
32
+ isMounted: Ref<boolean>;
33
+ status: Ref<TransitionStatus>;
34
+ };
35
+ type CSSStylesProperty = Record<string, string | number> | ((params: {
36
+ side: Side;
37
+ placement: Placement;
38
+ }) => Record<string, string | number>);
39
+ export interface UseTransitionStylesProps extends UseTransitionStatusProps {
40
+ /**
41
+ * The styles to apply when the floating element is initially mounted.
42
+ */
43
+ initial?: CSSStylesProperty | undefined;
44
+ /**
45
+ * The styles to apply when the floating element is transitioning to the
46
+ * `open` state.
47
+ */
48
+ open?: CSSStylesProperty | undefined;
49
+ /**
50
+ * The styles to apply when the floating element is transitioning to the
51
+ * `close` state.
52
+ */
53
+ close?: CSSStylesProperty | undefined;
54
+ /**
55
+ * The styles to apply to all states.
56
+ */
57
+ common?: CSSStylesProperty | undefined;
58
+ }
59
+ /**
60
+ * Provides styles to apply CSS transitions to a floating element, correctly
61
+ * handling placement-aware transitions. Wrapper around `useTransitionStatus`.
62
+ * @see https://floating-ui.com/docs/useTransition#usetransitionstyles
63
+ */
64
+ export declare function useTransitionStyles<RT extends ReferenceType = ReferenceType>(context: FloatingContext<RT>, props?: UseTransitionStylesProps): {
65
+ isMounted: Ref<boolean>;
66
+ styles: Ref<Record<string, string | number>>;
67
+ };
68
+ export {};
@@ -0,0 +1,66 @@
1
+ import { type Ref } from '@actview/core';
2
+ import type { ElementProps, FloatingRootContext } from '../types';
3
+ /**
4
+ * actview 版(upstream 为 React hook)。
5
+ *
6
+ * 与 upstream 的差异:
7
+ * - `React.useRef` → `ref()`;`useModernLayoutEffect` → `watch`
8
+ * - `activeIndex` / `selectedIndex` 接受 `Ref<number | null> | number | null`,
9
+ * 内部用 `toValue` 统一读取(传入 Ref 时 watch 响应式同步 prevIndexRef)
10
+ * - `listRef` 为 `Ref<Array<string | null>>`(.value)
11
+ * - 无 React 合成事件:onKeyDown 参数为原生 KeyboardEvent
12
+ * - `useEffectEvent` / `useLatestRef` / `stopEvent` 从 `../utils` 导入
13
+ */
14
+ export interface UseTypeaheadProps {
15
+ /**
16
+ * A ref which contains an array of strings whose indices match the HTML
17
+ * elements of the list.
18
+ * @default empty list
19
+ */
20
+ listRef: Ref<Array<string | null>>;
21
+ /**
22
+ * The index of the active (focused or highlighted) item in the list.
23
+ * @default null
24
+ */
25
+ activeIndex: Ref<number | null> | number | null;
26
+ /**
27
+ * Callback invoked with the matching index if found as the user types.
28
+ */
29
+ onMatch?: ((index: number) => void) | undefined;
30
+ /**
31
+ * Callback invoked with the typing state as the user types.
32
+ */
33
+ onTypingChange?: ((isTyping: boolean) => void) | undefined;
34
+ /**
35
+ * Whether the Hook is enabled, including all internal Effects and event
36
+ * handlers.
37
+ * @default true
38
+ */
39
+ enabled?: boolean | undefined;
40
+ /**
41
+ * A function that returns the matching string from the list.
42
+ * @default lowercase-finder
43
+ */
44
+ findMatch?: null | ((list: Array<string | null>, typedString: string) => string | null | undefined) | undefined;
45
+ /**
46
+ * The number of milliseconds to wait before resetting the typed string.
47
+ * @default 750
48
+ */
49
+ resetMs?: number | undefined;
50
+ /**
51
+ * An array of keys to ignore when typing.
52
+ * @default []
53
+ */
54
+ ignoreKeys?: Array<string> | undefined;
55
+ /**
56
+ * The index of the selected item in the list, if available.
57
+ * @default null
58
+ */
59
+ selectedIndex?: Ref<number | null> | number | null | undefined;
60
+ }
61
+ /**
62
+ * Provides a matching callback that can be used to focus an item as the user
63
+ * types, often used in tandem with `useListNavigation()`.
64
+ * @see https://floating-ui.com/docs/useTypeahead
65
+ */
66
+ export declare function useTypeahead(context: FloatingRootContext, props: UseTypeaheadProps): ElementProps;