feat: add new pickerAppearance option 'monthOnly'

This commit is contained in:
Felix Hofmann
2022-08-12 12:36:47 +02:00
parent 9e4e4b231c
commit 566c6ba3a9
6 changed files with 94 additions and 4 deletions

View File

@@ -31,6 +31,7 @@ const DateTime: React.FC<Props> = (props) => {
if (dateTimeFormat === undefined) {
if (pickerAppearance === 'dayAndTime') dateTimeFormat = 'MMM d, yyy h:mm a';
else if (pickerAppearance === 'timeOnly') dateTimeFormat = 'h:mm a';
else if (pickerAppearance === 'monthOnly') dateTimeFormat = 'MM/yyyy';
else dateTimeFormat = 'MMM d, yyy';
}
@@ -50,6 +51,7 @@ const DateTime: React.FC<Props> = (props) => {
showPopperArrow: false,
selected: value && new Date(value),
customInputRef: 'ref',
showMonthYearPicker: pickerAppearance === 'monthOnly',
};
const classes = [

View File

@@ -1,6 +1,6 @@
type SharedProps = {
displayFormat?: string | undefined
pickerAppearance?: 'dayAndTime' | 'timeOnly' | 'dayOnly'
displayFormat?: string
pickerAppearance?: 'dayAndTime' | 'timeOnly' | 'dayOnly' | 'monthOnly'
}
type TimePickerProps = {
@@ -16,6 +16,11 @@ type DayPickerProps = {
maxDate?: Date
}
type MonthPickerProps = {
minDate?: Date
maxDate?: Date
}
export type ConditionalDateProps =
| SharedProps & DayPickerProps & TimePickerProps & {
pickerAppearance?: 'dayAndTime'
@@ -26,6 +31,9 @@ export type ConditionalDateProps =
| SharedProps & DayPickerProps & {
pickerAppearance: 'dayOnly'
}
| SharedProps & MonthPickerProps & {
pickerAppearance: 'monthOnly'
}
export type Props = SharedProps & DayPickerProps & TimePickerProps & {
value?: Date