-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
Day.js
122 lines (99 loc) · 3.02 KB
/
Day.js
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import PropTypes from 'prop-types'
import React from 'react'
import { navigate } from './utils/constants'
import { DayLayoutAlgorithmPropType } from './utils/propTypes'
import TimeGrid from './TimeGrid'
class Day extends React.Component {
render() {
/**
* This allows us to default min, max, and scrollToTime
* using our localizer. This is necessary until such time
* as TODO: TimeGrid is converted to a functional component.
*/
let {
date,
localizer,
min = localizer.startOf(new Date(), 'day'),
max = localizer.endOf(new Date(), 'day'),
scrollToTime = localizer.startOf(new Date(), 'day'),
enableAutoScroll = true,
...props
} = this.props
let range = Day.range(date, { localizer: localizer })
return (
<TimeGrid
{...props}
range={range}
eventOffset={10}
localizer={localizer}
min={min}
max={max}
scrollToTime={scrollToTime}
enableAutoScroll={enableAutoScroll}
/>
)
}
}
Day.propTypes = {
date: PropTypes.instanceOf(Date).isRequired,
events: PropTypes.array.isRequired,
backgroundEvents: 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),
enableAutoScroll: PropTypes.bool,
showMultiDayTimes: PropTypes.bool,
rtl: PropTypes.bool,
resizable: PropTypes.bool,
width: PropTypes.number,
accessors: PropTypes.object.isRequired,
components: PropTypes.object.isRequired,
getters: PropTypes.object.isRequired,
localizer: PropTypes.object.isRequired,
allDayMaxRows: PropTypes.number,
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,
onKeyPressEvent: PropTypes.func,
onShowMore: PropTypes.func,
onDrillDown: PropTypes.func,
getDrilldownView: PropTypes.func.isRequired,
dayLayoutAlgorithm: DayLayoutAlgorithmPropType,
showAllEvents: PropTypes.bool,
doShowMoreDrillDown: PropTypes.bool,
popup: PropTypes.bool,
handleDragStart: PropTypes.func,
popupOffset: PropTypes.oneOfType([
PropTypes.number,
PropTypes.shape({
x: PropTypes.number,
y: PropTypes.number,
}),
]),
}
Day.range = (date, { localizer }) => {
return [localizer.startOf(date, 'day')]
}
Day.navigate = (date, action, { localizer }) => {
switch (action) {
case navigate.PREVIOUS:
return localizer.add(date, -1, 'day')
case navigate.NEXT:
return localizer.add(date, 1, 'day')
default:
return date
}
}
Day.title = (date, { localizer }) => localizer.format(date, 'dayHeaderFormat')
export default Day