blob: ddcae80991ea218e2d98fb8a5cc7c60b6e9cb1a1 [file] [log] [blame]
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/cdk/coercion"),require("@angular/core"),require("@angular/material/core"),require("rxjs"),require("@angular/animations"),require("@angular/common")):"function"==typeof define&&define.amd?define("@angular/material/sort",["exports","@angular/cdk/coercion","@angular/core","@angular/material/core","rxjs","@angular/animations","@angular/common"],e):e((t.ng=t.ng||{},t.ng.material=t.ng.material||{},t.ng.material.sort={}),t.ng.cdk.coercion,t.ng.core,t.ng.material.core,t.rxjs,t.ng.animations,t.ng.common)}(this,function(t,e,r,i,o,a,n){"use strict";function s(t,e){function r(){this.constructor=t}m(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function c(t){return Error("Cannot have two MatSortables with the same id ("+t+").")}function d(){return Error("MatSortHeader must be placed within a parent element with the MatSort directive.")}function l(){return Error("MatSortHeader must be provided with a unique id.")}function h(t){return Error(t+" is not a valid sort direction ('asc' or 'desc').")}function u(t,e){var r=["asc","desc"];return"desc"==t&&r.reverse(),e||r.push(""),r}function p(t){return t||new w}var m=function(t,e){return(m=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},f=function(){function t(){}return t}(),g=i.mixinInitialized(i.mixinDisabled(f)),_=function(t){function i(){var e=null!==t&&t.apply(this,arguments)||this;return e.sortables=new Map,e._stateChanges=new o.Subject,e.start="asc",e._direction="",e.sortChange=new r.EventEmitter,e}return s(i,t),Object.defineProperty(i.prototype,"direction",{get:function(){return this._direction},set:function(t){if(r.isDevMode()&&t&&"asc"!==t&&"desc"!==t)throw h(t);this._direction=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"disableClear",{get:function(){return this._disableClear},set:function(t){this._disableClear=e.coerceBooleanProperty(t)},enumerable:!0,configurable:!0}),i.prototype.register=function(t){if(!t.id)throw l();if(this.sortables.has(t.id))throw c(t.id);this.sortables.set(t.id,t)},i.prototype.deregister=function(t){this.sortables.delete(t.id)},i.prototype.sort=function(t){this.active!=t.id?(this.active=t.id,this.direction=t.start?t.start:this.start):this.direction=this.getNextSortDirection(t),this.sortChange.emit({active:this.active,direction:this.direction})},i.prototype.getNextSortDirection=function(t){if(!t)return"";var e=null!=t.disableClear?t.disableClear:this.disableClear,r=u(t.start||this.start,e),i=r.indexOf(this.direction)+1;return i>=r.length&&(i=0),r[i]},i.prototype.ngOnInit=function(){this._markInitialized()},i.prototype.ngOnChanges=function(){this._stateChanges.next()},i.prototype.ngOnDestroy=function(){this._stateChanges.complete()},i.decorators=[{type:r.Directive,args:[{selector:"[matSort]",exportAs:"matSort",inputs:["disabled: matSortDisabled"]}]}],i.propDecorators={active:[{type:r.Input,args:["matSortActive"]}],start:[{type:r.Input,args:["matSortStart"]}],direction:[{type:r.Input,args:["matSortDirection"]}],disableClear:[{type:r.Input,args:["matSortDisableClear"]}],sortChange:[{type:r.Output,args:["matSortChange"]}]},i}(g),y=i.AnimationDurations.ENTERING+" "+i.AnimationCurves.STANDARD_CURVE,b={indicator:a.trigger("indicator",[a.state("active-asc, asc",a.style({transform:"translateY(0px)"})),a.state("active-desc, desc",a.style({transform:"translateY(10px)"})),a.transition("active-asc <=> active-desc",a.animate(y))]),leftPointer:a.trigger("leftPointer",[a.state("active-asc, asc",a.style({transform:"rotate(-45deg)"})),a.state("active-desc, desc",a.style({transform:"rotate(45deg)"})),a.transition("active-asc <=> active-desc",a.animate(y))]),rightPointer:a.trigger("rightPointer",[a.state("active-asc, asc",a.style({transform:"rotate(45deg)"})),a.state("active-desc, desc",a.style({transform:"rotate(-45deg)"})),a.transition("active-asc <=> active-desc",a.animate(y))]),arrowOpacity:a.trigger("arrowOpacity",[a.state("desc-to-active, asc-to-active, active",a.style({opacity:1})),a.state("desc-to-hint, asc-to-hint, hint",a.style({opacity:.54})),a.state("hint-to-desc, active-to-desc, desc, hint-to-asc, active-to-asc, asc, void",a.style({opacity:0})),a.transition("* => asc, * => desc, * => active, * => hint, * => void",a.animate("0ms")),a.transition("* <=> *",a.animate(y))]),arrowPosition:a.trigger("arrowPosition",[a.transition("* => desc-to-hint, * => desc-to-active",a.animate(y,a.keyframes([a.style({transform:"translateY(-25%)"}),a.style({transform:"translateY(0)"})]))),a.transition("* => hint-to-desc, * => active-to-desc",a.animate(y,a.keyframes([a.style({transform:"translateY(0)"}),a.style({transform:"translateY(25%)"})]))),a.transition("* => asc-to-hint, * => asc-to-active",a.animate(y,a.keyframes([a.style({transform:"translateY(25%)"}),a.style({transform:"translateY(0)"})]))),a.transition("* => hint-to-asc, * => active-to-asc",a.animate(y,a.keyframes([a.style({transform:"translateY(0)"}),a.style({transform:"translateY(-25%)"})]))),a.state("desc-to-hint, asc-to-hint, hint, desc-to-active, asc-to-active, active",a.style({transform:"translateY(0)"})),a.state("hint-to-desc, active-to-desc, desc",a.style({transform:"translateY(-25%)"})),a.state("hint-to-asc, active-to-asc, asc",a.style({transform:"translateY(25%)"}))]),allowChildren:a.trigger("allowChildren",[a.transition("* <=> *",[a.query("@*",a.animateChild(),{optional:!0})])])},w=function(){function t(){this.changes=new o.Subject,this.sortButtonLabel=function(t){return"Change sorting for "+t}}return t.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],t.ngInjectableDef=r.ɵɵdefineInjectable({factory:function(){return new t},token:t,providedIn:"root"}),t}(),v={provide:w,deps:[[new r.Optional,new r.SkipSelf,w]],useFactory:p},S=function(){function t(){}return t}(),D=i.mixinDisabled(S),A=function(t){function i(e,r,i,a){var n=t.call(this)||this;if(n._intl=e,n._sort=i,n._columnDef=a,n._showIndicatorHint=!1,n._arrowDirection="",n._disableViewStateAnimation=!1,n.arrowPosition="after",!i)throw d();return n._rerenderSubscription=o.merge(i.sortChange,i._stateChanges,e.changes).subscribe(function(){n._isSorted()&&n._updateArrowDirection(),!n._isSorted()&&n._viewState&&"active"===n._viewState.toState&&(n._disableViewStateAnimation=!1,n._setAnimationTransitionState({fromState:"active",toState:n._arrowDirection})),r.markForCheck()}),n}return s(i,t),Object.defineProperty(i.prototype,"disableClear",{get:function(){return this._disableClear},set:function(t){this._disableClear=e.coerceBooleanProperty(t)},enumerable:!0,configurable:!0}),i.prototype.ngOnInit=function(){!this.id&&this._columnDef&&(this.id=this._columnDef.name),this._updateArrowDirection(),this._setAnimationTransitionState({toState:this._isSorted()?"active":this._arrowDirection}),this._sort.register(this)},i.prototype.ngOnDestroy=function(){this._sort.deregister(this),this._rerenderSubscription.unsubscribe()},i.prototype._setIndicatorHintVisible=function(t){this._isDisabled()&&t||(this._showIndicatorHint=t,this._isSorted()||(this._updateArrowDirection(),this._showIndicatorHint?this._setAnimationTransitionState({fromState:this._arrowDirection,toState:"hint"}):this._setAnimationTransitionState({fromState:"hint",toState:this._arrowDirection})))},i.prototype._setAnimationTransitionState=function(t){this._viewState=t,this._disableViewStateAnimation&&(this._viewState={toState:t.toState})},i.prototype._handleClick=function(){if(!this._isDisabled()){this._sort.sort(this),"hint"!==this._viewState.toState&&"active"!==this._viewState.toState||(this._disableViewStateAnimation=!0);var t=this._isSorted()?{fromState:this._arrowDirection,toState:"active"}:{fromState:"active",toState:this._arrowDirection};this._setAnimationTransitionState(t),this._showIndicatorHint=!1}},i.prototype._isSorted=function(){return this._sort.active==this.id&&("asc"===this._sort.direction||"desc"===this._sort.direction)},i.prototype._getArrowDirectionState=function(){return(this._isSorted()?"active-":"")+this._arrowDirection},i.prototype._getArrowViewState=function(){var t=this._viewState.fromState;return(t?t+"-to-":"")+this._viewState.toState},i.prototype._updateArrowDirection=function(){this._arrowDirection=this._isSorted()?this._sort.direction:this.start||this._sort.start},i.prototype._isDisabled=function(){return this._sort.disabled||this.disabled},i.prototype._getAriaSortAttribute=function(){return this._isSorted()?"asc"==this._sort.direction?"ascending":"descending":null},i.prototype._renderArrow=function(){return!this._isDisabled()||this._isSorted()},i.decorators=[{type:r.Component,args:[{selector:"[mat-sort-header]",exportAs:"matSortHeader",template:'<div class="mat-sort-header-container" [class.mat-sort-header-sorted]="_isSorted()" [class.mat-sort-header-position-before]="arrowPosition == \'before\'"><button class="mat-sort-header-button" type="button" [attr.disabled]="_isDisabled() || null" [attr.aria-label]="_intl.sortButtonLabel(id)" (focus)="_setIndicatorHintVisible(true)" (blur)="_setIndicatorHintVisible(false)"><ng-content></ng-content></button><div class="mat-sort-header-arrow" *ngIf="_renderArrow()" [@arrowOpacity]="_getArrowViewState()" [@arrowPosition]="_getArrowViewState()" [@allowChildren]="_getArrowDirectionState()" (@arrowPosition.start)="_disableViewStateAnimation = true" (@arrowPosition.done)="_disableViewStateAnimation = false"><div class="mat-sort-header-stem"></div><div class="mat-sort-header-indicator" [@indicator]="_getArrowDirectionState()"><div class="mat-sort-header-pointer-left" [@leftPointer]="_getArrowDirectionState()"></div><div class="mat-sort-header-pointer-right" [@rightPointer]="_getArrowDirectionState()"></div><div class="mat-sort-header-pointer-middle"></div></div></div></div>',styles:[".mat-sort-header-container{display:flex;cursor:pointer;align-items:center}.mat-sort-header-disabled .mat-sort-header-container{cursor:default}.mat-sort-header-position-before{flex-direction:row-reverse}.mat-sort-header-button{border:none;background:0 0;display:flex;align-items:center;padding:0;cursor:inherit;outline:0;font:inherit;color:currentColor}.mat-sort-header-button::-moz-focus-inner{border:0}.mat-sort-header-arrow{height:12px;width:12px;min-width:12px;position:relative;display:flex;opacity:0}.mat-sort-header-arrow,[dir=rtl] .mat-sort-header-position-before .mat-sort-header-arrow{margin:0 0 0 6px}.mat-sort-header-position-before .mat-sort-header-arrow,[dir=rtl] .mat-sort-header-arrow{margin:0 6px 0 0}.mat-sort-header-stem{background:currentColor;height:10px;width:2px;margin:auto;display:flex;align-items:center}@media (-ms-high-contrast:active){.mat-sort-header-stem{width:0;border-left:solid 2px}}.mat-sort-header-indicator{width:100%;height:2px;display:flex;align-items:center;position:absolute;top:0;left:0}.mat-sort-header-pointer-middle{margin:auto;height:2px;width:2px;background:currentColor;transform:rotate(45deg)}@media (-ms-high-contrast:active){.mat-sort-header-pointer-middle{width:0;height:0;border-top:solid 2px;border-left:solid 2px}}.mat-sort-header-pointer-left,.mat-sort-header-pointer-right{background:currentColor;width:6px;height:2px;position:absolute;top:0}@media (-ms-high-contrast:active){.mat-sort-header-pointer-left,.mat-sort-header-pointer-right{width:0;height:0;border-left:solid 6px;border-top:solid 2px}}.mat-sort-header-pointer-left{transform-origin:right;left:0}.mat-sort-header-pointer-right{transform-origin:left;right:0}"],host:{"(click)":"_handleClick()","(mouseenter)":"_setIndicatorHintVisible(true)","(longpress)":"_setIndicatorHintVisible(true)","(mouseleave)":"_setIndicatorHintVisible(false)","[attr.aria-sort]":"_getAriaSortAttribute()","[class.mat-sort-header-disabled]":"_isDisabled()"},encapsulation:r.ViewEncapsulation.None,changeDetection:r.ChangeDetectionStrategy.OnPush,inputs:["disabled"],animations:[b.indicator,b.leftPointer,b.rightPointer,b.arrowOpacity,b.arrowPosition,b.allowChildren]}]}],i.ctorParameters=function(){return[{type:w},{type:r.ChangeDetectorRef},{type:_,decorators:[{type:r.Optional}]},{type:void 0,decorators:[{type:r.Inject,args:["MAT_SORT_HEADER_COLUMN_DEF"]},{type:r.Optional}]}]},i.propDecorators={id:[{type:r.Input,args:["mat-sort-header"]}],arrowPosition:[{type:r.Input}],start:[{type:r.Input}],disableClear:[{type:r.Input}]},i}(D),C=function(){function t(){}return t.decorators=[{type:r.NgModule,args:[{imports:[n.CommonModule],exports:[_,A],declarations:[_,A],providers:[v]}]}],t}();t.MatSortModule=C,t.MatSortHeader=A,t.MAT_SORT_HEADER_INTL_PROVIDER_FACTORY=p,t.MatSortHeaderIntl=w,t.MAT_SORT_HEADER_INTL_PROVIDER=v,t.MatSort=_,t.matSortAnimations=b,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=material-sort.umd.min.js.map