@angular/cdk-experimental 16.0.0-next.4 → 16.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.
Files changed (108) hide show
  1. package/combobox/index.d.ts +2 -2
  2. package/{esm2020 → esm2022}/column-resize/column-resize-directives/column-resize-flex.mjs +4 -4
  3. package/{esm2020 → esm2022}/column-resize/column-resize-directives/column-resize.mjs +4 -4
  4. package/{esm2020 → esm2022}/column-resize/column-resize-directives/default-enabled-column-resize-flex.mjs +7 -7
  5. package/{esm2020 → esm2022}/column-resize/column-resize-directives/default-enabled-column-resize.mjs +7 -7
  6. package/{esm2020 → esm2022}/column-resize/column-resize-module.mjs +9 -9
  7. package/{esm2020 → esm2022}/column-resize/column-resize-notifier.mjs +7 -7
  8. package/{esm2020 → esm2022}/column-resize/column-resize.mjs +4 -4
  9. package/{esm2020 → esm2022}/column-resize/column-size-store.mjs +4 -4
  10. package/{esm2020 → esm2022}/column-resize/event-dispatcher.mjs +4 -4
  11. package/{esm2020 → esm2022}/column-resize/overlay-handle.mjs +4 -4
  12. package/{esm2020 → esm2022}/column-resize/resizable.mjs +4 -4
  13. package/{esm2020 → esm2022}/column-resize/resize-strategy.mjs +10 -10
  14. package/{esm2020 → esm2022}/combobox/combobox-module.mjs +5 -5
  15. package/{esm2020 → esm2022}/combobox/combobox-popup.mjs +4 -4
  16. package/{esm2020 → esm2022}/combobox/combobox.mjs +4 -4
  17. package/{esm2020 → esm2022}/popover-edit/edit-event-dispatcher.mjs +4 -4
  18. package/{esm2020 → esm2022}/popover-edit/edit-ref.mjs +4 -4
  19. package/{esm2020 → esm2022}/popover-edit/edit-services.mjs +4 -4
  20. package/{esm2020 → esm2022}/popover-edit/focus-dispatcher.mjs +4 -4
  21. package/{esm2020 → esm2022}/popover-edit/focus-escape-notifier.mjs +4 -4
  22. package/{esm2020 → esm2022}/popover-edit/lens-directives.mjs +10 -10
  23. package/esm2022/popover-edit/popover-edit-module.mjs +63 -0
  24. package/{esm2020 → esm2022}/popover-edit/popover-edit-position-strategy-factory.mjs +7 -7
  25. package/esm2022/popover-edit/table-directives.mjs +400 -0
  26. package/{esm2020 → esm2022}/scrolling/auto-size-virtual-scroll.mjs +10 -10
  27. package/{esm2020 → esm2022}/scrolling/scrolling-module.mjs +5 -5
  28. package/esm2022/selection/row-selection.mjs +52 -0
  29. package/esm2022/selection/select-all.mjs +101 -0
  30. package/{esm2020 → esm2022}/selection/selection-column.mjs +6 -6
  31. package/{esm2020 → esm2022}/selection/selection-module.mjs +9 -9
  32. package/esm2022/selection/selection-toggle.mjs +101 -0
  33. package/{esm2020 → esm2022}/selection/selection.mjs +4 -4
  34. package/{esm2020 → esm2022}/table-scroll-container/table-scroll-container-module.mjs +5 -5
  35. package/{esm2020 → esm2022}/table-scroll-container/table-scroll-container.mjs +4 -4
  36. package/{esm2020 → esm2022}/version.mjs +1 -1
  37. package/fesm2022/cdk-experimental.mjs +7 -0
  38. package/fesm2022/cdk-experimental.mjs.map +1 -0
  39. package/{fesm2020 → fesm2022}/column-resize.mjs +56 -177
  40. package/fesm2022/column-resize.mjs.map +1 -0
  41. package/{fesm2020 → fesm2022}/combobox.mjs +10 -47
  42. package/fesm2022/combobox.mjs.map +1 -0
  43. package/{fesm2020 → fesm2022}/popover-edit.mjs +70 -164
  44. package/fesm2022/popover-edit.mjs.map +1 -0
  45. package/{fesm2020 → fesm2022}/scrolling.mjs +13 -43
  46. package/fesm2022/scrolling.mjs.map +1 -0
  47. package/{fesm2020 → fesm2022}/selection.mjs +30 -103
  48. package/fesm2022/selection.mjs.map +1 -0
  49. package/{fesm2020 → fesm2022}/table-scroll-container.mjs +7 -37
  50. package/fesm2022/table-scroll-container.mjs.map +1 -0
  51. package/package.json +24 -42
  52. package/popover-edit/index.d.ts +4 -4
  53. package/scrolling/index.d.ts +1 -1
  54. package/selection/index.d.ts +4 -4
  55. package/esm2020/popover-edit/popover-edit-module.mjs +0 -63
  56. package/esm2020/popover-edit/table-directives.mjs +0 -401
  57. package/esm2020/selection/row-selection.mjs +0 -50
  58. package/esm2020/selection/select-all.mjs +0 -110
  59. package/esm2020/selection/selection-toggle.mjs +0 -102
  60. package/fesm2015/cdk-experimental.mjs +0 -30
  61. package/fesm2015/cdk-experimental.mjs.map +0 -1
  62. package/fesm2015/column-resize.mjs +0 -1028
  63. package/fesm2015/column-resize.mjs.map +0 -1
  64. package/fesm2015/combobox.mjs +0 -396
  65. package/fesm2015/combobox.mjs.map +0 -1
  66. package/fesm2015/popover-edit.mjs +0 -1230
  67. package/fesm2015/popover-edit.mjs.map +0 -1
  68. package/fesm2015/scrolling.mjs +0 -464
  69. package/fesm2015/scrolling.mjs.map +0 -1
  70. package/fesm2015/selection.mjs +0 -693
  71. package/fesm2015/selection.mjs.map +0 -1
  72. package/fesm2015/table-scroll-container.mjs +0 -177
  73. package/fesm2015/table-scroll-container.mjs.map +0 -1
  74. package/fesm2020/cdk-experimental.mjs +0 -30
  75. package/fesm2020/cdk-experimental.mjs.map +0 -1
  76. package/fesm2020/column-resize.mjs.map +0 -1
  77. package/fesm2020/combobox.mjs.map +0 -1
  78. package/fesm2020/popover-edit.mjs.map +0 -1
  79. package/fesm2020/scrolling.mjs.map +0 -1
  80. package/fesm2020/selection.mjs.map +0 -1
  81. package/fesm2020/table-scroll-container.mjs.map +0 -1
  82. /package/{esm2020 → esm2022}/column-resize/column-resize-directives/constants.mjs +0 -0
  83. /package/{esm2020 → esm2022}/column-resize/column-resize_public_index.mjs +0 -0
  84. /package/{esm2020 → esm2022}/column-resize/index.mjs +0 -0
  85. /package/{esm2020 → esm2022}/column-resize/public-api.mjs +0 -0
  86. /package/{esm2020 → esm2022}/column-resize/resize-ref.mjs +0 -0
  87. /package/{esm2020 → esm2022}/column-resize/selectors.mjs +0 -0
  88. /package/{esm2020 → esm2022}/combobox/combobox_public_index.mjs +0 -0
  89. /package/{esm2020 → esm2022}/combobox/index.mjs +0 -0
  90. /package/{esm2020 → esm2022}/combobox/public-api.mjs +0 -0
  91. /package/{esm2020 → esm2022}/index.mjs +0 -0
  92. /package/{esm2020 → esm2022}/popover-edit/constants.mjs +0 -0
  93. /package/{esm2020 → esm2022}/popover-edit/form-value-container.mjs +0 -0
  94. /package/{esm2020 → esm2022}/popover-edit/index.mjs +0 -0
  95. /package/{esm2020 → esm2022}/popover-edit/polyfill.mjs +0 -0
  96. /package/{esm2020 → esm2022}/popover-edit/popover-edit_public_index.mjs +0 -0
  97. /package/{esm2020 → esm2022}/popover-edit/public-api.mjs +0 -0
  98. /package/{esm2020 → esm2022}/public-api.mjs +0 -0
  99. /package/{esm2020 → esm2022}/scrolling/index.mjs +0 -0
  100. /package/{esm2020 → esm2022}/scrolling/public-api.mjs +0 -0
  101. /package/{esm2020 → esm2022}/scrolling/scrolling_public_index.mjs +0 -0
  102. /package/{esm2020 → esm2022}/selection/index.mjs +0 -0
  103. /package/{esm2020 → esm2022}/selection/public-api.mjs +0 -0
  104. /package/{esm2020 → esm2022}/selection/selection-set.mjs +0 -0
  105. /package/{esm2020 → esm2022}/selection/selection_public_index.mjs +0 -0
  106. /package/{esm2020 → esm2022}/table-scroll-container/index.mjs +0 -0
  107. /package/{esm2020 → esm2022}/table-scroll-container/public-api.mjs +0 -0
  108. /package/{esm2020 → esm2022}/table-scroll-container/table-scroll-container_public_index.mjs +0 -0
@@ -1,1230 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { Injectable, Self, EventEmitter, Directive, Input, Inject, NgModule } from '@angular/core';
3
- import { Subject, pipe, combineLatest, Observable, fromEvent, fromEventPattern, merge } from 'rxjs';
4
- import { distinctUntilChanged, startWith, shareReplay, filter, map, auditTime, audit, debounceTime, skip, take, takeUntil, mapTo, throttleTime, share, withLatestFrom } from 'rxjs/operators';
5
- import * as i1 from '@angular/forms';
6
- import { RIGHT_ARROW, LEFT_ARROW, DOWN_ARROW, UP_ARROW, hasModifierKey } from '@angular/cdk/keycodes';
7
- import * as i1$1 from '@angular/cdk/bidi';
8
- import * as i2 from '@angular/cdk/overlay';
9
- import { OverlayModule } from '@angular/cdk/overlay';
10
- import { TemplatePortal } from '@angular/cdk/portal';
11
- import * as i4 from '@angular/cdk/a11y';
12
- import { FocusTrap } from '@angular/cdk/a11y';
13
- import * as i7 from '@angular/cdk/scrolling';
14
- import { DOCUMENT } from '@angular/common';
15
-
16
- /**
17
- * @license
18
- * Copyright Google LLC All Rights Reserved.
19
- *
20
- * Use of this source code is governed by an MIT-style license that can be
21
- * found in the LICENSE file at https://angular.io/license
22
- */
23
- /** Selector for finding table cells. */
24
- const CELL_SELECTOR = '.cdk-cell, .mat-cell, td';
25
- /** Selector for finding editable table cells. */
26
- const EDITABLE_CELL_SELECTOR = '.cdk-popover-edit-cell, .mat-popover-edit-cell';
27
- /** Selector for finding table rows. */
28
- const ROW_SELECTOR = '.cdk-row, .mat-row, tr';
29
- /** Selector for finding the table element. */
30
- const TABLE_SELECTOR = 'table, cdk-table, mat-table';
31
- /** CSS class added to the edit lens pane. */
32
- const EDIT_PANE_CLASS = 'cdk-edit-pane';
33
- /** Selector for finding the edit lens pane. */
34
- const EDIT_PANE_SELECTOR = `.${EDIT_PANE_CLASS}, .mat-edit-pane`;
35
-
36
- /**
37
- * @license
38
- * Copyright Google LLC All Rights Reserved.
39
- *
40
- * Use of this source code is governed by an MIT-style license that can be
41
- * found in the LICENSE file at https://angular.io/license
42
- */
43
- /** closest implementation that is able to start from non-Element Nodes. */
44
- function closest(element, selector) {
45
- var _a;
46
- if (!(element instanceof Node)) {
47
- return null;
48
- }
49
- let curr = element;
50
- while (curr != null && !(curr instanceof Element)) {
51
- curr = curr.parentNode;
52
- }
53
- return (_a = curr === null || curr === void 0 ? void 0 : curr.closest(selector)) !== null && _a !== void 0 ? _a : null;
54
- }
55
-
56
- /**
57
- * @license
58
- * Copyright Google LLC All Rights Reserved.
59
- *
60
- * Use of this source code is governed by an MIT-style license that can be
61
- * found in the LICENSE file at https://angular.io/license
62
- */
63
- /** The delay applied to mouse events before hiding or showing hover content. */
64
- const MOUSE_EVENT_DELAY_MS = 40;
65
- /** The delay for reacting to focus/blur changes. */
66
- const FOCUS_DELAY = 0;
67
- // Note: this class is generic, rather than referencing EditRef directly, in order to avoid
68
- // circular imports. If we were to reference it here, importing the registry into the
69
- // class that is registering itself will introduce a circular import.
70
- /**
71
- * Service for sharing delegated events and state for triggering table edits.
72
- */
73
- class EditEventDispatcher {
74
- /** The EditRef for the currently active edit lens (if any). */
75
- get editRef() {
76
- return this._editRef;
77
- }
78
- constructor(_ngZone) {
79
- this._ngZone = _ngZone;
80
- /** A subject that indicates which table cell is currently editing (unless it is disabled). */
81
- this.editing = new Subject();
82
- /** A subject that indicates which table row is currently hovered. */
83
- this.hovering = new Subject();
84
- /** A subject that indicates which table row currently contains focus. */
85
- this.focused = new Subject();
86
- /** A subject that indicates all elements in the table matching ROW_SELECTOR. */
87
- this.allRows = new Subject();
88
- /** A subject that emits mouse move events from the table indicating the targeted row. */
89
- this.mouseMove = new Subject();
90
- // TODO: Use WeakSet once IE11 support is dropped.
91
- /**
92
- * Tracks the currently disabled editable cells - edit calls will be ignored
93
- * for these cells.
94
- */
95
- this.disabledCells = new WeakMap();
96
- this._editRef = null;
97
- // Optimization: Precompute common pipeable operators used per row/cell.
98
- this._distinctUntilChanged = distinctUntilChanged();
99
- this._startWithNull = startWith(null);
100
- this._distinctShare = pipe(this._distinctUntilChanged, shareReplay(1));
101
- this._startWithNullDistinct = pipe(this._startWithNull, this._distinctUntilChanged);
102
- this.editingAndEnabled = this.editing.pipe(filter(cell => cell == null || !this.disabledCells.has(cell)), shareReplay(1));
103
- /** An observable that emits the row containing focus or an active edit. */
104
- this.editingOrFocused = combineLatest([
105
- this.editingAndEnabled.pipe(map(cell => closest(cell, ROW_SELECTOR)), this._startWithNull),
106
- this.focused.pipe(this._startWithNull),
107
- ]).pipe(map(([editingRow, focusedRow]) => focusedRow || editingRow), this._distinctUntilChanged, auditTime(FOCUS_DELAY), // Use audit to skip over blur events to the next focused element.
108
- this._distinctUntilChanged, shareReplay(1));
109
- /** Tracks rows that contain hover content with a reference count. */
110
- this._rowsWithHoverContent = new WeakMap();
111
- /** The table cell that has an active edit lens (or null). */
112
- this._currentlyEditing = null;
113
- /** The combined set of row hover content states organized by row. */
114
- this._hoveredContentStateDistinct = combineLatest([
115
- this._getFirstRowWithHoverContent(),
116
- this._getLastRowWithHoverContent(),
117
- this.editingOrFocused,
118
- this.hovering.pipe(distinctUntilChanged(), audit(row => this.mouseMove.pipe(filter(mouseMoveRow => row === mouseMoveRow), this._startWithNull, debounceTime(MOUSE_EVENT_DELAY_MS))), this._startWithNullDistinct),
119
- ]).pipe(skip(1), // Skip the initial emission of [null, null, null, null].
120
- map(computeHoverContentState), distinctUntilChanged(areMapEntriesEqual),
121
- // Optimization: Enter the zone before shareReplay so that we trigger a single
122
- // ApplicationRef.tick for all row updates.
123
- this._enterZone(), shareReplay(1));
124
- this._editingAndEnabledDistinct = this.editingAndEnabled.pipe(distinctUntilChanged(), this._enterZone(), shareReplay(1));
125
- // Optimization: Share row events observable with subsequent callers.
126
- // At startup, calls will be sequential by row.
127
- this._lastSeenRow = null;
128
- this._lastSeenRowHoverOrFocus = null;
129
- this._editingAndEnabledDistinct.subscribe(cell => {
130
- this._currentlyEditing = cell;
131
- });
132
- }
133
- /**
134
- * Gets an Observable that emits true when the specified element's cell
135
- * is editing and false when not.
136
- */
137
- editingCell(element) {
138
- let cell = null;
139
- return this._editingAndEnabledDistinct.pipe(map(editCell => editCell === (cell || (cell = closest(element, CELL_SELECTOR)))), this._distinctUntilChanged);
140
- }
141
- /**
142
- * Stops editing for the specified cell. If the specified cell is not the current
143
- * edit cell, does nothing.
144
- */
145
- doneEditingCell(element) {
146
- const cell = closest(element, CELL_SELECTOR);
147
- if (this._currentlyEditing === cell) {
148
- this.editing.next(null);
149
- }
150
- }
151
- /** Sets the currently active EditRef. */
152
- setActiveEditRef(ref) {
153
- this._editRef = ref;
154
- }
155
- /** Unset the currently active EditRef, if the specified editRef is active. */
156
- unsetActiveEditRef(ref) {
157
- if (this._editRef !== ref) {
158
- return;
159
- }
160
- this._editRef = null;
161
- }
162
- /** Adds the specified table row to be tracked for first/last row comparisons. */
163
- registerRowWithHoverContent(row) {
164
- this._rowsWithHoverContent.set(row, (this._rowsWithHoverContent.get(row) || 0) + 1);
165
- }
166
- /**
167
- * Reference decrements and ultimately removes the specified table row from first/last row
168
- * comparisons.
169
- */
170
- deregisterRowWithHoverContent(row) {
171
- const refCount = this._rowsWithHoverContent.get(row) || 0;
172
- if (refCount <= 1) {
173
- this._rowsWithHoverContent.delete(row);
174
- }
175
- else {
176
- this._rowsWithHoverContent.set(row, refCount - 1);
177
- }
178
- }
179
- /**
180
- * Gets an Observable that emits true when the specified element's row
181
- * contains the focused element or is being hovered over and false when not.
182
- * Hovering is defined as when the mouse has momentarily stopped moving over the cell.
183
- */
184
- hoverOrFocusOnRow(row) {
185
- if (row !== this._lastSeenRow) {
186
- this._lastSeenRow = row;
187
- this._lastSeenRowHoverOrFocus = this._hoveredContentStateDistinct.pipe(map(state => state.get(row) || 0 /* HoverContentState.OFF */), this._distinctShare);
188
- }
189
- return this._lastSeenRowHoverOrFocus;
190
- }
191
- /**
192
- * RxJS operator that enters the Angular zone, used to reduce boilerplate in
193
- * re-entering the zone for stream pipelines.
194
- */
195
- _enterZone() {
196
- return (source) => new Observable(observer => source.subscribe({
197
- next: value => this._ngZone.run(() => observer.next(value)),
198
- error: err => observer.error(err),
199
- complete: () => observer.complete(),
200
- }));
201
- }
202
- _getFirstRowWithHoverContent() {
203
- return this._mapAllRowsToSingleRow(rows => {
204
- for (let i = 0, row; (row = rows[i]); i++) {
205
- if (this._rowsWithHoverContent.has(row)) {
206
- return row;
207
- }
208
- }
209
- return null;
210
- });
211
- }
212
- _getLastRowWithHoverContent() {
213
- return this._mapAllRowsToSingleRow(rows => {
214
- for (let i = rows.length - 1, row; (row = rows[i]); i--) {
215
- if (this._rowsWithHoverContent.has(row)) {
216
- return row;
217
- }
218
- }
219
- return null;
220
- });
221
- }
222
- _mapAllRowsToSingleRow(mapper) {
223
- return this.allRows.pipe(map(mapper), this._startWithNullDistinct);
224
- }
225
- }
226
- EditEventDispatcher.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: EditEventDispatcher, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable });
227
- EditEventDispatcher.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: EditEventDispatcher });
228
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: EditEventDispatcher, decorators: [{
229
- type: Injectable
230
- }], ctorParameters: function () { return [{ type: i0.NgZone }]; } });
231
- function computeHoverContentState([firstRow, lastRow, activeRow, hoverRow,]) {
232
- const hoverContentState = new Map();
233
- // Add focusable rows.
234
- for (const focussableRow of [
235
- firstRow,
236
- lastRow,
237
- activeRow && activeRow.previousElementSibling,
238
- activeRow && activeRow.nextElementSibling,
239
- ]) {
240
- if (focussableRow) {
241
- hoverContentState.set(focussableRow, 1 /* HoverContentState.FOCUSABLE */);
242
- }
243
- }
244
- // Add/overwrite with fully visible rows.
245
- for (const onRow of [activeRow, hoverRow]) {
246
- if (onRow) {
247
- hoverContentState.set(onRow, 2 /* HoverContentState.ON */);
248
- }
249
- }
250
- return hoverContentState;
251
- }
252
- function areMapEntriesEqual(a, b) {
253
- if (a.size !== b.size) {
254
- return false;
255
- }
256
- // TODO: use Map.prototype.entries once we're off IE11.
257
- for (const aKey of Array.from(a.keys())) {
258
- if (b.get(aKey) !== a.get(aKey)) {
259
- return false;
260
- }
261
- }
262
- return true;
263
- }
264
-
265
- /**
266
- * @license
267
- * Copyright Google LLC All Rights Reserved.
268
- *
269
- * Use of this source code is governed by an MIT-style license that can be
270
- * found in the LICENSE file at https://angular.io/license
271
- */
272
- /**
273
- * Used for communication between the form within the edit lens and the
274
- * table that launched it. Provided by CdkEditControl within the lens.
275
- */
276
- class EditRef {
277
- constructor(_form, _editEventDispatcher, _ngZone) {
278
- this._form = _form;
279
- this._editEventDispatcher = _editEventDispatcher;
280
- this._ngZone = _ngZone;
281
- /** Emits the final value of this edit instance before closing. */
282
- this._finalValueSubject = new Subject();
283
- this.finalValue = this._finalValueSubject;
284
- /** Emits when the user tabs out of this edit lens before closing. */
285
- this._blurredSubject = new Subject();
286
- this.blurred = this._blurredSubject;
287
- this._editEventDispatcher.setActiveEditRef(this);
288
- }
289
- /**
290
- * Called by the host directive's OnInit hook. Reads the initial state of the
291
- * form and overrides it with persisted state from previous openings, if
292
- * applicable.
293
- */
294
- init(previousFormValue) {
295
- // Wait for the zone to stabilize before caching the initial value.
296
- // This ensures that all form controls have been initialized.
297
- this._ngZone.onStable.pipe(take(1)).subscribe(() => {
298
- this.updateRevertValue();
299
- if (previousFormValue) {
300
- this.reset(previousFormValue);
301
- }
302
- });
303
- }
304
- ngOnDestroy() {
305
- this._editEventDispatcher.unsetActiveEditRef(this);
306
- this._finalValueSubject.next(this._form.value);
307
- this._finalValueSubject.complete();
308
- }
309
- /** Whether the attached form is in a valid state. */
310
- isValid() {
311
- return this._form.valid;
312
- }
313
- /** Set the form's current value as what it will be set to on revert/reset. */
314
- updateRevertValue() {
315
- this._revertFormValue = this._form.value;
316
- }
317
- /** Tells the table to close the edit popup. */
318
- close() {
319
- this._editEventDispatcher.editing.next(null);
320
- }
321
- /** Notifies the active edit that the user has moved focus out of the lens. */
322
- blur() {
323
- this._blurredSubject.next();
324
- }
325
- /**
326
- * Resets the form value to the specified value or the previously set
327
- * revert value.
328
- */
329
- reset(value) {
330
- this._form.reset(value || this._revertFormValue);
331
- }
332
- }
333
- EditRef.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: EditRef, deps: [{ token: i1.ControlContainer, self: true }, { token: EditEventDispatcher }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable });
334
- EditRef.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: EditRef });
335
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: EditRef, decorators: [{
336
- type: Injectable
337
- }], ctorParameters: function () {
338
- return [{ type: i1.ControlContainer, decorators: [{
339
- type: Self
340
- }] }, { type: EditEventDispatcher }, { type: i0.NgZone }];
341
- } });
342
-
343
- /**
344
- * Service responsible for moving cell focus around in response to keyboard events.
345
- * May be overridden to customize the keyboard behavior of popover edit.
346
- */
347
- class FocusDispatcher {
348
- constructor(directionality) {
349
- this.directionality = directionality;
350
- this.keyObserver = { next: event => this.handleKeyboardEvent(event) };
351
- }
352
- /**
353
- * Moves focus to earlier or later cells (in dom order) by offset cells relative to
354
- * currentCell.
355
- */
356
- moveFocusHorizontally(currentCell, offset) {
357
- const cells = Array.from(closest(currentCell, TABLE_SELECTOR).querySelectorAll(EDITABLE_CELL_SELECTOR));
358
- const currentIndex = cells.indexOf(currentCell);
359
- const newIndex = currentIndex + offset;
360
- if (cells[newIndex]) {
361
- cells[newIndex].focus();
362
- }
363
- }
364
- /** Moves focus to up or down by row by offset cells relative to currentCell. */
365
- moveFocusVertically(currentCell, offset) {
366
- const currentRow = closest(currentCell, ROW_SELECTOR);
367
- const rows = Array.from(closest(currentRow, TABLE_SELECTOR).querySelectorAll(ROW_SELECTOR));
368
- const currentRowIndex = rows.indexOf(currentRow);
369
- const currentIndexWithinRow = Array.from(currentRow.querySelectorAll(EDITABLE_CELL_SELECTOR)).indexOf(currentCell);
370
- const newRowIndex = currentRowIndex + offset;
371
- if (rows[newRowIndex]) {
372
- const rowToFocus = Array.from(rows[newRowIndex].querySelectorAll(EDITABLE_CELL_SELECTOR));
373
- if (rowToFocus[currentIndexWithinRow]) {
374
- rowToFocus[currentIndexWithinRow].focus();
375
- }
376
- }
377
- }
378
- /** Translates arrow keydown events into focus move operations. */
379
- handleKeyboardEvent(event) {
380
- const cell = closest(event.target, EDITABLE_CELL_SELECTOR);
381
- if (!cell) {
382
- return;
383
- }
384
- switch (event.keyCode) {
385
- case UP_ARROW:
386
- this.moveFocusVertically(cell, -1);
387
- break;
388
- case DOWN_ARROW:
389
- this.moveFocusVertically(cell, 1);
390
- break;
391
- case LEFT_ARROW:
392
- this.moveFocusHorizontally(cell, this.directionality.value === 'ltr' ? -1 : 1);
393
- break;
394
- case RIGHT_ARROW:
395
- this.moveFocusHorizontally(cell, this.directionality.value === 'ltr' ? 1 : -1);
396
- break;
397
- default:
398
- // If the keyboard event is not handled, return now so that we don't `preventDefault`.
399
- return;
400
- }
401
- event.preventDefault();
402
- }
403
- }
404
- FocusDispatcher.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: FocusDispatcher, deps: [{ token: i1$1.Directionality }], target: i0.ɵɵFactoryTarget.Injectable });
405
- FocusDispatcher.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: FocusDispatcher, providedIn: 'root' });
406
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: FocusDispatcher, decorators: [{
407
- type: Injectable,
408
- args: [{ providedIn: 'root' }]
409
- }], ctorParameters: function () { return [{ type: i1$1.Directionality }]; } });
410
-
411
- /**
412
- * @license
413
- * Copyright Google LLC All Rights Reserved.
414
- *
415
- * Use of this source code is governed by an MIT-style license that can be
416
- * found in the LICENSE file at https://angular.io/license
417
- */
418
- /**
419
- * A convenience class for preserving unsaved form state while an edit lens is closed.
420
- *
421
- * Example usage:
422
- * class MyComponent {
423
- * readonly nameEditValues = new FormValueContainer&lt;Item, {name: string}&gt;();
424
- * }
425
- *
426
- * &lt;form cdkEditControl [(cdkEditControlPreservedFormValue)]="nameEditValues.for(item).value"&gt;
427
- */
428
- class FormValueContainer {
429
- constructor() {
430
- this._formValues = new WeakMap();
431
- }
432
- for(key) {
433
- const _formValues = this._formValues;
434
- let entry = _formValues.get(key);
435
- if (!entry) {
436
- // Expose entry as an object so that we can [(two-way)] bind to its value member
437
- entry = {};
438
- _formValues.set(key, entry);
439
- }
440
- return entry;
441
- }
442
- }
443
-
444
- /**
445
- * @license
446
- * Copyright Google LLC All Rights Reserved.
447
- *
448
- * Use of this source code is governed by an MIT-style license that can be
449
- * found in the LICENSE file at https://angular.io/license
450
- */
451
- /**
452
- * A directive that attaches to a form within the edit lens.
453
- * It coordinates the form state with the table-wide edit system and handles
454
- * closing the edit lens when the form is submitted or the user clicks
455
- * out.
456
- */
457
- class CdkEditControl {
458
- constructor(elementRef, editRef) {
459
- this.elementRef = elementRef;
460
- this.editRef = editRef;
461
- this.destroyed = new Subject();
462
- /**
463
- * Specifies what should happen when the user clicks outside of the edit lens.
464
- * The default behavior is to close the lens without submitting the form.
465
- */
466
- this.clickOutBehavior = 'close';
467
- this.preservedFormValueChange = new EventEmitter();
468
- /**
469
- * Determines whether the lens will close on form submit if the form is not in a valid
470
- * state. By default the lens will remain open.
471
- */
472
- this.ignoreSubmitUnlessValid = true;
473
- }
474
- ngOnInit() {
475
- this.editRef.init(this.preservedFormValue);
476
- this.editRef.finalValue.subscribe(this.preservedFormValueChange);
477
- this.editRef.blurred.subscribe(() => this._handleBlur());
478
- }
479
- ngOnDestroy() {
480
- this.destroyed.next();
481
- this.destroyed.complete();
482
- }
483
- /**
484
- * Called when the form submits. If ignoreSubmitUnlessValid is true, checks
485
- * the form for validity before proceeding.
486
- * Updates the revert state with the latest submitted value then closes the edit.
487
- */
488
- handleFormSubmit() {
489
- if (this.ignoreSubmitUnlessValid && !this.editRef.isValid()) {
490
- return;
491
- }
492
- this.editRef.updateRevertValue();
493
- this.editRef.close();
494
- }
495
- /** Called on Escape keyup. Closes the edit. */
496
- close() {
497
- // todo - allow this behavior to be customized as well, such as calling
498
- // reset before close
499
- this.editRef.close();
500
- }
501
- /**
502
- * Called on click anywhere in the document.
503
- * If the click was outside of the lens, trigger the specified click out behavior.
504
- */
505
- handlePossibleClickOut(evt) {
506
- if (closest(evt.target, EDIT_PANE_SELECTOR)) {
507
- return;
508
- }
509
- switch (this.clickOutBehavior) {
510
- case 'submit':
511
- // Manually cause the form to submit before closing.
512
- this._triggerFormSubmit();
513
- this.editRef.close();
514
- break;
515
- case 'close':
516
- this.editRef.close();
517
- break;
518
- default:
519
- break;
520
- }
521
- }
522
- _handleKeydown(event) {
523
- if (event.key === 'Escape' && !hasModifierKey(event)) {
524
- this.close();
525
- event.preventDefault();
526
- }
527
- }
528
- /** Triggers submit on tab out if clickOutBehavior is 'submit'. */
529
- _handleBlur() {
530
- if (this.clickOutBehavior === 'submit') {
531
- // Manually cause the form to submit before closing.
532
- this._triggerFormSubmit();
533
- }
534
- }
535
- _triggerFormSubmit() {
536
- this.elementRef.nativeElement.dispatchEvent(new Event('submit'));
537
- }
538
- }
539
- CdkEditControl.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkEditControl, deps: [{ token: i0.ElementRef }, { token: EditRef }], target: i0.ɵɵFactoryTarget.Directive });
540
- CdkEditControl.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0-next.2", type: CdkEditControl, selector: "form[cdkEditControl]", inputs: { clickOutBehavior: ["cdkEditControlClickOutBehavior", "clickOutBehavior"], preservedFormValue: ["cdkEditControlPreservedFormValue", "preservedFormValue"], ignoreSubmitUnlessValid: ["cdkEditControlIgnoreSubmitUnlessValid", "ignoreSubmitUnlessValid"] }, outputs: { preservedFormValueChange: "cdkEditControlPreservedFormValueChange" }, host: { listeners: { "ngSubmit": "handleFormSubmit()", "document:click": "handlePossibleClickOut($event)", "keydown": "_handleKeydown($event)" } }, providers: [EditRef], ngImport: i0 });
541
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkEditControl, decorators: [{
542
- type: Directive,
543
- args: [{
544
- selector: 'form[cdkEditControl]',
545
- inputs: [
546
- 'clickOutBehavior: cdkEditControlClickOutBehavior',
547
- 'preservedFormValue: cdkEditControlPreservedFormValue',
548
- 'ignoreSubmitUnlessValid: cdkEditControlIgnoreSubmitUnlessValid',
549
- ],
550
- outputs: ['preservedFormValueChange: cdkEditControlPreservedFormValueChange'],
551
- providers: [EditRef],
552
- host: {
553
- '(ngSubmit)': 'handleFormSubmit()',
554
- '(document:click)': 'handlePossibleClickOut($event)',
555
- '(keydown)': '_handleKeydown($event)',
556
- },
557
- }]
558
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: EditRef }]; } });
559
- /** Reverts the form to its initial or previously submitted state on click. */
560
- class CdkEditRevert {
561
- constructor(editRef) {
562
- this.editRef = editRef;
563
- /** Type of the button. Defaults to `button` to avoid accident form submits. */
564
- this.type = 'button';
565
- }
566
- revertEdit() {
567
- this.editRef.reset();
568
- }
569
- }
570
- CdkEditRevert.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkEditRevert, deps: [{ token: EditRef }], target: i0.ɵɵFactoryTarget.Directive });
571
- CdkEditRevert.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0-next.2", type: CdkEditRevert, selector: "button[cdkEditRevert]", inputs: { type: "type" }, host: { attributes: { "type": "button" }, listeners: { "click": "revertEdit()" } }, ngImport: i0 });
572
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkEditRevert, decorators: [{
573
- type: Directive,
574
- args: [{
575
- selector: 'button[cdkEditRevert]',
576
- host: {
577
- 'type': 'button',
578
- '(click)': 'revertEdit()',
579
- },
580
- }]
581
- }], ctorParameters: function () { return [{ type: EditRef }]; }, propDecorators: { type: [{
582
- type: Input
583
- }] } });
584
- /** Closes the lens on click. */
585
- class CdkEditClose {
586
- constructor(elementRef, editRef) {
587
- this.elementRef = elementRef;
588
- this.editRef = editRef;
589
- const nativeElement = elementRef.nativeElement;
590
- // Prevent accidental form submits.
591
- if (nativeElement.nodeName === 'BUTTON' && !nativeElement.getAttribute('type')) {
592
- nativeElement.setAttribute('type', 'button');
593
- }
594
- }
595
- closeEdit() {
596
- // Note that we use `click` here, rather than a keyboard event, because some screen readers
597
- // will emit a fake click event instead of an enter keyboard event on buttons. For the keyboard
598
- // events we use `keydown`, rather than `keyup`, because we use `keydown` to open the overlay
599
- // as well. If we were to use `keyup`, the user could end up opening and closing within
600
- // the same event sequence if focus was moved quickly.
601
- this.editRef.close();
602
- }
603
- }
604
- CdkEditClose.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkEditClose, deps: [{ token: i0.ElementRef }, { token: EditRef }], target: i0.ɵɵFactoryTarget.Directive });
605
- CdkEditClose.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0-next.2", type: CdkEditClose, selector: "[cdkEditClose]", host: { listeners: { "click": "closeEdit()", "keydown.enter": "closeEdit()", "keydown.space": "closeEdit()" } }, ngImport: i0 });
606
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkEditClose, decorators: [{
607
- type: Directive,
608
- args: [{
609
- selector: '[cdkEditClose]',
610
- host: {
611
- '(click)': 'closeEdit()',
612
- '(keydown.enter)': 'closeEdit()',
613
- '(keydown.space)': 'closeEdit()',
614
- },
615
- }]
616
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: EditRef }]; } });
617
-
618
- /**
619
- * Overridable factory responsible for configuring how cdkPopoverEdit popovers are positioned
620
- * and sized.
621
- */
622
- class PopoverEditPositionStrategyFactory {
623
- }
624
- PopoverEditPositionStrategyFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: PopoverEditPositionStrategyFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
625
- PopoverEditPositionStrategyFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: PopoverEditPositionStrategyFactory });
626
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: PopoverEditPositionStrategyFactory, decorators: [{
627
- type: Injectable
628
- }] });
629
- /**
630
- * Default implementation of PopoverEditPositionStrategyFactory.
631
- * Uses a FlexibleConnectedPositionStrategy anchored to the start + top of the cell.
632
- * Note: This will change to CoverPositionStrategy once it implemented.
633
- */
634
- class DefaultPopoverEditPositionStrategyFactory extends PopoverEditPositionStrategyFactory {
635
- constructor(direction, overlay) {
636
- super();
637
- this.direction = direction;
638
- this.overlay = overlay;
639
- }
640
- positionStrategyForCells(cells) {
641
- return this.overlay
642
- .position()
643
- .flexibleConnectedTo(cells[0])
644
- .withGrowAfterOpen()
645
- .withPush()
646
- .withViewportMargin(16)
647
- .withPositions([
648
- {
649
- originX: 'start',
650
- originY: 'top',
651
- overlayX: 'start',
652
- overlayY: 'top',
653
- },
654
- ]);
655
- }
656
- sizeConfigForCells(cells) {
657
- if (cells.length === 0) {
658
- return {};
659
- }
660
- if (cells.length === 1) {
661
- return { width: cells[0].getBoundingClientRect().width };
662
- }
663
- let firstCell, lastCell;
664
- if (this.direction.value === 'ltr') {
665
- firstCell = cells[0];
666
- lastCell = cells[cells.length - 1];
667
- }
668
- else {
669
- lastCell = cells[0];
670
- firstCell = cells[cells.length - 1];
671
- }
672
- return { width: lastCell.getBoundingClientRect().right - firstCell.getBoundingClientRect().left };
673
- }
674
- }
675
- DefaultPopoverEditPositionStrategyFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: DefaultPopoverEditPositionStrategyFactory, deps: [{ token: i1$1.Directionality }, { token: i2.Overlay }], target: i0.ɵɵFactoryTarget.Injectable });
676
- DefaultPopoverEditPositionStrategyFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: DefaultPopoverEditPositionStrategyFactory });
677
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: DefaultPopoverEditPositionStrategyFactory, decorators: [{
678
- type: Injectable
679
- }], ctorParameters: function () { return [{ type: i1$1.Directionality }, { type: i2.Overlay }]; } });
680
-
681
- /**
682
- * @license
683
- * Copyright Google LLC All Rights Reserved.
684
- *
685
- * Use of this source code is governed by an MIT-style license that can be
686
- * found in the LICENSE file at https://angular.io/license
687
- */
688
- /**
689
- * Optimization
690
- * Collects multiple Injectables into a singleton shared across the table. By reducing the
691
- * number of services injected into each CdkPopoverEdit, this saves about 0.023ms of cpu time
692
- * and 56 bytes of memory per instance.
693
- */
694
- class EditServices {
695
- constructor(directionality, editEventDispatcher, focusDispatcher, focusTrapFactory, ngZone, overlay, positionFactory, scrollDispatcher, viewportRuler) {
696
- this.directionality = directionality;
697
- this.editEventDispatcher = editEventDispatcher;
698
- this.focusDispatcher = focusDispatcher;
699
- this.focusTrapFactory = focusTrapFactory;
700
- this.ngZone = ngZone;
701
- this.overlay = overlay;
702
- this.positionFactory = positionFactory;
703
- this.scrollDispatcher = scrollDispatcher;
704
- this.viewportRuler = viewportRuler;
705
- }
706
- }
707
- EditServices.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: EditServices, deps: [{ token: i1$1.Directionality }, { token: EditEventDispatcher }, { token: FocusDispatcher }, { token: i4.FocusTrapFactory }, { token: i0.NgZone }, { token: i2.Overlay }, { token: PopoverEditPositionStrategyFactory }, { token: i7.ScrollDispatcher }, { token: i7.ViewportRuler }], target: i0.ɵɵFactoryTarget.Injectable });
708
- EditServices.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: EditServices });
709
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: EditServices, decorators: [{
710
- type: Injectable
711
- }], ctorParameters: function () { return [{ type: i1$1.Directionality }, { type: EditEventDispatcher }, { type: FocusDispatcher }, { type: i4.FocusTrapFactory }, { type: i0.NgZone }, { type: i2.Overlay }, { type: PopoverEditPositionStrategyFactory }, { type: i7.ScrollDispatcher }, { type: i7.ViewportRuler }]; } });
712
-
713
- /**
714
- * @license
715
- * Copyright Google LLC All Rights Reserved.
716
- *
717
- * Use of this source code is governed by an MIT-style license that can be
718
- * found in the LICENSE file at https://angular.io/license
719
- */
720
- /**
721
- * Like FocusTrap, but rather than trapping focus within a dom region, notifies subscribers when
722
- * focus leaves the region.
723
- */
724
- class FocusEscapeNotifier extends FocusTrap {
725
- constructor(element, checker, ngZone, document) {
726
- super(element, checker, ngZone, document, true /* deferAnchors */);
727
- this._escapeSubject = new Subject();
728
- // The focus trap adds "anchors" at the beginning and end of a trapped region that redirect
729
- // focus. We override that redirect behavior here with simply emitting on a stream.
730
- this.startAnchorListener = () => {
731
- this._escapeSubject.next(0 /* FocusEscapeNotifierDirection.START */);
732
- return true;
733
- };
734
- this.endAnchorListener = () => {
735
- this._escapeSubject.next(1 /* FocusEscapeNotifierDirection.END */);
736
- return true;
737
- };
738
- this.attachAnchors();
739
- }
740
- escapes() {
741
- return this._escapeSubject;
742
- }
743
- }
744
- /** Factory that allows easy instantiation of focus escape notifiers. */
745
- class FocusEscapeNotifierFactory {
746
- constructor(_checker, _ngZone, _document) {
747
- this._checker = _checker;
748
- this._ngZone = _ngZone;
749
- this._document = _document;
750
- }
751
- /**
752
- * Creates a focus escape notifier region around the given element.
753
- * @param element The element around which focus will be monitored.
754
- * @returns The created focus escape notifier instance.
755
- */
756
- create(element) {
757
- return new FocusEscapeNotifier(element, this._checker, this._ngZone, this._document);
758
- }
759
- }
760
- FocusEscapeNotifierFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: FocusEscapeNotifierFactory, deps: [{ token: i4.InteractivityChecker }, { token: i0.NgZone }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable });
761
- FocusEscapeNotifierFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: FocusEscapeNotifierFactory, providedIn: 'root' });
762
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: FocusEscapeNotifierFactory, decorators: [{
763
- type: Injectable,
764
- args: [{ providedIn: 'root' }]
765
- }], ctorParameters: function () {
766
- return [{ type: i4.InteractivityChecker }, { type: i0.NgZone }, { type: undefined, decorators: [{
767
- type: Inject,
768
- args: [DOCUMENT]
769
- }] }];
770
- } });
771
-
772
- /** Used for rate-limiting mousemove events. */
773
- const MOUSE_MOVE_THROTTLE_TIME_MS = 10;
774
- /**
775
- * A directive that must be attached to enable editability on a table.
776
- * It is responsible for setting up delegated event handlers and providing the
777
- * EditEventDispatcher service for use by the other edit directives.
778
- */
779
- class CdkEditable {
780
- constructor(elementRef, editEventDispatcher, focusDispatcher, ngZone) {
781
- this.elementRef = elementRef;
782
- this.editEventDispatcher = editEventDispatcher;
783
- this.focusDispatcher = focusDispatcher;
784
- this.ngZone = ngZone;
785
- this.destroyed = new Subject();
786
- }
787
- ngAfterViewInit() {
788
- this._listenForTableEvents();
789
- }
790
- ngOnDestroy() {
791
- this.destroyed.next();
792
- this.destroyed.complete();
793
- }
794
- _listenForTableEvents() {
795
- const element = this.elementRef.nativeElement;
796
- const toClosest = (selector) => map((event) => closest(event.target, selector));
797
- this.ngZone.runOutsideAngular(() => {
798
- // Track mouse movement over the table to hide/show hover content.
799
- fromEvent(element, 'mouseover')
800
- .pipe(toClosest(ROW_SELECTOR), takeUntil(this.destroyed))
801
- .subscribe(this.editEventDispatcher.hovering);
802
- fromEvent(element, 'mouseleave')
803
- .pipe(mapTo(null), takeUntil(this.destroyed))
804
- .subscribe(this.editEventDispatcher.hovering);
805
- fromEvent(element, 'mousemove')
806
- .pipe(throttleTime(MOUSE_MOVE_THROTTLE_TIME_MS), toClosest(ROW_SELECTOR), takeUntil(this.destroyed))
807
- .subscribe(this.editEventDispatcher.mouseMove);
808
- // Track focus within the table to hide/show/make focusable hover content.
809
- fromEventPattern(handler => element.addEventListener('focus', handler, true), handler => element.removeEventListener('focus', handler, true))
810
- .pipe(toClosest(ROW_SELECTOR), share(), takeUntil(this.destroyed))
811
- .subscribe(this.editEventDispatcher.focused);
812
- merge(fromEventPattern(handler => element.addEventListener('blur', handler, true), handler => element.removeEventListener('blur', handler, true)), fromEvent(element, 'keydown').pipe(filter(event => event.key === 'Escape')))
813
- .pipe(mapTo(null), share(), takeUntil(this.destroyed))
814
- .subscribe(this.editEventDispatcher.focused);
815
- // Keep track of rows within the table. This is used to know which rows with hover content
816
- // are first or last in the table. They are kept focusable in case focus enters from above
817
- // or below the table.
818
- this.ngZone.onStable
819
- .pipe(
820
- // Optimization: ignore dom changes while focus is within the table as we already
821
- // ensure that rows above and below the focused/active row are tabbable.
822
- withLatestFrom(this.editEventDispatcher.editingOrFocused), filter(([_, activeRow]) => activeRow == null), map(() => element.querySelectorAll(ROW_SELECTOR)), share(), takeUntil(this.destroyed))
823
- .subscribe(this.editEventDispatcher.allRows);
824
- fromEvent(element, 'keydown')
825
- .pipe(filter(event => event.key === 'Enter'), toClosest(CELL_SELECTOR), takeUntil(this.destroyed))
826
- .subscribe(this.editEventDispatcher.editing);
827
- // Keydown must be used here or else key auto-repeat does not work properly on some platforms.
828
- fromEvent(element, 'keydown')
829
- .pipe(takeUntil(this.destroyed))
830
- .subscribe(this.focusDispatcher.keyObserver);
831
- });
832
- }
833
- }
834
- CdkEditable.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkEditable, deps: [{ token: i0.ElementRef }, { token: EditEventDispatcher }, { token: FocusDispatcher }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
835
- CdkEditable.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0-next.2", type: CdkEditable, selector: "table[editable], cdk-table[editable], mat-table[editable]", providers: [EditEventDispatcher, EditServices], ngImport: i0 });
836
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkEditable, decorators: [{
837
- type: Directive,
838
- args: [{
839
- selector: 'table[editable], cdk-table[editable], mat-table[editable]',
840
- providers: [EditEventDispatcher, EditServices],
841
- }]
842
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: EditEventDispatcher }, { type: FocusDispatcher }, { type: i0.NgZone }]; } });
843
- const POPOVER_EDIT_HOST_BINDINGS = {
844
- '[attr.tabindex]': 'disabled ? null : 0',
845
- 'class': 'cdk-popover-edit-cell',
846
- '[attr.aria-haspopup]': '!disabled',
847
- };
848
- const POPOVER_EDIT_INPUTS = [
849
- 'template: cdkPopoverEdit',
850
- 'context: cdkPopoverEditContext',
851
- 'colspan: cdkPopoverEditColspan',
852
- 'disabled: cdkPopoverEditDisabled',
853
- ];
854
- /**
855
- * Attaches an ng-template to a cell and shows it when instructed to by the
856
- * EditEventDispatcher service.
857
- * Makes the cell focusable.
858
- */
859
- class CdkPopoverEdit {
860
- /**
861
- * Specifies that the popup should cover additional table cells before and/or after
862
- * this one.
863
- */
864
- get colspan() {
865
- return this._colspan;
866
- }
867
- set colspan(value) {
868
- this._colspan = value;
869
- // Recompute positioning when the colspan changes.
870
- if (this.overlayRef) {
871
- this.overlayRef.updatePositionStrategy(this._getPositionStrategy());
872
- if (this.overlayRef.hasAttached()) {
873
- this._updateOverlaySize();
874
- }
875
- }
876
- }
877
- /** Whether popover edit is disabled for this cell. */
878
- get disabled() {
879
- return this._disabled;
880
- }
881
- set disabled(value) {
882
- this._disabled = value;
883
- if (value) {
884
- this.services.editEventDispatcher.doneEditingCell(this.elementRef.nativeElement);
885
- this.services.editEventDispatcher.disabledCells.set(this.elementRef.nativeElement, true);
886
- }
887
- else {
888
- this.services.editEventDispatcher.disabledCells.delete(this.elementRef.nativeElement);
889
- }
890
- }
891
- constructor(services, elementRef, viewContainerRef) {
892
- this.services = services;
893
- this.elementRef = elementRef;
894
- this.viewContainerRef = viewContainerRef;
895
- /** The edit lens template shown over the cell on edit. */
896
- this.template = null;
897
- this._colspan = {};
898
- this._disabled = false;
899
- this.destroyed = new Subject();
900
- }
901
- ngAfterViewInit() {
902
- this._startListeningToEditEvents();
903
- }
904
- ngOnDestroy() {
905
- this.destroyed.next();
906
- this.destroyed.complete();
907
- if (this.focusTrap) {
908
- this.focusTrap.destroy();
909
- this.focusTrap = undefined;
910
- }
911
- if (this.overlayRef) {
912
- this.overlayRef.dispose();
913
- }
914
- }
915
- initFocusTrap() {
916
- this.focusTrap = this.services.focusTrapFactory.create(this.overlayRef.overlayElement);
917
- }
918
- closeEditOverlay() {
919
- this.services.editEventDispatcher.doneEditingCell(this.elementRef.nativeElement);
920
- }
921
- panelClass() {
922
- return EDIT_PANE_CLASS;
923
- }
924
- _startListeningToEditEvents() {
925
- this.services.editEventDispatcher
926
- .editingCell(this.elementRef.nativeElement)
927
- .pipe(takeUntil(this.destroyed))
928
- .subscribe(open => {
929
- if (open && this.template) {
930
- if (!this.overlayRef) {
931
- this._createEditOverlay();
932
- }
933
- this._showEditOverlay();
934
- }
935
- else if (this.overlayRef) {
936
- this._maybeReturnFocusToCell();
937
- this.overlayRef.detach();
938
- }
939
- });
940
- }
941
- _createEditOverlay() {
942
- this.overlayRef = this.services.overlay.create({
943
- disposeOnNavigation: true,
944
- panelClass: this.panelClass(),
945
- positionStrategy: this._getPositionStrategy(),
946
- scrollStrategy: this.services.overlay.scrollStrategies.reposition(),
947
- direction: this.services.directionality,
948
- });
949
- this.initFocusTrap();
950
- this.overlayRef.overlayElement.setAttribute('aria-role', 'dialog');
951
- this.overlayRef.detachments().subscribe(() => this.closeEditOverlay());
952
- }
953
- _showEditOverlay() {
954
- this.overlayRef.attach(new TemplatePortal(this.template, this.viewContainerRef, { $implicit: this.context }));
955
- // We have to defer trapping focus, because doing so too early can cause the form inside
956
- // the overlay to be submitted immediately if it was opened on an Enter keydown event.
957
- this.services.ngZone.runOutsideAngular(() => {
958
- setTimeout(() => {
959
- this.focusTrap.focusInitialElement();
960
- });
961
- });
962
- // Update the size of the popup initially and on subsequent changes to
963
- // scroll position and viewport size.
964
- merge(this.services.scrollDispatcher.scrolled(), this.services.viewportRuler.change())
965
- .pipe(startWith(null), takeUntil(merge(this.overlayRef.detachments(), this.destroyed)))
966
- .subscribe(() => {
967
- this._updateOverlaySize();
968
- });
969
- }
970
- _getOverlayCells() {
971
- const cell = closest(this.elementRef.nativeElement, CELL_SELECTOR);
972
- if (!this._colspan.before && !this._colspan.after) {
973
- return [cell];
974
- }
975
- const row = closest(this.elementRef.nativeElement, ROW_SELECTOR);
976
- const rowCells = Array.from(row.querySelectorAll(CELL_SELECTOR));
977
- const ownIndex = rowCells.indexOf(cell);
978
- return rowCells.slice(ownIndex - (this._colspan.before || 0), ownIndex + (this._colspan.after || 0) + 1);
979
- }
980
- _getPositionStrategy() {
981
- return this.services.positionFactory.positionStrategyForCells(this._getOverlayCells());
982
- }
983
- _updateOverlaySize() {
984
- this.overlayRef.updateSize(this.services.positionFactory.sizeConfigForCells(this._getOverlayCells()));
985
- }
986
- _maybeReturnFocusToCell() {
987
- if (closest(document.activeElement, EDIT_PANE_SELECTOR) === this.overlayRef.overlayElement) {
988
- this.elementRef.nativeElement.focus();
989
- }
990
- }
991
- }
992
- CdkPopoverEdit.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkPopoverEdit, deps: [{ token: EditServices }, { token: i0.ElementRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
993
- CdkPopoverEdit.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0-next.2", type: CdkPopoverEdit, selector: "[cdkPopoverEdit]:not([cdkPopoverEditTabOut])", inputs: { template: ["cdkPopoverEdit", "template"], context: ["cdkPopoverEditContext", "context"], colspan: ["cdkPopoverEditColspan", "colspan"], disabled: ["cdkPopoverEditDisabled", "disabled"] }, host: { properties: { "attr.tabindex": "disabled ? null : 0", "attr.aria-haspopup": "!disabled" }, classAttribute: "cdk-popover-edit-cell" }, ngImport: i0 });
994
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkPopoverEdit, decorators: [{
995
- type: Directive,
996
- args: [{
997
- selector: '[cdkPopoverEdit]:not([cdkPopoverEditTabOut])',
998
- host: POPOVER_EDIT_HOST_BINDINGS,
999
- inputs: POPOVER_EDIT_INPUTS,
1000
- }]
1001
- }], ctorParameters: function () { return [{ type: EditServices }, { type: i0.ElementRef }, { type: i0.ViewContainerRef }]; } });
1002
- /**
1003
- * Attaches an ng-template to a cell and shows it when instructed to by the
1004
- * EditEventDispatcher service.
1005
- * Makes the cell focusable.
1006
- */
1007
- class CdkPopoverEditTabOut extends CdkPopoverEdit {
1008
- constructor(elementRef, viewContainerRef, services, focusEscapeNotifierFactory) {
1009
- super(services, elementRef, viewContainerRef);
1010
- this.focusEscapeNotifierFactory = focusEscapeNotifierFactory;
1011
- }
1012
- initFocusTrap() {
1013
- this.focusTrap = this.focusEscapeNotifierFactory.create(this.overlayRef.overlayElement);
1014
- this.focusTrap
1015
- .escapes()
1016
- .pipe(takeUntil(this.destroyed))
1017
- .subscribe(direction => {
1018
- if (this.services.editEventDispatcher.editRef) {
1019
- this.services.editEventDispatcher.editRef.blur();
1020
- }
1021
- this.services.focusDispatcher.moveFocusHorizontally(closest(this.elementRef.nativeElement, CELL_SELECTOR), direction === 0 /* FocusEscapeNotifierDirection.START */ ? -1 : 1);
1022
- this.closeEditOverlay();
1023
- });
1024
- }
1025
- }
1026
- CdkPopoverEditTabOut.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkPopoverEditTabOut, deps: [{ token: i0.ElementRef }, { token: i0.ViewContainerRef }, { token: EditServices }, { token: FocusEscapeNotifierFactory }], target: i0.ɵɵFactoryTarget.Directive });
1027
- CdkPopoverEditTabOut.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0-next.2", type: CdkPopoverEditTabOut, selector: "[cdkPopoverEdit][cdkPopoverEditTabOut]", inputs: { template: ["cdkPopoverEdit", "template"], context: ["cdkPopoverEditContext", "context"], colspan: ["cdkPopoverEditColspan", "colspan"], disabled: ["cdkPopoverEditDisabled", "disabled"] }, host: { properties: { "attr.tabindex": "disabled ? null : 0", "attr.aria-haspopup": "!disabled" }, classAttribute: "cdk-popover-edit-cell" }, usesInheritance: true, ngImport: i0 });
1028
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkPopoverEditTabOut, decorators: [{
1029
- type: Directive,
1030
- args: [{
1031
- selector: '[cdkPopoverEdit][cdkPopoverEditTabOut]',
1032
- host: POPOVER_EDIT_HOST_BINDINGS,
1033
- inputs: POPOVER_EDIT_INPUTS,
1034
- }]
1035
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ViewContainerRef }, { type: EditServices }, { type: FocusEscapeNotifierFactory }]; } });
1036
- /**
1037
- * A structural directive that shows its contents when the table row containing
1038
- * it is hovered or when an element in the row has focus.
1039
- */
1040
- class CdkRowHoverContent {
1041
- constructor(services, elementRef, templateRef, viewContainerRef) {
1042
- this.services = services;
1043
- this.elementRef = elementRef;
1044
- this.templateRef = templateRef;
1045
- this.viewContainerRef = viewContainerRef;
1046
- this.destroyed = new Subject();
1047
- this.viewRef = null;
1048
- }
1049
- ngAfterViewInit() {
1050
- this._row = closest(this.elementRef.nativeElement, ROW_SELECTOR);
1051
- this.services.editEventDispatcher.registerRowWithHoverContent(this._row);
1052
- this._listenForHoverAndFocusEvents();
1053
- }
1054
- ngOnDestroy() {
1055
- this.destroyed.next();
1056
- this.destroyed.complete();
1057
- if (this.viewRef) {
1058
- this.viewRef.destroy();
1059
- }
1060
- if (this._row) {
1061
- this.services.editEventDispatcher.deregisterRowWithHoverContent(this._row);
1062
- }
1063
- }
1064
- /**
1065
- * Called immediately after the hover content is created and added to the dom.
1066
- * In the CDK version, this is a noop but subclasses such as MatRowHoverContent use this
1067
- * to prepare/style the inserted element.
1068
- */
1069
- initElement(_) { }
1070
- /**
1071
- * Called when the hover content needs to be focusable to preserve a reasonable tab ordering
1072
- * but should not yet be shown.
1073
- */
1074
- makeElementHiddenButFocusable(element) {
1075
- element.style.opacity = '0';
1076
- }
1077
- /**
1078
- * Called when the hover content needs to be focusable to preserve a reasonable tab ordering
1079
- * but should not yet be shown.
1080
- */
1081
- makeElementVisible(element) {
1082
- element.style.opacity = '';
1083
- }
1084
- _listenForHoverAndFocusEvents() {
1085
- this.services.editEventDispatcher
1086
- .hoverOrFocusOnRow(this._row)
1087
- .pipe(takeUntil(this.destroyed))
1088
- .subscribe(eventState => {
1089
- // When in FOCUSABLE state, add the hover content to the dom but make it transparent so
1090
- // that it is in the tab order relative to the currently focused row.
1091
- if (eventState === 2 /* HoverContentState.ON */ || eventState === 1 /* HoverContentState.FOCUSABLE */) {
1092
- if (!this.viewRef) {
1093
- this.viewRef = this.viewContainerRef.createEmbeddedView(this.templateRef, {});
1094
- this.initElement(this.viewRef.rootNodes[0]);
1095
- this.viewRef.markForCheck();
1096
- }
1097
- else if (this.viewContainerRef.indexOf(this.viewRef) === -1) {
1098
- this.viewContainerRef.insert(this.viewRef);
1099
- this.viewRef.markForCheck();
1100
- }
1101
- if (eventState === 2 /* HoverContentState.ON */) {
1102
- this.makeElementVisible(this.viewRef.rootNodes[0]);
1103
- }
1104
- else {
1105
- this.makeElementHiddenButFocusable(this.viewRef.rootNodes[0]);
1106
- }
1107
- }
1108
- else if (this.viewRef) {
1109
- this.viewContainerRef.detach(this.viewContainerRef.indexOf(this.viewRef));
1110
- }
1111
- });
1112
- }
1113
- }
1114
- CdkRowHoverContent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkRowHoverContent, deps: [{ token: EditServices }, { token: i0.ElementRef }, { token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
1115
- CdkRowHoverContent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0-next.2", type: CdkRowHoverContent, selector: "[cdkRowHoverContent]", ngImport: i0 });
1116
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkRowHoverContent, decorators: [{
1117
- type: Directive,
1118
- args: [{
1119
- selector: '[cdkRowHoverContent]',
1120
- }]
1121
- }], ctorParameters: function () { return [{ type: EditServices }, { type: i0.ElementRef }, { type: i0.TemplateRef }, { type: i0.ViewContainerRef }]; } });
1122
- /**
1123
- * Opens the closest edit popover to this element, whether it's associated with this exact
1124
- * element or an ancestor element.
1125
- */
1126
- class CdkEditOpen {
1127
- constructor(elementRef, editEventDispatcher) {
1128
- this.elementRef = elementRef;
1129
- this.editEventDispatcher = editEventDispatcher;
1130
- const nativeElement = elementRef.nativeElement;
1131
- // Prevent accidental form submits.
1132
- if (nativeElement.nodeName === 'BUTTON' && !nativeElement.getAttribute('type')) {
1133
- nativeElement.setAttribute('type', 'button');
1134
- }
1135
- }
1136
- openEdit(evt) {
1137
- this.editEventDispatcher.editing.next(closest(this.elementRef.nativeElement, CELL_SELECTOR));
1138
- evt.stopPropagation();
1139
- }
1140
- }
1141
- CdkEditOpen.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkEditOpen, deps: [{ token: i0.ElementRef }, { token: EditEventDispatcher }], target: i0.ɵɵFactoryTarget.Directive });
1142
- CdkEditOpen.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0-next.2", type: CdkEditOpen, selector: "[cdkEditOpen]", host: { listeners: { "click": "openEdit($event)" } }, ngImport: i0 });
1143
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkEditOpen, decorators: [{
1144
- type: Directive,
1145
- args: [{
1146
- selector: '[cdkEditOpen]',
1147
- host: {
1148
- '(click)': 'openEdit($event)',
1149
- },
1150
- }]
1151
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: EditEventDispatcher }]; } });
1152
-
1153
- /**
1154
- * @license
1155
- * Copyright Google LLC All Rights Reserved.
1156
- *
1157
- * Use of this source code is governed by an MIT-style license that can be
1158
- * found in the LICENSE file at https://angular.io/license
1159
- */
1160
- const EXPORTED_DECLARATIONS = [
1161
- CdkPopoverEdit,
1162
- CdkPopoverEditTabOut,
1163
- CdkRowHoverContent,
1164
- CdkEditControl,
1165
- CdkEditRevert,
1166
- CdkEditClose,
1167
- CdkEditable,
1168
- CdkEditOpen,
1169
- ];
1170
- class CdkPopoverEditModule {
1171
- }
1172
- CdkPopoverEditModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkPopoverEditModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1173
- CdkPopoverEditModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkPopoverEditModule, declarations: [CdkPopoverEdit,
1174
- CdkPopoverEditTabOut,
1175
- CdkRowHoverContent,
1176
- CdkEditControl,
1177
- CdkEditRevert,
1178
- CdkEditClose,
1179
- CdkEditable,
1180
- CdkEditOpen], imports: [OverlayModule], exports: [CdkPopoverEdit,
1181
- CdkPopoverEditTabOut,
1182
- CdkRowHoverContent,
1183
- CdkEditControl,
1184
- CdkEditRevert,
1185
- CdkEditClose,
1186
- CdkEditable,
1187
- CdkEditOpen] });
1188
- CdkPopoverEditModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkPopoverEditModule, providers: [
1189
- {
1190
- provide: PopoverEditPositionStrategyFactory,
1191
- useClass: DefaultPopoverEditPositionStrategyFactory,
1192
- },
1193
- ], imports: [OverlayModule] });
1194
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkPopoverEditModule, decorators: [{
1195
- type: NgModule,
1196
- args: [{
1197
- imports: [OverlayModule],
1198
- exports: EXPORTED_DECLARATIONS,
1199
- declarations: EXPORTED_DECLARATIONS,
1200
- providers: [
1201
- {
1202
- provide: PopoverEditPositionStrategyFactory,
1203
- useClass: DefaultPopoverEditPositionStrategyFactory,
1204
- },
1205
- ],
1206
- }]
1207
- }] });
1208
-
1209
- /**
1210
- * @license
1211
- * Copyright Google LLC All Rights Reserved.
1212
- *
1213
- * Use of this source code is governed by an MIT-style license that can be
1214
- * found in the LICENSE file at https://angular.io/license
1215
- */
1216
-
1217
- /**
1218
- * @license
1219
- * Copyright Google LLC All Rights Reserved.
1220
- *
1221
- * Use of this source code is governed by an MIT-style license that can be
1222
- * found in the LICENSE file at https://angular.io/license
1223
- */
1224
-
1225
- /**
1226
- * Generated bundle index. Do not edit.
1227
- */
1228
-
1229
- export { CdkEditClose, CdkEditControl, CdkEditOpen, CdkEditRevert, CdkEditable, CdkPopoverEdit, CdkPopoverEditModule, CdkPopoverEditTabOut, CdkRowHoverContent, DefaultPopoverEditPositionStrategyFactory, EditEventDispatcher, EditRef, FocusDispatcher, FormValueContainer, PopoverEditPositionStrategyFactory, CELL_SELECTOR as _CELL_SELECTOR, closest as _closest };
1230
- //# sourceMappingURL=popover-edit.mjs.map