react-big-calendar
Advanced tools
Comparing version 0.21.0 to 0.22.0
@@ -20,3 +20,3 @@ "use strict"; | ||
var _dates = _interopRequireDefault(require("../../utils/dates")); | ||
var dates = _interopRequireWildcard(require("../../utils/dates")); | ||
@@ -76,6 +76,5 @@ var _reactDom = require("react-dom"); | ||
var eventEnd = accessors.end(event); | ||
var end = dates.add(currentSlot, dates.diff(eventStart, eventEnd, 'minutes'), 'minutes'); | ||
var end = _dates.default.add(currentSlot, _dates.default.diff(eventStart, eventEnd, 'minutes'), 'minutes'); | ||
_this.update(event, slotMetrics.getRange(currentSlot, end)); | ||
_this.update(event, slotMetrics.getRange(currentSlot, end, false, true)); | ||
}; | ||
@@ -225,6 +224,6 @@ | ||
end = accessors.end(event); | ||
start = _dates.default.min(currentSlot, slotMetrics.closestSlotFromDate(end, -1)); | ||
start = dates.min(currentSlot, slotMetrics.closestSlotFromDate(end, -1)); | ||
} else if (direction === 'DOWN') { | ||
start = accessors.start(event); | ||
end = _dates.default.max(currentSlot, slotMetrics.closestSlotFromDate(start)); | ||
end = dates.max(currentSlot, slotMetrics.closestSlotFromDate(start)); | ||
} | ||
@@ -231,0 +230,0 @@ |
@@ -20,3 +20,3 @@ "use strict"; | ||
var _dates = _interopRequireDefault(require("../../utils/dates")); | ||
var dates = _interopRequireWildcard(require("../../utils/dates")); | ||
@@ -40,5 +40,5 @@ var _selection = require("../../utils/selection"); | ||
var end = accessors.end(event); | ||
var isZeroDuration = _dates.default.eq(start, end, 'minutes') && start.getMinutes() === 0; // make zero duration midnight events at least one day long | ||
var isZeroDuration = dates.eq(start, end, 'minutes') && start.getMinutes() === 0; // make zero duration midnight events at least one day long | ||
if (isZeroDuration) end = _dates.default.add(end, 1, 'day'); | ||
if (isZeroDuration) end = dates.add(end, 1, 'day'); | ||
return { | ||
@@ -83,6 +83,5 @@ start: start, | ||
var start = _dates.default.merge(metrics.getDateForSlot((0, _selection.getSlotAtX)(rowBox, x, false, metrics.slots)), accessors.start(event)); | ||
var start = dates.merge(metrics.getDateForSlot((0, _selection.getSlotAtX)(rowBox, x, false, metrics.slots)), accessors.start(event)); | ||
var end = dates.add(start, dates.diff(accessors.start(event), accessors.end(event), 'minutes'), 'minutes'); | ||
var end = _dates.default.add(start, _dates.default.diff(accessors.start(event), accessors.end(event), 'minutes'), 'minutes'); | ||
_this.update(event, start, end); | ||
@@ -98,3 +97,3 @@ }; | ||
start: start, | ||
end: _dates.default.add(start, 1, 'day'), | ||
end: dates.add(start, 1, 'day'), | ||
allDay: false | ||
@@ -222,5 +221,5 @@ }); | ||
end = _dates.default.add(metrics.getDateForSlot((0, _selection.getSlotAtX)(rowBox, point.x, false, metrics.slots)), 1, 'day'); | ||
} else if (_dates.default.inRange(start, metrics.first, metrics.last) || rowBox.bottom < point.y && +metrics.first > +start) { | ||
end = _dates.default.add(metrics.last, 1, 'milliseconds'); | ||
end = dates.add(metrics.getDateForSlot((0, _selection.getSlotAtX)(rowBox, point.x, false, metrics.slots)), 1, 'day'); | ||
} else if (dates.inRange(start, metrics.first, metrics.last) || rowBox.bottom < point.y && +metrics.first > +start) { | ||
end = dates.add(metrics.last, 1, 'milliseconds'); | ||
} else { | ||
@@ -233,3 +232,3 @@ this.setState({ | ||
end = _dates.default.max(end, _dates.default.add(start, 1, 'day')); | ||
end = dates.max(end, dates.add(start, 1, 'day')); | ||
} else if (direction === 'LEFT') { | ||
@@ -240,4 +239,4 @@ // inbetween Row | ||
start = metrics.getDateForSlot((0, _selection.getSlotAtX)(rowBox, point.x, false, metrics.slots)); | ||
} else if (_dates.default.inRange(end, metrics.first, metrics.last) || rowBox.top > point.y && +metrics.last < +end) { | ||
start = _dates.default.add(metrics.first, -1, 'milliseconds'); | ||
} else if (dates.inRange(end, metrics.first, metrics.last) || rowBox.top > point.y && +metrics.last < +end) { | ||
start = dates.add(metrics.first, -1, 'milliseconds'); | ||
} else { | ||
@@ -248,3 +247,3 @@ this.reset(); | ||
start = _dates.default.min(_dates.default.add(end, -1, 'day'), start); | ||
start = dates.min(dates.add(end, -1, 'day'), start); | ||
} | ||
@@ -251,0 +250,0 @@ |
@@ -39,5 +39,2 @@ "use strict"; | ||
* ``` | ||
* (you can optionally pass any dnd backend as an optional second argument to `withDragAndDrop`. | ||
* It defaults to `react-dnd-html5-backend` which you should probably include in | ||
* your project if using this default). | ||
* | ||
@@ -44,0 +41,0 @@ * Set `resizable` to true in your calendar if you want events to be resizable. |
"use strict"; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
@@ -20,3 +22,3 @@ | ||
var _dates = _interopRequireDefault(require("./utils/dates")); | ||
var dates = _interopRequireWildcard(require("./utils/dates")); | ||
@@ -49,3 +51,3 @@ var _constants = require("./utils/constants"); | ||
events = events.filter(function (e) { | ||
return (0, _eventLevels.inRange)(e, _dates.default.startOf(day, 'day'), _dates.default.endOf(day, 'day'), accessors); | ||
return (0, _eventLevels.inRange)(e, dates.startOf(day, 'day'), dates.endOf(day, 'day'), accessors); | ||
}); | ||
@@ -92,5 +94,5 @@ return events.map(function (event, idx) { | ||
if (!accessors.allDay(event)) { | ||
if (_dates.default.eq(start, end)) { | ||
if (dates.eq(start, end)) { | ||
label = localizer.format(start, 'agendaTimeFormat'); | ||
} else if (_dates.default.eq(start, end, 'day')) { | ||
} else if (dates.eq(start, end, 'day')) { | ||
label = localizer.format({ | ||
@@ -100,5 +102,5 @@ start: start, | ||
}, 'agendaTimeRangeFormat'); | ||
} else if (_dates.default.eq(day, start, 'day')) { | ||
} else if (dates.eq(day, start, 'day')) { | ||
label = localizer.format(start, 'agendaTimeFormat'); | ||
} else if (_dates.default.eq(day, end, 'day')) { | ||
} else if (dates.eq(day, end, 'day')) { | ||
label = localizer.format(end, 'agendaTimeFormat'); | ||
@@ -108,4 +110,4 @@ } | ||
if (_dates.default.gt(day, start, 'day')) labelClass = 'rbc-continues-prior'; | ||
if (_dates.default.lt(day, end, 'day')) labelClass += ' rbc-continues-after'; | ||
if (dates.gt(day, start, 'day')) labelClass = 'rbc-continues-prior'; | ||
if (dates.lt(day, end, 'day')) labelClass += ' rbc-continues-after'; | ||
return _react.default.createElement("span", { | ||
@@ -171,7 +173,4 @@ className: labelClass.trim() | ||
var messages = localizer.messages; | ||
var end = _dates.default.add(date, length, 'day'); | ||
var range = _dates.default.range(date, end, 'day'); | ||
var end = dates.add(date, length, 'day'); | ||
var range = dates.range(date, end, 'day'); | ||
events = events.filter(function (event) { | ||
@@ -230,5 +229,3 @@ return (0, _eventLevels.inRange)(event, date, end, accessors); | ||
length = _ref$length === void 0 ? Agenda.defaultProps.length : _ref$length; | ||
var end = _dates.default.add(start, length, 'day'); | ||
var end = dates.add(start, length, 'day'); | ||
return { | ||
@@ -246,6 +243,6 @@ start: start, | ||
case _constants.navigate.PREVIOUS: | ||
return _dates.default.add(date, -length, 'day'); | ||
return dates.add(date, -length, 'day'); | ||
case _constants.navigate.NEXT: | ||
return _dates.default.add(date, length, 'day'); | ||
return dates.add(date, length, 'day'); | ||
@@ -261,5 +258,3 @@ default: | ||
localizer = _ref3.localizer; | ||
var end = _dates.default.add(start, length, 'day'); | ||
var end = dates.add(start, length, 'day'); | ||
return localizer.format({ | ||
@@ -266,0 +261,0 @@ start: start, |
@@ -22,3 +22,3 @@ "use strict"; | ||
var _dates = _interopRequireDefault(require("./utils/dates")); | ||
var dates = _interopRequireWildcard(require("./utils/dates")); | ||
@@ -88,3 +88,3 @@ var _helpers = require("./utils/helpers"); | ||
style: style, | ||
className: (0, _classnames.default)('rbc-day-bg', className, selected && 'rbc-selected-cell', _dates.default.eq(date, current, 'day') && 'rbc-today', currentDate && _dates.default.month(currentDate) !== _dates.default.month(date) && 'rbc-off-range-bg') | ||
className: (0, _classnames.default)('rbc-day-bg', className, selected && 'rbc-selected-cell', dates.eq(date, current, 'day') && 'rbc-today', currentDate && dates.month(currentDate) !== dates.month(date) && 'rbc-off-range-bg') | ||
})); | ||
@@ -91,0 +91,0 @@ })); |
@@ -18,3 +18,3 @@ "use strict"; | ||
var _uncontrollable = _interopRequireDefault(require("uncontrollable")); | ||
var _uncontrollable = require("uncontrollable"); | ||
@@ -267,3 +267,2 @@ var _classnames = _interopRequireDefault(require("classnames")); | ||
eventContainerWrapper: _NoopWrapper.default, | ||
dayWrapper: _NoopWrapper.default, | ||
dateCellWrapper: _NoopWrapper.default, | ||
@@ -318,3 +317,3 @@ weekWrapper: _NoopWrapper.default, | ||
return _react.default.createElement("div", (0, _extends2.default)({}, elementProps, { | ||
className: (0, _classnames.default)(className, 'rbc-calendar', props.rtl && 'rbc-is-rtl'), | ||
className: (0, _classnames.default)(className, 'rbc-calendar', props.rtl && 'rbc-rtl'), | ||
style: style | ||
@@ -695,3 +694,3 @@ }), toolbar && _react.default.createElement(CalToolbar, { | ||
* | ||
* @type Calendar.Views ('month'|'week'|'work_week'|'day'|'agenda') | ||
* @type Views ('month'|'week'|'work_week'|'day'|'agenda') | ||
* @View | ||
@@ -710,3 +709,3 @@ ['month', 'week', 'day', 'agenda'] | ||
* ```js | ||
* <BigCalendar | ||
* <Calendar | ||
* drilldownView="agenda" | ||
@@ -726,3 +725,3 @@ * /> | ||
* ```js | ||
* <BigCalendar | ||
* <Calendar | ||
* getDrilldownView={(targetDate, currentViewName, configuredViewNames) => | ||
@@ -759,4 +758,4 @@ * if (currentViewName === 'month' && configuredViewNames.includes('week')) | ||
* ```jsx | ||
* <BigCalendar popupOffset={30}/> | ||
* <BigCalendar popupOffset={{x: 30, y: 20}}/> | ||
* <Calendar popupOffset={30}/> | ||
* <Calendar popupOffset={{x: 30, y: 20}}/> | ||
* ``` | ||
@@ -977,3 +976,2 @@ */ | ||
* eventContainerWrapper: MyEventContainerWrapper, | ||
* dayWrapper: MyDayWrapper, | ||
* dateCellWrapper: MyDateCellWrapper, | ||
@@ -1006,28 +1004,27 @@ * timeSlotWrapper: MyTimeSlotWrapper, | ||
components: _propTypes.default.shape({ | ||
event: _propTypes2.elementType, | ||
eventWrapper: _propTypes2.elementType, | ||
eventContainerWrapper: _propTypes2.elementType, | ||
dayWrapper: _propTypes2.elementType, | ||
dateCellWrapper: _propTypes2.elementType, | ||
timeSlotWrapper: _propTypes2.elementType, | ||
timeGutterHeader: _propTypes2.elementType, | ||
resourceHeader: _propTypes2.elementType, | ||
toolbar: _propTypes2.elementType, | ||
event: _propTypes.default.elementType, | ||
eventWrapper: _propTypes.default.elementType, | ||
eventContainerWrapper: _propTypes.default.elementType, | ||
dateCellWrapper: _propTypes.default.elementType, | ||
timeSlotWrapper: _propTypes.default.elementType, | ||
timeGutterHeader: _propTypes.default.elementType, | ||
resourceHeader: _propTypes.default.elementType, | ||
toolbar: _propTypes.default.elementType, | ||
agenda: _propTypes.default.shape({ | ||
date: _propTypes2.elementType, | ||
time: _propTypes2.elementType, | ||
event: _propTypes2.elementType | ||
date: _propTypes.default.elementType, | ||
time: _propTypes.default.elementType, | ||
event: _propTypes.default.elementType | ||
}), | ||
day: _propTypes.default.shape({ | ||
header: _propTypes2.elementType, | ||
event: _propTypes2.elementType | ||
header: _propTypes.default.elementType, | ||
event: _propTypes.default.elementType | ||
}), | ||
week: _propTypes.default.shape({ | ||
header: _propTypes2.elementType, | ||
event: _propTypes2.elementType | ||
header: _propTypes.default.elementType, | ||
event: _propTypes.default.elementType | ||
}), | ||
month: _propTypes.default.shape({ | ||
header: _propTypes2.elementType, | ||
dateHeader: _propTypes2.elementType, | ||
event: _propTypes2.elementType | ||
header: _propTypes.default.elementType, | ||
dateHeader: _propTypes.default.elementType, | ||
event: _propTypes.default.elementType | ||
}) | ||
@@ -1056,3 +1053,3 @@ }), | ||
var _default = (0, _uncontrollable.default)(Calendar, { | ||
var _default = (0, _uncontrollable.uncontrollable)(Calendar, { | ||
view: 'onView', | ||
@@ -1059,0 +1056,0 @@ date: 'onNavigate', |
@@ -28,3 +28,3 @@ "use strict"; | ||
var _dates = _interopRequireDefault(require("./utils/dates")); | ||
var dates = _interopRequireWildcard(require("./utils/dates")); | ||
@@ -94,3 +94,3 @@ var _BackgroundCells = _interopRequireDefault(require("./BackgroundCells")); | ||
key: "header_" + index, | ||
className: (0, _classnames.default)('rbc-date-cell', _dates.default.eq(date, getNow(), 'day') && 'rbc-now') | ||
className: (0, _classnames.default)('rbc-date-cell', dates.eq(date, getNow(), 'day') && 'rbc-now') | ||
}); | ||
@@ -97,0 +97,0 @@ }; |
"use strict"; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
@@ -18,3 +20,3 @@ | ||
var _dates = _interopRequireDefault(require("./utils/dates")); | ||
var dates = _interopRequireWildcard(require("./utils/dates")); | ||
@@ -55,3 +57,3 @@ var _constants = require("./utils/constants"); | ||
Day.range = function (date) { | ||
return [_dates.default.startOf(date, 'day')]; | ||
return [dates.startOf(date, 'day')]; | ||
}; | ||
@@ -62,6 +64,6 @@ | ||
case _constants.navigate.PREVIOUS: | ||
return _dates.default.add(date, -1, 'day'); | ||
return dates.add(date, -1, 'day'); | ||
case _constants.navigate.NEXT: | ||
return _dates.default.add(date, 1, 'day'); | ||
return dates.add(date, 1, 'day'); | ||
@@ -68,0 +70,0 @@ default: |
@@ -28,3 +28,3 @@ "use strict"; | ||
var _dates = _interopRequireDefault(require("./utils/dates")); | ||
var dates = _interopRequireWildcard(require("./utils/dates")); | ||
@@ -65,3 +65,3 @@ var TimeSlotUtils = _interopRequireWildcard(require("./utils/TimeSlots")); | ||
events = _this$props.events, | ||
isRtl = _this$props.rtl, | ||
rtl = _this$props.rtl, | ||
selected = _this$props.selected, | ||
@@ -107,3 +107,3 @@ accessors = _this$props.accessors, | ||
getters: getters, | ||
isRtl: isRtl, | ||
rtl: rtl, | ||
components: components, | ||
@@ -140,3 +140,3 @@ continuesEarlier: continuesEarlier, | ||
if (onSelecting) { | ||
if (_dates.default.eq(current.startDate, start, 'minutes') && _dates.default.eq(current.endDate, end, 'minutes') || onSelecting({ | ||
if (dates.eq(current.startDate, start, 'minutes') && dates.eq(current.endDate, end, 'minutes') || onSelecting({ | ||
start: start, | ||
@@ -159,3 +159,3 @@ end: end | ||
var selectRange = _this.slotMetrics.getRange(_dates.default.min(initialSlot, currentSlot), _dates.default.max(initialSlot, currentSlot)); | ||
var selectRange = _this.slotMetrics.getRange(dates.min(initialSlot, currentSlot), dates.max(initialSlot, currentSlot)); | ||
@@ -238,5 +238,5 @@ return (0, _extends2.default)({}, selectRange, { | ||
while (_dates.default.lte(current, endDate)) { | ||
while (dates.lte(current, endDate)) { | ||
slots.push(current); | ||
current = _dates.default.add(current, _this.props.step, 'minutes'); | ||
current = dates.add(current, _this.props.step, 'minutes'); | ||
} | ||
@@ -298,3 +298,3 @@ | ||
_proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) { | ||
var getNowChanged = !_dates.default.eq(prevProps.getNow(), this.props.getNow(), 'minutes'); | ||
var getNowChanged = !dates.eq(prevProps.getNow(), this.props.getNow(), 'minutes'); | ||
@@ -305,6 +305,6 @@ if (prevProps.isNow !== this.props.isNow || getNowChanged) { | ||
if (this.props.isNow) { | ||
var tail = !getNowChanged && _dates.default.eq(prevProps.date, this.props.date, 'minutes') && prevState.timeIndicatorPosition === this.state.timeIndicatorPosition; | ||
var tail = !getNowChanged && dates.eq(prevProps.date, this.props.date, 'minutes') && prevState.timeIndicatorPosition === this.state.timeIndicatorPosition; | ||
this.setTimeIndicatorPositionUpdateInterval(tail); | ||
} | ||
} else if (this.props.isNow && !_dates.default.eq(prevProps.min, this.props.min, 'minutes')) { | ||
} else if (this.props.isNow && !dates.eq(prevProps.min, this.props.min, 'minutes')) { | ||
this.positionTimeIndicator(); | ||
@@ -311,0 +311,0 @@ } |
"use strict"; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
@@ -20,3 +22,3 @@ | ||
var _dates = _interopRequireDefault(require("./utils/dates")); | ||
var dates = _interopRequireWildcard(require("./utils/dates")); | ||
@@ -58,3 +60,3 @@ var EventCell = | ||
var allDay = accessors.allDay(event); | ||
var showAsAllDay = isAllDay || allDay || _dates.default.diff(start, _dates.default.ceil(end, 'day'), 'day') > 1; | ||
var showAsAllDay = isAllDay || allDay || dates.diff(start, dates.ceil(end, 'day'), 'day') > 1; | ||
var userProps = getters.eventProp(event, start, end, selected); | ||
@@ -61,0 +63,0 @@ |
@@ -6,34 +6,37 @@ "use strict"; | ||
exports.__esModule = true; | ||
exports.default = void 0; | ||
exports.Navigate = exports.Views = exports.DateLocalizer = exports.move = exports.globalizeLocalizer = exports.momentLocalizer = exports.Calendar = exports.components = void 0; | ||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); | ||
var _EventWrapper = _interopRequireDefault(require("./EventWrapper")); | ||
var _BackgroundWrapper = _interopRequireDefault(require("./BackgroundWrapper")); | ||
var _Calendar = _interopRequireDefault(require("./Calendar")); | ||
var _EventWrapper = _interopRequireDefault(require("./EventWrapper")); | ||
exports.Calendar = _Calendar.default; | ||
var _BackgroundWrapper = _interopRequireDefault(require("./BackgroundWrapper")); | ||
var _localizer = require("./localizer"); | ||
exports.DateLocalizer = _localizer.DateLocalizer; | ||
var _moment = _interopRequireDefault(require("./localizers/moment")); | ||
exports.momentLocalizer = _moment.default; | ||
var _globalize = _interopRequireDefault(require("./localizers/globalize")); | ||
exports.globalizeLocalizer = _globalize.default; | ||
var _move = _interopRequireDefault(require("./utils/move")); | ||
exports.move = _move.default; | ||
var _constants = require("./utils/constants"); | ||
(0, _extends2.default)(_Calendar.default, { | ||
globalizeLocalizer: _globalize.default, | ||
momentLocalizer: _moment.default, | ||
Views: _constants.views, | ||
Navigate: _constants.navigate, | ||
move: _move.default, | ||
components: { | ||
eventWrapper: _EventWrapper.default, | ||
dayWrapper: _BackgroundWrapper.default, | ||
dateCellWrapper: _BackgroundWrapper.default | ||
} | ||
}); | ||
var _default = _Calendar.default; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
exports.Views = _constants.views; | ||
exports.Navigate = _constants.navigate; | ||
var components = { | ||
eventWrapper: _EventWrapper.default, | ||
timeSlotWrapper: _BackgroundWrapper.default, | ||
dateCellWrapper: _BackgroundWrapper.default | ||
}; | ||
exports.components = components; |
@@ -5,2 +5,4 @@ "use strict"; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
exports.__esModule = true; | ||
@@ -10,3 +12,3 @@ exports.default = _default; | ||
var _dates = _interopRequireDefault(require("../utils/dates")); | ||
var dates = _interopRequireWildcard(require("../utils/dates")); | ||
@@ -56,3 +58,3 @@ var _oldGlobalize = _interopRequireDefault(require("./oldGlobalize")); | ||
end = _ref5.end; | ||
return local.format(start, 'MMM dd', culture) + ' — ' + local.format(end, _dates.default.eq(start, end, 'month') ? 'dd' : 'MMM dd', culture); | ||
return local.format(start, 'MMM dd', culture) + ' — ' + local.format(end, dates.eq(start, end, 'month') ? 'dd' : 'MMM dd', culture); | ||
}; | ||
@@ -59,0 +61,0 @@ |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
@@ -9,3 +9,3 @@ exports.__esModule = true; | ||
var _dates = _interopRequireDefault(require("../utils/dates")); | ||
var dates = _interopRequireWildcard(require("../utils/dates")); | ||
@@ -39,3 +39,3 @@ var _localizer = require("../localizer"); | ||
end = _ref5.end; | ||
return local.format(start, 'MMMM DD', culture) + ' - ' + local.format(end, _dates.default.eq(start, end, 'month') ? 'DD' : 'MMMM DD', culture); | ||
return local.format(start, 'MMMM DD', culture) + ' - ' + local.format(end, dates.eq(start, end, 'month') ? 'DD' : 'MMMM DD', culture); | ||
}; | ||
@@ -42,0 +42,0 @@ |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
@@ -9,3 +9,3 @@ exports.__esModule = true; | ||
var _dates = _interopRequireDefault(require("../utils/dates")); | ||
var dates = _interopRequireWildcard(require("../utils/dates")); | ||
@@ -39,3 +39,3 @@ var _localizer = require("../localizer"); | ||
end = _ref5.end; | ||
return local.format(start, 'MMM dd', culture) + ' - ' + local.format(end, _dates.default.eq(start, end, 'month') ? 'dd' : 'MMM dd', culture); | ||
return local.format(start, 'MMM dd', culture) + ' - ' + local.format(end, dates.eq(start, end, 'month') ? 'dd' : 'MMM dd', culture); | ||
}; | ||
@@ -42,0 +42,0 @@ |
"use strict"; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
@@ -24,3 +26,3 @@ | ||
var _dates = _interopRequireDefault(require("./utils/dates")); | ||
var dates = _interopRequireWildcard(require("./utils/dates")); | ||
@@ -127,7 +129,4 @@ var _chunk = _interopRequireDefault(require("lodash/chunk")); | ||
localizer = _this$props2.localizer; | ||
var isOffRange = _dates.default.month(date) !== _dates.default.month(currentDate); | ||
var isCurrent = _dates.default.eq(date, currentDate, 'day'); | ||
var isOffRange = dates.month(date) !== dates.month(currentDate); | ||
var isCurrent = dates.eq(date, currentDate, 'day'); | ||
var drilldownView = getDrilldownView(date); | ||
@@ -227,3 +226,3 @@ var label = localizer.format(date, 'dateFormat'); | ||
this.setState({ | ||
needLimitMeasure: !_dates.default.eq(date, this.props.date, 'month') | ||
needLimitMeasure: !dates.eq(date, this.props.date, 'month') | ||
}); | ||
@@ -264,5 +263,4 @@ }; | ||
className = _this$props4.className, | ||
month = _dates.default.visibleDays(date, localizer), | ||
month = dates.visibleDays(date, localizer), | ||
weeks = (0, _chunk.default)(month, 7); | ||
this._weekCount = weeks.length; | ||
@@ -283,3 +281,3 @@ return _react.default.createElement("div", { | ||
var HeaderComponent = components.header || _Header.default; | ||
return _dates.default.range(first, last, 'day').map(function (day, idx) { | ||
return dates.range(first, last, 'day').map(function (day, idx) { | ||
return _react.default.createElement("div", { | ||
@@ -402,7 +400,4 @@ key: 'header_' + idx, | ||
var localizer = _ref4.localizer; | ||
var start = _dates.default.firstVisibleDay(date, localizer); | ||
var end = _dates.default.lastVisibleDay(date, localizer); | ||
var start = dates.firstVisibleDay(date, localizer); | ||
var end = dates.lastVisibleDay(date, localizer); | ||
return { | ||
@@ -417,6 +412,6 @@ start: start, | ||
case _constants.navigate.PREVIOUS: | ||
return _dates.default.add(date, -1, 'month'); | ||
return dates.add(date, -1, 'month'); | ||
case _constants.navigate.NEXT: | ||
return _dates.default.add(date, 1, 'month'); | ||
return dates.add(date, 1, 'month'); | ||
@@ -423,0 +418,0 @@ default: |
@@ -16,3 +16,3 @@ "use strict"; | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _react = _interopRequireDefault(require("react")); | ||
@@ -25,3 +25,3 @@ var _offset = _interopRequireDefault(require("dom-helpers/query/offset")); | ||
var _dates = _interopRequireDefault(require("./utils/dates")); | ||
var dates = _interopRequireWildcard(require("./utils/dates")); | ||
@@ -109,4 +109,4 @@ var _EventCell = _interopRequireDefault(require("./EventCell")); | ||
onDoubleClick: onDoubleClick, | ||
continuesPrior: _dates.default.lt(accessors.end(event), slotStart, 'day'), | ||
continuesAfter: _dates.default.gte(accessors.start(event), slotEnd, 'day'), | ||
continuesPrior: dates.lt(accessors.end(event), slotStart, 'day'), | ||
continuesAfter: dates.gte(accessors.start(event), slotEnd, 'day'), | ||
selected: (0, _selection.isSelected)(event, selected) | ||
@@ -137,3 +137,3 @@ }); | ||
popperRef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.shape({ | ||
current: _propTypes.default.instanceOf(_react.Element) | ||
current: _propTypes.default.Element | ||
})]) | ||
@@ -140,0 +140,0 @@ /** |
@@ -77,2 +77,3 @@ "use strict"; | ||
this.isDetached = false; | ||
this.container = node; | ||
@@ -124,2 +125,3 @@ this.globalMouse = !node || global; | ||
_proto.teardown = function teardown() { | ||
this.isDetached = true; | ||
this.listeners = Object.create(null); | ||
@@ -244,2 +246,6 @@ this._onTouchMoveWindowListener && this._onTouchMoveWindowListener.remove(); | ||
_proto._handleInitialEvent = function _handleInitialEvent(e) { | ||
if (this.isDetached) { | ||
return; | ||
} | ||
var _getEventCoordinates2 = getEventCoordinates(e), | ||
@@ -368,3 +374,3 @@ clientX = _getEventCoordinates2.clientX, | ||
_proto._handleMoveEvent = function _handleMoveEvent(e) { | ||
if (this._initialEventData === null) { | ||
if (this._initialEventData === null || this.isDetached) { | ||
return; | ||
@@ -371,0 +377,0 @@ } |
@@ -26,3 +26,3 @@ "use strict"; | ||
var _dates = _interopRequireDefault(require("./utils/dates")); | ||
var dates = _interopRequireWildcard(require("./utils/dates")); | ||
@@ -158,3 +158,3 @@ var _DayColumn = _interopRequireDefault(require("./DayColumn")); | ||
if (!_dates.default.eq(nextProps.range[0], range[0], 'minute') || !_dates.default.eq(nextProps.scrollToTime, scrollToTime, 'minute')) { | ||
if (!dates.eq(nextProps.range[0], range[0], 'minute') || !dates.eq(nextProps.scrollToTime, scrollToTime, 'minute')) { | ||
this.calculateScroll(nextProps); | ||
@@ -180,11 +180,11 @@ } | ||
var daysEvents = (groupedEvents.get(id) || []).filter(function (event) { | ||
return _dates.default.inRange(date, accessors.start(event), accessors.end(event), 'day'); | ||
return dates.inRange(date, accessors.start(event), accessors.end(event), 'day'); | ||
}); | ||
return _react.default.createElement(_DayColumn.default, (0, _extends2.default)({}, _this2.props, { | ||
localizer: localizer, | ||
min: _dates.default.merge(date, min), | ||
max: _dates.default.merge(date, max), | ||
min: dates.merge(date, min), | ||
max: dates.merge(date, max), | ||
resource: resource && id, | ||
components: components, | ||
isNow: _dates.default.eq(date, now, 'day'), | ||
isNow: dates.eq(date, now, 'day'), | ||
key: i + '-' + jj, | ||
@@ -203,2 +203,3 @@ date: date, | ||
width = _this$props3.width, | ||
rtl = _this$props3.rtl, | ||
selected = _this$props3.selected, | ||
@@ -226,3 +227,3 @@ getNow = _this$props3.getNow, | ||
if (accessors.allDay(event) || _dates.default.isJustDate(eStart) && _dates.default.isJustDate(eEnd) || !showMultiDayTimes && !_dates.default.eq(eStart, eEnd, 'day')) { | ||
if (accessors.allDay(event) || dates.isJustDate(eStart) && dates.isJustDate(eEnd) || !showMultiDayTimes && !dates.eq(eStart, eEnd, 'day')) { | ||
allDayEvents.push(event); | ||
@@ -243,2 +244,3 @@ } else { | ||
width: width, | ||
rtl: rtl, | ||
getNow: getNow, | ||
@@ -268,4 +270,4 @@ localizer: localizer, | ||
localizer: localizer, | ||
min: _dates.default.merge(start, min), | ||
max: _dates.default.merge(start, max), | ||
min: dates.merge(start, min), | ||
max: dates.merge(start, max), | ||
step: this.props.step, | ||
@@ -320,7 +322,4 @@ getNow: this.props.getNow, | ||
scrollToTime = _props.scrollToTime; | ||
var diffMillis = scrollToTime - _dates.default.startOf(scrollToTime, 'day'); | ||
var totalMillis = _dates.default.diff(max, min); | ||
var diffMillis = scrollToTime - dates.startOf(scrollToTime, 'day'); | ||
var totalMillis = dates.diff(max, min); | ||
this._scrollRatio = diffMillis / totalMillis; | ||
@@ -365,6 +364,6 @@ }; | ||
timeslots: 2, | ||
min: _dates.default.startOf(new Date(), 'day'), | ||
max: _dates.default.endOf(new Date(), 'day'), | ||
scrollToTime: _dates.default.startOf(new Date(), 'day') | ||
min: dates.startOf(new Date(), 'day'), | ||
max: dates.endOf(new Date(), 'day'), | ||
scrollToTime: dates.startOf(new Date(), 'day') | ||
}; | ||
module.exports = exports["default"]; |
@@ -22,3 +22,3 @@ "use strict"; | ||
accessors = props.accessors, | ||
isRtl = props.isRtl, | ||
rtl = props.rtl, | ||
selected = props.selected, | ||
@@ -61,3 +61,3 @@ label = props.label, | ||
height: height + "%" | ||
}, _extends2[isRtl ? 'right' : 'left'] = Math.max(0, xOffset) + "%", _extends2.width = width + "%", _extends2)), | ||
}, _extends2[rtl ? 'right' : 'left'] = Math.max(0, xOffset) + "%", _extends2.width = width + "%", _extends2)), | ||
title: tooltip ? (typeof label === 'string' ? label + ': ' : '') + tooltip : undefined, | ||
@@ -64,0 +64,0 @@ className: (0, _classnames.default)('rbc-event', className, userProps.className, { |
"use strict"; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
@@ -18,3 +20,3 @@ | ||
var _dates = _interopRequireDefault(require("./utils/dates")); | ||
var dates = _interopRequireWildcard(require("./utils/dates")); | ||
@@ -118,3 +120,3 @@ var _DateContentRow = _interopRequireDefault(require("./DateContentRow")); | ||
style: style, | ||
className: (0, _classnames.default)('rbc-header', className, _dates.default.eq(date, today, 'day') && 'rbc-today') | ||
className: (0, _classnames.default)('rbc-header', className, dates.eq(date, today, 'day') && 'rbc-today') | ||
}, drilldownView ? _react.default.createElement("a", { | ||
@@ -121,0 +123,0 @@ href: "#", |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
exports.__esModule = true; | ||
exports.default = void 0; | ||
exports.monthsInYear = monthsInYear; | ||
exports.firstVisibleDay = firstVisibleDay; | ||
exports.lastVisibleDay = lastVisibleDay; | ||
exports.visibleDays = visibleDays; | ||
exports.ceil = ceil; | ||
exports.range = range; | ||
exports.merge = merge; | ||
exports.eqTime = eqTime; | ||
exports.isJustDate = isJustDate; | ||
exports.duration = duration; | ||
exports.diff = diff; | ||
exports.total = total; | ||
exports.week = week; | ||
exports.today = today; | ||
exports.yesterday = yesterday; | ||
exports.tomorrow = tomorrow; | ||
exports.max = exports.min = exports.inRange = exports.lt = exports.lte = exports.gt = exports.gte = exports.eq = exports.add = exports.endOf = exports.startOf = exports.month = exports.hours = exports.minutes = exports.seconds = exports.milliseconds = void 0; | ||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); | ||
var dates = _interopRequireWildcard(require("date-arithmetic")); | ||
var _dateArithmetic = _interopRequireDefault(require("date-arithmetic")); | ||
exports.milliseconds = dates.milliseconds; | ||
exports.seconds = dates.seconds; | ||
exports.minutes = dates.minutes; | ||
exports.hours = dates.hours; | ||
exports.month = dates.month; | ||
exports.startOf = dates.startOf; | ||
exports.endOf = dates.endOf; | ||
exports.add = dates.add; | ||
exports.eq = dates.eq; | ||
exports.gte = dates.gte; | ||
exports.gt = dates.gt; | ||
exports.lte = dates.lte; | ||
exports.lt = dates.lt; | ||
exports.inRange = dates.inRange; | ||
exports.min = dates.min; | ||
exports.max = dates.max; | ||
@@ -20,116 +51,127 @@ /* eslint no-fallthrough: off */ | ||
var MONTHS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; | ||
var dates = (0, _extends2.default)({}, _dateArithmetic.default, { | ||
monthsInYear: function monthsInYear(year) { | ||
var date = new Date(year, 0, 1); | ||
return MONTHS.map(function (i) { | ||
return dates.month(date, i); | ||
}); | ||
}, | ||
firstVisibleDay: function firstVisibleDay(date, localizer) { | ||
var firstOfMonth = dates.startOf(date, 'month'); | ||
return dates.startOf(firstOfMonth, 'week', localizer.startOfWeek()); | ||
}, | ||
lastVisibleDay: function lastVisibleDay(date, localizer) { | ||
var endOfMonth = dates.endOf(date, 'month'); | ||
return dates.endOf(endOfMonth, 'week', localizer.startOfWeek()); | ||
}, | ||
visibleDays: function visibleDays(date, localizer) { | ||
var current = dates.firstVisibleDay(date, localizer), | ||
last = dates.lastVisibleDay(date, localizer), | ||
days = []; | ||
while (dates.lte(current, last, 'day')) { | ||
days.push(current); | ||
current = dates.add(current, 1, 'day'); | ||
} | ||
function monthsInYear(year) { | ||
var date = new Date(year, 0, 1); | ||
return MONTHS.map(function (i) { | ||
return dates.month(date, i); | ||
}); | ||
} | ||
return days; | ||
}, | ||
ceil: function ceil(date, unit) { | ||
var floor = dates.startOf(date, unit); | ||
return dates.eq(floor, date) ? floor : dates.add(floor, 1, unit); | ||
}, | ||
range: function range(start, end, unit) { | ||
if (unit === void 0) { | ||
unit = 'day'; | ||
} | ||
function firstVisibleDay(date, localizer) { | ||
var firstOfMonth = dates.startOf(date, 'month'); | ||
return dates.startOf(firstOfMonth, 'week', localizer.startOfWeek()); | ||
} | ||
var current = start, | ||
days = []; | ||
function lastVisibleDay(date, localizer) { | ||
var endOfMonth = dates.endOf(date, 'month'); | ||
return dates.endOf(endOfMonth, 'week', localizer.startOfWeek()); | ||
} | ||
while (dates.lte(current, end, unit)) { | ||
days.push(current); | ||
current = dates.add(current, 1, unit); | ||
} | ||
function visibleDays(date, localizer) { | ||
var current = firstVisibleDay(date, localizer), | ||
last = lastVisibleDay(date, localizer), | ||
days = []; | ||
return days; | ||
}, | ||
merge: function merge(date, time) { | ||
if (time == null && date == null) return null; | ||
if (time == null) time = new Date(); | ||
if (date == null) date = new Date(); | ||
date = dates.startOf(date, 'day'); | ||
date = dates.hours(date, dates.hours(time)); | ||
date = dates.minutes(date, dates.minutes(time)); | ||
date = dates.seconds(date, dates.seconds(time)); | ||
return dates.milliseconds(date, dates.milliseconds(time)); | ||
}, | ||
eqTime: function eqTime(dateA, dateB) { | ||
return dates.hours(dateA) === dates.hours(dateB) && dates.minutes(dateA) === dates.minutes(dateB) && dates.seconds(dateA) === dates.seconds(dateB); | ||
}, | ||
isJustDate: function isJustDate(date) { | ||
return dates.hours(date) === 0 && dates.minutes(date) === 0 && dates.seconds(date) === 0 && dates.milliseconds(date) === 0; | ||
}, | ||
duration: function duration(start, end, unit, firstOfWeek) { | ||
if (unit === 'day') unit = 'date'; | ||
return Math.abs(dates[unit](start, undefined, firstOfWeek) - dates[unit](end, undefined, firstOfWeek)); | ||
}, | ||
diff: function diff(dateA, dateB, unit) { | ||
if (!unit || unit === 'milliseconds') return Math.abs(+dateA - +dateB); // the .round() handles an edge case | ||
// with DST where the total won't be exact | ||
// since one day in the range may be shorter/longer by an hour | ||
while (dates.lte(current, last, 'day')) { | ||
days.push(current); | ||
current = dates.add(current, 1, 'day'); | ||
} | ||
return Math.round(Math.abs(+dates.startOf(dateA, unit) / MILLI[unit] - +dates.startOf(dateB, unit) / MILLI[unit])); | ||
}, | ||
total: function total(date, unit) { | ||
var ms = date.getTime(), | ||
div = 1; | ||
return days; | ||
} | ||
switch (unit) { | ||
case 'week': | ||
div *= 7; | ||
function ceil(date, unit) { | ||
var floor = dates.startOf(date, unit); | ||
return dates.eq(floor, date) ? floor : dates.add(floor, 1, unit); | ||
} | ||
case 'day': | ||
div *= 24; | ||
function range(start, end, unit) { | ||
if (unit === void 0) { | ||
unit = 'day'; | ||
} | ||
case 'hours': | ||
div *= 60; | ||
var current = start, | ||
days = []; | ||
case 'minutes': | ||
div *= 60; | ||
while (dates.lte(current, end, unit)) { | ||
days.push(current); | ||
current = dates.add(current, 1, unit); | ||
} | ||
case 'seconds': | ||
div *= 1000; | ||
} | ||
return days; | ||
} | ||
return ms / div; | ||
}, | ||
week: function week(date) { | ||
var d = new Date(date); | ||
d.setHours(0, 0, 0); | ||
d.setDate(d.getDate() + 4 - (d.getDay() || 7)); | ||
return Math.ceil(((d - new Date(d.getFullYear(), 0, 1)) / 8.64e7 + 1) / 7); | ||
}, | ||
today: function today() { | ||
return dates.startOf(new Date(), 'day'); | ||
}, | ||
yesterday: function yesterday() { | ||
return dates.add(dates.startOf(new Date(), 'day'), -1, 'day'); | ||
}, | ||
tomorrow: function tomorrow() { | ||
return dates.add(dates.startOf(new Date(), 'day'), 1, 'day'); | ||
function merge(date, time) { | ||
if (time == null && date == null) return null; | ||
if (time == null) time = new Date(); | ||
if (date == null) date = new Date(); | ||
date = dates.startOf(date, 'day'); | ||
date = dates.hours(date, dates.hours(time)); | ||
date = dates.minutes(date, dates.minutes(time)); | ||
date = dates.seconds(date, dates.seconds(time)); | ||
return dates.milliseconds(date, dates.milliseconds(time)); | ||
} | ||
function eqTime(dateA, dateB) { | ||
return dates.hours(dateA) === dates.hours(dateB) && dates.minutes(dateA) === dates.minutes(dateB) && dates.seconds(dateA) === dates.seconds(dateB); | ||
} | ||
function isJustDate(date) { | ||
return dates.hours(date) === 0 && dates.minutes(date) === 0 && dates.seconds(date) === 0 && dates.milliseconds(date) === 0; | ||
} | ||
function duration(start, end, unit, firstOfWeek) { | ||
if (unit === 'day') unit = 'date'; | ||
return Math.abs(dates[unit](start, undefined, firstOfWeek) - dates[unit](end, undefined, firstOfWeek)); | ||
} | ||
function diff(dateA, dateB, unit) { | ||
if (!unit || unit === 'milliseconds') return Math.abs(+dateA - +dateB); // the .round() handles an edge case | ||
// with DST where the total won't be exact | ||
// since one day in the range may be shorter/longer by an hour | ||
return Math.round(Math.abs(+dates.startOf(dateA, unit) / MILLI[unit] - +dates.startOf(dateB, unit) / MILLI[unit])); | ||
} | ||
function total(date, unit) { | ||
var ms = date.getTime(), | ||
div = 1; | ||
switch (unit) { | ||
case 'week': | ||
div *= 7; | ||
case 'day': | ||
div *= 24; | ||
case 'hours': | ||
div *= 60; | ||
case 'minutes': | ||
div *= 60; | ||
case 'seconds': | ||
div *= 1000; | ||
} | ||
}); | ||
var _default = dates; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
return ms / div; | ||
} | ||
function week(date) { | ||
var d = new Date(date); | ||
d.setHours(0, 0, 0); | ||
d.setDate(d.getDate() + 4 - (d.getDay() || 7)); | ||
return Math.ceil(((d - new Date(d.getFullYear(), 0, 1)) / 8.64e7 + 1) / 7); | ||
} | ||
function today() { | ||
return dates.startOf(new Date(), 'day'); | ||
} | ||
function yesterday() { | ||
return dates.add(dates.startOf(new Date(), 'day'), -1, 'day'); | ||
} | ||
function tomorrow() { | ||
return dates.add(dates.startOf(new Date(), 'day'), 1, 'day'); | ||
} |
"use strict"; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
@@ -12,3 +14,3 @@ | ||
var _dates = _interopRequireDefault(require("./dates")); | ||
var dates = _interopRequireWildcard(require("./dates")); | ||
@@ -65,3 +67,3 @@ var _eventLevels2 = require("./eventLevels"); | ||
return range.find(function (r) { | ||
return _dates.default.eq(r, date, 'day'); | ||
return dates.eq(r, date, 'day'); | ||
}); | ||
@@ -77,10 +79,8 @@ }, | ||
continuesPrior: function continuesPrior(event) { | ||
return _dates.default.lt(accessors.start(event), first, 'day'); | ||
return dates.lt(accessors.start(event), first, 'day'); | ||
}, | ||
continuesAfter: function continuesAfter(event) { | ||
var eventEnd = accessors.end(event); | ||
var singleDayDuration = _dates.default.eq(accessors.start(event), eventEnd, 'minutes'); | ||
return singleDayDuration ? _dates.default.gte(eventEnd, last, 'minutes') : _dates.default.gt(eventEnd, last, 'minutes'); | ||
var singleDayDuration = dates.eq(accessors.start(event), eventEnd, 'minutes'); | ||
return singleDayDuration ? dates.gte(eventEnd, last, 'minutes') : dates.gt(eventEnd, last, 'minutes'); | ||
} | ||
@@ -87,0 +87,0 @@ }; |
"use strict"; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
@@ -15,3 +17,3 @@ | ||
var _dates = _interopRequireDefault(require("./dates")); | ||
var dates = _interopRequireWildcard(require("./dates")); | ||
@@ -25,3 +27,3 @@ function endOfRange(dateRange, unit) { | ||
first: dateRange[0], | ||
last: _dates.default.add(dateRange[dateRange.length - 1], 1, unit) | ||
last: dates.add(dateRange[dateRange.length - 1], 1, unit) | ||
}; | ||
@@ -35,14 +37,9 @@ } | ||
var slots = _dates.default.diff(first, last, 'day'); | ||
var start = _dates.default.max(_dates.default.startOf(accessors.start(event), 'day'), first); | ||
var end = _dates.default.min(_dates.default.ceil(accessors.end(event), 'day'), last); | ||
var slots = dates.diff(first, last, 'day'); | ||
var start = dates.max(dates.startOf(accessors.start(event), 'day'), first); | ||
var end = dates.min(dates.ceil(accessors.end(event), 'day'), last); | ||
var padding = (0, _findIndex.default)(range, function (x) { | ||
return _dates.default.eq(x, start, 'day'); | ||
return dates.eq(x, start, 'day'); | ||
}); | ||
var span = _dates.default.diff(start, end, 'day'); | ||
var span = dates.diff(start, end, 'day'); | ||
span = Math.min(span, slots); | ||
@@ -97,10 +94,7 @@ span = Math.max(span, 1); | ||
function inRange(e, start, end, accessors) { | ||
var eStart = _dates.default.startOf(accessors.start(e), 'day'); | ||
var eStart = dates.startOf(accessors.start(e), 'day'); | ||
var eEnd = accessors.end(e); | ||
var startsBeforeEnd = dates.lte(eStart, end, 'day'); // when the event is zero duration we need to handle a bit differently | ||
var startsBeforeEnd = _dates.default.lte(eStart, end, 'day'); // when the event is zero duration we need to handle a bit differently | ||
var endsAfterStart = !_dates.default.eq(eStart, eEnd, 'minutes') ? _dates.default.gt(eEnd, start, 'minutes') : _dates.default.gte(eEnd, start, 'minutes'); | ||
var endsAfterStart = !dates.eq(eStart, eEnd, 'minutes') ? dates.gt(eEnd, start, 'minutes') : dates.gte(eEnd, start, 'minutes'); | ||
return startsBeforeEnd && endsAfterStart; | ||
@@ -116,8 +110,5 @@ } | ||
function sortEvents(evtA, evtB, accessors) { | ||
var startSort = +_dates.default.startOf(accessors.start(evtA), 'day') - +_dates.default.startOf(accessors.start(evtB), 'day'); | ||
var durA = _dates.default.diff(accessors.start(evtA), _dates.default.ceil(accessors.end(evtA), 'day'), 'day'); | ||
var durB = _dates.default.diff(accessors.start(evtB), _dates.default.ceil(accessors.end(evtB), 'day'), 'day'); | ||
var startSort = +dates.startOf(accessors.start(evtA), 'day') - +dates.startOf(accessors.start(evtB), 'day'); | ||
var durA = dates.diff(accessors.start(evtA), dates.ceil(accessors.end(evtA), 'day'), 'day'); | ||
var durB = dates.diff(accessors.start(evtB), dates.ceil(accessors.end(evtB), 'day'), 'day'); | ||
return startSort || // sort by start Day first | ||
@@ -124,0 +115,0 @@ Math.max(durB, 1) - Math.max(durA, 1) || // events spanning multiple days go first |
@@ -6,22 +6,8 @@ "use strict"; | ||
exports.__esModule = true; | ||
exports.views = exports.dateRangeFormat = exports.dateFormat = exports.accessor = exports.eventComponent = void 0; | ||
exports.views = exports.dateRangeFormat = exports.dateFormat = exports.accessor = void 0; | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _elementType = _interopRequireDefault(require("prop-types-extra/lib/elementType")); | ||
exports.elementType = _elementType.default; | ||
var _all = _interopRequireDefault(require("prop-types-extra/lib/all")); | ||
var _constants = require("./constants"); | ||
var eventComponent = _propTypes.default.oneOfType([_elementType.default, _propTypes.default.shape({ | ||
month: _elementType.default, | ||
week: _elementType.default, | ||
day: _elementType.default, | ||
agenda: _elementType.default | ||
})]); | ||
exports.eventComponent = eventComponent; | ||
var viewNames = Object.keys(_constants.views).map(function (k) { | ||
@@ -57,16 +43,16 @@ return _constants.views[k]; | ||
var views = _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOf(viewNames)), (0, _all.default)(_propTypes.default.object, function (props, name) { | ||
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { | ||
args[_key - 2] = arguments[_key]; | ||
var views = _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOf(viewNames)), _propTypes.default.objectOf(function (prop, key) { | ||
var isBuiltinView = viewNames.indexOf(key) !== -1 && typeof prop[key] === 'boolean'; | ||
if (isBuiltinView) { | ||
return null; | ||
} else { | ||
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { | ||
args[_key - 2] = arguments[_key]; | ||
} | ||
return _propTypes.default.elementType.apply(_propTypes.default, [prop, key].concat(args)); | ||
} | ||
var prop = props[name], | ||
err; | ||
Object.keys(prop).every(function (key) { | ||
var isBuiltinView = viewNames.indexOf(key) !== -1 && typeof prop[key] === 'boolean'; | ||
return isBuiltinView || !(err = _elementType.default.apply(void 0, [prop, key].concat(args))); | ||
}); | ||
return err || null; | ||
})]); | ||
exports.views = views; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
@@ -8,3 +8,3 @@ exports.__esModule = true; | ||
var _dates = _interopRequireDefault(require("./dates")); | ||
var dates = _interopRequireWildcard(require("./dates")); | ||
@@ -16,3 +16,3 @@ var getDstOffset = function getDstOffset(start, end) { | ||
var getKey = function getKey(min, max, step, slots) { | ||
return "" + +_dates.default.startOf(min, 'minutes') + ("" + +_dates.default.startOf(max, 'minutes')) + (step + "-" + slots); | ||
return "" + +dates.startOf(min, 'minutes') + ("" + +dates.startOf(max, 'minutes')) + (step + "-" + slots); | ||
}; | ||
@@ -28,7 +28,6 @@ | ||
var daystart = _dates.default.startOf(start, 'day'); | ||
var daystart = dates.startOf(start, 'day'); | ||
var daystartdstoffset = getDstOffset(daystart, start); | ||
var totalMin = 1 + _dates.default.diff(start, end, 'minutes') + getDstOffset(start, end); | ||
var minutesFromMidnight = _dates.default.diff(daystart, start, 'minutes') + daystartdstoffset; | ||
var totalMin = 1 + dates.diff(start, end, 'minutes') + getDstOffset(start, end); | ||
var minutesFromMidnight = dates.diff(daystart, start, 'minutes') + daystartdstoffset; | ||
var numGroups = Math.ceil(totalMin / (step * timeslots)); | ||
@@ -56,3 +55,3 @@ var numSlots = numGroups * timeslots; | ||
function positionFromDate(date) { | ||
var diff = _dates.default.diff(start, date, 'minutes') + getDstOffset(start, date); | ||
var diff = dates.diff(start, date, 'minutes') + getDstOffset(start, date); | ||
return Math.min(diff, totalMin); | ||
@@ -69,3 +68,3 @@ } | ||
var nextGroup = groups[groupIndex + 1]; | ||
return _dates.default.inRange(date, groups[groupIndex][0], nextGroup ? nextGroup[0] : end, 'minutes'); | ||
return dates.inRange(date, groups[groupIndex][0], nextGroup ? nextGroup[0] : end, 'minutes'); | ||
}, | ||
@@ -75,3 +74,3 @@ nextSlot: function nextSlot(slot) { | ||
if (next === slot) next = _dates.default.add(slot, step, 'minutes'); | ||
if (next === slot) next = dates.add(slot, step, 'minutes'); | ||
return next; | ||
@@ -92,26 +91,24 @@ }, | ||
if (_dates.default.lt(date, start, 'minutes')) return slots[0]; | ||
var diffMins = _dates.default.diff(start, date, 'minutes'); | ||
if (dates.lt(date, start, 'minutes')) return slots[0]; | ||
var diffMins = dates.diff(start, date, 'minutes'); | ||
return slots[(diffMins - diffMins % step) / step + offset]; | ||
}, | ||
startsBeforeDay: function startsBeforeDay(date) { | ||
return _dates.default.lt(date, start, 'day'); | ||
return dates.lt(date, start, 'day'); | ||
}, | ||
startsAfterDay: function startsAfterDay(date) { | ||
return _dates.default.gt(date, end, 'day'); | ||
return dates.gt(date, end, 'day'); | ||
}, | ||
startsBefore: function startsBefore(date) { | ||
return _dates.default.lt(_dates.default.merge(start, date), start, 'minutes'); | ||
return dates.lt(dates.merge(start, date), start, 'minutes'); | ||
}, | ||
startsAfter: function startsAfter(date) { | ||
return _dates.default.gt(_dates.default.merge(end, date), end, 'minutes'); | ||
return dates.gt(dates.merge(end, date), end, 'minutes'); | ||
}, | ||
getRange: function getRange(rangeStart, rangeEnd) { | ||
rangeStart = _dates.default.min(end, _dates.default.max(start, rangeStart)); | ||
rangeEnd = _dates.default.min(end, _dates.default.max(start, rangeEnd)); | ||
getRange: function getRange(rangeStart, rangeEnd, ignoreMin, ignoreMax) { | ||
if (!ignoreMin) rangeStart = dates.min(end, dates.max(start, rangeStart)); | ||
if (!ignoreMax) rangeEnd = dates.min(end, dates.max(start, rangeEnd)); | ||
var rangeStartMin = positionFromDate(rangeStart); | ||
var rangeEndMin = positionFromDate(rangeEnd); | ||
var top = rangeStartMin / (step * numSlots) * 100; | ||
var top = rangeEndMin - rangeStartMin < step ? (rangeStartMin - step) / (step * numSlots) * 100 : rangeStartMin / (step * numSlots) * 100; | ||
return { | ||
@@ -118,0 +115,0 @@ top: top, |
"use strict"; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
@@ -18,3 +20,3 @@ | ||
var _dates = _interopRequireDefault(require("./utils/dates")); | ||
var dates = _interopRequireWildcard(require("./utils/dates")); | ||
@@ -58,6 +60,6 @@ var _constants = require("./utils/constants"); | ||
case _constants.navigate.PREVIOUS: | ||
return _dates.default.add(date, -1, 'week'); | ||
return dates.add(date, -1, 'week'); | ||
case _constants.navigate.NEXT: | ||
return _dates.default.add(date, 1, 'week'); | ||
return dates.add(date, 1, 'week'); | ||
@@ -72,8 +74,5 @@ default: | ||
var firstOfWeek = localizer.startOfWeek(); | ||
var start = _dates.default.startOf(date, 'week', firstOfWeek); | ||
var end = _dates.default.endOf(date, 'week', firstOfWeek); | ||
return _dates.default.range(start, end); | ||
var start = dates.startOf(date, 'week', firstOfWeek); | ||
var end = dates.endOf(date, 'week', firstOfWeek); | ||
return dates.range(start, end); | ||
}; | ||
@@ -80,0 +79,0 @@ |
{ | ||
"name": "react-big-calendar", | ||
"version": "0.21.0", | ||
"version": "0.22.0", | ||
"description": "Calendar! with events", | ||
@@ -80,2 +80,3 @@ "author": "Jason Quense <monastic.panic@gmail.com>", | ||
"babel-plugin-transform-react-remove-prop-types": "^0.4.22", | ||
"babel-plugin-transform-rename-import": "^2.3.0", | ||
"babel-preset-jason": "^6.0.1", | ||
@@ -126,11 +127,11 @@ "bootstrap": "^3.3.5", | ||
"classnames": "^2.2.6", | ||
"date-arithmetic": "^3.0.0", | ||
"date-arithmetic": "^4.0.0", | ||
"dom-helpers": "^3.4.0", | ||
"invariant": "^2.2.4", | ||
"lodash": "^4.17.11", | ||
"lodash-es": "^4.17.11", | ||
"memoize-one": "^4.0.3", | ||
"prop-types": "^15.6.2", | ||
"prop-types-extra": "^1.1.0", | ||
"react-overlays": "^1.2.0", | ||
"uncontrollable": "^6.0.0", | ||
"uncontrollable": "^6.2.3", | ||
"warning": "^4.0.2" | ||
@@ -137,0 +138,0 @@ }, |
@@ -42,10 +42,10 @@ # react-big-calendar | ||
```js | ||
import BigCalendar from 'react-big-calendar' | ||
import { Calendar, momentLocalizer } from 'react-big-calendar' | ||
import moment from 'moment' | ||
const localizer = BigCalendar.momentLocalizer(moment) | ||
const localizer = momentLocalizer(moment) | ||
const MyCalendar = props => ( | ||
<div> | ||
<BigCalendar | ||
<Calendar | ||
localizer={localizer} | ||
@@ -63,10 +63,10 @@ events={myEventsList} | ||
```js | ||
import BigCalendar from 'react-big-calendar' | ||
import { Calendar, globalizeLocalizer } from 'react-big-calendar' | ||
import globalize from 'globalize' | ||
const localizer = BigCalendar.globalizeLocalizer(globalize) | ||
const localizer = globalizeLocalizer(globalize) | ||
const MyCalendar = props => ( | ||
<div> | ||
<BigCalendar | ||
<Calendar | ||
localizer={localizer} | ||
@@ -73,0 +73,0 @@ events={myEventsList} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1158072
51
26560
+ Addedlodash-es@^4.17.11
+ Addeddate-arithmetic@4.1.0(transitive)
+ Addedlodash-es@4.17.21(transitive)
- Removedprop-types-extra@^1.1.0
- Removeddate-arithmetic@3.1.0(transitive)
Updateddate-arithmetic@^4.0.0
Updateduncontrollable@^6.2.3