UNPKG

@angular/material

Version:
30 lines 14.3 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/material/core"),require("@angular/cdk/coercion"),require("tslib"),require("@angular/cdk/bidi")):"function"==typeof define&&define.amd?define("@angular/material/grid-list",["exports","@angular/core","@angular/material/core","@angular/cdk/coercion","tslib","@angular/cdk/bidi"],e):e(((t=t||self).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.tslib,t.ng.cdk.bidi)}(this,(function(t,e,i,r,n,o){"use strict"; /** * @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 a=new e.InjectionToken("MAT_GRID_LIST"),s=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","[attr.rowspan]":"rowspan","[attr.colspan]":"colspan"},template:'\x3c!-- TODO(kara): Revisit why this is a figure.--\x3e\n<figure class="mat-figure">\n <ng-content></ng-content>\n</figure>',encapsulation:e.ViewEncapsulation.None,changeDetection:e.ChangeDetectionStrategy.OnPush,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-header,.mat-grid-tile .mat-grid-tile-footer{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-header>*,.mat-grid-tile .mat-grid-tile-footer>*{margin:0;padding:0;font-weight:normal;font-size:inherit}.mat-grid-tile .mat-grid-tile-header.mat-2-line,.mat-grid-tile .mat-grid-tile-footer.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:normal;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}\n"]}]}],t.ctorParameters=function(){return[{type:e.ElementRef},{type:void 0,decorators:[{type:e.Optional},{type:e.Inject,args:[a]}]}]},t.propDecorators={rowspan:[{type:e.Input}],colspan:[{type:e.Input}]},t}(),l=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>\n<div class="mat-grid-list-text"><ng-content select="[mat-line], [matLine]"></ng-content></div>\n<ng-content></ng-content>\n',changeDetection:e.ChangeDetectionStrategy.OnPush,encapsulation:e.ViewEncapsulation.None}]}],t.ctorParameters=function(){return[{type:e.ElementRef}]},t.propDecorators={_lines:[{type:e.ContentChildren,args:[i.MatLine,{descendants:!0}]}]},t}(),d=function(){function t(){}return t.decorators=[{type:e.Directive,args:[{selector:"[mat-grid-avatar], [matGridAvatar]",host:{class:"mat-grid-avatar"}}]}],t}(),g=function(){function t(){}return t.decorators=[{type:e.Directive,args:[{selector:"mat-grid-tile-header",host:{class:"mat-grid-tile-header"}}]}],t}(),h=function(){function t(){}return t.decorators=[{type:e.Directive,args:[{selector:"mat-grid-tile-footer",host:{class:"mat-grid-tile-footer"}}]}],t}(),c=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,n.__spread(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 p(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)):-1!=(e=this.tracker.indexOf(0,this.columnIndex))?(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}(),p=function p(t,e){this.row=t,this.col=e},u=/^-?\d+((\.\d+)?[A-Za-z%$]?)+$/,f=function(){function t(){this._rows=0,this._rowspan=0}return t.prototype.init=function(t,e,i,r){this._gutterSize=x(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":w("("+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);t._setStyle("rtl"===this._direction?"right":"left",this.getTilePosition(n,e)),t._setStyle("width",w(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}(),m=function(t){function e(e){var i=t.call(this)||this;return i.fixedRowHeight=e,i}return n.__extends(e,t),e.prototype.init=function(e,i,r,n){if(t.prototype.init.call(this,e,i,r,n),this.fixedRowHeight=x(this.fixedRowHeight),!u.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",w(this.getTileSize(this.fixedRowHeight,t.rowspan)))},e.prototype.getComputedHeight=function(){return["height",w(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}(f),y=function(t){function e(e){var i=t.call(this)||this;return i._parseRatio(e),i}return n.__extends(e,t),e.prototype.setRowStyles=function(t,e,i,r){this.baseTileHeight=this.getBaseTileSize(i/this.rowHeightRatio,r),t._setStyle("marginTop",this.getTilePosition(this.baseTileHeight,e)),t._setStyle("paddingTop",w(this.getTileSize(this.baseTileHeight,t.rowspan)))},e.prototype.getComputedHeight=function(){return["paddingBottom",w(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}(f),_=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n.__extends(e,t),e.prototype.setRowStyles=function(t,e){var i=this.getBaseTileSize(100/this._rowspan,(this._rows-1)/this._rows);t._setStyle("top",this.getTilePosition(i,e)),t._setStyle("height",w(this.getTileSize(i,t.rowspan)))},e.prototype.reset=function(t){t._tiles&&t._tiles.forEach((function(t){t._setStyle("top",null),t._setStyle("height",null)}))},e}(f); /** * @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 w(t){return"calc("+t+")"}function x(t){return t.match(/([A-Za-z%]+)$/)?t:t+"px"} /** * @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 S=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),this._tileStyler="fit"===t?new _:t&&t.indexOf(":")>-1?new y(t):new m(t)},t.prototype._layoutTiles=function(){var t=this;this._tileCoordinator||(this._tileCoordinator=new c);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>\n <ng-content></ng-content>\n</div>",host:{class:"mat-grid-list","[attr.cols]":"cols"},providers:[{provide:a,useExisting:t}],changeDetection:e.ChangeDetectionStrategy.OnPush,encapsulation:e.ViewEncapsulation.None,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-header,.mat-grid-tile .mat-grid-tile-footer{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-header>*,.mat-grid-tile .mat-grid-tile-footer>*{margin:0;padding:0;font-weight:normal;font-size:inherit}.mat-grid-tile .mat-grid-tile-header.mat-2-line,.mat-grid-tile .mat-grid-tile-footer.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:normal;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}\n"]}]}],t.ctorParameters=function(){return[{type:e.ElementRef},{type:o.Directionality,decorators:[{type:e.Optional}]}]},t.propDecorators={_tiles:[{type:e.ContentChildren,args:[s,{descendants:!0}]}],cols:[{type:e.Input}],gutterSize:[{type:e.Input}],rowHeight:[{type:e.Input}]},t}(),b=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{imports:[i.MatLineModule,i.MatCommonModule],exports:[S,s,l,i.MatLineModule,i.MatCommonModule,g,h,d],declarations:[S,s,l,g,h,d]}]}],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 */ t.MatGridAvatarCssMatStyler=d,t.MatGridList=S,t.MatGridListModule=b,t.MatGridTile=s,t.MatGridTileFooterCssMatStyler=h,t.MatGridTileHeaderCssMatStyler=g,t.MatGridTileText=l,t.ɵTileCoordinator=c,t.ɵangular_material_src_material_grid_list_grid_list_a=a,Object.defineProperty(t,"__esModule",{value:!0})}));