| 
									
										
										
										
											2023-12-18 15:41:24 +08:00
										 |  |  | 'use client' | 
					
						
							|  |  |  | import type { FC } from 'react' | 
					
						
							|  |  |  | import React, { useRef } from 'react' | 
					
						
							| 
									
										
										
										
											2024-06-20 11:05:08 +08:00
										 |  |  | import { RiCloseLine } from '@remixicon/react' | 
					
						
							| 
									
										
										
										
											2024-07-09 15:05:40 +08:00
										 |  |  | import cn from '@/utils/classnames' | 
					
						
							| 
									
										
										
										
											2023-12-18 15:41:24 +08:00
										 |  |  | import Drawer from '@/app/components/base/drawer' | 
					
						
							|  |  |  | import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type Props = { | 
					
						
							|  |  |  |   isShow: boolean | 
					
						
							|  |  |  |   onHide: () => void | 
					
						
							| 
									
										
										
										
											2025-04-22 09:59:14 +08:00
										 |  |  |   dialogClassName?: string | 
					
						
							|  |  |  |   dialogBackdropClassName?: string | 
					
						
							| 
									
										
										
										
											2024-01-23 19:31:56 +08:00
										 |  |  |   panelClassName?: string | 
					
						
							| 
									
										
										
										
											2023-12-18 15:41:24 +08:00
										 |  |  |   maxWidthClassName?: string | 
					
						
							| 
									
										
										
										
											2024-01-23 19:31:56 +08:00
										 |  |  |   contentClassName?: string | 
					
						
							|  |  |  |   headerClassName?: string | 
					
						
							| 
									
										
										
										
											2023-12-18 15:41:24 +08:00
										 |  |  |   height?: number | string | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |   title: string | React.JSX.Element | 
					
						
							|  |  |  |   titleDescription?: string | React.JSX.Element | 
					
						
							|  |  |  |   body: React.JSX.Element | 
					
						
							|  |  |  |   foot?: React.JSX.Element | 
					
						
							| 
									
										
										
										
											2024-01-23 19:31:56 +08:00
										 |  |  |   isShowMask?: boolean | 
					
						
							|  |  |  |   clickOutsideNotOpen?: boolean | 
					
						
							| 
									
										
										
										
											2024-05-27 21:57:08 +08:00
										 |  |  |   positionCenter?: boolean | 
					
						
							| 
									
										
										
										
											2023-12-18 15:41:24 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const DrawerPlus: FC<Props> = ({ | 
					
						
							|  |  |  |   isShow, | 
					
						
							|  |  |  |   onHide, | 
					
						
							| 
									
										
										
										
											2025-04-22 09:59:14 +08:00
										 |  |  |   dialogClassName = '', | 
					
						
							|  |  |  |   dialogBackdropClassName = '', | 
					
						
							| 
									
										
										
										
											2024-01-23 19:31:56 +08:00
										 |  |  |   panelClassName = '', | 
					
						
							| 
									
										
										
										
											2023-12-18 15:41:24 +08:00
										 |  |  |   maxWidthClassName = '!max-w-[640px]', | 
					
						
							|  |  |  |   height = 'calc(100vh - 72px)', | 
					
						
							| 
									
										
										
										
											2024-01-23 19:31:56 +08:00
										 |  |  |   contentClassName, | 
					
						
							|  |  |  |   headerClassName, | 
					
						
							| 
									
										
										
										
											2023-12-18 15:41:24 +08:00
										 |  |  |   title, | 
					
						
							| 
									
										
										
										
											2024-01-23 19:31:56 +08:00
										 |  |  |   titleDescription, | 
					
						
							| 
									
										
										
										
											2023-12-18 15:41:24 +08:00
										 |  |  |   body, | 
					
						
							|  |  |  |   foot, | 
					
						
							| 
									
										
										
										
											2024-01-23 19:31:56 +08:00
										 |  |  |   isShowMask, | 
					
						
							|  |  |  |   clickOutsideNotOpen = true, | 
					
						
							| 
									
										
										
										
											2024-05-27 21:57:08 +08:00
										 |  |  |   positionCenter, | 
					
						
							| 
									
										
										
										
											2023-12-18 15:41:24 +08:00
										 |  |  | }) => { | 
					
						
							|  |  |  |   const ref = useRef(null) | 
					
						
							|  |  |  |   const media = useBreakpoints() | 
					
						
							|  |  |  |   const isMobile = media === MediaType.mobile | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (!isShow) | 
					
						
							|  |  |  |     return null | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return ( | 
					
						
							|  |  |  |     // clickOutsideNotOpen to fix confirm modal click cause drawer close
 | 
					
						
							| 
									
										
										
										
											2024-05-27 21:57:08 +08:00
										 |  |  |     <Drawer | 
					
						
							|  |  |  |       isOpen={isShow} | 
					
						
							|  |  |  |       clickOutsideNotOpen={clickOutsideNotOpen} | 
					
						
							|  |  |  |       onClose={onHide} | 
					
						
							|  |  |  |       footer={null} | 
					
						
							|  |  |  |       mask={isMobile || isShowMask} | 
					
						
							|  |  |  |       positionCenter={positionCenter} | 
					
						
							| 
									
										
										
										
											2025-04-22 09:59:14 +08:00
										 |  |  |       dialogClassName={dialogClassName} | 
					
						
							|  |  |  |       dialogBackdropClassName={dialogBackdropClassName} | 
					
						
							|  |  |  |       panelClassName={cn('mx-2 mb-3 mt-16 rounded-xl !p-0 sm:mr-2', panelClassName, maxWidthClassName)} | 
					
						
							| 
									
										
										
										
											2024-05-27 21:57:08 +08:00
										 |  |  |     > | 
					
						
							| 
									
										
										
										
											2023-12-18 15:41:24 +08:00
										 |  |  |       <div | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |         className={cn(contentClassName, 'flex w-full flex-col rounded-xl border-[0.5px] border-divider-subtle bg-components-panel-bg shadow-xl')} | 
					
						
							| 
									
										
										
										
											2023-12-18 15:41:24 +08:00
										 |  |  |         style={{ | 
					
						
							|  |  |  |           height, | 
					
						
							|  |  |  |         }} | 
					
						
							|  |  |  |         ref={ref} | 
					
						
							|  |  |  |       > | 
					
						
							| 
									
										
										
										
											2024-12-12 10:09:48 +08:00
										 |  |  |         <div className={cn(headerClassName, 'shrink-0 border-b border-divider-subtle py-4')}> | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |           <div className='flex h-6 items-center justify-between pl-6 pr-5'> | 
					
						
							| 
									
										
										
										
											2024-12-12 10:09:48 +08:00
										 |  |  |             <div className='system-xl-semibold text-text-primary'> | 
					
						
							| 
									
										
										
										
											2024-01-23 19:31:56 +08:00
										 |  |  |               {title} | 
					
						
							|  |  |  |             </div> | 
					
						
							|  |  |  |             <div className='flex items-center'> | 
					
						
							|  |  |  |               <div | 
					
						
							|  |  |  |                 onClick={onHide} | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |                 className='flex h-6 w-6 cursor-pointer items-center justify-center' | 
					
						
							| 
									
										
										
										
											2024-01-23 19:31:56 +08:00
										 |  |  |               > | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |                 <RiCloseLine className='h-4 w-4 text-text-tertiary' /> | 
					
						
							| 
									
										
										
										
											2024-01-23 19:31:56 +08:00
										 |  |  |               </div> | 
					
						
							| 
									
										
										
										
											2023-12-18 15:41:24 +08:00
										 |  |  |             </div> | 
					
						
							|  |  |  |           </div> | 
					
						
							| 
									
										
										
										
											2024-01-23 19:31:56 +08:00
										 |  |  |           {titleDescription && ( | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |             <div className='system-xs-regular pl-6 pr-10 text-text-tertiary'> | 
					
						
							| 
									
										
										
										
											2024-01-23 19:31:56 +08:00
										 |  |  |               {titleDescription} | 
					
						
							|  |  |  |             </div> | 
					
						
							|  |  |  |           )} | 
					
						
							| 
									
										
										
										
											2023-12-18 15:41:24 +08:00
										 |  |  |         </div> | 
					
						
							|  |  |  |         <div className='grow overflow-y-auto'> | 
					
						
							|  |  |  |           {body} | 
					
						
							|  |  |  |         </div> | 
					
						
							|  |  |  |         {foot && ( | 
					
						
							|  |  |  |           <div className='shrink-0'> | 
					
						
							|  |  |  |             {foot} | 
					
						
							|  |  |  |           </div> | 
					
						
							|  |  |  |         )} | 
					
						
							|  |  |  |       </div> | 
					
						
							|  |  |  |     </Drawer> | 
					
						
							|  |  |  |   ) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | export default React.memo(DrawerPlus) |