@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,693 +0,0 @@
1
- import { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';
2
- import { isDataSource } from '@angular/cdk/collections';
3
- import * as i0 from '@angular/core';
4
- import { EventEmitter, Directive, Input, Output, Optional, Inject, Self, Component, ChangeDetectionStrategy, ViewEncapsulation, ViewChild, NgModule } from '@angular/core';
5
- import { Subject, Observable, of } from 'rxjs';
6
- import { takeUntil, switchMap, distinctUntilChanged } from 'rxjs/operators';
7
- import { NG_VALUE_ACCESSOR } from '@angular/forms';
8
- import * as i2 from '@angular/cdk/table';
9
- import { CdkTable, CdkColumnDef, CdkCellDef, CdkHeaderCellDef, CdkTableModule } from '@angular/cdk/table';
10
- import * as i1 from '@angular/common';
11
- import { CommonModule } from '@angular/common';
12
-
13
- /**
14
- * @license
15
- * Copyright Google LLC All Rights Reserved.
16
- *
17
- * Use of this source code is governed by an MIT-style license that can be
18
- * found in the LICENSE file at https://angular.io/license
19
- */
20
- /**
21
- * Maintains a set of selected items. Support selecting and deselecting items, and checking if a
22
- * value is selected.
23
- * When constructed with a `trackByFn`, all the items will be identified by applying the `trackByFn`
24
- * on them. Because `trackByFn` requires the index of the item to be passed in, the `index` field is
25
- * expected to be set when calling `isSelected`, `select` and `deselect`.
26
- */
27
- class SelectionSet {
28
- constructor(_multiple = false, _trackByFn) {
29
- this._multiple = _multiple;
30
- this._trackByFn = _trackByFn;
31
- this._selectionMap = new Map();
32
- this.changed = new Subject();
33
- }
34
- isSelected(value) {
35
- return this._selectionMap.has(this._getTrackedByValue(value));
36
- }
37
- select(...selects) {
38
- if (!this._multiple && selects.length > 1 && (typeof ngDevMode === 'undefined' || ngDevMode)) {
39
- throw Error('SelectionSet: not multiple selection');
40
- }
41
- const before = this._getCurrentSelection();
42
- if (!this._multiple) {
43
- this._selectionMap.clear();
44
- }
45
- const toSelect = [];
46
- for (const select of selects) {
47
- if (this.isSelected(select)) {
48
- continue;
49
- }
50
- toSelect.push(select);
51
- this._markSelected(this._getTrackedByValue(select), select);
52
- }
53
- const after = this._getCurrentSelection();
54
- this.changed.next({ before, after });
55
- }
56
- deselect(...selects) {
57
- if (!this._multiple && selects.length > 1 && (typeof ngDevMode === 'undefined' || ngDevMode)) {
58
- throw Error('SelectionSet: not multiple selection');
59
- }
60
- const before = this._getCurrentSelection();
61
- const toDeselect = [];
62
- for (const select of selects) {
63
- if (!this.isSelected(select)) {
64
- continue;
65
- }
66
- toDeselect.push(select);
67
- this._markDeselected(this._getTrackedByValue(select));
68
- }
69
- const after = this._getCurrentSelection();
70
- this.changed.next({ before, after });
71
- }
72
- _markSelected(key, toSelect) {
73
- this._selectionMap.set(key, toSelect);
74
- }
75
- _markDeselected(key) {
76
- this._selectionMap.delete(key);
77
- }
78
- _getTrackedByValue(select) {
79
- if (!this._trackByFn) {
80
- return select.value;
81
- }
82
- if (select.index == null && (typeof ngDevMode === 'undefined' || ngDevMode)) {
83
- throw Error('SelectionSet: index required when trackByFn is used.');
84
- }
85
- return this._trackByFn(select.index, select.value);
86
- }
87
- _getCurrentSelection() {
88
- return Array.from(this._selectionMap.values());
89
- }
90
- }
91
-
92
- /**
93
- * @license
94
- * Copyright Google LLC All Rights Reserved.
95
- *
96
- * Use of this source code is governed by an MIT-style license that can be
97
- * found in the LICENSE file at https://angular.io/license
98
- */
99
- /**
100
- * Manages the selection states of the items and provides methods to check and update the selection
101
- * states.
102
- * It must be applied to the parent element if `cdkSelectionToggle`, `cdkSelectAll`,
103
- * `cdkRowSelection` and `cdkSelectionColumn` are applied.
104
- */
105
- class CdkSelection {
106
- constructor() {
107
- /** Emits when selection changes. */
108
- this.change = new EventEmitter();
109
- this._destroyed = new Subject();
110
- this.selectAllState = 'none';
111
- }
112
- get dataSource() {
113
- return this._dataSource;
114
- }
115
- set dataSource(dataSource) {
116
- if (this._dataSource !== dataSource) {
117
- this._switchDataSource(dataSource);
118
- }
119
- }
120
- /** Whether to support multiple selection */
121
- get multiple() {
122
- return this._multiple;
123
- }
124
- set multiple(multiple) {
125
- this._multiple = coerceBooleanProperty(multiple);
126
- }
127
- _switchDataSource(dataSource) {
128
- this._data = [];
129
- // TODO: Move this logic to a shared function in `cdk/collections`.
130
- if (isDataSource(this._dataSource)) {
131
- this._dataSource.disconnect(this);
132
- }
133
- if (this._renderChangeSubscription) {
134
- this._renderChangeSubscription.unsubscribe();
135
- this._renderChangeSubscription = null;
136
- }
137
- this._dataSource = dataSource;
138
- }
139
- _observeRenderChanges() {
140
- if (!this._dataSource) {
141
- return;
142
- }
143
- let dataStream;
144
- if (isDataSource(this._dataSource)) {
145
- dataStream = this._dataSource.connect(this);
146
- }
147
- else if (this._dataSource instanceof Observable) {
148
- dataStream = this._dataSource;
149
- }
150
- else if (Array.isArray(this._dataSource)) {
151
- dataStream = of(this._dataSource);
152
- }
153
- if (dataStream == null && (typeof ngDevMode === 'undefined' || ngDevMode)) {
154
- throw Error('Unknown data source');
155
- }
156
- this._renderChangeSubscription = dataStream
157
- .pipe(takeUntil(this._destroyed))
158
- .subscribe(data => {
159
- this._data = data || [];
160
- });
161
- }
162
- ngOnInit() {
163
- this._selection = new SelectionSet(this._multiple, this.trackByFn);
164
- this._selection.changed.pipe(takeUntil(this._destroyed)).subscribe(change => {
165
- this._updateSelectAllState();
166
- this.change.emit(change);
167
- });
168
- }
169
- ngAfterContentChecked() {
170
- if (this._dataSource && !this._renderChangeSubscription) {
171
- this._observeRenderChanges();
172
- }
173
- }
174
- ngOnDestroy() {
175
- this._destroyed.next();
176
- this._destroyed.complete();
177
- if (isDataSource(this._dataSource)) {
178
- this._dataSource.disconnect(this);
179
- }
180
- }
181
- /** Toggles selection for a given value. `index` is required if `trackBy` is used. */
182
- toggleSelection(value, index) {
183
- if (!!this.trackByFn && index == null && (typeof ngDevMode === 'undefined' || ngDevMode)) {
184
- throw Error('CdkSelection: index required when trackBy is used');
185
- }
186
- if (this.isSelected(value, index)) {
187
- this._selection.deselect({ value, index });
188
- }
189
- else {
190
- this._selection.select({ value, index });
191
- }
192
- }
193
- /**
194
- * Toggles select-all. If no value is selected, select all values. If all values or some of the
195
- * values are selected, de-select all values.
196
- */
197
- toggleSelectAll() {
198
- if (!this._multiple && (typeof ngDevMode === 'undefined' || ngDevMode)) {
199
- throw Error('CdkSelection: multiple selection not enabled');
200
- }
201
- if (this.selectAllState === 'none') {
202
- this._selectAll();
203
- }
204
- else {
205
- this._clearAll();
206
- }
207
- }
208
- /** Checks whether a value is selected. `index` is required if `trackBy` is used. */
209
- isSelected(value, index) {
210
- if (!!this.trackByFn && index == null && (typeof ngDevMode === 'undefined' || ngDevMode)) {
211
- throw Error('CdkSelection: index required when trackBy is used');
212
- }
213
- return this._selection.isSelected({ value, index });
214
- }
215
- /** Checks whether all values are selected. */
216
- isAllSelected() {
217
- return this._data.every((value, index) => this._selection.isSelected({ value, index }));
218
- }
219
- /** Checks whether partially selected. */
220
- isPartialSelected() {
221
- return (!this.isAllSelected() &&
222
- this._data.some((value, index) => this._selection.isSelected({ value, index })));
223
- }
224
- _selectAll() {
225
- const toSelect = [];
226
- this._data.forEach((value, index) => {
227
- toSelect.push({ value, index });
228
- });
229
- this._selection.select(...toSelect);
230
- }
231
- _clearAll() {
232
- const toDeselect = [];
233
- this._data.forEach((value, index) => {
234
- toDeselect.push({ value, index });
235
- });
236
- this._selection.deselect(...toDeselect);
237
- }
238
- _updateSelectAllState() {
239
- if (this.isAllSelected()) {
240
- this.selectAllState = 'all';
241
- }
242
- else if (this.isPartialSelected()) {
243
- this.selectAllState = 'partial';
244
- }
245
- else {
246
- this.selectAllState = 'none';
247
- }
248
- }
249
- }
250
- CdkSelection.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkSelection, deps: [], target: i0.ɵɵFactoryTarget.Directive });
251
- CdkSelection.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0-next.2", type: CdkSelection, selector: "[cdkSelection]", inputs: { dataSource: "dataSource", trackByFn: ["trackBy", "trackByFn"], multiple: ["cdkSelectionMultiple", "multiple"] }, outputs: { change: "cdkSelectionChange" }, exportAs: ["cdkSelection"], ngImport: i0 });
252
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkSelection, decorators: [{
253
- type: Directive,
254
- args: [{
255
- selector: '[cdkSelection]',
256
- exportAs: 'cdkSelection',
257
- }]
258
- }], propDecorators: { dataSource: [{
259
- type: Input
260
- }], trackByFn: [{
261
- type: Input,
262
- args: ['trackBy']
263
- }], multiple: [{
264
- type: Input,
265
- args: ['cdkSelectionMultiple']
266
- }], change: [{
267
- type: Output,
268
- args: ['cdkSelectionChange']
269
- }] } });
270
-
271
- /**
272
- * @license
273
- * Copyright Google LLC All Rights Reserved.
274
- *
275
- * Use of this source code is governed by an MIT-style license that can be
276
- * found in the LICENSE file at https://angular.io/license
277
- */
278
- /**
279
- * Makes the element a select-all toggle.
280
- *
281
- * Must be used within a parent `CdkSelection` directive. It toggles the selection states
282
- * of all the selection toggles connected with the `CdkSelection` directive.
283
- * If the element implements `ControlValueAccessor`, e.g. `MatCheckbox`, the directive
284
- * automatically connects it with the select-all state provided by the `CdkSelection` directive. If
285
- * not, use `checked$` to get the checked state, `indeterminate$` to get the indeterminate state,
286
- * and `toggle()` to change the selection state.
287
- */
288
- class CdkSelectAll {
289
- /**
290
- * Toggles the select-all state.
291
- * @param event The click event if the toggle is triggered by a (mouse or keyboard) click. If
292
- * using with a native `<input type="checkbox">`, the parameter is required for the
293
- * indeterminate state to work properly.
294
- */
295
- toggle(event) {
296
- // This is needed when applying the directive on a native <input type="checkbox">
297
- // checkbox. The default behavior needs to be prevented in order to support the indeterminate
298
- // state. The timeout is also needed so the checkbox can show the latest state.
299
- if (event) {
300
- event.preventDefault();
301
- }
302
- setTimeout(() => {
303
- this._selection.toggleSelectAll();
304
- });
305
- }
306
- constructor(_selection, _controlValueAccessor) {
307
- this._selection = _selection;
308
- this._controlValueAccessor = _controlValueAccessor;
309
- /**
310
- * The checked state of the toggle.
311
- * Resolves to `true` if all the values are selected, `false` if no value is selected.
312
- */
313
- this.checked = this._selection.change.pipe(switchMap(() => of(this._selection.isAllSelected())));
314
- /**
315
- * The indeterminate state of the toggle.
316
- * Resolves to `true` if part (not all) of the values are selected, `false` if all values or no
317
- * value at all are selected.
318
- */
319
- this.indeterminate = this._selection.change.pipe(switchMap(() => of(this._selection.isPartialSelected())));
320
- this._destroyed = new Subject();
321
- }
322
- ngOnInit() {
323
- this._assertValidParentSelection();
324
- this._configureControlValueAccessor();
325
- }
326
- _configureControlValueAccessor() {
327
- if (this._controlValueAccessor && this._controlValueAccessor.length) {
328
- this._controlValueAccessor[0].registerOnChange((e) => {
329
- if (e === true || e === false) {
330
- this.toggle();
331
- }
332
- });
333
- this.checked.pipe(takeUntil(this._destroyed)).subscribe(state => {
334
- this._controlValueAccessor[0].writeValue(state);
335
- });
336
- }
337
- }
338
- _assertValidParentSelection() {
339
- if (!this._selection && (typeof ngDevMode === 'undefined' || ngDevMode)) {
340
- throw Error('CdkSelectAll: missing CdkSelection in the parent');
341
- }
342
- if (!this._selection.multiple && (typeof ngDevMode === 'undefined' || ngDevMode)) {
343
- throw Error('CdkSelectAll: CdkSelection must have cdkSelectionMultiple set to true');
344
- }
345
- }
346
- ngOnDestroy() {
347
- this._destroyed.next();
348
- this._destroyed.complete();
349
- }
350
- }
351
- CdkSelectAll.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkSelectAll, deps: [{ token: CdkSelection, optional: true }, { token: NG_VALUE_ACCESSOR, optional: true, self: true }], target: i0.ɵɵFactoryTarget.Directive });
352
- CdkSelectAll.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0-next.2", type: CdkSelectAll, selector: "[cdkSelectAll]", exportAs: ["cdkSelectAll"], ngImport: i0 });
353
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkSelectAll, decorators: [{
354
- type: Directive,
355
- args: [{
356
- selector: '[cdkSelectAll]',
357
- exportAs: 'cdkSelectAll',
358
- }]
359
- }], ctorParameters: function () {
360
- return [{ type: CdkSelection, decorators: [{
361
- type: Optional
362
- }, {
363
- type: Inject,
364
- args: [CdkSelection]
365
- }] }, { type: undefined, decorators: [{
366
- type: Optional
367
- }, {
368
- type: Self
369
- }, {
370
- type: Inject,
371
- args: [NG_VALUE_ACCESSOR]
372
- }] }];
373
- } });
374
-
375
- /**
376
- * @license
377
- * Copyright Google LLC All Rights Reserved.
378
- *
379
- * Use of this source code is governed by an MIT-style license that can be
380
- * found in the LICENSE file at https://angular.io/license
381
- */
382
- /**
383
- * Makes the element a selection toggle.
384
- *
385
- * Must be used within a parent `CdkSelection` directive.
386
- * Must be provided with the value. If `trackBy` is used on `CdkSelection`, the index of the value
387
- * is required. If the element implements `ControlValueAccessor`, e.g. `MatCheckbox`, the directive
388
- * automatically connects it with the selection state provided by the `CdkSelection` directive. If
389
- * not, use `checked$` to get the checked state of the value, and `toggle()` to change the selection
390
- * state.
391
- */
392
- class CdkSelectionToggle {
393
- /** The index of the value in the list. Required when used with `trackBy` */
394
- get index() {
395
- return this._index;
396
- }
397
- set index(index) {
398
- this._index = coerceNumberProperty(index);
399
- }
400
- /** Toggles the selection */
401
- toggle() {
402
- this._selection.toggleSelection(this.value, this.index);
403
- }
404
- constructor(_selection, _controlValueAccessors) {
405
- this._selection = _selection;
406
- this._controlValueAccessors = _controlValueAccessors;
407
- /** The checked state of the selection toggle */
408
- this.checked = this._selection.change.pipe(switchMap(() => of(this._isSelected())), distinctUntilChanged());
409
- this._destroyed = new Subject();
410
- }
411
- ngOnInit() {
412
- this._assertValidParentSelection();
413
- this._configureControlValueAccessor();
414
- }
415
- ngOnDestroy() {
416
- this._destroyed.next();
417
- this._destroyed.complete();
418
- }
419
- _assertValidParentSelection() {
420
- if (!this._selection && (typeof ngDevMode === 'undefined' || ngDevMode)) {
421
- throw Error('CdkSelectAll: missing CdkSelection in the parent');
422
- }
423
- }
424
- _configureControlValueAccessor() {
425
- if (this._controlValueAccessors && this._controlValueAccessors.length) {
426
- this._controlValueAccessors[0].registerOnChange((e) => {
427
- if (typeof e === 'boolean') {
428
- this.toggle();
429
- }
430
- });
431
- this.checked.pipe(takeUntil(this._destroyed)).subscribe(state => {
432
- this._controlValueAccessors[0].writeValue(state);
433
- });
434
- }
435
- }
436
- _isSelected() {
437
- return this._selection.isSelected(this.value, this.index);
438
- }
439
- }
440
- CdkSelectionToggle.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkSelectionToggle, deps: [{ token: CdkSelection, optional: true }, { token: NG_VALUE_ACCESSOR, optional: true, self: true }], target: i0.ɵɵFactoryTarget.Directive });
441
- CdkSelectionToggle.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0-next.2", type: CdkSelectionToggle, selector: "[cdkSelectionToggle]", inputs: { value: ["cdkSelectionToggleValue", "value"], index: ["cdkSelectionToggleIndex", "index"] }, exportAs: ["cdkSelectionToggle"], ngImport: i0 });
442
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkSelectionToggle, decorators: [{
443
- type: Directive,
444
- args: [{
445
- selector: '[cdkSelectionToggle]',
446
- exportAs: 'cdkSelectionToggle',
447
- }]
448
- }], ctorParameters: function () {
449
- return [{ type: CdkSelection, decorators: [{
450
- type: Optional
451
- }, {
452
- type: Inject,
453
- args: [CdkSelection]
454
- }] }, { type: undefined, decorators: [{
455
- type: Optional
456
- }, {
457
- type: Self
458
- }, {
459
- type: Inject,
460
- args: [NG_VALUE_ACCESSOR]
461
- }] }];
462
- }, propDecorators: { value: [{
463
- type: Input,
464
- args: ['cdkSelectionToggleValue']
465
- }], index: [{
466
- type: Input,
467
- args: ['cdkSelectionToggleIndex']
468
- }] } });
469
-
470
- /**
471
- * @license
472
- * Copyright Google LLC All Rights Reserved.
473
- *
474
- * Use of this source code is governed by an MIT-style license that can be
475
- * found in the LICENSE file at https://angular.io/license
476
- */
477
- /**
478
- * Column that adds row selecting checkboxes and a select-all checkbox if `cdkSelectionMultiple` is
479
- * `true`.
480
- *
481
- * Must be used within a parent `CdkSelection` directive.
482
- */
483
- class CdkSelectionColumn {
484
- /** Column name that should be used to reference this column. */
485
- get name() {
486
- return this._name;
487
- }
488
- set name(name) {
489
- this._name = name;
490
- this._syncColumnDefName();
491
- }
492
- constructor(_table, selection) {
493
- this._table = _table;
494
- this.selection = selection;
495
- }
496
- ngOnInit() {
497
- if (!this.selection && (typeof ngDevMode === 'undefined' || ngDevMode)) {
498
- throw Error('CdkSelectionColumn: missing CdkSelection in the parent');
499
- }
500
- this._syncColumnDefName();
501
- if (this._table) {
502
- this._columnDef.cell = this._cell;
503
- this._columnDef.headerCell = this._headerCell;
504
- this._table.addColumnDef(this._columnDef);
505
- }
506
- else if (typeof ngDevMode === 'undefined' || ngDevMode) {
507
- throw Error('CdkSelectionColumn: missing parent table');
508
- }
509
- }
510
- ngOnDestroy() {
511
- if (this._table) {
512
- this._table.removeColumnDef(this._columnDef);
513
- }
514
- }
515
- _syncColumnDefName() {
516
- if (this._columnDef) {
517
- this._columnDef.name = this._name;
518
- }
519
- }
520
- }
521
- CdkSelectionColumn.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkSelectionColumn, deps: [{ token: CdkTable, optional: true }, { token: CdkSelection, optional: true }], target: i0.ɵɵFactoryTarget.Component });
522
- CdkSelectionColumn.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.0-next.2", type: CdkSelectionColumn, selector: "cdk-selection-column", inputs: { name: ["cdkSelectionColumnName", "name"] }, viewQueries: [{ propertyName: "_columnDef", first: true, predicate: CdkColumnDef, descendants: true, static: true }, { propertyName: "_cell", first: true, predicate: CdkCellDef, descendants: true, static: true }, { propertyName: "_headerCell", first: true, predicate: CdkHeaderCellDef, descendants: true, static: true }], ngImport: i0, template: `
523
- <ng-container cdkColumnDef>
524
- <th cdkHeaderCell *cdkHeaderCellDef>
525
- <input type="checkbox" *ngIf="selection.multiple"
526
- cdkSelectAll
527
- #allToggler="cdkSelectAll"
528
- [checked]="allToggler.checked | async"
529
- [indeterminate]="allToggler.indeterminate | async"
530
- (click)="allToggler.toggle($event)">
531
- </th>
532
- <td cdkCell *cdkCellDef="let row; let i = $index">
533
- <input type="checkbox"
534
- #toggler="cdkSelectionToggle"
535
- cdkSelectionToggle
536
- [cdkSelectionToggleValue]="row"
537
- [cdkSelectionToggleIndex]="i"
538
- (click)="toggler.toggle()"
539
- [checked]="toggler.checked | async">
540
- </td>
541
- </ng-container>
542
- `, isInline: true, dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.CdkCellDef, selector: "[cdkCellDef]" }, { kind: "directive", type: i2.CdkHeaderCellDef, selector: "[cdkHeaderCellDef]" }, { kind: "directive", type: i2.CdkColumnDef, selector: "[cdkColumnDef]", inputs: ["sticky", "cdkColumnDef", "stickyEnd"] }, { kind: "directive", type: CdkSelectionToggle, selector: "[cdkSelectionToggle]", inputs: ["cdkSelectionToggleValue", "cdkSelectionToggleIndex"], exportAs: ["cdkSelectionToggle"] }, { kind: "directive", type: CdkSelectAll, selector: "[cdkSelectAll]", exportAs: ["cdkSelectAll"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
543
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkSelectionColumn, decorators: [{
544
- type: Component,
545
- args: [{
546
- selector: 'cdk-selection-column',
547
- template: `
548
- <ng-container cdkColumnDef>
549
- <th cdkHeaderCell *cdkHeaderCellDef>
550
- <input type="checkbox" *ngIf="selection.multiple"
551
- cdkSelectAll
552
- #allToggler="cdkSelectAll"
553
- [checked]="allToggler.checked | async"
554
- [indeterminate]="allToggler.indeterminate | async"
555
- (click)="allToggler.toggle($event)">
556
- </th>
557
- <td cdkCell *cdkCellDef="let row; let i = $index">
558
- <input type="checkbox"
559
- #toggler="cdkSelectionToggle"
560
- cdkSelectionToggle
561
- [cdkSelectionToggleValue]="row"
562
- [cdkSelectionToggleIndex]="i"
563
- (click)="toggler.toggle()"
564
- [checked]="toggler.checked | async">
565
- </td>
566
- </ng-container>
567
- `,
568
- changeDetection: ChangeDetectionStrategy.OnPush,
569
- encapsulation: ViewEncapsulation.None,
570
- }]
571
- }], ctorParameters: function () {
572
- return [{ type: i2.CdkTable, decorators: [{
573
- type: Optional
574
- }, {
575
- type: Inject,
576
- args: [CdkTable]
577
- }] }, { type: CdkSelection, decorators: [{
578
- type: Optional
579
- }, {
580
- type: Inject,
581
- args: [CdkSelection]
582
- }] }];
583
- }, propDecorators: { name: [{
584
- type: Input,
585
- args: ['cdkSelectionColumnName']
586
- }], _columnDef: [{
587
- type: ViewChild,
588
- args: [CdkColumnDef, { static: true }]
589
- }], _cell: [{
590
- type: ViewChild,
591
- args: [CdkCellDef, { static: true }]
592
- }], _headerCell: [{
593
- type: ViewChild,
594
- args: [CdkHeaderCellDef, { static: true }]
595
- }] } });
596
-
597
- /**
598
- * @license
599
- * Copyright Google LLC All Rights Reserved.
600
- *
601
- * Use of this source code is governed by an MIT-style license that can be
602
- * found in the LICENSE file at https://angular.io/license
603
- */
604
- /**
605
- * Applies `cdk-selected` class and `aria-selected` to an element.
606
- *
607
- * Must be used within a parent `CdkSelection` directive.
608
- * Must be provided with the value. The index is required if `trackBy` is used on the `CdkSelection`
609
- * directive.
610
- */
611
- class CdkRowSelection {
612
- get index() {
613
- return this._index;
614
- }
615
- set index(index) {
616
- this._index = coerceNumberProperty(index);
617
- }
618
- constructor(_selection) {
619
- this._selection = _selection;
620
- }
621
- }
622
- CdkRowSelection.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkRowSelection, deps: [{ token: CdkSelection }], target: i0.ɵɵFactoryTarget.Directive });
623
- CdkRowSelection.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0-next.2", type: CdkRowSelection, selector: "[cdkRowSelection]", inputs: { value: ["cdkRowSelectionValue", "value"], index: ["cdkRowSelectionIndex", "index"] }, host: { properties: { "class.cdk-selected": "_selection.isSelected(this.value, this.index)", "attr.aria-selected": "_selection.isSelected(this.value, this.index)" } }, ngImport: i0 });
624
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkRowSelection, decorators: [{
625
- type: Directive,
626
- args: [{
627
- selector: '[cdkRowSelection]',
628
- host: {
629
- '[class.cdk-selected]': '_selection.isSelected(this.value, this.index)',
630
- '[attr.aria-selected]': '_selection.isSelected(this.value, this.index)',
631
- },
632
- }]
633
- }], ctorParameters: function () { return [{ type: CdkSelection }]; }, propDecorators: { value: [{
634
- type: Input,
635
- args: ['cdkRowSelectionValue']
636
- }], index: [{
637
- type: Input,
638
- args: ['cdkRowSelectionIndex']
639
- }] } });
640
-
641
- /**
642
- * @license
643
- * Copyright Google LLC All Rights Reserved.
644
- *
645
- * Use of this source code is governed by an MIT-style license that can be
646
- * found in the LICENSE file at https://angular.io/license
647
- */
648
- class CdkSelectionModule {
649
- }
650
- CdkSelectionModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkSelectionModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
651
- CdkSelectionModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkSelectionModule, declarations: [CdkSelection,
652
- CdkSelectionToggle,
653
- CdkSelectAll,
654
- CdkSelectionColumn,
655
- CdkRowSelection], imports: [CommonModule, CdkTableModule], exports: [CdkSelection, CdkSelectionToggle, CdkSelectAll, CdkSelectionColumn, CdkRowSelection] });
656
- CdkSelectionModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkSelectionModule, imports: [CommonModule, CdkTableModule] });
657
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkSelectionModule, decorators: [{
658
- type: NgModule,
659
- args: [{
660
- imports: [CommonModule, CdkTableModule],
661
- exports: [CdkSelection, CdkSelectionToggle, CdkSelectAll, CdkSelectionColumn, CdkRowSelection],
662
- declarations: [
663
- CdkSelection,
664
- CdkSelectionToggle,
665
- CdkSelectAll,
666
- CdkSelectionColumn,
667
- CdkRowSelection,
668
- ],
669
- }]
670
- }] });
671
-
672
- /**
673
- * @license
674
- * Copyright Google LLC All Rights Reserved.
675
- *
676
- * Use of this source code is governed by an MIT-style license that can be
677
- * found in the LICENSE file at https://angular.io/license
678
- */
679
-
680
- /**
681
- * @license
682
- * Copyright Google LLC All Rights Reserved.
683
- *
684
- * Use of this source code is governed by an MIT-style license that can be
685
- * found in the LICENSE file at https://angular.io/license
686
- */
687
-
688
- /**
689
- * Generated bundle index. Do not edit.
690
- */
691
-
692
- export { CdkRowSelection, CdkSelectAll, CdkSelection, CdkSelectionColumn, CdkSelectionModule, CdkSelectionToggle, SelectionSet };
693
- //# sourceMappingURL=selection.mjs.map