@progress/kendo-angular-grid 5.5.1-dev.202112071035 → 6.0.0-dev.202201141020

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 (32) hide show
  1. package/LICENSE.md +1 -1
  2. package/NOTICE.txt +119 -79
  3. package/README.md +1 -1
  4. package/dist/cdn/js/kendo-angular-grid.js +1 -1
  5. package/dist/cdn/main.js +1 -1
  6. package/dist/es/filtering/menu/filter-menu-input-wrapper.component.js +2 -2
  7. package/dist/es/package-metadata.js +1 -1
  8. package/dist/es/rendering/details-expand.directive.js +20 -6
  9. package/dist/es/selection/pair-set.js +91 -0
  10. package/dist/es/selection/selection-default.js +48 -30
  11. package/dist/es/utils.js +1 -3
  12. package/dist/es2015/filtering/menu/filter-menu-input-wrapper.component.d.ts +2 -2
  13. package/dist/es2015/filtering/menu/filter-menu-input-wrapper.component.js +2 -2
  14. package/dist/es2015/index.metadata.json +1 -1
  15. package/dist/es2015/package-metadata.js +1 -1
  16. package/dist/es2015/rendering/details-expand.directive.d.ts +8 -2
  17. package/dist/es2015/rendering/details-expand.directive.js +20 -6
  18. package/dist/es2015/selection/pair-set.d.ts +50 -0
  19. package/dist/es2015/selection/pair-set.js +81 -0
  20. package/dist/es2015/selection/selection-default.d.ts +10 -2
  21. package/dist/es2015/selection/selection-default.js +42 -28
  22. package/dist/es2015/utils.d.ts +2 -2
  23. package/dist/fesm2015/index.js +139 -33
  24. package/dist/fesm5/index.js +155 -38
  25. package/dist/npm/filtering/menu/filter-menu-input-wrapper.component.js +2 -2
  26. package/dist/npm/package-metadata.js +1 -1
  27. package/dist/npm/rendering/details-expand.directive.js +19 -5
  28. package/dist/npm/selection/pair-set.js +93 -0
  29. package/dist/npm/selection/selection-default.js +48 -30
  30. package/dist/npm/utils.js +1 -3
  31. package/dist/systemjs/kendo-angular-grid.js +1 -1
  32. package/package.json +3 -3
@@ -9,7 +9,7 @@ export const packageMetadata = {
9
9
  name: '@progress/kendo-angular-grid',
10
10
  productName: 'Kendo UI for Angular',
11
11
  productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
12
- publishDate: 1638872746,
12
+ publishDate: 1642155100,
13
13
  version: '',
14
14
  licensingDocsUrl: 'https://www.telerik.com/kendo-angular-ui/my-license/?utm_medium=product&utm_source=kendoangular&utm_campaign=kendo-ui-angular-purchase-license-keys-warning'
15
15
  };
@@ -2,14 +2,14 @@
2
2
  * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
3
  * Licensed under commercial license. See LICENSE.md in the project root for more information
4
4
  *-------------------------------------------------------------------------------------------*/
5
- import { EventEmitter, OnDestroy } from '@angular/core';
5
+ import { EventEmitter, OnDestroy, OnChanges, SimpleChanges } from '@angular/core';
6
6
  import { GridComponent } from '../grid.component';
7
7
  import { Subscription } from 'rxjs';
8
8
  import { RowArgs } from './common/row-args';
9
9
  /**
10
10
  * A directive which controls the expanded state of the master detail rows.
11
11
  */
12
- export declare class ExpandDetailsDirective implements OnDestroy {
12
+ export declare class ExpandDetailsDirective implements OnChanges, OnDestroy {
13
13
  protected grid: GridComponent;
14
14
  /**
15
15
  * Fires when the expandedDetailKeys are changed.
@@ -31,12 +31,17 @@ export declare class ExpandDetailsDirective implements OnDestroy {
31
31
  expandedDetailKeys: any[];
32
32
  /**
33
33
  * Specifies if the items should be initially expanded.
34
+ * When set to `true` items added to the `expandedDetailKeys` collection will be collapsed, and items that are not present in it will be expanded.
35
+ *
34
36
  * @default false
35
37
  */
36
38
  initiallyExpanded: boolean;
39
+ protected expandedState: Set<any>;
40
+ protected lastExpandedState: any[];
37
41
  protected _expandBy: any;
38
42
  protected subscriptions: Subscription;
39
43
  constructor(grid: GridComponent);
44
+ ngOnChanges(changes: SimpleChanges): void;
40
45
  ngOnDestroy(): void;
41
46
  protected readonly keyGetter: any;
42
47
  /**
@@ -44,4 +49,5 @@ export declare class ExpandDetailsDirective implements OnDestroy {
44
49
  */
45
50
  isExpanded(args: RowArgs): boolean;
46
51
  private toggleState;
52
+ private notifyChange;
47
53
  }
@@ -8,7 +8,7 @@ import { GridComponent } from '../grid.component';
8
8
  import { Subscription, merge } from 'rxjs';
9
9
  import { map } from 'rxjs/operators';
10
10
  import { getter } from '@progress/kendo-common';
11
- import { isString } from '../utils';
11
+ import { isPresent, isString } from '../utils';
12
12
  /**
13
13
  * A directive which controls the expanded state of the master detail rows.
14
14
  */
@@ -25,9 +25,12 @@ let ExpandDetailsDirective = class ExpandDetailsDirective {
25
25
  this.expandedDetailKeys = [];
26
26
  /**
27
27
  * Specifies if the items should be initially expanded.
28
+ * When set to `true` items added to the `expandedDetailKeys` collection will be collapsed, and items that are not present in it will be expanded.
29
+ *
28
30
  * @default false
29
31
  */
30
32
  this.initiallyExpanded = false;
33
+ this.expandedState = new Set();
31
34
  this.subscriptions = new Subscription();
32
35
  this.grid.isDetailExpanded = this.isExpanded.bind(this);
33
36
  this.subscriptions.add(merge(this.grid.detailExpand.pipe(map(e => (Object.assign({ expand: true }, e)))), this.grid.detailCollapse.pipe(map(e => (Object.assign({ expand: false }, e))))).subscribe(this.toggleState.bind(this)));
@@ -57,6 +60,12 @@ let ExpandDetailsDirective = class ExpandDetailsDirective {
57
60
  set expandDetailBy(key) {
58
61
  this.expandDetailsKey = key;
59
62
  }
63
+ ngOnChanges(changes) {
64
+ // skip reinitialization if the user data is the same as the last state change
65
+ if (isPresent(changes.expandedDetailKeys) && this.lastExpandedState !== this.expandedDetailKeys) {
66
+ this.expandedState = new Set(this.expandedDetailKeys);
67
+ }
68
+ }
60
69
  ngOnDestroy() {
61
70
  this.subscriptions.unsubscribe();
62
71
  }
@@ -68,18 +77,23 @@ let ExpandDetailsDirective = class ExpandDetailsDirective {
68
77
  */
69
78
  isExpanded(args) {
70
79
  const key = this.keyGetter(args.dataItem);
71
- return this.expandedDetailKeys.indexOf(key) > -1 ? !this.initiallyExpanded : this.initiallyExpanded;
80
+ const hasKey = this.expandedState.has(key);
81
+ // when [initiallyExpanded]="true" a present key means the corresponding detail row is collapsed
82
+ return this.initiallyExpanded ? !hasKey : hasKey;
72
83
  }
73
84
  toggleState(args) {
74
85
  const key = this.keyGetter(args.dataItem);
75
86
  if (Boolean(this.initiallyExpanded) !== args.expand) {
76
- this.expandedDetailKeys.push(key);
87
+ this.expandedState.add(key);
77
88
  }
78
89
  else {
79
- const index = this.expandedDetailKeys.indexOf(key);
80
- this.expandedDetailKeys.splice(index, 1);
90
+ this.expandedState.delete(key);
81
91
  }
82
- this.expandedDetailKeysChange.emit(this.expandedDetailKeys);
92
+ this.notifyChange();
93
+ }
94
+ notifyChange() {
95
+ this.lastExpandedState = Array.from(this.expandedState);
96
+ this.expandedDetailKeysChange.emit(this.lastExpandedState);
83
97
  }
84
98
  };
85
99
  tslib_1.__decorate([
@@ -0,0 +1,50 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ /**
6
+ * @hidden
7
+ *
8
+ * Quick look-up structure for combinations of keys.
9
+ * Similar to the native JS Set, however, working with a couple of keys instead of with a single key.
10
+ * Supports both primitive keys and object keys (compared by reference).
11
+ */
12
+ export declare class PairSet {
13
+ /**
14
+ * Gets the total number of X/Y key pairs.
15
+ */
16
+ readonly size: number;
17
+ /**
18
+ * Holds a set of Y keys for each defined X key.
19
+ * Each X key creates a map which holds a set of Y keys.
20
+ *
21
+ * Map { 1 => Set { 1, 2, 3 } } // pairs: [1, 1], [1, 2], [1, 3]
22
+ */
23
+ private keysX;
24
+ /**
25
+ * Count the each added or deleted key manually to avoid iterating over all items when calling `this.size`.
26
+ */
27
+ private totalKeysCount;
28
+ constructor(items?: any[], keyXField?: string, keyYField?: string);
29
+ /**
30
+ * Adds a couple of items identified as a combination.
31
+ */
32
+ add(keyX: any, keyY: any): void;
33
+ /**
34
+ * Adds a combination of a couple of items identified together.
35
+ */
36
+ delete(keyX: any, keyY: any): void;
37
+ /**
38
+ * Checks whether the defined combination is stored.
39
+ */
40
+ has(keyX: any, keyY: any): boolean;
41
+ /**
42
+ * Clears all key combinations.
43
+ */
44
+ clear(): void;
45
+ /**
46
+ * Converts the persisted data structure to an array of objects,
47
+ * using the provided field names for the object props.
48
+ */
49
+ toArray(keyXField: string, keyYField: string): any[];
50
+ }
@@ -0,0 +1,81 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ /**
6
+ * @hidden
7
+ *
8
+ * Quick look-up structure for combinations of keys.
9
+ * Similar to the native JS Set, however, working with a couple of keys instead of with a single key.
10
+ * Supports both primitive keys and object keys (compared by reference).
11
+ */
12
+ export class PairSet {
13
+ constructor(items, keyXField, keyYField) {
14
+ /**
15
+ * Holds a set of Y keys for each defined X key.
16
+ * Each X key creates a map which holds a set of Y keys.
17
+ *
18
+ * Map { 1 => Set { 1, 2, 3 } } // pairs: [1, 1], [1, 2], [1, 3]
19
+ */
20
+ this.keysX = new Map();
21
+ /**
22
+ * Count the each added or deleted key manually to avoid iterating over all items when calling `this.size`.
23
+ */
24
+ this.totalKeysCount = 0;
25
+ if (items && keyXField && keyYField) {
26
+ items.forEach(item => this.add(item[keyXField], item[keyYField]));
27
+ }
28
+ }
29
+ /**
30
+ * Gets the total number of X/Y key pairs.
31
+ */
32
+ get size() {
33
+ return this.totalKeysCount;
34
+ }
35
+ /**
36
+ * Adds a couple of items identified as a combination.
37
+ */
38
+ add(keyX, keyY) {
39
+ if (!this.keysX.has(keyX)) {
40
+ this.keysX.set(keyX, new Set());
41
+ }
42
+ if (!this.has(keyX, keyY)) {
43
+ this.keysX.get(keyX).add(keyY);
44
+ this.totalKeysCount += 1;
45
+ }
46
+ }
47
+ /**
48
+ * Adds a combination of a couple of items identified together.
49
+ */
50
+ delete(keyX, keyY) {
51
+ if (this.has(keyX, keyY)) {
52
+ this.keysX.get(keyX).delete(keyY);
53
+ this.totalKeysCount -= 1;
54
+ }
55
+ }
56
+ /**
57
+ * Checks whether the defined combination is stored.
58
+ */
59
+ has(keyX, keyY) {
60
+ return this.keysX.has(keyX) && this.keysX.get(keyX).has(keyY);
61
+ }
62
+ /**
63
+ * Clears all key combinations.
64
+ */
65
+ clear() {
66
+ this.keysX.clear();
67
+ this.totalKeysCount = 0;
68
+ }
69
+ /**
70
+ * Converts the persisted data structure to an array of objects,
71
+ * using the provided field names for the object props.
72
+ */
73
+ toArray(keyXField, keyYField) {
74
+ return Array.from(this.keysX).reduce((pairs, pair) => {
75
+ // Array.from(mapInstance) returns an array of arrays [[itemKey1, columnKeysSet1], [itemKey2, columnKeysSet2]]
76
+ const [keyX, keysY] = pair;
77
+ Array.from(keysY).forEach(keyY => pairs.push({ [keyXField]: keyX, [keyYField]: keyY }));
78
+ return pairs;
79
+ }, []);
80
+ }
81
+ }
@@ -2,12 +2,13 @@
2
2
  * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
3
  * Licensed under commercial license. See LICENSE.md in the project root for more information
4
4
  *-------------------------------------------------------------------------------------------*/
5
- import { EventEmitter, ChangeDetectorRef } from '@angular/core';
5
+ import { EventEmitter, ChangeDetectorRef, SimpleChanges } from '@angular/core';
6
6
  import { GridComponent } from "../grid.component";
7
7
  import { Subscription } from "rxjs";
8
8
  import { RowArgs } from "../rendering/common/row-args";
9
9
  import { SelectionEvent, CellSelectionItem } from "./types";
10
10
  import { ColumnComponent } from '../columns/column.component';
11
+ import { PairSet } from './pair-set';
11
12
  /**
12
13
  * @hidden
13
14
  */
@@ -33,8 +34,13 @@ export declare class Selection {
33
34
  * Fires when the `selectedKeys` collection has been updated.
34
35
  */
35
36
  selectedKeysChange: EventEmitter<any[]>;
37
+ protected rowSelectionState: Set<any>;
38
+ protected cellSelectionState: PairSet;
39
+ protected lastSelectionState: any[];
36
40
  protected selectionChangeSubscription: Subscription;
41
+ private readonly isCellSelectionMode;
37
42
  constructor(grid: GridComponent, cd: ChangeDetectorRef);
43
+ ngOnChanges(changes: SimpleChanges): void;
38
44
  protected init(): void;
39
45
  /**
40
46
  * @hidden
@@ -47,5 +53,7 @@ export declare class Selection {
47
53
  protected getItemKey(row: RowArgs): any;
48
54
  protected getSelectionItem(row: RowArgs, col: ColumnComponent, colIndex: number): CellSelectionItem;
49
55
  protected onSelectionChange(selection: SelectionEvent): void;
50
- private getCellSelectionItemIndex;
56
+ private notifyChange;
57
+ private setState;
58
+ private stateToArray;
51
59
  }
@@ -3,9 +3,9 @@
3
3
  * Licensed under commercial license. See LICENSE.md in the project root for more information
4
4
  *-------------------------------------------------------------------------------------------*/
5
5
  import * as tslib_1 from "tslib";
6
- /* tslint:disable:no-input-rename */
7
6
  import { Input, EventEmitter, Output } from '@angular/core';
8
7
  import { isPresent } from "../utils";
8
+ import { PairSet } from './pair-set';
9
9
  /**
10
10
  * @hidden
11
11
  */
@@ -21,19 +21,28 @@ export class Selection {
21
21
  * Fires when the `selectedKeys` collection has been updated.
22
22
  */
23
23
  this.selectedKeysChange = new EventEmitter();
24
+ this.rowSelectionState = new Set();
25
+ this.cellSelectionState = new PairSet();
24
26
  this.init();
25
27
  }
28
+ get isCellSelectionMode() {
29
+ return isPresent(this.grid.selectable) && this.grid.selectable['cell'];
30
+ }
31
+ ngOnChanges(changes) {
32
+ // skip reinitialization if the user data is the same as the last state change
33
+ if (isPresent(changes.selectedKeys) && this.lastSelectionState !== this.selectedKeys) {
34
+ this.setState(this.selectedKeys);
35
+ }
36
+ }
26
37
  init() {
27
38
  if (!isPresent(this.grid.rowSelected)) {
28
- this.grid.rowSelected = (row) => {
29
- return this.selectedKeys.indexOf(this.getItemKey(row)) >= 0;
30
- };
39
+ this.grid.rowSelected = (row) => this.rowSelectionState.has(this.getItemKey(row));
31
40
  }
32
41
  if (!isPresent(this.grid.cellSelected)) {
33
42
  this.grid.cellSelected = (row, column, colIndex) => {
34
43
  const contender = this.getSelectionItem(row, column, colIndex);
35
44
  return {
36
- selected: this.selectedKeys.some(item => item.columnKey === contender.columnKey && item.itemKey === contender.itemKey),
45
+ selected: this.cellSelectionState.has(contender.itemKey, contender.columnKey),
37
46
  item: contender
38
47
  };
39
48
  };
@@ -52,7 +61,8 @@ export class Selection {
52
61
  * @hidden
53
62
  */
54
63
  reset() {
55
- this.selectedKeys = [];
64
+ this.rowSelectionState.clear();
65
+ this.cellSelectionState.clear();
56
66
  }
57
67
  getItemKey(row) {
58
68
  if (this.selectionKey) {
@@ -88,43 +98,47 @@ export class Selection {
88
98
  if (selection.selectedRows) {
89
99
  selection.deselectedRows.forEach((item) => {
90
100
  const itemKey = this.getItemKey(item);
91
- const itemIndex = this.selectedKeys.indexOf(itemKey);
92
- if (itemIndex >= 0) {
93
- this.selectedKeys.splice(itemIndex, 1);
94
- }
101
+ this.rowSelectionState.delete(itemKey);
95
102
  });
96
- if (this.grid.selectableSettings.mode === "single" && this.selectedKeys.length > 0) {
103
+ if (this.grid.selectableSettings.mode === "single" && this.rowSelectionState.size > 0) {
97
104
  this.reset();
98
105
  }
99
106
  selection.selectedRows.forEach((item) => {
100
107
  const itemKey = this.getItemKey(item);
101
- if (this.selectedKeys.indexOf(itemKey) < 0) {
102
- this.selectedKeys.push(itemKey);
103
- }
108
+ this.rowSelectionState.add(itemKey);
104
109
  });
105
110
  }
106
111
  else {
107
- selection.deselectedCells.forEach((item) => {
108
- const itemIndex = this.getCellSelectionItemIndex(item);
109
- if (itemIndex >= 0) {
110
- this.selectedKeys.splice(itemIndex, 1);
111
- }
112
+ selection.deselectedCells.forEach(({ itemKey, columnKey }) => {
113
+ this.cellSelectionState.delete(itemKey, columnKey);
112
114
  });
113
- if (this.grid.selectableSettings.mode === "single" && this.selectedKeys.length > 0) {
115
+ if (this.grid.selectableSettings.mode === "single" && this.cellSelectionState.size > 0) {
114
116
  this.reset();
115
117
  }
116
- selection.selectedCells.forEach((item) => {
117
- const itemIndex = this.getCellSelectionItemIndex(item);
118
- if (itemIndex < 0) {
119
- this.selectedKeys.push(item);
120
- }
118
+ selection.selectedCells.forEach(({ itemKey, columnKey }) => {
119
+ this.cellSelectionState.add(itemKey, columnKey);
121
120
  });
122
121
  }
123
122
  this.cd.markForCheck();
124
- this.selectedKeysChange.emit(this.selectedKeys);
123
+ this.notifyChange();
124
+ }
125
+ notifyChange() {
126
+ this.lastSelectionState = this.stateToArray();
127
+ this.selectedKeysChange.emit(this.lastSelectionState);
128
+ }
129
+ setState(selectedKeys) {
130
+ this.reset();
131
+ if (this.isCellSelectionMode) {
132
+ this.cellSelectionState = new PairSet(selectedKeys, 'itemKey', 'columnKey');
133
+ }
134
+ else {
135
+ this.rowSelectionState = new Set(selectedKeys);
136
+ }
125
137
  }
126
- getCellSelectionItemIndex(item) {
127
- return this.selectedKeys.findIndex(selectedItem => selectedItem.itemKey === item.itemKey && selectedItem.columnKey === item.columnKey);
138
+ stateToArray() {
139
+ return this.isCellSelectionMode ?
140
+ this.cellSelectionState.toArray('itemKey', 'columnKey') :
141
+ Array.from(this.rowSelectionState);
128
142
  }
129
143
  }
130
144
  tslib_1.__decorate([
@@ -36,11 +36,11 @@ export declare const isUniversal: () => boolean;
36
36
  /**
37
37
  * @hidden
38
38
  */
39
- export declare const isString: (value: any) => boolean;
39
+ export declare const isString: (value: any) => value is string;
40
40
  /**
41
41
  * @hidden
42
42
  */
43
- export declare const isNumber: (value: any) => boolean;
43
+ export declare const isNumber: (value: any) => value is number;
44
44
  /**
45
45
  * @hidden
46
46
  */