@@ -43,6 +43,9 @@ interface Props {
43
43
separator ?: string ;
44
44
startFrom ?: Date | null ;
45
45
i18n ?: string ;
46
+ disabled ?: boolean ;
47
+ inputClassName ?: string | null ;
48
+ containerClassName ?: string | null ;
46
49
}
47
50
48
51
const Datepicker : React . FC < Props > = ( {
@@ -57,7 +60,10 @@ const Datepicker: React.FC<Props> = ({
57
60
placeholder = null ,
58
61
separator = "~" ,
59
62
startFrom = null ,
60
- i18n = "en"
63
+ i18n = "en" ,
64
+ disabled = false ,
65
+ inputClassName = null ,
66
+ containerClassName = null
61
67
} ) => {
62
68
// Ref
63
69
const containerRef = useRef < HTMLDivElement > ( null ) ;
@@ -87,14 +93,23 @@ const Datepicker: React.FC<Props> = ({
87
93
// Functions
88
94
const hideDatepicker = useCallback ( ( ) => {
89
95
const div = calendarContainerRef . current ;
90
- if ( div && div . classList . contains ( "block" ) ) {
96
+ const arrow = arrowRef . current ;
97
+ if ( arrow && div && div . classList . contains ( "block" ) ) {
91
98
div . classList . remove ( "block" ) ;
92
99
div . classList . remove ( "translate-y-0" ) ;
93
100
div . classList . remove ( "opacity-1" ) ;
94
101
div . classList . add ( "translate-y-4" ) ;
95
102
div . classList . add ( "opacity-0" ) ;
96
103
setTimeout ( ( ) => {
104
+ div . classList . remove ( "bottom-full" ) ;
97
105
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" ) ;
98
113
} , 300 ) ;
99
114
}
100
115
} , [ ] ) ;
@@ -177,6 +192,7 @@ const Datepicker: React.FC<Props> = ({
177
192
const detail = container . getBoundingClientRect ( ) ;
178
193
const screenCenter = window . innerWidth / 2 ;
179
194
const containerCenter = ( detail . right - detail . x ) / 2 + detail . x ;
195
+
180
196
if ( containerCenter > screenCenter ) {
181
197
arrow . classList . add ( "right-0" ) ;
182
198
arrow . classList . add ( "mr-3.5" ) ;
@@ -224,6 +240,7 @@ const Datepicker: React.FC<Props> = ({
224
240
primaryColor : colorPrimary ,
225
241
configs,
226
242
calendarContainer : calendarContainerRef ,
243
+ arrowContainer : arrowRef ,
227
244
hideDatepicker,
228
245
period,
229
246
changePeriod : ( newPeriod : Period ) => setPeriod ( newPeriod ) ,
@@ -237,7 +254,10 @@ const Datepicker: React.FC<Props> = ({
237
254
placeholder,
238
255
separator,
239
256
i18n,
240
- value
257
+ value,
258
+ disabled,
259
+ inputClassName,
260
+ containerClassName
241
261
} ;
242
262
} , [
243
263
asSingle ,
@@ -253,12 +273,18 @@ const Datepicker: React.FC<Props> = ({
253
273
placeholder ,
254
274
separator ,
255
275
showFooter ,
256
- value
276
+ value ,
277
+ disabled ,
278
+ inputClassName ,
279
+ containerClassName
257
280
] ) ;
258
281
259
282
return (
260
283
< 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
+ >
262
288
< Input />
263
289
264
290
< div
@@ -272,7 +298,7 @@ const Datepicker: React.FC<Props> = ({
272
298
{ showShortcuts && < Shortcuts /> }
273
299
274
300
< 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 ${
276
302
showShortcuts ? "md:pl-2" : "md:pl-1"
277
303
} pr-2 lg:pr-1`}
278
304
>
0 commit comments