@@ -7,7 +7,7 @@ import { Manager, Popper, Reference } from 'react-popper'
77import { CSSTransition } from 'react-transition-group'
88
99import { CPopoverContent } from './CPopoverContent'
10- import { Placements , Triggers , triggerPropType } from '../Types'
10+ import { Triggers , triggerPropType } from '../Types'
1111
1212export interface CPopoverProps {
1313 children : ReactElement
@@ -26,10 +26,10 @@ export interface CPopoverProps {
2626 /**
2727 * 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. [docs]
2828 *
29- * @type 'auto' | ' top-end ' | 'top ' | 'top-start' | ' bottom-end ' | 'bottom' | 'bottom-start' | 'right-start' | 'right' | 'right-end' | ' left-start' | 'left' | 'left-end '
30- * @default 'bottom '
29+ * @type 'top' | 'right ' | 'bottom' | 'left'
30+ * @default 'top '
3131 */
32- placement ?: Placements | 'start ' | 'end' // TODO: find solution
32+ placement ?: 'top' | 'right ' | 'bottom' | 'left'
3333 /**
3434 * Toggle the visibility of popover component. [docs]
3535 *
@@ -46,7 +46,6 @@ export const CPopover: FC<CPopoverProps> = ({
4646 ...rest
4747} ) => {
4848 const [ _visible , setVisible ] = useState ( visible )
49- const _placement = placement === 'start' ? 'left' : placement === 'end' ? 'right' : placement
5049
5150 const getTransitionClass = ( state : string ) => {
5251 return state === 'entering'
@@ -92,11 +91,13 @@ export const CPopover: FC<CPopoverProps> = ({
9291 { ( state ) => {
9392 const transitionClass = getTransitionClass ( state )
9493 return (
95- < Popper placement = { _placement } >
94+ < Popper placement = { placement } >
9695 { ( p ) => (
9796 < CPopoverContent
9897 transitionClass = { transitionClass }
99- placementClassNamePostfix = { placement }
98+ placementClassNamePostfix = {
99+ placement === 'left' ? 'start' : placement === 'right' ? 'end' : placement
100+ }
100101 { ...rest }
101102 { ...p }
102103 > </ CPopoverContent >
@@ -113,23 +114,7 @@ export const CPopover: FC<CPopoverProps> = ({
113114
114115CPopover . propTypes = {
115116 children : PropTypes . any ,
116- placement : PropTypes . oneOf ( [
117- 'auto' ,
118- 'top-end' ,
119- 'top' ,
120- 'top-start' ,
121- 'bottom-end' ,
122- 'bottom' ,
123- 'bottom-start' ,
124- 'right-start' ,
125- 'right' ,
126- 'right-end' ,
127- 'left-start' ,
128- 'left' ,
129- 'left-end' ,
130- 'start' ,
131- 'end' ,
132- ] ) ,
117+ placement : PropTypes . oneOf ( [ 'top' , 'right' , 'bottom' , 'left' ] ) ,
133118 trigger : triggerPropType ,
134119 visible : PropTypes . bool ,
135120}
0 commit comments