material-grid-list.umd.js 49 KB

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