@@ -5,7 +5,7 @@ import { Manager, Popper, Reference } from 'react-popper'
55import { CSSTransition } from 'react-transition-group'
66
77import { CTooltipContent } from './CTooltipContent'
8- import { Placements , Triggers , triggerPropType } from '../Types'
8+ import { Triggers , triggerPropType } from '../Types'
99
1010export interface CTooltipProps {
1111 children : ReactElement
@@ -20,10 +20,10 @@ export interface CTooltipProps {
2020 /**
2121 * 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]
2222 *
23- * @type 'auto' | ' top-end ' | 'top ' | 'top-start' | ' bottom-end ' | 'bottom' | 'bottom-start' | 'right-start' | 'right' | 'right-end' | ' left-start' | 'left' | 'left-end '
23+ * @type 'top' | 'right ' | 'bottom' | 'left'
2424 * @default 'top'
2525 */
26- placement ?: Placements | 'start ' | 'end' // TODO: find solution
26+ placement ?: 'top' | 'right ' | 'bottom' | 'left'
2727 /**
2828 * Toggle the visibility of popover component. [docs]
2929 *
@@ -40,7 +40,6 @@ export const CTooltip: FC<CTooltipProps> = ({
4040 ...rest
4141} ) => {
4242 const [ _visible , setVisible ] = useState ( visible )
43- const _placement = placement === 'start' ? 'left' : placement === 'end' ? 'right' : placement
4443
4544 const getTransitionClass = ( state : string ) => {
4645 return state === 'entering'
@@ -86,11 +85,13 @@ export const CTooltip: FC<CTooltipProps> = ({
8685 { ( state ) => {
8786 const transitionClass = getTransitionClass ( state )
8887 return (
89- < Popper placement = { _placement } >
88+ < Popper placement = { placement } >
9089 { ( p ) => (
9190 < CTooltipContent
9291 transitionClass = { transitionClass }
93- placementClassNamePostfix = { placement }
92+ placementClassNamePostfix = {
93+ placement === 'left' ? 'start' : placement === 'right' ? 'end' : placement
94+ }
9495 { ...rest }
9596 { ...p }
9697 > </ CTooltipContent >
@@ -107,23 +108,7 @@ export const CTooltip: FC<CTooltipProps> = ({
107108
108109CTooltip . propTypes = {
109110 children : PropTypes . any ,
110- placement : PropTypes . oneOf ( [
111- 'auto' ,
112- 'top-end' ,
113- 'top' ,
114- 'top-start' ,
115- 'bottom-end' ,
116- 'bottom' ,
117- 'bottom-start' ,
118- 'right-start' ,
119- 'right' ,
120- 'right-end' ,
121- 'left-start' ,
122- 'left' ,
123- 'left-end' ,
124- 'start' ,
125- 'end' ,
126- ] ) ,
111+ placement : PropTypes . oneOf ( [ 'top' , 'right' , 'bottom' , 'left' ] ) ,
127112 trigger : triggerPropType ,
128113 visible : PropTypes . bool ,
129114}
0 commit comments