source: trip-planner-front/node_modules/@angular/material/esm2015/grid-list/tile-styler.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 32.2 KB
Line 
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/**
9 * RegExp that can be used to check whether a value will
10 * be allowed inside a CSS `calc()` expression.
11 */
12const cssCalcAllowedValue = /^-?\d+((\.\d+)?[A-Za-z%$]?)+$/;
13/**
14 * Sets the style properties for an individual tile, given the position calculated by the
15 * Tile Coordinator.
16 * @docs-private
17 */
18export class TileStyler {
19 constructor() {
20 this._rows = 0;
21 this._rowspan = 0;
22 }
23 /**
24 * Adds grid-list layout info once it is available. Cannot be processed in the constructor
25 * because these properties haven't been calculated by that point.
26 *
27 * @param gutterSize Size of the grid's gutter.
28 * @param tracker Instance of the TileCoordinator.
29 * @param cols Amount of columns in the grid.
30 * @param direction Layout direction of the grid.
31 */
32 init(gutterSize, tracker, cols, direction) {
33 this._gutterSize = normalizeUnits(gutterSize);
34 this._rows = tracker.rowCount;
35 this._rowspan = tracker.rowspan;
36 this._cols = cols;
37 this._direction = direction;
38 }
39 /**
40 * Computes the amount of space a single 1x1 tile would take up (width or height).
41 * Used as a basis for other calculations.
42 * @param sizePercent Percent of the total grid-list space that one 1x1 tile would take up.
43 * @param gutterFraction Fraction of the gutter size taken up by one 1x1 tile.
44 * @return The size of a 1x1 tile as an expression that can be evaluated via CSS calc().
45 */
46 getBaseTileSize(sizePercent, gutterFraction) {
47 // Take the base size percent (as would be if evenly dividing the size between cells),
48 // and then subtracting the size of one gutter. However, since there are no gutters on the
49 // edges, each tile only uses a fraction (gutterShare = numGutters / numCells) of the gutter
50 // size. (Imagine having one gutter per tile, and then breaking up the extra gutter on the
51 // edge evenly among the cells).
52 return `(${sizePercent}% - (${this._gutterSize} * ${gutterFraction}))`;
53 }
54 /**
55 * Gets The horizontal or vertical position of a tile, e.g., the 'top' or 'left' property value.
56 * @param offset Number of tiles that have already been rendered in the row/column.
57 * @param baseSize Base size of a 1x1 tile (as computed in getBaseTileSize).
58 * @return Position of the tile as a CSS calc() expression.
59 */
60 getTilePosition(baseSize, offset) {
61 // The position comes the size of a 1x1 tile plus gutter for each previous tile in the
62 // row/column (offset).
63 return offset === 0 ? '0' : calc(`(${baseSize} + ${this._gutterSize}) * ${offset}`);
64 }
65 /**
66 * Gets the actual size of a tile, e.g., width or height, taking rowspan or colspan into account.
67 * @param baseSize Base size of a 1x1 tile (as computed in getBaseTileSize).
68 * @param span The tile's rowspan or colspan.
69 * @return Size of the tile as a CSS calc() expression.
70 */
71 getTileSize(baseSize, span) {
72 return `(${baseSize} * ${span}) + (${span - 1} * ${this._gutterSize})`;
73 }
74 /**
75 * Sets the style properties to be applied to a tile for the given row and column index.
76 * @param tile Tile to which to apply the styling.
77 * @param rowIndex Index of the tile's row.
78 * @param colIndex Index of the tile's column.
79 */
80 setStyle(tile, rowIndex, colIndex) {
81 // Percent of the available horizontal space that one column takes up.
82 let percentWidthPerTile = 100 / this._cols;
83 // Fraction of the vertical gutter size that each column takes up.
84 // For example, if there are 5 columns, each column uses 4/5 = 0.8 times the gutter width.
85 let gutterWidthFractionPerTile = (this._cols - 1) / this._cols;
86 this.setColStyles(tile, colIndex, percentWidthPerTile, gutterWidthFractionPerTile);
87 this.setRowStyles(tile, rowIndex, percentWidthPerTile, gutterWidthFractionPerTile);
88 }
89 /** Sets the horizontal placement of the tile in the list. */
90 setColStyles(tile, colIndex, percentWidth, gutterWidth) {
91 // Base horizontal size of a column.
92 let baseTileWidth = this.getBaseTileSize(percentWidth, gutterWidth);
93 // The width and horizontal position of each tile is always calculated the same way, but the
94 // height and vertical position depends on the rowMode.
95 let side = this._direction === 'rtl' ? 'right' : 'left';
96 tile._setStyle(side, this.getTilePosition(baseTileWidth, colIndex));
97 tile._setStyle('width', calc(this.getTileSize(baseTileWidth, tile.colspan)));
98 }
99 /**
100 * Calculates the total size taken up by gutters across one axis of a list.
101 */
102 getGutterSpan() {
103 return `${this._gutterSize} * (${this._rowspan} - 1)`;
104 }
105 /**
106 * Calculates the total size taken up by tiles across one axis of a list.
107 * @param tileHeight Height of the tile.
108 */
109 getTileSpan(tileHeight) {
110 return `${this._rowspan} * ${this.getTileSize(tileHeight, 1)}`;
111 }
112 /**
113 * Calculates the computed height and returns the correct style property to set.
114 * This method can be implemented by each type of TileStyler.
115 * @docs-private
116 */
117 getComputedHeight() { return null; }
118}
119/**
120 * This type of styler is instantiated when the user passes in a fixed row height.
121 * Example `<mat-grid-list cols="3" rowHeight="100px">`
122 * @docs-private
123 */
124export class FixedTileStyler extends TileStyler {
125 constructor(fixedRowHeight) {
126 super();
127 this.fixedRowHeight = fixedRowHeight;
128 }
129 init(gutterSize, tracker, cols, direction) {
130 super.init(gutterSize, tracker, cols, direction);
131 this.fixedRowHeight = normalizeUnits(this.fixedRowHeight);
132 if (!cssCalcAllowedValue.test(this.fixedRowHeight) &&
133 (typeof ngDevMode === 'undefined' || ngDevMode)) {
134 throw Error(`Invalid value "${this.fixedRowHeight}" set as rowHeight.`);
135 }
136 }
137 setRowStyles(tile, rowIndex) {
138 tile._setStyle('top', this.getTilePosition(this.fixedRowHeight, rowIndex));
139 tile._setStyle('height', calc(this.getTileSize(this.fixedRowHeight, tile.rowspan)));
140 }
141 getComputedHeight() {
142 return [
143 'height', calc(`${this.getTileSpan(this.fixedRowHeight)} + ${this.getGutterSpan()}`)
144 ];
145 }
146 reset(list) {
147 list._setListStyle(['height', null]);
148 if (list._tiles) {
149 list._tiles.forEach(tile => {
150 tile._setStyle('top', null);
151 tile._setStyle('height', null);
152 });
153 }
154 }
155}
156/**
157 * This type of styler is instantiated when the user passes in a width:height ratio
158 * for the row height. Example `<mat-grid-list cols="3" rowHeight="3:1">`
159 * @docs-private
160 */
161export class RatioTileStyler extends TileStyler {
162 constructor(value) {
163 super();
164 this._parseRatio(value);
165 }
166 setRowStyles(tile, rowIndex, percentWidth, gutterWidth) {
167 let percentHeightPerTile = percentWidth / this.rowHeightRatio;
168 this.baseTileHeight = this.getBaseTileSize(percentHeightPerTile, gutterWidth);
169 // Use padding-top and margin-top to maintain the given aspect ratio, as
170 // a percentage-based value for these properties is applied versus the *width* of the
171 // containing block. See http://www.w3.org/TR/CSS2/box.html#margin-properties
172 tile._setStyle('marginTop', this.getTilePosition(this.baseTileHeight, rowIndex));
173 tile._setStyle('paddingTop', calc(this.getTileSize(this.baseTileHeight, tile.rowspan)));
174 }
175 getComputedHeight() {
176 return [
177 'paddingBottom', calc(`${this.getTileSpan(this.baseTileHeight)} + ${this.getGutterSpan()}`)
178 ];
179 }
180 reset(list) {
181 list._setListStyle(['paddingBottom', null]);
182 list._tiles.forEach(tile => {
183 tile._setStyle('marginTop', null);
184 tile._setStyle('paddingTop', null);
185 });
186 }
187 _parseRatio(value) {
188 const ratioParts = value.split(':');
189 if (ratioParts.length !== 2 && (typeof ngDevMode === 'undefined' || ngDevMode)) {
190 throw Error(`mat-grid-list: invalid ratio given for row-height: "${value}"`);
191 }
192 this.rowHeightRatio = parseFloat(ratioParts[0]) / parseFloat(ratioParts[1]);
193 }
194}
195/**
196 * This type of styler is instantiated when the user selects a "fit" row height mode.
197 * In other words, the row height will reflect the total height of the container divided
198 * by the number of rows. Example `<mat-grid-list cols="3" rowHeight="fit">`
199 *
200 * @docs-private
201 */
202export class FitTileStyler extends TileStyler {
203 setRowStyles(tile, rowIndex) {
204 // Percent of the available vertical space that one row takes up.
205 let percentHeightPerTile = 100 / this._rowspan;
206 // Fraction of the horizontal gutter size that each column takes up.
207 let gutterHeightPerTile = (this._rows - 1) / this._rows;
208 // Base vertical size of a column.
209 let baseTileHeight = this.getBaseTileSize(percentHeightPerTile, gutterHeightPerTile);
210 tile._setStyle('top', this.getTilePosition(baseTileHeight, rowIndex));
211 tile._setStyle('height', calc(this.getTileSize(baseTileHeight, tile.rowspan)));
212 }
213 reset(list) {
214 if (list._tiles) {
215 list._tiles.forEach(tile => {
216 tile._setStyle('top', null);
217 tile._setStyle('height', null);
218 });
219 }
220 }
221}
222/** Wraps a CSS string in a calc function */
223function calc(exp) {
224 return `calc(${exp})`;
225}
226/** Appends pixels to a CSS string if no units are given. */
227function normalizeUnits(value) {
228 return value.match(/([A-Za-z%]+)$/) ? value : `${value}px`;
229}
230//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGlsZS1zdHlsZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvbWF0ZXJpYWwvZ3JpZC1saXN0L3RpbGUtc3R5bGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRztBQU1IOzs7R0FHRztBQUNILE1BQU0sbUJBQW1CLEdBQUcsK0JBQStCLENBQUM7QUFRNUQ7Ozs7R0FJRztBQUNILE1BQU0sT0FBZ0IsVUFBVTtJQUFoQztRQUVFLFVBQUssR0FBVyxDQUFDLENBQUM7UUFDbEIsYUFBUSxHQUFXLENBQUMsQ0FBQztJQWlJdkIsQ0FBQztJQTdIQzs7Ozs7Ozs7T0FRRztJQUNILElBQUksQ0FBQyxVQUFrQixFQUFFLE9BQXdCLEVBQUUsSUFBWSxFQUFFLFNBQWlCO1FBQ2hGLElBQUksQ0FBQyxXQUFXLEdBQUcsY0FBYyxDQUFDLFVBQVUsQ0FBQyxDQUFDO1FBQzlDLElBQUksQ0FBQyxLQUFLLEdBQUcsT0FBTyxDQUFDLFFBQVEsQ0FBQztRQUM5QixJQUFJLENBQUMsUUFBUSxHQUFHLE9BQU8sQ0FBQyxPQUFPLENBQUM7UUFDaEMsSUFBSSxDQUFDLEtBQUssR0FBRyxJQUFJLENBQUM7UUFDbEIsSUFBSSxDQUFDLFVBQVUsR0FBRyxTQUFTLENBQUM7SUFDOUIsQ0FBQztJQUVEOzs7Ozs7T0FNRzt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