Skip to content

Commit

Permalink
Add prop to render elements after calendar (mui#1795)
Browse files Browse the repository at this point in the history
This allows us to render anything after the calendar (buttons, text…)
by passing the renderCalendarInfo props to DateRangePicker.
  • Loading branch information
Julien Enselme committed Jun 26, 2020
1 parent 757384e commit 2aef2d2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/src/DateRangePicker/DateRangePickerViewDesktop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface ExportedDesktopDateRangeCalendarProps {
* @default 2
*/
calendars?: 1 | 2 | 3;
renderCalendarInfo?: React.ReactNode;
}

interface DesktopDateRangeCalendarProps
Expand Down Expand Up @@ -93,6 +94,7 @@ export const DateRangePickerViewDesktop: React.FC<DesktopDateRangeCalendarProps>
maxDate: __maxDate,
currentlySelectingRangeEnd,
currentMonth,
renderCalendarInfo,
...other
}) => {
const utils = useUtils();
Expand Down Expand Up @@ -188,6 +190,7 @@ export const DateRangePickerViewDesktop: React.FC<DesktopDateRangeCalendarProps>
/>
)}
/>
{renderCalendarInfo}
</div>
);
})}
Expand Down
6 changes: 5 additions & 1 deletion lib/src/DateRangePicker/DateRangePickerViewMobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import {
DateValidationProps,
} from '../_helpers/date-utils';

export interface ExportedMobileDateRangeCalendarProps {}
export interface ExportedMobileDateRangeCalendarProps {
renderCalendarInfo?: React.ReactNode;
}

interface DesktopDateRangeCalendarProps
extends ExportedMobileDateRangeCalendarProps,
Expand All @@ -39,6 +41,7 @@ export const DateRangePickerViewMobile: React.FC<DesktopDateRangeCalendarProps>
rightArrowButtonProps,
rightArrowButtonText,
rightArrowIcon,
renderCalendarInfo,
...other
}) => {
const utils = useUtils();
Expand Down Expand Up @@ -79,6 +82,7 @@ export const DateRangePickerViewMobile: React.FC<DesktopDateRangeCalendarProps>
/>
)}
/>
{renderCalendarInfo}
</>
);
};
1 change: 1 addition & 0 deletions lib/src/wrappers/Wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { MobileWrapper, MobileWrapperProps } from './MobileWrapper';
import { DesktopWrapper, DesktopWrapperProps } from './DesktopWrapper';
import { ResponsiveWrapper, ResponsiveWrapperProps } from './ResponsiveWrapper';
import { DesktopPopperWrapper, DesktopPopperWrapperProps } from './DesktopPopperWrapper';
import { PropTypes } from '@material-ui/core';

export type DateInputPropsLike<TInputValue, TDateValue> = Omit<
DateInputProps<TInputValue, TDateValue>,
Expand Down

0 comments on commit 2aef2d2

Please sign in to comment.