-
Notifications
You must be signed in to change notification settings - Fork 276
Expand file tree
/
Copy pathEditableCalendarInput.tsx
More file actions
32 lines (29 loc) · 887 Bytes
/
EditableCalendarInput.tsx
File metadata and controls
32 lines (29 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { FC } from 'react'
import { Text } from '@react-pdf/renderer'
import DatePicker from 'react-datepicker'
import 'react-datepicker/dist/react-datepicker.css'
import compose from '../styles/compose'
interface Props {
className?: string
value?: string
selected?: Date
onChange?: (date: Date | [Date, Date] | null) => void
pdfMode?: boolean
}
const EditableCalendarInput: FC<Props> = ({ className, value, selected, onChange, pdfMode }) => {
return (
<>
{pdfMode ? (
<Text style={compose('span ' + (className ? className : ''))}>{value}</Text>
) : (
<DatePicker
className={'input ' + (className ? className : 'flex-item')}
selected={selected}
onChange={onChange ? (date) => onChange(date) : () => null}
dateFormat="dd.MM.yyyy"
/>
)}
</>
)
}
export default EditableCalendarInput