@progress/kendo-angular-grid 5.5.2 → 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.
- package/LICENSE.md +1 -1
- package/NOTICE.txt +119 -79
- package/README.md +1 -1
- package/dist/cdn/js/kendo-angular-grid.js +1 -1
- package/dist/cdn/main.js +1 -1
- package/dist/es/package-metadata.js +1 -1
- package/dist/es/rendering/details-expand.directive.js +20 -6
- package/dist/es/selection/pair-set.js +91 -0
- package/dist/es/selection/selection-default.js +48 -30
- package/dist/es/utils.js +1 -3
- package/dist/es2015/index.metadata.json +1 -1
- package/dist/es2015/package-metadata.js +1 -1
- package/dist/es2015/rendering/details-expand.directive.d.ts +8 -2
- package/dist/es2015/rendering/details-expand.directive.js +20 -6
- package/dist/es2015/selection/pair-set.d.ts +50 -0
- package/dist/es2015/selection/pair-set.js +81 -0
- package/dist/es2015/selection/selection-default.d.ts +10 -2
- package/dist/es2015/selection/selection-default.js +42 -28
- package/dist/es2015/utils.d.ts +2 -2
- package/dist/fesm2015/index.js +139 -33
- package/dist/fesm5/index.js +155 -38
- package/dist/npm/package-metadata.js +1 -1
- package/dist/npm/rendering/details-expand.directive.js +19 -5
- package/dist/npm/selection/pair-set.js +93 -0
- package/dist/npm/selection/selection-default.js +48 -30
- package/dist/npm/utils.js +1 -3
- package/dist/systemjs/kendo-angular-grid.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,93 @@
|
|
|
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
|
+
"use strict";
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
/**
|
|
8
|
+
* @hidden
|
|
9
|
+
*
|
|
10
|
+
* Quick look-up structure for combinations of keys.
|
|
11
|
+
* Similar to the native JS Set, however, working with a couple of keys instead of with a single key.
|
|
12
|
+
* Supports both primitive keys and object keys (compared by reference).
|
|
13
|
+
*/
|
|
14
|
+
var PairSet = /** @class */ (function () {
|
|
15
|
+
function PairSet(items, keyXField, keyYField) {
|
|
16
|
+
var _this = this;
|
|
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
|
+
this.keysX = new Map();
|
|
24
|
+
/**
|
|
25
|
+
* Count the each added or deleted key manually to avoid iterating over all items when calling `this.size`.
|
|
26
|
+
*/
|
|
27
|
+
this.totalKeysCount = 0;
|
|
28
|
+
if (items && keyXField && keyYField) {
|
|
29
|
+
items.forEach(function (item) { return _this.add(item[keyXField], item[keyYField]); });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
Object.defineProperty(PairSet.prototype, "size", {
|
|
33
|
+
/**
|
|
34
|
+
* Gets the total number of X/Y key pairs.
|
|
35
|
+
*/
|
|
36
|
+
get: function () {
|
|
37
|
+
return this.totalKeysCount;
|
|
38
|
+
},
|
|
39
|
+
enumerable: true,
|
|
40
|
+
configurable: true
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* Adds a couple of items identified as a combination.
|
|
44
|
+
*/
|
|
45
|
+
PairSet.prototype.add = function (keyX, keyY) {
|
|
46
|
+
if (!this.keysX.has(keyX)) {
|
|
47
|
+
this.keysX.set(keyX, new Set());
|
|
48
|
+
}
|
|
49
|
+
if (!this.has(keyX, keyY)) {
|
|
50
|
+
this.keysX.get(keyX).add(keyY);
|
|
51
|
+
this.totalKeysCount += 1;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Adds a combination of a couple of items identified together.
|
|
56
|
+
*/
|
|
57
|
+
PairSet.prototype.delete = function (keyX, keyY) {
|
|
58
|
+
if (this.has(keyX, keyY)) {
|
|
59
|
+
this.keysX.get(keyX).delete(keyY);
|
|
60
|
+
this.totalKeysCount -= 1;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Checks whether the defined combination is stored.
|
|
65
|
+
*/
|
|
66
|
+
PairSet.prototype.has = function (keyX, keyY) {
|
|
67
|
+
return this.keysX.has(keyX) && this.keysX.get(keyX).has(keyY);
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Clears all key combinations.
|
|
71
|
+
*/
|
|
72
|
+
PairSet.prototype.clear = function () {
|
|
73
|
+
this.keysX.clear();
|
|
74
|
+
this.totalKeysCount = 0;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Converts the persisted data structure to an array of objects,
|
|
78
|
+
* using the provided field names for the object props.
|
|
79
|
+
*/
|
|
80
|
+
PairSet.prototype.toArray = function (keyXField, keyYField) {
|
|
81
|
+
return Array.from(this.keysX).reduce(function (pairs, pair) {
|
|
82
|
+
// Array.from(mapInstance) returns an array of arrays [[itemKey1, columnKeysSet1], [itemKey2, columnKeysSet2]]
|
|
83
|
+
var keyX = pair[0], keysY = pair[1];
|
|
84
|
+
Array.from(keysY).forEach(function (keyY) {
|
|
85
|
+
var _a;
|
|
86
|
+
return pairs.push((_a = {}, _a[keyXField] = keyX, _a[keyYField] = keyY, _a));
|
|
87
|
+
});
|
|
88
|
+
return pairs;
|
|
89
|
+
}, []);
|
|
90
|
+
};
|
|
91
|
+
return PairSet;
|
|
92
|
+
}());
|
|
93
|
+
exports.PairSet = PairSet;
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
"use strict";
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
var tslib_1 = require("tslib");
|
|
8
|
-
/* tslint:disable:no-input-rename */
|
|
9
8
|
var core_1 = require("@angular/core");
|
|
10
9
|
var utils_1 = require("../utils");
|
|
10
|
+
var pair_set_1 = require("./pair-set");
|
|
11
11
|
/**
|
|
12
12
|
* @hidden
|
|
13
13
|
*/
|
|
@@ -23,20 +23,33 @@ var Selection = /** @class */ (function () {
|
|
|
23
23
|
* Fires when the `selectedKeys` collection has been updated.
|
|
24
24
|
*/
|
|
25
25
|
this.selectedKeysChange = new core_1.EventEmitter();
|
|
26
|
+
this.rowSelectionState = new Set();
|
|
27
|
+
this.cellSelectionState = new pair_set_1.PairSet();
|
|
26
28
|
this.init();
|
|
27
29
|
}
|
|
30
|
+
Object.defineProperty(Selection.prototype, "isCellSelectionMode", {
|
|
31
|
+
get: function () {
|
|
32
|
+
return utils_1.isPresent(this.grid.selectable) && this.grid.selectable['cell'];
|
|
33
|
+
},
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: true
|
|
36
|
+
});
|
|
37
|
+
Selection.prototype.ngOnChanges = function (changes) {
|
|
38
|
+
// skip reinitialization if the user data is the same as the last state change
|
|
39
|
+
if (utils_1.isPresent(changes.selectedKeys) && this.lastSelectionState !== this.selectedKeys) {
|
|
40
|
+
this.setState(this.selectedKeys);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
28
43
|
Selection.prototype.init = function () {
|
|
29
44
|
var _this = this;
|
|
30
45
|
if (!utils_1.isPresent(this.grid.rowSelected)) {
|
|
31
|
-
this.grid.rowSelected = function (row) {
|
|
32
|
-
return _this.selectedKeys.indexOf(_this.getItemKey(row)) >= 0;
|
|
33
|
-
};
|
|
46
|
+
this.grid.rowSelected = function (row) { return _this.rowSelectionState.has(_this.getItemKey(row)); };
|
|
34
47
|
}
|
|
35
48
|
if (!utils_1.isPresent(this.grid.cellSelected)) {
|
|
36
49
|
this.grid.cellSelected = function (row, column, colIndex) {
|
|
37
50
|
var contender = _this.getSelectionItem(row, column, colIndex);
|
|
38
51
|
return {
|
|
39
|
-
selected: _this.
|
|
52
|
+
selected: _this.cellSelectionState.has(contender.itemKey, contender.columnKey),
|
|
40
53
|
item: contender
|
|
41
54
|
};
|
|
42
55
|
};
|
|
@@ -55,7 +68,8 @@ var Selection = /** @class */ (function () {
|
|
|
55
68
|
* @hidden
|
|
56
69
|
*/
|
|
57
70
|
Selection.prototype.reset = function () {
|
|
58
|
-
this.
|
|
71
|
+
this.rowSelectionState.clear();
|
|
72
|
+
this.cellSelectionState.clear();
|
|
59
73
|
};
|
|
60
74
|
Selection.prototype.getItemKey = function (row) {
|
|
61
75
|
if (this.selectionKey) {
|
|
@@ -92,45 +106,49 @@ var Selection = /** @class */ (function () {
|
|
|
92
106
|
if (selection.selectedRows) {
|
|
93
107
|
selection.deselectedRows.forEach(function (item) {
|
|
94
108
|
var itemKey = _this.getItemKey(item);
|
|
95
|
-
|
|
96
|
-
if (itemIndex >= 0) {
|
|
97
|
-
_this.selectedKeys.splice(itemIndex, 1);
|
|
98
|
-
}
|
|
109
|
+
_this.rowSelectionState.delete(itemKey);
|
|
99
110
|
});
|
|
100
|
-
if (this.grid.selectableSettings.mode === "single" && this.
|
|
111
|
+
if (this.grid.selectableSettings.mode === "single" && this.rowSelectionState.size > 0) {
|
|
101
112
|
this.reset();
|
|
102
113
|
}
|
|
103
114
|
selection.selectedRows.forEach(function (item) {
|
|
104
115
|
var itemKey = _this.getItemKey(item);
|
|
105
|
-
|
|
106
|
-
_this.selectedKeys.push(itemKey);
|
|
107
|
-
}
|
|
116
|
+
_this.rowSelectionState.add(itemKey);
|
|
108
117
|
});
|
|
109
118
|
}
|
|
110
119
|
else {
|
|
111
|
-
selection.deselectedCells.forEach(function (
|
|
112
|
-
var
|
|
113
|
-
|
|
114
|
-
_this.selectedKeys.splice(itemIndex, 1);
|
|
115
|
-
}
|
|
120
|
+
selection.deselectedCells.forEach(function (_a) {
|
|
121
|
+
var itemKey = _a.itemKey, columnKey = _a.columnKey;
|
|
122
|
+
_this.cellSelectionState.delete(itemKey, columnKey);
|
|
116
123
|
});
|
|
117
|
-
if (this.grid.selectableSettings.mode === "single" && this.
|
|
124
|
+
if (this.grid.selectableSettings.mode === "single" && this.cellSelectionState.size > 0) {
|
|
118
125
|
this.reset();
|
|
119
126
|
}
|
|
120
|
-
selection.selectedCells.forEach(function (
|
|
121
|
-
var
|
|
122
|
-
|
|
123
|
-
_this.selectedKeys.push(item);
|
|
124
|
-
}
|
|
127
|
+
selection.selectedCells.forEach(function (_a) {
|
|
128
|
+
var itemKey = _a.itemKey, columnKey = _a.columnKey;
|
|
129
|
+
_this.cellSelectionState.add(itemKey, columnKey);
|
|
125
130
|
});
|
|
126
131
|
}
|
|
127
132
|
this.cd.markForCheck();
|
|
128
|
-
this.
|
|
133
|
+
this.notifyChange();
|
|
134
|
+
};
|
|
135
|
+
Selection.prototype.notifyChange = function () {
|
|
136
|
+
this.lastSelectionState = this.stateToArray();
|
|
137
|
+
this.selectedKeysChange.emit(this.lastSelectionState);
|
|
138
|
+
};
|
|
139
|
+
Selection.prototype.setState = function (selectedKeys) {
|
|
140
|
+
this.reset();
|
|
141
|
+
if (this.isCellSelectionMode) {
|
|
142
|
+
this.cellSelectionState = new pair_set_1.PairSet(selectedKeys, 'itemKey', 'columnKey');
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
this.rowSelectionState = new Set(selectedKeys);
|
|
146
|
+
}
|
|
129
147
|
};
|
|
130
|
-
Selection.prototype.
|
|
131
|
-
return this.
|
|
132
|
-
|
|
133
|
-
|
|
148
|
+
Selection.prototype.stateToArray = function () {
|
|
149
|
+
return this.isCellSelectionMode ?
|
|
150
|
+
this.cellSelectionState.toArray('itemKey', 'columnKey') :
|
|
151
|
+
Array.from(this.rowSelectionState);
|
|
134
152
|
};
|
|
135
153
|
tslib_1.__decorate([
|
|
136
154
|
core_1.Input(),
|
package/dist/npm/utils.js
CHANGED
|
@@ -45,9 +45,7 @@ exports.isUniversal = function () { return typeof document === 'undefined'; };
|
|
|
45
45
|
/**
|
|
46
46
|
* @hidden
|
|
47
47
|
*/
|
|
48
|
-
exports.isString = function (value) {
|
|
49
|
-
return typeof value === 'string';
|
|
50
|
-
};
|
|
48
|
+
exports.isString = function (value) { return typeof value === 'string'; };
|
|
51
49
|
/**
|
|
52
50
|
* @hidden
|
|
53
51
|
*/
|