@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.
- package/LICENSE +21 -0
- package/dist/_deprecated-inner.d.ts +82 -0
- package/dist/components/Composite.d.ts +109 -0
- package/dist/components/FloatingArrow.d.ts +66 -0
- package/dist/components/FloatingDelayGroup.d.ts +70 -0
- package/dist/components/FloatingFocusManager.d.ts +92 -0
- package/dist/components/FloatingList.d.ts +43 -0
- package/dist/components/FloatingOverlay.d.ts +18 -0
- package/dist/components/FloatingPortal.d.ts +63 -0
- package/dist/components/FloatingTree.d.ts +45 -0
- package/dist/components/FocusGuard.d.ts +19 -0
- package/dist/components/NextFloatingDelayGroup.d.ts +57 -0
- package/dist/floating-ui.actview.d.mts +37 -0
- package/dist/floating-ui.actview.d.ts +37 -0
- package/dist/floating-ui.actview.esm.js +6688 -0
- package/dist/floating-ui.actview.mjs +6688 -0
- package/dist/floating-ui.actview.umd.js +6772 -0
- package/dist/floating-ui.actview.umd.min.js +1 -0
- package/dist/floating-ui.actview.utils.d.mts +7 -0
- package/dist/floating-ui.actview.utils.d.ts +7 -0
- package/dist/floating-ui.actview.utils.esm.js +587 -0
- package/dist/floating-ui.actview.utils.mjs +587 -0
- package/dist/floating-ui.actview.utils.umd.js +634 -0
- package/dist/floating-ui.actview.utils.umd.min.js +1 -0
- package/dist/hooks/gridNavigation.d.ts +39 -0
- package/dist/hooks/useClick.d.ts +45 -0
- package/dist/hooks/useClientPoint.d.ts +32 -0
- package/dist/hooks/useDismiss.d.ts +80 -0
- package/dist/hooks/useFloating.d.ts +18 -0
- package/dist/hooks/useFloatingRootContext.d.ts +22 -0
- package/dist/hooks/useFocus.d.ts +21 -0
- package/dist/hooks/useHover.d.ts +57 -0
- package/dist/hooks/useId.d.ts +11 -0
- package/dist/hooks/useInteractions.d.ts +13 -0
- package/dist/hooks/useListNavigation.d.ts +176 -0
- package/dist/hooks/useMergeRefs.d.ts +20 -0
- package/dist/hooks/useRole.d.ts +33 -0
- package/dist/hooks/useTransition.d.ts +68 -0
- package/dist/hooks/useTypeahead.d.ts +66 -0
- package/dist/index.d.ts +37 -0
- package/dist/safePolygon.d.ts +12 -0
- package/dist/types.d.ts +140 -0
- package/dist/useFloating.d.ts +57 -0
- package/dist/utils/clearTimeoutIfSet.d.ts +2 -0
- package/dist/utils/composite.d.ts +41 -0
- package/dist/utils/constants.d.ts +8 -0
- package/dist/utils/createAttribute.d.ts +1 -0
- package/dist/utils/createEventEmitter.d.ts +5 -0
- package/dist/utils/deepEqual.d.ts +1 -0
- package/dist/utils/element.d.ts +10 -0
- package/dist/utils/enqueueFocus.d.ts +8 -0
- package/dist/utils/event.d.ts +10 -0
- package/dist/utils/getDPR.d.ts +1 -0
- package/dist/utils/hooks.d.ts +16 -0
- package/dist/utils/log.d.ts +2 -0
- package/dist/utils/markOthers.d.ts +4 -0
- package/dist/utils/nodes.d.ts +4 -0
- package/dist/utils/platform.d.ts +6 -0
- package/dist/utils/roundByDPR.d.ts +1 -0
- package/dist/utils/safeReact.d.ts +8 -0
- package/dist/utils/tabbable.d.ts +13 -0
- package/dist/utils/useLiteMergeRefs.d.ts +14 -0
- package/dist/utils.d.ts +7 -0
- package/package.json +83 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @floating-ui/actview — @floating-ui/react 的 actview 版。
|
|
3
|
+
*
|
|
4
|
+
* 导出面与 upstream `packages/react/src/index.ts` 对齐:
|
|
5
|
+
* - utils 工具(`./utils` 子路径同 `@floating-ui/react/utils`)
|
|
6
|
+
* - 交互 hooks(useClick / useDismiss / useHover / useListNavigation / ...)
|
|
7
|
+
* - 组件(FloatingTree / FloatingPortal / FloatingFocusManager / Composite / ...)
|
|
8
|
+
* - safePolygon / inner / useInnerOffset
|
|
9
|
+
*/
|
|
10
|
+
export { Composite, CompositeItem } from './components/Composite';
|
|
11
|
+
export { FloatingArrow } from './components/FloatingArrow';
|
|
12
|
+
export { FloatingDelayGroup, useDelayGroup, useDelayGroupContext, } from './components/FloatingDelayGroup';
|
|
13
|
+
export { NextFloatingDelayGroup, useNextDelayGroup, } from './components/NextFloatingDelayGroup';
|
|
14
|
+
export { FloatingFocusManager } from './components/FloatingFocusManager';
|
|
15
|
+
export { FloatingList, useListItem } from './components/FloatingList';
|
|
16
|
+
export { FloatingOverlay } from './components/FloatingOverlay';
|
|
17
|
+
export { FloatingPortal, useFloatingPortalNode, } from './components/FloatingPortal';
|
|
18
|
+
export { FloatingNode, FloatingTree, useFloatingNodeId, useFloatingParentNodeId, useFloatingTree, } from './components/FloatingTree';
|
|
19
|
+
export { useClick } from './hooks/useClick';
|
|
20
|
+
export { useClientPoint } from './hooks/useClientPoint';
|
|
21
|
+
export { useDismiss } from './hooks/useDismiss';
|
|
22
|
+
export { useFloating } from './hooks/useFloating';
|
|
23
|
+
export { useFloatingRootContext } from './hooks/useFloatingRootContext';
|
|
24
|
+
export { useFocus } from './hooks/useFocus';
|
|
25
|
+
export { useHover } from './hooks/useHover';
|
|
26
|
+
export { useId } from './hooks/useId';
|
|
27
|
+
export { useInteractions } from './hooks/useInteractions';
|
|
28
|
+
export { useListNavigation } from './hooks/useListNavigation';
|
|
29
|
+
export { gridNavigation } from './hooks/gridNavigation';
|
|
30
|
+
export { useMergeRefs } from './hooks/useMergeRefs';
|
|
31
|
+
export { useRole } from './hooks/useRole';
|
|
32
|
+
export { useTransitionStatus, useTransitionStyles } from './hooks/useTransition';
|
|
33
|
+
export { useTypeahead } from './hooks/useTypeahead';
|
|
34
|
+
export { inner, useInnerOffset } from './_deprecated-inner';
|
|
35
|
+
export { safePolygon } from './safePolygon';
|
|
36
|
+
export type * from './types';
|
|
37
|
+
export * from './utils';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { HandleClose } from './hooks/useHover';
|
|
2
|
+
export interface SafePolygonOptions {
|
|
3
|
+
buffer?: number | undefined;
|
|
4
|
+
blockPointerEvents?: boolean | undefined;
|
|
5
|
+
requireIntent?: boolean | undefined;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Generates a safe polygon area that the user can traverse without closing the
|
|
9
|
+
* floating element once leaving the reference element.
|
|
10
|
+
* @see https://floating-ui.com/docs/useHover#safepolygon
|
|
11
|
+
*/
|
|
12
|
+
export declare function safePolygon(options?: SafePolygonOptions): HandleClose;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @floating-ui/actview — 第一阶段类型子集。
|
|
3
|
+
*
|
|
4
|
+
* 只包含 utils 层(nodes.ts / composite.ts)实际引用的类型;
|
|
5
|
+
* hooks/components 阶段将按 upstream `packages/react/src/types.ts` 逐步补全。
|
|
6
|
+
*
|
|
7
|
+
* 与 upstream 的差异:
|
|
8
|
+
* - `React.MutableRefObject<T>` → actview 框架类型 `Ref<T>`(来自 @actview/core,只能读 .value)
|
|
9
|
+
* - `UsePositionFloatingReturn` 为最小结构(upstream 从 @floating-ui/react-dom 导入,
|
|
10
|
+
* actview 在 hooks 阶段实现 useFloating 时补全)
|
|
11
|
+
*/
|
|
12
|
+
import type { Ref } from '@actview/core';
|
|
13
|
+
import type { Dimensions, Middleware, MiddlewareData, Placement, Platform, Rect, Side, Strategy, VirtualElement } from '@floating-ui/dom';
|
|
14
|
+
export type { Dimensions, Middleware, Placement, Rect, Side };
|
|
15
|
+
export type { SafePolygonOptions } from './safePolygon';
|
|
16
|
+
export type Delay = number | Partial<{
|
|
17
|
+
open: number | undefined;
|
|
18
|
+
close: number | undefined;
|
|
19
|
+
}>;
|
|
20
|
+
export type Alignment = 'start' | 'end';
|
|
21
|
+
export type ReferenceType = Element | VirtualElement;
|
|
22
|
+
export type NarrowedElement<T> = T extends Element ? T : Element;
|
|
23
|
+
export interface FloatingEvents {
|
|
24
|
+
emit<T extends string>(event: T, data?: any): void;
|
|
25
|
+
on(event: string, handler: (data: any) => void): void;
|
|
26
|
+
off(event: string, handler: (data: any) => void): void;
|
|
27
|
+
}
|
|
28
|
+
export interface ContextData {
|
|
29
|
+
openEvent?: Event | undefined;
|
|
30
|
+
floatingContext?: FloatingContext | undefined;
|
|
31
|
+
/** @deprecated use `onTypingChange` prop in `useTypeahead` */
|
|
32
|
+
typing?: boolean | undefined;
|
|
33
|
+
[key: string]: any;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 定位返回值子集(upstream 来自 @floating-ui/react-dom 的 UsePositionFloatingReturn)。
|
|
37
|
+
* actview 版响应式字段为 `Ref<T>`(.value),hooks 阶段实现 useFloating 时补全。
|
|
38
|
+
*/
|
|
39
|
+
export interface UsePositionFloatingReturn {
|
|
40
|
+
x: Ref<number | null>;
|
|
41
|
+
y: Ref<number | null>;
|
|
42
|
+
placement: Ref<Placement>;
|
|
43
|
+
strategy: Ref<Strategy>;
|
|
44
|
+
middlewareData: Ref<MiddlewareData>;
|
|
45
|
+
isPositioned: Ref<boolean>;
|
|
46
|
+
update(): void;
|
|
47
|
+
floatingStyles: Ref<Record<string, string | number>>;
|
|
48
|
+
}
|
|
49
|
+
export interface ExtendedRefs<RT extends ReferenceType = ReferenceType> {
|
|
50
|
+
reference: Ref<ReferenceType | null>;
|
|
51
|
+
floating: Ref<HTMLElement | null>;
|
|
52
|
+
domReference: Ref<NarrowedElement<RT> | null>;
|
|
53
|
+
setReference(node: RT | null): void;
|
|
54
|
+
setFloating(node: HTMLElement | null): void;
|
|
55
|
+
setPositionReference(node: ReferenceType | null): void;
|
|
56
|
+
}
|
|
57
|
+
export interface ExtendedElements<RT extends ReferenceType = ReferenceType> {
|
|
58
|
+
reference: Ref<ReferenceType | null>;
|
|
59
|
+
floating: Ref<HTMLElement | null>;
|
|
60
|
+
domReference: Ref<Element | null>;
|
|
61
|
+
}
|
|
62
|
+
export type OpenChangeReason = 'outside-press' | 'escape-key' | 'ancestor-scroll' | 'reference-press' | 'click' | 'hover' | 'focus' | 'focus-out' | 'list-navigation' | 'safe-polygon';
|
|
63
|
+
export interface FloatingRootContext<RT extends ReferenceType = ReferenceType> {
|
|
64
|
+
dataRef: Ref<ContextData>;
|
|
65
|
+
open: Ref<boolean>;
|
|
66
|
+
onOpenChange(open: boolean, event?: Event, reason?: OpenChangeReason): void;
|
|
67
|
+
elements: {
|
|
68
|
+
domReference: Ref<Element | null>;
|
|
69
|
+
reference: Ref<RT | null>;
|
|
70
|
+
floating: Ref<HTMLElement | null>;
|
|
71
|
+
};
|
|
72
|
+
events: FloatingEvents;
|
|
73
|
+
floatingId: Ref<string | undefined>;
|
|
74
|
+
refs: {
|
|
75
|
+
setPositionReference(node: ReferenceType | null): void;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export type FloatingContext<RT extends ReferenceType = ReferenceType> = Omit<UsePositionFloatingReturn, 'refs' | 'elements'> & {
|
|
79
|
+
open: Ref<boolean>;
|
|
80
|
+
onOpenChange(open: boolean, event?: Event, reason?: OpenChangeReason): void;
|
|
81
|
+
events: FloatingEvents;
|
|
82
|
+
dataRef: Ref<ContextData>;
|
|
83
|
+
nodeId: Ref<string | undefined>;
|
|
84
|
+
floatingId: Ref<string | undefined>;
|
|
85
|
+
refs: ExtendedRefs<RT>;
|
|
86
|
+
elements: ExtendedElements<RT>;
|
|
87
|
+
};
|
|
88
|
+
export interface FloatingNodeType<RT extends ReferenceType = ReferenceType> {
|
|
89
|
+
id: string | undefined;
|
|
90
|
+
parentId: string | null;
|
|
91
|
+
context?: FloatingContext<RT> | undefined;
|
|
92
|
+
}
|
|
93
|
+
export interface FloatingTreeType<RT extends ReferenceType = ReferenceType> {
|
|
94
|
+
nodesRef: Ref<Array<FloatingNodeType<RT>>>;
|
|
95
|
+
events: FloatingEvents;
|
|
96
|
+
addNode(node: FloatingNodeType): void;
|
|
97
|
+
removeNode(node: FloatingNodeType): void;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* `useFloating` 的选项(upstream 拆分自 @floating-ui/react-dom 的
|
|
101
|
+
* UseFloatingOptions 与 react 包的扩展)。
|
|
102
|
+
* actview 版:`open` / `nodeId` 支持 `Ref<T> | 值`;`rootContext` 可外部注入。
|
|
103
|
+
*/
|
|
104
|
+
export interface UseFloatingOptions<RT extends ReferenceType = ReferenceType> {
|
|
105
|
+
open?: boolean | Ref<boolean> | undefined;
|
|
106
|
+
onOpenChange?: ((open: boolean, event?: Event, reason?: OpenChangeReason) => void) | undefined;
|
|
107
|
+
placement?: Placement | undefined;
|
|
108
|
+
strategy?: Strategy | undefined;
|
|
109
|
+
middleware?: Array<Middleware> | undefined;
|
|
110
|
+
platform?: Platform | undefined;
|
|
111
|
+
transform?: boolean | undefined;
|
|
112
|
+
whileElementsMounted?: ((reference: RT, floating: HTMLElement, update: () => void) => () => void) | undefined;
|
|
113
|
+
elements?: {
|
|
114
|
+
reference?: RT | null | undefined;
|
|
115
|
+
floating?: HTMLElement | null | undefined;
|
|
116
|
+
} | undefined;
|
|
117
|
+
rootContext?: FloatingRootContext<RT> | undefined;
|
|
118
|
+
nodeId?: string | Ref<string | undefined> | undefined;
|
|
119
|
+
}
|
|
120
|
+
export type UseFloatingReturn<RT extends ReferenceType = ReferenceType> = UsePositionFloatingReturn & {
|
|
121
|
+
context: FloatingContext<RT>;
|
|
122
|
+
refs: ExtendedRefs<RT>;
|
|
123
|
+
elements: ExtendedElements<RT>;
|
|
124
|
+
};
|
|
125
|
+
/** 事件处理器 props 中用于标记 active/selected 的自定义键(ACTIVE_KEY / SELECTED_KEY) */
|
|
126
|
+
export type ExtendedUserProps = {
|
|
127
|
+
active?: boolean | undefined;
|
|
128
|
+
selected?: boolean | undefined;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* 交互 hook(useClick / useHover / useDismiss / useListNavigation 等)返回的
|
|
132
|
+
* 事件处理器集合,由调用方 spread 到 reference / floating / item 元素上。
|
|
133
|
+
* reference / floating 可为 `Ref`(响应式派生,如 useRole 的 aria 属性随 open 变化);
|
|
134
|
+
* mergeProps 用 `unref` 统一解包。item 的函数形态按调用传入的 active/selected 派生。
|
|
135
|
+
*/
|
|
136
|
+
export interface ElementProps {
|
|
137
|
+
reference?: Record<string, unknown> | Ref<Record<string, unknown>> | undefined;
|
|
138
|
+
floating?: Record<string, unknown> | Ref<Record<string, unknown>> | undefined;
|
|
139
|
+
item?: Record<string, unknown> | Ref<Record<string, unknown>> | ((props: ExtendedUserProps) => Record<string, unknown>) | undefined;
|
|
140
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type Ref } from '@actview/core';
|
|
2
|
+
import { type Middleware, type MiddlewareData, type Placement, type Platform, type Strategy } from '@floating-ui/dom';
|
|
3
|
+
import type { ReferenceType } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* 定位核心(upstream 为 @floating-ui/react-dom 的 useFloating)。
|
|
6
|
+
*
|
|
7
|
+
* 与 upstream 的差异:
|
|
8
|
+
* - 无 React:状态(x / y / placement / strategy / middlewareData / isPositioned)
|
|
9
|
+
* 为 `Ref<T>`,update 结果直接赋值(actview 依赖追踪自动触发渲染)
|
|
10
|
+
* - 无 `ReactDOM.flushSync`(actview 自行调度渲染)
|
|
11
|
+
* - `useModernLayoutEffect` → `watch`(referenceEl / floatingEl 变化时定位 +
|
|
12
|
+
* whileElementsMounted 管理,immediate 首跑)
|
|
13
|
+
* - `open` 支持 `Ref<boolean> | boolean`(`isPositioned` 同步)
|
|
14
|
+
* - `elements.reference` / `elements.floating` 支持 `Ref`(toValue 读取)
|
|
15
|
+
* - 元素/引用统一用宽类型 `ReferenceType`(定位层面无需 RT 细分,
|
|
16
|
+
* `computePosition` 接受 Element | VirtualElement)
|
|
17
|
+
* - `middleware` 固定(setup 一次),无需 latestMiddleware 状态
|
|
18
|
+
* - `floatingStyles` 为 `computed`(`Record<string, string | number>`)
|
|
19
|
+
*/
|
|
20
|
+
export interface UseFloatingOptions {
|
|
21
|
+
placement?: Placement | undefined;
|
|
22
|
+
strategy?: Strategy | undefined;
|
|
23
|
+
middleware?: Array<Middleware> | undefined;
|
|
24
|
+
platform?: Platform | undefined;
|
|
25
|
+
elements?: {
|
|
26
|
+
reference?: ReferenceType | null | Ref<ReferenceType | null> | undefined;
|
|
27
|
+
floating?: HTMLElement | null | Ref<HTMLElement | null> | undefined;
|
|
28
|
+
} | undefined;
|
|
29
|
+
transform?: boolean | undefined;
|
|
30
|
+
whileElementsMounted?: ((reference: ReferenceType, floating: HTMLElement, update: () => void) => () => void) | undefined;
|
|
31
|
+
open?: boolean | Ref<boolean> | undefined;
|
|
32
|
+
}
|
|
33
|
+
export interface UseFloatingReturn {
|
|
34
|
+
x: Ref<number | null>;
|
|
35
|
+
y: Ref<number | null>;
|
|
36
|
+
strategy: Ref<Strategy>;
|
|
37
|
+
placement: Ref<Placement>;
|
|
38
|
+
middlewareData: Ref<MiddlewareData>;
|
|
39
|
+
isPositioned: Ref<boolean>;
|
|
40
|
+
update(): void;
|
|
41
|
+
floatingStyles: Ref<Record<string, string | number>>;
|
|
42
|
+
refs: {
|
|
43
|
+
reference: Ref<ReferenceType | null>;
|
|
44
|
+
floating: Ref<HTMLElement | null>;
|
|
45
|
+
setReference(node: ReferenceType | null): void;
|
|
46
|
+
setFloating(node: HTMLElement | null): void;
|
|
47
|
+
};
|
|
48
|
+
elements: {
|
|
49
|
+
reference: Ref<ReferenceType | null>;
|
|
50
|
+
floating: Ref<HTMLElement | null>;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Provides data to position a floating element.
|
|
55
|
+
* @see https://floating-ui.com/docs/useFloating
|
|
56
|
+
*/
|
|
57
|
+
export declare function useFloating(options?: UseFloatingOptions): UseFloatingReturn;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Ref } from '@actview/core';
|
|
2
|
+
import type { Dimensions } from '../types';
|
|
3
|
+
type ListRef = Ref<Array<HTMLElement | null>>;
|
|
4
|
+
interface KeyboardEventLike {
|
|
5
|
+
key: string;
|
|
6
|
+
preventDefault(): void;
|
|
7
|
+
stopPropagation(): void;
|
|
8
|
+
}
|
|
9
|
+
export type DisabledIndices = Array<number> | ((index: number) => boolean);
|
|
10
|
+
export declare function isDifferentGridRow(index: number, cols: number, prevRow: number): boolean;
|
|
11
|
+
export declare function isIndexOutOfListBounds(listRef: ListRef, index: number): boolean;
|
|
12
|
+
export declare function getMinListIndex(listRef: ListRef, disabledIndices?: DisabledIndices | undefined): number;
|
|
13
|
+
export declare function getMaxListIndex(listRef: ListRef, disabledIndices?: DisabledIndices | undefined): number;
|
|
14
|
+
export declare function findNonDisabledListIndex(listRef: ListRef, { startingIndex, decrement, disabledIndices, amount, }?: {
|
|
15
|
+
startingIndex?: number | undefined;
|
|
16
|
+
decrement?: boolean | undefined;
|
|
17
|
+
disabledIndices?: DisabledIndices | undefined;
|
|
18
|
+
amount?: number | undefined;
|
|
19
|
+
}): number;
|
|
20
|
+
export declare function getGridNavigatedIndex(listRef: ListRef, { event, orientation, loop, rtl, cols, disabledIndices, minIndex, maxIndex, prevIndex, stopEvent: stop, }: {
|
|
21
|
+
event: KeyboardEventLike;
|
|
22
|
+
orientation: 'horizontal' | 'vertical' | 'both';
|
|
23
|
+
loop: boolean;
|
|
24
|
+
rtl: boolean;
|
|
25
|
+
cols: number;
|
|
26
|
+
disabledIndices: DisabledIndices | undefined;
|
|
27
|
+
minIndex: number;
|
|
28
|
+
maxIndex: number;
|
|
29
|
+
prevIndex: number;
|
|
30
|
+
stopEvent?: boolean | undefined;
|
|
31
|
+
}): number;
|
|
32
|
+
/** For each cell index, gets the item index that occupies that cell */
|
|
33
|
+
export declare function createGridCellMap(sizes: Dimensions[], cols: number, dense: boolean): (number | undefined)[];
|
|
34
|
+
/** Gets cell index of an item's corner or -1 when index is -1. */
|
|
35
|
+
export declare function getGridCellIndexOfCorner(index: number, sizes: Dimensions[], cellMap: (number | undefined)[], cols: number, corner: 'tl' | 'tr' | 'bl' | 'br'): number;
|
|
36
|
+
/** Gets all cell indices that correspond to the specified indices */
|
|
37
|
+
export declare function getGridCellIndices(indices: (number | undefined)[], cellMap: (number | undefined)[]): number[];
|
|
38
|
+
export declare function isListIndexDisabled(listRef: ListRef, index: number, disabledIndices?: DisabledIndices): boolean;
|
|
39
|
+
export declare function isHiddenByStyles(styles: CSSStyleDeclaration): boolean;
|
|
40
|
+
export declare function isElementVisible(element: Element | null, styles?: CSSStyleDeclaration | null): boolean;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const FOCUSABLE_ATTRIBUTE = "data-floating-ui-focusable";
|
|
2
|
+
export declare const ACTIVE_KEY = "active";
|
|
3
|
+
export declare const SELECTED_KEY = "selected";
|
|
4
|
+
export declare const TYPEABLE_SELECTOR: string;
|
|
5
|
+
export declare const ARROW_LEFT = "ArrowLeft";
|
|
6
|
+
export declare const ARROW_RIGHT = "ArrowRight";
|
|
7
|
+
export declare const ARROW_UP = "ArrowUp";
|
|
8
|
+
export declare const ARROW_DOWN = "ArrowDown";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createAttribute(name: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function deepEqual(a: any, b: any): boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function activeElement(doc: Document): Element | null;
|
|
2
|
+
export declare function contains(parent?: Element | null, child?: Element | null): boolean;
|
|
3
|
+
export declare function getTarget(event: Event): EventTarget | null;
|
|
4
|
+
export declare function isEventTargetWithin(event: Event, node: Node | null | undefined): boolean;
|
|
5
|
+
export declare function isRootElement(element: Element): boolean;
|
|
6
|
+
export declare function getDocument(node: Element | null): Document;
|
|
7
|
+
export declare function isTypeableElement(element: unknown): boolean;
|
|
8
|
+
export declare function isTypeableCombobox(element: Element | null): boolean;
|
|
9
|
+
export declare function matchesFocusVisible(element: Element | null): boolean;
|
|
10
|
+
export declare function getFloatingFocusElement(floatingElement: HTMLElement | null | undefined): HTMLElement | null;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FocusableElement } from 'tabbable';
|
|
2
|
+
interface Options {
|
|
3
|
+
preventScroll?: boolean | undefined;
|
|
4
|
+
cancelPrevious?: boolean | undefined;
|
|
5
|
+
sync?: boolean | undefined;
|
|
6
|
+
}
|
|
7
|
+
export declare function enqueueFocus(el: FocusableElement | null, options?: Options): void;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface SyntheticEventLike {
|
|
2
|
+
preventDefault(): void;
|
|
3
|
+
stopPropagation(): void;
|
|
4
|
+
nativeEvent?: unknown;
|
|
5
|
+
}
|
|
6
|
+
export declare function stopEvent(event: Event | SyntheticEventLike): void;
|
|
7
|
+
export declare function isReactEvent(event: any): event is SyntheticEventLike;
|
|
8
|
+
export declare function isVirtualClick(event: MouseEvent | PointerEvent): boolean;
|
|
9
|
+
export declare function isVirtualPointerEvent(event: PointerEvent): boolean;
|
|
10
|
+
export declare function isMouseLikePointerType(pointerType: string | undefined, strict?: boolean): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getDPR(element: Element): number;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Ref } from '@actview/core';
|
|
2
|
+
/**
|
|
3
|
+
* actview 版(upstream 为 React hooks:useLatestRef / useEffectEvent)。
|
|
4
|
+
*
|
|
5
|
+
* 与 upstream 的差异:
|
|
6
|
+
* - ref 为 actview 框架类型 `Ref<T>`(.value,非 React 的 .current),创建用 `ref()`
|
|
7
|
+
* - actview 无渲染循环与 effect 概念(setup 只执行一次、render 闭包每次渲染执行)——
|
|
8
|
+
* `useLatestRef` 每次调用返回新的 `ref()`(引用稳定性由调用方负责)
|
|
9
|
+
* - `useEffectEvent` 无 useInsertionEffect 概念:回调在调用时同步写入 ref,
|
|
10
|
+
* 返回的稳定闭包始终调用最新回调。
|
|
11
|
+
* - `useModernLayoutEffect` 不再导出(React 专属,actview 无 layout effect)。
|
|
12
|
+
*/
|
|
13
|
+
export declare function useLatestRef<T>(value: T): Ref<T>;
|
|
14
|
+
type AnyFunction = (...args: any[]) => any;
|
|
15
|
+
export declare function useEffectEvent<T extends AnyFunction>(callback?: T): T;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ReferenceType, FloatingNodeType } from '../types';
|
|
2
|
+
export declare function getNodeChildren<RT extends ReferenceType = ReferenceType>(nodes: Array<FloatingNodeType<RT>>, id: string | undefined, onlyOpenChildren?: boolean): Array<FloatingNodeType<RT>>;
|
|
3
|
+
export declare function getDeepestNode<RT extends ReferenceType = ReferenceType>(nodes: Array<FloatingNodeType<RT>>, id: string | undefined): FloatingNodeType<RT> | undefined;
|
|
4
|
+
export declare function getNodeAncestors<RT extends ReferenceType = ReferenceType>(nodes: Array<FloatingNodeType<RT>>, id: string | undefined): FloatingNodeType<RT>[];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function getPlatform(): string;
|
|
2
|
+
export declare function getUserAgent(): string;
|
|
3
|
+
export declare function isSafari(): boolean;
|
|
4
|
+
export declare function isAndroid(): boolean;
|
|
5
|
+
export declare function isMac(): boolean;
|
|
6
|
+
export declare function isJSDOM(): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function roundByDPR(element: Element, value: number): number;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* actview 占位(upstream: `export const SafeReact = {...React}`,
|
|
3
|
+
* https://github.com/mui/material-ui/issues/41190 —— useInsertionEffect shim)。
|
|
4
|
+
*
|
|
5
|
+
* actview 无 React / useInsertionEffect 概念,此文件保留以对齐 upstream 结构;
|
|
6
|
+
* 无消费者(actview 版 hooks.ts 不引用 SafeReact)。
|
|
7
|
+
*/
|
|
8
|
+
export declare const SafeReact: never;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type FocusableElement } from 'tabbable';
|
|
2
|
+
export declare const getTabbableOptions: () => {
|
|
3
|
+
readonly getShadowRoot: true;
|
|
4
|
+
readonly displayCheck: "none" | "full";
|
|
5
|
+
};
|
|
6
|
+
export declare function getNextTabbable(referenceElement: Element | null): FocusableElement | null;
|
|
7
|
+
export declare function getPreviousTabbable(referenceElement: Element | null): FocusableElement | null;
|
|
8
|
+
export declare function isOutsideEvent(event: FocusEvent | {
|
|
9
|
+
relatedTarget?: EventTarget | null;
|
|
10
|
+
currentTarget: EventTarget | null;
|
|
11
|
+
}, container?: Element): boolean;
|
|
12
|
+
export declare function disableFocusInside(container: HTMLElement): void;
|
|
13
|
+
export declare function enableFocusInside(container: HTMLElement): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Ref } from '@actview/core';
|
|
2
|
+
/**
|
|
3
|
+
* actview 版(upstream 为 React hook:React.useMemo 缓存回调)。
|
|
4
|
+
*
|
|
5
|
+
* 与 upstream 的差异:
|
|
6
|
+
* - ref 为 actview 框架类型 `Ref<T>`(.value,非 React 的 .current)
|
|
7
|
+
* - 支持惰性 ref(`() => Ref<T | null> | fn | undefined`):调用时求值,
|
|
8
|
+
* 用于 portalContext 等挂载后才可用的 ref(如 FloatingFocusManager 的
|
|
9
|
+
* merged guard refs)
|
|
10
|
+
* - actview 无 useMemo 概念——每次调用返回新闭包,需要稳定引用的调用方自行缓存
|
|
11
|
+
* (如在 setup 中调用一次)。
|
|
12
|
+
*/
|
|
13
|
+
export type LiteMergeableRef<T> = Ref<T | null> | ((value: T | null) => void) | (() => Ref<T | null> | ((value: T | null) => void) | undefined);
|
|
14
|
+
export declare function useLiteMergeRefs<T>(refs: Array<LiteMergeableRef<T> | undefined>): (value: T | null) => void;
|
package/dist/utils.d.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@actview/floating-ui",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Floating UI for ActView",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"main": "./dist/floating-ui.actview.umd.js",
|
|
9
|
+
"module": "./dist/floating-ui.actview.esm.js",
|
|
10
|
+
"unpkg": "./dist/floating-ui.actview.umd.min.js",
|
|
11
|
+
"types": "./dist/floating-ui.actview.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
"./package.json": "./package.json",
|
|
14
|
+
".": {
|
|
15
|
+
"import": {
|
|
16
|
+
"types": "./dist/floating-ui.actview.d.mts",
|
|
17
|
+
"default": "./dist/floating-ui.actview.mjs"
|
|
18
|
+
},
|
|
19
|
+
"types": "./dist/floating-ui.actview.d.ts",
|
|
20
|
+
"module": "./dist/floating-ui.actview.esm.js",
|
|
21
|
+
"default": "./dist/floating-ui.actview.umd.js"
|
|
22
|
+
},
|
|
23
|
+
"./utils": {
|
|
24
|
+
"import": {
|
|
25
|
+
"types": "./dist/floating-ui.actview.utils.d.mts",
|
|
26
|
+
"default": "./dist/floating-ui.actview.utils.mjs"
|
|
27
|
+
},
|
|
28
|
+
"types": "./dist/floating-ui.actview.utils.d.ts",
|
|
29
|
+
"module": "./dist/floating-ui.actview.utils.esm.js",
|
|
30
|
+
"default": "./dist/floating-ui.actview.utils.umd.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"sideEffects": false,
|
|
34
|
+
"files": [
|
|
35
|
+
"dist",
|
|
36
|
+
"utils"
|
|
37
|
+
],
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"bugs": "https://github.com/floating-ui/floating-ui",
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "https://github.com/floating-ui/floating-ui.git",
|
|
43
|
+
"directory": "packages/actview"
|
|
44
|
+
},
|
|
45
|
+
"homepage": "https://floating-ui.com",
|
|
46
|
+
"keywords": [
|
|
47
|
+
"tooltip",
|
|
48
|
+
"popover",
|
|
49
|
+
"dropdown",
|
|
50
|
+
"menu",
|
|
51
|
+
"popup",
|
|
52
|
+
"positioning",
|
|
53
|
+
"actview"
|
|
54
|
+
],
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@actview/core": "1.1.0",
|
|
57
|
+
"@actview/jsx": "1.1.0",
|
|
58
|
+
"tabbable": "^6.0.0",
|
|
59
|
+
"@floating-ui/dom": "^1.8.0",
|
|
60
|
+
"@floating-ui/utils": "^0.2.12"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@actview/testing": "0.1.1",
|
|
64
|
+
"@testing-library/dom": "^10.4.0",
|
|
65
|
+
"@testing-library/jest-dom": "^6.2.0",
|
|
66
|
+
"@testing-library/user-event": "^14.6.1",
|
|
67
|
+
"@types/node": "^20.10.6",
|
|
68
|
+
"resize-observer-polyfill": "^1.5.1",
|
|
69
|
+
"vitest": "^4.1.9",
|
|
70
|
+
"@actview/plugin-babel": "1.0.7",
|
|
71
|
+
"config": "0.0.0"
|
|
72
|
+
},
|
|
73
|
+
"scripts": {
|
|
74
|
+
"lint": "eslint .",
|
|
75
|
+
"format": "prettier --ignore-path ../../.gitignore --write .",
|
|
76
|
+
"clean": "rimraf dist out-tsc utils",
|
|
77
|
+
"test": "vitest run",
|
|
78
|
+
"test:watch": "vitest watch",
|
|
79
|
+
"test:browser": "vitest run --browser",
|
|
80
|
+
"build": "rollup -c && tsc -p tsconfig.lib.json && node scripts/copy-dts.mjs",
|
|
81
|
+
"typecheck": "tsc -b"
|
|
82
|
+
}
|
|
83
|
+
}
|