@@ -6,11 +6,14 @@ import memoize from 'memoize-one'
66
77import DayColumn from './DayColumn'
88import TimeGutter from './TimeGutter'
9+ import TimeGridHeader from './TimeGridHeader'
10+ import PopOverlay from './PopOverlay'
911
1012import getWidth from 'dom-helpers/width'
11- import TimeGridHeader from './TimeGridHeader '
12- import { notify } from './utils/helpers '
13+ import getPosition from 'dom-helpers/position '
14+ import { views } from './utils/constants '
1315import { inRange , sortEvents } from './utils/eventLevels'
16+ import { notify } from './utils/helpers'
1417import Resources from './utils/Resources'
1518import { DayLayoutAlgorithmPropType } from './utils/propTypes'
1619
@@ -22,6 +25,7 @@ export default class TimeGrid extends Component {
2225
2326 this . scrollRef = React . createRef ( )
2427 this . contentRef = React . createRef ( )
28+ this . containerRef = React . createRef ( )
2529 this . _scrollRatio = null
2630 this . gutterRef = createRef ( )
2731 }
@@ -67,12 +71,50 @@ export default class TimeGrid extends Component {
6771 this . applyScroll ( )
6872 }
6973
70- handleSelectAlldayEvent = ( ...args ) => {
74+ handleKeyPressEvent = ( ...args ) => {
75+ this . clearSelection ( )
76+ notify ( this . props . onKeyPressEvent , args )
77+ }
78+
79+ handleSelectEvent = ( ...args ) => {
7180 //cancel any pending selections so only the event click goes through.
7281 this . clearSelection ( )
7382 notify ( this . props . onSelectEvent , args )
7483 }
7584
85+ handleDoubleClickEvent = ( ...args ) => {
86+ this . clearSelection ( )
87+ notify ( this . props . onDoubleClickEvent , args )
88+ }
89+
90+ handleShowMore = ( events , date , cell , slot , target ) => {
91+ const {
92+ popup,
93+ onDrillDown,
94+ onShowMore,
95+ getDrilldownView,
96+ doShowMoreDrillDown,
97+ } = this . props
98+ this . clearSelection ( )
99+
100+ if ( popup ) {
101+ let position = getPosition ( cell , this . containerRef . current )
102+
103+ this . setState ( {
104+ overlay : {
105+ date,
106+ events,
107+ position : { ...position , width : '200px' } ,
108+ target,
109+ } ,
110+ } )
111+ } else if ( doShowMoreDrillDown ) {
112+ notify ( onDrillDown , [ date , getDrilldownView ( date ) || views . DAY ] )
113+ }
114+
115+ notify ( onShowMore , [ events , date , slot ] )
116+ }
117+
76118 handleSelectAllDaySlot = ( slots , slotInfo ) => {
77119 const { onSelectSlot } = this . props
78120
@@ -202,6 +244,7 @@ export default class TimeGrid extends Component {
202244 'rbc-time-view' ,
203245 resources && 'rbc-time-view-resources'
204246 ) }
247+ ref = { this . containerRef }
205248 >
206249 < TimeGridHeader
207250 range = { range }
@@ -211,6 +254,11 @@ export default class TimeGrid extends Component {
211254 getNow = { getNow }
212255 localizer = { localizer }
213256 selected = { selected }
257+ allDayMaxRows = {
258+ this . props . showAllEvents
259+ ? Infinity
260+ : this . props . allDayMaxRows ?? Infinity
261+ }
214262 resources = { this . memoizedResources ( resources , accessors ) }
215263 selectable = { this . props . selectable }
216264 accessors = { accessors }
@@ -220,13 +268,15 @@ export default class TimeGrid extends Component {
220268 isOverflowing = { this . state . isOverflowing }
221269 longPressThreshold = { longPressThreshold }
222270 onSelectSlot = { this . handleSelectAllDaySlot }
223- onSelectEvent = { this . handleSelectAlldayEvent }
271+ onSelectEvent = { this . handleSelectEvent }
272+ onShowMore = { this . handleShowMore }
224273 onDoubleClickEvent = { this . props . onDoubleClickEvent }
225274 onKeyPressEvent = { this . props . onKeyPressEvent }
226275 onDrillDown = { this . props . onDrillDown }
227276 getDrilldownView = { this . props . getDrilldownView }
228277 resizable = { resizable }
229278 />
279+ { this . props . popup && this . renderOverlay ( ) }
230280 < div
231281 ref = { this . contentRef }
232282 className = "rbc-time-content"
@@ -256,6 +306,47 @@ export default class TimeGrid extends Component {
256306 )
257307 }
258308
309+ renderOverlay ( ) {
310+ let overlay = this . state ?. overlay ?? { }
311+ let {
312+ accessors,
313+ localizer,
314+ components,
315+ getters,
316+ selected,
317+ popupOffset,
318+ handleDragStart,
319+ } = this . props
320+
321+ const onHide = ( ) => this . setState ( { overlay : null } )
322+
323+ return (
324+ < PopOverlay
325+ overlay = { overlay }
326+ accessors = { accessors }
327+ localizer = { localizer }
328+ components = { components }
329+ getters = { getters }
330+ selected = { selected }
331+ popupOffset = { popupOffset }
332+ ref = { this . containerRef }
333+ handleKeyPressEvent = { this . handleKeyPressEvent }
334+ handleSelectEvent = { this . handleSelectEvent }
335+ handleDoubleClickEvent = { this . handleDoubleClickEvent }
336+ handleDragStart = { handleDragStart }
337+ show = { ! ! overlay . position }
338+ overlayDisplay = { this . overlayDisplay }
339+ onHide = { onHide }
340+ />
341+ )
342+ }
343+
344+ overlayDisplay = ( ) => {
345+ this . setState ( {
346+ overlay : null ,
347+ } )
348+ }
349+
259350 clearSelection ( ) {
260351 clearTimeout ( this . _selectTimer )
261352 this . _pendingSelection = [ ]
@@ -341,6 +432,8 @@ TimeGrid.propTypes = {
341432 getters : PropTypes . object . isRequired ,
342433 localizer : PropTypes . object . isRequired ,
343434
435+ allDayMaxRows : PropTypes . number ,
436+
344437 selected : PropTypes . object ,
345438 selectable : PropTypes . oneOf ( [ true , false , 'ignoreEvents' ] ) ,
346439 longPressThreshold : PropTypes . number ,
@@ -350,12 +443,27 @@ TimeGrid.propTypes = {
350443 onSelectEnd : PropTypes . func ,
351444 onSelectStart : PropTypes . func ,
352445 onSelectEvent : PropTypes . func ,
446+ onShowMore : PropTypes . func ,
353447 onDoubleClickEvent : PropTypes . func ,
354448 onKeyPressEvent : PropTypes . func ,
355449 onDrillDown : PropTypes . func ,
356450 getDrilldownView : PropTypes . func . isRequired ,
357451
358452 dayLayoutAlgorithm : DayLayoutAlgorithmPropType ,
453+
454+ showAllEvents : PropTypes . bool ,
455+ doShowMoreDrillDown : PropTypes . bool ,
456+
457+ popup : PropTypes . bool ,
458+ handleDragStart : PropTypes . func ,
459+
460+ popupOffset : PropTypes . oneOfType ( [
461+ PropTypes . number ,
462+ PropTypes . shape ( {
463+ x : PropTypes . number ,
464+ y : PropTypes . number ,
465+ } ) ,
466+ ] ) ,
359467}
360468
361469TimeGrid . defaultProps = {
0 commit comments