1
- import { computePosition , offset , flip , shift , arrow } from '@floating-ui/dom'
1
+ import { computePosition , offset , shift , arrow , flip } from '@floating-ui/dom'
2
2
import type { IComputePositions } from './compute-positions-types'
3
3
4
4
export const computeTooltipPosition = async ( {
@@ -8,6 +8,7 @@ export const computeTooltipPosition = async ({
8
8
place = 'top' ,
9
9
offset : offsetValue = 10 ,
10
10
strategy = 'absolute' ,
11
+ middlewares = [ offset ( Number ( offsetValue ) ) , flip ( ) , shift ( { padding : 5 } ) ] ,
11
12
} : IComputePositions ) => {
12
13
if ( ! elementReference ) {
13
14
// elementReference can be null or undefined and we will not compute the position
@@ -20,10 +21,11 @@ export const computeTooltipPosition = async ({
20
21
return { tooltipStyles : { } , tooltipArrowStyles : { } }
21
22
}
22
23
23
- const middleware = [ offset ( Number ( offsetValue ) ) , flip ( ) , shift ( { padding : 5 } ) ]
24
+ const middleware = middlewares
24
25
25
26
if ( tooltipArrowReference ) {
26
27
middleware . push ( arrow ( { element : tooltipArrowReference as HTMLElement , padding : 5 } ) )
28
+
27
29
return computePosition ( elementReference as HTMLElement , tooltipReference as HTMLElement , {
28
30
placement : place ,
29
31
strategy,
0 commit comments