| 
									
										
										
										
											2025-03-18 11:01:06 +08:00
										 |  |  | 'use client' | 
					
						
							|  |  |  | import type { FC } from 'react' | 
					
						
							|  |  |  | import React from 'react' | 
					
						
							|  |  |  | import { DataType } from '../types' | 
					
						
							|  |  |  | import Input from '@/app/components/base/input' | 
					
						
							|  |  |  | import { InputNumber } from '@/app/components/base/input-number' | 
					
						
							|  |  |  | import cn from '@/utils/classnames' | 
					
						
							|  |  |  | import Datepicker from '../base/date-picker' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type Props = { | 
					
						
							|  |  |  |   className?: string | 
					
						
							|  |  |  |   type: DataType | 
					
						
							|  |  |  |   value: any | 
					
						
							|  |  |  |   onChange: (value: any) => void | 
					
						
							|  |  |  |   readOnly?: boolean | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const InputCombined: FC<Props> = ({ | 
					
						
							|  |  |  |   className: configClassName, | 
					
						
							|  |  |  |   type, | 
					
						
							|  |  |  |   value, | 
					
						
							|  |  |  |   onChange, | 
					
						
							|  |  |  |   readOnly, | 
					
						
							|  |  |  | }) => { | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |   const className = cn('h-6 grow p-0.5 text-xs') | 
					
						
							| 
									
										
										
										
											2025-03-18 11:01:06 +08:00
										 |  |  |   if (type === DataType.time) { | 
					
						
							|  |  |  |     return ( | 
					
						
							|  |  |  |       <Datepicker | 
					
						
							|  |  |  |         className={className} | 
					
						
							|  |  |  |         value={value} | 
					
						
							|  |  |  |         onChange={onChange} | 
					
						
							|  |  |  |       /> | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (type === DataType.number) { | 
					
						
							|  |  |  |     return ( | 
					
						
							|  |  |  |       <div className='grow text-[0]'> | 
					
						
							|  |  |  |         <InputNumber | 
					
						
							|  |  |  |           className={cn(className, 'rounded-l-md')} | 
					
						
							|  |  |  |           value={value} | 
					
						
							|  |  |  |           onChange={onChange} | 
					
						
							| 
									
										
										
										
											2025-04-18 15:54:22 +08:00
										 |  |  |           size='regular' | 
					
						
							| 
									
										
										
										
											2025-03-18 11:01:06 +08:00
										 |  |  |           controlWrapClassName='overflow-hidden' | 
					
						
							|  |  |  |           controlClassName='pt-0 pb-0' | 
					
						
							|  |  |  |           readOnly={readOnly} | 
					
						
							|  |  |  |         /> | 
					
						
							|  |  |  |       </div> | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   return ( | 
					
						
							|  |  |  |     <Input | 
					
						
							|  |  |  |       wrapperClassName={configClassName} | 
					
						
							|  |  |  |       className={cn(className, 'rounded-md')} | 
					
						
							|  |  |  |       value={value} | 
					
						
							|  |  |  |       onChange={e => onChange(e.target.value)} | 
					
						
							|  |  |  |       readOnly={readOnly} | 
					
						
							|  |  |  |     /> | 
					
						
							|  |  |  |   ) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | export default React.memo(InputCombined) |