@@ -7,7 +7,7 @@ import Input from "../components/Input";
77import Shortcuts from "../components/Shortcuts" ;
88import { COLORS , DATE_FORMAT , DEFAULT_COLOR , LANGUAGE } from "../constants" ;
99import DatepickerContext from "../contexts/DatepickerContext" ;
10- import { formatDate , nextMonth , previousMonth } from "../helpers" ;
10+ import { formatDate , nextMonth , previousMonth , classNames as classNamesUtil } from "../helpers" ;
1111import useOnClickOutside from "../hooks" ;
1212import { Period , DatepickerType , ColorKeys } from "../types" ;
1313
@@ -29,6 +29,7 @@ const Datepicker: React.FC<DatepickerType> = ({
2929 disabled = false ,
3030 inputClassName = null ,
3131 containerClassName = null ,
32+ pickerClassName = null ,
3233 toggleClassName = null ,
3334 toggleIcon = undefined ,
3435 displayFormat = DATE_FORMAT ,
@@ -41,7 +42,8 @@ const Datepicker: React.FC<DatepickerType> = ({
4142 inputName,
4243 startWeekOn = "sun" ,
4344 classNames = undefined ,
44- popoverDirection = undefined
45+ popoverDirection = undefined ,
46+ inline = false
4547} ) => {
4648 // Ref
4749 const containerRef = useRef < HTMLDivElement | null > ( null ) ;
@@ -64,7 +66,7 @@ const Datepicker: React.FC<DatepickerType> = ({
6466 // Custom Hooks use
6567 useOnClickOutside ( containerRef , ( ) => {
6668 const container = containerRef . current ;
67- if ( container ) {
69+ if ( container && ! inline ) {
6870 hideDatepicker ( ) ;
6971 }
7072 } ) ;
@@ -327,18 +329,33 @@ const Datepicker: React.FC<DatepickerType> = ({
327329 : defaultContainerClassName ;
328330 } , [ containerClassName ] ) ;
329331
332+ const pickerClassNameOverload = useMemo ( ( ) => {
333+ const defaultPickerClassName = classNamesUtil (
334+ "shadow-sm border border-gray-300 px-1 py-0.5 bg-white dark:bg-slate-800 dark:text-white dark:border-slate-600 rounded-lg w-fit" ,
335+ ! inline && "mt-2.5"
336+ ) ;
337+ return typeof pickerClassName === "function"
338+ ? pickerClassName ( defaultPickerClassName )
339+ : typeof pickerClassName === "string" && pickerClassName !== ""
340+ ? pickerClassName
341+ : defaultPickerClassName ;
342+ } , [ pickerClassName , inline ] ) ;
343+
330344 return (
331345 < DatepickerContext . Provider value = { contextValues } >
332346 < div className = { containerClassNameOverload } ref = { containerRef } >
333- < Input setContextRef = { setInputRef } />
347+ { ! inline && < Input setContextRef = { setInputRef } /> }
334348
335349 < div
336- className = "transition-all ease-out duration-300 absolute z-10 mt-[1px] text-sm lg:text-xs 2xl:text-sm translate-y-4 opacity-0 hidden"
350+ className = { classNamesUtil (
351+ "transition-all ease-out duration-300 mt-[1px] text-sm lg:text-xs 2xl:text-sm" ,
352+ ! inline && "absolute z-10 opacity-0 hidden translate-y-4"
353+ ) }
337354 ref = { calendarContainerRef }
338355 >
339- < Arrow ref = { arrowRef } />
356+ { ! inline && < Arrow ref = { arrowRef } /> }
340357
341- < div className = "mt-2.5 shadow-sm border border-gray-300 px-1 py-0.5 bg-white dark:bg-slate-800 dark:text-white dark:border-slate-600 rounded-lg" >
358+ < div className = { pickerClassNameOverload } >
342359 < div className = "flex flex-col lg:flex-row py-2" >
343360 { showShortcuts && < Shortcuts /> }
344361
0 commit comments