UNPKG

@herculesproject/datetime-picker

Version:
1,036 lines (1,029 loc) 265 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/cdk/portal'), require('@angular/core'), require('@angular/material/datepicker'), require('rxjs'), require('@angular/material/core'), require('@angular/cdk/keycodes'), require('@angular/cdk/bidi'), require('rxjs/operators'), require('@angular/cdk/coercion'), require('@angular/cdk/overlay'), require('@angular/common'), require('@angular/material/dialog'), require('@angular/forms'), require('@angular/material/form-field'), require('@angular/material/input'), require('@angular/material/button'), require('@angular/material/icon'), require('@angular/cdk/platform')) : typeof define === 'function' && define.amd ? define('@herculesproject/datetime-picker', ['exports', '@angular/cdk/portal', '@angular/core', '@angular/material/datepicker', 'rxjs', '@angular/material/core', '@angular/cdk/keycodes', '@angular/cdk/bidi', 'rxjs/operators', '@angular/cdk/coercion', '@angular/cdk/overlay', '@angular/common', '@angular/material/dialog', '@angular/forms', '@angular/material/form-field', '@angular/material/input', '@angular/material/button', '@angular/material/icon', '@angular/cdk/platform'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.herculesproject = global.herculesproject || {}, global.herculesproject['datetime-picker'] = {}), global.ng.cdk.portal, global.ng.core, global.ng.material.datepicker, global.rxjs, global.ng.material.core, global.ng.cdk.keycodes, global.ng.cdk.bidi, global.rxjs.operators, global.ng.cdk.coercion, global.ng.cdk.overlay, global.ng.common, global.ng.material.dialog, global.ng.forms, global.ng.material.formField, global.ng.material.input, global.ng.material.button, global.ng.material.icon, global.ng.cdk.platform)); }(this, (function (exports, portal, core$1, datepicker, rxjs, core, keycodes, bidi, operators, coercion, overlay, common, dialog, forms, formField, input, button, icon, platform) { 'use strict'; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ /* global Reflect, Promise */ var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; function __extends(d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } var __assign = function () { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; function __rest(s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; } function __decorate(decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; } function __param(paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); }; } function __metadata(metadataKey, metadataValue) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); } function __awaiter(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); } function __generator(thisArg, body) { var _ = { label: 0, sent: function () { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } } var __createBinding = Object.create ? (function (o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } }); }) : (function (o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; }); function __exportStar(m, exports) { for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } function __values(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); } function __read(o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; } function __spread() { for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); return ar; } function __spreadArrays() { for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j]; return r; } ; function __await(v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } function __asyncGenerator(thisArg, _arguments, generator) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), i, q = []; return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } } function __asyncDelegator(o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } } function __asyncValues(o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var m = o[Symbol.asyncIterator], i; return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); } } function __makeTemplateObject(cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } return cooked; } ; var __setModuleDefault = Object.create ? (function (o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function (o, v) { o["default"] = v; }; function __importStar(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; } function __importDefault(mod) { return (mod && mod.__esModule) ? mod : { default: mod }; } function __classPrivateFieldGet(receiver, privateMap) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return privateMap.get(receiver); } function __classPrivateFieldSet(receiver, privateMap, value) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to set private field on non-instance"); } privateMap.set(receiver, value); return value; } /** * @abstract * @template D */ var NgxMatDateAdapter = /** @class */ (function (_super) { __extends(NgxMatDateAdapter, _super); function NgxMatDateAdapter() { return _super !== null && _super.apply(this, arguments) || this; } /** * Check if two date have same time * @param {?} a Date 1 * @param {?} b Date 2 * @return {?} */ NgxMatDateAdapter.prototype.isSameTime = function (a, b) { if (a == null || b == null) return true; return this.getHour(a) === this.getHour(b) && this.getMinute(a) === this.getMinute(b) && this.getSecond(a) === this.getSecond(b); }; /** * Copy time from a date to a another date * @param {?} toDate * @param {?} fromDate * @return {?} */ NgxMatDateAdapter.prototype.copyTime = function (toDate, fromDate) { /** @type {?} */ var value = toDate; value = this.setHour(toDate, this.getHour(fromDate)); value = this.setMinute(toDate, this.getMinute(fromDate)); value = this.setSecond(toDate, this.getSecond(fromDate)); return value; }; /** * Compares two dates. * @param {?} first The first date to compare. * @param {?} second The second date to compare. * @param {?=} showSeconds * @return {?} 0 if the dates are equal, a number less than 0 if the first date is earlier, * a number greater than 0 if the first date is later. */ NgxMatDateAdapter.prototype.compareDateWithTime = function (first, second, showSeconds) { /** @type {?} */ var res = _super.prototype.compareDate.call(this, first, second) || this.getHour(first) - this.getHour(second) || this.getMinute(first) - this.getMinute(second); if (showSeconds) { res = res || this.getSecond(first) - this.getSecond(second); } return res; }; /** * Set time by using default values * @param {?} date * @param {?} defaultTime List default values [hour, minute, second] * @return {?} */ NgxMatDateAdapter.prototype.setTimeByDefaultValues = function (date, defaultTime) { if (!Array.isArray(defaultTime)) { throw Error('@Input DefaultTime should be an array'); } /** @type {?} */ var value = date; value = this.setHour(date, defaultTime[0] || 0); value = this.setMinute(date, defaultTime[1] || 0); value = this.setSecond(date, defaultTime[2] || 0); return value; }; return NgxMatDateAdapter; }(core.DateAdapter)); if (false) { /** * Gets the hour component of the given date. * @abstract * @param {?} date The date to extract the month from. * @return {?} The hour component. */ NgxMatDateAdapter.prototype.getHour = function (date) { }; /** * Gets the minute component of the given date. * @abstract * @param {?} date The date to extract the month from. * @return {?} The minute component. */ NgxMatDateAdapter.prototype.getMinute = function (date) { }; /** * Gets the second component of the given date. * @abstract * @param {?} date The date to extract the month from. * @return {?} The second component. */ NgxMatDateAdapter.prototype.getSecond = function (date) { }; /** * Set the hour component of the given date. * @abstract * @param {?} date The date to extract the month from. * @param {?} value The value to set. * @return {?} */ NgxMatDateAdapter.prototype.setHour = function (date, value) { }; /** * Set the second component of the given date. * @abstract * @param {?} date The date to extract the month from. * @param {?} value The value to set. * @return {?} */ NgxMatDateAdapter.prototype.setMinute = function (date, value) { }; /** * Set the second component of the given date. * @abstract * @param {?} date The date to extract the month from. * @param {?} value The value to set. * @return {?} */ NgxMatDateAdapter.prototype.setSecond = function (date, value) { }; } /** * @fileoverview added by tsickle * Generated from: lib/core/date-formats.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ var NGX_MAT_DATE_FORMATS = new core$1.InjectionToken('ngx-mat-date-formats'); /** * @fileoverview added by tsickle * Generated from: lib/calendar-body.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * An internal class that represents the data corresponding to a single calendar cell. * \@docs-private * @template D */ var NgxMatCalendarCell = /** @class */ (function () { /** * @param {?} value * @param {?} displayValue * @param {?} ariaLabel * @param {?} enabled * @param {?=} cssClasses * @param {?=} compareValue * @param {?=} rawValue */ function NgxMatCalendarCell(value, displayValue, ariaLabel, enabled, cssClasses, compareValue, rawValue) { if (cssClasses === void 0) { cssClasses = {}; } if (compareValue === void 0) { compareValue = value; } this.value = value; this.displayValue = displayValue; this.ariaLabel = ariaLabel; this.enabled = enabled; this.cssClasses = cssClasses; this.compareValue = compareValue; this.rawValue = rawValue; } return NgxMatCalendarCell; }()); if (false) { /** @type {?} */ NgxMatCalendarCell.prototype.value; /** @type {?} */ NgxMatCalendarCell.prototype.displayValue; /** @type {?} */ NgxMatCalendarCell.prototype.ariaLabel; /** @type {?} */ NgxMatCalendarCell.prototype.enabled; /** @type {?} */ NgxMatCalendarCell.prototype.cssClasses; /** @type {?} */ NgxMatCalendarCell.prototype.compareValue; /** @type {?} */ NgxMatCalendarCell.prototype.rawValue; } /** * Event emitted when a date inside the calendar is triggered as a result of a user action. * @record * @template D */ function NgxMatCalendarUserEvent() { } if (false) { /** @type {?} */ NgxMatCalendarUserEvent.prototype.value; /** @type {?} */ NgxMatCalendarUserEvent.prototype.event; } /** * An internal component used to display calendar data in a table. * \@docs-private */ var NgxMatCalendarBody = /** @class */ (function () { /** * @param {?} _elementRef * @param {?} _ngZone */ function NgxMatCalendarBody(_elementRef, _ngZone) { var _this = this; this._elementRef = _elementRef; this._ngZone = _ngZone; /** * The number of columns in the table. */ this.numCols = 7; /** * The cell number of the active cell in the table. */ this.activeCell = 0; /** * Whether a range is being selected. */ this.isRange = false; /** * The aspect ratio (width / height) to use for the cells in the table. This aspect ratio will be * maintained even as the table resizes. */ this.cellAspectRatio = 1; /** * Start of the preview range. */ this.previewStart = null; /** * End of the preview range. */ this.previewEnd = null; /** * Emits when a new value is selected. */ this.selectedValueChange = new core$1.EventEmitter(); /** * Emits when the preview has changed as a result of a user action. */ this.previewChange = new core$1.EventEmitter(); /** * Event handler for when the user enters an element * inside the calendar body (e.g. by hovering in or focus). */ this._enterHandler = ( /** * @param {?} event * @return {?} */function (event) { if (_this._skipNextFocus && event.type === 'focus') { _this._skipNextFocus = false; return; } // We only need to hit the zone when we're selecting a range. if (event.target && _this.isRange) { /** @type {?} */ var cell_1 = _this._getCellFromElement(( /** @type {?} */(event.target))); if (cell_1) { _this._ngZone.run(( /** * @return {?} */function () { return _this.previewChange.emit({ value: cell_1.enabled ? cell_1 : null, event: event }); })); } } }); /** * Event handler for when the user's pointer leaves an element * inside the calendar body (e.g. by hovering out or blurring). */ this._leaveHandler = ( /** * @param {?} event * @return {?} */function (event) { // We only need to hit the zone when we're selecting a range. if (_this.previewEnd !== null && _this.isRange) { // Only reset the preview end value when leaving cells. This looks better, because // we have a gap between the cells and the rows and we don't want to remove the // range just for it to show up again when the user moves a few pixels to the side. if (event.target && isTableCell(( /** @type {?} */(event.target)))) { _this._ngZone.run(( /** * @return {?} */function () { return _this.previewChange.emit({ value: null, event: event }); })); } } }); _ngZone.runOutsideAngular(( /** * @return {?} */function () { /** @type {?} */ var element = _elementRef.nativeElement; element.addEventListener('mouseenter', _this._enterHandler, true); element.addEventListener('focus', _this._enterHandler, true); element.addEventListener('mouseleave', _this._leaveHandler, true); element.addEventListener('blur', _this._leaveHandler, true); })); } /** * Called when a cell is clicked. * @param {?} cell * @param {?} event * @return {?} */ NgxMatCalendarBody.prototype._cellClicked = function (cell, event) { if (cell.enabled) { this.selectedValueChange.emit({ value: cell.value, event: event }); } }; /** * Returns whether a cell should be marked as selected. * @param {?} cell * @return {?} */ NgxMatCalendarBody.prototype._isSelected = function (cell) { return this.startValue === cell.compareValue || this.endValue === cell.compareValue; }; /** * @param {?} changes * @return {?} */ NgxMatCalendarBody.prototype.ngOnChanges = function (changes) { /** @type {?} */ var columnChanges = changes['numCols']; var _a = this, rows = _a.rows, numCols = _a.numCols; if (changes['rows'] || columnChanges) { this._firstRowOffset = rows && rows.length && rows[0].length ? numCols - rows[0].length : 0; } if (changes['cellAspectRatio'] || columnChanges || !this._cellPadding) { this._cellPadding = 50 * this.cellAspectRatio / numCols + "%"; } if (columnChanges || !this._cellWidth) { this._cellWidth = 100 / numCols + "%"; } }; /** * @return {?} */ NgxMatCalendarBody.prototype.ngOnDestroy = function () { /** @type {?} */ var element = this._elementRef.nativeElement; element.removeEventListener('mouseenter', this._enterHandler, true); element.removeEventListener('focus', this._enterHandler, true); element.removeEventListener('mouseleave', this._leaveHandler, true); element.removeEventListener('blur', this._leaveHandler, true); }; /** * Returns whether a cell is active. * @param {?} rowIndex * @param {?} colIndex * @return {?} */ NgxMatCalendarBody.prototype._isActiveCell = function (rowIndex, colIndex) { /** @type {?} */ var cellNumber = rowIndex * this.numCols + colIndex; // Account for the fact that the first row may not have as many cells. if (rowIndex) { cellNumber -= this._firstRowOffset; } return cellNumber == this.activeCell; }; /** * Focuses the active cell after the microtask queue is empty. * @param {?=} movePreview * @return {?} */ NgxMatCalendarBody.prototype._focusActiveCell = function (movePreview) { var _this = this; if (movePreview === void 0) { movePreview = true; } this._ngZone.runOutsideAngular(( /** * @return {?} */function () { _this._ngZone.onStable.asObservable().pipe(operators.take(1)).subscribe(( /** * @return {?} */function () { /** @type {?} */ var activeCell = _this._elementRef.nativeElement.querySelector('.ngx-mat-calendar-body-active'); if (activeCell) { if (!movePreview) { _this._skipNextFocus = true; } activeCell.focus(); } })); })); }; /** * Gets whether a value is the start of the main range. * @param {?} value * @return {?} */ NgxMatCalendarBody.prototype._isRangeStart = function (value) { return isStart(value, this.startValue, this.endValue); }; /** * Gets whether a value is the end of the main range. * @param {?} value * @return {?} */ NgxMatCalendarBody.prototype._isRangeEnd = function (value) { return isEnd(value, this.startValue, this.endValue); }; /** * Gets whether a value is within the currently-selected range. * @param {?} value * @return {?} */ NgxMatCalendarBody.prototype._isInRange = function (value) { return isInRange(value, this.startValue, this.endValue, this.isRange); }; /** * Gets whether a value is the start of the comparison range. * @param {?} value * @return {?} */ NgxMatCalendarBody.prototype._isComparisonStart = function (value) { return isStart(value, this.comparisonStart, this.comparisonEnd); }; /** * Whether the cell is a start bridge cell between the main and comparison ranges. * @param {?} value * @param {?} rowIndex * @param {?} colIndex * @return {?} */ NgxMatCalendarBody.prototype._isComparisonBridgeStart = function (value, rowIndex, colIndex) { if (!this._isComparisonStart(value) || this._isRangeStart(value) || !this._isInRange(value)) { return false; } /** @type {?} */ var previousCell = this.rows[rowIndex][colIndex - 1]; if (!previousCell) { /** @type {?} */ var previousRow = this.rows[rowIndex - 1]; previousCell = previousRow && previousRow[previousRow.length - 1]; } return previousCell && !this._isRangeEnd(previousCell.compareValue); }; /** * Whether the cell is an end bridge cell between the main and comparison ranges. * @param {?} value * @param {?} rowIndex * @param {?} colIndex * @return {?} */ NgxMatCalendarBody.prototype._isComparisonBridgeEnd = function (value, rowIndex, colIndex) { if (!this._isComparisonEnd(value) || this._isRangeEnd(value) || !this._isInRange(value)) { return false; } /** @type {?} */ var nextCell = this.rows[rowIndex][colIndex + 1]; if (!nextCell) { /** @type {?} */ var nextRow = this.rows[rowIndex + 1]; nextCell = nextRow && nextRow[0]; } return nextCell && !this._isRangeStart(nextCell.compareValue); }; /** * Gets whether a value is the end of the comparison range. * @param {?} value * @return {?} */ NgxMatCalendarBody.prototype._isComparisonEnd = function (value) { return isEnd(value, this.comparisonStart, this.comparisonEnd); }; /** * Gets whether a value is within the current comparison range. * @param {?} value * @return {?} */ NgxMatCalendarBody.prototype._isInComparisonRange = function (value) { return isInRange(value, this.comparisonStart, this.comparisonEnd, this.isRange); }; /** * Gets whether a value is the start of the preview range. * @param {?} value * @return {?} */ NgxMatCalendarBody.prototype._isPreviewStart = function (value) { return isStart(value, this.previewStart, this.previewEnd); }; /** * Gets whether a value is the end of the preview range. * @param {?} value * @return {?} */ NgxMatCalendarBody.prototype._isPreviewEnd = function (value) { return isEnd(value, this.previewStart, this.previewEnd); }; /** * Gets whether a value is inside the preview range. * @param {?} value * @return {?} */ NgxMatCalendarBody.prototype._isInPreview = function (value) { return isInRange(value, this.previewStart, this.previewEnd, this.isRange); }; /** * Finds the NgxMatCalendarCell that corresponds to a DOM node. * @private * @param {?} element * @return {?} */ NgxMatCalendarBody.prototype._getCellFromElement = function (element) { /** @type {?} */ var cell; if (isTableCell(element)) { cell = element; } else if (isTableCell(( /** @type {?} */(element.parentNode)))) { cell = ( /** @type {?} */(element.parentNode)); } if (cell) { /** @type {?} */ var row = cell.getAttribute('data-ngx-mat-row'); /** @type {?} */ var col = cell.getAttribute('data-ngx-mat-col'); if (row && col) { return this.rows[parseInt(row)][parseInt(col)]; } } return null; }; return NgxMatCalendarBody; }()); NgxMatCalendarBody.decorators = [ { type: core$1.Component, args: [{ selector: '[ngx-mat-calendar-body]', template: "<!--\n If there's not enough space in the first row, create a separate label row. We mark this row as\n aria-hidden because we don't want it to be read out as one of the weeks in the month.\n-->\n<tr *ngIf=\"_firstRowOffset < labelMinRequiredCells\" aria-hidden=\"true\">\n <td class=\"mat-calendar-body-label\"\n [attr.colspan]=\"numCols\"\n [style.paddingTop]=\"_cellPadding\"\n [style.paddingBottom]=\"_cellPadding\">\n {{label}}\n </td>\n</tr>\n\n<!-- Create the first row separately so we can include a special spacer cell. -->\n<tr *ngFor=\"let row of rows; let rowIndex = index\" role=\"row\">\n <!--\n We mark this cell as aria-hidden so it doesn't get read out as one of the days in the week.\n The aspect ratio of the table cells is maintained by setting the top and bottom padding as a\n percentage of the width (a variant of the trick described here:\n https://www.w3schools.com/howto/howto_css_aspect_ratio.asp).\n -->\n <td *ngIf=\"rowIndex === 0 && _firstRowOffset\"\n aria-hidden=\"true\"\n class=\"mat-calendar-body-label\"\n [attr.colspan]=\"_firstRowOffset\"\n [style.paddingTop]=\"_cellPadding\"\n [style.paddingBottom]=\"_cellPadding\">\n {{_firstRowOffset >= labelMinRequiredCells ? label : ''}}\n </td>\n <td *ngFor=\"let item of row; let colIndex = index\"\n role=\"gridcell\"\n class=\"mat-calendar-body-cell\"\n [ngClass]=\"item.cssClasses\"\n [tabindex]=\"_isActiveCell(rowIndex, colIndex) ? 0 : -1\"\n [attr.data-mat-row]=\"rowIndex\"\n [attr.data-mat-col]=\"colIndex\"\n [class.mat-calendar-body-disabled]=\"!item.enabled\"\n [class.mat-calendar-body-active]=\"_isActiveCell(rowIndex, colIndex)\"\n [class.mat-calendar-body-range-start]=\"_isRangeStart(item.compareValue)\"\n [class.mat-calendar-body-range-end]=\"_isRangeEnd(item.compareValue)\"\n [class.mat-calendar-body-in-range]=\"_isInRange(item.compareValue)\"\n [class.mat-calendar-body-comparison-bridge-start]=\"_isComparisonBridgeStart(item.compareValue, rowIndex, colIndex)\"\n [class.mat-calendar-body-comparison-bridge-end]=\"_isComparisonBridgeEnd(item.compareValue, rowIndex, colIndex)\"\n [class.mat-calendar-body-comparison-start]=\"_isComparisonStart(item.compareValue)\"\n [class.mat-calendar-body-comparison-end]=\"_isComparisonEnd(item.compareValue)\"\n [class.mat-calendar-body-in-comparison-range]=\"_isInComparisonRange(item.compareValue)\"\n [class.mat-calendar-body-preview-start]=\"_isPreviewStart(item.compareValue)\"\n [class.mat-calendar-body-preview-end]=\"_isPreviewEnd(item.compareValue)\"\n [class.mat-calendar-body-in-preview]=\"_isInPreview(item.compareValue)\"\n [attr.aria-label]=\"item.ariaLabel\"\n [attr.aria-disabled]=\"!item.enabled || null\"\n [attr.aria-selected]=\"_isSelected(item)\"\n (click)=\"_cellClicked(item, $event)\"\n [style.width]=\"_cellWidth\"\n [style.paddingTop]=\"_cellPadding\"\n [style.paddingBottom]=\"_cellPadding\">\n <div class=\"mat-calendar-body-cell-content mat-focus-indicator\"\n [class.mat-calendar-body-selected]=\"_isSelected(item)\"\n [class.mat-calendar-body-today]=\"todayValue === item.compareValue\">\n {{item.displayValue}}\n </div>\n <div class=\"mat-calendar-body-cell-preview\"></div>\n </td>\n</tr>\n", host: { 'class': 'ngx-mat-calendar-body', 'role': 'grid', 'aria-readonly': 'true' }, exportAs: 'NgxMatCalendarBody', encapsulation: core$1.ViewEncapsulation.None, changeDetection: core$1.ChangeDetectionStrategy.OnPush, styles: [".mat-calendar-body{min-width:224px}.mat-calendar-body-label{height:0;line-height:0;padding-left:4.7142857143%;padding-right:4.7142857143%;text-align:left}.mat-calendar-body-cell{cursor:pointer;height:0;line-height:0;outline:none;position:relative;text-align:center}.mat-calendar-body-cell-preview,.mat-calendar-body-cell:after,.mat-calendar-body-cell:before{box-sizing:border-box;content:\"\";height:90%;left:0;position:absolute;top:5%;width:100%;z-index:0}.mat-calendar-body-comparison-start:after,.mat-calendar-body-comparison-start:not(.mat-calendar-body-comparison-bridge-start):before,.mat-calendar-body-preview-start .mat-calendar-body-cell-preview,.mat-calendar-body-range-start:after,.mat-calendar-body-range-start:not(.mat-calendar-body-in-comparison-range):before{border-bottom-left-radius:999px;border-top-left-radius:999px;left:5%;width:95%}[dir=rtl] .mat-calendar-body-comparison-start:after,[dir=rtl] .mat-calendar-body-comparison-start:not(.mat-calendar-body-comparison-bridge-start):before,[dir=rtl] .mat-calendar-body-preview-start .mat-calendar-body-cell-preview,[dir=rtl] .mat-calendar-body-range-start:after,[dir=rtl] .mat-calendar-body-range-start:not(.mat-calendar-body-in-comparison-range):before{border-bottom-right-radius:999px;border-radius:0;border-top-right-radius:999px;left:0}.mat-calendar-body-comparison-end:after,.mat-calendar-body-comparison-end:not(.mat-calendar-body-comparison-bridge-end):before,.mat-calendar-body-preview-end .mat-calendar-body-cell-preview,.mat-calendar-body-range-end:after,.mat-calendar-body-range-end:not(.mat-calendar-body-in-comparison-range):before{border-bottom-right-radius:999px;border-top-right-radius:999px;width:95%}[dir=rtl] .mat-calendar-body-comparison-end:after,[dir=rtl] .mat-calendar-body-comparison-end:not(.mat-calendar-body-comparison-bridge-end):before,[dir=rtl] .mat-calendar-body-preview-end .mat-calendar-body-cell-preview,[dir=rtl] .mat-calendar-body-range-end:after,[dir=rtl] .mat-calendar-body-range-end:not(.mat-calendar-body-in-comparison-range):before{border-bottom-left-radius:999px;border-radius:0;border-top-left-radius:999px;left:5%}[dir=rtl] .mat-calendar-body-comparison-bridge-end.mat-calendar-body-range-start:after,[dir=rtl] .mat-calendar-body-comparison-bridge-start.mat-calendar-body-range-end:after{border-bottom-right-radius:999px;border-top-right-radius:999px;width:95%}.mat-calendar-body-comparison-end.mat-calendar-body-range-start:after,.mat-calendar-body-comparison-start.mat-calendar-body-range-end:after,[dir=rtl] .mat-calendar-body-comparison-end.mat-calendar-body-range-start:after,[dir=rtl] .mat-calendar-body-comparison-start.mat-calendar-body-range-end:after{width:90%}.mat-calendar-body-in-preview .mat-calendar-body-cell-preview{border-bottom:1px dashed;border-top:1px dashed}.mat-calendar-body-preview-start .mat-calendar-body-cell-preview{border-left:1px dashed}[dir=rtl] .mat-calendar-body-preview-start .mat-calendar-body-cell-preview{border-left:0;border-right:1px dashed}.mat-calendar-body-preview-end .mat-calendar-body-cell-preview{border-right:1px dashed}[dir=rtl] .mat-calendar-body-preview-end .mat-calendar-body-cell-preview{border-left:1px dashed;border-right:0}.mat-calendar-body-disabled{cursor:default}.mat-calendar-body-cell-content{align-items:center;border-radius:999px;border-style:solid;border-width:1px;box-sizing:border-box;display:flex;height:90%;justify-content:center;left:5%;line-height:1;top:5%;width:90%;z-index:1}.mat-calendar-body-cell-content.mat-focus-indicator{position:absolute}.cdk-high-contrast-active .mat-calendar-body-cell-content{border:none}.cdk-high-contrast-active .mat-calendar-body-selected,.cdk-high-contrast-active .mat-datepicker-popup:not(:empty){outline:1px solid}.cdk-high-contrast-active .mat-calendar-body-today{outline:1px dotted}.cdk-high-contrast-active .cdk-keyboard-focused .mat-calendar-body-active>.mat-calendar-body-cell-content:not(.mat-calendar-body-selected),.cdk-high-contrast-active .cdk-program-focused .mat-calendar-body-active>.mat-calendar-body-cell-content:not(.mat-calendar-body-selected){outline:2px dotted}[dir=rtl] .mat-calendar-body-label{text-align:right}@media (hover:none){.mat-calendar-body-cell:not(.mat-calendar-body-disabled):hover>.mat-calendar-body-cell-content:not(.mat-calendar-body-selected){background-color:transparent}}"] }] } ]; /** @nocollapse */ NgxMatCalendarBody.ctorParameters = function () { return [ { type: core$1.ElementRef }, { type: core$1.NgZone } ]; }; NgxMatCalendarBody.propDecorators = { label: [{ type: core$1.Input }], rows: [{ type: core$1.Input }], todayValue: [{ type: core$1.Input }], startValue: [{ type: core$1.Input }], endValue: [{ type: core$1.Input }], labelMinRequiredCells: [{ type: core$1.Input }], numCols: [{ type: core$1.Input }], activeCell: [{ type: core$1.Input }], isRange: [{ type: core$1.Input }], cellAspectRatio: [{ type: core$1.Input }], comparisonStart: [{ type: core$1.Input }], comparisonEnd: [{ type: core$1.Input }], previewStart: [{ type: core$1.Input }], previewEnd: [{ type: core$1.Input }], selectedValueChange: [{ type: core$1.Output }], previewChange: [{ type: core$1.Output }] }; if (false) { /** * Used to skip the next focus event when rendering the preview range. * We need a flag like this, because some browsers fire focus events asynchronously. * @type {?} * @private */ NgxMatCalendarBody.prototype._skipNextFocus; /** * The label for the table. (e.g. "Jan 2017"). * @type {?} */ NgxMatCalendarBody.prototype.label; /** * The cells to display in the table. * @type {?} */ NgxMatCalendarBody.prototype.rows; /** * The value in the table that corresponds to today. * @type {?} */ NgxMatCalendarBody.prototype.todayValue; /** * Start value of the selected date range. * @type {?} */ NgxMatCalendarBody.prototype.startValue; /** * End value of the selected date range. * @type {?} */ NgxMatCalendarBody.prototype.endValue; /** * The minimum number of free cells needed to fit the label in the first row. * @type {?} */ NgxMatCalendarBody.prototype.labelMinRequiredCells; /** * The number of columns in the table. * @type {?} */ NgxMatCalendarBody.prototype.numCols; /** * The cell number of the active cell in the table. * @type {?} */ NgxMatCalendarBody.prototype.activeCell; /** * Whether a range is being selected. * @type {?} */ NgxMatCalendarBody.prototype.isRange; /** * The aspect ratio (width / height) to use for the cells in the table. This aspect ratio will be * maintained even as the table resizes. * @type {?} */ NgxMatCalendarBody.prototype.cellAspectRatio; /** * Start of the comparison range. * @type {?} */ NgxMatCalendarBody.prototype.comparisonStart; /** * End of the comparison range. * @type {?} */ NgxMatCalendarBody.prototype.comparisonEnd; /** * Start of the preview range. * @type {?} */ NgxMatCalendarBody.prototype.previewStart; /** * End of the preview range. * @type {?} */ NgxMatCalendarBody.prototype.previewEnd; /** * Emits when a new value is selected. * @type {?} */ NgxMatCalendarBody.prototype.selectedValueChange; /** * Emits when the preview has changed as a result of a user action. * @type {?} */ NgxMatCalendarBody.prototype.previewChange; /** * The number of blank cells to put at the beginning for the first row. * @type {?} */ NgxMatCalendarBody.prototype._firstRowOffset; /** * Padding for the individual date cells. * @type {?} */ NgxMatCalendarBody.prototype._cellPadding; /** * Width of an individual cell. * @type {?} */ NgxMatCalendarBody.prototype._cellWidth; /** * Event handler for when the user enters an element * inside the calendar body (e.g. by hovering in or focus). * @type {?} * @private */ NgxMatCalendarBody.prototype._enterHandler; /** * Event handler for when the user's pointer leaves an element * inside the calendar body (e.g. by hovering out or blurring). * @type {?} * @private */ NgxMatCalendarBody.prototype._leaveHandler; /** * @type {?} * @private */ NgxMatCalendarBody.prototype._elementRef; /** * @type {?} * @private */ NgxMatCalendarBody.prototype._ngZone; } /** * Checks whether a node is a table cell element. * @param {?} node * @return {?} */ function isTableCell(node) { return node.nodeName === 'TD'; } /** * Checks whether a value is the start of a range. * @param {?} value * @param {?} start * @param {?} end * @return {?} */ function isStart(value, start, end) { return end !== null && start !== end && value < end && value === start; } /** * Checks whether a value is the end of a range. * @param {?} value * @param {?} start * @param {?} end * @return {?} */ function isEnd(value, start, end) { return start !== null && start !== end && value >= start && value === end; } /** * Checks whether a value is inside of a range. * @param {?} value * @param {?} start * @param {?} end * @param {?} rangeEnabled * @return {?} */ function isInRange(value, start, end, rangeEnabled) { return rangeEnabled && start !== null && end !== null && start !== end && value >= start && value <= end; } /** * @fileoverview added by tsickle * Generated from