@@ -3,11 +3,7 @@ import tippy from 'tippy.js';
3
3
const visibleInstances = new Set ( ) ;
4
4
5
5
export function createTippy ( target , opts = { } ) {
6
- const { role, content, onHide : optsOnHide , onDestroy : optsOnDestroy , onShow : optOnShow } = opts ;
7
- delete opts . onHide ;
8
- delete opts . onDestroy ;
9
- delete opts . onShow ;
10
-
6
+ const { onHide, onShow, onDestroy, ...other } = opts ;
11
7
const instance = tippy ( target , {
12
8
appendTo : document . body ,
13
9
animation : false ,
@@ -18,11 +14,11 @@ export function createTippy(target, opts = {}) {
18
14
maxWidth : 500 , // increase over default 350px
19
15
onHide : ( instance ) => {
20
16
visibleInstances . delete ( instance ) ;
21
- return optsOnHide ?. ( instance ) ;
17
+ return onHide ?. ( instance ) ;
22
18
} ,
23
19
onDestroy : ( instance ) => {
24
20
visibleInstances . delete ( instance ) ;
25
- return optsOnDestroy ?. ( instance ) ;
21
+ return onDestroy ?. ( instance ) ;
26
22
} ,
27
23
onShow : ( instance ) => {
28
24
// hide other tooltip instances so only one tooltip shows at a time
@@ -32,19 +28,19 @@ export function createTippy(target, opts = {}) {
32
28
}
33
29
}
34
30
visibleInstances . add ( instance ) ;
35
- return optOnShow ?. ( instance ) ;
31
+ return onShow ?. ( instance ) ;
36
32
} ,
37
33
arrow : `<svg width="16" height="7"><path d="m0 7 8-7 8 7Z" class="tippy-svg-arrow-outer"/><path d="m0 8 8-7 8 7Z" class="tippy-svg-arrow-inner"/></svg>` ,
38
34
role : 'menu' , // HTML role attribute, only tooltips should use "tooltip"
39
- theme : role || 'menu' , // CSS theme, we support either "tooltip" or "menu"
40
- ...opts ,
35
+ theme : other . role || 'menu' , // CSS theme, we support either "tooltip" or "menu"
36
+ ...other ,
41
37
} ) ;
42
38
43
39
// for popups where content refers to a DOM element, we use the 'tippy-target' class
44
40
// to initially hide the content, now we can remove it as the content has been removed
45
41
// from the DOM by tippy
46
- if ( content instanceof Element ) {
47
- content . classList . remove ( 'tippy-target' ) ;
42
+ if ( other . content instanceof Element ) {
43
+ other . content . classList . remove ( 'tippy-target' ) ;
48
44
}
49
45
50
46
return instance ;
0 commit comments