6
6
* found in the LICENSE file at https://angular.dev/license
7
7
*/
8
8
9
- import { AfterViewInit , Directive , ElementRef , NgZone , OnDestroy } from '@angular/core' ;
9
+ import { AfterViewInit , Directive , ElementRef , inject , NgZone , OnDestroy } from '@angular/core' ;
10
+ import { _IdGenerator } from '@angular/cdk/a11y' ;
10
11
import { fromEvent , merge , Subject } from 'rxjs' ;
11
12
import { filter , map , mapTo , pairwise , startWith , take , takeUntil } from 'rxjs/operators' ;
12
13
@@ -19,14 +20,13 @@ import {HeaderRowEventDispatcher} from './event-dispatcher';
19
20
const HOVER_OR_ACTIVE_CLASS = 'cdk-column-resize-hover-or-active' ;
20
21
const WITH_RESIZED_COLUMN_CLASS = 'cdk-column-resize-with-resized-column' ;
21
22
22
- let nextId = 0 ;
23
-
24
23
/**
25
24
* Base class for ColumnResize directives which attach to mat-table elements to
26
25
* provide common events and services for column resizing.
27
26
*/
28
27
@Directive ( )
29
28
export abstract class ColumnResize implements AfterViewInit , OnDestroy {
29
+ private _idGenerator = inject ( _IdGenerator ) ;
30
30
protected readonly destroyed = new Subject < void > ( ) ;
31
31
32
32
/* Publicly accessible interface for triggering and being notified of resizes. */
@@ -40,7 +40,7 @@ export abstract class ColumnResize implements AfterViewInit, OnDestroy {
40
40
protected abstract readonly notifier : ColumnResizeNotifierSource ;
41
41
42
42
/** Unique ID for this table instance. */
43
- protected readonly selectorId = ` ${ ++ nextId } ` ;
43
+ protected readonly selectorId = this . _idGenerator . getId ( 'cdk-column-resize-' ) ;
44
44
45
45
/** The id attribute of the table, if specified. */
46
46
id ?: string ;
@@ -60,7 +60,7 @@ export abstract class ColumnResize implements AfterViewInit, OnDestroy {
60
60
61
61
/** Gets the unique CSS class name for this table instance. */
62
62
getUniqueCssClass ( ) {
63
- return `cdk-column-resize- ${ this . selectorId } ` ;
63
+ return this . selectorId ;
64
64
}
65
65
66
66
/** Called when a column in the table is resized. Applies a css class to the table element. */
0 commit comments