@@ -27,19 +27,15 @@ export interface NotificationProptypes extends CommonProps {
2727 loading ?: boolean ;
2828 datetime ?: string ;
2929 priority ?: Priority ;
30- showCloseButton ?: boolean ;
31- visible ?: boolean ;
30+ noCloseButton ?: boolean ;
3231 onClick ?: ( e : any ) => any ;
33- hideShowMoreButton ?: boolean ;
32+ noShowMoreButton ?: boolean ;
3433 truncate ?: boolean ;
3534 onClose ?: ( event : Event ) => void ;
3635
3736 children ?: React . ReactElement < NotificationProptypes > | React . ReactElement < NotificationProptypes > [ ] ;
3837 collapsed ?: boolean ;
3938 autoPriority ?: boolean ;
40-
41- isChild ?: boolean ;
42- isLastChild ?: boolean ;
4339}
4440
4541const useStyles = createUseStyles < JSSTheme , keyof ReturnType < typeof styles > > ( styles , { name : 'Notification' } ) ;
@@ -56,31 +52,24 @@ const Notification: FC<NotificationProptypes> = forwardRef(
5652 datetime,
5753 avatar,
5854 priority,
59- visible,
6055 onClick,
6156 children,
6257 collapsed,
6358 className,
6459 tooltip,
6560 style,
66- isChild,
67- isLastChild,
6861 autoPriority,
69- hideShowMoreButton ,
62+ noShowMoreButton ,
7063 truncate,
71- showCloseButton ,
64+ noCloseButton ,
7265 onClose
7366 } = props ;
7467
7568 const classes = useStyles ( props ) ;
76- const [ visibleState , toggleVisible ] = useState ( visible ) ;
69+ const [ visibleState , toggleVisible ] = useState ( true ) ;
7770 const [ showChildren , toggleChildrenVisible ] = useState ( ! collapsed ) ;
7871 const [ showMore , toggleShowMore ] = useState ( ! truncate ) ;
7972
80- useEffect ( ( ) => {
81- toggleVisible ( visible ) ;
82- } , [ visible ] ) ;
83-
8473 useEffect ( ( ) => {
8574 toggleChildrenVisible ( ! collapsed ) ;
8675 } , [ collapsed ] ) ;
@@ -129,6 +118,9 @@ const Notification: FC<NotificationProptypes> = forwardRef(
129118 toggleShowMore ( ! showMore ) ;
130119 } , [ showMore ] ) ;
131120
121+ const isLastChild = props [ 'isLastChild' ] ;
122+ const isChild = props [ 'isChild' ] ;
123+
132124 const notificationContainerStyles = useMemo ( ( ) => {
133125 const borderRadius = ( ) => {
134126 if ( isChild ) {
@@ -211,11 +203,13 @@ const Notification: FC<NotificationProptypes> = forwardRef(
211203 return React . Children . map ( children , ( item , index ) => {
212204 if ( React . Children . count ( children ) === index + 1 ) {
213205 return React . cloneElement ( item , {
206+ // @ts -ignore
214207 isLastChild : true ,
215208 className : `${ item . props . className } ${ classes . notificationContainerChild } `
216209 } ) ;
217210 }
218211 return React . cloneElement ( item , {
212+ // @ts -ignore
219213 isChild : true ,
220214 className : `${ item . props . className } ${ classes . notificationContainerChild } `
221215 } ) ;
@@ -256,7 +250,7 @@ const Notification: FC<NotificationProptypes> = forwardRef(
256250 < div className = { classes . semanticIcon } > { renderSemanticIcon } </ div >
257251 ) }
258252 < div className = { `${ classes . title } ${ truncate ? classes . titleEllipsised : '' } ` } > { title } </ div >
259- { showCloseButton && (
253+ { ! noCloseButton && (
260254 < Button
261255 className = { classes . closeButton }
262256 design = { ButtonDesign . Transparent }
@@ -284,7 +278,7 @@ const Notification: FC<NotificationProptypes> = forwardRef(
284278 </ div >
285279 < div className = { classes . footer } >
286280 < div style = { { display : 'flex' , flexDirection : 'row' , justifyContent : 'space-between' } } >
287- { ! hideShowMoreButton && (
281+ { ! noShowMoreButton && (
288282 < Button design = { ButtonDesign . Transparent } onClick = { handleShowMore } >
289283 { showMore ? 'Show Less' : 'Show More' }
290284 </ Button >
@@ -311,9 +305,7 @@ const Notification: FC<NotificationProptypes> = forwardRef(
311305) ;
312306
313307Notification . defaultProps = {
314- visible : true ,
315- truncate : true ,
316- showCloseButton : true
308+ truncate : true
317309} ;
318310
319311Notification . displayName = 'Notification' ;
0 commit comments