6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
8
import { FocusTrap } from '@angular/cdk/a11y' ;
9
- import { OverlayRef , PositionStrategy } from '@angular/cdk/overlay' ;
9
+ import { OverlayRef , OverlaySizeConfig , PositionStrategy } from '@angular/cdk/overlay' ;
10
10
import { TemplatePortal } from '@angular/cdk/portal' ;
11
11
import {
12
12
AfterViewInit ,
@@ -63,6 +63,7 @@ const MOUSE_MOVE_THROTTLE_TIME_MS = 10;
63
63
@Directive ( {
64
64
selector : 'table[editable], cdk-table[editable], mat-table[editable]' ,
65
65
providers : [ EditEventDispatcher , EditServices ] ,
66
+ standalone : true ,
66
67
} )
67
68
export class CdkEditable implements AfterViewInit , OnDestroy {
68
69
protected readonly destroyed = new Subject < void > ( ) ;
@@ -175,6 +176,7 @@ const POPOVER_EDIT_INPUTS = [
175
176
selector : '[cdkPopoverEdit]:not([cdkPopoverEditTabOut])' ,
176
177
host : POPOVER_EDIT_HOST_BINDINGS ,
177
178
inputs : POPOVER_EDIT_INPUTS ,
179
+ standalone : true ,
178
180
} )
179
181
export class CdkPopoverEdit < C > implements AfterViewInit , OnDestroy {
180
182
/** The edit lens template shown over the cell on edit. */
@@ -337,20 +339,53 @@ export class CdkPopoverEdit<C> implements AfterViewInit, OnDestroy {
337
339
}
338
340
339
341
private _getPositionStrategy ( ) : PositionStrategy {
340
- return this . services . positionFactory . positionStrategyForCells ( this . _getOverlayCells ( ) ) ;
342
+ const cells = this . _getOverlayCells ( ) ;
343
+ return this . services . overlay
344
+ . position ( )
345
+ . flexibleConnectedTo ( cells [ 0 ] )
346
+ . withGrowAfterOpen ( )
347
+ . withPush ( )
348
+ . withViewportMargin ( 16 )
349
+ . withPositions ( [
350
+ {
351
+ originX : 'start' ,
352
+ originY : 'top' ,
353
+ overlayX : 'start' ,
354
+ overlayY : 'top' ,
355
+ } ,
356
+ ] ) ;
341
357
}
342
358
343
359
private _updateOverlaySize ( ) : void {
344
- this . overlayRef ! . updateSize (
345
- this . services . positionFactory . sizeConfigForCells ( this . _getOverlayCells ( ) ) ,
346
- ) ;
360
+ this . overlayRef ! . updateSize ( this . _sizeConfigForCells ( this . _getOverlayCells ( ) ) ) ;
347
361
}
348
362
349
363
private _maybeReturnFocusToCell ( ) : void {
350
364
if ( closest ( document . activeElement , EDIT_PANE_SELECTOR ) === this . overlayRef ! . overlayElement ) {
351
365
this . elementRef . nativeElement ! . focus ( ) ;
352
366
}
353
367
}
368
+
369
+ private _sizeConfigForCells ( cells : HTMLElement [ ] ) : OverlaySizeConfig {
370
+ if ( cells . length === 0 ) {
371
+ return { } ;
372
+ }
373
+
374
+ if ( cells . length === 1 ) {
375
+ return { width : cells [ 0 ] . getBoundingClientRect ( ) . width } ;
376
+ }
377
+
378
+ let firstCell , lastCell ;
379
+ if ( this . services . directionality . value === 'ltr' ) {
380
+ firstCell = cells [ 0 ] ;
381
+ lastCell = cells [ cells . length - 1 ] ;
382
+ } else {
383
+ lastCell = cells [ 0 ] ;
384
+ firstCell = cells [ cells . length - 1 ] ;
385
+ }
386
+
387
+ return { width : lastCell . getBoundingClientRect ( ) . right - firstCell . getBoundingClientRect ( ) . left } ;
388
+ }
354
389
}
355
390
356
391
/**
@@ -362,6 +397,7 @@ export class CdkPopoverEdit<C> implements AfterViewInit, OnDestroy {
362
397
selector : '[cdkPopoverEdit][cdkPopoverEditTabOut]' ,
363
398
host : POPOVER_EDIT_HOST_BINDINGS ,
364
399
inputs : POPOVER_EDIT_INPUTS ,
400
+ standalone : true ,
365
401
} )
366
402
export class CdkPopoverEditTabOut < C > extends CdkPopoverEdit < C > {
367
403
protected override focusTrap ?: FocusEscapeNotifier = undefined ;
@@ -399,6 +435,7 @@ export class CdkPopoverEditTabOut<C> extends CdkPopoverEdit<C> {
399
435
*/
400
436
@Directive ( {
401
437
selector : '[cdkRowHoverContent]' ,
438
+ standalone : true ,
402
439
} )
403
440
export class CdkRowHoverContent implements AfterViewInit , OnDestroy {
404
441
protected readonly destroyed = new Subject < void > ( ) ;
@@ -495,6 +532,7 @@ export class CdkRowHoverContent implements AfterViewInit, OnDestroy {
495
532
host : {
496
533
'(click)' : 'openEdit($event)' ,
497
534
} ,
535
+ standalone : true ,
498
536
} )
499
537
export class CdkEditOpen {
500
538
constructor (
0 commit comments