File tree 6 files changed +86
-18
lines changed
6 files changed +86
-18
lines changed Original file line number Diff line number Diff line change 40
40
"link" : " npm link && link.sh"
41
41
},
42
42
"dependencies" : {
43
+ "@popperjs/core" : " ^2.2.1" ,
43
44
"classnames" : " ^2.2.6" ,
44
45
"core-js" : " ^3.6.4" ,
45
46
"lodash.isfunction" : " ^3.0.9" ,
Original file line number Diff line number Diff line change @@ -31,7 +31,11 @@ const CDropdown = props=>{
31
31
32
32
//render
33
33
34
- return < CDropdownCustom { ...attributes } show = { show } toggle = { toggle } /> ;
34
+ return < CDropdownCustom
35
+ { ...attributes }
36
+ show = { show }
37
+ toggle = { toggle }
38
+ /> ;
35
39
36
40
}
37
41
Original file line number Diff line number Diff line change @@ -194,7 +194,8 @@ const CDropdownCustom = props=>{
194
194
195
195
const direction = props . direction ; //(props.direction === 'down' && dropup) ? 'up' :
196
196
197
- attributes . tag = attributes . tag || ( inNav ? 'li' : 'div' ) ;
197
+ //attributes.tag
198
+ let Tag = attributes . tag || ( inNav ? 'li' : 'div' ) ;
198
199
199
200
let subItemIsActive = false ;
200
201
@@ -221,6 +222,27 @@ const CDropdownCustom = props=>{
221
222
}
222
223
) , cssModule ) ;
223
224
225
+ return (
226
+ < Context . Provider value = { {
227
+ toggle : props . toggle ,
228
+ isOpen : props . show ,
229
+ direction : props . direction , //(props.direction === 'down' && props.dropup) ? 'up' :
230
+ inNavbar : props . inNavbar ,
231
+ } } >
232
+ < Tag
233
+ { ...attributes }
234
+ className = { classes }
235
+ onKeyDown = { handleKeyDown }
236
+ ref = { reference }
237
+ >
238
+ < Manager >
239
+ { props . children }
240
+ </ Manager >
241
+ </ Tag >
242
+ </ Context . Provider >
243
+ ) ;
244
+
245
+ /*
224
246
return (
225
247
<Context.Provider value={{
226
248
toggle: props.toggle,
@@ -238,6 +260,7 @@ const CDropdownCustom = props=>{
238
260
</CPopperContentWrapper>
239
261
</Context.Provider>
240
262
);
263
+ */
241
264
242
265
}
243
266
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ const CDropdownMenu = props=>{
11
11
12
12
const {
13
13
className,
14
+ children,
14
15
cssModule,
15
16
right,
16
17
tag,
@@ -44,29 +45,48 @@ const CDropdownMenu = props=>{
44
45
) , cssModule ) ;
45
46
46
47
let Tag = tag ;
48
+ let placement ;
49
+ let myModifiers = modifiers ;
47
50
48
51
if ( persist || ( context . isOpen && ! context . inNavbar ) ) {
49
52
Tag = Popper ;
50
53
const position1 = directionPositionMap [ context . direction ] || 'bottom' ;
51
54
const position2 = right ? 'end' : 'start' ;
52
- attributes . placement = `${ position1 } -${ position2 } ` ;
53
- attributes . component = tag ;
54
- attributes . modifiers = ! flip ? {
55
+ placement = `${ position1 } -${ position2 } ` ;
56
+ // attributes.component = tag;
57
+ myModifiers = ! flip ? {
55
58
...modifiers ,
56
59
...noFlipModifier ,
57
60
} : modifiers ;
58
61
}
59
62
63
+ /*
64
+ x-placement={attributes.placement}
65
+ ref={innerRef}
66
+ */
60
67
return (
61
68
< Tag
62
- tabIndex = "-1"
63
- role = "menu"
64
- { ...attributes }
65
- aria-hidden = { ! context . isOpen }
66
- className = { classes }
67
- x-placement = { attributes . placement }
68
- ref = { innerRef }
69
- />
69
+ placement = { placement }
70
+ modifiers = { myModifiers }
71
+ >
72
+ { ( { ref, style, placement, arrowProps } ) => {
73
+ //console.log(style, children);
74
+ return (
75
+ < div
76
+ { ...attributes }
77
+ tabIndex = "-1"
78
+ role = "menu"
79
+ aria-hidden = { ! context . isOpen }
80
+ className = { classes }
81
+
82
+ ref = { ref }
83
+ data-placement = { placement }
84
+ >
85
+ { children }
86
+ </ div >
87
+ ) }
88
+ }
89
+ </ Tag >
70
90
) ;
71
91
72
92
}
Original file line number Diff line number Diff line change @@ -2,9 +2,10 @@ import React, {useContext} from 'react';
2
2
import PropTypes from 'prop-types' ;
3
3
import classNames from 'classnames' ;
4
4
import { tagPropType , mapToCssModules } from './Shared/helper.js' ;
5
- import { Target } from 'react-popper' ;
5
+ import { Reference } from 'react-popper' ;
6
6
import CButton from './CButton' ;
7
7
import { Context } from './CDropdownCustom' ;
8
+ import CHeaderNavLink from './CHeaderNavLink' ;
8
9
9
10
//component - CoreUI / CDropdownToggle
10
11
@@ -14,6 +15,7 @@ const CDropdownToggle = props=>{
14
15
className,
15
16
color,
16
17
cssModule,
18
+
17
19
//
18
20
innerRef,
19
21
caret,
@@ -24,7 +26,7 @@ const CDropdownToggle = props=>{
24
26
togglerHtml,
25
27
...attributes
26
28
} = props ;
27
-
29
+
28
30
const context = useContext ( Context ) ;
29
31
30
32
const onClick = e => {
@@ -98,6 +100,24 @@ const CDropdownToggle = props=>{
98
100
) ;
99
101
}
100
102
103
+ return (
104
+ < Reference >
105
+ { ( { ref } ) => (
106
+ < Tag
107
+ ref = { ref }
108
+ { ...attributes }
109
+ className = { classes }
110
+ onClick = { onClick }
111
+ aria-expanded = { context . isOpen }
112
+ ref = { innerRef }
113
+ >
114
+ { children }
115
+ </ Tag >
116
+ ) }
117
+ </ Reference >
118
+ ) ;
119
+
120
+ /*
101
121
return (
102
122
<Target
103
123
{...attributes}
@@ -110,7 +130,7 @@ const CDropdownToggle = props=>{
110
130
{children}
111
131
</Target>
112
132
);
113
-
133
+ */
114
134
}
115
135
116
136
CDropdownToggle . propTypes = {
Original file line number Diff line number Diff line change @@ -39,12 +39,12 @@ const CToggler = props=>{
39
39
40
40
const classes = mapToCssModules ( classNames (
41
41
className ,
42
- togglerType ? `${ togglerType } -toggler` : null ,
42
+ togglerType ? `c- ${ togglerType } -toggler` : null ,
43
43
) , cssModule ) ;
44
44
45
45
if ( ! custom ) {
46
46
const classesTrigger = mapToCssModules ( classNames (
47
- togglerType ? `${ togglerType } -toggler-icon` : null ,
47
+ togglerType ? `c- ${ togglerType } -toggler-icon` : null ,
48
48
) , cssModule ) ;
49
49
return (
50
50
< Tag { ...attributes } className = { classes } onClick = { onClick } >
You can’t perform that action at this time.
0 commit comments