Skip to content

Commit 5fe6291

Browse files
committed
review pt 2
1 parent c9e88e2 commit 5fe6291

File tree

9 files changed

+220
-181
lines changed

9 files changed

+220
-181
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import {Directive, ElementRef, NgZone} from '@angular/core';
2+
import {Directionality} from '@angular/cdk/bidi';
3+
4+
import {ColumnResize} from '../column-resize';
5+
import {ColumnResizeNotifierSource} from '../column-resize-notifier';
6+
import {HeaderRowEventDispatcher} from '../event-dispatcher';
7+
import {HOST_BINDINGS, FLEX_PROVIDERS} from './constants';
8+
9+
@Directive({
10+
selector: 'cdk-table[columnResize]',
11+
host: HOST_BINDINGS,
12+
providers: [
13+
...FLEX_PROVIDERS,
14+
{provide: ColumnResize, useExisting: CdkColumnResizeFlex},
15+
],
16+
})
17+
export class CdkColumnResizeFlex extends ColumnResize {
18+
constructor(
19+
readonly directionality: Directionality,
20+
protected readonly elementRef: ElementRef,
21+
protected readonly eventDispatcher: HeaderRowEventDispatcher,
22+
protected readonly ngZone: NgZone,
23+
protected readonly notifier: ColumnResizeNotifierSource) {
24+
super();
25+
}
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import {Directive, ElementRef, NgZone} from '@angular/core';
2+
import {Directionality} from '@angular/cdk/bidi';
3+
4+
import {ColumnResize} from '../column-resize';
5+
import {ColumnResizeNotifierSource} from '../column-resize-notifier';
6+
import {HeaderRowEventDispatcher} from '../event-dispatcher';
7+
import {HOST_BINDINGS, TABLE_PROVIDERS} from './constants';
8+
9+
@Directive({
10+
selector: 'table[cdk-table][columnResize]',
11+
host: HOST_BINDINGS,
12+
providers: [
13+
...TABLE_PROVIDERS,
14+
{provide: ColumnResize, useExisting: CdkColumnResize},
15+
],
16+
})
17+
export class CdkColumnResize extends ColumnResize {
18+
constructor(
19+
readonly directionality: Directionality,
20+
protected readonly elementRef: ElementRef,
21+
protected readonly eventDispatcher: HeaderRowEventDispatcher,
22+
protected readonly ngZone: NgZone,
23+
protected readonly notifier: ColumnResizeNotifierSource) {
24+
super();
25+
}
26+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import {ColumnResizeNotifier, ColumnResizeNotifierSource} from '../column-resize-notifier';
2+
import {HeaderRowEventDispatcher} from '../event-dispatcher';
3+
import {
4+
TABLE_LAYOUT_FIXED_RESIZE_STRATEGY_PROVIDER,
5+
FLEX_RESIZE_STRATEGY_PROVIDER,
6+
} from '../resize-strategy';
7+
8+
const PROVIDERS = [ColumnResizeNotifier, HeaderRowEventDispatcher, ColumnResizeNotifierSource];
9+
10+
export const TABLE_PROVIDERS = [...PROVIDERS, TABLE_LAYOUT_FIXED_RESIZE_STRATEGY_PROVIDER];
11+
export const FLEX_PROVIDERS = [...PROVIDERS, FLEX_RESIZE_STRATEGY_PROVIDER];
12+
export const HOST_BINDINGS = {
13+
'[class.cdk-column-resize-rtl]': 'directionality.value === "rtl"',
14+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import {Directive, ElementRef, NgZone} from '@angular/core';
2+
import {Directionality} from '@angular/cdk/bidi';
3+
4+
import {ColumnResize} from '../column-resize';
5+
import {ColumnResizeNotifierSource} from '../column-resize-notifier';
6+
import {HeaderRowEventDispatcher} from '../event-dispatcher';
7+
import {HOST_BINDINGS, FLEX_PROVIDERS} from './constants';
8+
9+
@Directive({
10+
selector: 'cdk-table',
11+
host: HOST_BINDINGS,
12+
providers: [
13+
...FLEX_PROVIDERS,
14+
{provide: ColumnResize, useExisting: CdkDefaultEnabledColumnResizeFlex},
15+
],
16+
})
17+
export class CdkDefaultEnabledColumnResizeFlex extends ColumnResize {
18+
constructor(
19+
readonly directionality: Directionality,
20+
protected readonly elementRef: ElementRef,
21+
protected readonly eventDispatcher: HeaderRowEventDispatcher,
22+
protected readonly ngZone: NgZone,
23+
protected readonly notifier: ColumnResizeNotifierSource) {
24+
super();
25+
}
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import {Directive, ElementRef, NgZone} from '@angular/core';
2+
import {Directionality} from '@angular/cdk/bidi';
3+
4+
import {ColumnResize} from '../column-resize';
5+
import {ColumnResizeNotifierSource} from '../column-resize-notifier';
6+
import {HeaderRowEventDispatcher} from '../event-dispatcher';
7+
import {HOST_BINDINGS, TABLE_PROVIDERS} from './constants';
8+
9+
@Directive({
10+
selector: 'table[cdk-table]',
11+
host: HOST_BINDINGS,
12+
providers: [
13+
...TABLE_PROVIDERS,
14+
{provide: ColumnResize, useExisting: CdkDefaultEnabledColumnResize},
15+
],
16+
})
17+
export class CdkDefaultEnabledColumnResize extends ColumnResize {
18+
constructor(
19+
readonly directionality: Directionality,
20+
protected readonly elementRef: ElementRef,
21+
protected readonly eventDispatcher: HeaderRowEventDispatcher,
22+
protected readonly ngZone: NgZone,
23+
protected readonly notifier: ColumnResizeNotifierSource) {
24+
super();
25+
}
26+
}

src/cdk-experimental/column-resize/column-resize-module.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88

99
import {NgModule} from '@angular/core';
1010

11-
import {
12-
CdkColumnResize,
13-
CdkColumnResizeFlex,
14-
CdkDefaultEnabledColumnResize,
15-
CdkDefaultEnabledColumnResizeFlex,
16-
} from './column-resize';
11+
import {CdkColumnResize} from './column-resize-directives/column-resize';
12+
import {CdkColumnResizeFlex} from './column-resize-directives/column-resize-flex';
13+
import {CdkDefaultEnabledColumnResize} from './column-resize-directives/default-enabled-column-resize';
14+
import {CdkDefaultEnabledColumnResizeFlex} from './column-resize-directives/default-enabled-column-resize-flex';
1715

1816
@NgModule({
1917
declarations: [CdkDefaultEnabledColumnResize, CdkDefaultEnabledColumnResizeFlex],

src/cdk-experimental/column-resize/column-resize.ts

Lines changed: 5 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,19 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {AfterViewInit, Directive, ElementRef, NgZone, OnDestroy} from '@angular/core';
9+
import {AfterViewInit, ElementRef, NgZone, OnDestroy} from '@angular/core';
1010
import {Directionality} from '@angular/cdk/bidi';
1111
import {fromEvent, merge, ReplaySubject} from 'rxjs';
1212
import {filter, map, mapTo, pairwise, startWith, take, takeUntil} from 'rxjs/operators';
1313

1414
import {closest, matches} from '../popover-edit/polyfill';
1515

16-
import {ColumnResizeNotifier, ColumnResizeNotifierSource} from './column-resize-notifier';
16+
import {ColumnResizeNotifierSource} from './column-resize-notifier';
1717
import {HEADER_CELL_SELECTOR, RESIZE_OVERLAY_SELECTOR} from './constants';
1818
import {HeaderRowEventDispatcher} from './event-dispatcher';
19-
import {
20-
TABLE_LAYOUT_FIXED_RESIZE_STRATEGY_PROVIDER,
21-
FLEX_RESIZE_STRATEGY_PROVIDER,
22-
} from './resize-strategy';
23-
24-
const PROVIDERS = [ColumnResizeNotifier, HeaderRowEventDispatcher, ColumnResizeNotifierSource];
25-
const TABLE_PROVIDERS = [...PROVIDERS, TABLE_LAYOUT_FIXED_RESIZE_STRATEGY_PROVIDER];
26-
const FLEX_PROVIDERS = [...PROVIDERS, FLEX_RESIZE_STRATEGY_PROVIDER];
27-
const HOST_BINDINGS = {
28-
'[class.cdk-column-resize-rtl]': 'directionality.value === "rtl"',
29-
};
19+
20+
const HOVER_OR_ACTIVE_CLASS = 'cdk-column-resize-hover-or-active';
21+
const WITH_RESIZED_COLUMN_CLASS = 'cdk-column-resize-with-resized-column';
3022

3123
let nextId = 0;
3224

@@ -105,82 +97,3 @@ export abstract class ColumnResize implements AfterViewInit, OnDestroy {
10597
});
10698
}
10799
}
108-
109-
@Directive({
110-
selector: 'table[cdk-table]',
111-
host: HOST_BINDINGS,
112-
providers: [
113-
...TABLE_PROVIDERS,
114-
{provide: ColumnResize, useExisting: CdkDefaultEnabledColumnResize},
115-
],
116-
})
117-
export class CdkDefaultEnabledColumnResize extends ColumnResize {
118-
constructor(
119-
readonly directionality: Directionality,
120-
protected readonly elementRef: ElementRef,
121-
protected readonly eventDispatcher: HeaderRowEventDispatcher,
122-
protected readonly ngZone: NgZone,
123-
protected readonly notifier: ColumnResizeNotifierSource) {
124-
super();
125-
}
126-
}
127-
128-
@Directive({
129-
selector: 'cdk-table',
130-
host: HOST_BINDINGS,
131-
providers: [
132-
...FLEX_PROVIDERS,
133-
{provide: ColumnResize, useExisting: CdkDefaultEnabledColumnResizeFlex},
134-
],
135-
})
136-
export class CdkDefaultEnabledColumnResizeFlex extends ColumnResize {
137-
constructor(
138-
readonly directionality: Directionality,
139-
protected readonly elementRef: ElementRef,
140-
protected readonly eventDispatcher: HeaderRowEventDispatcher,
141-
protected readonly ngZone: NgZone,
142-
protected readonly notifier: ColumnResizeNotifierSource) {
143-
super();
144-
}
145-
}
146-
147-
@Directive({
148-
selector: 'table[cdk-table][columnResize]',
149-
host: HOST_BINDINGS,
150-
providers: [
151-
...TABLE_PROVIDERS,
152-
{provide: ColumnResize, useExisting: CdkColumnResize},
153-
],
154-
})
155-
export class CdkColumnResize extends ColumnResize {
156-
constructor(
157-
readonly directionality: Directionality,
158-
protected readonly elementRef: ElementRef,
159-
protected readonly eventDispatcher: HeaderRowEventDispatcher,
160-
protected readonly ngZone: NgZone,
161-
protected readonly notifier: ColumnResizeNotifierSource) {
162-
super();
163-
}
164-
}
165-
166-
@Directive({
167-
selector: 'cdk-table[columnResize]',
168-
host: HOST_BINDINGS,
169-
providers: [
170-
...FLEX_PROVIDERS,
171-
{provide: ColumnResize, useExisting: CdkColumnResizeFlex},
172-
],
173-
})
174-
export class CdkColumnResizeFlex extends ColumnResize {
175-
constructor(
176-
readonly directionality: Directionality,
177-
protected readonly elementRef: ElementRef,
178-
protected readonly eventDispatcher: HeaderRowEventDispatcher,
179-
protected readonly ngZone: NgZone,
180-
protected readonly notifier: ColumnResizeNotifierSource) {
181-
super();
182-
}
183-
}
184-
185-
const HOVER_OR_ACTIVE_CLASS = 'cdk-column-resize-hover-or-active';
186-
const WITH_RESIZED_COLUMN_CLASS = 'cdk-column-resize-with-resized-column';

0 commit comments

Comments
 (0)