Skip to content

Commit c9ed1e8

Browse files
committed
Merge remote-tracking branch 'upstream/master' into add-background-events-feature
2 parents e62b716 + 8ffe39d commit c9ed1e8

23 files changed

+232
-92
lines changed

.size-snapshot.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
{
22
"./dist/react-big-calendar.js": {
3-
"bundled": 507436,
4-
"minified": 149016,
5-
"gzipped": 45496
3+
"bundled": 509547,
4+
"minified": 149932,
5+
"gzipped": 45769
66
},
77
"./dist/react-big-calendar.min.js": {
8-
"bundled": 444328,
9-
"minified": 130089,
10-
"gzipped": 41174
8+
"bundled": 446246,
9+
"minified": 130919,
10+
"gzipped": 41339
1111
},
1212
"dist/react-big-calendar.esm.js": {
13-
"bundled": 174497,
14-
"minified": 83179,
15-
"gzipped": 20739,
13+
"bundled": 176376,
14+
"minified": 84316,
15+
"gzipped": 21023,
1616
"treeshaked": {
1717
"rollup": {
18-
"code": 60400,
19-
"import_statements": 1578
18+
"code": 60196,
19+
"import_statements": 1590
2020
},
2121
"webpack": {
22-
"code": 64923
22+
"code": 64714
2323
}
2424
}
2525
}

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ $ yarn examples
3131

3232
### Localization and Date Formatting
3333

34-
`react-big-calendar` includes two options for handling the date formatting and culture localization, depending
35-
on your preference of DateTime libraries. You can use either the [Moment.js](http://momentjs.com/) or [Globalize.js](https://github.com/jquery/globalize) localizers.
34+
`react-big-calendar` includes three options for handling the date formatting and culture localization, depending
35+
on your preference of DateTime libraries. You can use either the [Moment.js](https://momentjs.com/), [Globalize.js](https://github.com/jquery/globalize) or [date-fns](https://date-fns.org/) localizers.
3636

3737
Regardless of your choice, you **must** choose a localizer to use this library:
3838

@@ -126,4 +126,4 @@ Big Calendar. Carefully test each change accordingly.
126126

127127
## Join us on Reactiflux Discord
128128

129-
Join us on [Reactiflux Discord](https://discord.gg/PPgj6tb) community under the channel #libraries if you have any questions.
129+
Join us on [Reactiflux Discord](https://discord.gg/reactiflux) community under the channel #libraries if you have any questions.

examples/demos/dndOutsideSource.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class Dnd extends React.Component {
6767
this.newEvent(event)
6868
}
6969

70-
moveEvent({ event, start, end, isAllDay: droppedOnAllDaySlot }) {
70+
moveEvent = ({ event, start, end, isAllDay: droppedOnAllDaySlot }) => {
7171
const { events } = this.state
7272

7373
const idx = events.indexOf(event)
@@ -107,7 +107,7 @@ class Dnd extends React.Component {
107107
//alert(`${event.title} was resized to ${start}-${end}`)
108108
}
109109

110-
newEvent(event) {
110+
newEvent = event => {
111111
let idList = this.state.events.map(a => a.id)
112112
let newId = Math.max(...idList) + 1
113113
let hour = {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
"lodash-es": "^4.17.11",
138138
"memoize-one": "^5.1.1",
139139
"prop-types": "^15.7.2",
140-
"react-overlays": "^2.0.0-0",
140+
"react-overlays": "^4.1.1",
141141
"uncontrollable": "^7.0.0"
142142
},
143143
"resolutions": {

src/BackgroundCells.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ class BackgroundCells extends React.Component {
160160
action,
161161
bounds,
162162
box,
163+
resourceId: this.props.resourceId,
163164
})
164165
}
165166
}
@@ -183,6 +184,7 @@ BackgroundCells.propTypes = {
183184
range: PropTypes.arrayOf(PropTypes.instanceOf(Date)),
184185
rtl: PropTypes.bool,
185186
type: PropTypes.string,
187+
resourceId: PropTypes.any,
186188
}
187189

188190
export default BackgroundCells

src/Calendar.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,15 @@ class Calendar extends React.Component {
335335
*/
336336
onDoubleClickEvent: PropTypes.func,
337337

338+
/**
339+
* Callback fired when a focused calendar event recieves a key press.
340+
*
341+
* ```js
342+
* (event: Object, e: SyntheticEvent) => void
343+
* ```
344+
*/
345+
onKeyPressEvent: PropTypes.func,
346+
338347
/**
339348
* Callback fired when dragging a selection in the Time views.
340349
*
@@ -355,6 +364,14 @@ class Calendar extends React.Component {
355364
*/
356365
onShowMore: PropTypes.func,
357366

367+
/**
368+
* Displays all events on the month view instead of
369+
* having some hidden behind +{count} more. This will
370+
* cause the rows in the month view to be scrollable if
371+
* the number of events exceed the height of the row.
372+
*/
373+
showAllEvents: PropTypes.bool,
374+
358375
/**
359376
* The selected event, if any.
360377
*/
@@ -952,6 +969,7 @@ class Calendar extends React.Component {
952969
onDrillDown={this.handleDrillDown}
953970
onSelectEvent={this.handleSelectEvent}
954971
onDoubleClickEvent={this.handleDoubleClickEvent}
972+
onKeyPressEvent={this.handleKeyPressEvent}
955973
onSelectSlot={this.handleSelectSlot}
956974
onShowMore={onShowMore}
957975
/>
@@ -1019,6 +1037,10 @@ class Calendar extends React.Component {
10191037
notify(this.props.onDoubleClickEvent, args)
10201038
}
10211039

1040+
handleKeyPressEvent = (...args) => {
1041+
notify(this.props.onKeyPressEvent, args)
1042+
}
1043+
10221044
handleSelectSlot = slotInfo => {
10231045
notify(this.props.onSelectSlot, slotInfo)
10241046
}

src/DateContentRow.js

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import * as dates from './utils/dates'
99
import BackgroundCells from './BackgroundCells'
1010
import EventRow from './EventRow'
1111
import EventEndingRow from './EventEndingRow'
12+
import NoopWrapper from './NoopWrapper'
13+
import ScrollableWeekWrapper from './ScrollableWeekWrapper'
1214
import * as DateSlotMetrics from './utils/DateSlotMetrics'
1315

1416
class DateContentRow extends React.Component {
@@ -71,10 +73,15 @@ class DateContentRow extends React.Component {
7173
}
7274

7375
renderDummy = () => {
74-
let { className, range, renderHeader } = this.props
76+
let { className, range, renderHeader, showAllEvents } = this.props
7577
return (
7678
<div className={className}>
77-
<div className="rbc-row-content">
79+
<div
80+
className={clsx(
81+
'rbc-row-content',
82+
showAllEvents && 'rbc-row-content-scrollable'
83+
)}
84+
>
7885
{renderHeader && (
7986
<div className="rbc-row" ref={this.createHeadingRef}>
8087
{range.map(this.renderHeadingCell)}
@@ -113,16 +120,22 @@ class DateContentRow extends React.Component {
113120
onSelectStart,
114121
onSelectEnd,
115122
onDoubleClick,
123+
onKeyPress,
116124
resourceId,
117125
longPressThreshold,
118126
isAllDay,
127+
resizable,
128+
showAllEvents,
119129
} = this.props
120130

121131
if (renderForMeasure) return this.renderDummy()
122132

123133
let metrics = this.slotMetrics(this.props)
124134
let { levels, extra } = metrics
125135

136+
let ScrollableWeekComponent = showAllEvents
137+
? ScrollableWeekWrapper
138+
: NoopWrapper
126139
let WeekWrapper = components.weekWrapper
127140

128141
const eventRowProps = {
@@ -133,8 +146,10 @@ class DateContentRow extends React.Component {
133146
components,
134147
onSelect,
135148
onDoubleClick,
149+
onKeyPress,
136150
resourceId,
137151
slotMetrics: metrics,
152+
resizable,
138153
}
139154

140155
return (
@@ -152,26 +167,34 @@ class DateContentRow extends React.Component {
152167
onSelectSlot={this.handleSelectSlot}
153168
components={components}
154169
longPressThreshold={longPressThreshold}
170+
resourceId={resourceId}
155171
/>
156172

157-
<div className="rbc-row-content">
173+
<div
174+
className={clsx(
175+
'rbc-row-content',
176+
showAllEvents && 'rbc-row-content-scrollable'
177+
)}
178+
>
158179
{renderHeader && (
159180
<div className="rbc-row " ref={this.createHeadingRef}>
160181
{range.map(this.renderHeadingCell)}
161182
</div>
162183
)}
163-
<WeekWrapper isAllDay={isAllDay} {...eventRowProps}>
164-
{levels.map((segs, idx) => (
165-
<EventRow key={idx} segments={segs} {...eventRowProps} />
166-
))}
167-
{!!extra.length && (
168-
<EventEndingRow
169-
segments={extra}
170-
onShowMore={this.handleShowMore}
171-
{...eventRowProps}
172-
/>
173-
)}
174-
</WeekWrapper>
184+
<ScrollableWeekComponent>
185+
<WeekWrapper isAllDay={isAllDay} {...eventRowProps}>
186+
{levels.map((segs, idx) => (
187+
<EventRow key={idx} segments={segs} {...eventRowProps} />
188+
))}
189+
{!!extra.length && (
190+
<EventEndingRow
191+
segments={extra}
192+
onShowMore={this.handleShowMore}
193+
{...eventRowProps}
194+
/>
195+
)}
196+
</WeekWrapper>
197+
</ScrollableWeekComponent>
175198
</div>
176199
</div>
177200
)
@@ -184,6 +207,7 @@ DateContentRow.propTypes = {
184207
range: PropTypes.array.isRequired,
185208

186209
rtl: PropTypes.bool,
210+
resizable: PropTypes.bool,
187211
resourceId: PropTypes.any,
188212
renderForMeasure: PropTypes.bool,
189213
renderHeader: PropTypes.func,
@@ -194,11 +218,13 @@ DateContentRow.propTypes = {
194218
longPressThreshold: PropTypes.number,
195219

196220
onShowMore: PropTypes.func,
221+
showAllEvents: PropTypes.bool,
197222
onSelectSlot: PropTypes.func,
198223
onSelect: PropTypes.func,
199224
onSelectEnd: PropTypes.func,
200225
onSelectStart: PropTypes.func,
201226
onDoubleClick: PropTypes.func,
227+
onKeyPress: PropTypes.func,
202228
dayPropGetter: PropTypes.func,
203229

204230
getNow: PropTypes.func.isRequired,

src/DayColumn.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ class DayColumn extends React.Component {
189189
step,
190190
timeslots,
191191
dayLayoutAlgorithm,
192+
resizable,
192193
} = this.props
193194

194195
const { slotMetrics } = this
@@ -236,6 +237,8 @@ class DayColumn extends React.Component {
236237
onClick={e => this._select(event, e)}
237238
onDoubleClick={e => this._doubleClick(event, e)}
238239
isBackgroundEvent={isBackgroundEvent}
240+
onKeyPress={e => this._keyPress(event, e)}
241+
resizable={resizable}
239242
/>
240243
)
241244
})
@@ -375,6 +378,10 @@ class DayColumn extends React.Component {
375378
_doubleClick = (...args) => {
376379
notify(this.props.onDoubleClickEvent, args)
377380
}
381+
382+
_keyPress = (...args) => {
383+
notify(this.props.onKeyPressEvent, args)
384+
}
378385
}
379386

380387
DayColumn.propTypes = {
@@ -388,6 +395,7 @@ DayColumn.propTypes = {
388395
isNow: PropTypes.bool,
389396

390397
rtl: PropTypes.bool,
398+
resizable: PropTypes.bool,
391399

392400
accessors: PropTypes.object.isRequired,
393401
components: PropTypes.object.isRequired,
@@ -407,6 +415,7 @@ DayColumn.propTypes = {
407415
onSelectSlot: PropTypes.func.isRequired,
408416
onSelectEvent: PropTypes.func.isRequired,
409417
onDoubleClickEvent: PropTypes.func.isRequired,
418+
onKeyPressEvent: PropTypes.func,
410419

411420
className: PropTypes.string,
412421
dragThroughEvents: PropTypes.bool,

src/EventCell.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class EventCell extends React.Component {
1313
isAllDay,
1414
onSelect,
1515
onDoubleClick,
16+
onKeyPress,
1617
localizer,
1718
continuesPrior,
1819
continuesAfter,
@@ -24,6 +25,7 @@ class EventCell extends React.Component {
2425
slotEnd,
2526
...props
2627
} = this.props
28+
delete props.resizable
2729

2830
let title = accessors.title(event)
2931
let tooltip = accessors.tooltip(event)
@@ -69,6 +71,7 @@ class EventCell extends React.Component {
6971
})}
7072
onClick={e => onSelect && onSelect(event, e)}
7173
onDoubleClick={e => onDoubleClick && onDoubleClick(event, e)}
74+
onKeyPress={e => onKeyPress && onKeyPress(event, e)}
7275
>
7376
{typeof children === 'function' ? children(content) : content}
7477
</div>
@@ -82,6 +85,7 @@ EventCell.propTypes = {
8285
slotStart: PropTypes.instanceOf(Date),
8386
slotEnd: PropTypes.instanceOf(Date),
8487

88+
resizable: PropTypes.bool,
8589
selected: PropTypes.bool,
8690
isAllDay: PropTypes.bool,
8791
continuesPrior: PropTypes.bool,
@@ -94,6 +98,7 @@ EventCell.propTypes = {
9498

9599
onSelect: PropTypes.func,
96100
onDoubleClick: PropTypes.func,
101+
onKeyPress: PropTypes.func,
97102
}
98103

99104
export default EventCell

src/EventRowMixin.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export default {
1818

1919
onSelect: PropTypes.func,
2020
onDoubleClick: PropTypes.func,
21+
onKeyPress: PropTypes.func,
2122
},
2223

2324
defaultProps: {
@@ -33,9 +34,11 @@ export default {
3334
getters,
3435
onSelect,
3536
onDoubleClick,
37+
onKeyPress,
3638
localizer,
3739
slotMetrics,
3840
components,
41+
resizable,
3942
} = props
4043

4144
let continuesPrior = slotMetrics.continuesPrior(event)
@@ -50,11 +53,13 @@ export default {
5053
components={components}
5154
onSelect={onSelect}
5255
onDoubleClick={onDoubleClick}
56+
onKeyPress={onKeyPress}
5357
continuesPrior={continuesPrior}
5458
continuesAfter={continuesAfter}
5559
slotStart={slotMetrics.first}
5660
slotEnd={slotMetrics.last}
5761
selected={isSelected(event, selected)}
62+
resizable={resizable}
5863
/>
5964
)
6065
},

0 commit comments

Comments
 (0)