blob: 6732e2b5df579e0419c89ecaa79d56a53e7c9b6b [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/core"),require("@angular/material/core"),require("@angular/cdk/coercion"),require("@angular/cdk/bidi")):"function"==typeof define&&define.amd?define("@angular/material/grid-list",["exports","@angular/core","@angular/material/core","@angular/cdk/coercion","@angular/cdk/bidi"],e):e((t.ng=t.ng||{},t.ng.material=t.ng.material||{},t.ng.material.gridList={}),t.ng.core,t.ng.material.core,t.ng.cdk.coercion,t.ng.cdk.bidi)}(this,function(t,e,i,r,n){"use strict";function o(t,e){function i(){this.constructor=t}l(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}function a(t){return"calc("+t+")"}function s(t){return t.match(/([A-Za-z%]+)$/)?t:t+"px"}var l=function(t,e){return(l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},d=new e.InjectionToken("MAT_GRID_LIST"),h=function(){function t(t,e){this._element=t,this._gridList=e,this._rowspan=1,this._colspan=1}return Object.defineProperty(t.prototype,"rowspan",{get:function(){return this._rowspan},set:function(t){this._rowspan=Math.round(r.coerceNumberProperty(t))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"colspan",{get:function(){return this._colspan},set:function(t){this._colspan=Math.round(r.coerceNumberProperty(t))},enumerable:!0,configurable:!0}),t.prototype._setStyle=function(t,e){this._element.nativeElement.style[t]=e},t.decorators=[{type:e.Component,args:[{selector:"mat-grid-tile",exportAs:"matGridTile",host:{class:"mat-grid-tile"},template:'<figure class="mat-figure"><ng-content></ng-content></figure>',styles:[".mat-grid-list{display:block;position:relative}.mat-grid-tile{display:block;position:absolute;overflow:hidden}.mat-grid-tile .mat-figure{top:0;left:0;right:0;bottom:0;position:absolute;display:flex;align-items:center;justify-content:center;height:100%;padding:0;margin:0}.mat-grid-tile .mat-grid-tile-footer,.mat-grid-tile .mat-grid-tile-header{display:flex;align-items:center;height:48px;color:#fff;background:rgba(0,0,0,.38);overflow:hidden;padding:0 16px;position:absolute;left:0;right:0}.mat-grid-tile .mat-grid-tile-footer>*,.mat-grid-tile .mat-grid-tile-header>*{margin:0;padding:0;font-weight:400;font-size:inherit}.mat-grid-tile .mat-grid-tile-footer.mat-2-line,.mat-grid-tile .mat-grid-tile-header.mat-2-line{height:68px}.mat-grid-tile .mat-grid-list-text{display:flex;flex-direction:column;width:100%;box-sizing:border-box;overflow:hidden}.mat-grid-tile .mat-grid-list-text>*{margin:0;padding:0;font-weight:400;font-size:inherit}.mat-grid-tile .mat-grid-list-text:empty{display:none}.mat-grid-tile .mat-grid-tile-header{top:0}.mat-grid-tile .mat-grid-tile-footer{bottom:0}.mat-grid-tile .mat-grid-avatar{padding-right:16px}[dir=rtl] .mat-grid-tile .mat-grid-avatar{padding-right:0;padding-left:16px}.mat-grid-tile .mat-grid-avatar:empty{display:none}"],encapsulation:e.ViewEncapsulation.None,changeDetection:e.ChangeDetectionStrategy.OnPush}]}],t.ctorParameters=function(){return[{type:e.ElementRef},{type:void 0,decorators:[{type:e.Optional},{type:e.Inject,args:[d]}]}]},t.propDecorators={rowspan:[{type:e.Input}],colspan:[{type:e.Input}]},t}(),c=function(){function t(t){this._element=t}return t.prototype.ngAfterContentInit=function(){i.setLines(this._lines,this._element)},t.decorators=[{type:e.Component,args:[{selector:"mat-grid-tile-header, mat-grid-tile-footer",template:'<ng-content select="[mat-grid-avatar], [matGridAvatar]"></ng-content><div class="mat-grid-list-text"><ng-content select="[mat-line], [matLine]"></ng-content></div><ng-content></ng-content>',changeDetection:e.ChangeDetectionStrategy.OnPush,encapsulation:e.ViewEncapsulation.None}]}],t.ctorParameters=function(){return[{type:e.ElementRef}]},t.propDecorators={_lines:[{type:e.ContentChildren,args:[i.MatLine]}]},t}(),g=function(){function t(){}return t.decorators=[{type:e.Directive,args:[{selector:"[mat-grid-avatar], [matGridAvatar]",host:{class:"mat-grid-avatar"}}]}],t}(),p=function(){function t(){}return t.decorators=[{type:e.Directive,args:[{selector:"mat-grid-tile-header",host:{class:"mat-grid-tile-header"}}]}],t}(),u=function(){function t(){}return t.decorators=[{type:e.Directive,args:[{selector:"mat-grid-tile-footer",host:{class:"mat-grid-tile-footer"}}]}],t}(),f=function(){function t(){this.columnIndex=0,this.rowIndex=0}return Object.defineProperty(t.prototype,"rowCount",{get:function(){return this.rowIndex+1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rowspan",{get:function(){var t=Math.max.apply(Math,this.tracker);return t>1?this.rowCount+t-1:this.rowCount},enumerable:!0,configurable:!0}),t.prototype.update=function(t,e){var i=this;this.columnIndex=0,this.rowIndex=0,this.tracker=new Array(t),this.tracker.fill(0,0,this.tracker.length),this.positions=e.map(function(t){return i._trackTile(t)})},t.prototype._trackTile=function(t){var e=this._findMatchingGap(t.colspan);return this._markTilePosition(e,t),this.columnIndex=e+t.colspan,new m(this.rowIndex,e)},t.prototype._findMatchingGap=function(t){if(t>this.tracker.length)throw Error("mat-grid-list: tile with colspan "+t+' is wider than grid with cols="'+this.tracker.length+'".');var e=-1,i=-1;do{this.columnIndex+t>this.tracker.length?(this._nextRow(),e=this.tracker.indexOf(0,this.columnIndex),i=this._findGapEndIndex(e)):(e=this.tracker.indexOf(0,this.columnIndex),-1!=e?(i=this._findGapEndIndex(e),this.columnIndex=e+1):(this._nextRow(),e=this.tracker.indexOf(0,this.columnIndex),i=this._findGapEndIndex(e)))}while(i-e<t||0==i);return Math.max(e,0)},t.prototype._nextRow=function(){this.columnIndex=0,this.rowIndex++;for(var t=0;t<this.tracker.length;t++)this.tracker[t]=Math.max(0,this.tracker[t]-1)},t.prototype._findGapEndIndex=function(t){for(var e=t+1;e<this.tracker.length;e++)if(0!=this.tracker[e])return e;return this.tracker.length},t.prototype._markTilePosition=function(t,e){for(var i=0;i<e.colspan;i++)this.tracker[t+i]=e.rowspan},t}(),m=function(){function t(t,e){this.row=t,this.col=e}return t}(),y=/^-?\d+((\.\d+)?[A-Za-z%$]?)+$/,_=function(){function t(){this._rows=0,this._rowspan=0}return t.prototype.init=function(t,e,i,r){this._gutterSize=s(t),this._rows=e.rowCount,this._rowspan=e.rowspan,this._cols=i,this._direction=r},t.prototype.getBaseTileSize=function(t,e){return"("+t+"% - ("+this._gutterSize+" * "+e+"))"},t.prototype.getTilePosition=function(t,e){return 0===e?"0":a("("+t+" + "+this._gutterSize+") * "+e)},t.prototype.getTileSize=function(t,e){return"("+t+" * "+e+") + ("+(e-1)+" * "+this._gutterSize+")"},t.prototype.setStyle=function(t,e,i){var r=100/this._cols,n=(this._cols-1)/this._cols;this.setColStyles(t,i,r,n),this.setRowStyles(t,e,r,n)},t.prototype.setColStyles=function(t,e,i,r){var n=this.getBaseTileSize(i,r),o="rtl"===this._direction?"right":"left";t._setStyle(o,this.getTilePosition(n,e)),t._setStyle("width",a(this.getTileSize(n,t.colspan)))},t.prototype.getGutterSpan=function(){return this._gutterSize+" * ("+this._rowspan+" - 1)"},t.prototype.getTileSpan=function(t){return this._rowspan+" * "+this.getTileSize(t,1)},t.prototype.getComputedHeight=function(){return null},t}(),w=function(t){function e(e){var i=t.call(this)||this;return i.fixedRowHeight=e,i}return o(e,t),e.prototype.init=function(e,i,r,n){if(t.prototype.init.call(this,e,i,r,n),this.fixedRowHeight=s(this.fixedRowHeight),!y.test(this.fixedRowHeight))throw Error('Invalid value "'+this.fixedRowHeight+'" set as rowHeight.')},e.prototype.setRowStyles=function(t,e){t._setStyle("top",this.getTilePosition(this.fixedRowHeight,e)),t._setStyle("height",a(this.getTileSize(this.fixedRowHeight,t.rowspan)))},e.prototype.getComputedHeight=function(){return["height",a(this.getTileSpan(this.fixedRowHeight)+" + "+this.getGutterSpan())]},e.prototype.reset=function(t){t._setListStyle(["height",null]),t._tiles&&t._tiles.forEach(function(t){t._setStyle("top",null),t._setStyle("height",null)})},e}(_),x=function(t){function e(e){var i=t.call(this)||this;return i._parseRatio(e),i}return o(e,t),e.prototype.setRowStyles=function(t,e,i,r){var n=i/this.rowHeightRatio;this.baseTileHeight=this.getBaseTileSize(n,r),t._setStyle("marginTop",this.getTilePosition(this.baseTileHeight,e)),t._setStyle("paddingTop",a(this.getTileSize(this.baseTileHeight,t.rowspan)))},e.prototype.getComputedHeight=function(){return["paddingBottom",a(this.getTileSpan(this.baseTileHeight)+" + "+this.getGutterSpan())]},e.prototype.reset=function(t){t._setListStyle(["paddingBottom",null]),t._tiles.forEach(function(t){t._setStyle("marginTop",null),t._setStyle("paddingTop",null)})},e.prototype._parseRatio=function(t){var e=t.split(":");if(2!==e.length)throw Error('mat-grid-list: invalid ratio given for row-height: "'+t+'"');this.rowHeightRatio=parseFloat(e[0])/parseFloat(e[1])},e}(_),S=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.setRowStyles=function(t,e){var i=100/this._rowspan,r=(this._rows-1)/this._rows,n=this.getBaseTileSize(i,r);t._setStyle("top",this.getTilePosition(n,e)),t._setStyle("height",a(this.getTileSize(n,t.rowspan)))},e.prototype.reset=function(t){t._tiles&&t._tiles.forEach(function(t){t._setStyle("top",null),t._setStyle("height",null)})},e}(_),b=function(){function t(t,e){this._element=t,this._dir=e,this._gutter="1px"}return Object.defineProperty(t.prototype,"cols",{get:function(){return this._cols},set:function(t){this._cols=Math.max(1,Math.round(r.coerceNumberProperty(t)))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"gutterSize",{get:function(){return this._gutter},set:function(t){this._gutter=""+(null==t?"":t)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rowHeight",{get:function(){return this._rowHeight},set:function(t){var e=""+(null==t?"":t);e!==this._rowHeight&&(this._rowHeight=e,this._setTileStyler(this._rowHeight))},enumerable:!0,configurable:!0}),t.prototype.ngOnInit=function(){this._checkCols(),this._checkRowHeight()},t.prototype.ngAfterContentChecked=function(){this._layoutTiles()},t.prototype._checkCols=function(){if(!this.cols)throw Error('mat-grid-list: must pass in number of columns. Example: <mat-grid-list cols="3">')},t.prototype._checkRowHeight=function(){this._rowHeight||this._setTileStyler("1:1")},t.prototype._setTileStyler=function(t){this._tileStyler&&this._tileStyler.reset(this),"fit"===t?this._tileStyler=new S:t&&t.indexOf(":")>-1?this._tileStyler=new x(t):this._tileStyler=new w(t)},t.prototype._layoutTiles=function(){var t=this;this._tileCoordinator||(this._tileCoordinator=new f);var e=this._tileCoordinator,i=this._tiles.filter(function(e){return!e._gridList||e._gridList===t}),r=this._dir?this._dir.value:"ltr";this._tileCoordinator.update(this.cols,i),this._tileStyler.init(this.gutterSize,e,this.cols,r),i.forEach(function(i,r){var n=e.positions[r];t._tileStyler.setStyle(i,n.row,n.col)}),this._setListStyle(this._tileStyler.getComputedHeight())},t.prototype._setListStyle=function(t){t&&(this._element.nativeElement.style[t[0]]=t[1])},t.decorators=[{type:e.Component,args:[{selector:"mat-grid-list",exportAs:"matGridList",template:"<div><ng-content></ng-content></div>",styles:[".mat-grid-list{display:block;position:relative}.mat-grid-tile{display:block;position:absolute;overflow:hidden}.mat-grid-tile .mat-figure{top:0;left:0;right:0;bottom:0;position:absolute;display:flex;align-items:center;justify-content:center;height:100%;padding:0;margin:0}.mat-grid-tile .mat-grid-tile-footer,.mat-grid-tile .mat-grid-tile-header{display:flex;align-items:center;height:48px;color:#fff;background:rgba(0,0,0,.38);overflow:hidden;padding:0 16px;position:absolute;left:0;right:0}.mat-grid-tile .mat-grid-tile-footer>*,.mat-grid-tile .mat-grid-tile-header>*{margin:0;padding:0;font-weight:400;font-size:inherit}.mat-grid-tile .mat-grid-tile-footer.mat-2-line,.mat-grid-tile .mat-grid-tile-header.mat-2-line{height:68px}.mat-grid-tile .mat-grid-list-text{display:flex;flex-direction:column;width:100%;box-sizing:border-box;overflow:hidden}.mat-grid-tile .mat-grid-list-text>*{margin:0;padding:0;font-weight:400;font-size:inherit}.mat-grid-tile .mat-grid-list-text:empty{display:none}.mat-grid-tile .mat-grid-tile-header{top:0}.mat-grid-tile .mat-grid-tile-footer{bottom:0}.mat-grid-tile .mat-grid-avatar{padding-right:16px}[dir=rtl] .mat-grid-tile .mat-grid-avatar{padding-right:0;padding-left:16px}.mat-grid-tile .mat-grid-avatar:empty{display:none}"],host:{class:"mat-grid-list"},providers:[{provide:d,useExisting:t}],changeDetection:e.ChangeDetectionStrategy.OnPush,encapsulation:e.ViewEncapsulation.None}]}],t.ctorParameters=function(){return[{type:e.ElementRef},{type:n.Directionality,decorators:[{type:e.Optional}]}]},t.propDecorators={_tiles:[{type:e.ContentChildren,args:[h,{descendants:!0}]}],cols:[{type:e.Input}],gutterSize:[{type:e.Input}],rowHeight:[{type:e.Input}]},t}(),v=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{imports:[i.MatLineModule,i.MatCommonModule],exports:[b,h,c,i.MatLineModule,i.MatCommonModule,p,u,g],declarations:[b,h,c,p,u,g]}]}],t}();t.MatGridListModule=v,t.MatGridList=b,t.MatGridTile=h,t.MatGridTileText=c,t.MatGridAvatarCssMatStyler=g,t.MatGridTileHeaderCssMatStyler=p,t.MatGridTileFooterCssMatStyler=u,ta6=d,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=material-grid-list.umd.min.js.map