UNPKG

ngx-mat-shift-selection

Version:

This is a simple date and time selection component design specificly for job shifts etc, with 24-hours available option.

936 lines (905 loc) 44.8 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('moment'), require('lodash'), require('@angular/forms'), require('@angular/common'), require('@angular/flex-layout'), require('@angular/material')) : typeof define === 'function' && define.amd ? define('ngx-mat-shift-selection', ['exports', '@angular/core', 'moment', 'lodash', '@angular/forms', '@angular/common', '@angular/flex-layout', '@angular/material'], factory) : (global = global || self, factory(global['ngx-mat-shift-selection'] = {}, global.ng.core, global.moment, global._, global.ng.forms, global.ng.common, global.ng['flex-layout'], global.ng.material)); }(this, (function (exports, core, _moment, lodash, forms, common, flexLayout, material) { 'use strict'; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ /* 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) { 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) : new P(function (resolve) { resolve(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 }; } } function __exportStar(m, exports) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } function __values(o) { var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; if (m) return m.call(o); return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; } 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; }; 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)) result[k] = mod[k]; result.default = mod; return result; } function __importDefault(mod) { return (mod && mod.__esModule) ? mod : { default: mod }; } /** * @fileoverview added by tsickle * Generated from: lib/ngx-mat-shift-selection.service.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var NgxMatShiftSelectionService = /** @class */ (function () { function NgxMatShiftSelectionService() { } NgxMatShiftSelectionService.decorators = [ { type: core.Injectable, args: [{ providedIn: 'root' },] } ]; /** @nocollapse */ NgxMatShiftSelectionService.ctorParameters = function () { return []; }; /** @nocollapse */ NgxMatShiftSelectionService.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function NgxMatShiftSelectionService_Factory() { return new NgxMatShiftSelectionService(); }, token: NgxMatShiftSelectionService, providedIn: "root" }); return NgxMatShiftSelectionService; }()); /** * @fileoverview added by tsickle * Generated from: lib/ngx-mat-shift-selection.component.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ var moment = _moment; var NgxMatShiftSelectionComponent = /** @class */ (function () { function NgxMatShiftSelectionComponent() { this.currentDate = moment(); this.dayNames = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; this.weeks = []; this.sortedDates = []; this.selectAll = false; this.availableAll = false; this.time = [ "00:00", "00:30", "01:00", "01:30", "02:00", "02:30", "03:00", "03:30", "04:00", "04:30", "05:00", "05:30", "06:00", "06:30", "07:00", "07:30", "08:00", "08:30", "09:00", "09:30", "10:00", "10:30", "11:00", "11:30", "12:00", "12:30", "13:00", "13:30", "14:00", "14:30", "15:00", "15:30", "16:00", "16:30", "17:00", "17:30", "18:00", "18:30", "19:00", "19:30", "20:00", "20:30", "21:00", "21:30", "22:00", "22:30", "23:00", "23:30" ]; this.selectedDates = []; this.calendarType = "month"; this.class = ""; this.onSelectDate = new core.EventEmitter(); } /** * @return {?} */ NgxMatShiftSelectionComponent.prototype.ngOnInit = /** * @return {?} */ function () { this.generateCalendar(); }; /** * @param {?} changes * @return {?} */ NgxMatShiftSelectionComponent.prototype.ngOnChanges = /** * @param {?} changes * @return {?} */ function (changes) { if (changes.selectedDates && changes.selectedDates.currentValue && changes.selectedDates.currentValue.length > 1) { // sort on date changes for better performance when range checking this.sortedDates = lodash.sortBy(changes.selectedDates.currentValue, (/** * @param {?} m * @return {?} */ function (m) { return m.mDate.valueOf(); })); this.generateCalendar(); } }; /** * @param {?} date * @return {?} */ NgxMatShiftSelectionComponent.prototype.selectDate = /** * @param {?} date * @return {?} */ function (date) { return __awaiter(this, void 0, void 0, function () { var _a; return __generator(this, function (_b) { switch (_b.label) { case 0: date.selected = !date.selected; date.isFullTime = false; if (!!date.selected) return [3 /*break*/, 2]; return [4 /*yield*/, lodash.remove(this.selectedDates, (/** * @param {?} v * @return {?} */ function (v) { return v.mDate.format("ll") == date.mDate.format("ll"); }))]; case 1: _b.sent(); return [3 /*break*/, 3]; case 2: date.startTime = ""; date.endTime = ""; date.isTimerVisible = this.weeks[0][1].mDate.week() == date.mDate.week() && !this.isPast(date.mDate); if (!this.isDuplicate(date.mDate)) this.selectedDates.push(date); _b.label = 3; case 3: _a = this; return [4 /*yield*/, lodash.sortBy(this.selectedDates, (/** * @param {?} m * @return {?} */ function (m) { return m.mDate.valueOf(); }))]; case 4: _a.sortedDates = _b.sent(); this.selectAll = this.areAllSelected(); this.availableAll = this.areAllAvailable(); this.onSelectDate.emit(this.sortedDates); return [2 /*return*/]; } }); }); }; // date checkers // date checkers /** * @param {?} date * @return {?} */ NgxMatShiftSelectionComponent.prototype.isToday = // date checkers /** * @param {?} date * @return {?} */ function (date) { return moment().isSame(moment(date), "day"); }; /** * @param {?} date * @return {?} */ NgxMatShiftSelectionComponent.prototype.isSelected = /** * @param {?} date * @return {?} */ function (date) { return (lodash.findIndex(this.selectedDates, (/** * @param {?} selectedDate * @return {?} */ function (selectedDate) { return moment(date).isSame(selectedDate.mDate, "day"); })) > -1); }; /** * @param {?} date * @return {?} */ NgxMatShiftSelectionComponent.prototype.isDuplicate = /** * @param {?} date * @return {?} */ function (date) { return (lodash.findIndex(this.selectedDates, (/** * @param {?} selectedDate * @return {?} */ function (selectedDate) { return moment(date).isSame(selectedDate.mDate, "day"); })) > -1); }; /** * @return {?} */ NgxMatShiftSelectionComponent.prototype.areAllSelected = /** * @return {?} */ function () { var e_1, _a; try { for (var _b = __values(this.weeks[0]), _c = _b.next(); !_c.done; _c = _b.next()) { var v = _c.value; if (!v.selected && !this.isPast(v.mDate)) return false; } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_1) throw e_1.error; } } return true; }; /** * @return {?} */ NgxMatShiftSelectionComponent.prototype.areAllAvailable = /** * @return {?} */ function () { var e_2, _a, e_3, _b; try { for (var _c = __values(this.sortedDates), _d = _c.next(); !_d.done; _d = _c.next()) { var v = _d.value; if (!v.isFullTime && v.isTimerVisible) return false; } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (_d && !_d.done && (_a = _c.return)) _a.call(_c); } finally { if (e_2) throw e_2.error; } } try { for (var _e = __values(this.weeks[0]), _f = _e.next(); !_f.done; _f = _e.next()) { var v = _f.value; if (!v.selected) return false; } } catch (e_3_1) { e_3 = { error: e_3_1 }; } finally { try { if (_f && !_f.done && (_b = _e.return)) _b.call(_e); } finally { if (e_3) throw e_3.error; } } return true; }; /** * @param {?} date * @return {?} */ NgxMatShiftSelectionComponent.prototype.isFullTime = /** * @param {?} date * @return {?} */ function (date) { return (lodash.findIndex(this.selectedDates, (/** * @param {?} selectedDate * @return {?} */ function (selectedDate) { return (moment(date).isSame(selectedDate.mDate, "day") && selectedDate.isFullTime); })) > -1); }; /** * @param {?} date * @return {?} */ NgxMatShiftSelectionComponent.prototype.isSelectedMonth = /** * @param {?} date * @return {?} */ function (date) { return moment(date).isSame(this.currentDate, "month"); }; /** * @param {?} date * @return {?} */ NgxMatShiftSelectionComponent.prototype.isPast = /** * @param {?} date * @return {?} */ function (date) { return moment(date).isBefore(moment().subtract(1, "day")); }; // actions from calendar // actions from calendar /** * @return {?} */ NgxMatShiftSelectionComponent.prototype.prevMonth = // actions from calendar /** * @return {?} */ function () { this.currentDate = moment(this.currentDate).subtract(1, "months"); this.generateCalendar(); }; /** * @return {?} */ NgxMatShiftSelectionComponent.prototype.nextMonth = /** * @return {?} */ function () { this.currentDate = moment(this.currentDate).add(1, "months"); this.generateCalendar(); }; /** * @return {?} */ NgxMatShiftSelectionComponent.prototype.nextWeek = /** * @return {?} */ function () { this.currentDate = moment(this.currentDate).add(1, "week"); this.generateCalendar(); }; /** * @return {?} */ NgxMatShiftSelectionComponent.prototype.prevWeek = /** * @return {?} */ function () { this.currentDate = moment(this.currentDate).subtract(1, "week"); this.generateCalendar(); }; /** * @return {?} */ NgxMatShiftSelectionComponent.prototype.firstMonth = /** * @return {?} */ function () { this.currentDate = moment(this.currentDate).startOf("year"); this.generateCalendar(); }; /** * @return {?} */ NgxMatShiftSelectionComponent.prototype.lastMonth = /** * @return {?} */ function () { this.currentDate = moment(this.currentDate).endOf("year"); this.generateCalendar(); }; /** * @return {?} */ NgxMatShiftSelectionComponent.prototype.prevYear = /** * @return {?} */ function () { this.currentDate = moment(this.currentDate).subtract(1, "year"); this.generateCalendar(); }; /** * @return {?} */ NgxMatShiftSelectionComponent.prototype.nextYear = /** * @return {?} */ function () { this.currentDate = moment(this.currentDate).add(1, "year"); this.generateCalendar(); }; // generate the calendar grid // generate the calendar grid /** * @return {?} */ NgxMatShiftSelectionComponent.prototype.generateCalendar = // generate the calendar grid /** * @return {?} */ function () { var e_4, _a; /** @type {?} */ var dates = this.fillDates(this.currentDate); /** @type {?} */ var weeks = []; while (dates.length > 0) { weeks.push(dates.splice(0, 7)); } try { for (var _b = __values(this.sortedDates), _c = _b.next(); !_c.done; _c = _b.next()) { var v = _c.value; v.isTimerVisible = weeks[0][1].mDate.week() == v.mDate.week() && !this.isPast(v.mDate); } } catch (e_4_1) { e_4 = { error: e_4_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_4) throw e_4.error; } } this.weeks = weeks; this.selectAll = this.areAllSelected(); this.availableAll = this.areAllAvailable(); }; /** * @param {?} currentMoment * @return {?} */ NgxMatShiftSelectionComponent.prototype.fillDates = /** * @param {?} currentMoment * @return {?} */ function (currentMoment) { var _this = this; if (this.calendarType == "week") { /** @type {?} */ var firstOfWeek = moment(currentMoment) .startOf("week") .day(); /** @type {?} */ var firstDayOfGrid_1 = moment(currentMoment) .startOf("week") .subtract(firstOfWeek, "days"); /** @type {?} */ var start_1 = firstDayOfGrid_1.date(); return lodash.range(start_1, start_1 + 7).map((/** * @param {?} date * @return {?} */ function (date) { /** @type {?} */ var d = moment(firstDayOfGrid_1).date(date); return { today: _this.isToday(d), selected: _this.isSelected(d), mDate: d, startTime: undefined, endTime: undefined, isTimerVisible: false, isFullTime: _this.isFullTime(d) }; })); } /** @type {?} */ var firstOfMonth = moment(currentMoment) .startOf("month") .day(); /** @type {?} */ var firstDayOfGrid = moment(currentMoment) .startOf("month") .subtract(firstOfMonth, "days"); /** @type {?} */ var start = firstDayOfGrid.date(); return lodash.range(start, start + 35).map((/** * @param {?} date * @return {?} */ function (date) { /** @type {?} */ var d = moment(firstDayOfGrid).date(date); return { today: _this.isToday(d), selected: _this.isSelected(d), mDate: d, startTime: undefined, endTime: undefined, isTimerVisible: false, isFullTime: _this.isFullTime(d) }; })); }; /** * @param {?} val * @return {?} */ NgxMatShiftSelectionComponent.prototype.timeChanged = /** * @param {?} val * @return {?} */ function (val) { val.isFullTime = val.startTime == "00:00" && val.endTime == "23:59" && this.weeks[0].map((/** * @param {?} v * @return {?} */ function (v) { if (v.mDate.format("ll") == val.mDate.format("ll")) { v.isFullTime = val.isFullTime; } })); this.availableAll = this.areAllAvailable(); this.onSelectDate.emit(this.sortedDates); }; /** * @param {?} val * @return {?} */ NgxMatShiftSelectionComponent.prototype.fullTimeChecked = /** * @param {?} val * @return {?} */ function (val) { val.startTime = val.isFullTime ? "00:00" : ""; val.endTime = val.isFullTime ? "23:59" : ""; for (var v in this.sortedDates) { if (this.sortedDates[v].mDate.format("ll") == val.mDate.format("ll")) { this.sortedDates[v].startTime = val.startTime; this.sortedDates[v].endTime = val.endTime; } } this.timeChanged(val); }; /** * @return {?} */ NgxMatShiftSelectionComponent.prototype.selectAllChecked = /** * @return {?} */ function () { var e_5, _a; try { for (var _b = __values(this.weeks[0]), _c = _b.next(); !_c.done; _c = _b.next()) { var v = _c.value; v.selected = this.selectAll; this.selectDate(v); } } catch (e_5_1) { e_5 = { error: e_5_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_5) throw e_5.error; } } }; /** * @return {?} */ NgxMatShiftSelectionComponent.prototype.availableAllChecked = /** * @return {?} */ function () { return __awaiter(this, void 0, void 0, function () { var _loop_1, this_1, _a, _b, v; var e_6, _c; return __generator(this, function (_d) { this.availableAll = !this.availableAll; _loop_1 = function (v) { v.isFullTime = v.isTimerVisible ? this_1.availableAll : v.isFullTime; v.startTime = v.isFullTime ? "00:00" : ""; v.endTime = v.isFullTime ? "23:59" : ""; this_1.weeks[0].map((/** * @param {?} val * @return {?} */ function (val) { if (val.mDate.format("ll") == v.mDate.format("ll")) { val.isFullTime = v.isFullTime; } })); }; this_1 = this; try { for (_a = __values(this.sortedDates), _b = _a.next(); !_b.done; _b = _a.next()) { v = _b.value; _loop_1(v); } } catch (e_6_1) { e_6 = { error: e_6_1 }; } finally { try { if (_b && !_b.done && (_c = _a.return)) _c.call(_a); } finally { if (e_6) throw e_6.error; } } this.onSelectDate.emit(this.sortedDates); return [2 /*return*/]; }); }); }; /** * @return {?} */ NgxMatShiftSelectionComponent.prototype.timeSelected = /** * @return {?} */ function () { this.onSelectDate.emit(this.sortedDates); }; NgxMatShiftSelectionComponent.decorators = [ { type: core.Component, args: [{ selector: "ngx-mat-shift-selection", template: "<div fxLayout=\"column\" [ngClass]=\"class\" class=\"calendar\">\n <div fxLayout=\"column\" class=\"calendar-navs\" *ngIf=\"calendarType != 'week'\">\n <div class=\"month-nav\" fxLayout=\"row\" fxLayoutAlign=\"space-between center\">\n <button mat-icon-button (click)=\"prevMonth()\">\n <mat-icon>arrow_back_ios</mat-icon>\n </button>\n <span class=\"title p4 mt-1\">{{ currentDate.format(\"MMMM\") }}</span>\n <button mat-icon-button (click)=\"nextMonth()\">\n <mat-icon>arrow_forward_ios</mat-icon>\n </button>\n </div>\n <div class=\"year-nav\" fxLayout=\"row\" fxLayoutAlign=\"space-between center\">\n <button mat-icon-button (click)=\"prevYear()\">\n <mat-icon>arrow_back_ios</mat-icon>\n </button>\n <span class=\"mt-1\">{{ currentDate.format(\"YYYY\") }}</span>\n <button mat-icon-button (click)=\"nextYear()\">\n <mat-icon>arrow_forward_ios</mat-icon>\n </button>\n </div>\n </div>\n <div fxLayout=\"column\" class=\"calendar-navs\" *ngIf=\"calendarType == 'week'\">\n <div class=\"month-nav\" fxLayout=\"row\" fxLayoutAlign=\"space-between center\">\n <button mat-icon-button (click)=\"prevWeek()\">\n <mat-icon>arrow_back_ios</mat-icon>\n </button>\n <span class=\"title p4 mt-1\">{{ currentDate.format(\"MMMM YYYY\") }}</span>\n <button mat-icon-button (click)=\"nextWeek()\">\n <mat-icon>arrow_forward_ios</mat-icon>\n </button>\n </div>\n </div>\n <mat-divider></mat-divider>\n <div fxLayout=\"column\" class=\"month-grid\">\n <div class=\"day-names\" fxLayout=\"row\" fxLayoutAlign=\"space-between center\">\n <div\n fxFlex=\"14\"\n *ngFor=\"let name of dayNames\"\n class=\"day-name p9\"\n style=\"text-align: center;\"\n >\n {{ name }}\n </div>\n </div>\n <div class=\"weeks\" fxLayout=\"column\">\n <div\n *ngFor=\"let week of weeks\"\n class=\"week\"\n style=\"text-align: center;\"\n fxLayout=\"row\"\n fxLayoutAlign=\"space-between center\"\n >\n <ng-container *ngFor=\"let day of week\">\n <div fxFlex=\"14\" class=\"week-date disabled\" *ngIf=\"isPast(day.mDate)\">\n <span class=\"date-text\">{{ day.mDate.date() }}</span>\n </div>\n <div\n fxFlex=\"14\"\n class=\"week-date enabled\"\n *ngIf=\"!isPast(day.mDate)\"\n (click)=\"selectDate(day)\"\n >\n <div\n fxLayout=\"row\"\n fxLayoutAlign=\"center center\"\n [ngClass]=\"{\n today: day.today,\n fullTimeSelected: day.isFullTime,\n selected: day.selected\n }\"\n >\n <span class=\"date-text\">{{ day.mDate.date() }}</span>\n </div>\n </div>\n </ng-container>\n </div>\n </div>\n </div>\n <mat-divider></mat-divider>\n <div class=\"row justify-content-between p-05\">\n <div class=\"col-12 mb-1\">\n Select All Days\n <mat-checkbox\n [checked]=\"selectAll\"\n (change)=\"selectAllChecked()\"\n ></mat-checkbox>\n </div>\n </div>\n <mat-divider></mat-divider>\n <ng-container *ngIf=\"sortedDates.length > 0\">\n <div class=\"p-05\" fxLayout=\"row\" fxLayoutAlign=\"start center\">\n <div fxFlex=\"50\">Select Available Time</div>\n <div fxFlex=\"50\" class=\"text-right\">\n <mat-checkbox\n [checked]=\"availableAll\"\n (change)=\"availableAllChecked()\"\n >\n </mat-checkbox>\n Available 24 Hours\n </div>\n </div>\n <mat-divider></mat-divider>\n </ng-container>\n <div *ngFor=\"let availableDate of sortedDates\">\n <div class=\"mt-1\" *ngIf=\"availableDate.isTimerVisible\">\n <div fxLayout=\"row\" fxLayoutAlign=\"start center\" class=\"p-05\">\n <div fxFlex=\"50\">{{ availableDate.mDate.format(\"LL\") }}</div>\n <div fxFlex=\"50\" class=\"text-right\">\n <mat-checkbox\n [(ngModel)]=\"availableDate.isFullTime\"\n (ngModelChange)=\"fullTimeChecked(availableDate)\"\n aria-label=\"Checkbox for following text input\"\n >\n </mat-checkbox>\n Available 24 Hours\n </div>\n </div>\n <div\n fxLayout=\"row\"\n fxLayoutAlign=\"start center\"\n *ngIf=\"!availableDate.isFullTime\"\n class=\"p-05\"\n >\n <mat-form-field fxFlex=\"40\">\n <input\n type=\"text\"\n placeholder=\"Start Time\"\n aria-label=\"Number\"\n matInput\n [(ngModel)]=\"availableDate.startTime\"\n [matAutocomplete]=\"auto\"\n (ngModelChange)=\"timeSelected()\"\n />\n <mat-autocomplete #auto=\"matAutocomplete\">\n <mat-option *ngFor=\"let option of time\" [value]=\"option\">\n {{ option }}\n </mat-option>\n </mat-autocomplete>\n </mat-form-field>\n <span class=\"text-center\" fxFlex=\"20\">to</span>\n <mat-form-field fxFlex=\"40\">\n <input\n type=\"text\"\n placeholder=\"End Time\"\n aria-label=\"Number\"\n matInput\n [(ngModel)]=\"availableDate.endTime\"\n [matAutocomplete]=\"auto\"\n (ngModelChange)=\"timeSelected()\"\n />\n <mat-autocomplete #auto=\"matAutocomplete\">\n <mat-option *ngFor=\"let option of time\" [value]=\"option\">\n {{ option }}\n </mat-option>\n </mat-autocomplete>\n </mat-form-field>\n </div>\n <mat-divider></mat-divider>\n </div>\n </div>\n</div>\n", styles: [".calendar{display:block;min-width:calc(45px * 7);background-color:transparent}.calendar *{box-sizing:border-box}.calendar .calendar-navs{background-color:transparent}.calendar .month-nav{padding:5px;display:flex;flex-direction:row;justify-content:space-between}.calendar .year-nav{padding:5px;display:flex;flex-direction:row;justify-content:space-between;font-family:Montserrat}.calendar .month-grid .day-names{display:flex;flex-direction:row;border-bottom-right-radius:3px;border-bottom-left-radius:3px}.calendar .month-grid .weeks{display:flex;flex-direction:column}.calendar .month-grid .week{display:flex;flex-direction:row}.calendar .month-grid .day-name,.calendar .month-grid .week-date{text-align:center;padding:5px;display:block;width:45px;display:flex;justify-content:center;align-items:center;font-size:1rem}.calendar .month-grid .day-name{color:#28a1e5}.calendar .month-grid .week-date{height:45px;position:relative;border-radius:50%}.calendar .month-grid .week-date .date-text{z-index:10;font-size:1rem;font-family:Montserrat,sans-serif}.calendar .month-grid .week-date::after{content:\"\";height:calc(45px * .9);width:calc(45px * .9);position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);border-radius:50%;transition:background-color 150ms linear,color 150ms linear;z-index:1}.calendar .month-grid .week-date.enabled{cursor:pointer}.calendar .month-grid .week-date.enabled:hover{opacity:.6}.calendar .month-grid .week-date .selected,.calendar .month-grid .week-date .selected:after{background-color:#28a1e5;color:#fff;width:34px;height:34px;border-radius:50%}.calendar .month-grid .week-date .selected:hover:after{background-color:transparent;width:34px;height:34px;border-radius:50%}.calendar .month-grid .week-date .fullTimeSelected,.calendar .month-grid .week-date .fullTimeSelected:after{background-color:#757374!important;color:#fff;width:34px;height:34px;border-radius:50%}.calendar .month-grid .week-date .fullTimeSelected:hover:after{background-color:transparent;width:34px;height:34px;border-radius:50%}.calendar .month-grid .week-date.disabled{opacity:.6}.calendar .month-grid .today{font-weight:700}.to-span{padding-top:2.5rem;margin-left:1rem;margin-right:1rem}.p-05{padding:.5rem}.time-selector{display:inline-flex}.title{font-size:1.2rem;font-weight:700}.hr-margin{margin-top:1px;margin-bottom:1px}.text-center{text-align:center}.text-right{text-align:right}*{font-size:.8rem}"] }] } ]; /** @nocollapse */ NgxMatShiftSelectionComponent.ctorParameters = function () { return []; }; NgxMatShiftSelectionComponent.propDecorators = { selectedDates: [{ type: core.Input }], calendarType: [{ type: core.Input }], class: [{ type: core.Input }], onSelectDate: [{ type: core.Output }] }; return NgxMatShiftSelectionComponent; }()); if (false) { /** @type {?} */ NgxMatShiftSelectionComponent.prototype.currentDate; /** @type {?} */ NgxMatShiftSelectionComponent.prototype.dayNames; /** @type {?} */ NgxMatShiftSelectionComponent.prototype.weeks; /** @type {?} */ NgxMatShiftSelectionComponent.prototype.sortedDates; /** @type {?} */ NgxMatShiftSelectionComponent.prototype.selectAll; /** @type {?} */ NgxMatShiftSelectionComponent.prototype.availableAll; /** @type {?} */ NgxMatShiftSelectionComponent.prototype.time; /** @type {?} */ NgxMatShiftSelectionComponent.prototype.selectedDates; /** @type {?} */ NgxMatShiftSelectionComponent.prototype.calendarType; /** @type {?} */ NgxMatShiftSelectionComponent.prototype.class; /** @type {?} */ NgxMatShiftSelectionComponent.prototype.onSelectDate; } /** * @record */ function CalendarDate() { } if (false) { /** @type {?} */ CalendarDate.prototype.mDate; /** @type {?|undefined} */ CalendarDate.prototype.selected; /** @type {?|undefined} */ CalendarDate.prototype.today; /** @type {?} */ CalendarDate.prototype.startTime; /** @type {?} */ CalendarDate.prototype.endTime; /** @type {?|undefined} */ CalendarDate.prototype.isTimerVisible; /** @type {?|undefined} */ CalendarDate.prototype.isFullTime; } /** * @fileoverview added by tsickle * Generated from: lib/ngx-mat-shift-selection.module.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var NgxMatShiftSelectionModule = /** @class */ (function () { function NgxMatShiftSelectionModule() { } NgxMatShiftSelectionModule.decorators = [ { type: core.NgModule, args: [{ declarations: [NgxMatShiftSelectionComponent], imports: [ common.CommonModule, forms.FormsModule, flexLayout.FlexLayoutModule, material.MatFormFieldModule, material.MatInputModule, material.MatAutocompleteModule, material.MatCheckboxModule, material.MatDividerModule, material.MatButtonModule, material.MatIconModule ], exports: [NgxMatShiftSelectionComponent] },] } ]; return NgxMatShiftSelectionModule; }()); exports.NgxMatShiftSelectionComponent = NgxMatShiftSelectionComponent; exports.NgxMatShiftSelectionModule = NgxMatShiftSelectionModule; exports.NgxMatShiftSelectionService = NgxMatShiftSelectionService; Object.defineProperty(exports, '__esModule', { value: true }); }))); //# sourceMappingURL=ngx-mat-shift-selection.umd.js.map