UNPKG

@progress/kendo-react-dateinputs

Version:
140 lines 4.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var kendo_date_math_1 = require("@progress/kendo-date-math"); var kendo_date_math_2 = require("@progress/kendo-date-math"); var SelectionRange_1 = require("./calendar/models/SelectionRange"); /** * @hidden */ exports.isEqualRange = function (initial, updated) { var _a = initial || SelectionRange_1.EMPTY_SELECTIONRANGE, initialStart = _a.start, initialEnd = _a.end; var _b = updated || SelectionRange_1.EMPTY_SELECTIONRANGE, updatedStart = _b.start, updatedEnd = _b.end; if (initialStart === null || initialEnd === null || updatedStart === null || updatedEnd === null) { return false; } return kendo_date_math_1.isEqual(initialStart, updatedStart) && kendo_date_math_1.isEqual(initialEnd, updatedEnd); }; /** * @hidden */ exports.viewInRange = function (candidate, min, max) { if (min === undefined || max === undefined) { return candidate; } return min <= candidate && candidate <= max ? candidate : candidate < min ? min : max; }; /** * @hidden */ exports.MIDNIGHT_DATE = new Date(1980, 0, 1); /** * @hidden */ exports.MIN_DATE = new Date(1900, 0, 1); /** * @hidden */ exports.MAX_DATE = new Date(2099, 11, 31); /** * @hidden */ exports.MIN_TIME = new Date(1980, 0, 1); /** * @hidden */ exports.MAX_TIME = new Date(1980, 0, 1, 23, 59, 59); var isSet = function (value) { return value !== null && value !== undefined; }; /** * @hidden */ exports.isValidRange = function (min, max) { return (!isSet(min) || !isSet(max) || min <= max); }; /** * @hidden */ exports.setTime = function (origin, candidate) { var date = kendo_date_math_1.cloneDate(origin); date.setHours(candidate.getHours(), candidate.getMinutes(), candidate.getSeconds(), candidate.getMilliseconds()); return date; }; /** * @hidden */ exports.getToday = function () { return kendo_date_math_2.getDate(new Date()); }; /** * @hidden */ exports.isInRange = function (candidate, min, max) { return (!candidate || !((min && min > candidate) || (max && max < candidate))); }; /** * @hidden */ exports.isInRangePicker = function (candidate, min, max) { return (candidate === null || !((min && kendo_date_math_2.getDate(min) > kendo_date_math_2.getDate(candidate)) || (max && kendo_date_math_2.getDate(max) < kendo_date_math_2.getDate(candidate)))); }; /** * @hidden */ exports.isInSelectionRange = function (value, selectionRange) { var _a = selectionRange || SelectionRange_1.EMPTY_SELECTIONRANGE, start = _a.start, end = _a.end; if (!start || !end) { return false; } return start < value && value < end; }; /** * @hidden */ exports.range = function (start, end, step) { if (step === void 0) { step = 1; } var result = []; for (var i = start; i < end; i = i + step) { result.push(i); } return result; }; /** * @hidden */ exports.shiftWeekNames = function (names, offset) { return (names.slice(offset).concat(names.slice(0, offset))); }; /** * @hidden */ exports.dateInRange = function (candidate, min, max) { if (!candidate) { return candidate; } if (min && candidate < min) { return kendo_date_math_1.cloneDate(min); } if (max && candidate > max) { return kendo_date_math_1.cloneDate(max); } return candidate; }; /** * @hidden */ exports.domContainerFactory = function (type) { return function (children, classes, styles) { if (classes === void 0) { classes = ''; } if (styles === void 0) { styles = {}; } var container = document.createElement(type); container.className = classes; Object.keys(styles).map(function (key) { return container.style[key] = styles[key]; }); if (typeof children === 'string') { container.innerHTML = children || ''; } else { (children || []).forEach(function (child) { return child && container.appendChild(child); }); } return container; }; }; /** * @hidden */ exports.isDocumentAvailable = function () { return typeof document !== 'undefined'; }; //# sourceMappingURL=utils.js.map