-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
index.ts
90 lines (87 loc) · 1.97 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import {computePosition as computePositionCore} from '@floating-ui/core';
import {platform} from './platform';
import type {
ComputePositionConfig,
FloatingElement,
ReferenceElement,
} from './types';
/**
* Computes the `x` and `y` coordinates that will place the floating element
* next to a given reference element.
*/
export const computePosition = (
reference: ReferenceElement,
floating: FloatingElement,
options?: Partial<ComputePositionConfig>,
) => {
// This caches the expensive `getClippingElementAncestors` function so that
// multiple lifecycle resets re-use the same result. It only lives for a
// single call. If other functions become expensive, we can add them as well.
const cache = new Map<ReferenceElement, Array<Element>>();
const mergedOptions = {platform, ...options};
const platformWithCache = {...mergedOptions.platform, _c: cache};
return computePositionCore(reference, floating, {
...mergedOptions,
platform: platformWithCache,
});
};
export {autoUpdate} from './autoUpdate';
export {
arrow,
autoPlacement,
detectOverflow,
flip,
hide,
inline,
limitShift,
offset,
shift,
size,
} from './middleware';
export {platform} from './platform';
export type {
ArrowOptions,
AutoPlacementOptions,
AutoUpdateOptions,
Boundary,
ComputePositionConfig,
Derivable,
DetectOverflowOptions,
Elements,
FlipOptions,
FloatingElement,
HideOptions,
Middleware,
MiddlewareArguments,
MiddlewareState,
NodeScroll,
OffsetOptions,
Platform,
ReferenceElement,
ShiftOptions,
SizeOptions,
VirtualElement,
} from './types';
export type {
AlignedPlacement,
Alignment,
Axis,
ClientRectObject,
ComputePositionReturn,
Coords,
Dimensions,
ElementContext,
ElementRects,
InlineOptions,
Length,
MiddlewareData,
MiddlewareReturn,
Padding,
Placement,
Rect,
RootBoundary,
Side,
SideObject,
Strategy,
} from '@floating-ui/core';
export {getOverflowAncestors} from '@floating-ui/utils/dom';