UNPKG

@angular/material

Version:
46 lines (44 loc) 15.4 kB
!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=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.ng.cdk.bidi)}(this,(function(t,e,i,r,n){"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 o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(t,e)};function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}function s(t,e){var i="function"==typeof Symbol&&t[Symbol.iterator];if(!i)return t;var r,n,o=i.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(t){n={error:t}}finally{try{r&&!r.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return a} /** * @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(){function t(){this.columnIndex=0,this.rowIndex=0}return Object.defineProperty(t.prototype,"rowCount",{get:function(){return this.rowIndex+1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rowspan",{get:function(){var t=Math.max.apply(Math,function e(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(s(arguments[e]));return t}(this.tracker));return t>1?this.rowCount+t-1:this.rowCount},enumerable:!1,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 c(this.rowIndex,e)},t.prototype._findMatchingGap=function(t){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}(),c=function c(t,e){this.row=t,this.col=e},d=new e.InjectionToken("MAT_GRID_LIST"),p=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:!1,configurable:!0}),Object.defineProperty(t.prototype,"colspan",{get:function(){return this._colspan},set:function(t){this._colspan=Math.round(r.coerceNumberProperty(t))},enumerable:!1,configurable:!0}),t.prototype._setStyle=function(t,e){this._element.nativeElement.style[t]=e},t}();p.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;flex:auto;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"]}]}],p.ctorParameters=function(){return[{type:e.ElementRef},{type:void 0,decorators:[{type:e.Optional},{type:e.Inject,args:[d]}]}]},p.propDecorators={rowspan:[{type:e.Input}],colspan:[{type:e.Input}]};var g,h,u,f=function(){function t(t){this._element=t}return t.prototype.ngAfterContentInit=function(){i.setLines(this._lines,this._element)},t}();f.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}]}],f.ctorParameters=function(){return[{type:e.ElementRef}]},f.propDecorators={_lines:[{type:e.ContentChildren,args:[i.MatLine,{descendants:!0}]}]},(g=function g(){}).decorators=[{type:e.Directive,args:[{selector:"[mat-grid-avatar], [matGridAvatar]",host:{class:"mat-grid-avatar"}}]}],(h=function h(){}).decorators=[{type:e.Directive,args:[{selector:"mat-grid-tile-header",host:{class:"mat-grid-tile-header"}}]}],(u=function u(){}).decorators=[{type:e.Directive,args:[{selector:"mat-grid-tile-footer",host:{class:"mat-grid-tile-footer"}}]}]; /** * @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 m=/^-?\d+((\.\d+)?[A-Za-z%$]?)+$/,y=function(){function t(){this._rows=0,this._rowspan=0}return t.prototype.init=function(t,e,i,r){this._gutterSize=v(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":S("("+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",S(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}(),_=function(t){function e(e){var i=t.call(this)||this;return i.fixedRowHeight=e,i}return a(e,t),e.prototype.init=function(e,i,r,n){t.prototype.init.call(this,e,i,r,n),this.fixedRowHeight=v(this.fixedRowHeight),m.test(this.fixedRowHeight)},e.prototype.setRowStyles=function(t,e){t._setStyle("top",this.getTilePosition(this.fixedRowHeight,e)),t._setStyle("height",S(this.getTileSize(this.fixedRowHeight,t.rowspan)))},e.prototype.getComputedHeight=function(){return["height",S(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}(y),w=function(t){function e(e){var i=t.call(this)||this;return i._parseRatio(e),i}return a(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",S(this.getTileSize(this.baseTileHeight,t.rowspan)))},e.prototype.getComputedHeight=function(){return["paddingBottom",S(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(":");this.rowHeightRatio=parseFloat(e[0])/parseFloat(e[1])},e}(y),x=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return a(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",S(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}(y);function S(t){return"calc("+t+")"}function v(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 b,T=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:!1,configurable:!0}),Object.defineProperty(t.prototype,"gutterSize",{get:function(){return this._gutter},set:function(t){this._gutter=""+(null==t?"":t)},enumerable:!1,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:!1,configurable:!0}),t.prototype.ngOnInit=function(){this._checkCols(),this._checkRowHeight()},t.prototype.ngAfterContentChecked=function(){this._layoutTiles()},t.prototype._checkCols=function(){},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 x:t&&t.indexOf(":")>-1?new w(t):new _(t)},t.prototype._layoutTiles=function(){var t=this;this._tileCoordinator||(this._tileCoordinator=new l);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}();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:d,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;flex:auto;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:n.Directionality,decorators:[{type:e.Optional}]}]},T.propDecorators={_tiles:[{type:e.ContentChildren,args:[p,{descendants:!0}]}],cols:[{type:e.Input}],gutterSize:[{type:e.Input}],rowHeight:[{type:e.Input}]},(b=function b(){}).decorators=[{type:e.NgModule,args:[{imports:[i.MatLineModule,i.MatCommonModule],exports:[T,p,f,i.MatLineModule,i.MatCommonModule,h,u,g],declarations:[T,p,f,h,u,g]}]}]; /** * @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 k=l;t.MatGridAvatarCssMatStyler=g,t.MatGridList=T,t.MatGridListModule=b,t.MatGridTile=p,t.MatGridTileFooterCssMatStyler=u,t.MatGridTileHeaderCssMatStyler=h,t.MatGridTileText=f,t.ɵTileCoordinator=k,t.ɵangular_material_src_material_grid_list_grid_list_a=d,Object.defineProperty(t,"__esModule",{value:!0})}));