1
1
import React , { FC , ReactElement , ReactNode , useState } from 'react'
2
2
import { createPortal } from 'react-dom'
3
3
import PropTypes from 'prop-types'
4
+ import classNames from 'classnames'
4
5
import { Manager , Popper , Reference } from 'react-popper'
8000
;
5
6
import { Transition } from 'react-transition-group'
6
7
7
- import { CPopoverContent } from './CPopoverContent'
8
+ // import { CPopoverContent } from './CPopoverContent'
8
9
import { Triggers , triggerPropType } from '../Types'
9
10
10
11
export interface CPopoverProps {
@@ -38,7 +39,7 @@ export interface CPopoverProps {
38
39
/**
39
40
* Describes the placement of your component after Popper.js has applied all the modifiers that may have flipped or altered the originally provided placement property.
40
41
*/
41
- placement ?: 'top' | 'right' | 'bottom' | 'left'
42
+ placement ?: 'auto' | ' top' | 'right' | 'bottom' | 'left'
42
43
/**
43
44
* Toggle the visibility of popover component.
44
45
*/
@@ -47,10 +48,12 @@ export interface CPopoverProps {
47
48
48
49
export const CPopover : FC < CPopoverProps > = ( {
49
50
children,
51
+ content,
50
52
placement = 'top' ,
51
53
offset = [ 0 , 8 ] ,
52
54
onHide,
53
55
onShow,
56
+ title,
54
57
trigger = 'click' ,
55
58
visible,
56
59
...rest
@@ -114,15 +117,23 @@ export const CPopover: FC<CPopoverProps> = ({
114
117
} ,
115
118
] }
116
119
>
117
- { ( p ) => (
118
- < CPopoverContent
119
- transitionClass = { transitionClass }
120
- placementClassNamePostfix = {
121
- placement === 'left' ? 'start' : placement === 'right' ? 'end' : placement
122
- }
120
+ { ( { arrowProps, style, ref } ) => (
121
+ < div
122
+ className = { classNames (
123
+ `popover bs-popover-${
124
+ placement === 'left' ? 'start' : placement === 'right' ? 'end' : placement
125
+ } `,
126
+ transitionClass ,
127
+ ) }
128
+ ref = { ref }
129
+ role = "tooltip"
130
+ style = { style }
123
131
{ ...rest }
124
- { ...p }
125
- > </ CPopoverContent >
132
+ >
133
+ < div className = "popover-arrow" { ...arrowProps } > </ div >
134
+ < div className = "popover-header" > { title } </ div >
135
+ < div className = "popover-body" > { content } </ div >
136
+ </ div >
126
137
) }
127
138
</ Popper >
128
139
)
@@ -136,10 +147,12 @@ export const CPopover: FC<CPopoverProps> = ({
136
147
137
148
CPopover . propTypes = {
138
149
children : PropTypes . any ,
139
- placement : PropTypes . oneOf ( [
867E
9;top' , 'right' , 'bottom' , 'left' ] ) ,
150
+ content : PropTypes . node ,
151
+ placement : PropTypes . oneOf ( [ 'auto' , 'top' , 'right' , 'bottom' , 'left' ] ) ,
140
152
offset : PropTypes . any , // TODO: find good proptype
141
153
onHide : PropTypes . func ,
142
154
onShow : PropTypes . func ,
155
+ title : PropTypes . string ,
143
156
trigger : triggerPropType ,
144
157
visible : PropTypes . bool ,
145
158
}
0 commit comments