1
- import React , { FC , ReactNode , useRef , useState } from 'react'
1
+ import React , { FC , HTMLAttributes , ReactNode , useRef , useEffect , useState } from 'react'
2
2
import { createPortal } from 'react-dom'
3
-
4
- import classNames from 'classnames'
5
3
import PropTypes from 'prop-types'
4
+ import classNames from 'classnames'
6
5
import { usePopper } from 'react-popper'
7
6
import { Transition } from 'react-transition-group'
8
7
9
8
import { Triggers , triggerPropType } from '../Types'
10
- import { useEffect } from 'react'
11
9
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
15
15
/**
16
16
* Content node for your component.
17
17
*/
@@ -50,6 +50,7 @@ export interface CPopoverProps {
50
50
51
51
export const CPopover : FC < CPopoverProps > = ( {
52
52
children,
53
+ className,
53
54
content,
54
55
offset = [ 0 , 8 ] ,
55
56
onHide,
@@ -95,7 +96,7 @@ export const CPopover: FC<CPopoverProps> = ({
95
96
96
97
return (
97
98
< >
98
- { React . cloneElement ( children , {
99
+ { React . cloneElement ( children as React . ReactElement < any > , {
99
100
ref : setReferenceElement ,
100
101
...( ( trigger === 'click' || trigger . includes ( 'click' ) ) && {
101
102
onClick : ( ) => setVisible ( ! _visible ) ,
@@ -131,6 +132,7 @@ export const CPopover: FC<CPopoverProps> = ({
131
132
`popover bs-popover-${
132
133
placement === 'left' ? 'start' : placement === 'right' ? 'end' : placement
133
134
} `,
135
+ className ,
134
136
transitionClass ,
135
137
) }
136
138
ref = { setPopperElement }
@@ -153,7 +155,8 @@ export const CPopover: FC<CPopoverProps> = ({
153
155
}
154
156
155
157
CPopover . propTypes = {
156
- children : PropTypes . any ,
158
+ children : PropTypes . node ,
159
+ className : PropTypes . string ,
157
160
content : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . node ] ) ,
158
161
offset : PropTypes . any , // TODO: find good proptype
159
162
onHide : PropTypes . func ,
0 commit comments