react-big-schedule
Version:
React Big Schedule is a powerful and intuitive scheduler and resource planning solution built with React. Seamlessly integrate this modern browser-compatible component into your applications to effectively manage time, appointments, and resources. With d
42 lines (40 loc) • 2.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getNextNumericEventId = getNextNumericEventId;
exports.getPos = getPos;
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function getPos(element) {
var x = 0;
var y = 0;
var currentElement = element;
while (currentElement) {
x += currentElement.offsetLeft - currentElement.scrollLeft;
y += currentElement.offsetTop - currentElement.scrollTop;
currentElement = currentElement.offsetParent;
}
return {
x: x,
y: y
};
}
/**
* Generates the next numeric event ID by finding the maximum numeric ID in the events array
* and incrementing it by 1. Filters out non-numeric and non-finite IDs.
* @param {Array} events - Array of event objects with id properties
* @returns {number} The next available numeric ID
*/
function getNextNumericEventId(events) {
var numericIds = events.map(function (event) {
return event.id;
}).filter(function (id) {
return typeof id === 'number' && Number.isFinite(id);
});
return Math.max.apply(Math, _toConsumableArray(numericIds).concat([0])) + 1;
}