UNPKG

@angular/material

Version:
60 lines (58 loc) 15.6 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/cdk/coercion"),require("@angular/material/core"),require("@angular/cdk/a11y"),require("rxjs"),require("@angular/animations"),require("@angular/common")):"function"==typeof define&&define.amd?define("@angular/material/sort",["exports","@angular/core","@angular/cdk/coercion","@angular/material/core","@angular/cdk/a11y","rxjs","@angular/animations","@angular/common"],e):e(((t=t||self).ng=t.ng||{},t.ng.material=t.ng.material||{},t.ng.material.sort={}),t.ng.core,t.ng.cdk.coercion,t.ng.material.core,t.ng.cdk.a11y,t.rxjs,t.ng.animations,t.ng.common)}(this,(function(t,e,r,i,o,a,n,s){"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 c=function(t,e){return(c=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)};function d(t,e){function r(){this.constructor=t}c(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)} /** * @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 */ var l=function(t){function i(){var r=null!==t&&t.apply(this,arguments)||this;return r.sortables=new Map,r._stateChanges=new a.Subject,r.start="asc",r._direction="",r.sortChange=new e.EventEmitter,r}return d(i,t),Object.defineProperty(i.prototype,"direction",{get:function(){return this._direction},set:function(t){if(e.isDevMode()&&t&&"asc"!==t&&"desc"!==t)throw function r(t){return Error(t+" is not a valid sort direction ('asc' or 'desc').")}(t);this._direction=t},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"disableClear",{get:function(){return this._disableClear},set:function(t){this._disableClear=r.coerceBooleanProperty(t)},enumerable:!1,configurable:!0}),i.prototype.register=function(t){if(!t.id)throw function e(){return Error("MatSortHeader must be provided with a unique id.")}();if(this.sortables.has(t.id)) /** * @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 */ throw function r(t){return Error("Cannot have two MatSortables with the same id ("+t+").")}(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=function r(t,e){var r=["asc","desc"];return"desc"==t&&r.reverse(),e||r.push(""),r} /** * @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 */(t.start||this.start,null!=t.disableClear?t.disableClear:this.disableClear),i=e.indexOf(this.direction)+1;return i>=e.length&&(i=0),e[i]},i.prototype.ngOnInit=function(){this._markInitialized()},i.prototype.ngOnChanges=function(){this._stateChanges.next()},i.prototype.ngOnDestroy=function(){this._stateChanges.complete()},i.decorators=[{type:e.Directive,args:[{selector:"[matSort]",exportAs:"matSort",host:{class:"mat-sort"},inputs:["disabled: matSortDisabled"]}]}],i.propDecorators={active:[{type:e.Input,args:["matSortActive"]}],start:[{type:e.Input,args:["matSortStart"]}],direction:[{type:e.Input,args:["matSortDirection"]}],disableClear:[{type:e.Input,args:["matSortDisableClear"]}],sortChange:[{type:e.Output,args:["matSortChange"]}]},i}(i.mixinInitialized(i.mixinDisabled((function h(){})))),u=i.AnimationDurations.ENTERING+" "+i.AnimationCurves.STANDARD_CURVE,p={indicator:n.trigger("indicator",[n.state("active-asc, asc",n.style({transform:"translateY(0px)"})),n.state("active-desc, desc",n.style({transform:"translateY(10px)"})),n.transition("active-asc <=> active-desc",n.animate(u))]),leftPointer:n.trigger("leftPointer",[n.state("active-asc, asc",n.style({transform:"rotate(-45deg)"})),n.state("active-desc, desc",n.style({transform:"rotate(45deg)"})),n.transition("active-asc <=> active-desc",n.animate(u))]),rightPointer:n.trigger("rightPointer",[n.state("active-asc, asc",n.style({transform:"rotate(45deg)"})),n.state("active-desc, desc",n.style({transform:"rotate(-45deg)"})),n.transition("active-asc <=> active-desc",n.animate(u))]),arrowOpacity:n.trigger("arrowOpacity",[n.state("desc-to-active, asc-to-active, active",n.style({opacity:1})),n.state("desc-to-hint, asc-to-hint, hint",n.style({opacity:.54})),n.state("hint-to-desc, active-to-desc, desc, hint-to-asc, active-to-asc, asc, void",n.style({opacity:0})),n.transition("* => asc, * => desc, * => active, * => hint, * => void",n.animate("0ms")),n.transition("* <=> *",n.animate(u))]),arrowPosition:n.trigger("arrowPosition",[n.transition("* => desc-to-hint, * => desc-to-active",n.animate(u,n.keyframes([n.style({transform:"translateY(-25%)"}),n.style({transform:"translateY(0)"})]))),n.transition("* => hint-to-desc, * => active-to-desc",n.animate(u,n.keyframes([n.style({transform:"translateY(0)"}),n.style({transform:"translateY(25%)"})]))),n.transition("* => asc-to-hint, * => asc-to-active",n.animate(u,n.keyframes([n.style({transform:"translateY(25%)"}),n.style({transform:"translateY(0)"})]))),n.transition("* => hint-to-asc, * => active-to-asc",n.animate(u,n.keyframes([n.style({transform:"translateY(0)"}),n.style({transform:"translateY(-25%)"})]))),n.state("desc-to-hint, asc-to-hint, hint, desc-to-active, asc-to-active, active",n.style({transform:"translateY(0)"})),n.state("hint-to-desc, active-to-desc, desc",n.style({transform:"translateY(-25%)"})),n.state("hint-to-asc, active-to-asc, asc",n.style({transform:"translateY(25%)"}))]),allowChildren:n.trigger("allowChildren",[n.transition("* <=> *",[n.query("@*",n.animateChild(),{optional:!0})])])},m=function(){function t(){this.changes=new a.Subject,this.sortButtonLabel=function(t){return"Change sorting for "+t}}return t.ɵprov=e.ɵɵdefineInjectable({factory:function e(){return new t},token:t,providedIn:"root"}),t.decorators=[{type:e.Injectable,args:[{providedIn:"root"}]}],t}();function f(t){return t||new m}var g={provide:m,deps:[[new e.Optional,new e.SkipSelf,m]],useFactory:f},_=function(t){function i(e,r,i,o,n,s){var c=t.call(this)||this;if(c._intl=e,c._sort=i,c._columnDef=o,c._focusMonitor=n,c._elementRef=s,c._showIndicatorHint=!1,c._arrowDirection="",c._disableViewStateAnimation=!1,c.arrowPosition="after",!i)throw function d(){return Error("MatSortHeader must be placed within a parent element with the MatSort directive.")}();return c._rerenderSubscription=a.merge(i.sortChange,i._stateChanges,e.changes).subscribe((function(){c._isSorted()&&c._updateArrowDirection(),!c._isSorted()&&c._viewState&&"active"===c._viewState.toState&&(c._disableViewStateAnimation=!1,c._setAnimationTransitionState({fromState:"active",toState:c._arrowDirection})),r.markForCheck()})),c}return d(i,t),Object.defineProperty(i.prototype,"disableClear",{get:function(){return this._disableClear},set:function(t){this._disableClear=r.coerceBooleanProperty(t)},enumerable:!1,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.ngAfterViewInit=function(){var t=this;this._focusMonitor.monitor(this._elementRef,!0).subscribe((function(e){return t._setIndicatorHintVisible(!!e)}))},i.prototype.ngOnDestroy=function(){this._focusMonitor.stopMonitoring(this._elementRef),this._sort.deregister(this),this._rerenderSubscription.unsubscribe()},i.prototype._setIndicatorHintVisible=function(t){this._isDisabled()&&t||(this._showIndicatorHint=t,this._isSorted()||(this._updateArrowDirection(),this._setAnimationTransitionState(this._showIndicatorHint?{fromState:this._arrowDirection,toState:"hint"}:{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:e.Component,args:[{selector:"[mat-sort-header]",exportAs:"matSortHeader",template:'<div class="mat-sort-header-container"\n [class.mat-sort-header-sorted]="_isSorted()"\n [class.mat-sort-header-position-before]="arrowPosition == \'before\'">\n <button class="mat-sort-header-button mat-focus-indicator" type="button"\n [attr.disabled]="_isDisabled() || null"\n [attr.aria-label]="_intl.sortButtonLabel(id)">\n <ng-content></ng-content>\n </button>\n\n \x3c!-- Disable animations while a current animation is running --\x3e\n <div class="mat-sort-header-arrow"\n *ngIf="_renderArrow()"\n [@arrowOpacity]="_getArrowViewState()"\n [@arrowPosition]="_getArrowViewState()"\n [@allowChildren]="_getArrowDirectionState()"\n (@arrowPosition.start)="_disableViewStateAnimation = true"\n (@arrowPosition.done)="_disableViewStateAnimation = false">\n <div class="mat-sort-header-stem"></div>\n <div class="mat-sort-header-indicator" [@indicator]="_getArrowDirectionState()">\n <div class="mat-sort-header-pointer-left" [@leftPointer]="_getArrowDirectionState()"></div>\n <div class="mat-sort-header-pointer-right" [@rightPointer]="_getArrowDirectionState()"></div>\n <div class="mat-sort-header-pointer-middle"></div>\n </div>\n </div>\n</div>\n',host:{class:"mat-sort-header","(click)":"_handleClick()","(mouseenter)":"_setIndicatorHintVisible(true)","(mouseleave)":"_setIndicatorHintVisible(false)","[attr.aria-sort]":"_getAriaSortAttribute()","[class.mat-sort-header-disabled]":"_isDisabled()"},encapsulation:e.ViewEncapsulation.None,changeDetection:e.ChangeDetectionStrategy.OnPush,inputs:["disabled"],animations:[p.indicator,p.leftPointer,p.rightPointer,p.arrowOpacity,p.arrowPosition,p.allowChildren],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].cdk-keyboard-focused .mat-sort-header-button,[mat-sort-header].cdk-program-focused .mat-sort-header-button{border-bottom:solid 1px 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}.cdk-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)}.cdk-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}.cdk-high-contrast-active .mat-sort-header-pointer-left,.cdk-high-contrast-active .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}\n"]}]}],i.ctorParameters=function(){return[{type:m},{type:e.ChangeDetectorRef},{type:l,decorators:[{type:e.Optional}]},{type:void 0,decorators:[{type:e.Inject,args:["MAT_SORT_HEADER_COLUMN_DEF"]},{type:e.Optional}]},{type:o.FocusMonitor},{type:e.ElementRef}]},i.propDecorators={id:[{type:e.Input,args:["mat-sort-header"]}],arrowPosition:[{type:e.Input}],start:[{type:e.Input}],disableClear:[{type:e.Input}]},i}(i.mixinDisabled((function y(){}))),b=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{imports:[s.CommonModule],exports:[l,_],declarations:[l,_],providers:[g]}]}],t}(); /** * @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 */ /** * @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 */ /** * @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 */ t.MAT_SORT_HEADER_INTL_PROVIDER=g,t.MAT_SORT_HEADER_INTL_PROVIDER_FACTORY=f,t.MatSort=l,t.MatSortHeader=_,t.MatSortHeaderIntl=m,t.MatSortModule=b,t.matSortAnimations=p,Object.defineProperty(t,"__esModule",{value:!0})}));