-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
EventRowMixin.js
81 lines (71 loc) · 1.88 KB
/
EventRowMixin.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
import PropTypes from 'prop-types'
import React from 'react'
import EventCell from './EventCell'
import { isSelected } from './utils/selection'
/* eslint-disable react/prop-types */
export default {
propTypes: {
slotMetrics: PropTypes.object.isRequired,
selected: PropTypes.object,
isAllDay: PropTypes.bool,
accessors: PropTypes.object.isRequired,
localizer: PropTypes.object.isRequired,
components: PropTypes.object.isRequired,
getters: PropTypes.object.isRequired,
onSelect: PropTypes.func,
onDoubleClick: PropTypes.func,
onKeyPress: PropTypes.func,
},
defaultProps: {
segments: [],
selected: {},
},
renderEvent(props, event) {
let {
selected,
isAllDay: _,
accessors,
getters,
onSelect,
onDoubleClick,
onKeyPress,
localizer,
slotMetrics,
components,
resizable,
} = props
let continuesPrior = slotMetrics.continuesPrior(event)
let continuesAfter = slotMetrics.continuesAfter(event)
return (
<EventCell
event={event}
getters={getters}
localizer={localizer}
accessors={accessors}
components={components}
onSelect={onSelect}
onDoubleClick={onDoubleClick}
onKeyPress={onKeyPress}
continuesPrior={continuesPrior}
continuesAfter={continuesAfter}
slotStart={slotMetrics.first}
slotEnd={slotMetrics.last}
selected={isSelected(event, selected)}
resizable={resizable}
/>
)
},
renderSpan(slots, len, key, content = ' ') {
let per = (Math.abs(len) / slots) * 100 + '%'
return (
<div
key={key}
className="rbc-row-segment"
// IE10/11 need max-width. flex-basis doesn't respect box-sizing
style={{ WebkitFlexBasis: per, flexBasis: per, maxWidth: per }}
>
{content}
</div>
)
},
}