Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@devexpress/dx-scheduler-core

Package Overview
Dependencies
Maintainers
13
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@devexpress/dx-scheduler-core - npm Package Compare versions

Comparing version 1.11.1 to 2.0.0

535

dist/dx-scheduler-core.es.js
/**
* Bundle of @devexpress/dx-scheduler-core
* Generated: 2019-06-14
* Version: 1.11.1
* Generated: 2019-07-08
* Version: 2.0.0
* License: https://js.devexpress.com/Licensing

@@ -257,6 +257,6 @@ */

var horizontalRectCalculator = function (appointment, _a) {
var rectByDates = _a.rectByDates, multiline = _a.multiline, _b = _a.rectByDatesMeta, cellElements = _b.cellElements, viewCellsData = _b.viewCellsData;
var rectByDates = _a.rectByDates, multiline = _a.multiline, _b = _a.rectByDatesMeta, cellElementsMeta = _b.cellElementsMeta, viewCellsData = _b.viewCellsData;
var _c = rectCalculatorBase(appointment, rectByDates, {
multiline: multiline,
cellElements: cellElements,
cellElementsMeta: cellElementsMeta,
viewCellsData: viewCellsData,

@@ -276,3 +276,3 @@ }), top = _c.top, left = _c.left, width = _c.width, height = _c.height, parentWidth = _c.parentWidth;

var verticalRectCalculator = function (appointment, _a) {
var rectByDates = _a.rectByDates, multiline = _a.multiline, _b = _a.rectByDatesMeta, viewCellsData = _b.viewCellsData, cellDuration = _b.cellDuration, cellElements = _b.cellElements, excludedDays = _b.excludedDays;
var rectByDates = _a.rectByDates, multiline = _a.multiline, _b = _a.rectByDatesMeta, viewCellsData = _b.viewCellsData, cellDuration = _b.cellDuration, cellElementsMeta = _b.cellElementsMeta, excludedDays = _b.excludedDays;
var _c = rectCalculatorBase(appointment, rectByDates, {

@@ -283,3 +283,3 @@ multiline: multiline,

excludedDays: excludedDays,
cellElements: cellElements,
cellElementsMeta: cellElementsMeta,
}), top = _c.top, left = _c.left, width = _c.width, height = _c.height, parentWidth = _c.parentWidth;

@@ -358,11 +358,11 @@ var widthInPx = width / appointment.reduceValue;

};
var availableViewNames = function (viewNames, viewName) {
if (!viewNames)
return [viewName];
if (viewNames.findIndex(function (view) { return viewName === view; }) === -1) {
var nextViewNames = viewNames.slice();
nextViewNames.push(viewName);
return nextViewNames;
var availableViews = function (views, viewName, viewDisplayName) {
if (!views)
return [{ name: viewName, displayName: viewDisplayName }];
if (views.findIndex(function (view) { return viewName === view.name; }) === -1) {
var nextViews = views.slice();
nextViews.push({ name: viewName, displayName: viewDisplayName });
return nextViews;
}
return viewNames;
return views;
};

@@ -405,27 +405,139 @@ var viewCellsData = function (currentDate, firstDayOfWeek, dayCount, excludedDays, startDayHour, endDayHour, cellDuration, currTime) {

var dateTimeFormatInstance = function (locale, formatOptions) { return new Intl.DateTimeFormat(locale, formatOptions); };
var sliceAppointmentByDay = function (appointment) {
var start = appointment.start, end = appointment.end, dataItem = appointment.dataItem;
if (start.isSame(end, 'day')) {
return [appointment];
}
return [
{ start: start, end: moment(start).endOf('day'), dataItem: dataItem },
{ start: moment(end).startOf('day'), end: end, dataItem: dataItem },
];
};
var dayBoundaryPredicate = function (appointment, leftBound, rightBound, excludedDays) {
if (excludedDays === void 0) { excludedDays = []; }
var dayStart = moment(leftBound);
var dayEnd = moment(rightBound);
var startDayTime = moment(appointment.start)
.hour(dayStart.hour())
.minutes(dayStart.minutes());
var endDayTime = moment(appointment.start)
.hour(dayEnd.hour())
.minutes(dayEnd.minutes());
if (appointment.end.isBefore(dayStart) || appointment.start.isAfter(dayEnd))
return false;
if (excludedDays.findIndex(function (day) { return day === moment(appointment.start).day(); }) !== -1)
return false;
return (appointment.end.isAfter(startDayTime)
&& appointment.start.isBefore(endDayTime));
};
var reduceAppointmentByDayBounds = function (appointment, leftBound, rightBound) {
var dayStart = moment(leftBound);
var dayEnd = moment(rightBound);
var startDayTime = moment(appointment.start)
.hour(dayStart.hour())
.minutes(dayStart.minutes())
.seconds(dayStart.seconds());
var endDayTime = moment(appointment.start)
.hour(dayEnd.hour())
.minutes(dayEnd.minutes())
.seconds(dayEnd.seconds());
return __assign({}, appointment, (appointment.start.isSameOrBefore(startDayTime) ? { start: startDayTime } : null), (appointment.end.isSameOrAfter(endDayTime) ? { end: endDayTime } : null));
};
var appointments = function (data) { return data.map(function (appointment) { return (__assign({ start: appointment.startDate, end: appointment.endDate }, appointment.allDay !== undefined && {
allDay: appointment.allDay,
}, appointment.rRule !== undefined && {
rRule: appointment.rRule,
}, appointment.exDate !== undefined && {
exDate: appointment.exDate,
}, { dataItem: appointment })); }); };
var formatDateTimeGetter = function (locale) {
var cache = new Map(); // any -> type
var formatter = function (nextDate, nextOptions) {
if (nextDate === undefined)
return '';
var date = new Date(nextDate);
var formatInstance = cache.get(nextOptions);
if (!formatInstance) {
formatInstance = dateTimeFormatInstance(locale, nextOptions);
cache.set(nextOptions, formatInstance);
}
return formatInstance.format(date);
var calculateWeekDateIntervals = function (appointments, leftBound, rightBound, excludedDays) { return appointments
.map(function (_a) {
var start = _a.start, end = _a.end, restArgs = __rest(_a, ["start", "end"]);
return (__assign({ start: moment(start), end: moment(end) }, restArgs));
})
.reduce(function (acc, appointment) {
return __spread(acc, filterByViewBoundaries(appointment, leftBound, rightBound, excludedDays, true));
}, [])
.reduce(function (acc, appointment) { return (__spread(acc, sliceAppointmentByDay(appointment))); }, [])
.filter(function (appointment) { return dayBoundaryPredicate(appointment, leftBound, rightBound, excludedDays); })
.map(function (appointment) { return reduceAppointmentByDayBounds(appointment, leftBound, rightBound); }); };
var CELL_GAP_PX = 10;
var CELL_BOUND_HORIZONTAL_OFFSET_PX = 1;
var CELL_BOUND_VERTICAL_OFFSET_PX = 4;
var getCellByDate = function (viewCellsData, date, takePrev) {
if (takePrev === void 0) { takePrev = false; }
var cellIndex = viewCellsData[0].findIndex(function (timeCell) { return moment(date)
.isSame(timeCell.startDate, 'date'); });
var rowIndex = viewCellsData.findIndex(function (timeCell) { return moment(date)
.isBetween(timeCell[cellIndex].startDate, timeCell[cellIndex].endDate, 'seconds', takePrev ? '(]' : '[)'); });
var totalCellIndex = (rowIndex * viewCellsData[0].length) + cellIndex;
return {
index: totalCellIndex,
startDate: viewCellsData[rowIndex][cellIndex].startDate,
};
return formatter;
};
var getCellRect = function (date, viewCellsData, cellDuration, cellElementsMeta, takePrev) {
var _a = getCellByDate(viewCellsData, date, takePrev), cellIndex = _a.index, cellStartDate = _a.startDate;
var _b = cellElementsMeta.getCellRects[cellIndex](), top = _b.top, left = _b.left, width = _b.width, cellHeight = _b.height;
var timeOffset = moment(date).diff(cellStartDate, 'minutes');
var topOffset = cellHeight * (timeOffset / cellDuration);
var parentRect = cellElementsMeta.parentRect();
return {
top: top,
left: left,
width: width,
topOffset: topOffset,
parentRect: parentRect,
};
};
var getVerticalRectByDates = function (startDate, endDate, _a) {
var viewCellsData = _a.viewCellsData, cellDuration = _a.cellDuration, cellElementsMeta = _a.cellElementsMeta;
var firstCellRect = getCellRect(startDate, viewCellsData, cellDuration, cellElementsMeta, false);
var lastCellRect = getCellRect(endDate, viewCellsData, cellDuration, cellElementsMeta, true);
var top = firstCellRect.top + firstCellRect.topOffset;
var height = (lastCellRect.top + lastCellRect.topOffset) - top;
return {
width: firstCellRect.width - CELL_GAP_PX - CELL_BOUND_HORIZONTAL_OFFSET_PX,
top: top - firstCellRect.parentRect.top + CELL_BOUND_HORIZONTAL_OFFSET_PX,
left: firstCellRect.left - firstCellRect.parentRect.left + CELL_BOUND_HORIZONTAL_OFFSET_PX,
parentWidth: firstCellRect.parentRect.width,
height: height - CELL_BOUND_VERTICAL_OFFSET_PX,
};
};
var allDayPredicate = function (appointment) { return (appointment.end.diff(appointment.start, 'hours') > 23
|| !!appointment.allDay); };
var getAllDayCellIndexByDate = function (viewCellsData, date, takePrev) {
var currentDate = moment(date);
var cellIndex = viewCellsData[0]
.findIndex(function (day) { return moment(day.startDate).day() === currentDate.day(); });
if (takePrev && currentDate.format() === currentDate.startOf('day').format()) {
cellIndex -= 1;
}
return cellIndex;
};
var sliceAppointmentsByBoundaries = function (appointment, left, right, excludedDays) {
if (excludedDays === void 0) { excludedDays = []; }
var startDate = appointment.start.clone();
var endDate = appointment.end.clone();
var nextStart = startDate.clone();
var nextEnd = endDate.clone();
if (startDate.isBefore(left)) {
nextStart = moment(left);
nextStart.startOf('day');
}
if (endDate.isAfter(right)) {
nextEnd = moment(right);
nextEnd.endOf('day');
}
if (excludedDays.findIndex(function (day) { return day === startDate.day(); }) !== -1) {
while (excludedDays.findIndex(function (day) { return day === nextStart.day(); }) !== -1
&& nextStart.isSameOrBefore(endDate, 'day')) {
nextStart.add(1, 'days').startOf('day');
}
}
if (excludedDays.findIndex(function (day) { return day === endDate.day(); }) !== -1) {
while (excludedDays.findIndex(function (day) { return day === nextEnd.day(); }) !== -1
&& nextStart.isSameOrAfter(startDate, 'day')) {
nextEnd.add(-1, 'days').endOf('day');
}
}
return [__assign({}, appointment, { start: nextStart, end: nextEnd })];
};
var sliceAppointmentByWeek = function (timeBounds, appointment, step) {

@@ -474,2 +586,33 @@ var left = timeBounds.left, right = timeBounds.right;

var TOP_CELL_OFFSET = 0.32;
var CELL_BOUND_OFFSET_PX = 1;
var getCellRect$1 = function (date, viewCellsData, cellElementsMeta, takePrev, multiline) {
var cellIndex = multiline
? getMonthCellIndexByDate(viewCellsData, date, takePrev)
: getAllDayCellIndexByDate(viewCellsData, date, takePrev);
var _a = cellElementsMeta.getCellRects[cellIndex](), top = _a.top, left = _a.left, width = _a.width, height = _a.height;
var parentRect = cellElementsMeta.parentRect();
return {
top: top,
left: left,
width: width,
height: height,
parentRect: parentRect,
};
};
var getHorizontalRectByDates = function (startDate, endDate, _a) {
var multiline = _a.multiline, viewCellsData = _a.viewCellsData, cellElementsMeta = _a.cellElementsMeta;
var firstCellRect = getCellRect$1(startDate, viewCellsData, cellElementsMeta, false, multiline);
var lastCellRect = getCellRect$1(endDate, viewCellsData, cellElementsMeta, true, multiline);
var top = firstCellRect.top + (firstCellRect.height * TOP_CELL_OFFSET);
var height = firstCellRect.height - (firstCellRect.height * TOP_CELL_OFFSET);
return {
top: top - firstCellRect.parentRect.top,
left: (firstCellRect.left - firstCellRect.parentRect.left) + CELL_BOUND_OFFSET_PX,
width: ((lastCellRect.left - firstCellRect.left) + firstCellRect.width) - CELL_BOUND_OFFSET_PX,
height: height,
parentWidth: firstCellRect.parentRect.width,
};
};
var DAY_COUNT = 7;

@@ -520,44 +663,3 @@ var MONTH_LENGTH = 31;

var sliceAppointmentByDay = function (appointment) {
var start = appointment.start, end = appointment.end, dataItem = appointment.dataItem;
if (start.isSame(end, 'day')) {
return [appointment];
}
return [
{ start: start, end: moment(start).endOf('day'), dataItem: dataItem },
{ start: moment(end).startOf('day'), end: end, dataItem: dataItem },
];
};
var dayBoundaryPredicate = function (appointment, leftBound, rightBound, excludedDays) {
if (excludedDays === void 0) { excludedDays = []; }
var dayStart = moment(leftBound);
var dayEnd = moment(rightBound);
var startDayTime = moment(appointment.start)
.hour(dayStart.hour())
.minutes(dayStart.minutes());
var endDayTime = moment(appointment.start)
.hour(dayEnd.hour())
.minutes(dayEnd.minutes());
if (appointment.end.isBefore(dayStart) || appointment.start.isAfter(dayEnd))
return false;
if (excludedDays.findIndex(function (day) { return day === moment(appointment.start).day(); }) !== -1)
return false;
return (appointment.end.isAfter(startDayTime)
&& appointment.start.isBefore(endDayTime));
};
var reduceAppointmentByDayBounds = function (appointment, leftBound, rightBound) {
var dayStart = moment(leftBound);
var dayEnd = moment(rightBound);
var startDayTime = moment(appointment.start)
.hour(dayStart.hour())
.minutes(dayStart.minutes())
.seconds(dayStart.seconds());
var endDayTime = moment(appointment.start)
.hour(dayEnd.hour())
.minutes(dayEnd.minutes())
.seconds(dayEnd.seconds());
return __assign({}, appointment, (appointment.start.isSameOrBefore(startDayTime) ? { start: startDayTime } : null), (appointment.end.isSameOrAfter(endDayTime) ? { end: endDayTime } : null));
};
var calculateWeekDateIntervals = function (appointments, leftBound, rightBound, excludedDays) { return appointments
var calculateAllDayDateIntervals = function (appointments, leftBound, rightBound, excludedDays) { return appointments
.map(function (_a) {

@@ -568,8 +670,71 @@ var start = _a.start, end = _a.end, restArgs = __rest(_a, ["start", "end"]);

.reduce(function (acc, appointment) {
return __spread(acc, filterByViewBoundaries(appointment, leftBound, rightBound, excludedDays, true));
return __spread(acc, filterByViewBoundaries(appointment, leftBound, rightBound, excludedDays, false));
}, [])
.reduce(function (acc, appointment) { return (__spread(acc, sliceAppointmentByDay(appointment))); }, [])
.filter(function (appointment) { return dayBoundaryPredicate(appointment, leftBound, rightBound, excludedDays); })
.map(function (appointment) { return reduceAppointmentByDayBounds(appointment, leftBound, rightBound); }); };
.filter(function (appointment) { return allDayPredicate(appointment); })
.reduce(function (acc, appointment) { return (__spread(acc, sliceAppointmentsByBoundaries(appointment, leftBound, rightBound, excludedDays))); }, []); };
var allDayRects = function (appointments, startViewDate, endViewDate, excludedDays, viewCellsData, cellElementsMeta) {
var intervals = calculateAllDayDateIntervals(appointments, startViewDate, endViewDate, excludedDays);
return calculateRectByDateIntervals({
growDirection: HORIZONTAL_TYPE,
multiline: false,
}, intervals, getHorizontalRectByDates, {
startViewDate: startViewDate,
endViewDate: endViewDate,
viewCellsData: viewCellsData,
cellElementsMeta: cellElementsMeta,
excludedDays: excludedDays,
});
};
var verticalTimeTableRects = function (appointments, startViewDate, endViewDate, excludedDays, viewCellsData, cellDuration, cellElementsMeta) {
var intervals = calculateWeekDateIntervals(appointments, startViewDate, endViewDate, excludedDays);
return calculateRectByDateIntervals({
growDirection: VERTICAL_TYPE,
multiline: false,
}, intervals, getVerticalRectByDates, {
startViewDate: startViewDate,
endViewDate: endViewDate,
viewCellsData: viewCellsData,
cellDuration: cellDuration,
cellElementsMeta: cellElementsMeta,
});
};
var horizontalTimeTableRects = function (appointments, startViewDate, endViewDate, viewCellsData, cellElementsMeta) {
var intervals = calculateMonthDateIntervals(appointments, startViewDate, endViewDate);
return calculateRectByDateIntervals({
growDirection: HORIZONTAL_TYPE,
multiline: true,
}, intervals, getHorizontalRectByDates, {
startViewDate: startViewDate,
endViewDate: endViewDate,
viewCellsData: viewCellsData,
cellElementsMeta: cellElementsMeta,
});
};
var dateTimeFormatInstance = function (locale, formatOptions) { return new Intl.DateTimeFormat(locale, formatOptions); };
var appointments = function (data) { return data.map(function (appointment) { return (__assign({ start: appointment.startDate, end: appointment.endDate }, appointment.allDay !== undefined && {
allDay: appointment.allDay,
}, appointment.rRule !== undefined && {
rRule: appointment.rRule,
}, appointment.exDate !== undefined && {
exDate: appointment.exDate,
}, { dataItem: appointment })); }); };
var formatDateTimeGetter = function (locale) {
var cache = new Map(); // any -> type
var formatter = function (nextDate, nextOptions) {
if (nextDate === undefined)
return '';
var date = new Date(nextDate);
var formatInstance = cache.get(nextOptions);
if (!formatInstance) {
formatInstance = dateTimeFormatInstance(locale, nextOptions);
cache.set(nextOptions, formatInstance);
}
return formatInstance.format(date);
};
return formatter;
};
var changeCurrentDate = function (currentDate, _a) {

@@ -636,53 +801,2 @@ var nextDate = _a.nextDate, step = _a.step, amount = _a.amount, direction = _a.direction;

var allDayPredicate = function (appointment) { return (appointment.end.diff(appointment.start, 'hours') > 23
|| !!appointment.allDay); };
var getAllDayCellIndexByDate = function (viewCellsData, date, takePrev) {
var currentDate = moment(date);
var cellIndex = viewCellsData[0]
.findIndex(function (day) { return moment(day.startDate).day() === currentDate.day(); });
if (takePrev && currentDate.format() === currentDate.startOf('day').format()) {
cellIndex -= 1;
}
return cellIndex;
};
var sliceAppointmentsByBoundaries = function (appointment, left, right, excludedDays) {
if (excludedDays === void 0) { excludedDays = []; }
var startDate = appointment.start.clone();
var endDate = appointment.end.clone();
var nextStart = startDate.clone();
var nextEnd = endDate.clone();
if (startDate.isBefore(left)) {
nextStart = moment(left);
nextStart.startOf('day');
}
if (endDate.isAfter(right)) {
nextEnd = moment(right);
nextEnd.endOf('day');
}
if (excludedDays.findIndex(function (day) { return day === startDate.day(); }) !== -1) {
while (excludedDays.findIndex(function (day) { return day === nextStart.day(); }) !== -1
&& nextStart.isSameOrBefore(endDate, 'day')) {
nextStart.add(1, 'days').startOf('day');
}
}
if (excludedDays.findIndex(function (day) { return day === endDate.day(); }) !== -1) {
while (excludedDays.findIndex(function (day) { return day === nextEnd.day(); }) !== -1
&& nextStart.isSameOrAfter(startDate, 'day')) {
nextEnd.add(-1, 'days').endOf('day');
}
}
return [__assign({}, appointment, { start: nextStart, end: nextEnd })];
};
var calculateAllDayDateIntervals = function (appointments, leftBound, rightBound, excludedDays) { return appointments
.map(function (_a) {
var start = _a.start, end = _a.end, restArgs = __rest(_a, ["start", "end"]);
return (__assign({ start: moment(start), end: moment(end) }, restArgs));
})
.reduce(function (acc, appointment) {
return __spread(acc, filterByViewBoundaries(appointment, leftBound, rightBound, excludedDays, false));
}, [])
.filter(function (appointment) { return allDayPredicate(appointment); })
.reduce(function (acc, appointment) { return (__spread(acc, sliceAppointmentsByBoundaries(appointment, leftBound, rightBound, excludedDays))); }, []); };
var addAppointment = function (addedAppointmentData, _a) {

@@ -709,124 +823,2 @@ var appointmentData = (_a === void 0 ? { appointmentData: {} } : _a).appointmentData;

var TOP_CELL_OFFSET = 0.32;
var CELL_BOUND_OFFSET_PX = 1;
var getCellRect = function (date, viewCellsData, cellElements, takePrev, multiline) {
var cellIndex = multiline
? getMonthCellIndexByDate(viewCellsData, date, takePrev)
: getAllDayCellIndexByDate(viewCellsData, date, takePrev);
var cellElement = cellElements[cellIndex];
var _a = cellElement.getBoundingClientRect(), top = _a.top, left = _a.left, width = _a.width, height = _a.height;
var parentRect = { left: 0, top: 0, width: 0 };
if (cellElement.offsetParent) {
parentRect = cellElement.offsetParent.getBoundingClientRect();
}
return {
top: top,
left: left,
width: width,
height: height,
parentRect: parentRect,
};
};
var getHorizontalRectByDates = function (startDate, endDate, _a) {
var multiline = _a.multiline, viewCellsData = _a.viewCellsData, cellElements = _a.cellElements;
var firstCellRect = getCellRect(startDate, viewCellsData, cellElements, false, multiline);
var lastCellRect = getCellRect(endDate, viewCellsData, cellElements, true, multiline);
var top = firstCellRect.top + (firstCellRect.height * TOP_CELL_OFFSET);
var height = firstCellRect.height - (firstCellRect.height * TOP_CELL_OFFSET);
return {
top: top - firstCellRect.parentRect.top,
left: (firstCellRect.left - firstCellRect.parentRect.left) + CELL_BOUND_OFFSET_PX,
width: ((lastCellRect.left - firstCellRect.left) + firstCellRect.width) - CELL_BOUND_OFFSET_PX,
height: height,
parentWidth: firstCellRect.parentRect.width,
};
};
var CELL_GAP_PX = 10;
var CELL_BOUND_HORIZONTAL_OFFSET_PX = 1;
var CELL_BOUND_VERTICAL_OFFSET_PX = 4;
var getCellByDate = function (viewCellsData, date, takePrev) {
if (takePrev === void 0) { takePrev = false; }
var cellIndex = viewCellsData[0].findIndex(function (timeCell) { return moment(date)
.isSame(timeCell.startDate, 'date'); });
var rowIndex = viewCellsData.findIndex(function (timeCell) { return moment(date)
.isBetween(timeCell[cellIndex].startDate, timeCell[cellIndex].endDate, 'seconds', takePrev ? '(]' : '[)'); });
var totalCellIndex = (rowIndex * viewCellsData[0].length) + cellIndex;
return {
index: totalCellIndex,
startDate: viewCellsData[rowIndex][cellIndex].startDate,
};
};
var getCellRect$1 = function (date, viewCellsData, cellDuration, cellElements, takePrev) {
var _a = getCellByDate(viewCellsData, date, takePrev), cellIndex = _a.index, cellStartDate = _a.startDate;
var cellElement = cellElements[cellIndex];
var _b = cellElement.getBoundingClientRect(), top = _b.top, left = _b.left, width = _b.width, cellHeight = _b.height;
var timeOffset = moment(date).diff(cellStartDate, 'minutes');
var topOffset = cellHeight * (timeOffset / cellDuration);
var parentRect = { left: 0, top: 0, width: 0 };
if (cellElement.offsetParent) {
parentRect = cellElement.offsetParent.getBoundingClientRect();
}
return {
top: top,
left: left,
width: width,
topOffset: topOffset,
parentRect: parentRect,
};
};
var getVerticalRectByDates = function (startDate, endDate, _a) {
var viewCellsData = _a.viewCellsData, cellDuration = _a.cellDuration, cellElements = _a.cellElements;
var firstCellRect = getCellRect$1(startDate, viewCellsData, cellDuration, cellElements, false);
var lastCellRect = getCellRect$1(endDate, viewCellsData, cellDuration, cellElements, true);
var top = firstCellRect.top + firstCellRect.topOffset;
var height = (lastCellRect.top + lastCellRect.topOffset) - top;
return {
width: firstCellRect.width - CELL_GAP_PX - CELL_BOUND_HORIZONTAL_OFFSET_PX,
top: top - firstCellRect.parentRect.top + CELL_BOUND_HORIZONTAL_OFFSET_PX,
left: firstCellRect.left - firstCellRect.parentRect.left + CELL_BOUND_HORIZONTAL_OFFSET_PX,
parentWidth: firstCellRect.parentRect.width,
height: height - CELL_BOUND_VERTICAL_OFFSET_PX,
};
};
var allDayRects = function (draftAppointments, startViewDate, endViewDate, excludedDays, viewCellsData, cellElements) {
var intervals = calculateAllDayDateIntervals(draftAppointments, startViewDate, endViewDate, excludedDays);
return calculateRectByDateIntervals({
growDirection: HORIZONTAL_TYPE,
multiline: false,
}, intervals, getHorizontalRectByDates, {
startViewDate: startViewDate,
endViewDate: endViewDate,
viewCellsData: viewCellsData,
cellElements: cellElements,
excludedDays: excludedDays,
});
};
var verticalTimeTableRects = function (draftAppointments, startViewDate, endViewDate, excludedDays, viewCellsData, cellDuration, cellElements) {
var intervals = calculateWeekDateIntervals(draftAppointments, startViewDate, endViewDate, excludedDays);
return calculateRectByDateIntervals({
growDirection: VERTICAL_TYPE,
multiline: false,
}, intervals, getVerticalRectByDates, {
startViewDate: startViewDate,
endViewDate: endViewDate,
viewCellsData: viewCellsData,
cellDuration: cellDuration,
cellElements: cellElements,
});
};
var horizontalTimeTableRects = function (draftAppointments, startViewDate, endViewDate, viewCellsData, cellElements) {
var intervals = calculateMonthDateIntervals(draftAppointments, startViewDate, endViewDate);
return calculateRectByDateIntervals({
growDirection: HORIZONTAL_TYPE,
multiline: true,
}, intervals, getHorizontalRectByDates, {
startViewDate: startViewDate,
endViewDate: endViewDate,
viewCellsData: viewCellsData,
cellElements: cellElements,
});
};
var clamp = function (value, min, max) { return Math.max(Math.min(value, max), min); };

@@ -838,4 +830,4 @@ var calculateInsideOffset = function (targetType, insidePart, cellDurationMinutes) { return targetType === VERTICAL_TYPE

var intervalDuration = function (data, type) { return moment(data.endDate).diff(data.startDate, type); };
var cellIndex = function (timeTableCells, clientOffset) { return timeTableCells.findIndex(function (timeTableCell) {
var _a = timeTableCell.getBoundingClientRect(), left = _a.left, top = _a.top, right = _a.right, bottom = _a.bottom;
var cellIndex = function (getCellRects, clientOffset) { return getCellRects.findIndex(function (getCellRect) {
var _a = getCellRect(), left = _a.left, top = _a.top, right = _a.right, bottom = _a.bottom;
var isOver = clientOffset

@@ -855,11 +847,9 @@ && clamp(clientOffset.x, left, right) === clientOffset.x

};
var autoScroll = function (clientOffset, layoutElement, layoutHeaderElement) {
var layout = layoutElement.current;
var layoutHeaderRect = layoutHeaderElement.current.getBoundingClientRect();
if ((clientOffset.y < layoutHeaderRect.height + layoutHeaderRect.top + SCROLL_OFFSET)
&& (clientOffset.y > layoutHeaderRect.height + layoutHeaderRect.top)) {
layout.scrollTop -= SCROLL_SPEED_PX;
var autoScroll = function (clientOffset, scrollingStrategy) {
if ((clientOffset.y < scrollingStrategy.topBoundary + SCROLL_OFFSET)
&& (clientOffset.y > scrollingStrategy.topBoundary)) {
scrollingStrategy.changeVerticalScroll(-SCROLL_SPEED_PX);
}
if (layout.clientHeight - SCROLL_OFFSET < clientOffset.y - layout.offsetTop) {
layout.scrollTop += SCROLL_SPEED_PX;
if (scrollingStrategy.bottomBoundary - SCROLL_OFFSET < clientOffset.y) {
scrollingStrategy.changeVerticalScroll(+SCROLL_SPEED_PX);
}

@@ -926,5 +916,5 @@ };

};
var calculateInsidePart = function (top, timeTableCells, timeTableIndex) {
var calculateInsidePart = function (top, timeTableCellsRects, timeTableIndex) {
if (timeTableIndex !== undefined && timeTableIndex !== -1) {
var cellRect = timeTableCells[timeTableIndex].getBoundingClientRect();
var cellRect = timeTableCellsRects[timeTableIndex]();
return top > cellRect.top + cellRect.height / 2 ? 1 : 0;

@@ -934,7 +924,8 @@ }

};
var calculateDraftAppointments = function (allDayIndex, draftAppointments, startViewDate, endViewDate, excludedDays, viewCellsData, allDayCells, targetType, cellDurationMinutes, timeTableCells) {
var calculateDraftAppointments = function (allDayIndex, draftAppointments, startViewDate, endViewDate, excludedDays, viewCellsData, getAllDayCellsElementRects, targetType, cellDurationMinutes, getTableCellElementRects) {
if (allDayIndex !== -1
|| (allDayCells.length && intervalDuration(draftAppointments[0].dataItem, HOURS) > 23)) {
|| (getAllDayCellsElementRects.getCellRects.length
&& intervalDuration(draftAppointments[0].dataItem, HOURS) > 23)) {
return {
allDayDraftAppointments: allDayRects(draftAppointments, startViewDate, endViewDate, excludedDays, viewCellsData, allDayCells),
allDayDraftAppointments: allDayRects(draftAppointments, startViewDate, endViewDate, excludedDays, viewCellsData, getAllDayCellsElementRects),
timeTableDraftAppointments: [],

@@ -946,3 +937,3 @@ };

allDayDraftAppointments: [],
timeTableDraftAppointments: verticalTimeTableRects(draftAppointments, startViewDate, endViewDate, excludedDays, viewCellsData, cellDurationMinutes, timeTableCells),
timeTableDraftAppointments: verticalTimeTableRects(draftAppointments, startViewDate, endViewDate, excludedDays, viewCellsData, cellDurationMinutes, getTableCellElementRects),
};

@@ -952,3 +943,3 @@ }

allDayDraftAppointments: [],
timeTableDraftAppointments: horizontalTimeTableRects(draftAppointments, startViewDate, endViewDate, viewCellsData, timeTableCells),
timeTableDraftAppointments: horizontalTimeTableRects(draftAppointments, startViewDate, endViewDate, viewCellsData, getTableCellElementRects),
};

@@ -959,3 +950,3 @@ };

export { AUTO_HEIGHT, CANCEL_COMMAND_BUTTON, CLOSE_COMMAND_BUTTON, COMMIT_COMMAND_BUTTON, DAY_LONG_MONTH_LONG_YEAR_OPTIONS, DAY_OPTIONS, DAY_SHORT_MONTH_LONG_YEAR_OPTIONS, DAY_SHORT_MONTH_OPTIONS, DAY_SHORT_MONTH_SHORT_YEAR_OPTIONS, DELETE_COMMAND_BUTTON, HORIZONTAL_TYPE, HOURS, HOUR_MINUTE_OPTIONS, MINUTES, MONTH_YEAR_OPTIONS, OPEN_COMMAND_BUTTON, POSITION_END, POSITION_START, RESIZE_BOTTOM, RESIZE_TOP, SCROLL_OFFSET, SCROLL_SPEED_PX, SECONDS, SHORT_MONTH_LONG_YEAR_OPTIONS, SHORT_MONTH_OPTIONS, SHORT_MONTH_SHORT_YEAR_OPTIONS, VERTICAL_TYPE, WEEK_DAY_OPTIONS, addAppointment, adjustAppointments, allDayCells, allDayPredicate, appointments, autoScroll, availableViewNames, calculateAllDayDateIntervals, calculateAppointmentTimeBoundaries, calculateDraftAppointments, calculateFirstDateOfWeek, calculateInsidePart, calculateMonthDateIntervals, calculateRectByDateIntervals, calculateWeekDateIntervals, callActionIfExists, cancelAddedAppointment, cancelChanges, cellData, cellIndex, cellType, changeAppointment, changeCurrentDate, changedAppointmentById, computed, dayBoundaryPredicate, dayScale, endViewDate, filterByViewBoundaries, findOverlappedAppointments, formatDateTimeGetter, getAllDayCellIndexByDate, getAppointmentStyle, getCellByDate, getHorizontalRectByDates, getMonthCellIndexByDate, getVerticalRectByDates, getViewType, intervalDuration, isAllDayCell, monthCellsData, reduceAppointmentByDayBounds, setAppointmentData, setAppointmentMeta, setCurrentViewName, sliceAppointmentByDay, sliceAppointmentByWeek, sliceAppointmentsByBoundaries, sortAppointments, startEditAppointment, startViewDate, stopEditAppointment, timeBoundariesByDrag, timeBoundariesByResize, timeScale, toPercentage, unwrapGroups, viewBoundText, viewCellsData, viewPredicate };
export { AUTO_HEIGHT, CANCEL_COMMAND_BUTTON, CLOSE_COMMAND_BUTTON, COMMIT_COMMAND_BUTTON, DAY_LONG_MONTH_LONG_YEAR_OPTIONS, DAY_OPTIONS, DAY_SHORT_MONTH_LONG_YEAR_OPTIONS, DAY_SHORT_MONTH_OPTIONS, DAY_SHORT_MONTH_SHORT_YEAR_OPTIONS, DELETE_COMMAND_BUTTON, HORIZONTAL_TYPE, HOURS, HOUR_MINUTE_OPTIONS, MINUTES, MONTH_YEAR_OPTIONS, OPEN_COMMAND_BUTTON, POSITION_END, POSITION_START, RESIZE_BOTTOM, RESIZE_TOP, SCROLL_OFFSET, SCROLL_SPEED_PX, SECONDS, SHORT_MONTH_LONG_YEAR_OPTIONS, SHORT_MONTH_OPTIONS, SHORT_MONTH_SHORT_YEAR_OPTIONS, VERTICAL_TYPE, WEEK_DAY_OPTIONS, addAppointment, adjustAppointments, allDayCells, allDayPredicate, allDayRects, appointments, autoScroll, availableViews, calculateAllDayDateIntervals, calculateAppointmentTimeBoundaries, calculateDraftAppointments, calculateFirstDateOfWeek, calculateInsidePart, calculateMonthDateIntervals, calculateRectByDateIntervals, calculateWeekDateIntervals, callActionIfExists, cancelAddedAppointment, cancelChanges, cellData, cellIndex, cellType, changeAppointment, changeCurrentDate, changedAppointmentById, computed, dayBoundaryPredicate, dayScale, endViewDate, filterByViewBoundaries, findOverlappedAppointments, formatDateTimeGetter, getAllDayCellIndexByDate, getAppointmentStyle, getCellByDate, getHorizontalRectByDates, getMonthCellIndexByDate, getVerticalRectByDates, getViewType, horizontalTimeTableRects, intervalDuration, isAllDayCell, monthCellsData, reduceAppointmentByDayBounds, setAppointmentData, setAppointmentMeta, setCurrentViewName, sliceAppointmentByDay, sliceAppointmentByWeek, sliceAppointmentsByBoundaries, sortAppointments, startEditAppointment, startViewDate, stopEditAppointment, timeBoundariesByDrag, timeBoundariesByResize, timeScale, toPercentage, unwrapGroups, verticalTimeTableRects, viewBoundText, viewCellsData, viewPredicate };
//# sourceMappingURL=dx-scheduler-core.es.js.map
/**
* Bundle of @devexpress/dx-scheduler-core
* Generated: 2019-06-14
* Version: 1.11.1
* Generated: 2019-07-08
* Version: 2.0.0
* License: https://js.devexpress.com/Licensing

@@ -264,6 +264,6 @@ */

var horizontalRectCalculator = function (appointment, _a) {
var rectByDates = _a.rectByDates, multiline = _a.multiline, _b = _a.rectByDatesMeta, cellElements = _b.cellElements, viewCellsData = _b.viewCellsData;
var rectByDates = _a.rectByDates, multiline = _a.multiline, _b = _a.rectByDatesMeta, cellElementsMeta = _b.cellElementsMeta, viewCellsData = _b.viewCellsData;
var _c = rectCalculatorBase(appointment, rectByDates, {
multiline: multiline,
cellElements: cellElements,
cellElementsMeta: cellElementsMeta,
viewCellsData: viewCellsData,

@@ -283,3 +283,3 @@ }), top = _c.top, left = _c.left, width = _c.width, height = _c.height, parentWidth = _c.parentWidth;

var verticalRectCalculator = function (appointment, _a) {
var rectByDates = _a.rectByDates, multiline = _a.multiline, _b = _a.rectByDatesMeta, viewCellsData = _b.viewCellsData, cellDuration = _b.cellDuration, cellElements = _b.cellElements, excludedDays = _b.excludedDays;
var rectByDates = _a.rectByDates, multiline = _a.multiline, _b = _a.rectByDatesMeta, viewCellsData = _b.viewCellsData, cellDuration = _b.cellDuration, cellElementsMeta = _b.cellElementsMeta, excludedDays = _b.excludedDays;
var _c = rectCalculatorBase(appointment, rectByDates, {

@@ -290,3 +290,3 @@ multiline: multiline,

excludedDays: excludedDays,
cellElements: cellElements,
cellElementsMeta: cellElementsMeta,
}), top = _c.top, left = _c.left, width = _c.width, height = _c.height, parentWidth = _c.parentWidth;

@@ -365,11 +365,11 @@ var widthInPx = width / appointment.reduceValue;

};
var availableViewNames = function (viewNames, viewName) {
if (!viewNames)
return [viewName];
if (viewNames.findIndex(function (view) { return viewName === view; }) === -1) {
var nextViewNames = viewNames.slice();
nextViewNames.push(viewName);
return nextViewNames;
var availableViews = function (views, viewName, viewDisplayName) {
if (!views)
return [{ name: viewName, displayName: viewDisplayName }];
if (views.findIndex(function (view) { return viewName === view.name; }) === -1) {
var nextViews = views.slice();
nextViews.push({ name: viewName, displayName: viewDisplayName });
return nextViews;
}
return viewNames;
return views;
};

@@ -412,27 +412,139 @@ var viewCellsData = function (currentDate, firstDayOfWeek, dayCount, excludedDays, startDayHour, endDayHour, cellDuration, currTime) {

var dateTimeFormatInstance = function (locale, formatOptions) { return new Intl.DateTimeFormat(locale, formatOptions); };
var sliceAppointmentByDay = function (appointment) {
var start = appointment.start, end = appointment.end, dataItem = appointment.dataItem;
if (start.isSame(end, 'day')) {
return [appointment];
}
return [
{ start: start, end: moment(start).endOf('day'), dataItem: dataItem },
{ start: moment(end).startOf('day'), end: end, dataItem: dataItem },
];
};
var dayBoundaryPredicate = function (appointment, leftBound, rightBound, excludedDays) {
if (excludedDays === void 0) { excludedDays = []; }
var dayStart = moment(leftBound);
var dayEnd = moment(rightBound);
var startDayTime = moment(appointment.start)
.hour(dayStart.hour())
.minutes(dayStart.minutes());
var endDayTime = moment(appointment.start)
.hour(dayEnd.hour())
.minutes(dayEnd.minutes());
if (appointment.end.isBefore(dayStart) || appointment.start.isAfter(dayEnd))
return false;
if (excludedDays.findIndex(function (day) { return day === moment(appointment.start).day(); }) !== -1)
return false;
return (appointment.end.isAfter(startDayTime)
&& appointment.start.isBefore(endDayTime));
};
var reduceAppointmentByDayBounds = function (appointment, leftBound, rightBound) {
var dayStart = moment(leftBound);
var dayEnd = moment(rightBound);
var startDayTime = moment(appointment.start)
.hour(dayStart.hour())
.minutes(dayStart.minutes())
.seconds(dayStart.seconds());
var endDayTime = moment(appointment.start)
.hour(dayEnd.hour())
.minutes(dayEnd.minutes())
.seconds(dayEnd.seconds());
return __assign({}, appointment, (appointment.start.isSameOrBefore(startDayTime) ? { start: startDayTime } : null), (appointment.end.isSameOrAfter(endDayTime) ? { end: endDayTime } : null));
};
var appointments = function (data) { return data.map(function (appointment) { return (__assign({ start: appointment.startDate, end: appointment.endDate }, appointment.allDay !== undefined && {
allDay: appointment.allDay,
}, appointment.rRule !== undefined && {
rRule: appointment.rRule,
}, appointment.exDate !== undefined && {
exDate: appointment.exDate,
}, { dataItem: appointment })); }); };
var formatDateTimeGetter = function (locale) {
var cache = new Map(); // any -> type
var formatter = function (nextDate, nextOptions) {
if (nextDate === undefined)
return '';
var date = new Date(nextDate);
var formatInstance = cache.get(nextOptions);
if (!formatInstance) {
formatInstance = dateTimeFormatInstance(locale, nextOptions);
cache.set(nextOptions, formatInstance);
}
return formatInstance.format(date);
var calculateWeekDateIntervals = function (appointments, leftBound, rightBound, excludedDays) { return appointments
.map(function (_a) {
var start = _a.start, end = _a.end, restArgs = __rest(_a, ["start", "end"]);
return (__assign({ start: moment(start), end: moment(end) }, restArgs));
})
.reduce(function (acc, appointment) {
return __spread(acc, filterByViewBoundaries(appointment, leftBound, rightBound, excludedDays, true));
}, [])
.reduce(function (acc, appointment) { return (__spread(acc, sliceAppointmentByDay(appointment))); }, [])
.filter(function (appointment) { return dayBoundaryPredicate(appointment, leftBound, rightBound, excludedDays); })
.map(function (appointment) { return reduceAppointmentByDayBounds(appointment, leftBound, rightBound); }); };
var CELL_GAP_PX = 10;
var CELL_BOUND_HORIZONTAL_OFFSET_PX = 1;
var CELL_BOUND_VERTICAL_OFFSET_PX = 4;
var getCellByDate = function (viewCellsData, date, takePrev) {
if (takePrev === void 0) { takePrev = false; }
var cellIndex = viewCellsData[0].findIndex(function (timeCell) { return moment(date)
.isSame(timeCell.startDate, 'date'); });
var rowIndex = viewCellsData.findIndex(function (timeCell) { return moment(date)
.isBetween(timeCell[cellIndex].startDate, timeCell[cellIndex].endDate, 'seconds', takePrev ? '(]' : '[)'); });
var totalCellIndex = (rowIndex * viewCellsData[0].length) + cellIndex;
return {
index: totalCellIndex,
startDate: viewCellsData[rowIndex][cellIndex].startDate,
};
return formatter;
};
var getCellRect = function (date, viewCellsData, cellDuration, cellElementsMeta, takePrev) {
var _a = getCellByDate(viewCellsData, date, takePrev), cellIndex = _a.index, cellStartDate = _a.startDate;
var _b = cellElementsMeta.getCellRects[cellIndex](), top = _b.top, left = _b.left, width = _b.width, cellHeight = _b.height;
var timeOffset = moment(date).diff(cellStartDate, 'minutes');
var topOffset = cellHeight * (timeOffset / cellDuration);
var parentRect = cellElementsMeta.parentRect();
return {
top: top,
left: left,
width: width,
topOffset: topOffset,
parentRect: parentRect,
};
};
var getVerticalRectByDates = function (startDate, endDate, _a) {
var viewCellsData = _a.viewCellsData, cellDuration = _a.cellDuration, cellElementsMeta = _a.cellElementsMeta;
var firstCellRect = getCellRect(startDate, viewCellsData, cellDuration, cellElementsMeta, false);
var lastCellRect = getCellRect(endDate, viewCellsData, cellDuration, cellElementsMeta, true);
var top = firstCellRect.top + firstCellRect.topOffset;
var height = (lastCellRect.top + lastCellRect.topOffset) - top;
return {
width: firstCellRect.width - CELL_GAP_PX - CELL_BOUND_HORIZONTAL_OFFSET_PX,
top: top - firstCellRect.parentRect.top + CELL_BOUND_HORIZONTAL_OFFSET_PX,
left: firstCellRect.left - firstCellRect.parentRect.left + CELL_BOUND_HORIZONTAL_OFFSET_PX,
parentWidth: firstCellRect.parentRect.width,
height: height - CELL_BOUND_VERTICAL_OFFSET_PX,
};
};
var allDayPredicate = function (appointment) { return (appointment.end.diff(appointment.start, 'hours') > 23
|| !!appointment.allDay); };
var getAllDayCellIndexByDate = function (viewCellsData, date, takePrev) {
var currentDate = moment(date);
var cellIndex = viewCellsData[0]
.findIndex(function (day) { return moment(day.startDate).day() === currentDate.day(); });
if (takePrev && currentDate.format() === currentDate.startOf('day').format()) {
cellIndex -= 1;
}
return cellIndex;
};
var sliceAppointmentsByBoundaries = function (appointment, left, right, excludedDays) {
if (excludedDays === void 0) { excludedDays = []; }
var startDate = appointment.start.clone();
var endDate = appointment.end.clone();
var nextStart = startDate.clone();
var nextEnd = endDate.clone();
if (startDate.isBefore(left)) {
nextStart = moment(left);
nextStart.startOf('day');
}
if (endDate.isAfter(right)) {
nextEnd = moment(right);
nextEnd.endOf('day');
}
if (excludedDays.findIndex(function (day) { return day === startDate.day(); }) !== -1) {
while (excludedDays.findIndex(function (day) { return day === nextStart.day(); }) !== -1
&& nextStart.isSameOrBefore(endDate, 'day')) {
nextStart.add(1, 'days').startOf('day');
}
}
if (excludedDays.findIndex(function (day) { return day === endDate.day(); }) !== -1) {
while (excludedDays.findIndex(function (day) { return day === nextEnd.day(); }) !== -1
&& nextStart.isSameOrAfter(startDate, 'day')) {
nextEnd.add(-1, 'days').endOf('day');
}
}
return [__assign({}, appointment, { start: nextStart, end: nextEnd })];
};
var sliceAppointmentByWeek = function (timeBounds, appointment, step) {

@@ -481,2 +593,33 @@ var left = timeBounds.left, right = timeBounds.right;

var TOP_CELL_OFFSET = 0.32;
var CELL_BOUND_OFFSET_PX = 1;
var getCellRect$1 = function (date, viewCellsData, cellElementsMeta, takePrev, multiline) {
var cellIndex = multiline
? getMonthCellIndexByDate(viewCellsData, date, takePrev)
: getAllDayCellIndexByDate(viewCellsData, date, takePrev);
var _a = cellElementsMeta.getCellRects[cellIndex](), top = _a.top, left = _a.left, width = _a.width, height = _a.height;
var parentRect = cellElementsMeta.parentRect();
return {
top: top,
left: left,
width: width,
height: height,
parentRect: parentRect,
};
};
var getHorizontalRectByDates = function (startDate, endDate, _a) {
var multiline = _a.multiline, viewCellsData = _a.viewCellsData, cellElementsMeta = _a.cellElementsMeta;
var firstCellRect = getCellRect$1(startDate, viewCellsData, cellElementsMeta, false, multiline);
var lastCellRect = getCellRect$1(endDate, viewCellsData, cellElementsMeta, true, multiline);
var top = firstCellRect.top + (firstCellRect.height * TOP_CELL_OFFSET);
var height = firstCellRect.height - (firstCellRect.height * TOP_CELL_OFFSET);
return {
top: top - firstCellRect.parentRect.top,
left: (firstCellRect.left - firstCellRect.parentRect.left) + CELL_BOUND_OFFSET_PX,
width: ((lastCellRect.left - firstCellRect.left) + firstCellRect.width) - CELL_BOUND_OFFSET_PX,
height: height,
parentWidth: firstCellRect.parentRect.width,
};
};
var DAY_COUNT = 7;

@@ -527,44 +670,3 @@ var MONTH_LENGTH = 31;

var sliceAppointmentByDay = function (appointment) {
var start = appointment.start, end = appointment.end, dataItem = appointment.dataItem;
if (start.isSame(end, 'day')) {
return [appointment];
}
return [
{ start: start, end: moment(start).endOf('day'), dataItem: dataItem },
{ start: moment(end).startOf('day'), end: end, dataItem: dataItem },
];
};
var dayBoundaryPredicate = function (appointment, leftBound, rightBound, excludedDays) {
if (excludedDays === void 0) { excludedDays = []; }
var dayStart = moment(leftBound);
var dayEnd = moment(rightBound);
var startDayTime = moment(appointment.start)
.hour(dayStart.hour())
.minutes(dayStart.minutes());
var endDayTime = moment(appointment.start)
.hour(dayEnd.hour())
.minutes(dayEnd.minutes());
if (appointment.end.isBefore(dayStart) || appointment.start.isAfter(dayEnd))
return false;
if (excludedDays.findIndex(function (day) { return day === moment(appointment.start).day(); }) !== -1)
return false;
return (appointment.end.isAfter(startDayTime)
&& appointment.start.isBefore(endDayTime));
};
var reduceAppointmentByDayBounds = function (appointment, leftBound, rightBound) {
var dayStart = moment(leftBound);
var dayEnd = moment(rightBound);
var startDayTime = moment(appointment.start)
.hour(dayStart.hour())
.minutes(dayStart.minutes())
.seconds(dayStart.seconds());
var endDayTime = moment(appointment.start)
.hour(dayEnd.hour())
.minutes(dayEnd.minutes())
.seconds(dayEnd.seconds());
return __assign({}, appointment, (appointment.start.isSameOrBefore(startDayTime) ? { start: startDayTime } : null), (appointment.end.isSameOrAfter(endDayTime) ? { end: endDayTime } : null));
};
var calculateWeekDateIntervals = function (appointments, leftBound, rightBound, excludedDays) { return appointments
var calculateAllDayDateIntervals = function (appointments, leftBound, rightBound, excludedDays) { return appointments
.map(function (_a) {

@@ -575,8 +677,71 @@ var start = _a.start, end = _a.end, restArgs = __rest(_a, ["start", "end"]);

.reduce(function (acc, appointment) {
return __spread(acc, filterByViewBoundaries(appointment, leftBound, rightBound, excludedDays, true));
return __spread(acc, filterByViewBoundaries(appointment, leftBound, rightBound, excludedDays, false));
}, [])
.reduce(function (acc, appointment) { return (__spread(acc, sliceAppointmentByDay(appointment))); }, [])
.filter(function (appointment) { return dayBoundaryPredicate(appointment, leftBound, rightBound, excludedDays); })
.map(function (appointment) { return reduceAppointmentByDayBounds(appointment, leftBound, rightBound); }); };
.filter(function (appointment) { return allDayPredicate(appointment); })
.reduce(function (acc, appointment) { return (__spread(acc, sliceAppointmentsByBoundaries(appointment, leftBound, rightBound, excludedDays))); }, []); };
var allDayRects = function (appointments, startViewDate, endViewDate, excludedDays, viewCellsData, cellElementsMeta) {
var intervals = calculateAllDayDateIntervals(appointments, startViewDate, endViewDate, excludedDays);
return calculateRectByDateIntervals({
growDirection: HORIZONTAL_TYPE,
multiline: false,
}, intervals, getHorizontalRectByDates, {
startViewDate: startViewDate,
endViewDate: endViewDate,
viewCellsData: viewCellsData,
cellElementsMeta: cellElementsMeta,
excludedDays: excludedDays,
});
};
var verticalTimeTableRects = function (appointments, startViewDate, endViewDate, excludedDays, viewCellsData, cellDuration, cellElementsMeta) {
var intervals = calculateWeekDateIntervals(appointments, startViewDate, endViewDate, excludedDays);
return calculateRectByDateIntervals({
growDirection: VERTICAL_TYPE,
multiline: false,
}, intervals, getVerticalRectByDates, {
startViewDate: startViewDate,
endViewDate: endViewDate,
viewCellsData: viewCellsData,
cellDuration: cellDuration,
cellElementsMeta: cellElementsMeta,
});
};
var horizontalTimeTableRects = function (appointments, startViewDate, endViewDate, viewCellsData, cellElementsMeta) {
var intervals = calculateMonthDateIntervals(appointments, startViewDate, endViewDate);
return calculateRectByDateIntervals({
growDirection: HORIZONTAL_TYPE,
multiline: true,
}, intervals, getHorizontalRectByDates, {
startViewDate: startViewDate,
endViewDate: endViewDate,
viewCellsData: viewCellsData,
cellElementsMeta: cellElementsMeta,
});
};
var dateTimeFormatInstance = function (locale, formatOptions) { return new Intl.DateTimeFormat(locale, formatOptions); };
var appointments = function (data) { return data.map(function (appointment) { return (__assign({ start: appointment.startDate, end: appointment.endDate }, appointment.allDay !== undefined && {
allDay: appointment.allDay,
}, appointment.rRule !== undefined && {
rRule: appointment.rRule,
}, appointment.exDate !== undefined && {
exDate: appointment.exDate,
}, { dataItem: appointment })); }); };
var formatDateTimeGetter = function (locale) {
var cache = new Map(); // any -> type
var formatter = function (nextDate, nextOptions) {
if (nextDate === undefined)
return '';
var date = new Date(nextDate);
var formatInstance = cache.get(nextOptions);
if (!formatInstance) {
formatInstance = dateTimeFormatInstance(locale, nextOptions);
cache.set(nextOptions, formatInstance);
}
return formatInstance.format(date);
};
return formatter;
};
var changeCurrentDate = function (currentDate, _a) {

@@ -643,53 +808,2 @@ var nextDate = _a.nextDate, step = _a.step, amount = _a.amount, direction = _a.direction;

var allDayPredicate = function (appointment) { return (appointment.end.diff(appointment.start, 'hours') > 23
|| !!appointment.allDay); };
var getAllDayCellIndexByDate = function (viewCellsData, date, takePrev) {
var currentDate = moment(date);
var cellIndex = viewCellsData[0]
.findIndex(function (day) { return moment(day.startDate).day() === currentDate.day(); });
if (takePrev && currentDate.format() === currentDate.startOf('day').format()) {
cellIndex -= 1;
}
return cellIndex;
};
var sliceAppointmentsByBoundaries = function (appointment, left, right, excludedDays) {
if (excludedDays === void 0) { excludedDays = []; }
var startDate = appointment.start.clone();
var endDate = appointment.end.clone();
var nextStart = startDate.clone();
var nextEnd = endDate.clone();
if (startDate.isBefore(left)) {
nextStart = moment(left);
nextStart.startOf('day');
}
if (endDate.isAfter(right)) {
nextEnd = moment(right);
nextEnd.endOf('day');
}
if (excludedDays.findIndex(function (day) { return day === startDate.day(); }) !== -1) {
while (excludedDays.findIndex(function (day) { return day === nextStart.day(); }) !== -1
&& nextStart.isSameOrBefore(endDate, 'day')) {
nextStart.add(1, 'days').startOf('day');
}
}
if (excludedDays.findIndex(function (day) { return day === endDate.day(); }) !== -1) {
while (excludedDays.findIndex(function (day) { return day === nextEnd.day(); }) !== -1
&& nextStart.isSameOrAfter(startDate, 'day')) {
nextEnd.add(-1, 'days').endOf('day');
}
}
return [__assign({}, appointment, { start: nextStart, end: nextEnd })];
};
var calculateAllDayDateIntervals = function (appointments, leftBound, rightBound, excludedDays) { return appointments
.map(function (_a) {
var start = _a.start, end = _a.end, restArgs = __rest(_a, ["start", "end"]);
return (__assign({ start: moment(start), end: moment(end) }, restArgs));
})
.reduce(function (acc, appointment) {
return __spread(acc, filterByViewBoundaries(appointment, leftBound, rightBound, excludedDays, false));
}, [])
.filter(function (appointment) { return allDayPredicate(appointment); })
.reduce(function (acc, appointment) { return (__spread(acc, sliceAppointmentsByBoundaries(appointment, leftBound, rightBound, excludedDays))); }, []); };
var addAppointment = function (addedAppointmentData, _a) {

@@ -716,124 +830,2 @@ var appointmentData = (_a === void 0 ? { appointmentData: {} } : _a).appointmentData;

var TOP_CELL_OFFSET = 0.32;
var CELL_BOUND_OFFSET_PX = 1;
var getCellRect = function (date, viewCellsData, cellElements, takePrev, multiline) {
var cellIndex = multiline
? getMonthCellIndexByDate(viewCellsData, date, takePrev)
: getAllDayCellIndexByDate(viewCellsData, date, takePrev);
var cellElement = cellElements[cellIndex];
var _a = cellElement.getBoundingClientRect(), top = _a.top, left = _a.left, width = _a.width, height = _a.height;
var parentRect = { left: 0, top: 0, width: 0 };
if (cellElement.offsetParent) {
parentRect = cellElement.offsetParent.getBoundingClientRect();
}
return {
top: top,
left: left,
width: width,
height: height,
parentRect: parentRect,
};
};
var getHorizontalRectByDates = function (startDate, endDate, _a) {
var multiline = _a.multiline, viewCellsData = _a.viewCellsData, cellElements = _a.cellElements;
var firstCellRect = getCellRect(startDate, viewCellsData, cellElements, false, multiline);
var lastCellRect = getCellRect(endDate, viewCellsData, cellElements, true, multiline);
var top = firstCellRect.top + (firstCellRect.height * TOP_CELL_OFFSET);
var height = firstCellRect.height - (firstCellRect.height * TOP_CELL_OFFSET);
return {
top: top - firstCellRect.parentRect.top,
left: (firstCellRect.left - firstCellRect.parentRect.left) + CELL_BOUND_OFFSET_PX,
width: ((lastCellRect.left - firstCellRect.left) + firstCellRect.width) - CELL_BOUND_OFFSET_PX,
height: height,
parentWidth: firstCellRect.parentRect.width,
};
};
var CELL_GAP_PX = 10;
var CELL_BOUND_HORIZONTAL_OFFSET_PX = 1;
var CELL_BOUND_VERTICAL_OFFSET_PX = 4;
var getCellByDate = function (viewCellsData, date, takePrev) {
if (takePrev === void 0) { takePrev = false; }
var cellIndex = viewCellsData[0].findIndex(function (timeCell) { return moment(date)
.isSame(timeCell.startDate, 'date'); });
var rowIndex = viewCellsData.findIndex(function (timeCell) { return moment(date)
.isBetween(timeCell[cellIndex].startDate, timeCell[cellIndex].endDate, 'seconds', takePrev ? '(]' : '[)'); });
var totalCellIndex = (rowIndex * viewCellsData[0].length) + cellIndex;
return {
index: totalCellIndex,
startDate: viewCellsData[rowIndex][cellIndex].startDate,
};
};
var getCellRect$1 = function (date, viewCellsData, cellDuration, cellElements, takePrev) {
var _a = getCellByDate(viewCellsData, date, takePrev), cellIndex = _a.index, cellStartDate = _a.startDate;
var cellElement = cellElements[cellIndex];
var _b = cellElement.getBoundingClientRect(), top = _b.top, left = _b.left, width = _b.width, cellHeight = _b.height;
var timeOffset = moment(date).diff(cellStartDate, 'minutes');
var topOffset = cellHeight * (timeOffset / cellDuration);
var parentRect = { left: 0, top: 0, width: 0 };
if (cellElement.offsetParent) {
parentRect = cellElement.offsetParent.getBoundingClientRect();
}
return {
top: top,
left: left,
width: width,
topOffset: topOffset,
parentRect: parentRect,
};
};
var getVerticalRectByDates = function (startDate, endDate, _a) {
var viewCellsData = _a.viewCellsData, cellDuration = _a.cellDuration, cellElements = _a.cellElements;
var firstCellRect = getCellRect$1(startDate, viewCellsData, cellDuration, cellElements, false);
var lastCellRect = getCellRect$1(endDate, viewCellsData, cellDuration, cellElements, true);
var top = firstCellRect.top + firstCellRect.topOffset;
var height = (lastCellRect.top + lastCellRect.topOffset) - top;
return {
width: firstCellRect.width - CELL_GAP_PX - CELL_BOUND_HORIZONTAL_OFFSET_PX,
top: top - firstCellRect.parentRect.top + CELL_BOUND_HORIZONTAL_OFFSET_PX,
left: firstCellRect.left - firstCellRect.parentRect.left + CELL_BOUND_HORIZONTAL_OFFSET_PX,
parentWidth: firstCellRect.parentRect.width,
height: height - CELL_BOUND_VERTICAL_OFFSET_PX,
};
};
var allDayRects = function (draftAppointments, startViewDate, endViewDate, excludedDays, viewCellsData, cellElements) {
var intervals = calculateAllDayDateIntervals(draftAppointments, startViewDate, endViewDate, excludedDays);
return calculateRectByDateIntervals({
growDirection: HORIZONTAL_TYPE,
multiline: false,
}, intervals, getHorizontalRectByDates, {
startViewDate: startViewDate,
endViewDate: endViewDate,
viewCellsData: viewCellsData,
cellElements: cellElements,
excludedDays: excludedDays,
});
};
var verticalTimeTableRects = function (draftAppointments, startViewDate, endViewDate, excludedDays, viewCellsData, cellDuration, cellElements) {
var intervals = calculateWeekDateIntervals(draftAppointments, startViewDate, endViewDate, excludedDays);
return calculateRectByDateIntervals({
growDirection: VERTICAL_TYPE,
multiline: false,
}, intervals, getVerticalRectByDates, {
startViewDate: startViewDate,
endViewDate: endViewDate,
viewCellsData: viewCellsData,
cellDuration: cellDuration,
cellElements: cellElements,
});
};
var horizontalTimeTableRects = function (draftAppointments, startViewDate, endViewDate, viewCellsData, cellElements) {
var intervals = calculateMonthDateIntervals(draftAppointments, startViewDate, endViewDate);
return calculateRectByDateIntervals({
growDirection: HORIZONTAL_TYPE,
multiline: true,
}, intervals, getHorizontalRectByDates, {
startViewDate: startViewDate,
endViewDate: endViewDate,
viewCellsData: viewCellsData,
cellElements: cellElements,
});
};
var clamp = function (value, min, max) { return Math.max(Math.min(value, max), min); };

@@ -845,4 +837,4 @@ var calculateInsideOffset = function (targetType, insidePart, cellDurationMinutes) { return targetType === VERTICAL_TYPE

var intervalDuration = function (data, type) { return moment(data.endDate).diff(data.startDate, type); };
var cellIndex = function (timeTableCells, clientOffset) { return timeTableCells.findIndex(function (timeTableCell) {
var _a = timeTableCell.getBoundingClientRect(), left = _a.left, top = _a.top, right = _a.right, bottom = _a.bottom;
var cellIndex = function (getCellRects, clientOffset) { return getCellRects.findIndex(function (getCellRect) {
var _a = getCellRect(), left = _a.left, top = _a.top, right = _a.right, bottom = _a.bottom;
var isOver = clientOffset

@@ -862,11 +854,9 @@ && clamp(clientOffset.x, left, right) === clientOffset.x

};
var autoScroll = function (clientOffset, layoutElement, layoutHeaderElement) {
var layout = layoutElement.current;
var layoutHeaderRect = layoutHeaderElement.current.getBoundingClientRect();
if ((clientOffset.y < layoutHeaderRect.height + layoutHeaderRect.top + SCROLL_OFFSET)
&& (clientOffset.y > layoutHeaderRect.height + layoutHeaderRect.top)) {
layout.scrollTop -= SCROLL_SPEED_PX;
var autoScroll = function (clientOffset, scrollingStrategy) {
if ((clientOffset.y < scrollingStrategy.topBoundary + SCROLL_OFFSET)
&& (clientOffset.y > scrollingStrategy.topBoundary)) {
scrollingStrategy.changeVerticalScroll(-SCROLL_SPEED_PX);
}
if (layout.clientHeight - SCROLL_OFFSET < clientOffset.y - layout.offsetTop) {
layout.scrollTop += SCROLL_SPEED_PX;
if (scrollingStrategy.bottomBoundary - SCROLL_OFFSET < clientOffset.y) {
scrollingStrategy.changeVerticalScroll(+SCROLL_SPEED_PX);
}

@@ -933,5 +923,5 @@ };

};
var calculateInsidePart = function (top, timeTableCells, timeTableIndex) {
var calculateInsidePart = function (top, timeTableCellsRects, timeTableIndex) {
if (timeTableIndex !== undefined && timeTableIndex !== -1) {
var cellRect = timeTableCells[timeTableIndex].getBoundingClientRect();
var cellRect = timeTableCellsRects[timeTableIndex]();
return top > cellRect.top + cellRect.height / 2 ? 1 : 0;

@@ -941,7 +931,8 @@ }

};
var calculateDraftAppointments = function (allDayIndex, draftAppointments, startViewDate, endViewDate, excludedDays, viewCellsData, allDayCells, targetType, cellDurationMinutes, timeTableCells) {
var calculateDraftAppointments = function (allDayIndex, draftAppointments, startViewDate, endViewDate, excludedDays, viewCellsData, getAllDayCellsElementRects, targetType, cellDurationMinutes, getTableCellElementRects) {
if (allDayIndex !== -1
|| (allDayCells.length && intervalDuration(draftAppointments[0].dataItem, HOURS) > 23)) {
|| (getAllDayCellsElementRects.getCellRects.length
&& intervalDuration(draftAppointments[0].dataItem, HOURS) > 23)) {
return {
allDayDraftAppointments: allDayRects(draftAppointments, startViewDate, endViewDate, excludedDays, viewCellsData, allDayCells),
allDayDraftAppointments: allDayRects(draftAppointments, startViewDate, endViewDate, excludedDays, viewCellsData, getAllDayCellsElementRects),
timeTableDraftAppointments: [],

@@ -953,3 +944,3 @@ };

allDayDraftAppointments: [],
timeTableDraftAppointments: verticalTimeTableRects(draftAppointments, startViewDate, endViewDate, excludedDays, viewCellsData, cellDurationMinutes, timeTableCells),
timeTableDraftAppointments: verticalTimeTableRects(draftAppointments, startViewDate, endViewDate, excludedDays, viewCellsData, cellDurationMinutes, getTableCellElementRects),
};

@@ -959,3 +950,3 @@ }

allDayDraftAppointments: [],
timeTableDraftAppointments: horizontalTimeTableRects(draftAppointments, startViewDate, endViewDate, viewCellsData, timeTableCells),
timeTableDraftAppointments: horizontalTimeTableRects(draftAppointments, startViewDate, endViewDate, viewCellsData, getTableCellElementRects),
};

@@ -998,5 +989,6 @@ };

exports.allDayPredicate = allDayPredicate;
exports.allDayRects = allDayRects;
exports.appointments = appointments;
exports.autoScroll = autoScroll;
exports.availableViewNames = availableViewNames;
exports.availableViews = availableViews;
exports.calculateAllDayDateIntervals = calculateAllDayDateIntervals;

@@ -1033,2 +1025,3 @@ exports.calculateAppointmentTimeBoundaries = calculateAppointmentTimeBoundaries;

exports.getViewType = getViewType;
exports.horizontalTimeTableRects = horizontalTimeTableRects;
exports.intervalDuration = intervalDuration;

@@ -1053,2 +1046,3 @@ exports.isAllDayCell = isAllDayCell;

exports.unwrapGroups = unwrapGroups;
exports.verticalTimeTableRects = verticalTimeTableRects;
exports.viewBoundText = viewBoundText;

@@ -1055,0 +1049,0 @@ exports.viewCellsData = viewCellsData;

{
"name": "@devexpress/dx-scheduler-core",
"version": "1.11.1",
"version": "2.0.0",
"description": "Core library for the DevExtreme Reactive Scheduler component",

@@ -44,3 +44,3 @@ "author": {

"@babel/preset-env": "^7.4.5",
"@devexpress/dx-core": "1.11.1",
"@devexpress/dx-core": "2.0.0",
"babel-core": "^7.0.0-bridge.0",

@@ -63,3 +63,3 @@ "babel-jest": "^24.8.0",

"peerDependencies": {
"@devexpress/dx-core": "1.11.1"
"@devexpress/dx-core": "2.0.0"
},

@@ -70,3 +70,3 @@ "dependencies": {

},
"gitHead": "1e024a4be45e7b7141404f5a2fbf7b2f9c1d7afa"
"gitHead": "d7aa247ebebd08f5d99aebf60d0c91d7d3fffd18"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc