@angular/cdk-experimental 21.0.0-next.8 → 21.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/_polyfill-chunk.mjs +8 -9
- package/fesm2022/_polyfill-chunk.mjs.map +1 -1
- package/fesm2022/cdk-experimental.mjs +1 -2
- package/fesm2022/cdk-experimental.mjs.map +1 -1
- package/fesm2022/column-resize.mjs +1115 -954
- package/fesm2022/column-resize.mjs.map +1 -1
- package/fesm2022/popover-edit.mjs +1125 -1061
- package/fesm2022/popover-edit.mjs.map +1 -1
- package/fesm2022/scrolling.mjs +292 -409
- package/fesm2022/scrolling.mjs.map +1 -1
- package/fesm2022/selection.mjs +698 -535
- package/fesm2022/selection.mjs.map +1 -1
- package/fesm2022/table-scroll-container.mjs +163 -113
- package/fesm2022/table-scroll-container.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -10,8 +10,6 @@ import { ComponentPortal } from '@angular/cdk/portal';
|
|
|
10
10
|
import { createFlexibleConnectedPositionStrategy, createOverlayRef, createRepositionScrollStrategy } from '@angular/cdk/overlay';
|
|
11
11
|
import { ESCAPE } from '@angular/cdk/keycodes';
|
|
12
12
|
|
|
13
|
-
// TODO: Figure out how to remove `mat-` classes from the CDK part of the
|
|
14
|
-
// column resize implementation.
|
|
15
13
|
const HEADER_CELL_SELECTOR = '.cdk-header-cell, .mat-header-cell';
|
|
16
14
|
const HEADER_ROW_SELECTOR = '.cdk-header-row, .mat-header-row';
|
|
17
15
|
const RESIZE_OVERLAY_SELECTOR = '.mat-column-resize-overlay-thumb';
|
|
@@ -19,1028 +17,1191 @@ const RESIZE_OVERLAY_SELECTOR = '.mat-column-resize-overlay-thumb';
|
|
|
19
17
|
const HOVER_OR_ACTIVE_CLASS = 'cdk-column-resize-hover-or-active';
|
|
20
18
|
const WITH_RESIZED_COLUMN_CLASS = 'cdk-column-resize-with-resized-column';
|
|
21
19
|
const COLUMN_RESIZE_OPTIONS = new InjectionToken('CdkColumnResizeOptions');
|
|
22
|
-
/**
|
|
23
|
-
* Base class for ColumnResize directives which attach to mat-table elements to
|
|
24
|
-
* provide common events and services for column resizing.
|
|
25
|
-
*/
|
|
26
20
|
class ColumnResize {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
21
|
+
_renderer = inject(Renderer2);
|
|
22
|
+
_eventCleanups;
|
|
23
|
+
destroyed = new Subject();
|
|
24
|
+
selectorId = inject(_IdGenerator).getId('cdk-column-resize-');
|
|
25
|
+
id;
|
|
26
|
+
_flushPending = false;
|
|
27
|
+
liveResizeUpdates = inject(COLUMN_RESIZE_OPTIONS, {
|
|
28
|
+
optional: true
|
|
29
|
+
})?.liveResizeUpdates ?? true;
|
|
30
|
+
ngAfterViewInit() {
|
|
31
|
+
this.elementRef.nativeElement.classList.add(this.getUniqueCssClass());
|
|
32
|
+
this._listenForRowHoverEvents();
|
|
33
|
+
this._listenForResizeActivity();
|
|
34
|
+
this._listenForHoverActivity();
|
|
35
|
+
}
|
|
36
|
+
ngOnDestroy() {
|
|
37
|
+
this._eventCleanups?.forEach(cleanup => cleanup());
|
|
38
|
+
this.destroyed.next();
|
|
39
|
+
this.destroyed.complete();
|
|
40
|
+
}
|
|
41
|
+
getUniqueCssClass() {
|
|
42
|
+
return this.selectorId;
|
|
43
|
+
}
|
|
44
|
+
getTableId() {
|
|
45
|
+
return String(this.elementRef.nativeElement.id);
|
|
46
|
+
}
|
|
47
|
+
setResized() {
|
|
48
|
+
this.elementRef.nativeElement.classList.add(WITH_RESIZED_COLUMN_CLASS);
|
|
49
|
+
}
|
|
50
|
+
_listenForRowHoverEvents() {
|
|
51
|
+
this.ngZone.runOutsideAngular(() => {
|
|
52
|
+
const element = this.elementRef.nativeElement;
|
|
53
|
+
this._eventCleanups = [this._renderer.listen(element, 'mouseover', event => {
|
|
54
|
+
this.eventDispatcher.headerCellHovered.next(closest(event.target, HEADER_CELL_SELECTOR));
|
|
55
|
+
}), this._renderer.listen(element, 'mouseleave', event => {
|
|
56
|
+
if (event.relatedTarget && !event.relatedTarget.matches(RESIZE_OVERLAY_SELECTOR)) {
|
|
57
|
+
this.eventDispatcher.headerCellHovered.next(null);
|
|
58
|
+
}
|
|
59
|
+
})];
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
_listenForResizeActivity() {
|
|
63
|
+
merge(this.eventDispatcher.overlayHandleActiveForCell.pipe(mapTo(undefined)), this.notifier.triggerResize.pipe(mapTo(undefined)), this.notifier.resizeCompleted.pipe(mapTo(undefined))).pipe(take(1), takeUntil(this.destroyed)).subscribe(() => {
|
|
64
|
+
this.setResized();
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
_listenForHoverActivity() {
|
|
68
|
+
this.eventDispatcher.headerRowHoveredOrActiveDistinct.pipe(startWith(null), pairwise(), takeUntil(this.destroyed)).subscribe(([previousRow, hoveredRow]) => {
|
|
69
|
+
if (hoveredRow) {
|
|
70
|
+
hoveredRow.classList.add(HOVER_OR_ACTIVE_CLASS);
|
|
71
|
+
}
|
|
72
|
+
if (previousRow) {
|
|
73
|
+
previousRow.classList.remove(HOVER_OR_ACTIVE_CLASS);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
78
|
+
minVersion: "12.0.0",
|
|
79
|
+
version: "20.2.0-next.2",
|
|
80
|
+
ngImport: i0,
|
|
81
|
+
type: ColumnResize,
|
|
82
|
+
deps: [],
|
|
83
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
84
|
+
});
|
|
85
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
86
|
+
minVersion: "14.0.0",
|
|
87
|
+
version: "20.2.0-next.2",
|
|
88
|
+
type: ColumnResize,
|
|
89
|
+
isStandalone: true,
|
|
90
|
+
inputs: {
|
|
91
|
+
liveResizeUpdates: "liveResizeUpdates"
|
|
92
|
+
},
|
|
93
|
+
ngImport: i0
|
|
94
|
+
});
|
|
101
95
|
}
|
|
102
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
96
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
97
|
+
minVersion: "12.0.0",
|
|
98
|
+
version: "20.2.0-next.2",
|
|
99
|
+
ngImport: i0,
|
|
100
|
+
type: ColumnResize,
|
|
101
|
+
decorators: [{
|
|
102
|
+
type: Directive
|
|
103
|
+
}],
|
|
104
|
+
propDecorators: {
|
|
105
|
+
liveResizeUpdates: [{
|
|
106
|
+
type: Input
|
|
107
|
+
}]
|
|
108
|
+
}
|
|
109
|
+
});
|
|
107
110
|
|
|
108
|
-
/**
|
|
109
|
-
* Originating source of column resize events within a table.
|
|
110
|
-
* @docs-private
|
|
111
|
-
*/
|
|
112
111
|
class ColumnResizeNotifierSource {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
112
|
+
resizeCanceled = new Subject();
|
|
113
|
+
resizeCompleted = new Subject();
|
|
114
|
+
triggerResize = new Subject();
|
|
115
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
116
|
+
minVersion: "12.0.0",
|
|
117
|
+
version: "20.2.0-next.2",
|
|
118
|
+
ngImport: i0,
|
|
119
|
+
type: ColumnResizeNotifierSource,
|
|
120
|
+
deps: [],
|
|
121
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
122
|
+
});
|
|
123
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
124
|
+
minVersion: "12.0.0",
|
|
125
|
+
version: "20.2.0-next.2",
|
|
126
|
+
ngImport: i0,
|
|
127
|
+
type: ColumnResizeNotifierSource
|
|
128
|
+
});
|
|
121
129
|
}
|
|
122
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
130
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
131
|
+
minVersion: "12.0.0",
|
|
132
|
+
version: "20.2.0-next.2",
|
|
133
|
+
ngImport: i0,
|
|
134
|
+
type: ColumnResizeNotifierSource,
|
|
135
|
+
decorators: [{
|
|
136
|
+
type: Injectable
|
|
137
|
+
}]
|
|
138
|
+
});
|
|
126
139
|
class ColumnResizeNotifier {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
140
|
+
_source = inject(ColumnResizeNotifierSource);
|
|
141
|
+
resizeCompleted = this._source.resizeCompleted;
|
|
142
|
+
resize(columnId, size) {
|
|
143
|
+
this._source.triggerResize.next({
|
|
144
|
+
columnId,
|
|
145
|
+
size,
|
|
146
|
+
completeImmediately: true,
|
|
147
|
+
isStickyColumn: true
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
151
|
+
minVersion: "12.0.0",
|
|
152
|
+
version: "20.2.0-next.2",
|
|
153
|
+
ngImport: i0,
|
|
154
|
+
type: ColumnResizeNotifier,
|
|
155
|
+
deps: [],
|
|
156
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
157
|
+
});
|
|
158
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
159
|
+
minVersion: "12.0.0",
|
|
160
|
+
version: "20.2.0-next.2",
|
|
161
|
+
ngImport: i0,
|
|
162
|
+
type: ColumnResizeNotifier
|
|
163
|
+
});
|
|
141
164
|
}
|
|
142
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
143
|
-
|
|
144
|
-
|
|
165
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
166
|
+
minVersion: "12.0.0",
|
|
167
|
+
version: "20.2.0-next.2",
|
|
168
|
+
ngImport: i0,
|
|
169
|
+
type: ColumnResizeNotifier,
|
|
170
|
+
decorators: [{
|
|
171
|
+
type: Injectable
|
|
172
|
+
}]
|
|
173
|
+
});
|
|
145
174
|
|
|
146
|
-
/** Coordinates events between the column resize directives. */
|
|
147
175
|
class HeaderRowEventDispatcher {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
return this._lastSeenRowHover;
|
|
186
|
-
}
|
|
187
|
-
_enterZone() {
|
|
188
|
-
return (source) => new Observable(observer => source.subscribe({
|
|
189
|
-
next: value => this._ngZone.run(() => observer.next(value)),
|
|
190
|
-
error: err => observer.error(err),
|
|
191
|
-
complete: () => observer.complete(),
|
|
192
|
-
}));
|
|
193
|
-
}
|
|
194
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: HeaderRowEventDispatcher, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
195
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: HeaderRowEventDispatcher });
|
|
176
|
+
_ngZone = inject(NgZone);
|
|
177
|
+
headerCellHovered = new Subject();
|
|
178
|
+
overlayHandleActiveForCell = new Subject();
|
|
179
|
+
headerCellHoveredDistinct = this.headerCellHovered.pipe(distinctUntilChanged(), share());
|
|
180
|
+
headerRowHoveredOrActiveDistinct = combineLatest([this.headerCellHoveredDistinct.pipe(map(cell => closest(cell, HEADER_ROW_SELECTOR)), startWith(null), distinctUntilChanged()), this.overlayHandleActiveForCell.pipe(map(cell => closest(cell, HEADER_ROW_SELECTOR)), startWith(null), distinctUntilChanged())]).pipe(skip(1), map(([hovered, active]) => active || hovered), distinctUntilChanged(), share());
|
|
181
|
+
_headerRowHoveredOrActiveDistinctReenterZone = this.headerRowHoveredOrActiveDistinct.pipe(this._enterZone(), share());
|
|
182
|
+
_lastSeenRow = null;
|
|
183
|
+
_lastSeenRowHover = null;
|
|
184
|
+
resizeOverlayVisibleForHeaderRow(row) {
|
|
185
|
+
if (row !== this._lastSeenRow) {
|
|
186
|
+
this._lastSeenRow = row;
|
|
187
|
+
this._lastSeenRowHover = this._headerRowHoveredOrActiveDistinctReenterZone.pipe(map(hoveredRow => hoveredRow === row), distinctUntilChanged(), share());
|
|
188
|
+
}
|
|
189
|
+
return this._lastSeenRowHover;
|
|
190
|
+
}
|
|
191
|
+
_enterZone() {
|
|
192
|
+
return source => new Observable(observer => source.subscribe({
|
|
193
|
+
next: value => this._ngZone.run(() => observer.next(value)),
|
|
194
|
+
error: err => observer.error(err),
|
|
195
|
+
complete: () => observer.complete()
|
|
196
|
+
}));
|
|
197
|
+
}
|
|
198
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
199
|
+
minVersion: "12.0.0",
|
|
200
|
+
version: "20.2.0-next.2",
|
|
201
|
+
ngImport: i0,
|
|
202
|
+
type: HeaderRowEventDispatcher,
|
|
203
|
+
deps: [],
|
|
204
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
205
|
+
});
|
|
206
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
207
|
+
minVersion: "12.0.0",
|
|
208
|
+
version: "20.2.0-next.2",
|
|
209
|
+
ngImport: i0,
|
|
210
|
+
type: HeaderRowEventDispatcher
|
|
211
|
+
});
|
|
196
212
|
}
|
|
197
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
198
|
-
|
|
199
|
-
|
|
213
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
214
|
+
minVersion: "12.0.0",
|
|
215
|
+
version: "20.2.0-next.2",
|
|
216
|
+
ngImport: i0,
|
|
217
|
+
type: HeaderRowEventDispatcher,
|
|
218
|
+
decorators: [{
|
|
219
|
+
type: Injectable
|
|
220
|
+
}]
|
|
221
|
+
});
|
|
200
222
|
|
|
201
|
-
/**
|
|
202
|
-
* @docs-private
|
|
203
|
-
*/
|
|
204
223
|
class _Schedule {
|
|
205
|
-
|
|
206
|
-
|
|
224
|
+
tasks = [];
|
|
225
|
+
endTasks = [];
|
|
207
226
|
}
|
|
208
|
-
/** Injection token used to provide a coalesced style scheduler. */
|
|
209
227
|
const _COALESCED_STYLE_SCHEDULER = new InjectionToken('_COALESCED_STYLE_SCHEDULER');
|
|
210
|
-
/**
|
|
211
|
-
* Allows grouping up CSSDom mutations after the current execution context.
|
|
212
|
-
* This can significantly improve performance when separate consecutive functions are
|
|
213
|
-
* reading from the CSSDom and then mutating it.
|
|
214
|
-
*
|
|
215
|
-
* @docs-private
|
|
216
|
-
*/
|
|
217
228
|
class _CoalescedStyleScheduler {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
if (this._currentSchedule) {
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
229
|
+
_currentSchedule = null;
|
|
230
|
+
_ngZone = inject(NgZone);
|
|
231
|
+
constructor() {}
|
|
232
|
+
schedule(task) {
|
|
233
|
+
this._createScheduleIfNeeded();
|
|
234
|
+
this._currentSchedule.tasks.push(task);
|
|
235
|
+
}
|
|
236
|
+
scheduleEnd(task) {
|
|
237
|
+
this._createScheduleIfNeeded();
|
|
238
|
+
this._currentSchedule.endTasks.push(task);
|
|
239
|
+
}
|
|
240
|
+
_createScheduleIfNeeded() {
|
|
241
|
+
if (this._currentSchedule) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
this._currentSchedule = new _Schedule();
|
|
245
|
+
this._ngZone.runOutsideAngular(() => queueMicrotask(() => {
|
|
246
|
+
while (this._currentSchedule.tasks.length || this._currentSchedule.endTasks.length) {
|
|
247
|
+
const schedule = this._currentSchedule;
|
|
240
248
|
this._currentSchedule = new _Schedule();
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
249
|
+
for (const task of schedule.tasks) {
|
|
250
|
+
task();
|
|
251
|
+
}
|
|
252
|
+
for (const task of schedule.endTasks) {
|
|
253
|
+
task();
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
this._currentSchedule = null;
|
|
257
|
+
}));
|
|
258
|
+
}
|
|
259
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
260
|
+
minVersion: "12.0.0",
|
|
261
|
+
version: "20.2.0-next.2",
|
|
262
|
+
ngImport: i0,
|
|
263
|
+
type: _CoalescedStyleScheduler,
|
|
264
|
+
deps: [],
|
|
265
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
266
|
+
});
|
|
267
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
268
|
+
minVersion: "12.0.0",
|
|
269
|
+
version: "20.2.0-next.2",
|
|
270
|
+
ngImport: i0,
|
|
271
|
+
type: _CoalescedStyleScheduler
|
|
272
|
+
});
|
|
263
273
|
}
|
|
264
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
265
|
-
|
|
266
|
-
|
|
274
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
275
|
+
minVersion: "12.0.0",
|
|
276
|
+
version: "20.2.0-next.2",
|
|
277
|
+
ngImport: i0,
|
|
278
|
+
type: _CoalescedStyleScheduler,
|
|
279
|
+
decorators: [{
|
|
280
|
+
type: Injectable
|
|
281
|
+
}],
|
|
282
|
+
ctorParameters: () => []
|
|
283
|
+
});
|
|
267
284
|
|
|
268
|
-
/**
|
|
269
|
-
* Provides an implementation for resizing a column.
|
|
270
|
-
* The details of how resizing works for tables for flex mat-tables are quite different.
|
|
271
|
-
*/
|
|
272
285
|
class ResizeStrategy {
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
286
|
+
_tableObserved = false;
|
|
287
|
+
_elemSizeCache = new WeakMap();
|
|
288
|
+
_resizeObserver = globalThis?.ResizeObserver ? new globalThis.ResizeObserver(entries => this._updateCachedSizes(entries)) : null;
|
|
289
|
+
updateTableWidthAndStickyColumns(delta) {
|
|
290
|
+
this.columnResize._flushPending = true;
|
|
291
|
+
this.styleScheduler.scheduleEnd(() => {
|
|
292
|
+
if (!this.columnResize._flushPending) {
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
this.columnResize._flushPending = false;
|
|
296
|
+
this.table.updateStickyColumnStyles();
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
getElementWidth(element) {
|
|
300
|
+
return coercePixelsFromCssValue(element.style.width) || this._elemSizeCache.get(element)?.width || element.offsetWidth;
|
|
301
|
+
}
|
|
302
|
+
registerColumn(column) {
|
|
303
|
+
if (!this._tableObserved) {
|
|
304
|
+
this._tableObserved = true;
|
|
305
|
+
this._resizeObserver?.observe(this.columnResize.elementRef.nativeElement, {
|
|
306
|
+
box: 'border-box'
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
this._resizeObserver?.observe(column, {
|
|
310
|
+
box: 'border-box'
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
ngOnDestroy() {
|
|
314
|
+
this._resizeObserver?.disconnect();
|
|
315
|
+
}
|
|
316
|
+
_updateCachedSizes(entries) {
|
|
317
|
+
for (const entry of entries) {
|
|
318
|
+
const newEntry = entry.borderBoxSize?.length ? {
|
|
319
|
+
width: entry.borderBoxSize[0].inlineSize,
|
|
320
|
+
height: entry.borderBoxSize[0].blockSize
|
|
321
|
+
} : {
|
|
322
|
+
width: entry.contentRect.width,
|
|
323
|
+
height: entry.contentRect.height
|
|
324
|
+
};
|
|
325
|
+
this._elemSizeCache.set(entry.target, newEntry);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
329
|
+
minVersion: "12.0.0",
|
|
330
|
+
version: "20.2.0-next.2",
|
|
331
|
+
ngImport: i0,
|
|
332
|
+
type: ResizeStrategy,
|
|
333
|
+
deps: [],
|
|
334
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
335
|
+
});
|
|
336
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
337
|
+
minVersion: "12.0.0",
|
|
338
|
+
version: "20.2.0-next.2",
|
|
339
|
+
ngImport: i0,
|
|
340
|
+
type: ResizeStrategy
|
|
341
|
+
});
|
|
326
342
|
}
|
|
327
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
*/
|
|
343
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
344
|
+
minVersion: "12.0.0",
|
|
345
|
+
version: "20.2.0-next.2",
|
|
346
|
+
ngImport: i0,
|
|
347
|
+
type: ResizeStrategy,
|
|
348
|
+
decorators: [{
|
|
349
|
+
type: Injectable
|
|
350
|
+
}]
|
|
351
|
+
});
|
|
337
352
|
class TableLayoutFixedResizeStrategy extends ResizeStrategy {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
353
|
+
columnResize = inject(ColumnResize);
|
|
354
|
+
styleScheduler = inject(_COALESCED_STYLE_SCHEDULER);
|
|
355
|
+
table = inject(CdkTable);
|
|
356
|
+
applyColumnSize(_, columnHeader, sizeInPx, previousSizeInPx) {
|
|
357
|
+
const delta = sizeInPx - (previousSizeInPx ?? this.getElementWidth(columnHeader));
|
|
358
|
+
if (delta === 0) {
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
this.styleScheduler.schedule(() => {
|
|
362
|
+
columnHeader.style.width = coerceCssPixelValue(sizeInPx);
|
|
363
|
+
});
|
|
364
|
+
this.updateTableWidthAndStickyColumns(delta);
|
|
365
|
+
}
|
|
366
|
+
applyMinColumnSize(_, columnHeader, sizeInPx) {
|
|
367
|
+
const currentWidth = this.getElementWidth(columnHeader);
|
|
368
|
+
const newWidth = Math.max(currentWidth, sizeInPx);
|
|
369
|
+
this.applyColumnSize(_, columnHeader, newWidth, currentWidth);
|
|
370
|
+
}
|
|
371
|
+
applyMaxColumnSize(_, columnHeader, sizeInPx) {
|
|
372
|
+
const currentWidth = this.getElementWidth(columnHeader);
|
|
373
|
+
const newWidth = Math.min(currentWidth, sizeInPx);
|
|
374
|
+
this.applyColumnSize(_, columnHeader, newWidth, currentWidth);
|
|
375
|
+
}
|
|
376
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
377
|
+
minVersion: "12.0.0",
|
|
378
|
+
version: "20.2.0-next.2",
|
|
379
|
+
ngImport: i0,
|
|
380
|
+
type: TableLayoutFixedResizeStrategy,
|
|
381
|
+
deps: null,
|
|
382
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
383
|
+
});
|
|
384
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
385
|
+
minVersion: "12.0.0",
|
|
386
|
+
version: "20.2.0-next.2",
|
|
387
|
+
ngImport: i0,
|
|
388
|
+
type: TableLayoutFixedResizeStrategy
|
|
389
|
+
});
|
|
363
390
|
}
|
|
364
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
391
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
392
|
+
minVersion: "12.0.0",
|
|
393
|
+
version: "20.2.0-next.2",
|
|
394
|
+
ngImport: i0,
|
|
395
|
+
type: TableLayoutFixedResizeStrategy,
|
|
396
|
+
decorators: [{
|
|
397
|
+
type: Injectable
|
|
398
|
+
}]
|
|
399
|
+
});
|
|
373
400
|
class CdkFlexTableResizeStrategy extends ResizeStrategy {
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
401
|
+
columnResize = inject(ColumnResize);
|
|
402
|
+
styleScheduler = inject(_COALESCED_STYLE_SCHEDULER);
|
|
403
|
+
table = inject(CdkTable);
|
|
404
|
+
_nonce = inject(CSP_NONCE, {
|
|
405
|
+
optional: true
|
|
406
|
+
});
|
|
407
|
+
_document = inject(DOCUMENT);
|
|
408
|
+
_columnIndexes = new Map();
|
|
409
|
+
_columnProperties = new Map();
|
|
410
|
+
_styleElement;
|
|
411
|
+
_indexSequence = 0;
|
|
412
|
+
defaultMinSize = 0;
|
|
413
|
+
defaultMaxSize = Number.MAX_SAFE_INTEGER;
|
|
414
|
+
applyColumnSize(cssFriendlyColumnName, columnHeader, sizeInPx, previousSizeInPx) {
|
|
415
|
+
const delta = sizeInPx - (previousSizeInPx ?? (this._getAppliedWidth(cssFriendlyColumnName) || columnHeader.offsetWidth));
|
|
416
|
+
if (delta === 0) {
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
const cssSize = coerceCssPixelValue(sizeInPx);
|
|
420
|
+
this._applyProperty(cssFriendlyColumnName, 'flex', `0 0.01 ${cssSize}`);
|
|
421
|
+
this.updateTableWidthAndStickyColumns(delta);
|
|
422
|
+
}
|
|
423
|
+
applyMinColumnSize(cssFriendlyColumnName, _, sizeInPx) {
|
|
424
|
+
const cssSize = coerceCssPixelValue(sizeInPx);
|
|
425
|
+
this._applyProperty(cssFriendlyColumnName, 'min-width', cssSize, sizeInPx !== this.defaultMinSize);
|
|
426
|
+
this.updateTableWidthAndStickyColumns(0);
|
|
427
|
+
}
|
|
428
|
+
applyMaxColumnSize(cssFriendlyColumnName, _, sizeInPx) {
|
|
429
|
+
const cssSize = coerceCssPixelValue(sizeInPx);
|
|
430
|
+
this._applyProperty(cssFriendlyColumnName, 'max-width', cssSize, sizeInPx !== this.defaultMaxSize);
|
|
431
|
+
this.updateTableWidthAndStickyColumns(0);
|
|
432
|
+
}
|
|
433
|
+
getColumnCssClass(cssFriendlyColumnName) {
|
|
434
|
+
return `cdk-column-${cssFriendlyColumnName}`;
|
|
435
|
+
}
|
|
436
|
+
ngOnDestroy() {
|
|
437
|
+
super.ngOnDestroy();
|
|
438
|
+
this._styleElement?.remove();
|
|
439
|
+
this._styleElement = undefined;
|
|
440
|
+
}
|
|
441
|
+
_getPropertyValue(cssFriendlyColumnName, key) {
|
|
442
|
+
const properties = this._getColumnPropertiesMap(cssFriendlyColumnName);
|
|
443
|
+
return properties.get(key);
|
|
444
|
+
}
|
|
445
|
+
_getAppliedWidth(cssFriendslyColumnName) {
|
|
446
|
+
return coercePixelsFromFlexValue(this._getPropertyValue(cssFriendslyColumnName, 'flex'));
|
|
447
|
+
}
|
|
448
|
+
_applyProperty(cssFriendlyColumnName, key, value, enable = true) {
|
|
449
|
+
const properties = this._getColumnPropertiesMap(cssFriendlyColumnName);
|
|
450
|
+
this.styleScheduler.schedule(() => {
|
|
451
|
+
if (enable) {
|
|
452
|
+
properties.set(key, value);
|
|
453
|
+
} else {
|
|
454
|
+
properties.delete(key);
|
|
455
|
+
}
|
|
456
|
+
this._applySizeCss(cssFriendlyColumnName);
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
_getStyleSheet() {
|
|
460
|
+
if (!this._styleElement) {
|
|
461
|
+
this._styleElement = this._document.createElement('style');
|
|
462
|
+
if (this._nonce) {
|
|
463
|
+
this._styleElement.setAttribute('nonce', this._nonce);
|
|
464
|
+
}
|
|
465
|
+
this._styleElement.appendChild(this._document.createTextNode(''));
|
|
466
|
+
this._document.head.appendChild(this._styleElement);
|
|
467
|
+
}
|
|
468
|
+
return this._styleElement.sheet;
|
|
469
|
+
}
|
|
470
|
+
_getColumnPropertiesMap(cssFriendlyColumnName) {
|
|
471
|
+
let properties = this._columnProperties.get(cssFriendlyColumnName);
|
|
472
|
+
if (properties === undefined) {
|
|
473
|
+
properties = new Map();
|
|
474
|
+
this._columnProperties.set(cssFriendlyColumnName, properties);
|
|
475
|
+
}
|
|
476
|
+
return properties;
|
|
477
|
+
}
|
|
478
|
+
_applySizeCss(cssFriendlyColumnName) {
|
|
479
|
+
const properties = this._getColumnPropertiesMap(cssFriendlyColumnName);
|
|
480
|
+
const propertyKeys = Array.from(properties.keys());
|
|
481
|
+
let index = this._columnIndexes.get(cssFriendlyColumnName);
|
|
482
|
+
if (index === undefined) {
|
|
483
|
+
if (!propertyKeys.length) {
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
index = this._indexSequence++;
|
|
487
|
+
this._columnIndexes.set(cssFriendlyColumnName, index);
|
|
488
|
+
} else {
|
|
489
|
+
this._getStyleSheet().deleteRule(index);
|
|
490
|
+
}
|
|
491
|
+
const columnClassName = this.getColumnCssClass(cssFriendlyColumnName);
|
|
492
|
+
const tableClassName = this.columnResize.getUniqueCssClass();
|
|
493
|
+
const selector = `.${tableClassName} .${columnClassName}`;
|
|
494
|
+
const body = propertyKeys.map(key => `${key}:${properties.get(key)}`).join(';');
|
|
495
|
+
this._getStyleSheet().insertRule(`${selector} {${body}}`, index);
|
|
496
|
+
}
|
|
497
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
498
|
+
minVersion: "12.0.0",
|
|
499
|
+
version: "20.2.0-next.2",
|
|
500
|
+
ngImport: i0,
|
|
501
|
+
type: CdkFlexTableResizeStrategy,
|
|
502
|
+
deps: null,
|
|
503
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
504
|
+
});
|
|
505
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
506
|
+
minVersion: "12.0.0",
|
|
507
|
+
version: "20.2.0-next.2",
|
|
508
|
+
ngImport: i0,
|
|
509
|
+
type: CdkFlexTableResizeStrategy
|
|
510
|
+
});
|
|
477
511
|
}
|
|
478
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
512
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
513
|
+
minVersion: "12.0.0",
|
|
514
|
+
version: "20.2.0-next.2",
|
|
515
|
+
ngImport: i0,
|
|
516
|
+
type: CdkFlexTableResizeStrategy,
|
|
517
|
+
decorators: [{
|
|
518
|
+
type: Injectable
|
|
519
|
+
}]
|
|
520
|
+
});
|
|
482
521
|
function coercePixelsFromCssValue(cssValue) {
|
|
483
|
-
|
|
522
|
+
return Number(cssValue.match(/(\d+)px/)?.[1]);
|
|
484
523
|
}
|
|
485
|
-
/**
|
|
486
|
-
* Converts CSS flex values as set in CdkFlexTableResizeStrategy to numbers,
|
|
487
|
-
* eg "0 0.01 123px" to 123.
|
|
488
|
-
*/
|
|
489
524
|
function coercePixelsFromFlexValue(flexValue) {
|
|
490
|
-
|
|
525
|
+
return Number(flexValue?.match(/0 0\.01 (\d+)px/)?.[1]);
|
|
491
526
|
}
|
|
492
527
|
const TABLE_LAYOUT_FIXED_RESIZE_STRATEGY_PROVIDER = {
|
|
493
|
-
|
|
494
|
-
|
|
528
|
+
provide: ResizeStrategy,
|
|
529
|
+
useClass: TableLayoutFixedResizeStrategy
|
|
495
530
|
};
|
|
496
531
|
const FLEX_RESIZE_STRATEGY_PROVIDER = {
|
|
497
|
-
|
|
498
|
-
|
|
532
|
+
provide: ResizeStrategy,
|
|
533
|
+
useClass: CdkFlexTableResizeStrategy
|
|
499
534
|
};
|
|
500
535
|
|
|
501
|
-
const PROVIDERS = [
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
];
|
|
507
|
-
const TABLE_PROVIDERS = [
|
|
508
|
-
...PROVIDERS,
|
|
509
|
-
TABLE_LAYOUT_FIXED_RESIZE_STRATEGY_PROVIDER,
|
|
510
|
-
];
|
|
536
|
+
const PROVIDERS = [ColumnResizeNotifier, HeaderRowEventDispatcher, ColumnResizeNotifierSource, {
|
|
537
|
+
provide: _COALESCED_STYLE_SCHEDULER,
|
|
538
|
+
useClass: _CoalescedStyleScheduler
|
|
539
|
+
}];
|
|
540
|
+
const TABLE_PROVIDERS = [...PROVIDERS, TABLE_LAYOUT_FIXED_RESIZE_STRATEGY_PROVIDER];
|
|
511
541
|
const FLEX_PROVIDERS = [...PROVIDERS, FLEX_RESIZE_STRATEGY_PROVIDER];
|
|
512
542
|
|
|
513
|
-
/**
|
|
514
|
-
* Explicitly enables column resizing for a table-based cdk-table.
|
|
515
|
-
* Individual columns must be annotated specifically.
|
|
516
|
-
*/
|
|
517
543
|
class CdkColumnResize extends ColumnResize {
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
544
|
+
columnResizeNotifier = inject(ColumnResizeNotifier);
|
|
545
|
+
elementRef = inject(ElementRef);
|
|
546
|
+
eventDispatcher = inject(HeaderRowEventDispatcher);
|
|
547
|
+
ngZone = inject(NgZone);
|
|
548
|
+
notifier = inject(ColumnResizeNotifierSource);
|
|
549
|
+
table = inject(CdkTable);
|
|
550
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
551
|
+
minVersion: "12.0.0",
|
|
552
|
+
version: "20.2.0-next.2",
|
|
553
|
+
ngImport: i0,
|
|
554
|
+
type: CdkColumnResize,
|
|
555
|
+
deps: null,
|
|
556
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
557
|
+
});
|
|
558
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
559
|
+
minVersion: "14.0.0",
|
|
560
|
+
version: "20.2.0-next.2",
|
|
561
|
+
type: CdkColumnResize,
|
|
562
|
+
isStandalone: true,
|
|
563
|
+
selector: "table[cdk-table][columnResize]",
|
|
564
|
+
providers: [...TABLE_PROVIDERS, {
|
|
565
|
+
provide: ColumnResize,
|
|
566
|
+
useExisting: CdkColumnResize
|
|
567
|
+
}],
|
|
568
|
+
usesInheritance: true,
|
|
569
|
+
ngImport: i0
|
|
570
|
+
});
|
|
526
571
|
}
|
|
527
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
572
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
573
|
+
minVersion: "12.0.0",
|
|
574
|
+
version: "20.2.0-next.2",
|
|
575
|
+
ngImport: i0,
|
|
576
|
+
type: CdkColumnResize,
|
|
577
|
+
decorators: [{
|
|
578
|
+
type: Directive,
|
|
579
|
+
args: [{
|
|
580
|
+
selector: 'table[cdk-table][columnResize]',
|
|
581
|
+
providers: [...TABLE_PROVIDERS, {
|
|
582
|
+
provide: ColumnResize,
|
|
583
|
+
useExisting: CdkColumnResize
|
|
584
|
+
}]
|
|
585
|
+
}]
|
|
586
|
+
}]
|
|
587
|
+
});
|
|
534
588
|
|
|
535
|
-
/**
|
|
536
|
-
* Explicitly enables column resizing for a flexbox-based cdk-table.
|
|
537
|
-
* Individual columns must be annotated specifically.
|
|
538
|
-
*/
|
|
539
589
|
class CdkColumnResizeFlex extends ColumnResize {
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
590
|
+
columnResizeNotifier = inject(ColumnResizeNotifier);
|
|
591
|
+
elementRef = inject(ElementRef);
|
|
592
|
+
eventDispatcher = inject(HeaderRowEventDispatcher);
|
|
593
|
+
ngZone = inject(NgZone);
|
|
594
|
+
notifier = inject(ColumnResizeNotifierSource);
|
|
595
|
+
table = inject(CdkTable);
|
|
596
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
597
|
+
minVersion: "12.0.0",
|
|
598
|
+
version: "20.2.0-next.2",
|
|
599
|
+
ngImport: i0,
|
|
600
|
+
type: CdkColumnResizeFlex,
|
|
601
|
+
deps: null,
|
|
602
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
603
|
+
});
|
|
604
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
605
|
+
minVersion: "14.0.0",
|
|
606
|
+
version: "20.2.0-next.2",
|
|
607
|
+
type: CdkColumnResizeFlex,
|
|
608
|
+
isStandalone: true,
|
|
609
|
+
selector: "cdk-table[columnResize]",
|
|
610
|
+
providers: [...FLEX_PROVIDERS, {
|
|
611
|
+
provide: ColumnResize,
|
|
612
|
+
useExisting: CdkColumnResizeFlex
|
|
613
|
+
}],
|
|
614
|
+
usesInheritance: true,
|
|
615
|
+
ngImport: i0
|
|
616
|
+
});
|
|
548
617
|
}
|
|
549
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
618
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
619
|
+
minVersion: "12.0.0",
|
|
620
|
+
version: "20.2.0-next.2",
|
|
621
|
+
ngImport: i0,
|
|
622
|
+
type: CdkColumnResizeFlex,
|
|
623
|
+
decorators: [{
|
|
624
|
+
type: Directive,
|
|
625
|
+
args: [{
|
|
626
|
+
selector: 'cdk-table[columnResize]',
|
|
627
|
+
providers: [...FLEX_PROVIDERS, {
|
|
628
|
+
provide: ColumnResize,
|
|
629
|
+
useExisting: CdkColumnResizeFlex
|
|
630
|
+
}]
|
|
631
|
+
}]
|
|
632
|
+
}]
|
|
633
|
+
});
|
|
556
634
|
|
|
557
|
-
/**
|
|
558
|
-
* Implicitly enables column resizing for a table-based cdk-table.
|
|
559
|
-
* Individual columns will be resizable unless opted out.
|
|
560
|
-
*/
|
|
561
635
|
class CdkDefaultEnabledColumnResize extends ColumnResize {
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
636
|
+
columnResizeNotifier = inject(ColumnResizeNotifier);
|
|
637
|
+
elementRef = inject(ElementRef);
|
|
638
|
+
eventDispatcher = inject(HeaderRowEventDispatcher);
|
|
639
|
+
ngZone = inject(NgZone);
|
|
640
|
+
notifier = inject(ColumnResizeNotifierSource);
|
|
641
|
+
table = inject(CdkTable);
|
|
642
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
643
|
+
minVersion: "12.0.0",
|
|
644
|
+
version: "20.2.0-next.2",
|
|
645
|
+
ngImport: i0,
|
|
646
|
+
type: CdkDefaultEnabledColumnResize,
|
|
647
|
+
deps: null,
|
|
648
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
649
|
+
});
|
|
650
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
651
|
+
minVersion: "14.0.0",
|
|
652
|
+
version: "20.2.0-next.2",
|
|
653
|
+
type: CdkDefaultEnabledColumnResize,
|
|
654
|
+
isStandalone: true,
|
|
655
|
+
selector: "table[cdk-table]",
|
|
656
|
+
providers: [...TABLE_PROVIDERS, {
|
|
657
|
+
provide: ColumnResize,
|
|
658
|
+
useExisting: CdkDefaultEnabledColumnResize
|
|
659
|
+
}],
|
|
660
|
+
usesInheritance: true,
|
|
661
|
+
ngImport: i0
|
|
662
|
+
});
|
|
573
663
|
}
|
|
574
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
664
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
665
|
+
minVersion: "12.0.0",
|
|
666
|
+
version: "20.2.0-next.2",
|
|
667
|
+
ngImport: i0,
|
|
668
|
+
type: CdkDefaultEnabledColumnResize,
|
|
669
|
+
decorators: [{
|
|
670
|
+
type: Directive,
|
|
671
|
+
args: [{
|
|
672
|
+
selector: 'table[cdk-table]',
|
|
673
|
+
providers: [...TABLE_PROVIDERS, {
|
|
674
|
+
provide: ColumnResize,
|
|
675
|
+
useExisting: CdkDefaultEnabledColumnResize
|
|
676
|
+
}]
|
|
677
|
+
}]
|
|
678
|
+
}]
|
|
679
|
+
});
|
|
584
680
|
|
|
585
|
-
/**
|
|
586
|
-
* Implicitly enables column resizing for a flex cdk-table.
|
|
587
|
-
* Individual columns will be resizable unless opted out.
|
|
588
|
-
*/
|
|
589
681
|
class CdkDefaultEnabledColumnResizeFlex extends ColumnResize {
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
682
|
+
columnResizeNotifier = inject(ColumnResizeNotifier);
|
|
683
|
+
elementRef = inject(ElementRef);
|
|
684
|
+
eventDispatcher = inject(HeaderRowEventDispatcher);
|
|
685
|
+
ngZone = inject(NgZone);
|
|
686
|
+
notifier = inject(ColumnResizeNotifierSource);
|
|
687
|
+
table = inject(CdkTable);
|
|
688
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
689
|
+
minVersion: "12.0.0",
|
|
690
|
+
version: "20.2.0-next.2",
|
|
691
|
+
ngImport: i0,
|
|
692
|
+
type: CdkDefaultEnabledColumnResizeFlex,
|
|
693
|
+
deps: null,
|
|
694
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
695
|
+
});
|
|
696
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
697
|
+
minVersion: "14.0.0",
|
|
698
|
+
version: "20.2.0-next.2",
|
|
699
|
+
type: CdkDefaultEnabledColumnResizeFlex,
|
|
700
|
+
isStandalone: true,
|
|
701
|
+
selector: "cdk-table",
|
|
702
|
+
providers: [...FLEX_PROVIDERS, {
|
|
703
|
+
provide: ColumnResize,
|
|
704
|
+
useExisting: CdkDefaultEnabledColumnResizeFlex
|
|
705
|
+
}],
|
|
706
|
+
usesInheritance: true,
|
|
707
|
+
ngImport: i0
|
|
708
|
+
});
|
|
601
709
|
}
|
|
602
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
710
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
711
|
+
minVersion: "12.0.0",
|
|
712
|
+
version: "20.2.0-next.2",
|
|
713
|
+
ngImport: i0,
|
|
714
|
+
type: CdkDefaultEnabledColumnResizeFlex,
|
|
715
|
+
decorators: [{
|
|
716
|
+
type: Directive,
|
|
717
|
+
args: [{
|
|
718
|
+
selector: 'cdk-table',
|
|
719
|
+
providers: [...FLEX_PROVIDERS, {
|
|
720
|
+
provide: ColumnResize,
|
|
721
|
+
useExisting: CdkDefaultEnabledColumnResizeFlex
|
|
722
|
+
}]
|
|
723
|
+
}]
|
|
724
|
+
}]
|
|
725
|
+
});
|
|
612
726
|
|
|
613
|
-
/**
|
|
614
|
-
* One of two NgModules for use with CdkColumnResize.
|
|
615
|
-
* When using this module, columns are resizable by default.
|
|
616
|
-
*/
|
|
617
727
|
class CdkColumnResizeDefaultEnabledModule {
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
728
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
729
|
+
minVersion: "12.0.0",
|
|
730
|
+
version: "20.2.0-next.2",
|
|
731
|
+
ngImport: i0,
|
|
732
|
+
type: CdkColumnResizeDefaultEnabledModule,
|
|
733
|
+
deps: [],
|
|
734
|
+
target: i0.ɵɵFactoryTarget.NgModule
|
|
735
|
+
});
|
|
736
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({
|
|
737
|
+
minVersion: "14.0.0",
|
|
738
|
+
version: "20.2.0-next.2",
|
|
739
|
+
ngImport: i0,
|
|
740
|
+
type: CdkColumnResizeDefaultEnabledModule,
|
|
741
|
+
imports: [CdkDefaultEnabledColumnResize, CdkDefaultEnabledColumnResizeFlex],
|
|
742
|
+
exports: [CdkDefaultEnabledColumnResize, CdkDefaultEnabledColumnResizeFlex]
|
|
743
|
+
});
|
|
744
|
+
static ɵinj = i0.ɵɵngDeclareInjector({
|
|
745
|
+
minVersion: "12.0.0",
|
|
746
|
+
version: "20.2.0-next.2",
|
|
747
|
+
ngImport: i0,
|
|
748
|
+
type: CdkColumnResizeDefaultEnabledModule
|
|
749
|
+
});
|
|
621
750
|
}
|
|
622
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
751
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
752
|
+
minVersion: "12.0.0",
|
|
753
|
+
version: "20.2.0-next.2",
|
|
754
|
+
ngImport: i0,
|
|
755
|
+
type: CdkColumnResizeDefaultEnabledModule,
|
|
756
|
+
decorators: [{
|
|
757
|
+
type: NgModule,
|
|
758
|
+
args: [{
|
|
759
|
+
imports: [CdkDefaultEnabledColumnResize, CdkDefaultEnabledColumnResizeFlex],
|
|
760
|
+
exports: [CdkDefaultEnabledColumnResize, CdkDefaultEnabledColumnResizeFlex]
|
|
761
|
+
}]
|
|
762
|
+
}]
|
|
763
|
+
});
|
|
633
764
|
class CdkColumnResizeModule {
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
765
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
766
|
+
minVersion: "12.0.0",
|
|
767
|
+
version: "20.2.0-next.2",
|
|
768
|
+
ngImport: i0,
|
|
769
|
+
type: CdkColumnResizeModule,
|
|
770
|
+
deps: [],
|
|
771
|
+
target: i0.ɵɵFactoryTarget.NgModule
|
|
772
|
+
});
|
|
773
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({
|
|
774
|
+
minVersion: "14.0.0",
|
|
775
|
+
version: "20.2.0-next.2",
|
|
776
|
+
ngImport: i0,
|
|
777
|
+
type: CdkColumnResizeModule,
|
|
778
|
+
imports: [CdkColumnResize, CdkColumnResizeFlex],
|
|
779
|
+
exports: [CdkColumnResize, CdkColumnResizeFlex]
|
|
780
|
+
});
|
|
781
|
+
static ɵinj = i0.ɵɵngDeclareInjector({
|
|
782
|
+
minVersion: "12.0.0",
|
|
783
|
+
version: "20.2.0-next.2",
|
|
784
|
+
ngImport: i0,
|
|
785
|
+
type: CdkColumnResizeModule
|
|
786
|
+
});
|
|
637
787
|
}
|
|
638
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
788
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
789
|
+
minVersion: "12.0.0",
|
|
790
|
+
version: "20.2.0-next.2",
|
|
791
|
+
ngImport: i0,
|
|
792
|
+
type: CdkColumnResizeModule,
|
|
793
|
+
decorators: [{
|
|
794
|
+
type: NgModule,
|
|
795
|
+
args: [{
|
|
796
|
+
imports: [CdkColumnResize, CdkColumnResizeFlex],
|
|
797
|
+
exports: [CdkColumnResize, CdkColumnResizeFlex]
|
|
798
|
+
}]
|
|
799
|
+
}]
|
|
800
|
+
});
|
|
645
801
|
|
|
646
|
-
/**
|
|
647
|
-
* Can be provided by the host application to enable persistence of column resize state.
|
|
648
|
-
*/
|
|
649
802
|
class ColumnSizeStore {
|
|
650
|
-
|
|
651
|
-
|
|
803
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
804
|
+
minVersion: "12.0.0",
|
|
805
|
+
version: "20.2.0-next.2",
|
|
806
|
+
ngImport: i0,
|
|
807
|
+
type: ColumnSizeStore,
|
|
808
|
+
deps: [],
|
|
809
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
810
|
+
});
|
|
811
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
812
|
+
minVersion: "12.0.0",
|
|
813
|
+
version: "20.2.0-next.2",
|
|
814
|
+
ngImport: i0,
|
|
815
|
+
type: ColumnSizeStore
|
|
816
|
+
});
|
|
652
817
|
}
|
|
653
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
654
|
-
|
|
655
|
-
|
|
818
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
819
|
+
minVersion: "12.0.0",
|
|
820
|
+
version: "20.2.0-next.2",
|
|
821
|
+
ngImport: i0,
|
|
822
|
+
type: ColumnSizeStore,
|
|
823
|
+
decorators: [{
|
|
824
|
+
type: Injectable
|
|
825
|
+
}]
|
|
826
|
+
});
|
|
656
827
|
|
|
657
|
-
/** Tracks state of resize events in progress. */
|
|
658
828
|
class ResizeRef {
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
829
|
+
origin;
|
|
830
|
+
overlayRef;
|
|
831
|
+
minWidthPx;
|
|
832
|
+
maxWidthPx;
|
|
833
|
+
liveUpdates;
|
|
834
|
+
constructor(origin, overlayRef, minWidthPx, maxWidthPx, liveUpdates = true) {
|
|
835
|
+
this.origin = origin;
|
|
836
|
+
this.overlayRef = overlayRef;
|
|
837
|
+
this.minWidthPx = minWidthPx;
|
|
838
|
+
this.maxWidthPx = maxWidthPx;
|
|
839
|
+
this.liveUpdates = liveUpdates;
|
|
840
|
+
}
|
|
671
841
|
}
|
|
672
842
|
|
|
673
843
|
const OVERLAY_ACTIVE_CLASS = 'cdk-resizable-overlay-thumb-active';
|
|
674
844
|
const RESIZE_DISABLED_CLASS = 'cdk-resizable-resize-disabled';
|
|
675
|
-
/**
|
|
676
|
-
* Base class for Resizable directives which are applied to column headers to make those columns
|
|
677
|
-
* resizable.
|
|
678
|
-
*/
|
|
679
845
|
class Resizable {
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
846
|
+
minWidthPxInternal = 0;
|
|
847
|
+
maxWidthPxInternal = Number.MAX_SAFE_INTEGER;
|
|
848
|
+
inlineHandle;
|
|
849
|
+
overlayRef;
|
|
850
|
+
destroyed = new Subject();
|
|
851
|
+
columnSizeStore = inject(ColumnSizeStore, {
|
|
852
|
+
optional: true
|
|
853
|
+
});
|
|
854
|
+
_injector = inject(Injector);
|
|
855
|
+
_viewInitialized = false;
|
|
856
|
+
_isDestroyed = false;
|
|
857
|
+
get minWidthPx() {
|
|
858
|
+
return this.minWidthPxInternal;
|
|
859
|
+
}
|
|
860
|
+
set minWidthPx(value) {
|
|
861
|
+
this.minWidthPxInternal = value;
|
|
862
|
+
this.columnResize.setResized();
|
|
863
|
+
if (this.elementRef.nativeElement && this._viewInitialized) {
|
|
864
|
+
this._applyMinWidthPx();
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
get maxWidthPx() {
|
|
868
|
+
return this.maxWidthPxInternal;
|
|
869
|
+
}
|
|
870
|
+
set maxWidthPx(value) {
|
|
871
|
+
this.maxWidthPxInternal = value;
|
|
872
|
+
this.columnResize.setResized();
|
|
873
|
+
if (this.elementRef.nativeElement && this._viewInitialized) {
|
|
874
|
+
this._applyMaxWidthPx();
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
ngOnInit() {
|
|
878
|
+
this.resizeStrategy.registerColumn(this.elementRef.nativeElement);
|
|
879
|
+
}
|
|
880
|
+
ngAfterViewInit() {
|
|
881
|
+
this._listenForRowHoverEvents();
|
|
882
|
+
this._listenForResizeEvents();
|
|
883
|
+
this._appendInlineHandle();
|
|
884
|
+
this.styleScheduler.scheduleEnd(() => {
|
|
885
|
+
if (this._isDestroyed) return;
|
|
886
|
+
this._viewInitialized = true;
|
|
887
|
+
this._applyMinWidthPx();
|
|
888
|
+
this._applyMaxWidthPx();
|
|
889
|
+
this.columnSizeStore?.getSize(this.columnResize.getTableId(), this.columnDef.name)?.pipe(take(1), takeUntil(this.destroyed)).subscribe(size => {
|
|
890
|
+
if (size == null) {
|
|
891
|
+
return;
|
|
698
892
|
}
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
893
|
+
this._applySize(size);
|
|
894
|
+
});
|
|
895
|
+
});
|
|
896
|
+
}
|
|
897
|
+
ngOnDestroy() {
|
|
898
|
+
this._isDestroyed = true;
|
|
899
|
+
this.destroyed.next();
|
|
900
|
+
this.destroyed.complete();
|
|
901
|
+
this.inlineHandle?.remove();
|
|
902
|
+
this.overlayRef?.dispose();
|
|
903
|
+
}
|
|
904
|
+
_createOverlayForHandle() {
|
|
905
|
+
const isRtl = this.directionality.value === 'rtl';
|
|
906
|
+
const positionStrategy = createFlexibleConnectedPositionStrategy(this._injector, this.elementRef.nativeElement).withFlexibleDimensions(false).withGrowAfterOpen(false).withPush(false).withDefaultOffsetX(isRtl ? 1 : 0).withPositions([{
|
|
907
|
+
originX: isRtl ? 'start' : 'end',
|
|
908
|
+
originY: 'top',
|
|
909
|
+
overlayX: 'center',
|
|
910
|
+
overlayY: 'top'
|
|
911
|
+
}]);
|
|
912
|
+
return createOverlayRef(this._injector, {
|
|
913
|
+
direction: 'ltr',
|
|
914
|
+
disposeOnNavigation: true,
|
|
915
|
+
positionStrategy,
|
|
916
|
+
scrollStrategy: createRepositionScrollStrategy(this._injector),
|
|
917
|
+
width: '16px'
|
|
918
|
+
});
|
|
919
|
+
}
|
|
920
|
+
_listenForRowHoverEvents() {
|
|
921
|
+
const element = this.elementRef.nativeElement;
|
|
922
|
+
const takeUntilDestroyed = takeUntil(this.destroyed);
|
|
923
|
+
this.eventDispatcher.resizeOverlayVisibleForHeaderRow(closest(element, HEADER_ROW_SELECTOR)).pipe(takeUntilDestroyed).subscribe(hoveringRow => {
|
|
924
|
+
if (hoveringRow) {
|
|
925
|
+
const tooBigToResize = this.maxWidthPxInternal < Number.MAX_SAFE_INTEGER && element.offsetWidth > this.maxWidthPxInternal;
|
|
926
|
+
element.classList.toggle(RESIZE_DISABLED_CLASS, tooBigToResize);
|
|
927
|
+
if (!tooBigToResize) {
|
|
928
|
+
if (!this.overlayRef) {
|
|
929
|
+
this.overlayRef = this._createOverlayForHandle();
|
|
930
|
+
}
|
|
931
|
+
this._showHandleOverlay();
|
|
709
932
|
}
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
this.
|
|
739
|
-
this.
|
|
740
|
-
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
.
|
|
774
|
-
|
|
775
|
-
.subscribe(hoveringRow => {
|
|
776
|
-
if (hoveringRow) {
|
|
777
|
-
const tooBigToResize = this.maxWidthPxInternal < Number.MAX_SAFE_INTEGER &&
|
|
778
|
-
element.offsetWidth > this.maxWidthPxInternal;
|
|
779
|
-
element.classList.toggle(RESIZE_DISABLED_CLASS, tooBigToResize);
|
|
780
|
-
if (!tooBigToResize) {
|
|
781
|
-
if (!this.overlayRef) {
|
|
782
|
-
this.overlayRef = this._createOverlayForHandle();
|
|
783
|
-
}
|
|
784
|
-
this._showHandleOverlay();
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
else if (this.overlayRef) {
|
|
788
|
-
// todo - can't detach during an active resize - need to work that out
|
|
789
|
-
this.overlayRef.detach();
|
|
790
|
-
}
|
|
791
|
-
});
|
|
792
|
-
}
|
|
793
|
-
_listenForResizeEvents() {
|
|
794
|
-
const takeUntilDestroyed = takeUntil(this.destroyed);
|
|
795
|
-
merge(this.resizeNotifier.resizeCanceled, this.resizeNotifier.triggerResize)
|
|
796
|
-
.pipe(takeUntilDestroyed, filter(columnSize => columnSize.columnId === this.columnDef.name))
|
|
797
|
-
.subscribe(({ size, previousSize, completeImmediately }) => {
|
|
798
|
-
this.elementRef.nativeElement.classList.add(OVERLAY_ACTIVE_CLASS);
|
|
799
|
-
this._applySize(size, previousSize);
|
|
800
|
-
if (completeImmediately) {
|
|
801
|
-
this._completeResizeOperation();
|
|
802
|
-
}
|
|
803
|
-
});
|
|
804
|
-
merge(this.resizeNotifier.resizeCanceled, this.resizeNotifier.resizeCompleted)
|
|
805
|
-
.pipe(takeUntilDestroyed)
|
|
806
|
-
.subscribe(columnSize => {
|
|
807
|
-
this._cleanUpAfterResize(columnSize);
|
|
808
|
-
});
|
|
809
|
-
this.resizeNotifier.resizeCompleted
|
|
810
|
-
.pipe(filter(sizeUpdate => sizeUpdate.columnId === this.columnDef.name), distinctUntilChanged((a, b) => a.size === b.size), takeUntil(this.destroyed))
|
|
811
|
-
.subscribe(sizeUpdate => {
|
|
812
|
-
this.columnSizeStore?.setSize(this.columnResize.getTableId(), this.columnDef.name, sizeUpdate.size);
|
|
813
|
-
});
|
|
814
|
-
}
|
|
815
|
-
_completeResizeOperation() {
|
|
816
|
-
this.ngZone.run(() => {
|
|
817
|
-
this.resizeNotifier.resizeCompleted.next({
|
|
818
|
-
columnId: this.columnDef.name,
|
|
819
|
-
size: this.elementRef.nativeElement.offsetWidth,
|
|
820
|
-
});
|
|
821
|
-
});
|
|
822
|
-
}
|
|
823
|
-
_cleanUpAfterResize(columnSize) {
|
|
824
|
-
this.elementRef.nativeElement.classList.remove(OVERLAY_ACTIVE_CLASS);
|
|
825
|
-
if (this.overlayRef && this.overlayRef.hasAttached()) {
|
|
826
|
-
this._updateOverlayHandleHeight();
|
|
827
|
-
this.overlayRef.updatePosition();
|
|
828
|
-
if (columnSize.columnId === this.columnDef.name) {
|
|
829
|
-
this.inlineHandle.focus();
|
|
830
|
-
}
|
|
933
|
+
} else if (this.overlayRef) {
|
|
934
|
+
this.overlayRef.detach();
|
|
935
|
+
}
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
_listenForResizeEvents() {
|
|
939
|
+
const takeUntilDestroyed = takeUntil(this.destroyed);
|
|
940
|
+
merge(this.resizeNotifier.resizeCanceled, this.resizeNotifier.triggerResize).pipe(takeUntilDestroyed, filter(columnSize => columnSize.columnId === this.columnDef.name)).subscribe(({
|
|
941
|
+
size,
|
|
942
|
+
previousSize,
|
|
943
|
+
completeImmediately
|
|
944
|
+
}) => {
|
|
945
|
+
this.elementRef.nativeElement.classList.add(OVERLAY_ACTIVE_CLASS);
|
|
946
|
+
this._applySize(size, previousSize);
|
|
947
|
+
if (completeImmediately) {
|
|
948
|
+
this._completeResizeOperation();
|
|
949
|
+
}
|
|
950
|
+
});
|
|
951
|
+
merge(this.resizeNotifier.resizeCanceled, this.resizeNotifier.resizeCompleted).pipe(takeUntilDestroyed).subscribe(columnSize => {
|
|
952
|
+
this._cleanUpAfterResize(columnSize);
|
|
953
|
+
});
|
|
954
|
+
this.resizeNotifier.resizeCompleted.pipe(filter(sizeUpdate => sizeUpdate.columnId === this.columnDef.name), distinctUntilChanged((a, b) => a.size === b.size), takeUntil(this.destroyed)).subscribe(sizeUpdate => {
|
|
955
|
+
this.columnSizeStore?.setSize(this.columnResize.getTableId(), this.columnDef.name, sizeUpdate.size);
|
|
956
|
+
});
|
|
957
|
+
}
|
|
958
|
+
_completeResizeOperation() {
|
|
959
|
+
this.ngZone.run(() => {
|
|
960
|
+
this.resizeNotifier.resizeCompleted.next({
|
|
961
|
+
columnId: this.columnDef.name,
|
|
962
|
+
size: this.elementRef.nativeElement.offsetWidth
|
|
963
|
+
});
|
|
964
|
+
});
|
|
965
|
+
}
|
|
966
|
+
_cleanUpAfterResize(columnSize) {
|
|
967
|
+
this.elementRef.nativeElement.classList.remove(OVERLAY_ACTIVE_CLASS);
|
|
968
|
+
if (this.overlayRef && this.overlayRef.hasAttached()) {
|
|
969
|
+
this._updateOverlayHandleHeight();
|
|
970
|
+
this.overlayRef.updatePosition();
|
|
971
|
+
if (columnSize.columnId === this.columnDef.name) {
|
|
972
|
+
this.inlineHandle.focus();
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
_createHandlePortal() {
|
|
977
|
+
const injector = Injector.create({
|
|
978
|
+
parent: this.injector,
|
|
979
|
+
providers: [{
|
|
980
|
+
provide: ResizeRef,
|
|
981
|
+
useValue: new ResizeRef(this.elementRef, this.overlayRef, this.minWidthPx, this.maxWidthPx, this.columnResize.liveResizeUpdates)
|
|
982
|
+
}]
|
|
983
|
+
});
|
|
984
|
+
return new ComponentPortal(this.getOverlayHandleComponentType(), this.viewContainerRef, injector);
|
|
985
|
+
}
|
|
986
|
+
_showHandleOverlay() {
|
|
987
|
+
this._updateOverlayHandleHeight();
|
|
988
|
+
this.overlayRef.attach(this._createHandlePortal());
|
|
989
|
+
this.changeDetectorRef.markForCheck();
|
|
990
|
+
}
|
|
991
|
+
_updateOverlayHandleHeight() {
|
|
992
|
+
runInInjectionContext(this.injector, () => {
|
|
993
|
+
afterNextRender({
|
|
994
|
+
write: () => {
|
|
995
|
+
this.overlayRef.updateSize({
|
|
996
|
+
height: this.elementRef.nativeElement.offsetHeight
|
|
997
|
+
});
|
|
831
998
|
}
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
this.resizeStrategy.applyMinColumnSize(this.columnDef.cssClassFriendlyName, this.elementRef.nativeElement, this.minWidthPx);
|
|
866
|
-
}
|
|
867
|
-
_applyMaxWidthPx() {
|
|
868
|
-
this.resizeStrategy.applyMaxColumnSize(this.columnDef.cssClassFriendlyName, this.elementRef.nativeElement, this.maxWidthPx);
|
|
869
|
-
}
|
|
870
|
-
_appendInlineHandle() {
|
|
871
|
-
this.inlineHandle = this.document.createElement('div');
|
|
872
|
-
// TODO: re-apply tab index once this element has behavior.
|
|
873
|
-
// this.inlineHandle.tabIndex = 0;
|
|
874
|
-
this.inlineHandle.className = this.getInlineHandleCssClassName();
|
|
875
|
-
// TODO: Apply correct aria role (probably slider) after a11y spec questions resolved.
|
|
876
|
-
this.elementRef.nativeElement.appendChild(this.inlineHandle);
|
|
877
|
-
}
|
|
878
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: Resizable, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
879
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.2.0-next.2", type: Resizable, isStandalone: true, ngImport: i0 });
|
|
999
|
+
});
|
|
1000
|
+
});
|
|
1001
|
+
}
|
|
1002
|
+
_applySize(sizeInPixels, previousSize) {
|
|
1003
|
+
const sizeToApply = Math.min(Math.max(sizeInPixels, this.minWidthPx, 0), this.maxWidthPx);
|
|
1004
|
+
this.resizeStrategy.applyColumnSize(this.columnDef.cssClassFriendlyName, this.elementRef.nativeElement, sizeToApply, previousSize);
|
|
1005
|
+
}
|
|
1006
|
+
_applyMinWidthPx() {
|
|
1007
|
+
this.resizeStrategy.applyMinColumnSize(this.columnDef.cssClassFriendlyName, this.elementRef.nativeElement, this.minWidthPx);
|
|
1008
|
+
}
|
|
1009
|
+
_applyMaxWidthPx() {
|
|
1010
|
+
this.resizeStrategy.applyMaxColumnSize(this.columnDef.cssClassFriendlyName, this.elementRef.nativeElement, this.maxWidthPx);
|
|
1011
|
+
}
|
|
1012
|
+
_appendInlineHandle() {
|
|
1013
|
+
this.inlineHandle = this.document.createElement('div');
|
|
1014
|
+
this.inlineHandle.className = this.getInlineHandleCssClassName();
|
|
1015
|
+
this.elementRef.nativeElement.appendChild(this.inlineHandle);
|
|
1016
|
+
}
|
|
1017
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
1018
|
+
minVersion: "12.0.0",
|
|
1019
|
+
version: "20.2.0-next.2",
|
|
1020
|
+
ngImport: i0,
|
|
1021
|
+
type: Resizable,
|
|
1022
|
+
deps: [],
|
|
1023
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
1024
|
+
});
|
|
1025
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
1026
|
+
minVersion: "14.0.0",
|
|
1027
|
+
version: "20.2.0-next.2",
|
|
1028
|
+
type: Resizable,
|
|
1029
|
+
isStandalone: true,
|
|
1030
|
+
ngImport: i0
|
|
1031
|
+
});
|
|
880
1032
|
}
|
|
881
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
882
|
-
|
|
883
|
-
|
|
1033
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1034
|
+
minVersion: "12.0.0",
|
|
1035
|
+
version: "20.2.0-next.2",
|
|
1036
|
+
ngImport: i0,
|
|
1037
|
+
type: Resizable,
|
|
1038
|
+
decorators: [{
|
|
1039
|
+
type: Directive
|
|
1040
|
+
}]
|
|
1041
|
+
});
|
|
884
1042
|
|
|
885
|
-
// TODO: Take another look at using cdk drag drop. IIRC I ran into a couple
|
|
886
|
-
// good reasons for not using it but I don't remember what they were at this point.
|
|
887
|
-
/**
|
|
888
|
-
* Base class for a component shown over the edge of a resizable column that is responsible
|
|
889
|
-
* for handling column resize mouse events and displaying any visible UI on the column edge.
|
|
890
|
-
*/
|
|
891
1043
|
class ResizeOverlayHandle {
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
1044
|
+
_renderer = inject(Renderer2);
|
|
1045
|
+
destroyed = new Subject();
|
|
1046
|
+
_cumulativeDeltaX = 0;
|
|
1047
|
+
ngAfterViewInit() {
|
|
1048
|
+
this._listenForMouseEvents();
|
|
1049
|
+
}
|
|
1050
|
+
ngOnDestroy() {
|
|
1051
|
+
this.destroyed.next();
|
|
1052
|
+
this.destroyed.complete();
|
|
1053
|
+
}
|
|
1054
|
+
_listenForMouseEvents() {
|
|
1055
|
+
this.ngZone.runOutsideAngular(() => {
|
|
1056
|
+
this._observableFromEvent(this.elementRef.nativeElement, 'mouseenter').pipe(mapTo(this.resizeRef.origin.nativeElement), takeUntil(this.destroyed)).subscribe(cell => this.eventDispatcher.headerCellHovered.next(cell));
|
|
1057
|
+
this._observableFromEvent(this.elementRef.nativeElement, 'mouseleave').pipe(map(event => event.relatedTarget && closest(event.relatedTarget, HEADER_CELL_SELECTOR)), takeUntil(this.destroyed)).subscribe(cell => this.eventDispatcher.headerCellHovered.next(cell));
|
|
1058
|
+
this._observableFromEvent(this.elementRef.nativeElement, 'mousedown').pipe(takeUntil(this.destroyed)).subscribe(mousedownEvent => {
|
|
1059
|
+
this._dragStarted(mousedownEvent);
|
|
1060
|
+
});
|
|
1061
|
+
});
|
|
1062
|
+
}
|
|
1063
|
+
_dragStarted(mousedownEvent) {
|
|
1064
|
+
if (mousedownEvent.button !== 0) {
|
|
1065
|
+
return;
|
|
1066
|
+
}
|
|
1067
|
+
const mouseup = this._observableFromEvent(this.document, 'mouseup');
|
|
1068
|
+
const mousemove = this._observableFromEvent(this.document, 'mousemove');
|
|
1069
|
+
const escape = this._observableFromEvent(this.document, 'keyup').pipe(filter(event => event.keyCode === ESCAPE));
|
|
1070
|
+
const startX = mousedownEvent.screenX;
|
|
1071
|
+
const initialSize = this._getOriginWidth();
|
|
1072
|
+
let overlayOffset = 0;
|
|
1073
|
+
let originOffset = this._getOriginOffset();
|
|
1074
|
+
let size = initialSize;
|
|
1075
|
+
let overshot = 0;
|
|
1076
|
+
this._cumulativeDeltaX = 0;
|
|
1077
|
+
this.updateResizeActive(true);
|
|
1078
|
+
mouseup.pipe(takeUntil(merge(escape, this.destroyed))).subscribe(({
|
|
1079
|
+
screenX
|
|
1080
|
+
}) => {
|
|
1081
|
+
this.styleScheduler.scheduleEnd(() => {
|
|
1082
|
+
this._notifyResizeEnded(size, screenX !== startX);
|
|
1083
|
+
});
|
|
1084
|
+
});
|
|
1085
|
+
escape.pipe(takeUntil(merge(mouseup, this.destroyed))).subscribe(() => {
|
|
1086
|
+
this._notifyResizeEnded(initialSize);
|
|
1087
|
+
});
|
|
1088
|
+
mousemove.pipe(map(({
|
|
1089
|
+
screenX
|
|
1090
|
+
}) => screenX), startWith(startX), distinctUntilChanged(), pairwise(), takeUntil(merge(mouseup, escape, this.destroyed))).subscribe(([prevX, currX]) => {
|
|
1091
|
+
let deltaX = currX - prevX;
|
|
1092
|
+
if (!this.resizeRef.liveUpdates) {
|
|
1093
|
+
this._cumulativeDeltaX += deltaX;
|
|
1094
|
+
const sizeDelta = this._computeNewSize(size, this._cumulativeDeltaX) - size;
|
|
1095
|
+
this._updateOverlayOffset(sizeDelta);
|
|
1096
|
+
return;
|
|
1097
|
+
}
|
|
1098
|
+
if (overshot !== 0) {
|
|
1099
|
+
if (overshot < 0 && deltaX < 0 || overshot > 0 && deltaX > 0) {
|
|
1100
|
+
overshot += deltaX;
|
|
1101
|
+
return;
|
|
1102
|
+
} else {
|
|
1103
|
+
const remainingOvershot = overshot + deltaX;
|
|
1104
|
+
overshot = overshot > 0 ? Math.max(remainingOvershot, 0) : Math.min(remainingOvershot, 0);
|
|
1105
|
+
deltaX = remainingOvershot - overshot;
|
|
1106
|
+
if (deltaX === 0) {
|
|
920
1107
|
return;
|
|
1108
|
+
}
|
|
921
1109
|
}
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
const
|
|
926
|
-
const
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
this.
|
|
932
|
-
this.
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
_isLtr() {
|
|
1008
|
-
return this.directionality.value === 'ltr';
|
|
1009
|
-
}
|
|
1010
|
-
_notifyResizeEnded(size, completedSuccessfully = false) {
|
|
1011
|
-
this.updateResizeActive(false);
|
|
1012
|
-
this.ngZone.run(() => {
|
|
1013
|
-
const sizeMessage = {
|
|
1014
|
-
columnId: this.columnDef.name,
|
|
1015
|
-
size: this._computeNewSize(size, this._cumulativeDeltaX),
|
|
1016
|
-
};
|
|
1017
|
-
if (completedSuccessfully) {
|
|
1018
|
-
if (!this.resizeRef.liveUpdates) {
|
|
1019
|
-
this._triggerResize(size, this._cumulativeDeltaX);
|
|
1020
|
-
}
|
|
1021
|
-
this.resizeNotifier.resizeCompleted.next(sizeMessage);
|
|
1022
|
-
}
|
|
1023
|
-
else {
|
|
1024
|
-
this.resizeNotifier.resizeCanceled.next(sizeMessage);
|
|
1025
|
-
}
|
|
1026
|
-
});
|
|
1027
|
-
}
|
|
1028
|
-
_observableFromEvent(element, name) {
|
|
1029
|
-
return new Observable(subscriber => {
|
|
1030
|
-
const handler = (event) => subscriber.next(event);
|
|
1031
|
-
const cleanup = this._renderer.listen(element, name, handler);
|
|
1032
|
-
return () => {
|
|
1033
|
-
cleanup();
|
|
1034
|
-
subscriber.complete();
|
|
1035
|
-
};
|
|
1036
|
-
});
|
|
1037
|
-
}
|
|
1038
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: ResizeOverlayHandle, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1039
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.2.0-next.2", type: ResizeOverlayHandle, isStandalone: true, ngImport: i0 });
|
|
1110
|
+
}
|
|
1111
|
+
this._triggerResize(size, deltaX);
|
|
1112
|
+
this.styleScheduler.scheduleEnd(() => {
|
|
1113
|
+
const originNewSize = this._getOriginWidth();
|
|
1114
|
+
const originNewOffset = this._getOriginOffset();
|
|
1115
|
+
const originOffsetDeltaX = originNewOffset - originOffset;
|
|
1116
|
+
const originSizeDeltaX = originNewSize - size;
|
|
1117
|
+
size = originNewSize;
|
|
1118
|
+
originOffset = originNewOffset;
|
|
1119
|
+
overshot += deltaX + (this._isLtr() ? -originSizeDeltaX : originSizeDeltaX);
|
|
1120
|
+
overlayOffset += originOffsetDeltaX + (this._isLtr() ? originSizeDeltaX : 0);
|
|
1121
|
+
this._updateOverlayOffset(overlayOffset);
|
|
1122
|
+
});
|
|
1123
|
+
});
|
|
1124
|
+
}
|
|
1125
|
+
updateResizeActive(active) {
|
|
1126
|
+
this.eventDispatcher.overlayHandleActiveForCell.next(active ? this.resizeRef.origin.nativeElement : null);
|
|
1127
|
+
}
|
|
1128
|
+
_triggerResize(startSize, deltaX) {
|
|
1129
|
+
this.resizeNotifier.triggerResize.next({
|
|
1130
|
+
columnId: this.columnDef.name,
|
|
1131
|
+
size: this._computeNewSize(startSize, deltaX),
|
|
1132
|
+
previousSize: startSize,
|
|
1133
|
+
isStickyColumn: this.columnDef.sticky || this.columnDef.stickyEnd
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
_computeNewSize(startSize, deltaX) {
|
|
1137
|
+
let computedNewSize = startSize + (this._isLtr() ? deltaX : -deltaX);
|
|
1138
|
+
computedNewSize = Math.min(Math.max(computedNewSize, this.resizeRef.minWidthPx, 0), this.resizeRef.maxWidthPx);
|
|
1139
|
+
return computedNewSize;
|
|
1140
|
+
}
|
|
1141
|
+
_getOriginWidth() {
|
|
1142
|
+
return this.resizeRef.origin.nativeElement.offsetWidth;
|
|
1143
|
+
}
|
|
1144
|
+
_getOriginOffset() {
|
|
1145
|
+
return this.resizeRef.origin.nativeElement.offsetLeft;
|
|
1146
|
+
}
|
|
1147
|
+
_updateOverlayOffset(offset) {
|
|
1148
|
+
this.resizeRef.overlayRef.overlayElement.style.transform = `translateX(${coerceCssPixelValue(offset)})`;
|
|
1149
|
+
}
|
|
1150
|
+
_isLtr() {
|
|
1151
|
+
return this.directionality.value === 'ltr';
|
|
1152
|
+
}
|
|
1153
|
+
_notifyResizeEnded(size, completedSuccessfully = false) {
|
|
1154
|
+
this.updateResizeActive(false);
|
|
1155
|
+
this.ngZone.run(() => {
|
|
1156
|
+
const sizeMessage = {
|
|
1157
|
+
columnId: this.columnDef.name,
|
|
1158
|
+
size: this._computeNewSize(size, this._cumulativeDeltaX)
|
|
1159
|
+
};
|
|
1160
|
+
if (completedSuccessfully) {
|
|
1161
|
+
if (!this.resizeRef.liveUpdates) {
|
|
1162
|
+
this._triggerResize(size, this._cumulativeDeltaX);
|
|
1163
|
+
}
|
|
1164
|
+
this.resizeNotifier.resizeCompleted.next(sizeMessage);
|
|
1165
|
+
} else {
|
|
1166
|
+
this.resizeNotifier.resizeCanceled.next(sizeMessage);
|
|
1167
|
+
}
|
|
1168
|
+
});
|
|
1169
|
+
}
|
|
1170
|
+
_observableFromEvent(element, name) {
|
|
1171
|
+
return new Observable(subscriber => {
|
|
1172
|
+
const handler = event => subscriber.next(event);
|
|
1173
|
+
const cleanup = this._renderer.listen(element, name, handler);
|
|
1174
|
+
return () => {
|
|
1175
|
+
cleanup();
|
|
1176
|
+
subscriber.complete();
|
|
1177
|
+
};
|
|
1178
|
+
});
|
|
1179
|
+
}
|
|
1180
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
1181
|
+
minVersion: "12.0.0",
|
|
1182
|
+
version: "20.2.0-next.2",
|
|
1183
|
+
ngImport: i0,
|
|
1184
|
+
type: ResizeOverlayHandle,
|
|
1185
|
+
deps: [],
|
|
1186
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
1187
|
+
});
|
|
1188
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
1189
|
+
minVersion: "14.0.0",
|
|
1190
|
+
version: "20.2.0-next.2",
|
|
1191
|
+
type: ResizeOverlayHandle,
|
|
1192
|
+
isStandalone: true,
|
|
1193
|
+
ngImport: i0
|
|
1194
|
+
});
|
|
1040
1195
|
}
|
|
1041
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
1042
|
-
|
|
1043
|
-
|
|
1196
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1197
|
+
minVersion: "12.0.0",
|
|
1198
|
+
version: "20.2.0-next.2",
|
|
1199
|
+
ngImport: i0,
|
|
1200
|
+
type: ResizeOverlayHandle,
|
|
1201
|
+
decorators: [{
|
|
1202
|
+
type: Directive
|
|
1203
|
+
}]
|
|
1204
|
+
});
|
|
1044
1205
|
|
|
1045
1206
|
export { COLUMN_RESIZE_OPTIONS, CdkColumnResize, CdkColumnResizeDefaultEnabledModule, CdkColumnResizeFlex, CdkColumnResizeModule, CdkDefaultEnabledColumnResize, CdkDefaultEnabledColumnResizeFlex, CdkFlexTableResizeStrategy, ColumnResize, ColumnResizeNotifier, ColumnResizeNotifierSource, ColumnSizeStore, FLEX_RESIZE_STRATEGY_PROVIDER, HeaderRowEventDispatcher, Resizable, ResizeOverlayHandle, ResizeRef, ResizeStrategy, TABLE_LAYOUT_FIXED_RESIZE_STRATEGY_PROVIDER, TableLayoutFixedResizeStrategy, _COALESCED_STYLE_SCHEDULER, _CoalescedStyleScheduler, _Schedule };
|
|
1046
1207
|
//# sourceMappingURL=column-resize.mjs.map
|