import React from 'react'; import { DownOutlined } from '@ant-design/icons'; import { DatePicker, Dropdown, Space } from 'antd'; import dayjs from 'dayjs'; const App: React.FC = () => { const [visible, setVisible] = React.useState(false); const [panelVisible, setPanelVisible] = React.useState(false); const [date, setDate] = React.useState(dayjs()); return ( { setVisible(open); if (!open) { setPanelVisible(false); } }} menu={{ items: [ { key: 'today', label: 'Today', onClick() { setDate(dayjs()); setVisible(false); }, }, { key: 'tomorrow', label: 'Tomorrow', onClick() { setDate(dayjs().add(1, 'day')); setVisible(false); }, }, { key: 'custom-date', label: (
{ e.stopPropagation(); setPanelVisible(true); }} >
Customize
{ e.stopPropagation(); }} style={{ height: 0, width: 0, overflow: 'hidden', position: 'absolute', top: 0, insetInlineStart: 0, }} > { setDate(date); setVisible(false); setPanelVisible(false); }} />
), }, ], }} > {date.format('YYYY-MM-DD')}
); }; export default App;