-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
PopOverlay.js
95 lines (89 loc) · 2.28 KB
/
PopOverlay.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
import React, { useRef } from 'react'
import PropTypes from 'prop-types'
import { Overlay } from 'react-overlays'
import Popup from './Popup'
function CalOverlay({
containerRef,
popupOffset = 5,
overlay,
accessors,
localizer,
components,
getters,
selected,
handleSelectEvent,
handleDoubleClickEvent,
handleKeyPressEvent,
handleDragStart,
onHide,
overlayDisplay,
}) {
const popperRef = useRef(null)
if (!overlay.position) return null
let offset = popupOffset
if (!isNaN(popupOffset)) {
offset = { x: popupOffset, y: popupOffset }
}
const { position, events, date, end } = overlay
return (
<Overlay
rootClose
flip
show
placement="bottom"
onHide={onHide}
target={overlay.target}
>
{({ props }) => (
<Popup
{...props}
containerRef={containerRef}
ref={popperRef}
target={overlay.target}
offset={offset}
accessors={accessors}
getters={getters}
selected={selected}
components={components}
localizer={localizer}
position={position}
show={overlayDisplay}
events={events}
slotStart={date}
slotEnd={end}
onSelect={handleSelectEvent}
onDoubleClick={handleDoubleClickEvent}
onKeyPress={handleKeyPressEvent}
handleDragStart={handleDragStart}
/>
)}
</Overlay>
)
}
const PopOverlay = React.forwardRef((props, ref) => (
<CalOverlay {...props} containerRef={ref} />
))
PopOverlay.propTypes = {
popupOffset: PropTypes.oneOfType([
PropTypes.number,
PropTypes.shape({ x: PropTypes.number, y: PropTypes.number }),
]),
overlay: PropTypes.shape({
position: PropTypes.object,
events: PropTypes.array,
date: PropTypes.instanceOf(Date),
end: PropTypes.instanceOf(Date),
}),
accessors: PropTypes.object.isRequired,
localizer: PropTypes.object.isRequired,
components: PropTypes.object.isRequired,
getters: PropTypes.object.isRequired,
selected: PropTypes.object,
handleSelectEvent: PropTypes.func,
handleDoubleClickEvent: PropTypes.func,
handleKeyPressEvent: PropTypes.func,
handleDragStart: PropTypes.func,
onHide: PropTypes.func,
overlayDisplay: PropTypes.func,
}
export default PopOverlay