@devexpress/dx-scheduler-core
Advanced tools
Comparing version 1.11.0-alpha.1 to 1.11.0-beta.1
/** | ||
* Bundle of @devexpress/dx-scheduler-core | ||
* Generated: 2019-03-13 | ||
* Version: 1.11.0-alpha.1 | ||
* Generated: 2019-04-24 | ||
* Version: 1.11.0-beta.1 | ||
* License: https://js.devexpress.com/Licensing | ||
@@ -9,2 +9,3 @@ */ | ||
import moment from 'moment'; | ||
import { RRule, RRuleSet, rrulestr } from 'rrule'; | ||
@@ -75,2 +76,8 @@ /*! ***************************************************************************** | ||
var SECONDS = 'seconds'; | ||
var MINUTES = 'minutes'; | ||
var HOURS = 'hours'; | ||
var RESIZE_TOP = 'resize-start'; | ||
var RESIZE_BOTTOM = 'resize-end'; | ||
var POSITION_START = 'start'; | ||
var POSITION_END = 'end'; | ||
@@ -218,2 +225,4 @@ var computed = function (getters, viewName, baseComputed, defaultValue) { | ||
reduceValue: reduceValue, | ||
fromPrev: moment(appointment.start).diff(appointment.dataItem.startDate, 'minutes') > 1, | ||
toNext: moment(appointment.dataItem.endDate).diff(appointment.end, 'minutes') > 1, | ||
}); }))); | ||
@@ -246,2 +255,4 @@ return acc; | ||
dataItem: appointment.dataItem, | ||
fromPrev: appointment.fromPrev, | ||
toNext: appointment.toNext, | ||
type: HORIZONTAL_TYPE, | ||
@@ -266,2 +277,4 @@ }; | ||
dataItem: appointment.dataItem, | ||
fromPrev: appointment.fromPrev, | ||
toNext: appointment.toNext, | ||
type: VERTICAL_TYPE, | ||
@@ -280,2 +293,21 @@ }; | ||
}; | ||
var filterByViewBoundaries = function (appointment, leftBound, rightBound, excludedDays, keepAllDay) { | ||
if (!appointment.rRule) { | ||
return viewPredicate(appointment, leftBound, rightBound, excludedDays, keepAllDay) | ||
? [appointment] | ||
: []; | ||
} | ||
var options = __assign({}, RRule.parseString(appointment.rRule), { dtstart: moment(appointment.start).toDate() }); | ||
var rruleSet = new RRuleSet(); | ||
if (appointment.exDate) { | ||
rruleSet = rrulestr("EXDATE:" + appointment.exDate, { forceset: true }); | ||
} | ||
rruleSet.rrule(new RRule(options)); | ||
var datesInBoundaries = rruleSet.between(leftBound, rightBound); | ||
if (datesInBoundaries.length === 0) | ||
return []; | ||
var appointmentDuration = moment(appointment.end) | ||
.diff(appointment.start, 'minutes'); | ||
return datesInBoundaries.map(function (startDate, index) { return (__assign({}, appointment, { dataItem: __assign({}, appointment.dataItem, { startDate: moment(startDate).toDate(), endDate: moment(startDate).add(appointmentDuration, 'minutes').toDate() }), start: moment(startDate), end: moment(startDate).add(appointmentDuration, 'minutes') })); }); | ||
}; | ||
@@ -360,2 +392,6 @@ var subtractSecond = function (date) { return moment(date).subtract(1, 'second').toDate(); }; | ||
allDay: appointment.allDay, | ||
}, appointment.rRule !== undefined && { | ||
rRule: appointment.rRule, | ||
}, appointment.exDate !== undefined && { | ||
exDate: appointment.exDate, | ||
}, { dataItem: appointment })); }); }; | ||
@@ -446,3 +482,5 @@ | ||
}) | ||
.filter(function (appointment) { return viewPredicate(appointment, leftBound, rightBound); }) | ||
.reduce(function (acc, appointment) { | ||
return __spread(acc, filterByViewBoundaries(appointment, leftBound, rightBound, [], false)); | ||
}, []) | ||
.reduce(function (acc, appointment) { return (__spread(acc, sliceAppointmentByWeek({ left: moment(leftBound), right: moment(rightBound) }, appointment, DAY_COUNT))); }, []); }; | ||
@@ -496,3 +534,5 @@ | ||
}) | ||
.filter(function (appointment) { return viewPredicate(appointment, leftBound, rightBound, excludedDays, true); }) | ||
.reduce(function (acc, appointment) { | ||
return __spread(acc, filterByViewBoundaries(appointment, leftBound, rightBound, excludedDays, true)); | ||
}, []) | ||
.reduce(function (acc, appointment) { return (__spread(acc, sliceAppointmentByDay(appointment))); }, []) | ||
@@ -608,4 +648,6 @@ .filter(function (appointment) { return dayBoundaryPredicate(appointment, leftBound, rightBound, excludedDays); }) | ||
}) | ||
.filter(function (appointment) { return (viewPredicate(appointment, leftBound, rightBound, excludedDays, false) | ||
&& allDayPredicate(appointment)); }) | ||
.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))); }, []); }; | ||
@@ -717,22 +759,2 @@ | ||
var clamp = function (value, min, max) { return Math.max(Math.min(value, max), min); }; | ||
var cellType = function (data) { return moment(data.startDate) | ||
.isSame(data.endDate, 'day') ? VERTICAL_TYPE : HORIZONTAL_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 isOver = clientOffset | ||
&& clamp(clientOffset.x, left, right) === clientOffset.x | ||
&& clamp(clientOffset.y, top, bottom) === clientOffset.y; | ||
return isOver; | ||
}); }; | ||
var cellData = function (timeTableIndex, allDayIndex, viewCellsData) { | ||
if (allDayIndex !== -1) { | ||
var allDayCellsData = allDayCells(viewCellsData); | ||
return allDayCellsData[allDayIndex]; | ||
} | ||
var firstIndex = Math.floor(timeTableIndex / viewCellsData[0].length); | ||
var secondIndex = timeTableIndex % viewCellsData[0].length; | ||
return viewCellsData[firstIndex][secondIndex]; | ||
}; | ||
var allDayRects = function (draftAppointments, startViewDate, endViewDate, excludedDays, viewCellsData, cellElements) { | ||
@@ -764,3 +786,3 @@ var intervals = calculateAllDayDateIntervals(draftAppointments, startViewDate, endViewDate, excludedDays); | ||
}; | ||
var horizontalTimeTableRects = function (draftAppointments, startViewDate, endViewDate, excludedDays, viewCellsData, cellElements) { | ||
var horizontalTimeTableRects = function (draftAppointments, startViewDate, endViewDate, viewCellsData, cellElements) { | ||
var intervals = calculateMonthDateIntervals(draftAppointments, startViewDate, endViewDate); | ||
@@ -778,3 +800,122 @@ return calculateRectByDateIntervals({ | ||
export { dayScale, timeScale, availableViewNames, viewCellsData, allDayCells, startViewDate, endViewDate, getViewType, appointments, monthCellsData, calculateMonthDateIntervals, sliceAppointmentByWeek, getMonthCellIndexByDate, calculateWeekDateIntervals, sliceAppointmentByDay, dayBoundaryPredicate, reduceAppointmentByDayBounds, changeCurrentDate, setCurrentViewName, viewBoundText, setAppointmentMeta, OPEN_COMMAND_BUTTON, CLOSE_COMMAND_BUTTON, DELETE_COMMAND_BUTTON, CANCEL_COMMAND_BUTTON, COMMIT_COMMAND_BUTTON, setAppointmentData, callActionIfExists, isAllDayCell, calculateAllDayDateIntervals, allDayPredicate, getAllDayCellIndexByDate, sliceAppointmentsByBoundaries, addAppointment, cancelAddedAppointment, startEditAppointment, stopEditAppointment, changeAppointment, cancelChanges, changedAppointmentById, getHorizontalRectByDates, getCellByDate, getVerticalRectByDates, cellType, intervalDuration, cellIndex, cellData, allDayRects, verticalTimeTableRects, horizontalTimeTableRects, VERTICAL_TYPE, HORIZONTAL_TYPE, SCROLL_OFFSET, SCROLL_SPEED_PX, SECONDS, computed, toPercentage, viewPredicate, sortAppointments, findOverlappedAppointments, adjustAppointments, calculateFirstDateOfWeek, unwrapGroups, getAppointmentStyle, calculateRectByDateIntervals }; | ||
var clamp = function (value, min, max) { return Math.max(Math.min(value, max), min); }; | ||
var calculateInsideOffset = function (targetType, insidePart, cellDurationMinutes) { return targetType === VERTICAL_TYPE | ||
? insidePart * cellDurationMinutes * 60 / 2 : 0; }; | ||
var cellType = function (data) { return moment(data.startDate) | ||
.isSame(data.endDate, 'day') ? VERTICAL_TYPE : HORIZONTAL_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 isOver = clientOffset | ||
&& clamp(clientOffset.x, left, right) === clientOffset.x | ||
&& clamp(clientOffset.y, top, bottom) === clientOffset.y; | ||
return isOver; | ||
}); }; | ||
var cellData = function (timeTableIndex, allDayIndex, viewCellsData) { | ||
if (allDayIndex !== -1) { | ||
var allDayCellsData = allDayCells(viewCellsData); | ||
return allDayCellsData[allDayIndex]; | ||
} | ||
var firstIndex = Math.floor(timeTableIndex / viewCellsData[0].length); | ||
var secondIndex = timeTableIndex % viewCellsData[0].length; | ||
return viewCellsData[firstIndex][secondIndex]; | ||
}; | ||
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; | ||
} | ||
if (layout.clientHeight - SCROLL_OFFSET < clientOffset.y - layout.offsetTop) { | ||
layout.scrollTop += SCROLL_SPEED_PX; | ||
} | ||
}; | ||
var timeBoundariesByResize = function (payload, targetData, targetType, cellDurationMinutes, insidePart) { | ||
if (targetType !== payload.appointmentType) { | ||
return { appointmentStartTime: undefined, appointmentEndTime: undefined }; | ||
} | ||
var appointmentStartTime; | ||
var appointmentEndTime; | ||
var sourceType = payload.type; | ||
if (sourceType === RESIZE_TOP) { | ||
var insideTopOffset = calculateInsideOffset(targetType, insidePart, cellDurationMinutes); | ||
appointmentStartTime = moment(targetData.startDate) | ||
.add(insideTopOffset, SECONDS).toDate(); | ||
appointmentEndTime = new Date(payload.endDate); | ||
} | ||
if (sourceType === RESIZE_BOTTOM) { | ||
var insideBottomOffset = insidePart === 0 && targetType === VERTICAL_TYPE | ||
? cellDurationMinutes * 60 / 2 : 0; | ||
appointmentEndTime = moment(targetData.endDate) | ||
.add(-insideBottomOffset, SECONDS).toDate(); | ||
appointmentStartTime = new Date(payload.startDate); | ||
} | ||
// keep origin appointment duration if coordinates are wrong | ||
if (moment(appointmentEndTime).diff(appointmentStartTime, MINUTES) < 1) { | ||
appointmentStartTime = new Date(payload.startDate); | ||
appointmentEndTime = new Date(payload.endDate); | ||
} | ||
return { appointmentStartTime: appointmentStartTime, appointmentEndTime: appointmentEndTime }; | ||
}; | ||
var timeBoundariesByDrag = function (payload, targetData, targetType, cellDurationMinutes, insidePart, offsetTimeTopBase) { | ||
var offsetTimeTop; | ||
var appointmentStartTime; | ||
var appointmentEndTime; | ||
var insideOffset = calculateInsideOffset(targetType, insidePart, cellDurationMinutes); | ||
var start = moment(targetData.startDate).add(insideOffset, SECONDS); | ||
if (offsetTimeTopBase === null) { | ||
offsetTimeTop = moment(targetData.startDate) | ||
.diff(payload.startDate, SECONDS) + insideOffset; | ||
} | ||
else { | ||
offsetTimeTop = offsetTimeTopBase; | ||
} | ||
if (payload.type === targetType) { | ||
var appointmentDurationSeconds = intervalDuration(payload, SECONDS); | ||
appointmentStartTime = moment(start).add((offsetTimeTop) * (-1), SECONDS).toDate(); | ||
appointmentEndTime = moment(start) | ||
.add((appointmentDurationSeconds - offsetTimeTop), SECONDS).toDate(); | ||
} | ||
else { | ||
appointmentStartTime = moment(targetData.startDate) | ||
.add(insideOffset, SECONDS).toDate(); | ||
appointmentEndTime = moment(targetData.endDate).add(insideOffset, SECONDS).toDate(); | ||
} | ||
return { appointmentStartTime: appointmentStartTime, appointmentEndTime: appointmentEndTime, offsetTimeTop: offsetTimeTop }; | ||
}; | ||
var calculateAppointmentTimeBoundaries = function (payload, targetData, targetType, cellDurationMinutes, insidePart, offsetTimeTopBase) { | ||
var isDragging = (payload.type === VERTICAL_TYPE || payload.type === HORIZONTAL_TYPE); | ||
return (isDragging | ||
? timeBoundariesByDrag(payload, targetData, targetType, cellDurationMinutes, insidePart, offsetTimeTopBase) | ||
: timeBoundariesByResize(payload, targetData, targetType, cellDurationMinutes, insidePart)); | ||
}; | ||
var calculateInsidePart = function (top, timeTableCells, timeTableIndex) { | ||
if (timeTableIndex !== undefined && timeTableIndex !== -1) { | ||
var cellRect = timeTableCells[timeTableIndex].getBoundingClientRect(); | ||
return top > cellRect.top + cellRect.height / 2 ? 1 : 0; | ||
} | ||
return 0; | ||
}; | ||
var calculateDraftAppointments = function (allDayIndex, draftAppointments, startViewDate, endViewDate, excludedDays, viewCellsData, allDayCells, targetType, cellDurationMinutes, timeTableCells) { | ||
if (allDayIndex !== -1 | ||
|| (allDayCells.length && intervalDuration(draftAppointments[0].dataItem, HOURS) > 23)) { | ||
return { | ||
allDayDraftAppointments: allDayRects(draftAppointments, startViewDate, endViewDate, excludedDays, viewCellsData, allDayCells), | ||
timeTableDraftAppointments: [], | ||
}; | ||
} | ||
if (targetType === VERTICAL_TYPE || allDayIndex !== -1) { | ||
return { | ||
allDayDraftAppointments: [], | ||
timeTableDraftAppointments: verticalTimeTableRects(draftAppointments, startViewDate, endViewDate, excludedDays, viewCellsData, cellDurationMinutes, timeTableCells), | ||
}; | ||
} | ||
return { | ||
allDayDraftAppointments: [], | ||
timeTableDraftAppointments: horizontalTimeTableRects(draftAppointments, startViewDate, endViewDate, viewCellsData, timeTableCells), | ||
}; | ||
}; | ||
export { dayScale, timeScale, availableViewNames, viewCellsData, allDayCells, startViewDate, endViewDate, getViewType, appointments, monthCellsData, calculateMonthDateIntervals, sliceAppointmentByWeek, getMonthCellIndexByDate, calculateWeekDateIntervals, sliceAppointmentByDay, dayBoundaryPredicate, reduceAppointmentByDayBounds, changeCurrentDate, setCurrentViewName, viewBoundText, setAppointmentMeta, OPEN_COMMAND_BUTTON, CLOSE_COMMAND_BUTTON, DELETE_COMMAND_BUTTON, CANCEL_COMMAND_BUTTON, COMMIT_COMMAND_BUTTON, setAppointmentData, callActionIfExists, isAllDayCell, calculateAllDayDateIntervals, allDayPredicate, getAllDayCellIndexByDate, sliceAppointmentsByBoundaries, addAppointment, cancelAddedAppointment, startEditAppointment, stopEditAppointment, changeAppointment, cancelChanges, changedAppointmentById, getHorizontalRectByDates, getCellByDate, getVerticalRectByDates, cellType, intervalDuration, cellIndex, cellData, autoScroll, timeBoundariesByResize, timeBoundariesByDrag, calculateAppointmentTimeBoundaries, calculateInsidePart, calculateDraftAppointments, VERTICAL_TYPE, HORIZONTAL_TYPE, SCROLL_OFFSET, SCROLL_SPEED_PX, SECONDS, MINUTES, HOURS, RESIZE_TOP, RESIZE_BOTTOM, POSITION_START, POSITION_END, computed, toPercentage, viewPredicate, sortAppointments, findOverlappedAppointments, adjustAppointments, calculateFirstDateOfWeek, unwrapGroups, getAppointmentStyle, calculateRectByDateIntervals, filterByViewBoundaries }; | ||
//# sourceMappingURL=dx-scheduler-core.es.js.map |
/** | ||
* Bundle of @devexpress/dx-scheduler-core | ||
* Generated: 2019-03-13 | ||
* Version: 1.11.0-alpha.1 | ||
* Generated: 2019-04-24 | ||
* Version: 1.11.0-beta.1 | ||
* License: https://js.devexpress.com/Licensing | ||
@@ -9,6 +9,6 @@ */ | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('moment')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'moment'], factory) : | ||
(global = global || self, factory((global.DevExpress = global.DevExpress || {}, global.DevExpress.DXSchedulerCore = {}), global.moment)); | ||
}(this, function (exports, moment) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('moment'), require('rrule')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'moment', 'rrule'], factory) : | ||
(global = global || self, factory((global.DevExpress = global.DevExpress || {}, global.DevExpress.DXSchedulerCore = {}), global.moment, global.rrule)); | ||
}(this, function (exports, moment, rrule) { 'use strict'; | ||
@@ -83,2 +83,8 @@ if (typeof process === "undefined") { var process = { env: {} }; } | ||
var SECONDS = 'seconds'; | ||
var MINUTES = 'minutes'; | ||
var HOURS = 'hours'; | ||
var RESIZE_TOP = 'resize-start'; | ||
var RESIZE_BOTTOM = 'resize-end'; | ||
var POSITION_START = 'start'; | ||
var POSITION_END = 'end'; | ||
@@ -226,2 +232,4 @@ var computed = function (getters, viewName, baseComputed, defaultValue) { | ||
reduceValue: reduceValue, | ||
fromPrev: moment(appointment.start).diff(appointment.dataItem.startDate, 'minutes') > 1, | ||
toNext: moment(appointment.dataItem.endDate).diff(appointment.end, 'minutes') > 1, | ||
}); }))); | ||
@@ -254,2 +262,4 @@ return acc; | ||
dataItem: appointment.dataItem, | ||
fromPrev: appointment.fromPrev, | ||
toNext: appointment.toNext, | ||
type: HORIZONTAL_TYPE, | ||
@@ -274,2 +284,4 @@ }; | ||
dataItem: appointment.dataItem, | ||
fromPrev: appointment.fromPrev, | ||
toNext: appointment.toNext, | ||
type: VERTICAL_TYPE, | ||
@@ -288,2 +300,21 @@ }; | ||
}; | ||
var filterByViewBoundaries = function (appointment, leftBound, rightBound, excludedDays, keepAllDay) { | ||
if (!appointment.rRule) { | ||
return viewPredicate(appointment, leftBound, rightBound, excludedDays, keepAllDay) | ||
? [appointment] | ||
: []; | ||
} | ||
var options = __assign({}, rrule.RRule.parseString(appointment.rRule), { dtstart: moment(appointment.start).toDate() }); | ||
var rruleSet = new rrule.RRuleSet(); | ||
if (appointment.exDate) { | ||
rruleSet = rrule.rrulestr("EXDATE:" + appointment.exDate, { forceset: true }); | ||
} | ||
rruleSet.rrule(new rrule.RRule(options)); | ||
var datesInBoundaries = rruleSet.between(leftBound, rightBound); | ||
if (datesInBoundaries.length === 0) | ||
return []; | ||
var appointmentDuration = moment(appointment.end) | ||
.diff(appointment.start, 'minutes'); | ||
return datesInBoundaries.map(function (startDate, index) { return (__assign({}, appointment, { dataItem: __assign({}, appointment.dataItem, { startDate: moment(startDate).toDate(), endDate: moment(startDate).add(appointmentDuration, 'minutes').toDate() }), start: moment(startDate), end: moment(startDate).add(appointmentDuration, 'minutes') })); }); | ||
}; | ||
@@ -368,2 +399,6 @@ var subtractSecond = function (date) { return moment(date).subtract(1, 'second').toDate(); }; | ||
allDay: appointment.allDay, | ||
}, appointment.rRule !== undefined && { | ||
rRule: appointment.rRule, | ||
}, appointment.exDate !== undefined && { | ||
exDate: appointment.exDate, | ||
}, { dataItem: appointment })); }); }; | ||
@@ -454,3 +489,5 @@ | ||
}) | ||
.filter(function (appointment) { return viewPredicate(appointment, leftBound, rightBound); }) | ||
.reduce(function (acc, appointment) { | ||
return __spread(acc, filterByViewBoundaries(appointment, leftBound, rightBound, [], false)); | ||
}, []) | ||
.reduce(function (acc, appointment) { return (__spread(acc, sliceAppointmentByWeek({ left: moment(leftBound), right: moment(rightBound) }, appointment, DAY_COUNT))); }, []); }; | ||
@@ -504,3 +541,5 @@ | ||
}) | ||
.filter(function (appointment) { return viewPredicate(appointment, leftBound, rightBound, excludedDays, true); }) | ||
.reduce(function (acc, appointment) { | ||
return __spread(acc, filterByViewBoundaries(appointment, leftBound, rightBound, excludedDays, true)); | ||
}, []) | ||
.reduce(function (acc, appointment) { return (__spread(acc, sliceAppointmentByDay(appointment))); }, []) | ||
@@ -616,4 +655,6 @@ .filter(function (appointment) { return dayBoundaryPredicate(appointment, leftBound, rightBound, excludedDays); }) | ||
}) | ||
.filter(function (appointment) { return (viewPredicate(appointment, leftBound, rightBound, excludedDays, false) | ||
&& allDayPredicate(appointment)); }) | ||
.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))); }, []); }; | ||
@@ -725,22 +766,2 @@ | ||
var clamp = function (value, min, max) { return Math.max(Math.min(value, max), min); }; | ||
var cellType = function (data) { return moment(data.startDate) | ||
.isSame(data.endDate, 'day') ? VERTICAL_TYPE : HORIZONTAL_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 isOver = clientOffset | ||
&& clamp(clientOffset.x, left, right) === clientOffset.x | ||
&& clamp(clientOffset.y, top, bottom) === clientOffset.y; | ||
return isOver; | ||
}); }; | ||
var cellData = function (timeTableIndex, allDayIndex, viewCellsData) { | ||
if (allDayIndex !== -1) { | ||
var allDayCellsData = allDayCells(viewCellsData); | ||
return allDayCellsData[allDayIndex]; | ||
} | ||
var firstIndex = Math.floor(timeTableIndex / viewCellsData[0].length); | ||
var secondIndex = timeTableIndex % viewCellsData[0].length; | ||
return viewCellsData[firstIndex][secondIndex]; | ||
}; | ||
var allDayRects = function (draftAppointments, startViewDate, endViewDate, excludedDays, viewCellsData, cellElements) { | ||
@@ -772,3 +793,3 @@ var intervals = calculateAllDayDateIntervals(draftAppointments, startViewDate, endViewDate, excludedDays); | ||
}; | ||
var horizontalTimeTableRects = function (draftAppointments, startViewDate, endViewDate, excludedDays, viewCellsData, cellElements) { | ||
var horizontalTimeTableRects = function (draftAppointments, startViewDate, endViewDate, viewCellsData, cellElements) { | ||
var intervals = calculateMonthDateIntervals(draftAppointments, startViewDate, endViewDate); | ||
@@ -786,2 +807,121 @@ return calculateRectByDateIntervals({ | ||
var clamp = function (value, min, max) { return Math.max(Math.min(value, max), min); }; | ||
var calculateInsideOffset = function (targetType, insidePart, cellDurationMinutes) { return targetType === VERTICAL_TYPE | ||
? insidePart * cellDurationMinutes * 60 / 2 : 0; }; | ||
var cellType = function (data) { return moment(data.startDate) | ||
.isSame(data.endDate, 'day') ? VERTICAL_TYPE : HORIZONTAL_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 isOver = clientOffset | ||
&& clamp(clientOffset.x, left, right) === clientOffset.x | ||
&& clamp(clientOffset.y, top, bottom) === clientOffset.y; | ||
return isOver; | ||
}); }; | ||
var cellData = function (timeTableIndex, allDayIndex, viewCellsData) { | ||
if (allDayIndex !== -1) { | ||
var allDayCellsData = allDayCells(viewCellsData); | ||
return allDayCellsData[allDayIndex]; | ||
} | ||
var firstIndex = Math.floor(timeTableIndex / viewCellsData[0].length); | ||
var secondIndex = timeTableIndex % viewCellsData[0].length; | ||
return viewCellsData[firstIndex][secondIndex]; | ||
}; | ||
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; | ||
} | ||
if (layout.clientHeight - SCROLL_OFFSET < clientOffset.y - layout.offsetTop) { | ||
layout.scrollTop += SCROLL_SPEED_PX; | ||
} | ||
}; | ||
var timeBoundariesByResize = function (payload, targetData, targetType, cellDurationMinutes, insidePart) { | ||
if (targetType !== payload.appointmentType) { | ||
return { appointmentStartTime: undefined, appointmentEndTime: undefined }; | ||
} | ||
var appointmentStartTime; | ||
var appointmentEndTime; | ||
var sourceType = payload.type; | ||
if (sourceType === RESIZE_TOP) { | ||
var insideTopOffset = calculateInsideOffset(targetType, insidePart, cellDurationMinutes); | ||
appointmentStartTime = moment(targetData.startDate) | ||
.add(insideTopOffset, SECONDS).toDate(); | ||
appointmentEndTime = new Date(payload.endDate); | ||
} | ||
if (sourceType === RESIZE_BOTTOM) { | ||
var insideBottomOffset = insidePart === 0 && targetType === VERTICAL_TYPE | ||
? cellDurationMinutes * 60 / 2 : 0; | ||
appointmentEndTime = moment(targetData.endDate) | ||
.add(-insideBottomOffset, SECONDS).toDate(); | ||
appointmentStartTime = new Date(payload.startDate); | ||
} | ||
// keep origin appointment duration if coordinates are wrong | ||
if (moment(appointmentEndTime).diff(appointmentStartTime, MINUTES) < 1) { | ||
appointmentStartTime = new Date(payload.startDate); | ||
appointmentEndTime = new Date(payload.endDate); | ||
} | ||
return { appointmentStartTime: appointmentStartTime, appointmentEndTime: appointmentEndTime }; | ||
}; | ||
var timeBoundariesByDrag = function (payload, targetData, targetType, cellDurationMinutes, insidePart, offsetTimeTopBase) { | ||
var offsetTimeTop; | ||
var appointmentStartTime; | ||
var appointmentEndTime; | ||
var insideOffset = calculateInsideOffset(targetType, insidePart, cellDurationMinutes); | ||
var start = moment(targetData.startDate).add(insideOffset, SECONDS); | ||
if (offsetTimeTopBase === null) { | ||
offsetTimeTop = moment(targetData.startDate) | ||
.diff(payload.startDate, SECONDS) + insideOffset; | ||
} | ||
else { | ||
offsetTimeTop = offsetTimeTopBase; | ||
} | ||
if (payload.type === targetType) { | ||
var appointmentDurationSeconds = intervalDuration(payload, SECONDS); | ||
appointmentStartTime = moment(start).add((offsetTimeTop) * (-1), SECONDS).toDate(); | ||
appointmentEndTime = moment(start) | ||
.add((appointmentDurationSeconds - offsetTimeTop), SECONDS).toDate(); | ||
} | ||
else { | ||
appointmentStartTime = moment(targetData.startDate) | ||
.add(insideOffset, SECONDS).toDate(); | ||
appointmentEndTime = moment(targetData.endDate).add(insideOffset, SECONDS).toDate(); | ||
} | ||
return { appointmentStartTime: appointmentStartTime, appointmentEndTime: appointmentEndTime, offsetTimeTop: offsetTimeTop }; | ||
}; | ||
var calculateAppointmentTimeBoundaries = function (payload, targetData, targetType, cellDurationMinutes, insidePart, offsetTimeTopBase) { | ||
var isDragging = (payload.type === VERTICAL_TYPE || payload.type === HORIZONTAL_TYPE); | ||
return (isDragging | ||
? timeBoundariesByDrag(payload, targetData, targetType, cellDurationMinutes, insidePart, offsetTimeTopBase) | ||
: timeBoundariesByResize(payload, targetData, targetType, cellDurationMinutes, insidePart)); | ||
}; | ||
var calculateInsidePart = function (top, timeTableCells, timeTableIndex) { | ||
if (timeTableIndex !== undefined && timeTableIndex !== -1) { | ||
var cellRect = timeTableCells[timeTableIndex].getBoundingClientRect(); | ||
return top > cellRect.top + cellRect.height / 2 ? 1 : 0; | ||
} | ||
return 0; | ||
}; | ||
var calculateDraftAppointments = function (allDayIndex, draftAppointments, startViewDate, endViewDate, excludedDays, viewCellsData, allDayCells, targetType, cellDurationMinutes, timeTableCells) { | ||
if (allDayIndex !== -1 | ||
|| (allDayCells.length && intervalDuration(draftAppointments[0].dataItem, HOURS) > 23)) { | ||
return { | ||
allDayDraftAppointments: allDayRects(draftAppointments, startViewDate, endViewDate, excludedDays, viewCellsData, allDayCells), | ||
timeTableDraftAppointments: [], | ||
}; | ||
} | ||
if (targetType === VERTICAL_TYPE || allDayIndex !== -1) { | ||
return { | ||
allDayDraftAppointments: [], | ||
timeTableDraftAppointments: verticalTimeTableRects(draftAppointments, startViewDate, endViewDate, excludedDays, viewCellsData, cellDurationMinutes, timeTableCells), | ||
}; | ||
} | ||
return { | ||
allDayDraftAppointments: [], | ||
timeTableDraftAppointments: horizontalTimeTableRects(draftAppointments, startViewDate, endViewDate, viewCellsData, timeTableCells), | ||
}; | ||
}; | ||
exports.dayScale = dayScale; | ||
@@ -834,5 +974,8 @@ exports.timeScale = timeScale; | ||
exports.cellData = cellData; | ||
exports.allDayRects = allDayRects; | ||
exports.verticalTimeTableRects = verticalTimeTableRects; | ||
exports.horizontalTimeTableRects = horizontalTimeTableRects; | ||
exports.autoScroll = autoScroll; | ||
exports.timeBoundariesByResize = timeBoundariesByResize; | ||
exports.timeBoundariesByDrag = timeBoundariesByDrag; | ||
exports.calculateAppointmentTimeBoundaries = calculateAppointmentTimeBoundaries; | ||
exports.calculateInsidePart = calculateInsidePart; | ||
exports.calculateDraftAppointments = calculateDraftAppointments; | ||
exports.VERTICAL_TYPE = VERTICAL_TYPE; | ||
@@ -843,2 +986,8 @@ exports.HORIZONTAL_TYPE = HORIZONTAL_TYPE; | ||
exports.SECONDS = SECONDS; | ||
exports.MINUTES = MINUTES; | ||
exports.HOURS = HOURS; | ||
exports.RESIZE_TOP = RESIZE_TOP; | ||
exports.RESIZE_BOTTOM = RESIZE_BOTTOM; | ||
exports.POSITION_START = POSITION_START; | ||
exports.POSITION_END = POSITION_END; | ||
exports.computed = computed; | ||
@@ -854,2 +1003,3 @@ exports.toPercentage = toPercentage; | ||
exports.calculateRectByDateIntervals = calculateRectByDateIntervals; | ||
exports.filterByViewBoundaries = filterByViewBoundaries; | ||
@@ -856,0 +1006,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
{ | ||
"name": "@devexpress/dx-scheduler-core", | ||
"version": "1.11.0-alpha.1", | ||
"version": "1.11.0-beta.1", | ||
"description": "Core library for the DevExtreme Reactive Scheduler component", | ||
@@ -38,3 +38,3 @@ "author": { | ||
"lint": "tslint -p tsconfig.lint.json", | ||
"lint:fix": "yarn run lint -- --fix" | ||
"lint:fix": "yarn lint -- --fix" | ||
}, | ||
@@ -45,3 +45,3 @@ "devDependencies": { | ||
"@babel/preset-env": "^7.3.1", | ||
"@devexpress/dx-core": "1.11.0-alpha.1", | ||
"@devexpress/dx-core": "1.11.0-beta.1", | ||
"babel-core": "^7.0.0-bridge.0", | ||
@@ -61,8 +61,9 @@ "babel-jest": "^24.1.0", | ||
"peerDependencies": { | ||
"@devexpress/dx-core": "1.11.0-alpha.1" | ||
"@devexpress/dx-core": "1.11.0-beta.1" | ||
}, | ||
"dependencies": { | ||
"moment": "^2.24.0" | ||
"moment": "^2.24.0", | ||
"rrule": "^2.6.0" | ||
}, | ||
"gitHead": "04937befc4fe9c5e329039533983c956deb78390" | ||
"gitHead": "972b9b88a1e51db0c0c8c30a009407b2d35a7a4f" | ||
} |
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
269603
1840
3
+ Addedrrule@^2.6.0
+ Added@devexpress/dx-core@1.11.0-beta.1(transitive)
+ Addedrrule@2.8.1(transitive)
+ Addedtslib@2.8.1(transitive)
- Removed@devexpress/dx-core@1.11.0-alpha.1(transitive)