11import React , { FC , ReactElement , ReactNode , useState } from 'react'
22import { createPortal } from 'react-dom'
33import PropTypes from 'prop-types'
4+ import classNames from 'classnames'
45import { Manager , Popper , Reference } from 'react-popper'
56import { Transition } from 'react-transition-group'
67
7- import { CPopoverContent } from './CPopoverContent'
8+ // import { CPopoverContent } from './CPopoverContent'
89import { Triggers , triggerPropType } from '../Types'
910
1011export interface CPopoverProps {
@@ -38,7 +39,7 @@ export interface CPopoverProps {
3839 /**
3940 * 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.
4041 */
41- placement ?: 'top' | 'right' | 'bottom' | 'left'
42+ placement ?: 'auto' | ' top' | 'right' | 'bottom' | 'left'
4243 /**
4344 * Toggle the visibility of popover component.
4445 */
@@ -47,10 +48,12 @@ export interface CPopoverProps {
4748
4849export const CPopover : FC < CPopoverProps > = ( {
4950 children,
51+ content,
5052 placement = 'top' ,
5153 offset = [ 0 , 8 ] ,
5254 onHide,
5355 onShow,
56+ title,
5457 trigger = 'click' ,
5558 visible,
5659 ...rest
@@ -114,15 +117,23 @@ export const CPopover: FC<CPopoverProps> = ({
114117 } ,
115118 ] }
116119 >
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 }
123131 { ...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 >
126137 ) }
127138 </ Popper >
128139 )
@@ -136,10 +147,12 @@ export const CPopover: FC<CPopoverProps> = ({
136147
137148CPopover . propTypes = {
138149 children : PropTypes . any ,
139- placement : PropTypes . oneOf ( [ 'top' , 'right' , 'bottom' , 'left' ] ) ,
150+ content : PropTypes . node ,
151+ placement : PropTypes . oneOf ( [ 'auto' , 'top' , 'right' , 'bottom' , 'left' ] ) ,
140152 offset : PropTypes . any , // TODO: find good proptype
141153 onHide : PropTypes . func ,
142154 onShow : PropTypes . func ,
155+ title : PropTypes . string ,
143156 trigger : triggerPropType ,
144157 visible : PropTypes . bool ,
145158}
0 commit comments