[6a3a178] | 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 { QueryList } from '@angular/core';
|
---|
| 9 | import { MatGridTile } from './grid-tile';
|
---|
| 10 | import { TileCoordinator } from './tile-coordinator';
|
---|
| 11 | /** Object that can be styled by the `TileStyler`. */
|
---|
| 12 | export interface TileStyleTarget {
|
---|
| 13 | _setListStyle(style: [string, string | null] | null): void;
|
---|
| 14 | _tiles: QueryList<MatGridTile>;
|
---|
| 15 | }
|
---|
| 16 | /**
|
---|
| 17 | * Sets the style properties for an individual tile, given the position calculated by the
|
---|
| 18 | * Tile Coordinator.
|
---|
| 19 | * @docs-private
|
---|
| 20 | */
|
---|
| 21 | export declare abstract class TileStyler {
|
---|
| 22 | _gutterSize: string;
|
---|
| 23 | _rows: number;
|
---|
| 24 | _rowspan: number;
|
---|
| 25 | _cols: number;
|
---|
| 26 | _direction: string;
|
---|
| 27 | /**
|
---|
| 28 | * Adds grid-list layout info once it is available. Cannot be processed in the constructor
|
---|
| 29 | * because these properties haven't been calculated by that point.
|
---|
| 30 | *
|
---|
| 31 | * @param gutterSize Size of the grid's gutter.
|
---|
| 32 | * @param tracker Instance of the TileCoordinator.
|
---|
| 33 | * @param cols Amount of columns in the grid.
|
---|
| 34 | * @param direction Layout direction of the grid.
|
---|
| 35 | */
|
---|
| 36 | init(gutterSize: string, tracker: TileCoordinator, cols: number, direction: string): void;
|
---|
| 37 | /**
|
---|
| 38 | * Computes the amount of space a single 1x1 tile would take up (width or height).
|
---|
| 39 | * Used as a basis for other calculations.
|
---|
| 40 | * @param sizePercent Percent of the total grid-list space that one 1x1 tile would take up.
|
---|
| 41 | * @param gutterFraction Fraction of the gutter size taken up by one 1x1 tile.
|
---|
| 42 | * @return The size of a 1x1 tile as an expression that can be evaluated via CSS calc().
|
---|
| 43 | */
|
---|
| 44 | getBaseTileSize(sizePercent: number, gutterFraction: number): string;
|
---|
| 45 | /**
|
---|
| 46 | * Gets The horizontal or vertical position of a tile, e.g., the 'top' or 'left' property value.
|
---|
| 47 | * @param offset Number of tiles that have already been rendered in the row/column.
|
---|
| 48 | * @param baseSize Base size of a 1x1 tile (as computed in getBaseTileSize).
|
---|
| 49 | * @return Position of the tile as a CSS calc() expression.
|
---|
| 50 | */
|
---|
| 51 | getTilePosition(baseSize: string, offset: number): string;
|
---|
| 52 | /**
|
---|
| 53 | * Gets the actual size of a tile, e.g., width or height, taking rowspan or colspan into account.
|
---|
| 54 | * @param baseSize Base size of a 1x1 tile (as computed in getBaseTileSize).
|
---|
| 55 | * @param span The tile's rowspan or colspan.
|
---|
| 56 | * @return Size of the tile as a CSS calc() expression.
|
---|
| 57 | */
|
---|
| 58 | getTileSize(baseSize: string, span: number): string;
|
---|
| 59 | /**
|
---|
| 60 | * Sets the style properties to be applied to a tile for the given row and column index.
|
---|
| 61 | * @param tile Tile to which to apply the styling.
|
---|
| 62 | * @param rowIndex Index of the tile's row.
|
---|
| 63 | * @param colIndex Index of the tile's column.
|
---|
| 64 | */
|
---|
| 65 | setStyle(tile: MatGridTile, rowIndex: number, colIndex: number): void;
|
---|
| 66 | /** Sets the horizontal placement of the tile in the list. */
|
---|
| 67 | setColStyles(tile: MatGridTile, colIndex: number, percentWidth: number, gutterWidth: number): void;
|
---|
| 68 | /**
|
---|
| 69 | * Calculates the total size taken up by gutters across one axis of a list.
|
---|
| 70 | */
|
---|
| 71 | getGutterSpan(): string;
|
---|
| 72 | /**
|
---|
| 73 | * Calculates the total size taken up by tiles across one axis of a list.
|
---|
| 74 | * @param tileHeight Height of the tile.
|
---|
| 75 | */
|
---|
| 76 | getTileSpan(tileHeight: string): string;
|
---|
| 77 | /**
|
---|
| 78 | * Sets the vertical placement of the tile in the list.
|
---|
| 79 | * This method will be implemented by each type of TileStyler.
|
---|
| 80 | * @docs-private
|
---|
| 81 | */
|
---|
| 82 | abstract setRowStyles(tile: MatGridTile, rowIndex: number, percentWidth: number, gutterWidth: number): void;
|
---|
| 83 | /**
|
---|
| 84 | * Calculates the computed height and returns the correct style property to set.
|
---|
| 85 | * This method can be implemented by each type of TileStyler.
|
---|
| 86 | * @docs-private
|
---|
| 87 | */
|
---|
| 88 | getComputedHeight(): [string, string] | null;
|
---|
| 89 | /**
|
---|
| 90 | * Called when the tile styler is swapped out with a different one. To be used for cleanup.
|
---|
| 91 | * @param list Grid list that the styler was attached to.
|
---|
| 92 | * @docs-private
|
---|
| 93 | */
|
---|
| 94 | abstract reset(list: TileStyleTarget): void;
|
---|
| 95 | }
|
---|
| 96 | /**
|
---|
| 97 | * This type of styler is instantiated when the user passes in a fixed row height.
|
---|
| 98 | * Example `<mat-grid-list cols="3" rowHeight="100px">`
|
---|
| 99 | * @docs-private
|
---|
| 100 | */
|
---|
| 101 | export declare class FixedTileStyler extends TileStyler {
|
---|
| 102 | fixedRowHeight: string;
|
---|
| 103 | constructor(fixedRowHeight: string);
|
---|
| 104 | init(gutterSize: string, tracker: TileCoordinator, cols: number, direction: string): void;
|
---|
| 105 | setRowStyles(tile: MatGridTile, rowIndex: number): void;
|
---|
| 106 | getComputedHeight(): [string, string];
|
---|
| 107 | reset(list: TileStyleTarget): void;
|
---|
| 108 | }
|
---|
| 109 | /**
|
---|
| 110 | * This type of styler is instantiated when the user passes in a width:height ratio
|
---|
| 111 | * for the row height. Example `<mat-grid-list cols="3" rowHeight="3:1">`
|
---|
| 112 | * @docs-private
|
---|
| 113 | */
|
---|
| 114 | export declare class RatioTileStyler extends TileStyler {
|
---|
| 115 | /** Ratio width:height given by user to determine row height. */
|
---|
| 116 | rowHeightRatio: number;
|
---|
| 117 | baseTileHeight: string;
|
---|
| 118 | constructor(value: string);
|
---|
| 119 | setRowStyles(tile: MatGridTile, rowIndex: number, percentWidth: number, gutterWidth: number): void;
|
---|
| 120 | getComputedHeight(): [string, string];
|
---|
| 121 | reset(list: TileStyleTarget): void;
|
---|
| 122 | private _parseRatio;
|
---|
| 123 | }
|
---|
| 124 | /**
|
---|
| 125 | * This type of styler is instantiated when the user selects a "fit" row height mode.
|
---|
| 126 | * In other words, the row height will reflect the total height of the container divided
|
---|
| 127 | * by the number of rows. Example `<mat-grid-list cols="3" rowHeight="fit">`
|
---|
| 128 | *
|
---|
| 129 | * @docs-private
|
---|
| 130 | */
|
---|
| 131 | export declare class FitTileStyler extends TileStyler {
|
---|
| 132 | setRowStyles(tile: MatGridTile, rowIndex: number): void;
|
---|
| 133 | reset(list: TileStyleTarget): void;
|
---|
| 134 | }
|
---|