/** * @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 */ import { Component, ViewEncapsulation, Input, ContentChildren, QueryList, ElementRef, Optional, ChangeDetectionStrategy, } from '@angular/core'; import { MatGridTile } from './grid-tile'; import { TileCoordinator } from './tile-coordinator'; import { FitTileStyler, RatioTileStyler, FixedTileStyler, } from './tile-styler'; import { Directionality } from '@angular/cdk/bidi'; import { coerceNumberProperty } from '@angular/cdk/coercion'; import { MAT_GRID_LIST } from './grid-list-base'; import * as i0 from "@angular/core"; import * as i1 from "@angular/cdk/bidi"; // TODO(kara): Conditional (responsive) column count / row size. // TODO(kara): Re-layout on window resize / media change (debounced). // TODO(kara): gridTileHeader and gridTileFooter. const MAT_FIT_MODE = 'fit'; export class MatGridList { constructor(_element, _dir) { this._element = _element; this._dir = _dir; /** The amount of space between tiles. This will be something like '5px' or '2em'. */ this._gutter = '1px'; } /** Amount of columns in the grid list. */ get cols() { return this._cols; } set cols(value) { this._cols = Math.max(1, Math.round(coerceNumberProperty(value))); } /** Size of the grid list's gutter in pixels. */ get gutterSize() { return this._gutter; } set gutterSize(value) { this._gutter = `${value == null ? '' : value}`; } /** Set internal representation of row height from the user-provided value. */ get rowHeight() { return this._rowHeight; } set rowHeight(value) { const newValue = `${value == null ? '' : value}`; if (newValue !== this._rowHeight) { this._rowHeight = newValue; this._setTileStyler(this._rowHeight); } } ngOnInit() { this._checkCols(); this._checkRowHeight(); } /** * The layout calculation is fairly cheap if nothing changes, so there's little cost * to run it frequently. */ ngAfterContentChecked() { this._layoutTiles(); } /** Throw a friendly error if cols property is missing */ _checkCols() { if (!this.cols && (typeof ngDevMode === 'undefined' || ngDevMode)) { throw Error(`mat-grid-list: must pass in number of columns. ` + `Example: `); } } /** Default to equal width:height if rowHeight property is missing */ _checkRowHeight() { if (!this._rowHeight) { this._setTileStyler('1:1'); } } /** Creates correct Tile Styler subtype based on rowHeight passed in by user */ _setTileStyler(rowHeight) { if (this._tileStyler) { this._tileStyler.reset(this); } if (rowHeight === MAT_FIT_MODE) { this._tileStyler = new FitTileStyler(); } else if (rowHeight && rowHeight.indexOf(':') > -1) { this._tileStyler = new RatioTileStyler(rowHeight); } else { this._tileStyler = new FixedTileStyler(rowHeight); } } /** Computes and applies the size and position for all children grid tiles. */ _layoutTiles() { if (!this._tileCoordinator) { this._tileCoordinator = new TileCoordinator(); } const tracker = this._tileCoordinator; const tiles = this._tiles.filter(tile => !tile._gridList || tile._gridList === this); const direction = this._dir ? this._dir.value : 'ltr'; this._tileCoordinator.update(this.cols, tiles); this._tileStyler.init(this.gutterSize, tracker, this.cols, direction); tiles.forEach((tile, index) => { const pos = tracker.positions[index]; this._tileStyler.setStyle(tile, pos.row, pos.col); }); this._setListStyle(this._tileStyler.getComputedHeight()); } /** Sets style on the main grid-list element, given the style name and value. */ _setListStyle(style) { if (style) { this._element.nativeElement.style[style[0]] = style[1]; } } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatGridList, deps: [{ token: i0.ElementRef }, { token: i1.Directionality, optional: true }], target: i0.ɵɵFactoryTarget.Component }); } static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.1", type: MatGridList, selector: "mat-grid-list", inputs: { cols: "cols", gutterSize: "gutterSize", rowHeight: "rowHeight" }, host: { properties: { "attr.cols": "cols" }, classAttribute: "mat-grid-list" }, providers: [ { provide: MAT_GRID_LIST, useExisting: MatGridList, }, ], queries: [{ propertyName: "_tiles", predicate: MatGridTile, descendants: true }], exportAs: ["matGridList"], ngImport: i0, template: "
\n \n
", styles: [".mat-grid-list{display:block;position:relative}.mat-grid-tile{display:block;position:absolute;overflow:hidden}.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}.mat-grid-tile-header{font-size:var(--mat-grid-list-tile-header-primary-text-size)}.mat-grid-tile-header .mat-line{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:block;box-sizing:border-box}.mat-grid-tile-header .mat-line:nth-child(n+2){font-size:var(--mat-grid-list-tile-header-secondary-text-size)}.mat-grid-tile-footer{font-size:var(--mat-grid-list-tile-footer-primary-text-size)}.mat-grid-tile-footer .mat-line{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:block;box-sizing:border-box}.mat-grid-tile-footer .mat-line:nth-child(n+2){font-size:var(--mat-grid-list-tile-footer-secondary-text-size)}.mat-grid-tile-content{top:0;left:0;right:0;bottom:0;position:absolute;display:flex;align-items:center;justify-content:center;height:100%;padding:0;margin:0}"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatGridList, decorators: [{ type: Component, args: [{ selector: 'mat-grid-list', exportAs: 'matGridList', host: { 'class': 'mat-grid-list', // Ensures that the "cols" input value is reflected in the DOM. This is // needed for the grid-list harness. '[attr.cols]': 'cols', }, providers: [ { provide: MAT_GRID_LIST, useExisting: MatGridList, }, ], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: "
\n \n
", styles: [".mat-grid-list{display:block;position:relative}.mat-grid-tile{display:block;position:absolute;overflow:hidden}.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}.mat-grid-tile-header{font-size:var(--mat-grid-list-tile-header-primary-text-size)}.mat-grid-tile-header .mat-line{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:block;box-sizing:border-box}.mat-grid-tile-header .mat-line:nth-child(n+2){font-size:var(--mat-grid-list-tile-header-secondary-text-size)}.mat-grid-tile-footer{font-size:var(--mat-grid-list-tile-footer-primary-text-size)}.mat-grid-tile-footer .mat-line{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:block;box-sizing:border-box}.mat-grid-tile-footer .mat-line:nth-child(n+2){font-size:var(--mat-grid-list-tile-footer-secondary-text-size)}.mat-grid-tile-content{top:0;left:0;right:0;bottom:0;position:absolute;display:flex;align-items:center;justify-content:center;height:100%;padding:0;margin:0}"] }] }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i1.Directionality, decorators: [{ type: Optional }] }]; }, propDecorators: { _tiles: [{ type: ContentChildren, args: [MatGridTile, { descendants: true }] }], cols: [{ type: Input }], gutterSize: [{ type: Input }], rowHeight: [{ type: Input }] } }); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ3JpZC1saXN0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vc3JjL21hdGVyaWFsL2dyaWQtbGlzdC9ncmlkLWxpc3QudHMiLCIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvbWF0ZXJpYWwvZ3JpZC1saXN0L2dyaWQtbGlzdC5odG1sIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRztBQUVILE9BQU8sRUFDTCxTQUFTLEVBQ1QsaUJBQWlCLEVBR2pCLEtBQUssRUFDTCxlQUFlLEVBQ2YsU0FBUyxFQUNULFVBQVUsRUFDVixRQUFRLEVBQ1IsdUJBQXVCLEdBQ3hCLE1BQU0sZUFBZSxDQUFDO0FBQ3ZCLE9BQU8sRUFBQyxXQUFXLEVBQUMsTUFBTSxhQUFhLENBQUM7QUFDeEMsT0FBTyxFQUFDLGVBQWUsRUFBQyxNQUFNLG9CQUFvQixDQUFDO0FBQ25ELE9BQU8sRUFFTCxhQUFhLEVBQ2IsZUFBZSxFQUNmLGVBQWUsR0FFaEIsTUFBTSxlQUFlLENBQUM7QUFDdkIsT0FBTyxFQUFDLGNBQWMsRUFBQyxNQUFNLG1CQUFtQixDQUFDO0FBQ2pELE9BQU8sRUFBQyxvQkFBb0IsRUFBYyxNQUFNLHVCQUF1QixDQUFDO0FBQ3hFLE9BQU8sRUFBQyxhQUFhLEVBQWtCLE1BQU0sa0JBQWtCLENBQUM7OztBQUVoRSxnRUFBZ0U7QUFDaEUscUVBQX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