@@ -43,6 +43,9 @@ interface Props {
4343 separator ?: string ;
4444 startFrom ?: Date | null ;
4545 i18n ?: string ;
46+ disabled ?: boolean ;
47+ inputClassName ?: string | null ;
48+ containerClassName ?: string | null ;
4649}
4750
4851const Datepicker : React . FC < Props > = ( {
@@ -57,7 +60,10 @@ const Datepicker: React.FC<Props> = ({
5760 placeholder = null ,
5861 separator = "~" ,
5962 startFrom = null ,
60- i18n = "en"
63+ i18n = "en" ,
64+ disabled = false ,
65+ inputClassName = null ,
66+ containerClassName = null
6167} ) => {
6268 // Ref
6369 const containerRef = useRef < HTMLDivElement > ( null ) ;
@@ -87,14 +93,23 @@ const Datepicker: React.FC<Props> = ({
8793 // Functions
8894 const hideDatepicker = useCallback ( ( ) => {
8995 const div = calendarContainerRef . current ;
90- if ( div && div . classList . contains ( "block" ) ) {
96+ const arrow = arrowRef . current ;
97+ if ( arrow && div && div . classList . contains ( "block" ) ) {
9198 div . classList . remove ( "block" ) ;
9299 div . classList . remove ( "translate-y-0" ) ;
93100 div . classList . remove ( "opacity-1" ) ;
94101 div . classList . add ( "translate-y-4" ) ;
95102 div . classList . add ( "opacity-0" ) ;
96103 setTimeout ( ( ) => {
104+ div . classList . remove ( "bottom-full" ) ;
97105 div . classList . add ( "hidden" ) ;
106+ div . classList . add ( "mb-2.5" ) ;
107+ div . classList . add ( "mt-2.5" ) ;
108+ arrow . classList . remove ( "-bottom-2" ) ;
109+ arrow . classList . remove ( "border-r" ) ;
110+ arrow . classList . remove ( "border-b" ) ;
111+ arrow . classList . add ( "border-l" ) ;
112+ arrow . classList . add ( "border-t" ) ;
98113 } , 300 ) ;
99114 }
100115 } , [ ] ) ;
@@ -177,6 +192,7 @@ const Datepicker: React.FC<Props> = ({
177192 const detail = container . getBoundingClientRect ( ) ;
178193 const screenCenter = window . innerWidth / 2 ;
179194 const containerCenter = ( detail . right - detail . x ) / 2 + detail . x ;
195+
180196 if ( containerCenter > screenCenter ) {
181197 arrow . classList . add ( "right-0" ) ;
182198 arrow . classList . add ( "mr-3.5" ) ;
@@ -224,6 +240,7 @@ const Datepicker: React.FC<Props> = ({
224240 primaryColor : colorPrimary ,
225241 configs,
226242 calendarContainer : calendarContainerRef ,
243+ arrowContainer : arrowRef ,
227244 hideDatepicker,
228245 period,
229246 changePeriod : ( newPeriod : Period ) => setPeriod ( newPeriod ) ,
@@ -237,7 +254,10 @@ const Datepicker: React.FC<Props> = ({
237254 placeholder,
238255 separator,
239256 i18n,
240- value
257+ value,
258+ disabled,
259+ inputClassName,
260+ containerClassName
241261 } ;
242262 } , [
243263 asSingle ,
@@ -253,12 +273,18 @@ const Datepicker: React.FC<Props> = ({
253273 placeholder ,
254274 separator ,
255275 showFooter ,
256- value
276+ value ,
277+ disabled ,
278+ inputClassName ,
279+ containerClassName
257280 ] ) ;
258281
259282 return (
260283 < DatepickerContext . Provider value = { contextValues } >
261- < div className = "relative w-full text-gray-700" ref = { containerRef } >
284+ < div
285+ className = { `relative w-full text-gray-700 ${ containerClassName } ` }
286+ ref = { containerRef }
287+ >
262288 < Input />
263289
264290 < div
@@ -272,7 +298,7 @@ const Datepicker: React.FC<Props> = ({
272298 { showShortcuts && < Shortcuts /> }
273299
274300 < div
275- className = { `flex items-stretch flex-col md:flex-row items-center space-y-4 md:space-y-0 md:space-x-1.5 ${
301+ className = { `flex items-stretch flex-col md:flex-row space-y-4 md:space-y-0 md:space-x-1.5 ${
276302 showShortcuts ? "md:pl-2" : "md:pl-1"
277303 } pr-2 lg:pr-1`}
278304 >
0 commit comments