[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 | /**
|
---|
| 9 | * Directions that can be used when setting sticky positioning.
|
---|
| 10 | * @docs-private
|
---|
| 11 | */
|
---|
| 12 | import { Direction } from '@angular/cdk/bidi';
|
---|
| 13 | import { _CoalescedStyleScheduler } from './coalesced-style-scheduler';
|
---|
| 14 | import { StickyPositioningListener } from './sticky-position-listener';
|
---|
| 15 | export declare type StickyDirection = 'top' | 'bottom' | 'left' | 'right';
|
---|
| 16 | /**
|
---|
| 17 | * List of all possible directions that can be used for sticky positioning.
|
---|
| 18 | * @docs-private
|
---|
| 19 | */
|
---|
| 20 | export declare const STICKY_DIRECTIONS: StickyDirection[];
|
---|
| 21 | /**
|
---|
| 22 | * Applies and removes sticky positioning styles to the `CdkTable` rows and columns cells.
|
---|
| 23 | * @docs-private
|
---|
| 24 | */
|
---|
| 25 | export declare class StickyStyler {
|
---|
| 26 | private _isNativeHtmlTable;
|
---|
| 27 | private _stickCellCss;
|
---|
| 28 | direction: Direction;
|
---|
| 29 | private _coalescedStyleScheduler;
|
---|
| 30 | private _isBrowser;
|
---|
| 31 | private readonly _needsPositionStickyOnElement;
|
---|
| 32 | private readonly _positionListener?;
|
---|
| 33 | private _cachedCellWidths;
|
---|
| 34 | private readonly _borderCellCss;
|
---|
| 35 | /**
|
---|
| 36 | * @param _isNativeHtmlTable Whether the sticky logic should be based on a table
|
---|
| 37 | * that uses the native `<table>` element.
|
---|
| 38 | * @param _stickCellCss The CSS class that will be applied to every row/cell that has
|
---|
| 39 | * sticky positioning applied.
|
---|
| 40 | * @param direction The directionality context of the table (ltr/rtl); affects column positioning
|
---|
| 41 | * by reversing left/right positions.
|
---|
| 42 | * @param _isBrowser Whether the table is currently being rendered on the server or the client.
|
---|
| 43 | * @param _needsPositionStickyOnElement Whether we need to specify position: sticky on cells
|
---|
| 44 | * using inline styles. If false, it is assumed that position: sticky is included in
|
---|
| 45 | * the component stylesheet for _stickCellCss.
|
---|
| 46 | * @param _positionListener A listener that is notified of changes to sticky rows/columns
|
---|
| 47 | * and their dimensions.
|
---|
| 48 | */
|
---|
| 49 | constructor(_isNativeHtmlTable: boolean, _stickCellCss: string, direction: Direction, _coalescedStyleScheduler: _CoalescedStyleScheduler, _isBrowser?: boolean, _needsPositionStickyOnElement?: boolean, _positionListener?: StickyPositioningListener | undefined);
|
---|
| 50 | /**
|
---|
| 51 | * Clears the sticky positioning styles from the row and its cells by resetting the `position`
|
---|
| 52 | * style, setting the zIndex to 0, and unsetting each provided sticky direction.
|
---|
| 53 | * @param rows The list of rows that should be cleared from sticking in the provided directions
|
---|
| 54 | * @param stickyDirections The directions that should no longer be set as sticky on the rows.
|
---|
| 55 | */
|
---|
| 56 | clearStickyPositioning(rows: HTMLElement[], stickyDirections: StickyDirection[]): void;
|
---|
| 57 | /**
|
---|
| 58 | * Applies sticky left and right positions to the cells of each row according to the sticky
|
---|
| 59 | * states of the rendered column definitions.
|
---|
| 60 | * @param rows The rows that should have its set of cells stuck according to the sticky states.
|
---|
| 61 | * @param stickyStartStates A list of boolean states where each state represents whether the cell
|
---|
| 62 | * in this index position should be stuck to the start of the row.
|
---|
| 63 | * @param stickyEndStates A list of boolean states where each state represents whether the cell
|
---|
| 64 | * in this index position should be stuck to the end of the row.
|
---|
| 65 | * @param recalculateCellWidths Whether the sticky styler should recalculate the width of each
|
---|
| 66 | * column cell. If `false` cached widths will be used instead.
|
---|
| 67 | */
|
---|
| 68 | updateStickyColumns(rows: HTMLElement[], stickyStartStates: boolean[], stickyEndStates: boolean[], recalculateCellWidths?: boolean): void;
|
---|
| 69 | /**
|
---|
| 70 | * Applies sticky positioning to the row's cells if using the native table layout, and to the
|
---|
| 71 | * row itself otherwise.
|
---|
| 72 | * @param rowsToStick The list of rows that should be stuck according to their corresponding
|
---|
| 73 | * sticky state and to the provided top or bottom position.
|
---|
| 74 | * @param stickyStates A list of boolean states where each state represents whether the row
|
---|
| 75 | * should be stuck in the particular top or bottom position.
|
---|
| 76 | * @param position The position direction in which the row should be stuck if that row should be
|
---|
| 77 | * sticky.
|
---|
| 78 | *
|
---|
| 79 | */
|
---|
| 80 | stickRows(rowsToStick: HTMLElement[], stickyStates: boolean[], position: 'top' | 'bottom'): void;
|
---|
| 81 | /**
|
---|
| 82 | * When using the native table in Safari, sticky footer cells do not stick. The only way to stick
|
---|
| 83 | * footer rows is to apply sticky styling to the tfoot container. This should only be done if
|
---|
| 84 | * all footer rows are sticky. If not all footer rows are sticky, remove sticky positioning from
|
---|
| 85 | * the tfoot element.
|
---|
| 86 | */
|
---|
| 87 | updateStickyFooterContainer(tableElement: Element, stickyStates: boolean[]): void;
|
---|
| 88 | /**
|
---|
| 89 | * Removes the sticky style on the element by removing the sticky cell CSS class, re-evaluating
|
---|
| 90 | * the zIndex, removing each of the provided sticky directions, and removing the
|
---|
| 91 | * sticky position if there are no more directions.
|
---|
| 92 | */
|
---|
| 93 | _removeStickyStyle(element: HTMLElement, stickyDirections: StickyDirection[]): void;
|
---|
| 94 | /**
|
---|
| 95 | * Adds the sticky styling to the element by adding the sticky style class, changing position
|
---|
| 96 | * to be sticky (and -webkit-sticky), setting the appropriate zIndex, and adding a sticky
|
---|
| 97 | * direction and value.
|
---|
| 98 | */
|
---|
| 99 | _addStickyStyle(element: HTMLElement, dir: StickyDirection, dirValue: number, isBorderElement: boolean): void;
|
---|
| 100 | /**
|
---|
| 101 | * Calculate what the z-index should be for the element, depending on what directions (top,
|
---|
| 102 | * bottom, left, right) have been set. It should be true that elements with a top direction
|
---|
| 103 | * should have the highest index since these are elements like a table header. If any of those
|
---|
| 104 | * elements are also sticky in another direction, then they should appear above other elements
|
---|
| 105 | * that are only sticky top (e.g. a sticky column on a sticky header). Bottom-sticky elements
|
---|
| 106 | * (e.g. footer rows) should then be next in the ordering such that they are below the header
|
---|
| 107 | * but above any non-sticky elements. Finally, left/right sticky elements (e.g. sticky columns)
|
---|
| 108 | * should minimally increment so that they are above non-sticky elements but below top and bottom
|
---|
| 109 | * elements.
|
---|
| 110 | */
|
---|
| 111 | _getCalculatedZIndex(element: HTMLElement): string;
|
---|
| 112 | /** Gets the widths for each cell in the provided row. */
|
---|
| 113 | _getCellWidths(row: HTMLElement, recalculateCellWidths?: boolean): number[];
|
---|
| 114 | /**
|
---|
| 115 | * Determines the left and right positions of each sticky column cell, which will be the
|
---|
| 116 | * accumulation of all sticky column cell widths to the left and right, respectively.
|
---|
| 117 | * Non-sticky cells do not need to have a value set since their positions will not be applied.
|
---|
| 118 | */
|
---|
| 119 | _getStickyStartColumnPositions(widths: number[], stickyStates: boolean[]): number[];
|
---|
| 120 | /**
|
---|
| 121 | * Determines the left and right positions of each sticky column cell, which will be the
|
---|
| 122 | * accumulation of all sticky column cell widths to the left and right, respectively.
|
---|
| 123 | * Non-sticky cells do not need to have a value set since their positions will not be applied.
|
---|
| 124 | */
|
---|
| 125 | _getStickyEndColumnPositions(widths: number[], stickyStates: boolean[]): number[];
|
---|
| 126 | }
|
---|