2022-09-01 10:09:08 +00:00
|
|
|
// @see: https://github.com/wojtekmaj/react-daterange-picker/issues/91
|
|
|
|
import "@wojtekmaj/react-daterange-picker/dist/DateRangePicker.css";
|
|
|
|
import PrimitiveDateRangePicker from "@wojtekmaj/react-daterange-picker/dist/entry.nostyle";
|
|
|
|
|
2023-04-12 15:26:31 +00:00
|
|
|
import { ArrowRight, Calendar, ChevronLeft, ChevronRight } from "../../icon";
|
2022-11-23 02:55:25 +00:00
|
|
|
import "./styles.css";
|
2022-09-01 10:09:08 +00:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
disabled?: boolean | undefined;
|
|
|
|
startDate: Date;
|
|
|
|
endDate: Date;
|
|
|
|
onDatesChange?: ((arg: { startDate: Date; endDate: Date }) => void) | undefined;
|
|
|
|
};
|
|
|
|
|
|
|
|
const DateRangePicker = ({ disabled, startDate, endDate, onDatesChange }: Props) => {
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<PrimitiveDateRangePicker
|
|
|
|
disabled={disabled || false}
|
2023-04-05 18:14:46 +00:00
|
|
|
className="border-default rounded-sm text-sm"
|
2022-09-01 10:09:08 +00:00
|
|
|
clearIcon={null}
|
2023-04-12 15:26:31 +00:00
|
|
|
calendarIcon={<Calendar className="text-subtle h-4 w-4" />}
|
|
|
|
rangeDivider={<ArrowRight className="text-muted h-4 w-4 ltr:mr-2 rtl:ml-2" />}
|
2022-09-01 10:09:08 +00:00
|
|
|
value={[startDate, endDate]}
|
|
|
|
onChange={([startDate, endDate]: [Date, Date]) => {
|
|
|
|
if (typeof onDatesChange === "function") onDatesChange({ startDate, endDate });
|
|
|
|
}}
|
2023-04-12 15:26:31 +00:00
|
|
|
nextLabel={<ChevronRight className="text-subtle h-4 w-4" />}
|
|
|
|
prevLabel={<ChevronLeft className="text-subtle h-4 w-4" />}
|
2022-09-01 10:09:08 +00:00
|
|
|
/>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default DateRangePicker;
|