Skip to content
This repository has been archived by the owner on Sep 1, 2020. It is now read-only.

Commit

Permalink
Merge pull request #2 from kr-project/apg-bump-memoize
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-codaio authored Feb 5, 2020
2 parents 2d1c922 + 00e557f commit 1d1ae1a
Show file tree
Hide file tree
Showing 16 changed files with 105 additions and 58 deletions.
22 changes: 11 additions & 11 deletions .size-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
{
"./dist/react-big-calendar.js": {
"bundled": 508624,
"minified": 149246,
"gzipped": 45937
"bundled": 506890,
"minified": 148898,
"gzipped": 45540
},
"./dist/react-big-calendar.min.js": {
"bundled": 445192,
"minified": 130121,
"gzipped": 41450
"bundled": 444058,
"minified": 130004,
"gzipped": 41140
},
"dist/react-big-calendar.esm.js": {
"bundled": 173889,
"minified": 82988,
"gzipped": 20692,
"bundled": 173920,
"minified": 82985,
"gzipped": 20693,
"treeshaked": {
"rollup": {
"code": 60296,
"code": 60293,
"import_statements": 1562
},
"webpack": {
"code": 64942
"code": 64778
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions lib/DayColumn.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,16 +455,16 @@ var DayColumn =
localizer = _this$props3.localizer,
_this$props3$getters = _this$props3.getters,
dayProp = _this$props3$getters.dayProp,
getters = (0,
_objectWithoutPropertiesLoose2.default)(_this$props3$getters, [
'dayProp',
]),
getters = (0, _objectWithoutPropertiesLoose2.default)(
_this$props3$getters,
['dayProp']
),
_this$props3$componen = _this$props3.components,
EventContainer = _this$props3$componen.eventContainerWrapper,
components = (0,
_objectWithoutPropertiesLoose2.default)(_this$props3$componen, [
'eventContainerWrapper',
])
components = (0, _objectWithoutPropertiesLoose2.default)(
_this$props3$componen,
['eventContainerWrapper']
)
var slotMetrics = this.slotMetrics
var _this$state = this.state,
selecting = _this$state.selecting,
Expand Down
2 changes: 1 addition & 1 deletion lib/EventCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ var EventCell =
'div',
(0, _extends2.default)({}, props, {
tabIndex: 0,
style: (0, _extends2.default)({}, userProps.style, {}, style),
style: (0, _extends2.default)({}, userProps.style, style),
className: (0, _clsx.default)(
'rbc-event',
className,
Expand Down
1 change: 1 addition & 0 deletions lib/EventRowMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var _EventCell = _interopRequireDefault(require('./EventCell'))

var _selection = require('./utils/selection')

/* eslint-disable react/prop-types */
var _default = {
propTypes: {
slotMetrics: _propTypes.default.object.isRequired,
Expand Down
10 changes: 5 additions & 5 deletions lib/Popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ var Popup =
return _react.default.createElement(
'div',
{
style: (0, _extends2.default)({}, this.props.style, {}, style),
style: (0, _extends2.default)({}, this.props.style, style),
className: 'rbc-overlay',
ref: popperRef,
},
Expand Down Expand Up @@ -156,12 +156,12 @@ Popup.propTypes =
current: _propTypes.default.Element,
}),
]),
/**
* The Overlay component, of react-overlays, creates a ref that is passed to the Popup, and
* requires proper ref forwarding to be used without error
*/
}
: {}
/**
* The Overlay component, of react-overlays, creates a ref that is passed to the Popup, and
* requires proper ref forwarding to be used without error
*/

var _default = _react.default.forwardRef(function(props, ref) {
return _react.default.createElement(
Expand Down
14 changes: 6 additions & 8 deletions lib/Selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,14 +558,12 @@ function objectsCollide(nodeA, nodeB, tolerance) {
_getBoundsForNode2$bo = _getBoundsForNode2.bottom,
bBottom = _getBoundsForNode2$bo === void 0 ? bTop : _getBoundsForNode2$bo

return !(
// 'a' bottom doesn't touch 'b' top
(
aBottom - tolerance < bTop || // 'a' top doesn't touch 'b' bottom
aTop + tolerance > bBottom || // 'a' right doesn't touch 'b' left
aRight - tolerance < bLeft || // 'a' left doesn't touch 'b' right
aLeft + tolerance > bRight
)
return !// 'a' bottom doesn't touch 'b' top
(
aBottom - tolerance < bTop || // 'a' top doesn't touch 'b' bottom
aTop + tolerance > bBottom || // 'a' right doesn't touch 'b' left
aRight - tolerance < bLeft || // 'a' left doesn't touch 'b' right
aLeft + tolerance > bRight
)
}
/**
Expand Down
15 changes: 7 additions & 8 deletions lib/Views.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ var _Agenda = _interopRequireDefault(require('./Agenda'))

var _VIEWS

var VIEWS =
((_VIEWS = {}),
(_VIEWS[_constants.views.MONTH] = _Month.default),
(_VIEWS[_constants.views.WEEK] = _Week.default),
(_VIEWS[_constants.views.WORK_WEEK] = _WorkWeek.default),
(_VIEWS[_constants.views.DAY] = _Day.default),
(_VIEWS[_constants.views.AGENDA] = _Agenda.default),
_VIEWS)
var VIEWS = ((_VIEWS = {}),
(_VIEWS[_constants.views.MONTH] = _Month.default),
(_VIEWS[_constants.views.WEEK] = _Week.default),
(_VIEWS[_constants.views.WORK_WEEK] = _WorkWeek.default),
(_VIEWS[_constants.views.DAY] = _Day.default),
(_VIEWS[_constants.views.AGENDA] = _Agenda.default),
_VIEWS)
var _default = VIEWS
exports.default = _default
module.exports = exports['default']
1 change: 0 additions & 1 deletion lib/addons/dragAndDrop/EventContainerWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,6 @@ var EventContainerWrapper =
accessors: (0, _extends2.default)(
{},
accessors,
{},
_common.dragAccessors
),
continuesEarlier: startsBeforeDay,
Expand Down
1 change: 0 additions & 1 deletion lib/addons/dragAndDrop/WeekWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ var WeekWrapper =
accessors: (0, _extends2.default)(
{},
accessors,
{},
_common.dragAccessors
),
})
Expand Down
55 changes: 55 additions & 0 deletions lib/addons/dragAndDrop/withDragAndDrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,61 @@ var _WeekWrapper = _interopRequireDefault(require('./WeekWrapper'))

var _common = require('./common')

/**
* Creates a higher-order component (HOC) supporting drag & drop and optionally resizing
* of events:
*
* ```js
* import Calendar from 'react-big-calendar'
* import withDragAndDrop from 'react-big-calendar/lib/addons/dragAndDrop'
* export default withDragAndDrop(Calendar)
* ```
*
* Set `resizable` to true in your calendar if you want events to be resizable.
*
* The HOC adds `onEventDrop`, `onEventResize`, and `onDragStart` callback properties if the events are
* moved or resized. These callbacks are called with these signatures:
*
* ```js
* function onEventDrop({ event, start, end, allDay }) {...}
* function onEventResize(type, { event, start, end, allDay }) {...} // type is always 'drop'
* function onDragStart({ event, action, direction }) {...}
* ```
*
* Moving and resizing of events has some subtlety which one should be aware of.
*
* In some situations, non-allDay events are displayed in "row" format where they
* are rendered horizontally. This is the case for ALL events in a month view. It
* is also occurs with multi-day events in a day or week view (unless `showMultiDayTimes`
* is set).
*
* When dropping or resizing non-allDay events into a the header area or when
* resizing them horizontally because they are displayed in row format, their
* times are preserved, only their date is changed.
*
* If you care about these corner cases, you can examine the `allDay` param suppled
* in the callback to determine how the user dropped or resized the event.
*
* Additionally, this HOC adds the callback props `onDropFromOutside` and `onDragOver`.
* By default, the calendar will not respond to outside draggable items being dropped
* onto it. However, if `onDropFromOutside` callback is passed, then when draggable
* DOM elements are dropped on the calendar, the callback will fire, receiving an
* object with start and end times, and an allDay boolean.
*
* If `onDropFromOutside` is passed, but `onDragOver` is not, any draggable event will be
* droppable onto the calendar by default. On the other hand, if an `onDragOver` callback
* *is* passed, then it can discriminate as to whether a draggable item is droppable on the
* calendar. To designate a draggable item as droppable, call `event.preventDefault`
* inside `onDragOver`. If `event.preventDefault` is not called in the `onDragOver`
* callback, then the draggable item will not be droppable on the calendar.
*
* * ```js
* function onDropFromOutside({ start, end, allDay }) {...}
* function onDragOver(DragEvent: event) {...}
* ```
* @param {*} Calendar
* @param {*} backend
*/
function withDragAndDrop(Calendar) {
var DragAndDropCalendar =
/*#__PURE__*/
Expand Down
7 changes: 1 addition & 6 deletions lib/localizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,7 @@ var DateLocalizer = function DateLocalizer(spec) {
exports.DateLocalizer = DateLocalizer

function mergeWithDefaults(localizer, culture, formatOverrides, messages) {
var formats = (0, _extends2.default)(
{},
localizer.formats,
{},
formatOverrides
)
var formats = (0, _extends2.default)({}, localizer.formats, formatOverrides)
return (0, _extends2.default)({}, localizer, {
messages: messages,
startOfWeek: function startOfWeek() {
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/DateSlotMetrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var isSegmentInSlot = function isSegmentInSlot(seg, slot) {
}

var isEqual = function isEqual(a, b) {
return a.range === b.range && a.events === b.events
return a[0].range === b[0].range && a[0].events === b[0].events
}

function getSlotMetrics() {
Expand Down Expand Up @@ -61,7 +61,7 @@ function getSlotMetrics() {
slots: range.length,
clone: function clone(args) {
var metrics = getSlotMetrics()
return metrics((0, _extends2.default)({}, options, {}, args))
return metrics((0, _extends2.default)({}, options, args))
},
getDateForSlot: function getDateForSlot(slotNumber) {
return range[slotNumber]
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var defaultMessages = {
}

function messages(msgs) {
return (0, _extends2.default)({}, defaultMessages, {}, msgs)
return (0, _extends2.default)({}, defaultMessages, msgs)
}

module.exports = exports['default']
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
"invariant": "^2.2.4",
"lodash": "^4.17.11",
"lodash-es": "^4.17.11",
"memoize-one": "^4.0.3",
"memoize-one": "5.0.4",
"prop-types": "^15.6.2",
"react-overlays": "^2.0.0-0",
"uncontrollable": "^7.0.0"
Expand Down
3 changes: 2 additions & 1 deletion src/utils/DateSlotMetrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { eventSegments, endOfRange, eventLevels } from './eventLevels'

let isSegmentInSlot = (seg, slot) => seg.left <= slot && seg.right >= slot

const isEqual = (a, b) => a.range === b.range && a.events === b.events
const isEqual = (a, b) =>
a[0].range === b[0].range && a[0].events === b[0].events

export function getSlotMetrics() {
return memoize(options => {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8531,10 +8531,10 @@ mem@^4.0.0:
mimic-fn "^2.0.0"
p-is-promise "^2.0.0"

memoize-one@^4.0.3:
version "4.1.0"
resolved "https://registry.yarnpkg.com/memoize-one/-/memoize-one-4.1.0.tgz#a2387c58c03fff27ca390c31b764a79addf3f906"
integrity sha512-2GApq0yI/b22J2j9rhbrAlsHb0Qcz+7yWxeLG8h+95sl1XPUgeLimQSOdur4Vw7cUhrBHwaUZxWFZueojqNRzA==
memoize-one@5.0.4:
version "5.0.4"
resolved "https://registry.yarnpkg.com/memoize-one/-/memoize-one-5.0.4.tgz#005928aced5c43d890a4dfab18ca908b0ec92cbc"
integrity sha512-P0z5IeAH6qHHGkJIXWw0xC2HNEgkx/9uWWBQw64FJj3/ol14VYdfVGWWr0fXfjhhv3TKVIqUq65os6O4GUNksA==

memoizerific@^1.11.3:
version "1.11.3"
Expand Down

0 comments on commit 1d1ae1a

Please sign in to comment.