| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246 |
- /**
- * @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 { InjectionToken, Component, ViewEncapsulation, ElementRef, Input, Optional, ContentChildren, Directive, ChangeDetectionStrategy, Inject, NgModule } from '@angular/core';
- import { MatLine, setLines, MatLineModule, MatCommonModule } from '@angular/material/core';
- import { coerceNumberProperty } from '@angular/cdk/coercion';
- import { __extends } from 'tslib';
- import { Directionality } from '@angular/cdk/bidi';
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /**
- * Injection token used to provide a grid list to a tile and to avoid circular imports.
- * \@docs-private
- * @type {?}
- */
- var MAT_GRID_LIST = new InjectionToken('MAT_GRID_LIST');
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- var MatGridTile = /** @class */ (function () {
- function MatGridTile(_element, _gridList) {
- this._element = _element;
- this._gridList = _gridList;
- this._rowspan = 1;
- this._colspan = 1;
- }
- Object.defineProperty(MatGridTile.prototype, "rowspan", {
- /** Amount of rows that the grid tile takes up. */
- get: /**
- * Amount of rows that the grid tile takes up.
- * @return {?}
- */
- function () { return this._rowspan; },
- set: /**
- * @param {?} value
- * @return {?}
- */
- function (value) { this._rowspan = Math.round(coerceNumberProperty(value)); },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MatGridTile.prototype, "colspan", {
- /** Amount of columns that the grid tile takes up. */
- get: /**
- * Amount of columns that the grid tile takes up.
- * @return {?}
- */
- function () { return this._colspan; },
- set: /**
- * @param {?} value
- * @return {?}
- */
- function (value) { this._colspan = Math.round(coerceNumberProperty(value)); },
- enumerable: true,
- configurable: true
- });
- /**
- * Sets the style of the grid-tile element. Needs to be set manually to avoid
- * "Changed after checked" errors that would occur with HostBinding.
- */
- /**
- * Sets the style of the grid-tile element. Needs to be set manually to avoid
- * "Changed after checked" errors that would occur with HostBinding.
- * @param {?} property
- * @param {?} value
- * @return {?}
- */
- MatGridTile.prototype._setStyle = /**
- * Sets the style of the grid-tile element. Needs to be set manually to avoid
- * "Changed after checked" errors that would occur with HostBinding.
- * @param {?} property
- * @param {?} value
- * @return {?}
- */
- function (property, value) {
- ((/** @type {?} */ (this._element.nativeElement.style)))[property] = value;
- };
- MatGridTile.decorators = [
- { type: 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: ViewEncapsulation.None,
- changeDetection: ChangeDetectionStrategy.OnPush,
- },] },
- ];
- /** @nocollapse */
- MatGridTile.ctorParameters = function () { return [
- { type: ElementRef },
- { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [MAT_GRID_LIST,] }] }
- ]; };
- MatGridTile.propDecorators = {
- rowspan: [{ type: Input }],
- colspan: [{ type: Input }]
- };
- return MatGridTile;
- }());
- var MatGridTileText = /** @class */ (function () {
- function MatGridTileText(_element) {
- this._element = _element;
- }
- /**
- * @return {?}
- */
- MatGridTileText.prototype.ngAfterContentInit = /**
- * @return {?}
- */
- function () {
- setLines(this._lines, this._element);
- };
- MatGridTileText.decorators = [
- { type: 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: ChangeDetectionStrategy.OnPush,
- encapsulation: ViewEncapsulation.None,
- },] },
- ];
- /** @nocollapse */
- MatGridTileText.ctorParameters = function () { return [
- { type: ElementRef }
- ]; };
- MatGridTileText.propDecorators = {
- _lines: [{ type: ContentChildren, args: [MatLine,] }]
- };
- return MatGridTileText;
- }());
- /**
- * Directive whose purpose is to add the mat- CSS styling to this selector.
- * \@docs-private
- */
- var MatGridAvatarCssMatStyler = /** @class */ (function () {
- function MatGridAvatarCssMatStyler() {
- }
- MatGridAvatarCssMatStyler.decorators = [
- { type: Directive, args: [{
- selector: '[mat-grid-avatar], [matGridAvatar]',
- host: { 'class': 'mat-grid-avatar' }
- },] },
- ];
- return MatGridAvatarCssMatStyler;
- }());
- /**
- * Directive whose purpose is to add the mat- CSS styling to this selector.
- * \@docs-private
- */
- var MatGridTileHeaderCssMatStyler = /** @class */ (function () {
- function MatGridTileHeaderCssMatStyler() {
- }
- MatGridTileHeaderCssMatStyler.decorators = [
- { type: Directive, args: [{
- selector: 'mat-grid-tile-header',
- host: { 'class': 'mat-grid-tile-header' }
- },] },
- ];
- return MatGridTileHeaderCssMatStyler;
- }());
- /**
- * Directive whose purpose is to add the mat- CSS styling to this selector.
- * \@docs-private
- */
- var MatGridTileFooterCssMatStyler = /** @class */ (function () {
- function MatGridTileFooterCssMatStyler() {
- }
- MatGridTileFooterCssMatStyler.decorators = [
- { type: Directive, args: [{
- selector: 'mat-grid-tile-footer',
- host: { 'class': 'mat-grid-tile-footer' }
- },] },
- ];
- return MatGridTileFooterCssMatStyler;
- }());
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /**
- * Class for determining, from a list of tiles, the (row, col) position of each of those tiles
- * in the grid. This is necessary (rather than just rendering the tiles in normal document flow)
- * because the tiles can have a rowspan.
- *
- * The positioning algorithm greedily places each tile as soon as it encounters a gap in the grid
- * large enough to accommodate it so that the tiles still render in the same order in which they
- * are given.
- *
- * The basis of the algorithm is the use of an array to track the already placed tiles. Each
- * element of the array corresponds to a column, and the value indicates how many cells in that
- * column are already occupied; zero indicates an empty cell. Moving "down" to the next row
- * decrements each value in the tracking array (indicating that the column is one cell closer to
- * being free).
- *
- * \@docs-private
- */
- var /**
- * Class for determining, from a list of tiles, the (row, col) position of each of those tiles
- * in the grid. This is necessary (rather than just rendering the tiles in normal document flow)
- * because the tiles can have a rowspan.
- *
- * The positioning algorithm greedily places each tile as soon as it encounters a gap in the grid
- * large enough to accommodate it so that the tiles still render in the same order in which they
- * are given.
- *
- * The basis of the algorithm is the use of an array to track the already placed tiles. Each
- * element of the array corresponds to a column, and the value indicates how many cells in that
- * column are already occupied; zero indicates an empty cell. Moving "down" to the next row
- * decrements each value in the tracking array (indicating that the column is one cell closer to
- * being free).
- *
- * \@docs-private
- */
- TileCoordinator = /** @class */ (function () {
- function TileCoordinator() {
- /**
- * Index at which the search for the next gap will start.
- */
- this.columnIndex = 0;
- /**
- * The current row index.
- */
- this.rowIndex = 0;
- }
- Object.defineProperty(TileCoordinator.prototype, "rowCount", {
- /** Gets the total number of rows occupied by tiles */
- get: /**
- * Gets the total number of rows occupied by tiles
- * @return {?}
- */
- function () { return this.rowIndex + 1; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(TileCoordinator.prototype, "rowspan", {
- /**
- * Gets the total span of rows occupied by tiles.
- * Ex: A list with 1 row that contains a tile with rowspan 2 will have a total rowspan of 2.
- */
- get: /**
- * Gets the total span of rows occupied by tiles.
- * Ex: A list with 1 row that contains a tile with rowspan 2 will have a total rowspan of 2.
- * @return {?}
- */
- function () {
- /** @type {?} */
- var lastRowMax = Math.max.apply(Math, this.tracker);
- // if any of the tiles has a rowspan that pushes it beyond the total row count,
- // add the difference to the rowcount
- return lastRowMax > 1 ? this.rowCount + lastRowMax - 1 : this.rowCount;
- },
- enumerable: true,
- configurable: true
- });
- /**
- * Updates the tile positions.
- * @param numColumns Amount of columns in the grid.
- */
- /**
- * Updates the tile positions.
- * @param {?} numColumns Amount of columns in the grid.
- * @param {?} tiles
- * @return {?}
- */
- TileCoordinator.prototype.update = /**
- * Updates the tile positions.
- * @param {?} numColumns Amount of columns in the grid.
- * @param {?} tiles
- * @return {?}
- */
- function (numColumns, tiles) {
- var _this = this;
- this.columnIndex = 0;
- this.rowIndex = 0;
- this.tracker = new Array(numColumns);
- this.tracker.fill(0, 0, this.tracker.length);
- this.positions = tiles.map((/**
- * @param {?} tile
- * @return {?}
- */
- function (tile) { return _this._trackTile(tile); }));
- };
- /** Calculates the row and col position of a tile. */
- /**
- * Calculates the row and col position of a tile.
- * @private
- * @param {?} tile
- * @return {?}
- */
- TileCoordinator.prototype._trackTile = /**
- * Calculates the row and col position of a tile.
- * @private
- * @param {?} tile
- * @return {?}
- */
- function (tile) {
- // Find a gap large enough for this tile.
- /** @type {?} */
- var gapStartIndex = this._findMatchingGap(tile.colspan);
- // Place tile in the resulting gap.
- this._markTilePosition(gapStartIndex, tile);
- // The next time we look for a gap, the search will start at columnIndex, which should be
- // immediately after the tile that has just been placed.
- this.columnIndex = gapStartIndex + tile.colspan;
- return new TilePosition(this.rowIndex, gapStartIndex);
- };
- /** Finds the next available space large enough to fit the tile. */
- /**
- * Finds the next available space large enough to fit the tile.
- * @private
- * @param {?} tileCols
- * @return {?}
- */
- TileCoordinator.prototype._findMatchingGap = /**
- * Finds the next available space large enough to fit the tile.
- * @private
- * @param {?} tileCols
- * @return {?}
- */
- function (tileCols) {
- if (tileCols > this.tracker.length) {
- throw Error("mat-grid-list: tile with colspan " + tileCols + " is wider than " +
- ("grid with cols=\"" + this.tracker.length + "\"."));
- }
- // Start index is inclusive, end index is exclusive.
- /** @type {?} */
- var gapStartIndex = -1;
- /** @type {?} */
- var gapEndIndex = -1;
- // Look for a gap large enough to fit the given tile. Empty spaces are marked with a zero.
- do {
- // If we've reached the end of the row, go to the next row.
- if (this.columnIndex + tileCols > this.tracker.length) {
- this._nextRow();
- gapStartIndex = this.tracker.indexOf(0, this.columnIndex);
- gapEndIndex = this._findGapEndIndex(gapStartIndex);
- continue;
- }
- gapStartIndex = this.tracker.indexOf(0, this.columnIndex);
- // If there are no more empty spaces in this row at all, move on to the next row.
- if (gapStartIndex == -1) {
- this._nextRow();
- gapStartIndex = this.tracker.indexOf(0, this.columnIndex);
- gapEndIndex = this._findGapEndIndex(gapStartIndex);
- continue;
- }
- gapEndIndex = this._findGapEndIndex(gapStartIndex);
- // If a gap large enough isn't found, we want to start looking immediately after the current
- // gap on the next iteration.
- this.columnIndex = gapStartIndex + 1;
- // Continue iterating until we find a gap wide enough for this tile. Since gapEndIndex is
- // exclusive, gapEndIndex is 0 means we didn't find a gap and should continue.
- } while ((gapEndIndex - gapStartIndex < tileCols) || (gapEndIndex == 0));
- // If we still didn't manage to find a gap, ensure that the index is
- // at least zero so the tile doesn't get pulled out of the grid.
- return Math.max(gapStartIndex, 0);
- };
- /** Move "down" to the next row. */
- /**
- * Move "down" to the next row.
- * @private
- * @return {?}
- */
- TileCoordinator.prototype._nextRow = /**
- * Move "down" to the next row.
- * @private
- * @return {?}
- */
- function () {
- this.columnIndex = 0;
- this.rowIndex++;
- // Decrement all spaces by one to reflect moving down one row.
- for (var i = 0; i < this.tracker.length; i++) {
- this.tracker[i] = Math.max(0, this.tracker[i] - 1);
- }
- };
- /**
- * Finds the end index (exclusive) of a gap given the index from which to start looking.
- * The gap ends when a non-zero value is found.
- */
- /**
- * Finds the end index (exclusive) of a gap given the index from which to start looking.
- * The gap ends when a non-zero value is found.
- * @private
- * @param {?} gapStartIndex
- * @return {?}
- */
- TileCoordinator.prototype._findGapEndIndex = /**
- * Finds the end index (exclusive) of a gap given the index from which to start looking.
- * The gap ends when a non-zero value is found.
- * @private
- * @param {?} gapStartIndex
- * @return {?}
- */
- function (gapStartIndex) {
- for (var i = gapStartIndex + 1; i < this.tracker.length; i++) {
- if (this.tracker[i] != 0) {
- return i;
- }
- }
- // The gap ends with the end of the row.
- return this.tracker.length;
- };
- /** Update the tile tracker to account for the given tile in the given space. */
- /**
- * Update the tile tracker to account for the given tile in the given space.
- * @private
- * @param {?} start
- * @param {?} tile
- * @return {?}
- */
- TileCoordinator.prototype._markTilePosition = /**
- * Update the tile tracker to account for the given tile in the given space.
- * @private
- * @param {?} start
- * @param {?} tile
- * @return {?}
- */
- function (start, tile) {
- for (var i = 0; i < tile.colspan; i++) {
- this.tracker[start + i] = tile.rowspan;
- }
- };
- return TileCoordinator;
- }());
- /**
- * Simple data structure for tile position (row, col).
- * \@docs-private
- */
- var /**
- * Simple data structure for tile position (row, col).
- * \@docs-private
- */
- TilePosition = /** @class */ (function () {
- function TilePosition(row, col) {
- this.row = row;
- this.col = col;
- }
- return TilePosition;
- }());
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /**
- * RegExp that can be used to check whether a value will
- * be allowed inside a CSS `calc()` expression.
- * @type {?}
- */
- var cssCalcAllowedValue = /^-?\d+((\.\d+)?[A-Za-z%$]?)+$/;
- /**
- * Sets the style properties for an individual tile, given the position calculated by the
- * Tile Coordinator.
- * \@docs-private
- * @abstract
- */
- var /**
- * Sets the style properties for an individual tile, given the position calculated by the
- * Tile Coordinator.
- * \@docs-private
- * @abstract
- */
- TileStyler = /** @class */ (function () {
- function TileStyler() {
- this._rows = 0;
- this._rowspan = 0;
- }
- /**
- * Adds grid-list layout info once it is available. Cannot be processed in the constructor
- * because these properties haven't been calculated by that point.
- *
- * @param gutterSize Size of the grid's gutter.
- * @param tracker Instance of the TileCoordinator.
- * @param cols Amount of columns in the grid.
- * @param direction Layout direction of the grid.
- */
- /**
- * Adds grid-list layout info once it is available. Cannot be processed in the constructor
- * because these properties haven't been calculated by that point.
- *
- * @param {?} gutterSize Size of the grid's gutter.
- * @param {?} tracker Instance of the TileCoordinator.
- * @param {?} cols Amount of columns in the grid.
- * @param {?} direction Layout direction of the grid.
- * @return {?}
- */
- TileStyler.prototype.init = /**
- * Adds grid-list layout info once it is available. Cannot be processed in the constructor
- * because these properties haven't been calculated by that point.
- *
- * @param {?} gutterSize Size of the grid's gutter.
- * @param {?} tracker Instance of the TileCoordinator.
- * @param {?} cols Amount of columns in the grid.
- * @param {?} direction Layout direction of the grid.
- * @return {?}
- */
- function (gutterSize, tracker, cols, direction) {
- this._gutterSize = normalizeUnits(gutterSize);
- this._rows = tracker.rowCount;
- this._rowspan = tracker.rowspan;
- this._cols = cols;
- this._direction = direction;
- };
- /**
- * Computes the amount of space a single 1x1 tile would take up (width or height).
- * Used as a basis for other calculations.
- * @param sizePercent Percent of the total grid-list space that one 1x1 tile would take up.
- * @param gutterFraction Fraction of the gutter size taken up by one 1x1 tile.
- * @return The size of a 1x1 tile as an expression that can be evaluated via CSS calc().
- */
- /**
- * Computes the amount of space a single 1x1 tile would take up (width or height).
- * Used as a basis for other calculations.
- * @param {?} sizePercent Percent of the total grid-list space that one 1x1 tile would take up.
- * @param {?} gutterFraction Fraction of the gutter size taken up by one 1x1 tile.
- * @return {?} The size of a 1x1 tile as an expression that can be evaluated via CSS calc().
- */
- TileStyler.prototype.getBaseTileSize = /**
- * Computes the amount of space a single 1x1 tile would take up (width or height).
- * Used as a basis for other calculations.
- * @param {?} sizePercent Percent of the total grid-list space that one 1x1 tile would take up.
- * @param {?} gutterFraction Fraction of the gutter size taken up by one 1x1 tile.
- * @return {?} The size of a 1x1 tile as an expression that can be evaluated via CSS calc().
- */
- function (sizePercent, gutterFraction) {
- // Take the base size percent (as would be if evenly dividing the size between cells),
- // and then subtracting the size of one gutter. However, since there are no gutters on the
- // edges, each tile only uses a fraction (gutterShare = numGutters / numCells) of the gutter
- // size. (Imagine having one gutter per tile, and then breaking up the extra gutter on the
- // edge evenly among the cells).
- return "(" + sizePercent + "% - (" + this._gutterSize + " * " + gutterFraction + "))";
- };
- /**
- * Gets The horizontal or vertical position of a tile, e.g., the 'top' or 'left' property value.
- * @param offset Number of tiles that have already been rendered in the row/column.
- * @param baseSize Base size of a 1x1 tile (as computed in getBaseTileSize).
- * @return Position of the tile as a CSS calc() expression.
- */
- /**
- * Gets The horizontal or vertical position of a tile, e.g., the 'top' or 'left' property value.
- * @param {?} baseSize Base size of a 1x1 tile (as computed in getBaseTileSize).
- * @param {?} offset Number of tiles that have already been rendered in the row/column.
- * @return {?} Position of the tile as a CSS calc() expression.
- */
- TileStyler.prototype.getTilePosition = /**
- * Gets The horizontal or vertical position of a tile, e.g., the 'top' or 'left' property value.
- * @param {?} baseSize Base size of a 1x1 tile (as computed in getBaseTileSize).
- * @param {?} offset Number of tiles that have already been rendered in the row/column.
- * @return {?} Position of the tile as a CSS calc() expression.
- */
- function (baseSize, offset) {
- // The position comes the size of a 1x1 tile plus gutter for each previous tile in the
- // row/column (offset).
- return offset === 0 ? '0' : calc("(" + baseSize + " + " + this._gutterSize + ") * " + offset);
- };
- /**
- * Gets the actual size of a tile, e.g., width or height, taking rowspan or colspan into account.
- * @param baseSize Base size of a 1x1 tile (as computed in getBaseTileSize).
- * @param span The tile's rowspan or colspan.
- * @return Size of the tile as a CSS calc() expression.
- */
- /**
- * Gets the actual size of a tile, e.g., width or height, taking rowspan or colspan into account.
- * @param {?} baseSize Base size of a 1x1 tile (as computed in getBaseTileSize).
- * @param {?} span The tile's rowspan or colspan.
- * @return {?} Size of the tile as a CSS calc() expression.
- */
- TileStyler.prototype.getTileSize = /**
- * Gets the actual size of a tile, e.g., width or height, taking rowspan or colspan into account.
- * @param {?} baseSize Base size of a 1x1 tile (as computed in getBaseTileSize).
- * @param {?} span The tile's rowspan or colspan.
- * @return {?} Size of the tile as a CSS calc() expression.
- */
- function (baseSize, span) {
- return "(" + baseSize + " * " + span + ") + (" + (span - 1) + " * " + this._gutterSize + ")";
- };
- /**
- * Sets the style properties to be applied to a tile for the given row and column index.
- * @param tile Tile to which to apply the styling.
- * @param rowIndex Index of the tile's row.
- * @param colIndex Index of the tile's column.
- */
- /**
- * Sets the style properties to be applied to a tile for the given row and column index.
- * @param {?} tile Tile to which to apply the styling.
- * @param {?} rowIndex Index of the tile's row.
- * @param {?} colIndex Index of the tile's column.
- * @return {?}
- */
- TileStyler.prototype.setStyle = /**
- * Sets the style properties to be applied to a tile for the given row and column index.
- * @param {?} tile Tile to which to apply the styling.
- * @param {?} rowIndex Index of the tile's row.
- * @param {?} colIndex Index of the tile's column.
- * @return {?}
- */
- function (tile, rowIndex, colIndex) {
- // Percent of the available horizontal space that one column takes up.
- /** @type {?} */
- var percentWidthPerTile = 100 / this._cols;
- // Fraction of the vertical gutter size that each column takes up.
- // For example, if there are 5 columns, each column uses 4/5 = 0.8 times the gutter width.
- /** @type {?} */
- var gutterWidthFractionPerTile = (this._cols - 1) / this._cols;
- this.setColStyles(tile, colIndex, percentWidthPerTile, gutterWidthFractionPerTile);
- this.setRowStyles(tile, rowIndex, percentWidthPerTile, gutterWidthFractionPerTile);
- };
- /** Sets the horizontal placement of the tile in the list. */
- /**
- * Sets the horizontal placement of the tile in the list.
- * @param {?} tile
- * @param {?} colIndex
- * @param {?} percentWidth
- * @param {?} gutterWidth
- * @return {?}
- */
- TileStyler.prototype.setColStyles = /**
- * Sets the horizontal placement of the tile in the list.
- * @param {?} tile
- * @param {?} colIndex
- * @param {?} percentWidth
- * @param {?} gutterWidth
- * @return {?}
- */
- function (tile, colIndex, percentWidth, gutterWidth) {
- // Base horizontal size of a column.
- /** @type {?} */
- var baseTileWidth = this.getBaseTileSize(percentWidth, gutterWidth);
- // The width and horizontal position of each tile is always calculated the same way, but the
- // height and vertical position depends on the rowMode.
- /** @type {?} */
- var side = this._direction === 'rtl' ? 'right' : 'left';
- tile._setStyle(side, this.getTilePosition(baseTileWidth, colIndex));
- tile._setStyle('width', calc(this.getTileSize(baseTileWidth, tile.colspan)));
- };
- /**
- * Calculates the total size taken up by gutters across one axis of a list.
- */
- /**
- * Calculates the total size taken up by gutters across one axis of a list.
- * @return {?}
- */
- TileStyler.prototype.getGutterSpan = /**
- * Calculates the total size taken up by gutters across one axis of a list.
- * @return {?}
- */
- function () {
- return this._gutterSize + " * (" + this._rowspan + " - 1)";
- };
- /**
- * Calculates the total size taken up by tiles across one axis of a list.
- * @param tileHeight Height of the tile.
- */
- /**
- * Calculates the total size taken up by tiles across one axis of a list.
- * @param {?} tileHeight Height of the tile.
- * @return {?}
- */
- TileStyler.prototype.getTileSpan = /**
- * Calculates the total size taken up by tiles across one axis of a list.
- * @param {?} tileHeight Height of the tile.
- * @return {?}
- */
- function (tileHeight) {
- return this._rowspan + " * " + this.getTileSize(tileHeight, 1);
- };
- /**
- * Calculates the computed height and returns the correct style property to set.
- * This method can be implemented by each type of TileStyler.
- * @docs-private
- */
- /**
- * Calculates the computed height and returns the correct style property to set.
- * This method can be implemented by each type of TileStyler.
- * \@docs-private
- * @return {?}
- */
- TileStyler.prototype.getComputedHeight = /**
- * Calculates the computed height and returns the correct style property to set.
- * This method can be implemented by each type of TileStyler.
- * \@docs-private
- * @return {?}
- */
- function () { return null; };
- return TileStyler;
- }());
- /**
- * This type of styler is instantiated when the user passes in a fixed row height.
- * Example `<mat-grid-list cols="3" rowHeight="100px">`
- * \@docs-private
- */
- var /**
- * This type of styler is instantiated when the user passes in a fixed row height.
- * Example `<mat-grid-list cols="3" rowHeight="100px">`
- * \@docs-private
- */
- FixedTileStyler = /** @class */ (function (_super) {
- __extends(FixedTileStyler, _super);
- function FixedTileStyler(fixedRowHeight) {
- var _this = _super.call(this) || this;
- _this.fixedRowHeight = fixedRowHeight;
- return _this;
- }
- /**
- * @param {?} gutterSize
- * @param {?} tracker
- * @param {?} cols
- * @param {?} direction
- * @return {?}
- */
- FixedTileStyler.prototype.init = /**
- * @param {?} gutterSize
- * @param {?} tracker
- * @param {?} cols
- * @param {?} direction
- * @return {?}
- */
- function (gutterSize, tracker, cols, direction) {
- _super.prototype.init.call(this, gutterSize, tracker, cols, direction);
- this.fixedRowHeight = normalizeUnits(this.fixedRowHeight);
- if (!cssCalcAllowedValue.test(this.fixedRowHeight)) {
- throw Error("Invalid value \"" + this.fixedRowHeight + "\" set as rowHeight.");
- }
- };
- /**
- * @param {?} tile
- * @param {?} rowIndex
- * @return {?}
- */
- FixedTileStyler.prototype.setRowStyles = /**
- * @param {?} tile
- * @param {?} rowIndex
- * @return {?}
- */
- function (tile, rowIndex) {
- tile._setStyle('top', this.getTilePosition(this.fixedRowHeight, rowIndex));
- tile._setStyle('height', calc(this.getTileSize(this.fixedRowHeight, tile.rowspan)));
- };
- /**
- * @return {?}
- */
- FixedTileStyler.prototype.getComputedHeight = /**
- * @return {?}
- */
- function () {
- return [
- 'height', calc(this.getTileSpan(this.fixedRowHeight) + " + " + this.getGutterSpan())
- ];
- };
- /**
- * @param {?} list
- * @return {?}
- */
- FixedTileStyler.prototype.reset = /**
- * @param {?} list
- * @return {?}
- */
- function (list) {
- list._setListStyle(['height', null]);
- if (list._tiles) {
- list._tiles.forEach((/**
- * @param {?} tile
- * @return {?}
- */
- function (tile) {
- tile._setStyle('top', null);
- tile._setStyle('height', null);
- }));
- }
- };
- return FixedTileStyler;
- }(TileStyler));
- /**
- * This type of styler is instantiated when the user passes in a width:height ratio
- * for the row height. Example `<mat-grid-list cols="3" rowHeight="3:1">`
- * \@docs-private
- */
- var /**
- * This type of styler is instantiated when the user passes in a width:height ratio
- * for the row height. Example `<mat-grid-list cols="3" rowHeight="3:1">`
- * \@docs-private
- */
- RatioTileStyler = /** @class */ (function (_super) {
- __extends(RatioTileStyler, _super);
- function RatioTileStyler(value) {
- var _this = _super.call(this) || this;
- _this._parseRatio(value);
- return _this;
- }
- /**
- * @param {?} tile
- * @param {?} rowIndex
- * @param {?} percentWidth
- * @param {?} gutterWidth
- * @return {?}
- */
- RatioTileStyler.prototype.setRowStyles = /**
- * @param {?} tile
- * @param {?} rowIndex
- * @param {?} percentWidth
- * @param {?} gutterWidth
- * @return {?}
- */
- function (tile, rowIndex, percentWidth, gutterWidth) {
- /** @type {?} */
- var percentHeightPerTile = percentWidth / this.rowHeightRatio;
- this.baseTileHeight = this.getBaseTileSize(percentHeightPerTile, gutterWidth);
- // Use padding-top and margin-top to maintain the given aspect ratio, as
- // a percentage-based value for these properties is applied versus the *width* of the
- // containing block. See http://www.w3.org/TR/CSS2/box.html#margin-properties
- tile._setStyle('marginTop', this.getTilePosition(this.baseTileHeight, rowIndex));
- tile._setStyle('paddingTop', calc(this.getTileSize(this.baseTileHeight, tile.rowspan)));
- };
- /**
- * @return {?}
- */
- RatioTileStyler.prototype.getComputedHeight = /**
- * @return {?}
- */
- function () {
- return [
- 'paddingBottom', calc(this.getTileSpan(this.baseTileHeight) + " + " + this.getGutterSpan())
- ];
- };
- /**
- * @param {?} list
- * @return {?}
- */
- RatioTileStyler.prototype.reset = /**
- * @param {?} list
- * @return {?}
- */
- function (list) {
- list._setListStyle(['paddingBottom', null]);
- list._tiles.forEach((/**
- * @param {?} tile
- * @return {?}
- */
- function (tile) {
- tile._setStyle('marginTop', null);
- tile._setStyle('paddingTop', null);
- }));
- };
- /**
- * @private
- * @param {?} value
- * @return {?}
- */
- RatioTileStyler.prototype._parseRatio = /**
- * @private
- * @param {?} value
- * @return {?}
- */
- function (value) {
- /** @type {?} */
- var ratioParts = value.split(':');
- if (ratioParts.length !== 2) {
- throw Error("mat-grid-list: invalid ratio given for row-height: \"" + value + "\"");
- }
- this.rowHeightRatio = parseFloat(ratioParts[0]) / parseFloat(ratioParts[1]);
- };
- return RatioTileStyler;
- }(TileStyler));
- /**
- * This type of styler is instantiated when the user selects a "fit" row height mode.
- * In other words, the row height will reflect the total height of the container divided
- * by the number of rows. Example `<mat-grid-list cols="3" rowHeight="fit">`
- *
- * \@docs-private
- */
- var /**
- * This type of styler is instantiated when the user selects a "fit" row height mode.
- * In other words, the row height will reflect the total height of the container divided
- * by the number of rows. Example `<mat-grid-list cols="3" rowHeight="fit">`
- *
- * \@docs-private
- */
- FitTileStyler = /** @class */ (function (_super) {
- __extends(FitTileStyler, _super);
- function FitTileStyler() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- /**
- * @param {?} tile
- * @param {?} rowIndex
- * @return {?}
- */
- FitTileStyler.prototype.setRowStyles = /**
- * @param {?} tile
- * @param {?} rowIndex
- * @return {?}
- */
- function (tile, rowIndex) {
- // Percent of the available vertical space that one row takes up.
- /** @type {?} */
- var percentHeightPerTile = 100 / this._rowspan;
- // Fraction of the horizontal gutter size that each column takes up.
- /** @type {?} */
- var gutterHeightPerTile = (this._rows - 1) / this._rows;
- // Base vertical size of a column.
- /** @type {?} */
- var baseTileHeight = this.getBaseTileSize(percentHeightPerTile, gutterHeightPerTile);
- tile._setStyle('top', this.getTilePosition(baseTileHeight, rowIndex));
- tile._setStyle('height', calc(this.getTileSize(baseTileHeight, tile.rowspan)));
- };
- /**
- * @param {?} list
- * @return {?}
- */
- FitTileStyler.prototype.reset = /**
- * @param {?} list
- * @return {?}
- */
- function (list) {
- if (list._tiles) {
- list._tiles.forEach((/**
- * @param {?} tile
- * @return {?}
- */
- function (tile) {
- tile._setStyle('top', null);
- tile._setStyle('height', null);
- }));
- }
- };
- return FitTileStyler;
- }(TileStyler));
- /**
- * Wraps a CSS string in a calc function
- * @param {?} exp
- * @return {?}
- */
- function calc(exp) {
- return "calc(" + exp + ")";
- }
- /**
- * Appends pixels to a CSS string if no units are given.
- * @param {?} value
- * @return {?}
- */
- function normalizeUnits(value) {
- return value.match(/([A-Za-z%]+)$/) ? value : value + "px";
- }
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- // TODO(kara): Conditional (responsive) column count / row size.
- // TODO(kara): Re-layout on window resize / media change (debounced).
- // TODO(kara): gridTileHeader and gridTileFooter.
- /** @type {?} */
- var MAT_FIT_MODE = 'fit';
- var MatGridList = /** @class */ (function () {
- function MatGridList(_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';
- }
- Object.defineProperty(MatGridList.prototype, "cols", {
- /** Amount of columns in the grid list. */
- get: /**
- * Amount of columns in the grid list.
- * @return {?}
- */
- function () { return this._cols; },
- set: /**
- * @param {?} value
- * @return {?}
- */
- function (value) {
- this._cols = Math.max(1, Math.round(coerceNumberProperty(value)));
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MatGridList.prototype, "gutterSize", {
- /** Size of the grid list's gutter in pixels. */
- get: /**
- * Size of the grid list's gutter in pixels.
- * @return {?}
- */
- function () { return this._gutter; },
- set: /**
- * @param {?} value
- * @return {?}
- */
- function (value) { this._gutter = "" + (value == null ? '' : value); },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MatGridList.prototype, "rowHeight", {
- /** Set internal representation of row height from the user-provided value. */
- get: /**
- * Set internal representation of row height from the user-provided value.
- * @return {?}
- */
- function () { return this._rowHeight; },
- set: /**
- * @param {?} value
- * @return {?}
- */
- function (value) {
- /** @type {?} */
- var newValue = "" + (value == null ? '' : value);
- if (newValue !== this._rowHeight) {
- this._rowHeight = newValue;
- this._setTileStyler(this._rowHeight);
- }
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @return {?}
- */
- MatGridList.prototype.ngOnInit = /**
- * @return {?}
- */
- function () {
- this._checkCols();
- this._checkRowHeight();
- };
- /**
- * The layout calculation is fairly cheap if nothing changes, so there's little cost
- * to run it frequently.
- */
- /**
- * The layout calculation is fairly cheap if nothing changes, so there's little cost
- * to run it frequently.
- * @return {?}
- */
- MatGridList.prototype.ngAfterContentChecked = /**
- * The layout calculation is fairly cheap if nothing changes, so there's little cost
- * to run it frequently.
- * @return {?}
- */
- function () {
- this._layoutTiles();
- };
- /** Throw a friendly error if cols property is missing */
- /**
- * Throw a friendly error if cols property is missing
- * @private
- * @return {?}
- */
- MatGridList.prototype._checkCols = /**
- * Throw a friendly error if cols property is missing
- * @private
- * @return {?}
- */
- function () {
- if (!this.cols) {
- throw Error("mat-grid-list: must pass in number of columns. " +
- "Example: <mat-grid-list cols=\"3\">");
- }
- };
- /** Default to equal width:height if rowHeight property is missing */
- /**
- * Default to equal width:height if rowHeight property is missing
- * @private
- * @return {?}
- */
- MatGridList.prototype._checkRowHeight = /**
- * Default to equal width:height if rowHeight property is missing
- * @private
- * @return {?}
- */
- function () {
- if (!this._rowHeight) {
- this._setTileStyler('1:1');
- }
- };
- /** Creates correct Tile Styler subtype based on rowHeight passed in by user */
- /**
- * Creates correct Tile Styler subtype based on rowHeight passed in by user
- * @private
- * @param {?} rowHeight
- * @return {?}
- */
- MatGridList.prototype._setTileStyler = /**
- * Creates correct Tile Styler subtype based on rowHeight passed in by user
- * @private
- * @param {?} rowHeight
- * @return {?}
- */
- function (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. */
- /**
- * Computes and applies the size and position for all children grid tiles.
- * @private
- * @return {?}
- */
- MatGridList.prototype._layoutTiles = /**
- * Computes and applies the size and position for all children grid tiles.
- * @private
- * @return {?}
- */
- function () {
- var _this = this;
- if (!this._tileCoordinator) {
- this._tileCoordinator = new TileCoordinator();
- }
- /** @type {?} */
- var tracker = this._tileCoordinator;
- /** @type {?} */
- var tiles = this._tiles.filter((/**
- * @param {?} tile
- * @return {?}
- */
- function (tile) { return !tile._gridList || tile._gridList === _this; }));
- /** @type {?} */
- var direction = this._dir ? this._dir.value : 'ltr';
- this._tileCoordinator.update(this.cols, tiles);
- this._tileStyler.init(this.gutterSize, tracker, this.cols, direction);
- tiles.forEach((/**
- * @param {?} tile
- * @param {?} index
- * @return {?}
- */
- function (tile, index) {
- /** @type {?} */
- var 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. */
- /**
- * Sets style on the main grid-list element, given the style name and value.
- * @param {?} style
- * @return {?}
- */
- MatGridList.prototype._setListStyle = /**
- * Sets style on the main grid-list element, given the style name and value.
- * @param {?} style
- * @return {?}
- */
- function (style) {
- if (style) {
- ((/** @type {?} */ (this._element.nativeElement.style)))[style[0]] = style[1];
- }
- };
- MatGridList.decorators = [
- { type: 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: MAT_GRID_LIST,
- useExisting: MatGridList
- }],
- changeDetection: ChangeDetectionStrategy.OnPush,
- encapsulation: ViewEncapsulation.None,
- },] },
- ];
- /** @nocollapse */
- MatGridList.ctorParameters = function () { return [
- { type: ElementRef },
- { type: Directionality, decorators: [{ type: Optional }] }
- ]; };
- MatGridList.propDecorators = {
- _tiles: [{ type: ContentChildren, args: [MatGridTile, { descendants: true },] }],
- cols: [{ type: Input }],
- gutterSize: [{ type: Input }],
- rowHeight: [{ type: Input }]
- };
- return MatGridList;
- }());
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- var MatGridListModule = /** @class */ (function () {
- function MatGridListModule() {
- }
- MatGridListModule.decorators = [
- { type: NgModule, args: [{
- imports: [MatLineModule, MatCommonModule],
- exports: [
- MatGridList,
- MatGridTile,
- MatGridTileText,
- MatLineModule,
- MatCommonModule,
- MatGridTileHeaderCssMatStyler,
- MatGridTileFooterCssMatStyler,
- MatGridAvatarCssMatStyler
- ],
- declarations: [
- MatGridList,
- MatGridTile,
- MatGridTileText,
- MatGridTileHeaderCssMatStyler,
- MatGridTileFooterCssMatStyler,
- MatGridAvatarCssMatStyler
- ],
- },] },
- ];
- return MatGridListModule;
- }());
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- export { MatGridListModule, MatGridList, MatGridTile, MatGridTileText, MatGridAvatarCssMatStyler, MatGridTileHeaderCssMatStyler, MatGridTileFooterCssMatStyler, MAT_GRID_LIST as ɵa6 };
- //# sourceMappingURL=grid-list.es5.js.map
|