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
+
1
9
import { AfterViewInit , Directive , ElementRef , NgZone , OnDestroy } from '@angular/core' ;
2
10
import { Directionality } from '@angular/cdk/bidi' ;
3
11
import { fromEvent , merge , ReplaySubject } from 'rxjs' ;
4
12
import { filter , map , mapTo , pairwise , startWith , take , takeUntil } from 'rxjs/operators' ;
5
13
6
- import { matches } from '../popover-edit/polyfill' ;
14
+ import { closest , matches } from '../popover-edit/polyfill' ;
7
15
8
- import { ColumnResizeNotifier , _ColumnResizeNotifierSource } from './column-resize-notifier' ;
16
+ import { ColumnResizeNotifier , ColumnResizeNotifierSource } from './column-resize-notifier' ;
9
17
import { HEADER_CELL_SELECTOR , RESIZE_OVERLAY_SELECTOR } from './constants' ;
10
- import { _HeaderRowEventDispatcher } from './event-dispatcher' ;
18
+ import { HeaderRowEventDispatcher } from './event-dispatcher' ;
11
19
import {
12
20
TABLE_LAYOUT_FIXED_RESIZE_STRATEGY_PROVIDER ,
13
21
FLEX_RESIZE_STRATEGY_PROVIDER ,
14
22
} from './resize-strategy' ;
15
23
16
- import { closest } from '../popover-edit/polyfill' ;
17
-
18
- const PROVIDERS = [ ColumnResizeNotifier , _HeaderRowEventDispatcher , _ColumnResizeNotifierSource ] ;
24
+ const PROVIDERS = [ ColumnResizeNotifier , HeaderRowEventDispatcher , ColumnResizeNotifierSource ] ;
19
25
const TABLE_PROVIDERS = [ ...PROVIDERS , TABLE_LAYOUT_FIXED_RESIZE_STRATEGY_PROVIDER ] ;
20
26
const FLEX_PROVIDERS = [ ...PROVIDERS , FLEX_RESIZE_STRATEGY_PROVIDER ] ;
21
27
const HOST_BINDINGS = {
@@ -27,13 +33,13 @@ let idSequence = 0;
27
33
28
34
export abstract class ColumnResize implements AfterViewInit , OnDestroy {
29
35
protected readonly destroyed = new ReplaySubject < void > ( ) ;
30
-
36
+
31
37
abstract readonly directionality : Directionality ;
32
38
protected abstract readonly elementRef : ElementRef ;
33
- protected abstract readonly eventDispatcher : _HeaderRowEventDispatcher ;
39
+ protected abstract readonly eventDispatcher : HeaderRowEventDispatcher ;
34
40
protected abstract readonly ngZone : NgZone ;
35
- protected abstract readonly notifier : _ColumnResizeNotifierSource ;
36
-
41
+ protected abstract readonly notifier : ColumnResizeNotifierSource ;
42
+
37
43
private _specifiedId ?: string ;
38
44
private _generatedId ?: string ;
39
45
@@ -49,37 +55,38 @@ export abstract class ColumnResize implements AfterViewInit, OnDestroy {
49
55
set id ( value : string ) {
50
56
this . _specifiedId = value ;
51
57
}
52
-
58
+
53
59
ngAfterViewInit ( ) {
54
60
this . _listenForRowHoverEvents ( ) ;
55
61
this . _listenForResizeActivity ( ) ;
56
62
this . _listenForHoverActivity ( ) ;
57
63
}
58
-
64
+
59
65
ngOnDestroy ( ) {
60
66
this . destroyed . next ( ) ;
61
67
this . destroyed . complete ( ) ;
62
68
}
63
-
69
+
64
70
getIdClass ( ) {
65
71
return `column-resize-${ this . id } ` ;
66
72
}
67
-
73
+
68
74
getWithResizedColumnClass ( ) {
69
75
return 'with-resized-column' ;
70
76
}
71
-
77
+
72
78
private _listenForRowHoverEvents ( ) {
73
79
this . ngZone . runOutsideAngular ( ( ) => {
74
80
const element = this . elementRef . nativeElement ! ;
75
-
81
+
76
82
fromEvent < MouseEvent > ( element , 'mouseover' ) . pipe (
77
83
takeUntil ( this . destroyed ) ,
78
84
map ( event => closest ( event . target , HEADER_CELL_SELECTOR ) ) ,
79
85
) . subscribe ( this . eventDispatcher . headerCellHovered ) ;
80
86
fromEvent < MouseEvent > ( element , 'mouseleave' ) . pipe (
81
87
takeUntil ( this . destroyed ) ,
82
- filter ( event => ! ! event . relatedTarget && ! matches ( event . relatedTarget as Element , RESIZE_OVERLAY_SELECTOR ) ) ,
88
+ filter ( event => ! ! event . relatedTarget &&
89
+ ! matches ( event . relatedTarget as Element , RESIZE_OVERLAY_SELECTOR ) ) ,
83
90
mapTo ( null ) ,
84
91
) . subscribe ( this . eventDispatcher . headerCellHovered ) ;
85
92
} ) ;
@@ -97,7 +104,7 @@ export abstract class ColumnResize implements AfterViewInit, OnDestroy {
97
104
this . elementRef . nativeElement ! . classList . add ( this . getWithResizedColumnClass ( ) ) ;
98
105
} ) ;
99
106
}
100
-
107
+
101
108
private _listenForHoverActivity ( ) {
102
109
this . eventDispatcher . headerRowHoveredOrActiveDistinct . pipe (
103
110
takeUntil ( this . destroyed ) ,
@@ -126,9 +133,9 @@ export class CdkDefaultEnabledColumnResize extends ColumnResize {
126
133
constructor (
127
134
readonly directionality : Directionality ,
128
135
protected readonly elementRef : ElementRef ,
129
- protected readonly eventDispatcher : _HeaderRowEventDispatcher ,
136
+ protected readonly eventDispatcher : HeaderRowEventDispatcher ,
130
137
protected readonly ngZone : NgZone ,
131
- protected readonly notifier : _ColumnResizeNotifierSource ) {
138
+ protected readonly notifier : ColumnResizeNotifierSource ) {
132
139
super ( ) ;
133
140
}
134
141
}
@@ -145,9 +152,9 @@ export class CdkDefaultEnabledColumnResizeFlex extends ColumnResize {
145
152
constructor (
146
153
readonly directionality : Directionality ,
147
154
protected readonly elementRef : ElementRef ,
148
- protected readonly eventDispatcher : _HeaderRowEventDispatcher ,
155
+ protected readonly eventDispatcher : HeaderRowEventDispatcher ,
149
156
protected readonly ngZone : NgZone ,
150
- protected readonly notifier : _ColumnResizeNotifierSource ) {
157
+ protected readonly notifier : ColumnResizeNotifierSource ) {
151
158
super ( ) ;
152
159
}
153
160
}
@@ -164,9 +171,9 @@ export class CdkColumnResize extends ColumnResize {
164
171
constructor (
165
172
readonly directionality : Directionality ,
166
173
protected readonly elementRef : ElementRef ,
167
- protected readonly eventDispatcher : _HeaderRowEventDispatcher ,
174
+ protected readonly eventDispatcher : HeaderRowEventDispatcher ,
168
175
protected readonly ngZone : NgZone ,
169
- protected readonly notifier : _ColumnResizeNotifierSource ) {
176
+ protected readonly notifier : ColumnResizeNotifierSource ) {
170
177
super ( ) ;
171
178
}
172
179
}
@@ -183,9 +190,9 @@ export class CdkColumnResizeFlex extends ColumnResize {
183
190
constructor (
184
191
readonly directionality : Directionality ,
185
192
protected readonly elementRef : ElementRef ,
186
- protected readonly eventDispatcher : _HeaderRowEventDispatcher ,
193
+ protected readonly eventDispatcher : HeaderRowEventDispatcher ,
187
194
protected readonly ngZone : NgZone ,
188
- protected readonly notifier : _ColumnResizeNotifierSource ) {
195
+ protected readonly notifier : ColumnResizeNotifierSource ) {
189
196
super ( ) ;
190
197
}
191
198
}
0 commit comments