import React from 'react'; import type { DatePickerProps } from 'antd'; import { Button, DatePicker, Flex, Slider, Space, Typography } from 'antd'; import dayjs from 'dayjs'; import type { Dayjs } from 'dayjs'; const onChange: DatePickerProps['onChange'] = (date, dateString) => { console.log(date, dateString); }; type DateComponent = Required['components']>>['date']; type GetProps = T extends React.ComponentType ? P : never; const MyDatePanel = (props: GetProps) => { const { value, onSelect, onHover } = props; // Value const startDate = React.useMemo(() => dayjs().date(1).month(0), []); const [innerValue, setInnerValue] = React.useState(value || startDate); React.useEffect(() => { if (value) { setInnerValue(value); } }, [value]); // Range const dateCount = React.useMemo(() => { const endDate = startDate.add(1, 'year').add(-1, 'day'); return endDate.diff(startDate, 'day'); }, [startDate]); const sliderValue = Math.min(Math.max(0, innerValue.diff(startDate, 'day')), dateCount); // Render return ( The BEST Picker Panel { const nextDate = startDate.add(nextValue, 'day'); setInnerValue(nextDate); onHover?.(nextDate); }} tooltip={{ formatter: (nextValue) => startDate.add(nextValue || 0, 'day').format('YYYY-MM-DD'), }} /> ); }; const App: React.FC = () => ( ); export default App;