diff --git a/.babelrc b/.babelrc index d08766d52..7a0f098c6 100644 --- a/.babelrc +++ b/.babelrc @@ -1,5 +1,8 @@ { "presets": ["jason"], + plugins: [ + ['transform-react-remove-prop-types', { mode: 'wrap' }], + ], "env": { "esm": { "presets": [ diff --git a/.size-snapshot.json b/.size-snapshot.json index cde87a8dd..d5fd570f0 100644 --- a/.size-snapshot.json +++ b/.size-snapshot.json @@ -1,12 +1,12 @@ { "./dist/react-big-calendar.js": { - "bundled": 470107, - "minified": 152579, - "gzipped": 42233 + "bundled": 469894, + "minified": 152522, + "gzipped": 42174 }, "./dist/react-big-calendar.min.js": { - "bundled": 439313, - "minified": 142681, - "gzipped": 39554 + "bundled": 412865, + "minified": 135555, + "gzipped": 38300 } } diff --git a/package.json b/package.json index 51dc1a5ba..dc8ff698a 100644 --- a/package.json +++ b/package.json @@ -72,6 +72,7 @@ "babel-core": "^7.0.0-bridge.0", "babel-eslint": "^10.0.1", "babel-jest": "^23.6.0", + "babel-plugin-transform-react-remove-prop-types": "^0.4.22", "babel-preset-jason": "^6.0.1", "bootstrap": "^3.3.5", "component-metadata-loader": "^4.0.0", diff --git a/src/Agenda.js b/src/Agenda.js index 04dbb4e1a..f185eec92 100644 --- a/src/Agenda.js +++ b/src/Agenda.js @@ -10,23 +10,6 @@ import { inRange } from './utils/eventLevels' import { isSelected } from './utils/selection' class Agenda extends React.Component { - static propTypes = { - events: PropTypes.array, - date: PropTypes.instanceOf(Date), - length: PropTypes.number.isRequired, - - selected: PropTypes.object, - - accessors: PropTypes.object.isRequired, - components: PropTypes.object.isRequired, - getters: PropTypes.object.isRequired, - localizer: PropTypes.object.isRequired, - } - - static defaultProps = { - length: 30, - } - componentDidMount() { this._adjustHeader() } @@ -200,6 +183,23 @@ class Agenda extends React.Component { } } +Agenda.propTypes = { + events: PropTypes.array, + date: PropTypes.instanceOf(Date), + length: PropTypes.number.isRequired, + + selected: PropTypes.object, + + accessors: PropTypes.object.isRequired, + components: PropTypes.object.isRequired, + getters: PropTypes.object.isRequired, + localizer: PropTypes.object.isRequired, +} + +Agenda.defaultProps = { + length: 30, +} + Agenda.range = (start, { length = Agenda.defaultProps.length }) => { let end = dates.add(start, length, 'day') return { start, end } diff --git a/src/BackgroundCells.js b/src/BackgroundCells.js index ecc6af5e2..62dab92e2 100644 --- a/src/BackgroundCells.js +++ b/src/BackgroundCells.js @@ -9,27 +9,6 @@ import { dateCellSelection, getSlotAtX, pointInBox } from './utils/selection' import Selection, { getBoundsForNode, isEvent } from './Selection' class BackgroundCells extends React.Component { - static propTypes = { - date: PropTypes.instanceOf(Date), - getNow: PropTypes.func.isRequired, - - getters: PropTypes.object.isRequired, - components: PropTypes.object.isRequired, - - container: PropTypes.func, - dayPropGetter: PropTypes.func, - selectable: PropTypes.oneOf([true, false, 'ignoreEvents']), - longPressThreshold: PropTypes.number, - - onSelectSlot: PropTypes.func.isRequired, - onSelectEnd: PropTypes.func, - onSelectStart: PropTypes.func, - - range: PropTypes.arrayOf(PropTypes.instanceOf(Date)), - rtl: PropTypes.bool, - type: PropTypes.string, - } - constructor(props, context) { super(props, context) @@ -185,4 +164,25 @@ class BackgroundCells extends React.Component { } } +BackgroundCells.propTypes = { + date: PropTypes.instanceOf(Date), + getNow: PropTypes.func.isRequired, + + getters: PropTypes.object.isRequired, + components: PropTypes.object.isRequired, + + container: PropTypes.func, + dayPropGetter: PropTypes.func, + selectable: PropTypes.oneOf([true, false, 'ignoreEvents']), + longPressThreshold: PropTypes.number, + + onSelectSlot: PropTypes.func.isRequired, + onSelectEnd: PropTypes.func, + onSelectStart: PropTypes.func, + + range: PropTypes.arrayOf(PropTypes.instanceOf(Date)), + rtl: PropTypes.bool, + type: PropTypes.string, +} + export default BackgroundCells diff --git a/src/Calendar.js b/src/Calendar.js index 999c8f8be..72c7110e3 100644 --- a/src/Calendar.js +++ b/src/Calendar.js @@ -952,7 +952,11 @@ class Calendar extends React.Component { } let views = this.getViews() - this.handleRangeChange(this.props.date || this.props.getNow(), views[view], view) + this.handleRangeChange( + this.props.date || this.props.getNow(), + views[view], + view + ) } handleSelectEvent = (...args) => { diff --git a/src/DateContentRow.js b/src/DateContentRow.js index 95d028e23..d5577f231 100644 --- a/src/DateContentRow.js +++ b/src/DateContentRow.js @@ -11,46 +11,6 @@ import EventRow from './EventRow' import EventEndingRow from './EventEndingRow' import * as DateSlotMetrics from './utils/DateSlotMetrics' -const propTypes = { - date: PropTypes.instanceOf(Date), - events: PropTypes.array.isRequired, - range: PropTypes.array.isRequired, - - rtl: PropTypes.bool, - resourceId: PropTypes.any, - renderForMeasure: PropTypes.bool, - renderHeader: PropTypes.func, - - container: PropTypes.func, - selected: PropTypes.object, - selectable: PropTypes.oneOf([true, false, 'ignoreEvents']), - longPressThreshold: PropTypes.number, - - onShowMore: PropTypes.func, - onSelectSlot: PropTypes.func, - onSelect: PropTypes.func, - onSelectEnd: PropTypes.func, - onSelectStart: PropTypes.func, - onDoubleClick: PropTypes.func, - dayPropGetter: PropTypes.func, - - getNow: PropTypes.func.isRequired, - isAllDay: PropTypes.bool, - - accessors: PropTypes.object.isRequired, - components: PropTypes.object.isRequired, - getters: PropTypes.object.isRequired, - localizer: PropTypes.object.isRequired, - - minRows: PropTypes.number.isRequired, - maxRows: PropTypes.number.isRequired, -} - -const defaultProps = { - minRows: 0, - maxRows: Infinity, -} - class DateContentRow extends React.Component { constructor(...args) { super(...args) @@ -218,7 +178,44 @@ class DateContentRow extends React.Component { } } -DateContentRow.propTypes = propTypes -DateContentRow.defaultProps = defaultProps +DateContentRow.propTypes = { + date: PropTypes.instanceOf(Date), + events: PropTypes.array.isRequired, + range: PropTypes.array.isRequired, + + rtl: PropTypes.bool, + resourceId: PropTypes.any, + renderForMeasure: PropTypes.bool, + renderHeader: PropTypes.func, + + container: PropTypes.func, + selected: PropTypes.object, + selectable: PropTypes.oneOf([true, false, 'ignoreEvents']), + longPressThreshold: PropTypes.number, + + onShowMore: PropTypes.func, + onSelectSlot: PropTypes.func, + onSelect: PropTypes.func, + onSelectEnd: PropTypes.func, + onSelectStart: PropTypes.func, + onDoubleClick: PropTypes.func, + dayPropGetter: PropTypes.func, + + getNow: PropTypes.func.isRequired, + isAllDay: PropTypes.bool, + + accessors: PropTypes.object.isRequired, + components: PropTypes.object.isRequired, + getters: PropTypes.object.isRequired, + localizer: PropTypes.object.isRequired, + + minRows: PropTypes.number.isRequired, + maxRows: PropTypes.number.isRequired, +} + +DateContentRow.defaultProps = { + minRows: 0, + maxRows: Infinity, +} export default DateContentRow diff --git a/src/Day.js b/src/Day.js index 26ee9e209..8176973e5 100644 --- a/src/Day.js +++ b/src/Day.js @@ -6,10 +6,6 @@ import { navigate } from './utils/constants' import TimeGrid from './TimeGrid' class Day extends React.Component { - static propTypes = { - date: PropTypes.instanceOf(Date).isRequired, - } - render() { let { date, ...props } = this.props let range = Day.range(date) @@ -18,6 +14,10 @@ class Day extends React.Component { } } +Day.propTypes = { + date: PropTypes.instanceOf(Date).isRequired, +} + Day.range = date => { return [dates.startOf(date, 'day')] } diff --git a/src/DayColumn.js b/src/DayColumn.js index 3a675297b..8771f3ceb 100644 --- a/src/DayColumn.js +++ b/src/DayColumn.js @@ -14,46 +14,6 @@ import TimeSlotGroup from './TimeSlotGroup' import TimeGridEvent from './TimeGridEvent' class DayColumn extends React.Component { - static propTypes = { - events: PropTypes.array.isRequired, - step: PropTypes.number.isRequired, - date: PropTypes.instanceOf(Date).isRequired, - min: PropTypes.instanceOf(Date).isRequired, - max: PropTypes.instanceOf(Date).isRequired, - getNow: PropTypes.func.isRequired, - isNow: PropTypes.bool, - - rtl: PropTypes.bool, - - accessors: PropTypes.object.isRequired, - components: PropTypes.object.isRequired, - getters: PropTypes.object.isRequired, - localizer: PropTypes.object.isRequired, - - showMultiDayTimes: PropTypes.bool, - culture: PropTypes.string, - timeslots: PropTypes.number, - - selected: PropTypes.object, - selectable: PropTypes.oneOf([true, false, 'ignoreEvents']), - eventOffset: PropTypes.number, - longPressThreshold: PropTypes.number, - - onSelecting: PropTypes.func, - onSelectSlot: PropTypes.func.isRequired, - onSelectEvent: PropTypes.func.isRequired, - onDoubleClickEvent: PropTypes.func.isRequired, - - className: PropTypes.string, - dragThroughEvents: PropTypes.bool, - resource: PropTypes.any, - } - - static defaultProps = { - dragThroughEvents: true, - timeslots: 2, - } - state = { selecting: false, timeIndicatorPosition: null } constructor(...args) { @@ -390,4 +350,44 @@ class DayColumn extends React.Component { } } +DayColumn.propTypes = { + events: PropTypes.array.isRequired, + step: PropTypes.number.isRequired, + date: PropTypes.instanceOf(Date).isRequired, + min: PropTypes.instanceOf(Date).isRequired, + max: PropTypes.instanceOf(Date).isRequired, + getNow: PropTypes.func.isRequired, + isNow: PropTypes.bool, + + rtl: PropTypes.bool, + + accessors: PropTypes.object.isRequired, + components: PropTypes.object.isRequired, + getters: PropTypes.object.isRequired, + localizer: PropTypes.object.isRequired, + + showMultiDayTimes: PropTypes.bool, + culture: PropTypes.string, + timeslots: PropTypes.number, + + selected: PropTypes.object, + selectable: PropTypes.oneOf([true, false, 'ignoreEvents']), + eventOffset: PropTypes.number, + longPressThreshold: PropTypes.number, + + onSelecting: PropTypes.func, + onSelectSlot: PropTypes.func.isRequired, + onSelectEvent: PropTypes.func.isRequired, + onDoubleClickEvent: PropTypes.func.isRequired, + + className: PropTypes.string, + dragThroughEvents: PropTypes.bool, + resource: PropTypes.any, +} + +DayColumn.defaultProps = { + dragThroughEvents: true, + timeslots: 2, +} + export default DayColumn diff --git a/src/EventCell.js b/src/EventCell.js index 1ea0b7589..513be0353 100644 --- a/src/EventCell.js +++ b/src/EventCell.js @@ -3,25 +3,6 @@ import React from 'react' import cn from 'classnames' import dates from './utils/dates' -let propTypes = { - event: PropTypes.object.isRequired, - slotStart: PropTypes.instanceOf(Date), - slotEnd: PropTypes.instanceOf(Date), - - selected: PropTypes.bool, - isAllDay: PropTypes.bool, - continuesPrior: PropTypes.bool, - continuesAfter: PropTypes.bool, - - accessors: PropTypes.object.isRequired, - components: PropTypes.object.isRequired, - getters: PropTypes.object.isRequired, - localizer: PropTypes.object, - - onSelect: PropTypes.func, - onDoubleClick: PropTypes.func, -} - class EventCell extends React.Component { render() { let { @@ -89,6 +70,23 @@ class EventCell extends React.Component { } } -EventCell.propTypes = propTypes +EventCell.propTypes = { + event: PropTypes.object.isRequired, + slotStart: PropTypes.instanceOf(Date), + slotEnd: PropTypes.instanceOf(Date), + + selected: PropTypes.bool, + isAllDay: PropTypes.bool, + continuesPrior: PropTypes.bool, + continuesAfter: PropTypes.bool, + + accessors: PropTypes.object.isRequired, + components: PropTypes.object.isRequired, + getters: PropTypes.object.isRequired, + localizer: PropTypes.object, + + onSelect: PropTypes.func, + onDoubleClick: PropTypes.func, +} export default EventCell diff --git a/src/EventEndingRow.js b/src/EventEndingRow.js index 16e47c6b7..798d3c4c7 100644 --- a/src/EventEndingRow.js +++ b/src/EventEndingRow.js @@ -9,18 +9,11 @@ let eventsInSlot = (segments, slot) => segments.filter(seg => isSegmentInSlot(seg, slot)).length class EventEndingRow extends React.Component { - static propTypes = { - segments: PropTypes.array, - slots: PropTypes.number, - onShowMore: PropTypes.func, - ...EventRowMixin.propTypes, - } - static defaultProps = { - ...EventRowMixin.defaultProps, - } - render() { - let { segments, slotMetrics: { slots } } = this.props + let { + segments, + slotMetrics: { slots }, + } = this.props let rowSegments = eventLevels(segments).levels[0] let current = 1, @@ -104,4 +97,15 @@ class EventEndingRow extends React.Component { } } +EventEndingRow.propTypes = { + segments: PropTypes.array, + slots: PropTypes.number, + onShowMore: PropTypes.func, + ...EventRowMixin.propTypes, +} + +EventEndingRow.defaultProps = { + ...EventRowMixin.defaultProps, +} + export default EventEndingRow diff --git a/src/EventRow.js b/src/EventRow.js index f1e98a13b..772c48dff 100644 --- a/src/EventRow.js +++ b/src/EventRow.js @@ -4,15 +4,12 @@ import React from 'react' import EventRowMixin from './EventRowMixin' class EventRow extends React.Component { - static propTypes = { - segments: PropTypes.array, - ...EventRowMixin.propTypes, - } - static defaultProps = { - ...EventRowMixin.defaultProps, - } render() { - let { segments, slotMetrics: { slots }, className } = this.props + let { + segments, + slotMetrics: { slots }, + className, + } = this.props let lastEnd = 1 @@ -37,4 +34,13 @@ class EventRow extends React.Component { } } +EventRow.propTypes = { + segments: PropTypes.array, + ...EventRowMixin.propTypes, +} + +EventRow.defaultProps = { + ...EventRowMixin.defaultProps, +} + export default EventRow diff --git a/src/Month.js b/src/Month.js index b3cb07b82..58e2eab1d 100644 --- a/src/Month.js +++ b/src/Month.js @@ -22,52 +22,7 @@ import { inRange, sortEvents } from './utils/eventLevels' let eventsForWeek = (evts, start, end, accessors) => evts.filter(e => inRange(e, start, end, accessors)) -let propTypes = { - events: PropTypes.array.isRequired, - date: PropTypes.instanceOf(Date), - - min: PropTypes.instanceOf(Date), - max: PropTypes.instanceOf(Date), - - step: PropTypes.number, - getNow: PropTypes.func.isRequired, - - scrollToTime: PropTypes.instanceOf(Date), - rtl: PropTypes.bool, - width: PropTypes.number, - - accessors: PropTypes.object.isRequired, - components: PropTypes.object.isRequired, - getters: PropTypes.object.isRequired, - localizer: PropTypes.object.isRequired, - - selected: PropTypes.object, - selectable: PropTypes.oneOf([true, false, 'ignoreEvents']), - longPressThreshold: PropTypes.number, - - onNavigate: PropTypes.func, - onSelectSlot: PropTypes.func, - onSelectEvent: PropTypes.func, - onDoubleClickEvent: PropTypes.func, - onShowMore: PropTypes.func, - onDrillDown: PropTypes.func, - getDrilldownView: PropTypes.func.isRequired, - - popup: PropTypes.bool, - - popupOffset: PropTypes.oneOfType([ - PropTypes.number, - PropTypes.shape({ - x: PropTypes.number, - y: PropTypes.number, - }), - ]), -} - class MonthView extends React.Component { - static displayName = 'MonthView' - static propTypes = propTypes - constructor(...args) { super(...args) @@ -327,6 +282,48 @@ class MonthView extends React.Component { } } +MonthView.propTypes = { + events: PropTypes.array.isRequired, + date: PropTypes.instanceOf(Date), + + min: PropTypes.instanceOf(Date), + max: PropTypes.instanceOf(Date), + + step: PropTypes.number, + getNow: PropTypes.func.isRequired, + + scrollToTime: PropTypes.instanceOf(Date), + rtl: PropTypes.bool, + width: PropTypes.number, + + accessors: PropTypes.object.isRequired, + components: PropTypes.object.isRequired, + getters: PropTypes.object.isRequired, + localizer: PropTypes.object.isRequired, + + selected: PropTypes.object, + selectable: PropTypes.oneOf([true, false, 'ignoreEvents']), + longPressThreshold: PropTypes.number, + + onNavigate: PropTypes.func, + onSelectSlot: PropTypes.func, + onSelectEvent: PropTypes.func, + onDoubleClickEvent: PropTypes.func, + onShowMore: PropTypes.func, + onDrillDown: PropTypes.func, + getDrilldownView: PropTypes.func.isRequired, + + popup: PropTypes.bool, + + popupOffset: PropTypes.oneOfType([ + PropTypes.number, + PropTypes.shape({ + x: PropTypes.number, + y: PropTypes.number, + }), + ]), +} + MonthView.range = (date, { localizer }) => { let start = dates.firstVisibleDay(date, localizer) let end = dates.lastVisibleDay(date, localizer) diff --git a/src/Popup.js b/src/Popup.js index b3f3979b6..abf455148 100644 --- a/src/Popup.js +++ b/src/Popup.js @@ -8,28 +8,6 @@ import dates from './utils/dates' import EventCell from './EventCell' import { isSelected } from './utils/selection' -const propTypes = { - position: PropTypes.object, - popupOffset: PropTypes.oneOfType([ - PropTypes.number, - PropTypes.shape({ - x: PropTypes.number, - y: PropTypes.number, - }), - ]), - events: PropTypes.array, - selected: PropTypes.object, - - accessors: PropTypes.object.isRequired, - components: PropTypes.object.isRequired, - getters: PropTypes.object.isRequired, - localizer: PropTypes.object.isRequired, - onSelect: PropTypes.func, - onDoubleClick: PropTypes.func, - slotStart: PropTypes.instanceOf(Date), - slotEnd: PropTypes.number, -} - class Popup extends React.Component { componentDidMount() { let { popupOffset = 5 } = this.props, @@ -100,6 +78,26 @@ class Popup extends React.Component { } } -Popup.propTypes = propTypes +Popup.propTypes = { + position: PropTypes.object, + popupOffset: PropTypes.oneOfType([ + PropTypes.number, + PropTypes.shape({ + x: PropTypes.number, + y: PropTypes.number, + }), + ]), + events: PropTypes.array, + selected: PropTypes.object, + + accessors: PropTypes.object.isRequired, + components: PropTypes.object.isRequired, + getters: PropTypes.object.isRequired, + localizer: PropTypes.object.isRequired, + onSelect: PropTypes.func, + onDoubleClick: PropTypes.func, + slotStart: PropTypes.instanceOf(Date), + slotEnd: PropTypes.number, +} export default Popup diff --git a/src/TimeGrid.js b/src/TimeGrid.js index c3ba681d3..c96c87e5a 100644 --- a/src/TimeGrid.js +++ b/src/TimeGrid.js @@ -16,50 +16,6 @@ import { inRange, sortEvents } from './utils/eventLevels' import Resources from './utils/Resources' export default class TimeGrid extends Component { - static propTypes = { - events: PropTypes.array.isRequired, - resources: PropTypes.array, - - step: PropTypes.number, - timeslots: PropTypes.number, - range: PropTypes.arrayOf(PropTypes.instanceOf(Date)), - min: PropTypes.instanceOf(Date), - max: PropTypes.instanceOf(Date), - getNow: PropTypes.func.isRequired, - - scrollToTime: PropTypes.instanceOf(Date), - showMultiDayTimes: PropTypes.bool, - - rtl: PropTypes.bool, - width: PropTypes.number, - - accessors: PropTypes.object.isRequired, - components: PropTypes.object.isRequired, - getters: PropTypes.object.isRequired, - localizer: PropTypes.object.isRequired, - - selected: PropTypes.object, - selectable: PropTypes.oneOf([true, false, 'ignoreEvents']), - longPressThreshold: PropTypes.number, - - onNavigate: PropTypes.func, - onSelectSlot: PropTypes.func, - onSelectEnd: PropTypes.func, - onSelectStart: PropTypes.func, - onSelectEvent: PropTypes.func, - onDoubleClickEvent: PropTypes.func, - onDrillDown: PropTypes.func, - getDrilldownView: PropTypes.func.isRequired, - } - - static defaultProps = { - step: 30, - timeslots: 2, - min: dates.startOf(new Date(), 'day'), - max: dates.endOf(new Date(), 'day'), - scrollToTime: dates.startOf(new Date(), 'day'), - } - constructor(props) { super(props) @@ -94,7 +50,7 @@ export default class TimeGrid extends Component { raf.cancel(this.rafHandle) this.rafHandle = raf(this.checkOverflow) } - + componentWillUnmount() { window.removeEventListener('resize', this.handleResize) @@ -327,5 +283,51 @@ export default class TimeGrid extends Component { } } - memoizedResources = memoize((resources, accessors) => Resources(resources, accessors)) + memoizedResources = memoize((resources, accessors) => + Resources(resources, accessors) + ) +} + +TimeGrid.propTypes = { + events: PropTypes.array.isRequired, + resources: PropTypes.array, + + step: PropTypes.number, + timeslots: PropTypes.number, + range: PropTypes.arrayOf(PropTypes.instanceOf(Date)), + min: PropTypes.instanceOf(Date), + max: PropTypes.instanceOf(Date), + getNow: PropTypes.func.isRequired, + + scrollToTime: PropTypes.instanceOf(Date), + showMultiDayTimes: PropTypes.bool, + + rtl: PropTypes.bool, + width: PropTypes.number, + + accessors: PropTypes.object.isRequired, + components: PropTypes.object.isRequired, + getters: PropTypes.object.isRequired, + localizer: PropTypes.object.isRequired, + + selected: PropTypes.object, + selectable: PropTypes.oneOf([true, false, 'ignoreEvents']), + longPressThreshold: PropTypes.number, + + onNavigate: PropTypes.func, + onSelectSlot: PropTypes.func, + onSelectEnd: PropTypes.func, + onSelectStart: PropTypes.func, + onSelectEvent: PropTypes.func, + onDoubleClickEvent: PropTypes.func, + onDrillDown: PropTypes.func, + getDrilldownView: PropTypes.func.isRequired, +} + +TimeGrid.defaultProps = { + step: 30, + timeslots: 2, + min: dates.startOf(new Date(), 'day'), + max: dates.endOf(new Date(), 'day'), + scrollToTime: dates.startOf(new Date(), 'day'), } diff --git a/src/TimeGridHeader.js b/src/TimeGridHeader.js index 1562473eb..f06b86714 100644 --- a/src/TimeGridHeader.js +++ b/src/TimeGridHeader.js @@ -9,33 +9,6 @@ import Header from './Header' import { notify } from './utils/helpers' class TimeGridHeader extends React.Component { - static propTypes = { - range: PropTypes.array.isRequired, - events: PropTypes.array.isRequired, - resources: PropTypes.object, - getNow: PropTypes.func.isRequired, - isOverflowing: PropTypes.bool, - - rtl: PropTypes.bool, - width: PropTypes.number, - - localizer: PropTypes.object.isRequired, - accessors: PropTypes.object.isRequired, - components: PropTypes.object.isRequired, - getters: PropTypes.object.isRequired, - - selected: PropTypes.object, - selectable: PropTypes.oneOf([true, false, 'ignoreEvents']), - longPressThreshold: PropTypes.number, - - onSelectSlot: PropTypes.func, - onSelectEvent: PropTypes.func, - onDoubleClickEvent: PropTypes.func, - onDrillDown: PropTypes.func, - getDrilldownView: PropTypes.func.isRequired, - scrollRef: PropTypes.any, - } - handleHeaderClick = (date, view, e) => { e.preventDefault() notify(this.props.onDrillDown, [date, view]) @@ -209,4 +182,31 @@ class TimeGridHeader extends React.Component { } } +TimeGridHeader.propTypes = { + range: PropTypes.array.isRequired, + events: PropTypes.array.isRequired, + resources: PropTypes.object, + getNow: PropTypes.func.isRequired, + isOverflowing: PropTypes.bool, + + rtl: PropTypes.bool, + width: PropTypes.number, + + localizer: PropTypes.object.isRequired, + accessors: PropTypes.object.isRequired, + components: PropTypes.object.isRequired, + getters: PropTypes.object.isRequired, + + selected: PropTypes.object, + selectable: PropTypes.oneOf([true, false, 'ignoreEvents']), + longPressThreshold: PropTypes.number, + + onSelectSlot: PropTypes.func, + onSelectEvent: PropTypes.func, + onDoubleClickEvent: PropTypes.func, + onDrillDown: PropTypes.func, + getDrilldownView: PropTypes.func.isRequired, + scrollRef: PropTypes.any, +} + export default TimeGridHeader diff --git a/src/TimeGutter.js b/src/TimeGutter.js index 3824e0471..6d833bfc6 100644 --- a/src/TimeGutter.js +++ b/src/TimeGutter.js @@ -6,18 +6,6 @@ import * as TimeSlotUtils from './utils/TimeSlots' import TimeSlotGroup from './TimeSlotGroup' export default class TimeGutter extends Component { - static propTypes = { - min: PropTypes.instanceOf(Date).isRequired, - max: PropTypes.instanceOf(Date).isRequired, - timeslots: PropTypes.number.isRequired, - step: PropTypes.number.isRequired, - getNow: PropTypes.func.isRequired, - components: PropTypes.object.isRequired, - - localizer: PropTypes.object.isRequired, - resource: PropTypes.string, - } - constructor(...args) { super(...args) @@ -67,3 +55,15 @@ export default class TimeGutter extends Component { ) } } + +TimeGutter.propTypes = { + min: PropTypes.instanceOf(Date).isRequired, + max: PropTypes.instanceOf(Date).isRequired, + timeslots: PropTypes.number.isRequired, + step: PropTypes.number.isRequired, + getNow: PropTypes.func.isRequired, + components: PropTypes.object.isRequired, + + localizer: PropTypes.object.isRequired, + resource: PropTypes.string, +} diff --git a/src/TimeSlotGroup.js b/src/TimeSlotGroup.js index ab964b57a..a3f6e1d89 100644 --- a/src/TimeSlotGroup.js +++ b/src/TimeSlotGroup.js @@ -5,14 +5,6 @@ import React, { Component } from 'react' import BackgroundWrapper from './BackgroundWrapper' export default class TimeSlotGroup extends Component { - static propTypes = { - renderSlot: PropTypes.func, - group: PropTypes.array.isRequired, - resource: PropTypes.any, - components: PropTypes.object, - getters: PropTypes.object, - } - render() { const { renderSlot, @@ -41,3 +33,11 @@ export default class TimeSlotGroup extends Component { ) } } + +TimeSlotGroup.propTypes = { + renderSlot: PropTypes.func, + group: PropTypes.array.isRequired, + resource: PropTypes.any, + components: PropTypes.object, + getters: PropTypes.object, +} diff --git a/src/Toolbar.js b/src/Toolbar.js index 0fe370413..7a1ebf1ca 100644 --- a/src/Toolbar.js +++ b/src/Toolbar.js @@ -4,17 +4,11 @@ import cn from 'classnames' import { navigate } from './utils/constants' class Toolbar extends React.Component { - static propTypes = { - view: PropTypes.string.isRequired, - views: PropTypes.arrayOf(PropTypes.string).isRequired, - label: PropTypes.node.isRequired, - localizer: PropTypes.object, - onNavigate: PropTypes.func.isRequired, - onView: PropTypes.func.isRequired, - } - render() { - let { localizer: { messages }, label } = this.props + let { + localizer: { messages }, + label, + } = this.props return (