grid-list.es5.js 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246
  1. /**
  2. * @license
  3. * Copyright Google LLC All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://angular.io/license
  7. */
  8. import { InjectionToken, Component, ViewEncapsulation, ElementRef, Input, Optional, ContentChildren, Directive, ChangeDetectionStrategy, Inject, NgModule } from '@angular/core';
  9. import { MatLine, setLines, MatLineModule, MatCommonModule } from '@angular/material/core';
  10. import { coerceNumberProperty } from '@angular/cdk/coercion';
  11. import { __extends } from 'tslib';
  12. import { Directionality } from '@angular/cdk/bidi';
  13. /**
  14. * @fileoverview added by tsickle
  15. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  16. */
  17. /**
  18. * Injection token used to provide a grid list to a tile and to avoid circular imports.
  19. * \@docs-private
  20. * @type {?}
  21. */
  22. var MAT_GRID_LIST = new InjectionToken('MAT_GRID_LIST');
  23. /**
  24. * @fileoverview added by tsickle
  25. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  26. */
  27. var MatGridTile = /** @class */ (function () {
  28. function MatGridTile(_element, _gridList) {
  29. this._element = _element;
  30. this._gridList = _gridList;
  31. this._rowspan = 1;
  32. this._colspan = 1;
  33. }
  34. Object.defineProperty(MatGridTile.prototype, "rowspan", {
  35. /** Amount of rows that the grid tile takes up. */
  36. get: /**
  37. * Amount of rows that the grid tile takes up.
  38. * @return {?}
  39. */
  40. function () { return this._rowspan; },
  41. set: /**
  42. * @param {?} value
  43. * @return {?}
  44. */
  45. function (value) { this._rowspan = Math.round(coerceNumberProperty(value)); },
  46. enumerable: true,
  47. configurable: true
  48. });
  49. Object.defineProperty(MatGridTile.prototype, "colspan", {
  50. /** Amount of columns that the grid tile takes up. */
  51. get: /**
  52. * Amount of columns that the grid tile takes up.
  53. * @return {?}
  54. */
  55. function () { return this._colspan; },
  56. set: /**
  57. * @param {?} value
  58. * @return {?}
  59. */
  60. function (value) { this._colspan = Math.round(coerceNumberProperty(value)); },
  61. enumerable: true,
  62. configurable: true
  63. });
  64. /**
  65. * Sets the style of the grid-tile element. Needs to be set manually to avoid
  66. * "Changed after checked" errors that would occur with HostBinding.
  67. */
  68. /**
  69. * Sets the style of the grid-tile element. Needs to be set manually to avoid
  70. * "Changed after checked" errors that would occur with HostBinding.
  71. * @param {?} property
  72. * @param {?} value
  73. * @return {?}
  74. */
  75. MatGridTile.prototype._setStyle = /**
  76. * Sets the style of the grid-tile element. Needs to be set manually to avoid
  77. * "Changed after checked" errors that would occur with HostBinding.
  78. * @param {?} property
  79. * @param {?} value
  80. * @return {?}
  81. */
  82. function (property, value) {
  83. ((/** @type {?} */ (this._element.nativeElement.style)))[property] = value;
  84. };
  85. MatGridTile.decorators = [
  86. { type: Component, args: [{selector: 'mat-grid-tile',
  87. exportAs: 'matGridTile',
  88. host: {
  89. 'class': 'mat-grid-tile',
  90. },
  91. template: "<figure class=\"mat-figure\"><ng-content></ng-content></figure>",
  92. 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}"],
  93. encapsulation: ViewEncapsulation.None,
  94. changeDetection: ChangeDetectionStrategy.OnPush,
  95. },] },
  96. ];
  97. /** @nocollapse */
  98. MatGridTile.ctorParameters = function () { return [
  99. { type: ElementRef },
  100. { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [MAT_GRID_LIST,] }] }
  101. ]; };
  102. MatGridTile.propDecorators = {
  103. rowspan: [{ type: Input }],
  104. colspan: [{ type: Input }]
  105. };
  106. return MatGridTile;
  107. }());
  108. var MatGridTileText = /** @class */ (function () {
  109. function MatGridTileText(_element) {
  110. this._element = _element;
  111. }
  112. /**
  113. * @return {?}
  114. */
  115. MatGridTileText.prototype.ngAfterContentInit = /**
  116. * @return {?}
  117. */
  118. function () {
  119. setLines(this._lines, this._element);
  120. };
  121. MatGridTileText.decorators = [
  122. { type: Component, args: [{selector: 'mat-grid-tile-header, mat-grid-tile-footer',
  123. 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>",
  124. changeDetection: ChangeDetectionStrategy.OnPush,
  125. encapsulation: ViewEncapsulation.None,
  126. },] },
  127. ];
  128. /** @nocollapse */
  129. MatGridTileText.ctorParameters = function () { return [
  130. { type: ElementRef }
  131. ]; };
  132. MatGridTileText.propDecorators = {
  133. _lines: [{ type: ContentChildren, args: [MatLine,] }]
  134. };
  135. return MatGridTileText;
  136. }());
  137. /**
  138. * Directive whose purpose is to add the mat- CSS styling to this selector.
  139. * \@docs-private
  140. */
  141. var MatGridAvatarCssMatStyler = /** @class */ (function () {
  142. function MatGridAvatarCssMatStyler() {
  143. }
  144. MatGridAvatarCssMatStyler.decorators = [
  145. { type: Directive, args: [{
  146. selector: '[mat-grid-avatar], [matGridAvatar]',
  147. host: { 'class': 'mat-grid-avatar' }
  148. },] },
  149. ];
  150. return MatGridAvatarCssMatStyler;
  151. }());
  152. /**
  153. * Directive whose purpose is to add the mat- CSS styling to this selector.
  154. * \@docs-private
  155. */
  156. var MatGridTileHeaderCssMatStyler = /** @class */ (function () {
  157. function MatGridTileHeaderCssMatStyler() {
  158. }
  159. MatGridTileHeaderCssMatStyler.decorators = [
  160. { type: Directive, args: [{
  161. selector: 'mat-grid-tile-header',
  162. host: { 'class': 'mat-grid-tile-header' }
  163. },] },
  164. ];
  165. return MatGridTileHeaderCssMatStyler;
  166. }());
  167. /**
  168. * Directive whose purpose is to add the mat- CSS styling to this selector.
  169. * \@docs-private
  170. */
  171. var MatGridTileFooterCssMatStyler = /** @class */ (function () {
  172. function MatGridTileFooterCssMatStyler() {
  173. }
  174. MatGridTileFooterCssMatStyler.decorators = [
  175. { type: Directive, args: [{
  176. selector: 'mat-grid-tile-footer',
  177. host: { 'class': 'mat-grid-tile-footer' }
  178. },] },
  179. ];
  180. return MatGridTileFooterCssMatStyler;
  181. }());
  182. /**
  183. * @fileoverview added by tsickle
  184. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  185. */
  186. /**
  187. * Class for determining, from a list of tiles, the (row, col) position of each of those tiles
  188. * in the grid. This is necessary (rather than just rendering the tiles in normal document flow)
  189. * because the tiles can have a rowspan.
  190. *
  191. * The positioning algorithm greedily places each tile as soon as it encounters a gap in the grid
  192. * large enough to accommodate it so that the tiles still render in the same order in which they
  193. * are given.
  194. *
  195. * The basis of the algorithm is the use of an array to track the already placed tiles. Each
  196. * element of the array corresponds to a column, and the value indicates how many cells in that
  197. * column are already occupied; zero indicates an empty cell. Moving "down" to the next row
  198. * decrements each value in the tracking array (indicating that the column is one cell closer to
  199. * being free).
  200. *
  201. * \@docs-private
  202. */
  203. var /**
  204. * Class for determining, from a list of tiles, the (row, col) position of each of those tiles
  205. * in the grid. This is necessary (rather than just rendering the tiles in normal document flow)
  206. * because the tiles can have a rowspan.
  207. *
  208. * The positioning algorithm greedily places each tile as soon as it encounters a gap in the grid
  209. * large enough to accommodate it so that the tiles still render in the same order in which they
  210. * are given.
  211. *
  212. * The basis of the algorithm is the use of an array to track the already placed tiles. Each
  213. * element of the array corresponds to a column, and the value indicates how many cells in that
  214. * column are already occupied; zero indicates an empty cell. Moving "down" to the next row
  215. * decrements each value in the tracking array (indicating that the column is one cell closer to
  216. * being free).
  217. *
  218. * \@docs-private
  219. */
  220. TileCoordinator = /** @class */ (function () {
  221. function TileCoordinator() {
  222. /**
  223. * Index at which the search for the next gap will start.
  224. */
  225. this.columnIndex = 0;
  226. /**
  227. * The current row index.
  228. */
  229. this.rowIndex = 0;
  230. }
  231. Object.defineProperty(TileCoordinator.prototype, "rowCount", {
  232. /** Gets the total number of rows occupied by tiles */
  233. get: /**
  234. * Gets the total number of rows occupied by tiles
  235. * @return {?}
  236. */
  237. function () { return this.rowIndex + 1; },
  238. enumerable: true,
  239. configurable: true
  240. });
  241. Object.defineProperty(TileCoordinator.prototype, "rowspan", {
  242. /**
  243. * Gets the total span of rows occupied by tiles.
  244. * Ex: A list with 1 row that contains a tile with rowspan 2 will have a total rowspan of 2.
  245. */
  246. get: /**
  247. * Gets the total span of rows occupied by tiles.
  248. * Ex: A list with 1 row that contains a tile with rowspan 2 will have a total rowspan of 2.
  249. * @return {?}
  250. */
  251. function () {
  252. /** @type {?} */
  253. var lastRowMax = Math.max.apply(Math, this.tracker);
  254. // if any of the tiles has a rowspan that pushes it beyond the total row count,
  255. // add the difference to the rowcount
  256. return lastRowMax > 1 ? this.rowCount + lastRowMax - 1 : this.rowCount;
  257. },
  258. enumerable: true,
  259. configurable: true
  260. });
  261. /**
  262. * Updates the tile positions.
  263. * @param numColumns Amount of columns in the grid.
  264. */
  265. /**
  266. * Updates the tile positions.
  267. * @param {?} numColumns Amount of columns in the grid.
  268. * @param {?} tiles
  269. * @return {?}
  270. */
  271. TileCoordinator.prototype.update = /**
  272. * Updates the tile positions.
  273. * @param {?} numColumns Amount of columns in the grid.
  274. * @param {?} tiles
  275. * @return {?}
  276. */
  277. function (numColumns, tiles) {
  278. var _this = this;
  279. this.columnIndex = 0;
  280. this.rowIndex = 0;
  281. this.tracker = new Array(numColumns);
  282. this.tracker.fill(0, 0, this.tracker.length);
  283. this.positions = tiles.map((/**
  284. * @param {?} tile
  285. * @return {?}
  286. */
  287. function (tile) { return _this._trackTile(tile); }));
  288. };
  289. /** Calculates the row and col position of a tile. */
  290. /**
  291. * Calculates the row and col position of a tile.
  292. * @private
  293. * @param {?} tile
  294. * @return {?}
  295. */
  296. TileCoordinator.prototype._trackTile = /**
  297. * Calculates the row and col position of a tile.
  298. * @private
  299. * @param {?} tile
  300. * @return {?}
  301. */
  302. function (tile) {
  303. // Find a gap large enough for this tile.
  304. /** @type {?} */
  305. var gapStartIndex = this._findMatchingGap(tile.colspan);
  306. // Place tile in the resulting gap.
  307. this._markTilePosition(gapStartIndex, tile);
  308. // The next time we look for a gap, the search will start at columnIndex, which should be
  309. // immediately after the tile that has just been placed.
  310. this.columnIndex = gapStartIndex + tile.colspan;
  311. return new TilePosition(this.rowIndex, gapStartIndex);
  312. };
  313. /** Finds the next available space large enough to fit the tile. */
  314. /**
  315. * Finds the next available space large enough to fit the tile.
  316. * @private
  317. * @param {?} tileCols
  318. * @return {?}
  319. */
  320. TileCoordinator.prototype._findMatchingGap = /**
  321. * Finds the next available space large enough to fit the tile.
  322. * @private
  323. * @param {?} tileCols
  324. * @return {?}
  325. */
  326. function (tileCols) {
  327. if (tileCols > this.tracker.length) {
  328. throw Error("mat-grid-list: tile with colspan " + tileCols + " is wider than " +
  329. ("grid with cols=\"" + this.tracker.length + "\"."));
  330. }
  331. // Start index is inclusive, end index is exclusive.
  332. /** @type {?} */
  333. var gapStartIndex = -1;
  334. /** @type {?} */
  335. var gapEndIndex = -1;
  336. // Look for a gap large enough to fit the given tile. Empty spaces are marked with a zero.
  337. do {
  338. // If we've reached the end of the row, go to the next row.
  339. if (this.columnIndex + tileCols > this.tracker.length) {
  340. this._nextRow();
  341. gapStartIndex = this.tracker.indexOf(0, this.columnIndex);
  342. gapEndIndex = this._findGapEndIndex(gapStartIndex);
  343. continue;
  344. }
  345. gapStartIndex = this.tracker.indexOf(0, this.columnIndex);
  346. // If there are no more empty spaces in this row at all, move on to the next row.
  347. if (gapStartIndex == -1) {
  348. this._nextRow();
  349. gapStartIndex = this.tracker.indexOf(0, this.columnIndex);
  350. gapEndIndex = this._findGapEndIndex(gapStartIndex);
  351. continue;
  352. }
  353. gapEndIndex = this._findGapEndIndex(gapStartIndex);
  354. // If a gap large enough isn't found, we want to start looking immediately after the current
  355. // gap on the next iteration.
  356. this.columnIndex = gapStartIndex + 1;
  357. // Continue iterating until we find a gap wide enough for this tile. Since gapEndIndex is
  358. // exclusive, gapEndIndex is 0 means we didn't find a gap and should continue.
  359. } while ((gapEndIndex - gapStartIndex < tileCols) || (gapEndIndex == 0));
  360. // If we still didn't manage to find a gap, ensure that the index is
  361. // at least zero so the tile doesn't get pulled out of the grid.
  362. return Math.max(gapStartIndex, 0);
  363. };
  364. /** Move "down" to the next row. */
  365. /**
  366. * Move "down" to the next row.
  367. * @private
  368. * @return {?}
  369. */
  370. TileCoordinator.prototype._nextRow = /**
  371. * Move "down" to the next row.
  372. * @private
  373. * @return {?}
  374. */
  375. function () {
  376. this.columnIndex = 0;
  377. this.rowIndex++;
  378. // Decrement all spaces by one to reflect moving down one row.
  379. for (var i = 0; i < this.tracker.length; i++) {
  380. this.tracker[i] = Math.max(0, this.tracker[i] - 1);
  381. }
  382. };
  383. /**
  384. * Finds the end index (exclusive) of a gap given the index from which to start looking.
  385. * The gap ends when a non-zero value is found.
  386. */
  387. /**
  388. * Finds the end index (exclusive) of a gap given the index from which to start looking.
  389. * The gap ends when a non-zero value is found.
  390. * @private
  391. * @param {?} gapStartIndex
  392. * @return {?}
  393. */
  394. TileCoordinator.prototype._findGapEndIndex = /**
  395. * Finds the end index (exclusive) of a gap given the index from which to start looking.
  396. * The gap ends when a non-zero value is found.
  397. * @private
  398. * @param {?} gapStartIndex
  399. * @return {?}
  400. */
  401. function (gapStartIndex) {
  402. for (var i = gapStartIndex + 1; i < this.tracker.length; i++) {
  403. if (this.tracker[i] != 0) {
  404. return i;
  405. }
  406. }
  407. // The gap ends with the end of the row.
  408. return this.tracker.length;
  409. };
  410. /** Update the tile tracker to account for the given tile in the given space. */
  411. /**
  412. * Update the tile tracker to account for the given tile in the given space.
  413. * @private
  414. * @param {?} start
  415. * @param {?} tile
  416. * @return {?}
  417. */
  418. TileCoordinator.prototype._markTilePosition = /**
  419. * Update the tile tracker to account for the given tile in the given space.
  420. * @private
  421. * @param {?} start
  422. * @param {?} tile
  423. * @return {?}
  424. */
  425. function (start, tile) {
  426. for (var i = 0; i < tile.colspan; i++) {
  427. this.tracker[start + i] = tile.rowspan;
  428. }
  429. };
  430. return TileCoordinator;
  431. }());
  432. /**
  433. * Simple data structure for tile position (row, col).
  434. * \@docs-private
  435. */
  436. var /**
  437. * Simple data structure for tile position (row, col).
  438. * \@docs-private
  439. */
  440. TilePosition = /** @class */ (function () {
  441. function TilePosition(row, col) {
  442. this.row = row;
  443. this.col = col;
  444. }
  445. return TilePosition;
  446. }());
  447. /**
  448. * @fileoverview added by tsickle
  449. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  450. */
  451. /**
  452. * RegExp that can be used to check whether a value will
  453. * be allowed inside a CSS `calc()` expression.
  454. * @type {?}
  455. */
  456. var cssCalcAllowedValue = /^-?\d+((\.\d+)?[A-Za-z%$]?)+$/;
  457. /**
  458. * Sets the style properties for an individual tile, given the position calculated by the
  459. * Tile Coordinator.
  460. * \@docs-private
  461. * @abstract
  462. */
  463. var /**
  464. * Sets the style properties for an individual tile, given the position calculated by the
  465. * Tile Coordinator.
  466. * \@docs-private
  467. * @abstract
  468. */
  469. TileStyler = /** @class */ (function () {
  470. function TileStyler() {
  471. this._rows = 0;
  472. this._rowspan = 0;
  473. }
  474. /**
  475. * Adds grid-list layout info once it is available. Cannot be processed in the constructor
  476. * because these properties haven't been calculated by that point.
  477. *
  478. * @param gutterSize Size of the grid's gutter.
  479. * @param tracker Instance of the TileCoordinator.
  480. * @param cols Amount of columns in the grid.
  481. * @param direction Layout direction of the grid.
  482. */
  483. /**
  484. * Adds grid-list layout info once it is available. Cannot be processed in the constructor
  485. * because these properties haven't been calculated by that point.
  486. *
  487. * @param {?} gutterSize Size of the grid's gutter.
  488. * @param {?} tracker Instance of the TileCoordinator.
  489. * @param {?} cols Amount of columns in the grid.
  490. * @param {?} direction Layout direction of the grid.
  491. * @return {?}
  492. */
  493. TileStyler.prototype.init = /**
  494. * Adds grid-list layout info once it is available. Cannot be processed in the constructor
  495. * because these properties haven't been calculated by that point.
  496. *
  497. * @param {?} gutterSize Size of the grid's gutter.
  498. * @param {?} tracker Instance of the TileCoordinator.
  499. * @param {?} cols Amount of columns in the grid.
  500. * @param {?} direction Layout direction of the grid.
  501. * @return {?}
  502. */
  503. function (gutterSize, tracker, cols, direction) {
  504. this._gutterSize = normalizeUnits(gutterSize);
  505. this._rows = tracker.rowCount;
  506. this._rowspan = tracker.rowspan;
  507. this._cols = cols;
  508. this._direction = direction;
  509. };
  510. /**
  511. * Computes the amount of space a single 1x1 tile would take up (width or height).
  512. * Used as a basis for other calculations.
  513. * @param sizePercent Percent of the total grid-list space that one 1x1 tile would take up.
  514. * @param gutterFraction Fraction of the gutter size taken up by one 1x1 tile.
  515. * @return The size of a 1x1 tile as an expression that can be evaluated via CSS calc().
  516. */
  517. /**
  518. * Computes the amount of space a single 1x1 tile would take up (width or height).
  519. * Used as a basis for other calculations.
  520. * @param {?} sizePercent Percent of the total grid-list space that one 1x1 tile would take up.
  521. * @param {?} gutterFraction Fraction of the gutter size taken up by one 1x1 tile.
  522. * @return {?} The size of a 1x1 tile as an expression that can be evaluated via CSS calc().
  523. */
  524. TileStyler.prototype.getBaseTileSize = /**
  525. * Computes the amount of space a single 1x1 tile would take up (width or height).
  526. * Used as a basis for other calculations.
  527. * @param {?} sizePercent Percent of the total grid-list space that one 1x1 tile would take up.
  528. * @param {?} gutterFraction Fraction of the gutter size taken up by one 1x1 tile.
  529. * @return {?} The size of a 1x1 tile as an expression that can be evaluated via CSS calc().
  530. */
  531. function (sizePercent, gutterFraction) {
  532. // Take the base size percent (as would be if evenly dividing the size between cells),
  533. // and then subtracting the size of one gutter. However, since there are no gutters on the
  534. // edges, each tile only uses a fraction (gutterShare = numGutters / numCells) of the gutter
  535. // size. (Imagine having one gutter per tile, and then breaking up the extra gutter on the
  536. // edge evenly among the cells).
  537. return "(" + sizePercent + "% - (" + this._gutterSize + " * " + gutterFraction + "))";
  538. };
  539. /**
  540. * Gets The horizontal or vertical position of a tile, e.g., the 'top' or 'left' property value.
  541. * @param offset Number of tiles that have already been rendered in the row/column.
  542. * @param baseSize Base size of a 1x1 tile (as computed in getBaseTileSize).
  543. * @return Position of the tile as a CSS calc() expression.
  544. */
  545. /**
  546. * Gets The horizontal or vertical position of a tile, e.g., the 'top' or 'left' property value.
  547. * @param {?} baseSize Base size of a 1x1 tile (as computed in getBaseTileSize).
  548. * @param {?} offset Number of tiles that have already been rendered in the row/column.
  549. * @return {?} Position of the tile as a CSS calc() expression.
  550. */
  551. TileStyler.prototype.getTilePosition = /**
  552. * Gets The horizontal or vertical position of a tile, e.g., the 'top' or 'left' property value.
  553. * @param {?} baseSize Base size of a 1x1 tile (as computed in getBaseTileSize).
  554. * @param {?} offset Number of tiles that have already been rendered in the row/column.
  555. * @return {?} Position of the tile as a CSS calc() expression.
  556. */
  557. function (baseSize, offset) {
  558. // The position comes the size of a 1x1 tile plus gutter for each previous tile in the
  559. // row/column (offset).
  560. return offset === 0 ? '0' : calc("(" + baseSize + " + " + this._gutterSize + ") * " + offset);
  561. };
  562. /**
  563. * Gets the actual size of a tile, e.g., width or height, taking rowspan or colspan into account.
  564. * @param baseSize Base size of a 1x1 tile (as computed in getBaseTileSize).
  565. * @param span The tile's rowspan or colspan.
  566. * @return Size of the tile as a CSS calc() expression.
  567. */
  568. /**
  569. * Gets the actual size of a tile, e.g., width or height, taking rowspan or colspan into account.
  570. * @param {?} baseSize Base size of a 1x1 tile (as computed in getBaseTileSize).
  571. * @param {?} span The tile's rowspan or colspan.
  572. * @return {?} Size of the tile as a CSS calc() expression.
  573. */
  574. TileStyler.prototype.getTileSize = /**
  575. * Gets the actual size of a tile, e.g., width or height, taking rowspan or colspan into account.
  576. * @param {?} baseSize Base size of a 1x1 tile (as computed in getBaseTileSize).
  577. * @param {?} span The tile's rowspan or colspan.
  578. * @return {?} Size of the tile as a CSS calc() expression.
  579. */
  580. function (baseSize, span) {
  581. return "(" + baseSize + " * " + span + ") + (" + (span - 1) + " * " + this._gutterSize + ")";
  582. };
  583. /**
  584. * Sets the style properties to be applied to a tile for the given row and column index.
  585. * @param tile Tile to which to apply the styling.
  586. * @param rowIndex Index of the tile's row.
  587. * @param colIndex Index of the tile's column.
  588. */
  589. /**
  590. * Sets the style properties to be applied to a tile for the given row and column index.
  591. * @param {?} tile Tile to which to apply the styling.
  592. * @param {?} rowIndex Index of the tile's row.
  593. * @param {?} colIndex Index of the tile's column.
  594. * @return {?}
  595. */
  596. TileStyler.prototype.setStyle = /**
  597. * Sets the style properties to be applied to a tile for the given row and column index.
  598. * @param {?} tile Tile to which to apply the styling.
  599. * @param {?} rowIndex Index of the tile's row.
  600. * @param {?} colIndex Index of the tile's column.
  601. * @return {?}
  602. */
  603. function (tile, rowIndex, colIndex) {
  604. // Percent of the available horizontal space that one column takes up.
  605. /** @type {?} */
  606. var percentWidthPerTile = 100 / this._cols;
  607. // Fraction of the vertical gutter size that each column takes up.
  608. // For example, if there are 5 columns, each column uses 4/5 = 0.8 times the gutter width.
  609. /** @type {?} */
  610. var gutterWidthFractionPerTile = (this._cols - 1) / this._cols;
  611. this.setColStyles(tile, colIndex, percentWidthPerTile, gutterWidthFractionPerTile);
  612. this.setRowStyles(tile, rowIndex, percentWidthPerTile, gutterWidthFractionPerTile);
  613. };
  614. /** Sets the horizontal placement of the tile in the list. */
  615. /**
  616. * Sets the horizontal placement of the tile in the list.
  617. * @param {?} tile
  618. * @param {?} colIndex
  619. * @param {?} percentWidth
  620. * @param {?} gutterWidth
  621. * @return {?}
  622. */
  623. TileStyler.prototype.setColStyles = /**
  624. * Sets the horizontal placement of the tile in the list.
  625. * @param {?} tile
  626. * @param {?} colIndex
  627. * @param {?} percentWidth
  628. * @param {?} gutterWidth
  629. * @return {?}
  630. */
  631. function (tile, colIndex, percentWidth, gutterWidth) {
  632. // Base horizontal size of a column.
  633. /** @type {?} */
  634. var baseTileWidth = this.getBaseTileSize(percentWidth, gutterWidth);
  635. // The width and horizontal position of each tile is always calculated the same way, but the
  636. // height and vertical position depends on the rowMode.
  637. /** @type {?} */
  638. var side = this._direction === 'rtl' ? 'right' : 'left';
  639. tile._setStyle(side, this.getTilePosition(baseTileWidth, colIndex));
  640. tile._setStyle('width', calc(this.getTileSize(baseTileWidth, tile.colspan)));
  641. };
  642. /**
  643. * Calculates the total size taken up by gutters across one axis of a list.
  644. */
  645. /**
  646. * Calculates the total size taken up by gutters across one axis of a list.
  647. * @return {?}
  648. */
  649. TileStyler.prototype.getGutterSpan = /**
  650. * Calculates the total size taken up by gutters across one axis of a list.
  651. * @return {?}
  652. */
  653. function () {
  654. return this._gutterSize + " * (" + this._rowspan + " - 1)";
  655. };
  656. /**
  657. * Calculates the total size taken up by tiles across one axis of a list.
  658. * @param tileHeight Height of the tile.
  659. */
  660. /**
  661. * Calculates the total size taken up by tiles across one axis of a list.
  662. * @param {?} tileHeight Height of the tile.
  663. * @return {?}
  664. */
  665. TileStyler.prototype.getTileSpan = /**
  666. * Calculates the total size taken up by tiles across one axis of a list.
  667. * @param {?} tileHeight Height of the tile.
  668. * @return {?}
  669. */
  670. function (tileHeight) {
  671. return this._rowspan + " * " + this.getTileSize(tileHeight, 1);
  672. };
  673. /**
  674. * Calculates the computed height and returns the correct style property to set.
  675. * This method can be implemented by each type of TileStyler.
  676. * @docs-private
  677. */
  678. /**
  679. * Calculates the computed height and returns the correct style property to set.
  680. * This method can be implemented by each type of TileStyler.
  681. * \@docs-private
  682. * @return {?}
  683. */
  684. TileStyler.prototype.getComputedHeight = /**
  685. * Calculates the computed height and returns the correct style property to set.
  686. * This method can be implemented by each type of TileStyler.
  687. * \@docs-private
  688. * @return {?}
  689. */
  690. function () { return null; };
  691. return TileStyler;
  692. }());
  693. /**
  694. * This type of styler is instantiated when the user passes in a fixed row height.
  695. * Example `<mat-grid-list cols="3" rowHeight="100px">`
  696. * \@docs-private
  697. */
  698. var /**
  699. * This type of styler is instantiated when the user passes in a fixed row height.
  700. * Example `<mat-grid-list cols="3" rowHeight="100px">`
  701. * \@docs-private
  702. */
  703. FixedTileStyler = /** @class */ (function (_super) {
  704. __extends(FixedTileStyler, _super);
  705. function FixedTileStyler(fixedRowHeight) {
  706. var _this = _super.call(this) || this;
  707. _this.fixedRowHeight = fixedRowHeight;
  708. return _this;
  709. }
  710. /**
  711. * @param {?} gutterSize
  712. * @param {?} tracker
  713. * @param {?} cols
  714. * @param {?} direction
  715. * @return {?}
  716. */
  717. FixedTileStyler.prototype.init = /**
  718. * @param {?} gutterSize
  719. * @param {?} tracker
  720. * @param {?} cols
  721. * @param {?} direction
  722. * @return {?}
  723. */
  724. function (gutterSize, tracker, cols, direction) {
  725. _super.prototype.init.call(this, gutterSize, tracker, cols, direction);
  726. this.fixedRowHeight = normalizeUnits(this.fixedRowHeight);
  727. if (!cssCalcAllowedValue.test(this.fixedRowHeight)) {
  728. throw Error("Invalid value \"" + this.fixedRowHeight + "\" set as rowHeight.");
  729. }
  730. };
  731. /**
  732. * @param {?} tile
  733. * @param {?} rowIndex
  734. * @return {?}
  735. */
  736. FixedTileStyler.prototype.setRowStyles = /**
  737. * @param {?} tile
  738. * @param {?} rowIndex
  739. * @return {?}
  740. */
  741. function (tile, rowIndex) {
  742. tile._setStyle('top', this.getTilePosition(this.fixedRowHeight, rowIndex));
  743. tile._setStyle('height', calc(this.getTileSize(this.fixedRowHeight, tile.rowspan)));
  744. };
  745. /**
  746. * @return {?}
  747. */
  748. FixedTileStyler.prototype.getComputedHeight = /**
  749. * @return {?}
  750. */
  751. function () {
  752. return [
  753. 'height', calc(this.getTileSpan(this.fixedRowHeight) + " + " + this.getGutterSpan())
  754. ];
  755. };
  756. /**
  757. * @param {?} list
  758. * @return {?}
  759. */
  760. FixedTileStyler.prototype.reset = /**
  761. * @param {?} list
  762. * @return {?}
  763. */
  764. function (list) {
  765. list._setListStyle(['height', null]);
  766. if (list._tiles) {
  767. list._tiles.forEach((/**
  768. * @param {?} tile
  769. * @return {?}
  770. */
  771. function (tile) {
  772. tile._setStyle('top', null);
  773. tile._setStyle('height', null);
  774. }));
  775. }
  776. };
  777. return FixedTileStyler;
  778. }(TileStyler));
  779. /**
  780. * This type of styler is instantiated when the user passes in a width:height ratio
  781. * for the row height. Example `<mat-grid-list cols="3" rowHeight="3:1">`
  782. * \@docs-private
  783. */
  784. var /**
  785. * This type of styler is instantiated when the user passes in a width:height ratio
  786. * for the row height. Example `<mat-grid-list cols="3" rowHeight="3:1">`
  787. * \@docs-private
  788. */
  789. RatioTileStyler = /** @class */ (function (_super) {
  790. __extends(RatioTileStyler, _super);
  791. function RatioTileStyler(value) {
  792. var _this = _super.call(this) || this;
  793. _this._parseRatio(value);
  794. return _this;
  795. }
  796. /**
  797. * @param {?} tile
  798. * @param {?} rowIndex
  799. * @param {?} percentWidth
  800. * @param {?} gutterWidth
  801. * @return {?}
  802. */
  803. RatioTileStyler.prototype.setRowStyles = /**
  804. * @param {?} tile
  805. * @param {?} rowIndex
  806. * @param {?} percentWidth
  807. * @param {?} gutterWidth
  808. * @return {?}
  809. */
  810. function (tile, rowIndex, percentWidth, gutterWidth) {
  811. /** @type {?} */
  812. var percentHeightPerTile = percentWidth / this.rowHeightRatio;
  813. this.baseTileHeight = this.getBaseTileSize(percentHeightPerTile, gutterWidth);
  814. // Use padding-top and margin-top to maintain the given aspect ratio, as
  815. // a percentage-based value for these properties is applied versus the *width* of the
  816. // containing block. See http://www.w3.org/TR/CSS2/box.html#margin-properties
  817. tile._setStyle('marginTop', this.getTilePosition(this.baseTileHeight, rowIndex));
  818. tile._setStyle('paddingTop', calc(this.getTileSize(this.baseTileHeight, tile.rowspan)));
  819. };
  820. /**
  821. * @return {?}
  822. */
  823. RatioTileStyler.prototype.getComputedHeight = /**
  824. * @return {?}
  825. */
  826. function () {
  827. return [
  828. 'paddingBottom', calc(this.getTileSpan(this.baseTileHeight) + " + " + this.getGutterSpan())
  829. ];
  830. };
  831. /**
  832. * @param {?} list
  833. * @return {?}
  834. */
  835. RatioTileStyler.prototype.reset = /**
  836. * @param {?} list
  837. * @return {?}
  838. */
  839. function (list) {
  840. list._setListStyle(['paddingBottom', null]);
  841. list._tiles.forEach((/**
  842. * @param {?} tile
  843. * @return {?}
  844. */
  845. function (tile) {
  846. tile._setStyle('marginTop', null);
  847. tile._setStyle('paddingTop', null);
  848. }));
  849. };
  850. /**
  851. * @private
  852. * @param {?} value
  853. * @return {?}
  854. */
  855. RatioTileStyler.prototype._parseRatio = /**
  856. * @private
  857. * @param {?} value
  858. * @return {?}
  859. */
  860. function (value) {
  861. /** @type {?} */
  862. var ratioParts = value.split(':');
  863. if (ratioParts.length !== 2) {
  864. throw Error("mat-grid-list: invalid ratio given for row-height: \"" + value + "\"");
  865. }
  866. this.rowHeightRatio = parseFloat(ratioParts[0]) / parseFloat(ratioParts[1]);
  867. };
  868. return RatioTileStyler;
  869. }(TileStyler));
  870. /**
  871. * This type of styler is instantiated when the user selects a "fit" row height mode.
  872. * In other words, the row height will reflect the total height of the container divided
  873. * by the number of rows. Example `<mat-grid-list cols="3" rowHeight="fit">`
  874. *
  875. * \@docs-private
  876. */
  877. var /**
  878. * This type of styler is instantiated when the user selects a "fit" row height mode.
  879. * In other words, the row height will reflect the total height of the container divided
  880. * by the number of rows. Example `<mat-grid-list cols="3" rowHeight="fit">`
  881. *
  882. * \@docs-private
  883. */
  884. FitTileStyler = /** @class */ (function (_super) {
  885. __extends(FitTileStyler, _super);
  886. function FitTileStyler() {
  887. return _super !== null && _super.apply(this, arguments) || this;
  888. }
  889. /**
  890. * @param {?} tile
  891. * @param {?} rowIndex
  892. * @return {?}
  893. */
  894. FitTileStyler.prototype.setRowStyles = /**
  895. * @param {?} tile
  896. * @param {?} rowIndex
  897. * @return {?}
  898. */
  899. function (tile, rowIndex) {
  900. // Percent of the available vertical space that one row takes up.
  901. /** @type {?} */
  902. var percentHeightPerTile = 100 / this._rowspan;
  903. // Fraction of the horizontal gutter size that each column takes up.
  904. /** @type {?} */
  905. var gutterHeightPerTile = (this._rows - 1) / this._rows;
  906. // Base vertical size of a column.
  907. /** @type {?} */
  908. var baseTileHeight = this.getBaseTileSize(percentHeightPerTile, gutterHeightPerTile);
  909. tile._setStyle('top', this.getTilePosition(baseTileHeight, rowIndex));
  910. tile._setStyle('height', calc(this.getTileSize(baseTileHeight, tile.rowspan)));
  911. };
  912. /**
  913. * @param {?} list
  914. * @return {?}
  915. */
  916. FitTileStyler.prototype.reset = /**
  917. * @param {?} list
  918. * @return {?}
  919. */
  920. function (list) {
  921. if (list._tiles) {
  922. list._tiles.forEach((/**
  923. * @param {?} tile
  924. * @return {?}
  925. */
  926. function (tile) {
  927. tile._setStyle('top', null);
  928. tile._setStyle('height', null);
  929. }));
  930. }
  931. };
  932. return FitTileStyler;
  933. }(TileStyler));
  934. /**
  935. * Wraps a CSS string in a calc function
  936. * @param {?} exp
  937. * @return {?}
  938. */
  939. function calc(exp) {
  940. return "calc(" + exp + ")";
  941. }
  942. /**
  943. * Appends pixels to a CSS string if no units are given.
  944. * @param {?} value
  945. * @return {?}
  946. */
  947. function normalizeUnits(value) {
  948. return value.match(/([A-Za-z%]+)$/) ? value : value + "px";
  949. }
  950. /**
  951. * @fileoverview added by tsickle
  952. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  953. */
  954. // TODO(kara): Conditional (responsive) column count / row size.
  955. // TODO(kara): Re-layout on window resize / media change (debounced).
  956. // TODO(kara): gridTileHeader and gridTileFooter.
  957. /** @type {?} */
  958. var MAT_FIT_MODE = 'fit';
  959. var MatGridList = /** @class */ (function () {
  960. function MatGridList(_element, _dir) {
  961. this._element = _element;
  962. this._dir = _dir;
  963. /**
  964. * The amount of space between tiles. This will be something like '5px' or '2em'.
  965. */
  966. this._gutter = '1px';
  967. }
  968. Object.defineProperty(MatGridList.prototype, "cols", {
  969. /** Amount of columns in the grid list. */
  970. get: /**
  971. * Amount of columns in the grid list.
  972. * @return {?}
  973. */
  974. function () { return this._cols; },
  975. set: /**
  976. * @param {?} value
  977. * @return {?}
  978. */
  979. function (value) {
  980. this._cols = Math.max(1, Math.round(coerceNumberProperty(value)));
  981. },
  982. enumerable: true,
  983. configurable: true
  984. });
  985. Object.defineProperty(MatGridList.prototype, "gutterSize", {
  986. /** Size of the grid list's gutter in pixels. */
  987. get: /**
  988. * Size of the grid list's gutter in pixels.
  989. * @return {?}
  990. */
  991. function () { return this._gutter; },
  992. set: /**
  993. * @param {?} value
  994. * @return {?}
  995. */
  996. function (value) { this._gutter = "" + (value == null ? '' : value); },
  997. enumerable: true,
  998. configurable: true
  999. });
  1000. Object.defineProperty(MatGridList.prototype, "rowHeight", {
  1001. /** Set internal representation of row height from the user-provided value. */
  1002. get: /**
  1003. * Set internal representation of row height from the user-provided value.
  1004. * @return {?}
  1005. */
  1006. function () { return this._rowHeight; },
  1007. set: /**
  1008. * @param {?} value
  1009. * @return {?}
  1010. */
  1011. function (value) {
  1012. /** @type {?} */
  1013. var newValue = "" + (value == null ? '' : value);
  1014. if (newValue !== this._rowHeight) {
  1015. this._rowHeight = newValue;
  1016. this._setTileStyler(this._rowHeight);
  1017. }
  1018. },
  1019. enumerable: true,
  1020. configurable: true
  1021. });
  1022. /**
  1023. * @return {?}
  1024. */
  1025. MatGridList.prototype.ngOnInit = /**
  1026. * @return {?}
  1027. */
  1028. function () {
  1029. this._checkCols();
  1030. this._checkRowHeight();
  1031. };
  1032. /**
  1033. * The layout calculation is fairly cheap if nothing changes, so there's little cost
  1034. * to run it frequently.
  1035. */
  1036. /**
  1037. * The layout calculation is fairly cheap if nothing changes, so there's little cost
  1038. * to run it frequently.
  1039. * @return {?}
  1040. */
  1041. MatGridList.prototype.ngAfterContentChecked = /**
  1042. * The layout calculation is fairly cheap if nothing changes, so there's little cost
  1043. * to run it frequently.
  1044. * @return {?}
  1045. */
  1046. function () {
  1047. this._layoutTiles();
  1048. };
  1049. /** Throw a friendly error if cols property is missing */
  1050. /**
  1051. * Throw a friendly error if cols property is missing
  1052. * @private
  1053. * @return {?}
  1054. */
  1055. MatGridList.prototype._checkCols = /**
  1056. * Throw a friendly error if cols property is missing
  1057. * @private
  1058. * @return {?}
  1059. */
  1060. function () {
  1061. if (!this.cols) {
  1062. throw Error("mat-grid-list: must pass in number of columns. " +
  1063. "Example: <mat-grid-list cols=\"3\">");
  1064. }
  1065. };
  1066. /** Default to equal width:height if rowHeight property is missing */
  1067. /**
  1068. * Default to equal width:height if rowHeight property is missing
  1069. * @private
  1070. * @return {?}
  1071. */
  1072. MatGridList.prototype._checkRowHeight = /**
  1073. * Default to equal width:height if rowHeight property is missing
  1074. * @private
  1075. * @return {?}
  1076. */
  1077. function () {
  1078. if (!this._rowHeight) {
  1079. this._setTileStyler('1:1');
  1080. }
  1081. };
  1082. /** Creates correct Tile Styler subtype based on rowHeight passed in by user */
  1083. /**
  1084. * Creates correct Tile Styler subtype based on rowHeight passed in by user
  1085. * @private
  1086. * @param {?} rowHeight
  1087. * @return {?}
  1088. */
  1089. MatGridList.prototype._setTileStyler = /**
  1090. * Creates correct Tile Styler subtype based on rowHeight passed in by user
  1091. * @private
  1092. * @param {?} rowHeight
  1093. * @return {?}
  1094. */
  1095. function (rowHeight) {
  1096. if (this._tileStyler) {
  1097. this._tileStyler.reset(this);
  1098. }
  1099. if (rowHeight === MAT_FIT_MODE) {
  1100. this._tileStyler = new FitTileStyler();
  1101. }
  1102. else if (rowHeight && rowHeight.indexOf(':') > -1) {
  1103. this._tileStyler = new RatioTileStyler(rowHeight);
  1104. }
  1105. else {
  1106. this._tileStyler = new FixedTileStyler(rowHeight);
  1107. }
  1108. };
  1109. /** Computes and applies the size and position for all children grid tiles. */
  1110. /**
  1111. * Computes and applies the size and position for all children grid tiles.
  1112. * @private
  1113. * @return {?}
  1114. */
  1115. MatGridList.prototype._layoutTiles = /**
  1116. * Computes and applies the size and position for all children grid tiles.
  1117. * @private
  1118. * @return {?}
  1119. */
  1120. function () {
  1121. var _this = this;
  1122. if (!this._tileCoordinator) {
  1123. this._tileCoordinator = new TileCoordinator();
  1124. }
  1125. /** @type {?} */
  1126. var tracker = this._tileCoordinator;
  1127. /** @type {?} */
  1128. var tiles = this._tiles.filter((/**
  1129. * @param {?} tile
  1130. * @return {?}
  1131. */
  1132. function (tile) { return !tile._gridList || tile._gridList === _this; }));
  1133. /** @type {?} */
  1134. var direction = this._dir ? this._dir.value : 'ltr';
  1135. this._tileCoordinator.update(this.cols, tiles);
  1136. this._tileStyler.init(this.gutterSize, tracker, this.cols, direction);
  1137. tiles.forEach((/**
  1138. * @param {?} tile
  1139. * @param {?} index
  1140. * @return {?}
  1141. */
  1142. function (tile, index) {
  1143. /** @type {?} */
  1144. var pos = tracker.positions[index];
  1145. _this._tileStyler.setStyle(tile, pos.row, pos.col);
  1146. }));
  1147. this._setListStyle(this._tileStyler.getComputedHeight());
  1148. };
  1149. /** Sets style on the main grid-list element, given the style name and value. */
  1150. /**
  1151. * Sets style on the main grid-list element, given the style name and value.
  1152. * @param {?} style
  1153. * @return {?}
  1154. */
  1155. MatGridList.prototype._setListStyle = /**
  1156. * Sets style on the main grid-list element, given the style name and value.
  1157. * @param {?} style
  1158. * @return {?}
  1159. */
  1160. function (style) {
  1161. if (style) {
  1162. ((/** @type {?} */ (this._element.nativeElement.style)))[style[0]] = style[1];
  1163. }
  1164. };
  1165. MatGridList.decorators = [
  1166. { type: Component, args: [{selector: 'mat-grid-list',
  1167. exportAs: 'matGridList',
  1168. template: "<div><ng-content></ng-content></div>",
  1169. 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}"],
  1170. host: {
  1171. 'class': 'mat-grid-list',
  1172. },
  1173. providers: [{
  1174. provide: MAT_GRID_LIST,
  1175. useExisting: MatGridList
  1176. }],
  1177. changeDetection: ChangeDetectionStrategy.OnPush,
  1178. encapsulation: ViewEncapsulation.None,
  1179. },] },
  1180. ];
  1181. /** @nocollapse */
  1182. MatGridList.ctorParameters = function () { return [
  1183. { type: ElementRef },
  1184. { type: Directionality, decorators: [{ type: Optional }] }
  1185. ]; };
  1186. MatGridList.propDecorators = {
  1187. _tiles: [{ type: ContentChildren, args: [MatGridTile, { descendants: true },] }],
  1188. cols: [{ type: Input }],
  1189. gutterSize: [{ type: Input }],
  1190. rowHeight: [{ type: Input }]
  1191. };
  1192. return MatGridList;
  1193. }());
  1194. /**
  1195. * @fileoverview added by tsickle
  1196. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1197. */
  1198. var MatGridListModule = /** @class */ (function () {
  1199. function MatGridListModule() {
  1200. }
  1201. MatGridListModule.decorators = [
  1202. { type: NgModule, args: [{
  1203. imports: [MatLineModule, MatCommonModule],
  1204. exports: [
  1205. MatGridList,
  1206. MatGridTile,
  1207. MatGridTileText,
  1208. MatLineModule,
  1209. MatCommonModule,
  1210. MatGridTileHeaderCssMatStyler,
  1211. MatGridTileFooterCssMatStyler,
  1212. MatGridAvatarCssMatStyler
  1213. ],
  1214. declarations: [
  1215. MatGridList,
  1216. MatGridTile,
  1217. MatGridTileText,
  1218. MatGridTileHeaderCssMatStyler,
  1219. MatGridTileFooterCssMatStyler,
  1220. MatGridAvatarCssMatStyler
  1221. ],
  1222. },] },
  1223. ];
  1224. return MatGridListModule;
  1225. }());
  1226. /**
  1227. * @fileoverview added by tsickle
  1228. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1229. */
  1230. /**
  1231. * @fileoverview added by tsickle
  1232. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1233. */
  1234. export { MatGridListModule, MatGridList, MatGridTile, MatGridTileText, MatGridAvatarCssMatStyler, MatGridTileHeaderCssMatStyler, MatGridTileFooterCssMatStyler, MAT_GRID_LIST as ɵa6 };
  1235. //# sourceMappingURL=grid-list.es5.js.map