mat-daterangepicker
Version:
Angular material date picker extension to support range selection.
16 lines (14 loc) • 34.7 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common"),require("@angular/cdk/a11y"),require("@angular/cdk/overlay"),require("@angular/cdk/portal"),require("@angular/material/core"),require("@angular/material/button"),require("@angular/material/dialog"),require("@angular/material/datepicker"),require("rxjs"),require("@angular/cdk/bidi"),require("rxjs/operators"),require("@angular/forms"),require("@angular/material/form-field"),require("@angular/material/input")):"function"==typeof define&&define.amd?define("mat-daterangepicker",["exports","@angular/core","@angular/common","@angular/cdk/a11y","@angular/cdk/overlay","@angular/cdk/portal","@angular/material/core","@angular/material/button","@angular/material/dialog","@angular/material/datepicker","rxjs","@angular/cdk/bidi","rxjs/operators","@angular/forms","@angular/material/form-field","@angular/material/input"],t):t((e=e||self)["mat-daterangepicker"]={},e.ng.core,e.ng.common,e.ng.cdk.a11y,e.ng.cdk.overlay,e.ng.cdk.portal,e.ng.material.core,e.ng.material.button,e.ng.material.dialog,e.ng.material.datepicker,e.rxjs,e.ng.cdk.bidi,e.rxjs.operators,e.ng.forms,e.ng.material.formField,e.ng.material.input)}(this,(function(e,t,a,n,r,i,o,d,s,l,c,p,u,g,h,m){"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.
***************************************************************************** */var y=function(e,t){return(y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var a in t)t.hasOwnProperty(a)&&(e[a]=t[a])})(e,t)};function D(e,t){function a(){this.constructor=e}y(e,t),e.prototype=null===t?Object.create(t):(a.prototype=t.prototype,new a)}function _(e,t,a,n){var r,i=arguments.length,o=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,a):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,a,n);else for(var d=e.length-1;d>=0;d--)(r=e[d])&&(o=(i<3?r(o):i>3?r(t,a,o):r(t,a))||o);return i>3&&o&&Object.defineProperty(t,a,o),o}function f(e,t){return function(a,n){t(a,n,e)}}function v(e,t,a,n){return new(a||(a=Promise))((function(r,i){function o(e){try{s(n.next(e))}catch(e){i(e)}}function d(e){try{s(n.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof a?t:new a((function(e){e(t)}))).then(o,d)}s((n=n.apply(e,t||[])).next())}))}function b(e,t){var a,n,r,i,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:d(0),throw:d(1),return:d(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function d(i){return function(d){return function(i){if(a)throw new TypeError("Generator is already executing.");for(;o;)try{if(a=1,n&&(r=2&i[0]?n.return:i[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,i[1])).done)return r;switch(n=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,n=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){o.label=i[1];break}if(6===i[0]&&o.label<r[1]){o.label=r[1],r=i;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(i);break}r[2]&&o.ops.pop(),o.trys.pop();continue}i=t.call(e,o)}catch(e){i=[6,e],n=0}finally{a=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,d])}}}var R=function(e){function a(a,n,r,i,o){var d=e.call(this,a,n,r,i)||this;return d.drInjector=o,d.selectedRangeEndChange=new t.EventEmitter,d}return D(a,e),a.prototype.ngAfterContentInit=function(){e.prototype.ngAfterContentInit.call(this);var a=t.ReflectiveInjector.resolveAndCreate([{provide:l.MatCalendar,useValue:this}],this.drInjector);this._calendarHeaderPortal.injector=a;var n=this.startAt||this._dateAdapter.today();this.activeDate=0===this.view?n:this.getSecondViewActiveDate(n)},Object.defineProperty(a.prototype,"selectedRangeEnd",{get:function(){return this._selectedRangeEnd},set:function(e){this._selectedRangeEnd=this._getValidDateOrNull(this._dateAdapter.deserialize(e))},enumerable:!0,configurable:!0}),a.prototype._dateSelectedRangeEnd=function(e){this._dateAdapter.sameDate(e,this.selectedRangeEnd)||this.selectedRangeEndChange.emit(e)},a.prototype.getSecondViewActiveDate=function(e){var t,a,n=this._dateAdapter.getDate(e),r=this._dateAdapter.getMonth(e),i=this._dateAdapter.getYear(e);return 11===r?(a=0,t=i+1):(a=r+1,t=i),this._dateAdapter.createDate(t,a,n)},a.ctorParameters=function(){return[{type:l.MatDatepickerIntl},{type:o.DateAdapter,decorators:[{type:t.Optional}]},{type:void 0,decorators:[{type:t.Optional},{type:t.Inject,args:[o.MAT_DATE_FORMATS]}]},{type:t.ChangeDetectorRef},{type:t.Injector}]},_([t.Input()],a.prototype,"view",void 0),_([t.Input()],a.prototype,"setHoverCells",void 0),_([t.Input()],a.prototype,"clearBody",void 0),_([t.Input()],a.prototype,"range",void 0),_([t.Input()],a.prototype,"selectedRangeEnd",null),_([t.Output()],a.prototype,"selectedRangeEndChange",void 0),a=_([t.Component({selector:"mat-daterange-calendar",template:'\x3c!-- \n\tRANGE: Most of the code is redundant and hera as inheritance boilerplate.\n\tThe relevant code is marked with a comment.\n\tADDED LOC ~3\n--\x3e\n<ng-template [cdkPortalOutlet]="_calendarHeaderPortal"></ng-template>\n\n<div class="mat-calendar-content" [ngSwitch]="currentView" cdkMonitorSubtreeFocus tabindex="-1">\n\n\t<mat-daterange-month-view\n\t\t*ngSwitchCase="\'month\'"\n\t\t[view]="view"\n\t\t[activeDate]="activeDate"\n\t\t[selected]="selected"\n\t\t[dateFilter]="dateFilter"\n\t\t[maxDate]="maxDate"\n\t\t[minDate]="minDate"\n\t\t(selectedChange)="_dateSelected($event)"\n\t\t(_userSelection)="_userSelected()"\n\n\t\t[range]="range"\n\t\t[setHoverCells]="setHoverCells"\n\t\t[clearBody]="clearBody"\n\t\t[selectedRangeEnd]="selectedRangeEnd"\n\t\t(selectedRangeEndChange)="_dateSelectedRangeEnd($event)">\n\t\t\x3c!-- THE 3 LINES ABOVE ARE THE ONLY ADDITION --\x3e\n\t</mat-daterange-month-view>\n\n\t<mat-year-view\n\t\t*ngSwitchCase="\'year\'"\n\t\t[activeDate]="activeDate"\n\t\t[selected]="selected"\n\t\t[dateFilter]="dateFilter"\n\t\t[maxDate]="maxDate"\n\t\t[minDate]="minDate"\n\t\t(monthSelected)="_monthSelectedInYearView($event)"\n\t\t(selectedChange)="_goToDateInView($event, \'month\')">\n\t</mat-year-view>\n\n\t<mat-multi-year-view\n\t\t*ngSwitchCase="\'multi-year\'"\n\t\t[activeDate]="activeDate"\n\t\t[selected]="selected"\n\t\t[dateFilter]="dateFilter"\n\t\t[maxDate]="maxDate"\n\t\t[minDate]="minDate"\n\t\t(yearSelected)="_yearSelectedInMultiYearView($event)"\n\t\t(selectedChange)="_goToDateInView($event, \'year\')">\n\t</mat-multi-year-view>\n</div>\n\n',host:{class:"mat-calendar"},exportAs:"matDaterangeCalendar",encapsulation:t.ViewEncapsulation.None,changeDetection:t.ChangeDetectionStrategy.OnPush}),f(1,t.Optional()),f(2,t.Optional()),f(2,t.Inject(o.MAT_DATE_FORMATS))],a)}(l.MatCalendar),E=function(e){function a(){var a=null!==e&&e.apply(this,arguments)||this;return a._onApplyRange=new t.EventEmitter,a.setHoverCells=new c.BehaviorSubject(null),a.clearBody=new c.BehaviorSubject(null),a}return D(a,e),Object.defineProperty(a.prototype,"drDatepicker",{get:function(){return this.datepicker},enumerable:!0,configurable:!0}),a.prototype.ngOnInit=function(){},a.prototype.ngAfterViewInit=function(){},a.prototype.onUserSelection=function(e){this.drDatepicker._userSelection()},a.prototype.applyRange=function(){this.drDatepicker.applyButton&&this.drDatepicker.applyRange()},a.prototype.clearRange=function(){this.drDatepicker.clearRange(),this.clearBody.next(!0),this.datepicker._selected=null,this.drDatepicker._selectedRangeEnd=null},a.prototype.setCustomRange=function(e){e.startDate&&e.endDate&&(this.datepicker._selected=e.startDate,this.drDatepicker._selectedRangeEnd=e.endDate,this.datepicker._selectedChanged.next(e.startDate),this.drDatepicker._selectedChangedRangeEnd.next(e.endDate),this.setActiveDate(e.startDate,e.endDate))},a.prototype.isSameRange=function(e){if(this.datepicker._selected&&this.drDatepicker._selectedRangeEnd&&e.startDate&&e.endDate)return 0==this.drDatepicker._drDateAdapter.compareDate(e.startDate,this.datepicker._selected)&&0==this.drDatepicker._drDateAdapter.compareDate(e.endDate,this.drDatepicker._selectedRangeEnd)},a.prototype.isSomeRange=function(){var e=this;return!(!this.datepicker._selected||!this.drDatepicker._selectedRangeEnd)&&this.drDatepicker.customRanges.some((function(t){return e.isSameRange(t)}))},a.prototype.getWidthDateRangePicker=function(){return this.drDatepicker.dualView?this.drDatepicker.showCustomRanges&&this.drDatepicker.customRanges.length?"655px":"600px":this.drDatepicker.showCustomRanges&&this.drDatepicker.customRanges.length?"450px":void 0},a.prototype.setActiveDate=function(e,t){var a,n,r=this.drDatepicker._drDateAdapter.getMonth(e),i=this.drDatepicker._drDateAdapter.getMonth(t),o=this.drDatepicker._drDateAdapter.getYear(t);this.drDatepicker._drDateAdapter.getDate(t);11===i?(n=0,a=o+1):(n=i+1,a=o);var d=this.drDatepicker._drDateAdapter.createDate(a,n,1);this.calendars.forEach((function(a,n){a.activeDate=0===n?e:r!==i?t:d}))},_([t.ViewChild(R,{static:!0})],a.prototype,"_calendar",void 0),_([t.ViewChildren(R)],a.prototype,"calendars",void 0),a=_([t.Component({selector:"mat-daterangepicker-content",template:'<div>\n\t\x3c!-- \n\t\tRANGE: Most of the code is redundant and hera as inheritance boilerplate.\n\t\tThe relevant code is marked with a comment.\n\t\tADDED LOC ~3\n\t--\x3e\n\t<div class="mat-daterange-calendars" [ngStyle]="{\'width\': getWidthDateRangePicker()}">\n\t\t<div *ngIf="drDatepicker.showCustomRanges && drDatepicker.customRanges.length" class="mat-daterange-custom-ranges">\n\t\t\t<button *ngFor="let range of drDatepicker.customRanges" mat-flat-button [color]="isSameRange(range) ? \'primary\' : \'\'" (click)="setCustomRange(range)" class="mat-daterange-calendar-button-action">{{range.name}}</button>\n\t\t\t<button mat-flat-button [color]="!isSomeRange() ? \'primary\' : \'\'" class="mat-daterange-custom-range mat-daterange-calendar-button-action">Custom Range</button>\n\t\t</div>\n\t\t<mat-daterange-calendar *ngFor="let view of drDatepicker._getViews()" #Calendar cdkTrapFocus\n\t\t\t\t\t[id]="datepicker.id"\n\t\t\t\t\t[ngClass]="datepicker.panelClass"\n\t\t\t\t\tclass="mat-daterange-calendar"\n\t\t\t\t\t[view]="view"\n\t\t\t\t\t[setHoverCells]="setHoverCells"\n\t\t\t\t\t[clearBody]="clearBody"\n\t\t\t\t\t\n\t\t\t\t\t[startAt]="datepicker.startAt"\n\t\t\t\t\t[startView]="datepicker.startView"\n\t\t\t\t\t[minDate]="datepicker._minDate"\n\t\t\t\t\t[maxDate]="datepicker._maxDate"\n\t\t\t\t\t[dateFilter]="datepicker._dateFilter"\n\t\t\t\t\t[headerComponent]="datepicker.calendarHeaderComponent"\n\t\t\t\t\t[selected]="datepicker._selected"\n\t\t\t\t\t[@fadeInCalendar]="\'enter\'"\n\t\t\t\t\t(selectedChange)="datepicker.select($event)"\n\t\t\t\t\t(yearSelected)="datepicker._selectYear($event)"\n\t\t\t\t\t(monthSelected)="datepicker._selectMonth($event)"\n\n\t\t\t\t\t[range]="!!drDatepicker._datepickerInputRangeEnd"\n\t\t\t\t\t[selectedRangeEnd]="drDatepicker._selectedRangeEnd"\n\t\t\t\t\t(selectedRangeEndChange)="drDatepicker.selectRangeEnd($event)"\n\t\t\t\t\t(_userSelection)="onUserSelection(view)">\n\t\t\t\t\t\x3c!-- \n\t\t\t\t\t\t\tTHE 3 LINES ABOVE ARE THE ONLY ADDITION\n\t\t\t\t\t\t\tThe _userSelection will pass logic handling to the datepicker component\n\t\t\t\t\t\t\tinstead of closing the dialog/popup, this is because range logic is handled there.\n\n\t\t\t\t\t\t\tThe other attributes are passing on the additional date (Range end) bindings\n\t\t\t\t\t\t\tand a flag that sets range on/off based on the input range.\n\t\t\t\t\t\t\tThis means that an *ngIf on that input by the user can toggle range on/off without\n\t\t\t\t\t\t\ta special flag.\n\t\t\t\t\t--\x3e\n\n\t\t</mat-daterange-calendar>\n\t</div>\n\n\t<div *ngIf="drDatepicker.applyButton" class="mat-daterange-calendar-actions">\n\t\t<button mat-button color="primary" (click)="clearRange()">Clear</button> \n\t\t<button mat-flat-button color="primary" (click)="applyRange()">Apply</button>\n\t</div>\n</div>',host:{class:"mat-datepicker-content","[@transformPanel]":'"enter"',"[class.mat-datepicker-content-touch]":"datepicker.touchUi","[class.mat-datepicker-content-above]":"_isAbove"},animations:[l.matDatepickerAnimations.transformPanel,l.matDatepickerAnimations.fadeInCalendar],exportAs:"matDaterangepickerContent",encapsulation:t.ViewEncapsulation.None,changeDetection:t.ChangeDetectionStrategy.OnPush,inputs:["color"],styles:[".mat-daterange-calendar-body-in-range{background-color:rgba(63,81,181,.15)}.mat-daterange-calendar-body-in-range.mat-daterange-calendar-body-range-start{border-radius:100% 0 0 100%}.mat-daterange-calendar-body-in-range.mat-daterange-calendar-body-range-end{border-radius:0 100% 100% 0}.mat-daterange-calendars{display:flex}.mat-daterange-calendar{flex-grow:1}.mat-daterange-calendar-actions{padding:15px;text-align:right}.mat-daterange-custom-ranges{display:flex;flex-flow:column;width:130px;padding:8px}.mat-daterange-custom-ranges button{text-align:left;font-size:12px;line-height:32px;font-weight:400!important}.mat-daterange-calendar-button-action{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}"]})],a)}(l.MatDatepickerContent),w=function(){var e,t,a=(new Date).getFullYear(),n=(new Date).getMonth();return e=a,t=n+1,11===n&&(e=a+1,t=0),{name:"This Month",startDate:new Date(a,n,1),endDate:new Date(e,t,0)}},C=function(){var e,t,a,n,r=(new Date).getFullYear(),i=(new Date).getMonth();return e=r,t=i-1,a=r,n=i,0===i&&(e=r-1,t=11),{name:"Last Month",startDate:new Date(e,t,1),endDate:new Date(a,n,0)}},k=function(){var e,t,a,n,r=(new Date).getFullYear(),i=(new Date).getMonth();return e=r,a=r,n=i,(t=i-3)<0&&(e=r-1,t=12+t),{name:"Last 3 Months",startDate:new Date(e,t,1),endDate:new Date(a,n,0)}},A=[{name:"Today",startDate:new Date,endDate:new Date},{name:"Yesterday",startDate:new Date((new Date).setDate((new Date).getDate()-1)),endDate:new Date((new Date).setDate((new Date).getDate()-1))},{name:"Last 7 Days",startDate:new Date((new Date).setDate((new Date).getDate()-6)),endDate:new Date},{name:"Last 30 Days",startDate:new Date((new Date).setDate((new Date).getDate()-29)),endDate:new Date},w(),C(),k()],I=new t.InjectionToken("Custom Ranges"),S=[],M=function(e){function n(a,n,r,o,d,l,p,g,h){var m=e.call(this,a=Object.create(a),n,r,o,d,l,p,g)||this;return m._drOverlay=n,m._drNgZone=r,m._drViewContainerRef=o,m._drScrollStrategy=d,m._drDateAdapter=l,m._drDir=p,m._drDocument=g,m._customRanges=h,m.applyButton=!0,m.dualView=!0,m.showCustomRanges=!1,m.apply=new t.EventEmitter,m.customRanges=[],m._validSelectedRangeEnd=null,m._selectedChangedRangeEnd=new c.Subject,m._clearRangeEnd=new c.Subject,m._range=!1,m._inputRangeEndSubscription=c.Subscription.EMPTY,m._drDialog=a,m._drDialog.open=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return"function"!=typeof e[0].createEmbeddedView&&(e[0]=E),s.MatDialog.prototype.open.apply(a,e)},m._openAsPopup=function(){var e=new i.ComponentPortal(E,m._drViewContainerRef);m._destroyPopup(),m._createPopup(),m._popupComponentRef=m._popupRef.attach(e),m.forwardContentValues(m._popupComponentRef.instance),m._drNgZone.onStable.asObservable().pipe(u.take(1)).subscribe((function(){m._popupRef.updatePosition()}))},m}return D(n,e),Object.defineProperty(n.prototype,"_selectedRangeEnd",{get:function(){return this._validSelectedRangeEnd},set:function(e){this._validSelectedRangeEnd=e},enumerable:!0,configurable:!0}),n.prototype.ngOnInit=function(){this.customRanges&&this._setCustomRanges()},n.prototype.ngAfterViewInit=function(){},n.prototype.forwardContentValues=function(e){e.datepicker=this,e.color=this.color},n.prototype.ngOnDestroy=function(){e.prototype.ngOnDestroy.call(this),this._inputRangeEndSubscription.unsubscribe()},n.prototype.selectRangeEnd=function(t){if(this._range)if(t)if(!this._selected||this._selectedRangeEnd)this._selectedRangeEnd&&this._selectRangeEnd(null),e.prototype.select.call(this,t);else if(t<this._selected){var a=this._selected;e.prototype.select.call(this,t),this._selectRangeEnd(a)}else t>=this._selected&&this._selectRangeEnd(t);else this._selected&&this._selectedRangeEnd?(e.prototype.select.call(this,null),this._selectRangeEnd(null)):this._selected?e.prototype.select.call(this,null):this._selectedRangeEnd&&this._selectRangeEnd(null);else e.prototype.select.call(this,t)},n.prototype._userSelection=function(){this.applyButton||(!this._range||this._selected&&this._selectedRangeEnd)&&this.close()},n.prototype.applyRange=function(){this.close(),this.apply.emit()},n.prototype.clearRange=function(){this._datepickerInput.value=null,this._clearRangeEnd.next()},n.prototype._getViews=function(){return this.dualView?[0,1]:[0]},n.prototype._registerInputRangeEnd=function(e){var t=this;if(this._datepickerInputRangeEnd)throw Error("A MatDatepicker can only be associated with a single range end input.");this._datepickerInputRangeEnd=e,this._range=!!e,this._inputRangeEndSubscription.unsubscribe(),this._range&&(this._inputRangeEndSubscription=this._datepickerInputRangeEnd._valueChange.subscribe((function(e){return t._selectedRangeEnd=e})))},n.prototype._unregisterInputRangeEnd=function(e){this._datepickerInputRangeEnd&&(e&&e!==this._datepickerInputRangeEnd||(this._datepickerInputRangeEnd=void 0,this._range=!1,this._inputRangeEndSubscription.unsubscribe()))},n.prototype._selectRangeEnd=function(e){var t=this._selectedRangeEnd;this._selectedRangeEnd=e,this._drDateAdapter.sameDate(t,this._selectedRangeEnd)||this._selectedChangedRangeEnd.next(this._selectedRangeEnd)},n.prototype._setCustomRanges=function(){var e=this;this._customRanges.length?this.customRanges=this._customRanges:this.customRanges=A.map((function(t){return{name:t.name,startDate:t.startDate?e._drDateAdapter.createDate(t.startDate.getFullYear(),t.startDate.getMonth(),t.startDate.getDate()):null,endDate:t.endDate?e._drDateAdapter.createDate(t.endDate.getFullYear(),t.endDate.getMonth(),t.endDate.getDate()):null}}))},n.ctorParameters=function(){return[{type:s.MatDialog},{type:r.Overlay},{type:t.NgZone},{type:t.ViewContainerRef},{type:void 0,decorators:[{type:t.Inject,args:[l.MAT_DATEPICKER_SCROLL_STRATEGY]}]},{type:o.DateAdapter,decorators:[{type:t.Optional}]},{type:p.Directionality,decorators:[{type:t.Optional}]},{type:void 0,decorators:[{type:t.Optional},{type:t.Inject,args:[a.DOCUMENT]}]},{type:Array,decorators:[{type:t.Inject,args:[I]}]}]},_([t.Input()],n.prototype,"applyButton",void 0),_([t.Input()],n.prototype,"dualView",void 0),_([t.Input()],n.prototype,"showCustomRanges",void 0),_([t.Output()],n.prototype,"apply",void 0),n=_([t.Component({selector:"mat-daterangepicker",template:"",exportAs:"matDaterangepicker",changeDetection:t.ChangeDetectionStrategy.OnPush,encapsulation:t.ViewEncapsulation.None,providers:[{provide:I,useValue:S}]}),f(4,t.Inject(l.MAT_DATEPICKER_SCROLL_STRATEGY)),f(5,t.Optional()),f(6,t.Optional()),f(7,t.Optional()),f(7,t.Inject(a.DOCUMENT)),f(8,t.Inject(I))],n)}(l.MatDatepicker),O={provide:g.NG_VALUE_ACCESSOR,useExisting:t.forwardRef((function(){return T})),multi:!0},x={provide:g.NG_VALIDATORS,useExisting:t.forwardRef((function(){return T})),multi:!0},T=function(e){function a(t,a,n,r){var i=e.call(this,t,a,n,r)||this;return i._drElementRef=t,i._drDateAdapter=a,i._drDateFormats=n,i._drFormField=r,i._matDatepickerSubscription=c.Subscription.EMPTY,i._drCvaOnChange=function(){},i._drDatepickerClearSubscription=c.Subscription.EMPTY,i}var n;return D(a,e),n=a,Object.defineProperty(a.prototype,"matDaterangepickerEnd",{set:function(e){this._datepicker!==e&&(this.unregister(),this._datepicker=e,e._registerInputRangeEnd(this))},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"_matDaterangepickerEnd",{get:function(){return this._datepicker},enumerable:!0,configurable:!0}),a.prototype.ngAfterViewInit=function(){},a.prototype.ngAfterContentInit=function(){var e=this;this._datepicker&&(this._matDatepickerSubscription=this._matDaterangepickerEnd._selectedChangedRangeEnd.subscribe((function(t){e.value=t,e._drCvaOnChange(t),e._onTouched(),e.dateInput.emit(new l.MatDatepickerInputEvent(e,e._drElementRef.nativeElement)),e.dateChange.emit(new l.MatDatepickerInputEvent(e,e._drElementRef.nativeElement))})),this._drDatepickerClearSubscription=this._matDaterangepickerEnd._clearRangeEnd.subscribe((function(){e.value=null,e._drCvaOnChange(null)})))},a.prototype.ngOnDestroy=function(){e.prototype.ngOnDestroy.call(this),this.unregister(),this._matDatepickerSubscription.unsubscribe(),this._drDatepickerClearSubscription.unsubscribe()},a.prototype.registerOnChange=function(t){this._drCvaOnChange=t,e.prototype.registerOnChange.call(this,t)},a.prototype.unregister=function(){this._matDaterangepickerEnd&&this._matDaterangepickerEnd._unregisterInputRangeEnd(this)},a.ctorParameters=function(){return[{type:t.ElementRef},{type:o.DateAdapter,decorators:[{type:t.Optional}]},{type:void 0,decorators:[{type:t.Optional},{type:t.Inject,args:[o.MAT_DATE_FORMATS]}]},{type:h.MatFormField,decorators:[{type:t.Optional}]}]},_([t.Input()],a.prototype,"matDaterangepickerEnd",null),a=n=_([t.Directive({selector:"[matDaterangepickerEnd]",providers:[O,x,{provide:m.MAT_INPUT_VALUE_ACCESSOR,useExisting:n}],host:{"[attr.aria-haspopup]":"true","[attr.aria-owns]":"(_datepicker?.opened && _datepicker.id) || null","[attr.min]":"min ? _dateAdapter.toIso8601(min) : null","[attr.max]":"max ? _dateAdapter.toIso8601(max) : null","[disabled]":"disabled","(input)":"_onInput($event.target.value)","(change)":"_onChange()","(blur)":"_onBlur()","(keydown)":"_onKeydown($event)"},exportAs:"MatDaterangepickerInputEnd"}),f(1,t.Optional()),f(2,t.Optional()),f(2,t.Inject(o.MAT_DATE_FORMATS)),f(3,t.Optional())],a)}(l.MatDatepickerInput),V=function(e){function a(){var a=null!==e&&e.apply(this,arguments)||this;return a.selectedRangeEndChange=new t.EventEmitter,a._createDate=function(e){var t=a._dateAdapter.getYear(a.activeDate),n=a._dateAdapter.getMonth(a.activeDate);return new Date(t,n,e)},a}return D(a,e),Object.defineProperty(a.prototype,"selectedRangeEnd",{get:function(){return this._selectedRangeEnd},set:function(e){this._selectedRangeEnd=this._getValidDateOrNull(this._dateAdapter.deserialize(e)),this._selectedRangeEndDate=this._getDateInCurrentMonth(this._selectedRangeEnd)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"_allInRange",{get:function(){if(this.range&&this.activeDate&&this.selectedRangeEnd&&this.selected){var e=this._dateAdapter.getNumDaysInMonth(this.activeDate),t=this.createDate(1),a=this.createDate(e);return this._dateAdapter.compareDate(this.selected,t)<0&&this._dateAdapter.compareDate(this.selectedRangeEnd,a)>0}return!1},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"_rangable",{get:function(){if(this.range&&this._weeks){var e=this._dateAdapter.getNumDaysInMonth(this.activeDate),t=this.createDate(1),a=this.createDate(e);return!(this.selectedRangeEnd<t)&&!(this.selected>a)}return!1},enumerable:!0,configurable:!0}),a.prototype._init=function(){this._selectedRangeEndDate=this._getDateInCurrentMonth(this.selectedRangeEnd),e.prototype._init.call(this)},a.prototype._dateSelected=function(t){return v(this,void 0,void 0,(function(){var a,n,r;return b(this,(function(i){return this.range?!this.selected||this.selectedRangeEnd?(this._selectedRangeEnd&&this._dateSelectedRangeEnd(null),e.prototype._dateSelected.call(this,t)):null===t?this._dateSelectedRangeEnd(null):this.createDate(t)<this.selected?(a=this._dateAdapter.getYear(this.selected),n=this._dateAdapter.getMonth(this.selected),r=this._dateAdapter.getDate(this.selected),e.prototype._dateSelected.call(this,t),this._dateSelectedRangeEnd(r,a,n)):this._dateSelectedRangeEnd(t):e.prototype._dateSelected.call(this,t),[2]}))}))},a.prototype._dateSelectedRangeEnd=function(e,t,a){if(null===e)this.selectedRangeEndChange.emit(null);else if(this._selectedRangeEndDate!=e){var n=void 0;n=t&&a?this._dateAdapter.createDate(t,a,e):this.createDate(e),this.selectedRangeEndChange.emit(n),this._userSelection.emit()}},a.prototype.createDate=function(e){var t=this._dateAdapter.getYear(this.activeDate),a=this._dateAdapter.getMonth(this.activeDate);return this._dateAdapter.createDate(t,a,e)},a.prototype.getSelectedDate=function(){if(!this.selected)return null;var e=this._dateAdapter.getYear(this.selected),t=this._dateAdapter.getMonth(this.selected),a=this._dateAdapter.getDate(this.selected);return new Date(e,t,a)},a.prototype.getSelectedRangeEndDate=function(){if(!this.selectedRangeEnd)return null;var e=this._dateAdapter.getYear(this.selectedRangeEnd),t=this._dateAdapter.getMonth(this.selectedRangeEnd),a=this._dateAdapter.getDate(this.selectedRangeEnd);return new Date(e,t,a)},_([t.Input()],a.prototype,"range",void 0),_([t.Input()],a.prototype,"view",void 0),_([t.Input()],a.prototype,"setHoverCells",void 0),_([t.Input()],a.prototype,"clearBody",void 0),_([t.Input()],a.prototype,"selectedRangeEnd",null),_([t.Output()],a.prototype,"selectedRangeEndChange",void 0),a=_([t.Component({selector:"mat-daterange-month-view",template:'\x3c!-- \n RANGE: Most of the code is redundant and hera as inheritance boilerplate.\n \n The 3 attributes in the middle are the additional bindings to the template.\n They notify the body:\n - Are we in range mode ([range])\n - Are all the dates in range ([allInRange])\n this happens when the start date is before the current month and the end is after it.\n - The value marking the end of the range ([selectedRangeEndValue])\n\n ADDED LOC ~3\n --\x3e\n\n<table class="mat-calendar-table">\n <thead class="mat-calendar-table-header">\n <tr><th *ngFor="let day of _weekdays" [attr.aria-label]="day.long">{{day.narrow}}</th></tr>\n <tr><th class="mat-calendar-table-header-divider" colspan="7" aria-hidden="true"></th></tr>\n </thead>\n <tbody mat-daterange-calendar-body\n [view]="view"\n [label]="_monthLabel"\n [rows]="_weeks"\n [todayValue]="_todayDate"\n [selectedValue]="_selectedDate"\n\n [selectedRangeEndValue]="_selectedRangeEndDate"\n [allInRange]="_allInRange"\n [range]="_rangable"\n [createDate]="_createDate"\n [dateAdapter]="_dateAdapter"\n [selected]="getSelectedDate()"\n [selectedRangeEnd]="getSelectedRangeEndDate()"\n [setHoverCells]="setHoverCells"\n [clearBody]="clearBody"\n [labelMinRequiredCells]="3"\n [activeCell]="_dateAdapter.getDate(activeDate) - 1"\n (selectedValueChange)="_dateSelected($event)" \n (keydown)="_handleCalendarBodyKeydown($event)">\n </tbody>\n</table>\n',exportAs:"matMonthView",encapsulation:t.ViewEncapsulation.None,preserveWhitespaces:!1,changeDetection:t.ChangeDetectionStrategy.OnPush})],a)}(l.MatMonthView),P=function(e){function a(){var t=null!==e&&e.apply(this,arguments)||this;return t.hoverSubscription=c.Subscription.EMPTY,t.clearBodySubscription=c.Subscription.EMPTY,t}return D(a,e),a.prototype.ngOnInit=function(){var e=this;this.hoverSubscription=this.setHoverCells.subscribe((function(t){return v(e,void 0,void 0,(function(){return b(this,(function(e){return!t||!this.selected||this.selectedRangeEnd||this.selected&&this.selectedRangeEnd||this._doHoverCells(t),[2]}))}))})),this.clearBodySubscription=this.clearBody.subscribe((function(t){t&&e._doHoverCells(null,t)}))},a.prototype._cellClass=function(e){if(this.selected&&this.selectedRangeEnd){var t=this.selected.getTime(),a=this.selectedRangeEnd.getTime(),n=this.createDate(e).getTime();return{"mat-daterange-calendar-body-in-range":n>=t&&n<=a&&t!==a,"mat-daterange-calendar-body-range-start":n===t&&t!==a,"mat-daterange-calendar-body-range-end":n===a&&t!==a}}},a.prototype._inRange=function(e){},a.prototype._onHoverCell=function(e){this.selectedRangeEndValue||this.setHoverCells.next(this.createDate(e))},a.prototype._doHoverCells=function(e,t){var a,n=this,r=null===(a=this.selected)||void 0===a?void 0:a.getTime(),i=null==e?void 0:e.getTime();this.rows.map((function(e,a){var o=n.rowsElms.toArray()[a],d=!1;e.map((function(e,a){var s=o.nativeElement.cells[d?a+1:a];if(s.classList.contains("mat-calendar-body-label")&&(d=!0,s=o.nativeElement.cells[a+1]),s.classList.remove("mat-daterange-calendar-body-in-range"),s.classList.remove("mat-daterange-calendar-body-range-end"),s.classList.remove("mat-daterange-calendar-body-range-start"),!t)n._inRangeTemp(e.value,r,i,s)}))}))},a.prototype._inRangeTemp=function(e,t,a,n){var r=this.createDate(e).getTime();return a>=t?(a!==t&&(r===t&&(n.classList.add("mat-daterange-calendar-body-in-range"),n.classList.add("mat-daterange-calendar-body-range-start")),r===a&&(n.classList.add("mat-daterange-calendar-body-in-range"),n.classList.add("mat-daterange-calendar-body-range-end"))),r>t&&r<a&&(n.classList.add("mat-daterange-calendar-body-in-range"),!0)):(a!==t&&(r===t&&(n.classList.add("mat-daterange-calendar-body-in-range"),n.classList.add("mat-daterange-calendar-body-range-end")),r===a&&(n.classList.add("mat-daterange-calendar-body-in-range"),n.classList.add("mat-daterange-calendar-body-range-start"))),r<t&&r>a&&(n.classList.add("mat-daterange-calendar-body-in-range"),!0))},a.prototype.ngOnDestroy=function(){this.hoverSubscription.unsubscribe(),this.clearBodySubscription.unsubscribe()},_([t.Input()],a.prototype,"range",void 0),_([t.Input()],a.prototype,"allInRange",void 0),_([t.Input()],a.prototype,"selectedRangeEndValue",void 0),_([t.Input()],a.prototype,"view",void 0),_([t.Input()],a.prototype,"createDate",void 0),_([t.Input()],a.prototype,"selected",void 0),_([t.Input()],a.prototype,"selectedRangeEnd",void 0),_([t.Input()],a.prototype,"setHoverCells",void 0),_([t.Input()],a.prototype,"clearBody",void 0),_([t.Input()],a.prototype,"dateAdapter",void 0),_([t.ViewChildren("Row")],a.prototype,"rowsElms",void 0),a=_([t.Component({selector:"[mat-daterange-calendar-body]",template:'\x3c!-- \n RANGE: Most of the code is redundant and hera as inheritance boilerplate.\n The relevant code is all element attribute bindings with the word "range"\n and an editing to the binding of [class.mat-calendar-body-selected]\n\n ADDED LOC ~3\n --\x3e\n\n\x3c!--\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--\x3e\n<tr *ngIf="_firstRowOffset < labelMinRequiredCells" aria-hidden="true">\n\t<td class="mat-calendar-body-label"\n\t\t[attr.colspan]="numCols"\n\t\t[style.paddingTop.%]="50 * cellAspectRatio / numCols"\n\t\t[style.paddingBottom.%]="50 * cellAspectRatio / numCols">\n\t\t{{label}}\n\t</td>\n</tr>\n\n\x3c!-- Create the first row separately so we can include a special spacer cell. --\x3e\n<tr *ngFor="let row of rows; let rowIndex = index" #Row role="row">\n\t\x3c!--\n\t\tWe mark this cell as aria-hidden so it doesn\'t get read out as one of the days in the week.\n\t\tThe aspect ratio of the table cells is maintained by setting the top and bottom padding as a\n\t\tpercentage of the width (a variant of the trick described here:\n\t\thttps://www.w3schools.com/howto/howto_css_aspect_ratio.asp).\n\t--\x3e\n\t<td *ngIf="rowIndex === 0 && _firstRowOffset"\n\t\taria-hidden="true"\n\t\tclass="mat-calendar-body-label"\n\t\t[attr.colspan]="_firstRowOffset"\n\t\t[style.paddingTop.%]="50 * cellAspectRatio / numCols"\n\t\t[style.paddingBottom.%]="50 * cellAspectRatio / numCols">\n\t\t{{_firstRowOffset >= labelMinRequiredCells ? label : \'\'}}\n\t</td>\n\t<td *ngFor="let item of row; let colIndex = index"\n\t\t#Cell\n\t\trole="gridcell"\n\t\tclass="mat-calendar-body-cell"\n\t\t[tabindex]="_isActiveCell(rowIndex, colIndex) ? 0 : -1"\n\t\t[class.mat-calendar-body-disabled]="!item.enabled"\n\t\t[class.mat-calendar-body-active]="_isActiveCell(rowIndex, colIndex)"\n\n\t\t[ngClass]="_cellClass(item.value)"\n\n\t\t[attr.aria-label]="item.ariaLabel"\n\t\t[attr.aria-disabled]="!item.enabled || null"\n\t\t(click)="_cellClicked(item)"\n\t\t(mouseover)="_onHoverCell(item.value)"\n\t\t[style.width.%]="100 / numCols"\n\t\t[style.paddingTop.%]="50 * cellAspectRatio / numCols"\n\t\t[style.paddingBottom.%]="50 * cellAspectRatio / numCols">\n\t\t<div class="mat-calendar-body-cell-content"\n\t\t\t[class.mat-calendar-body-selected]="selectedValue === item.value || selectedRangeEndValue === item.value"\n\t\t\t[class.mat-calendar-body-today]="todayValue === item.value">\n\t\t{{item.displayValue}}\n\t\t</div>\n\t</td>\n</tr>\n',host:{class:"mat-calendar-body","[class.mat-daterange-calendar-body-range]":"range",role:"grid","attr.aria-readonly":"true"},exportAs:"matCalendarBody",encapsulation:t.ViewEncapsulation.None,preserveWhitespaces:!1,changeDetection:t.ChangeDetectionStrategy.OnPush})],a)}(l.MatCalendarBody),j=function(){function e(e,t){e.resolveComponentFactory(l.MatDatepicker).create(t),e.resolveComponentFactory(l.MatDatepickerContent).create(t),e.resolveComponentFactory(l.MatCalendar).create(t),e.resolveComponentFactory(l.MatMonthView).create(t),e.resolveComponentFactory(l.MatCalendarBody).create(t),e.resolveComponentFactory(l.MatDatepickerToggle).create(t)}return e.ctorParameters=function(){return[{type:t.ComponentFactoryResolver},{type:t.Injector}]},e=_([t.NgModule({imports:[a.CommonModule,d.MatButtonModule,s.MatDialogModule,n.A11yModule,i.PortalModule,r.OverlayModule,l.MatDatepickerModule,o.MatNativeDateModule],declarations:[M,T,E,R,V,P],exports:[M,T,E],entryComponents:[E]})],e)}();e.MAT_DEFAULT_DATES_RANGES=I,e.MatDaterangepicker=M,e.MatDaterangepickerContent=E,e.MatDaterangepickerInputEnd=T,e.MatDaterangepickerModule=j,e.SG_DATEPICKER_VALIDATORS=x,e.SG_DATEPICKER_VALUE_ACCESSOR=O,e.ɵ0=S,e.ɵa=R,e.ɵb=V,e.ɵc=P,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=mat-daterangepicker.umd.min.js.map