|
| 1 | +import isFunction from 'lodash/isFunction'; |
1 | 2 | import PropTypes from 'prop-types'; |
2 | 3 | import XDate from 'xdate'; |
3 | 4 | import memoize from 'memoize-one'; |
@@ -43,6 +44,8 @@ export type AgendaProps = CalendarListProps & ReservationListProps & { |
43 | 44 | onDayChange?: (data: DateData) => void; |
44 | 45 | /** specify how agenda knob should look like */ |
45 | 46 | renderKnob?: () => JSX.Element; |
| 47 | + /** override inner list with a custom implemented component */ |
| 48 | + renderList?: (listProps: ReservationListProps) => JSX.Element; |
46 | 49 | /** initially selected day */ |
47 | 50 | selected?: string; //TODO: Should be renamed 'selectedDay' and inherited from ReservationList |
48 | 51 | /** Hide knob button. Default = false */ |
@@ -79,6 +82,7 @@ export default class Agenda extends Component<AgendaProps, State> { |
79 | 82 | onCalendarToggled: PropTypes.func, |
80 | 83 | onDayChange: PropTypes.func, |
81 | 84 | renderKnob: PropTypes.func, |
| 85 | + renderList: PropTypes.func, |
82 | 86 | selected: PropTypes.any, //TODO: Should be renamed 'selectedDay' and inherited from ReservationList |
83 | 87 | hideKnob: PropTypes.bool, |
84 | 88 | showClosingKnob: PropTypes.bool |
@@ -329,6 +333,14 @@ export default class Agenda extends Component<AgendaProps, State> { |
329 | 333 |
|
330 | 334 | renderReservations() { |
331 | 335 | const reservationListProps = extractReservationListProps(this.props); |
| 336 | + if (isFunction(this.props.renderList)) { |
| 337 | + return this.props.renderList({ |
| 338 | + ...reservationListProps, |
| 339 | + selectedDay: this.state.selectedDay, |
| 340 | + topDay: this.state.topDay, |
| 341 | + onDayChange: this.onDayChange, |
| 342 | + }); |
| 343 | + } |
332 | 344 |
|
333 | 345 | return ( |
334 | 346 | <ReservationList |
|
0 commit comments