license import { Directionality } from '@angular/cdk/bidi' ; import { Overlay , OverlaySizeConfig , PositionStrategy } from '@angular/cdk/overlay' ; import { Injectable } from '@angular/core' ; /**
 * Overridable factory responsible for configuring how cdkPopoverEdit popovers are positioned
 * and sized.
 */ @ Injectable ( ) export abstract class PopoverEditPositionStrategyFactory { /**
     * Creates a PositionStrategy based on the specified table cells.
     * The cells will be provided in DOM order.
     */ abstract positionStrategyForCells ( cells ) ; /**
     * Creates an OverlaySizeConfig based on the specified table cells.
     * The cells will be provided in DOM order.
     */ abstract sizeConfigForCells ( cells ) ; } /**
 * Default implementation of PopoverEditPositionStrategyFactory.
 * Uses a FlexibleConnectedPositionStrategy anchored to the start + top of the cell.
 * Note: This will change to CoverPositionStrategy once it implemented.
 */ @ Injectable ( ) export class DefaultPopoverEditPositionStrategyFactory extends PopoverEditPositionStrategyFactory { constructor ( protected readonly direction , protected readonly overlay ) { super ( ) ; } positionStrategyForCells ( cells ) { return this . overlay . position ( ) . flexibleConnectedTo ( cells [ 0 ] ) . withGrowAfterOpen ( ) . withPush ( ) . withViewportMargin ( 16 ) . withPositions ( [ { originX : 'start' , originY : 'top' , overlayX : 'start' , overlayY : 'top' , } , ] ) ; } sizeConfigForCells ( cells ) { if ( cells . length === 0 ) { return { } ; } if ( cells . length === 1 ) { return { width : cells [ 0 ] . getBoundingClientRect ( ) . width } ; } let firstCell , lastCell ; if ( this . direction . value === 'ltr' ) { firstCell = cells [ 0 ] ; lastCell = cells [ cells . length - 1 ] ; } else { lastCell = cells [ 0 ] ; firstCell = cells [ cells . length - 1 ] ; } return { width : lastCell . getBoundingClientRect ( ) . right - firstCell . getBoundingClientRect ( ) . left } ; } }