1- import React , { FC , ReactNode , useRef , useState } from 'react'
1+ import React , { FC , HTMLAttributes , ReactNode , useRef , useEffect , useState } from 'react'
22import { createPortal } from 'react-dom'
3-
4- import classNames from 'classnames'
53import PropTypes from 'prop-types'
4+ import classNames from 'classnames'
65import { usePopper } from 'react-popper'
76import { Transition } from 'react-transition-group'
87
98import { Triggers , triggerPropType } from '../Types'
10- import { useEffect } from 'react'
119
12- export interface CPopoverProps {
13- // TODO: find solution to not use any
14- children : any
10+ export interface CPopoverProps extends Omit < HTMLAttributes < HTMLDivElement > , 'title' > {
11+ /**
12+ * A string of all className you want applied to the component.
13+ */
14+ className ?: string
1515 /**
1616 * Content node for your component.
1717 */
@@ -50,6 +50,7 @@ export interface CPopoverProps {
5050
5151export const CPopover : FC < CPopoverProps > = ( {
5252 children,
53+ className,
5354 content,
5455 offset = [ 0 , 8 ] ,
5556 onHide,
@@ -95,7 +96,7 @@ export const CPopover: FC<CPopoverProps> = ({
9596
9697 return (
9798 < >
98- { React . cloneElement ( children , {
99+ { React . cloneElement ( children as React . ReactElement < any > , {
99100 ref : setReferenceElement ,
100101 ...( ( trigger === 'click' || trigger . includes ( 'click' ) ) && {
101102 onClick : ( ) => setVisible ( ! _visible ) ,
@@ -131,6 +132,7 @@ export const CPopover: FC<CPopoverProps> = ({
131132 `popover bs-popover-${
132133 placement === 'left' ? 'start' : placement === 'right' ? 'end' : placement
133134 } `,
135+ className ,
134136 transitionClass ,
135137 ) }
136138 ref = { setPopperElement }
@@ -153,7 +155,8 @@ export const CPopover: FC<CPopoverProps> = ({
153155}
154156
155157CPopover . propTypes = {
156- children : PropTypes . any ,
158+ children : PropTypes . node ,
159+ className : PropTypes . string ,
157160 content : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . node ] ) ,
158161 offset : PropTypes . any , // TODO: find good proptype
159162 onHide : PropTypes . func ,
0 commit comments