@@ -11,6 +11,7 @@ import {
11
11
import {
12
12
setPopperForElement ,
13
13
isModifier ,
14
+ type CustomPopperOptions ,
14
15
type PopperModifierDescription ,
15
16
} from './index' ;
16
17
import {
@@ -23,9 +24,9 @@ export interface PopperSignature {
23
24
Args : {
24
25
Positional : [
25
26
HTMLElement ,
26
- ...( Partial < PopperOptions > | PopperModifierDescription ) [ ] ,
27
+ ...( Partial < CustomPopperOptions > | PopperModifierDescription ) [ ] ,
27
28
] ;
28
- Named : Partial < PopperOptions > ;
29
+ Named : Partial < CustomPopperOptions > ;
29
30
} ;
30
31
Element : HTMLElement ;
31
32
}
@@ -39,8 +40,8 @@ function getPopperOptions(
39
40
40
41
// Positional args that are not modifiers should be treated as full "options" objects
41
42
const allPositionalOptions = positionalArguments . filter <
42
- Partial < PopperOptions >
43
- > ( ( arg ) : arg is Partial < PopperOptions > => ! isModifier ( arg ) ) ;
43
+ Partial < CustomPopperOptions >
44
+ > ( ( arg ) : arg is Partial < CustomPopperOptions > => ! isModifier ( arg ) ) ;
44
45
45
46
// Positional args that are modifiers will extend the rest of the configuration
46
47
const allPositionalModifiers =
@@ -49,28 +50,25 @@ function getPopperOptions(
49
50
) ;
50
51
51
52
const { ...namedOptions } = named ;
52
- const options : Partial < PopperOptions > = {
53
+ const customOptions : Partial < CustomPopperOptions > = {
53
54
...allPositionalOptions . reduce ( ( acc , curr ) => {
54
55
return { ...acc , ...curr } ;
55
56
} , { } ) ,
56
57
...namedOptions ,
57
58
} ;
58
-
59
- // Ensure that the `modifiers` is always an array
60
- const modifiers =
61
- options . modifiers === undefined || isEmpty ( options . modifiers )
62
- ? [ ]
63
- : isArray ( options . modifiers )
64
- ? options . modifiers
65
- : [ options . modifiers ] ;
59
+ const options : Partial < PopperOptions > = {
60
+ ...customOptions ,
61
+ // Ensure that the `modifiers` is always an array
62
+ modifiers :
63
+ customOptions . modifiers === undefined || isEmpty ( customOptions . modifiers )
64
+ ? [ ]
65
+ : isArray ( customOptions . modifiers )
66
+ ? customOptions . modifiers
67
+ : [ customOptions . modifiers ] ,
68
+ } ;
66
69
67
70
// Add runloop integration and positional modifiers to the array of modifiers
68
- options . modifiers = [
69
- ...modifiers ,
70
- ...allPositionalModifiers ,
71
- beginRunLoop ,
72
- endRunLoop ,
73
- ] ;
71
+ options . modifiers ?. push ( ...allPositionalModifiers , beginRunLoop , endRunLoop ) ;
74
72
75
73
return options ;
76
74
}
0 commit comments