@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.
@@ -2831,7 +2831,7 @@ const packageMetadata = {
2831
2831
  name: '@progress/kendo-angular-grid',
2832
2832
  productName: 'Kendo UI for Angular',
2833
2833
  productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
2834
- publishDate: 1641921939,
2834
+ publishDate: 1642155100,
2835
2835
  version: '',
2836
2836
  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'
2837
2837
  };
@@ -4760,6 +4760,84 @@ class DataCollection {
4760
4760
  toString() { return this.accessor().toString(); }
4761
4761
  }
4762
4762
 
4763
+ /**
4764
+ * @hidden
4765
+ *
4766
+ * Quick look-up structure for combinations of keys.
4767
+ * Similar to the native JS Set, however, working with a couple of keys instead of with a single key.
4768
+ * Supports both primitive keys and object keys (compared by reference).
4769
+ */
4770
+ class PairSet {
4771
+ constructor(items, keyXField, keyYField) {
4772
+ /**
4773
+ * Holds a set of Y keys for each defined X key.
4774
+ * Each X key creates a map which holds a set of Y keys.
4775
+ *
4776
+ * Map { 1 => Set { 1, 2, 3 } } // pairs: [1, 1], [1, 2], [1, 3]
4777
+ */
4778
+ this.keysX = new Map();
4779
+ /**
4780
+ * Count the each added or deleted key manually to avoid iterating over all items when calling `this.size`.
4781
+ */
4782
+ this.totalKeysCount = 0;
4783
+ if (items && keyXField && keyYField) {
4784
+ items.forEach(item => this.add(item[keyXField], item[keyYField]));
4785
+ }
4786
+ }
4787
+ /**
4788
+ * Gets the total number of X/Y key pairs.
4789
+ */
4790
+ get size() {
4791
+ return this.totalKeysCount;
4792
+ }
4793
+ /**
4794
+ * Adds a couple of items identified as a combination.
4795
+ */
4796
+ add(keyX, keyY) {
4797
+ if (!this.keysX.has(keyX)) {
4798
+ this.keysX.set(keyX, new Set());
4799
+ }
4800
+ if (!this.has(keyX, keyY)) {
4801
+ this.keysX.get(keyX).add(keyY);
4802
+ this.totalKeysCount += 1;
4803
+ }
4804
+ }
4805
+ /**
4806
+ * Adds a combination of a couple of items identified together.
4807
+ */
4808
+ delete(keyX, keyY) {
4809
+ if (this.has(keyX, keyY)) {
4810
+ this.keysX.get(keyX).delete(keyY);
4811
+ this.totalKeysCount -= 1;
4812
+ }
4813
+ }
4814
+ /**
4815
+ * Checks whether the defined combination is stored.
4816
+ */
4817
+ has(keyX, keyY) {
4818
+ return this.keysX.has(keyX) && this.keysX.get(keyX).has(keyY);
4819
+ }
4820
+ /**
4821
+ * Clears all key combinations.
4822
+ */
4823
+ clear() {
4824
+ this.keysX.clear();
4825
+ this.totalKeysCount = 0;
4826
+ }
4827
+ /**
4828
+ * Converts the persisted data structure to an array of objects,
4829
+ * using the provided field names for the object props.
4830
+ */
4831
+ toArray(keyXField, keyYField) {
4832
+ return Array.from(this.keysX).reduce((pairs, pair) => {
4833
+ // Array.from(mapInstance) returns an array of arrays [[itemKey1, columnKeysSet1], [itemKey2, columnKeysSet2]]
4834
+ const [keyX, keysY] = pair;
4835
+ Array.from(keysY).forEach(keyY => pairs.push({ [keyXField]: keyX, [keyYField]: keyY }));
4836
+ return pairs;
4837
+ }, []);
4838
+ }
4839
+ }
4840
+
4763
4841
  /**
4764
4842
  * @hidden
4765
4843
  */
@@ -4775,19 +4853,28 @@ class Selection {
4775
4853
  * Fires when the `selectedKeys` collection has been updated.
4776
4854
  */
4777
4855
  this.selectedKeysChange = new EventEmitter();
4856
+ this.rowSelectionState = new Set();
4857
+ this.cellSelectionState = new PairSet();
4778
4858
  this.init();
4779
4859
  }
4860
+ get isCellSelectionMode() {
4861
+ return isPresent(this.grid.selectable) && this.grid.selectable['cell'];
4862
+ }
4863
+ ngOnChanges(changes) {
4864
+ // skip reinitialization if the user data is the same as the last state change
4865
+ if (isPresent(changes.selectedKeys) && this.lastSelectionState !== this.selectedKeys) {
4866
+ this.setState(this.selectedKeys);
4867
+ }
4868
+ }
4780
4869
  init() {
4781
4870
  if (!isPresent(this.grid.rowSelected)) {
4782
- this.grid.rowSelected = (row) => {
4783
- return this.selectedKeys.indexOf(this.getItemKey(row)) >= 0;
4784
- };
4871
+ this.grid.rowSelected = (row) => this.rowSelectionState.has(this.getItemKey(row));
4785
4872
  }
4786
4873
  if (!isPresent(this.grid.cellSelected)) {
4787
4874
  this.grid.cellSelected = (row, column, colIndex) => {
4788
4875
  const contender = this.getSelectionItem(row, column, colIndex);
4789
4876
  return {
4790
- selected: this.selectedKeys.some(item => item.columnKey === contender.columnKey && item.itemKey === contender.itemKey),
4877
+ selected: this.cellSelectionState.has(contender.itemKey, contender.columnKey),
4791
4878
  item: contender
4792
4879
  };
4793
4880
  };
@@ -4806,7 +4893,8 @@ class Selection {
4806
4893
  * @hidden
4807
4894
  */
4808
4895
  reset() {
4809
- this.selectedKeys = [];
4896
+ this.rowSelectionState.clear();
4897
+ this.cellSelectionState.clear();
4810
4898
  }
4811
4899
  getItemKey(row) {
4812
4900
  if (this.selectionKey) {
@@ -4842,43 +4930,47 @@ class Selection {
4842
4930
  if (selection.selectedRows) {
4843
4931
  selection.deselectedRows.forEach((item) => {
4844
4932
  const itemKey = this.getItemKey(item);
4845
- const itemIndex = this.selectedKeys.indexOf(itemKey);
4846
- if (itemIndex >= 0) {
4847
- this.selectedKeys.splice(itemIndex, 1);
4848
- }
4933
+ this.rowSelectionState.delete(itemKey);
4849
4934
  });
4850
- if (this.grid.selectableSettings.mode === "single" && this.selectedKeys.length > 0) {
4935
+ if (this.grid.selectableSettings.mode === "single" && this.rowSelectionState.size > 0) {
4851
4936
  this.reset();
4852
4937
  }
4853
4938
  selection.selectedRows.forEach((item) => {
4854
4939
  const itemKey = this.getItemKey(item);
4855
- if (this.selectedKeys.indexOf(itemKey) < 0) {
4856
- this.selectedKeys.push(itemKey);
4857
- }
4940
+ this.rowSelectionState.add(itemKey);
4858
4941
  });
4859
4942
  }
4860
4943
  else {
4861
- selection.deselectedCells.forEach((item) => {
4862
- const itemIndex = this.getCellSelectionItemIndex(item);
4863
- if (itemIndex >= 0) {
4864
- this.selectedKeys.splice(itemIndex, 1);
4865
- }
4944
+ selection.deselectedCells.forEach(({ itemKey, columnKey }) => {
4945
+ this.cellSelectionState.delete(itemKey, columnKey);
4866
4946
  });
4867
- if (this.grid.selectableSettings.mode === "single" && this.selectedKeys.length > 0) {
4947
+ if (this.grid.selectableSettings.mode === "single" && this.cellSelectionState.size > 0) {
4868
4948
  this.reset();
4869
4949
  }
4870
- selection.selectedCells.forEach((item) => {
4871
- const itemIndex = this.getCellSelectionItemIndex(item);
4872
- if (itemIndex < 0) {
4873
- this.selectedKeys.push(item);
4874
- }
4950
+ selection.selectedCells.forEach(({ itemKey, columnKey }) => {
4951
+ this.cellSelectionState.add(itemKey, columnKey);
4875
4952
  });
4876
4953
  }
4877
4954
  this.cd.markForCheck();
4878
- this.selectedKeysChange.emit(this.selectedKeys);
4955
+ this.notifyChange();
4879
4956
  }
4880
- getCellSelectionItemIndex(item) {
4881
- return this.selectedKeys.findIndex(selectedItem => selectedItem.itemKey === item.itemKey && selectedItem.columnKey === item.columnKey);
4957
+ notifyChange() {
4958
+ this.lastSelectionState = this.stateToArray();
4959
+ this.selectedKeysChange.emit(this.lastSelectionState);
4960
+ }
4961
+ setState(selectedKeys) {
4962
+ this.reset();
4963
+ if (this.isCellSelectionMode) {
4964
+ this.cellSelectionState = new PairSet(selectedKeys, 'itemKey', 'columnKey');
4965
+ }
4966
+ else {
4967
+ this.rowSelectionState = new Set(selectedKeys);
4968
+ }
4969
+ }
4970
+ stateToArray() {
4971
+ return this.isCellSelectionMode ?
4972
+ this.cellSelectionState.toArray('itemKey', 'columnKey') :
4973
+ Array.from(this.rowSelectionState);
4882
4974
  }
4883
4975
  }
4884
4976
  __decorate([
@@ -10375,9 +10467,12 @@ let ExpandDetailsDirective = class ExpandDetailsDirective {
10375
10467
  this.expandedDetailKeys = [];
10376
10468
  /**
10377
10469
  * Specifies if the items should be initially expanded.
10470
+ * When set to `true` items added to the `expandedDetailKeys` collection will be collapsed, and items that are not present in it will be expanded.
10471
+ *
10378
10472
  * @default false
10379
10473
  */
10380
10474
  this.initiallyExpanded = false;
10475
+ this.expandedState = new Set();
10381
10476
  this.subscriptions = new Subscription();
10382
10477
  this.grid.isDetailExpanded = this.isExpanded.bind(this);
10383
10478
  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)));
@@ -10407,6 +10502,12 @@ let ExpandDetailsDirective = class ExpandDetailsDirective {
10407
10502
  set expandDetailBy(key) {
10408
10503
  this.expandDetailsKey = key;
10409
10504
  }
10505
+ ngOnChanges(changes) {
10506
+ // skip reinitialization if the user data is the same as the last state change
10507
+ if (isPresent(changes.expandedDetailKeys) && this.lastExpandedState !== this.expandedDetailKeys) {
10508
+ this.expandedState = new Set(this.expandedDetailKeys);
10509
+ }
10510
+ }
10410
10511
  ngOnDestroy() {
10411
10512
  this.subscriptions.unsubscribe();
10412
10513
  }
@@ -10418,18 +10519,23 @@ let ExpandDetailsDirective = class ExpandDetailsDirective {
10418
10519
  */
10419
10520
  isExpanded(args) {
10420
10521
  const key = this.keyGetter(args.dataItem);
10421
- return this.expandedDetailKeys.indexOf(key) > -1 ? !this.initiallyExpanded : this.initiallyExpanded;
10522
+ const hasKey = this.expandedState.has(key);
10523
+ // when [initiallyExpanded]="true" a present key means the corresponding detail row is collapsed
10524
+ return this.initiallyExpanded ? !hasKey : hasKey;
10422
10525
  }
10423
10526
  toggleState(args) {
10424
10527
  const key = this.keyGetter(args.dataItem);
10425
10528
  if (Boolean(this.initiallyExpanded) !== args.expand) {
10426
- this.expandedDetailKeys.push(key);
10529
+ this.expandedState.add(key);
10427
10530
  }
10428
10531
  else {
10429
- const index = this.expandedDetailKeys.indexOf(key);
10430
- this.expandedDetailKeys.splice(index, 1);
10532
+ this.expandedState.delete(key);
10431
10533
  }
10432
- this.expandedDetailKeysChange.emit(this.expandedDetailKeys);
10534
+ this.notifyChange();
10535
+ }
10536
+ notifyChange() {
10537
+ this.lastExpandedState = Array.from(this.expandedState);
10538
+ this.expandedDetailKeysChange.emit(this.lastExpandedState);
10433
10539
  }
10434
10540
  };
10435
10541
  __decorate([
@@ -60,9 +60,7 @@ var isUniversal = function () { return typeof document === 'undefined'; };
60
60
  /**
61
61
  * @hidden
62
62
  */
63
- var isString = function (value) {
64
- return typeof value === 'string';
65
- };
63
+ var isString = function (value) { return typeof value === 'string'; };
66
64
  /**
67
65
  * @hidden
68
66
  */
@@ -3046,7 +3044,7 @@ var packageMetadata = {
3046
3044
  name: '@progress/kendo-angular-grid',
3047
3045
  productName: 'Kendo UI for Angular',
3048
3046
  productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
3049
- publishDate: 1641921939,
3047
+ publishDate: 1642155100,
3050
3048
  version: '',
3051
3049
  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'
3052
3050
  };
@@ -5206,6 +5204,93 @@ var DataCollection = /** @class */ (function () {
5206
5204
  return DataCollection;
5207
5205
  }());
5208
5206
 
5207
+ /**
5208
+ * @hidden
5209
+ *
5210
+ * Quick look-up structure for combinations of keys.
5211
+ * Similar to the native JS Set, however, working with a couple of keys instead of with a single key.
5212
+ * Supports both primitive keys and object keys (compared by reference).
5213
+ */
5214
+ var PairSet = /** @class */ (function () {
5215
+ function PairSet(items, keyXField, keyYField) {
5216
+ var _this = this;
5217
+ /**
5218
+ * Holds a set of Y keys for each defined X key.
5219
+ * Each X key creates a map which holds a set of Y keys.
5220
+ *
5221
+ * Map { 1 => Set { 1, 2, 3 } } // pairs: [1, 1], [1, 2], [1, 3]
5222
+ */
5223
+ this.keysX = new Map();
5224
+ /**
5225
+ * Count the each added or deleted key manually to avoid iterating over all items when calling `this.size`.
5226
+ */
5227
+ this.totalKeysCount = 0;
5228
+ if (items && keyXField && keyYField) {
5229
+ items.forEach(function (item) { return _this.add(item[keyXField], item[keyYField]); });
5230
+ }
5231
+ }
5232
+ Object.defineProperty(PairSet.prototype, "size", {
5233
+ /**
5234
+ * Gets the total number of X/Y key pairs.
5235
+ */
5236
+ get: function () {
5237
+ return this.totalKeysCount;
5238
+ },
5239
+ enumerable: true,
5240
+ configurable: true
5241
+ });
5242
+ /**
5243
+ * Adds a couple of items identified as a combination.
5244
+ */
5245
+ PairSet.prototype.add = function (keyX, keyY) {
5246
+ if (!this.keysX.has(keyX)) {
5247
+ this.keysX.set(keyX, new Set());
5248
+ }
5249
+ if (!this.has(keyX, keyY)) {
5250
+ this.keysX.get(keyX).add(keyY);
5251
+ this.totalKeysCount += 1;
5252
+ }
5253
+ };
5254
+ /**
5255
+ * Adds a combination of a couple of items identified together.
5256
+ */
5257
+ PairSet.prototype.delete = function (keyX, keyY) {
5258
+ if (this.has(keyX, keyY)) {
5259
+ this.keysX.get(keyX).delete(keyY);
5260
+ this.totalKeysCount -= 1;
5261
+ }
5262
+ };
5263
+ /**
5264
+ * Checks whether the defined combination is stored.
5265
+ */
5266
+ PairSet.prototype.has = function (keyX, keyY) {
5267
+ return this.keysX.has(keyX) && this.keysX.get(keyX).has(keyY);
5268
+ };
5269
+ /**
5270
+ * Clears all key combinations.
5271
+ */
5272
+ PairSet.prototype.clear = function () {
5273
+ this.keysX.clear();
5274
+ this.totalKeysCount = 0;
5275
+ };
5276
+ /**
5277
+ * Converts the persisted data structure to an array of objects,
5278
+ * using the provided field names for the object props.
5279
+ */
5280
+ PairSet.prototype.toArray = function (keyXField, keyYField) {
5281
+ return Array.from(this.keysX).reduce(function (pairs, pair) {
5282
+ // Array.from(mapInstance) returns an array of arrays [[itemKey1, columnKeysSet1], [itemKey2, columnKeysSet2]]
5283
+ var keyX = pair[0], keysY = pair[1];
5284
+ Array.from(keysY).forEach(function (keyY) {
5285
+ var _a;
5286
+ return pairs.push((_a = {}, _a[keyXField] = keyX, _a[keyYField] = keyY, _a));
5287
+ });
5288
+ return pairs;
5289
+ }, []);
5290
+ };
5291
+ return PairSet;
5292
+ }());
5293
+
5209
5294
  /**
5210
5295
  * @hidden
5211
5296
  */
@@ -5221,20 +5306,33 @@ var Selection = /** @class */ (function () {
5221
5306
  * Fires when the `selectedKeys` collection has been updated.
5222
5307
  */
5223
5308
  this.selectedKeysChange = new EventEmitter();
5309
+ this.rowSelectionState = new Set();
5310
+ this.cellSelectionState = new PairSet();
5224
5311
  this.init();
5225
5312
  }
5313
+ Object.defineProperty(Selection.prototype, "isCellSelectionMode", {
5314
+ get: function () {
5315
+ return isPresent(this.grid.selectable) && this.grid.selectable['cell'];
5316
+ },
5317
+ enumerable: true,
5318
+ configurable: true
5319
+ });
5320
+ Selection.prototype.ngOnChanges = function (changes) {
5321
+ // skip reinitialization if the user data is the same as the last state change
5322
+ if (isPresent(changes.selectedKeys) && this.lastSelectionState !== this.selectedKeys) {
5323
+ this.setState(this.selectedKeys);
5324
+ }
5325
+ };
5226
5326
  Selection.prototype.init = function () {
5227
5327
  var _this = this;
5228
5328
  if (!isPresent(this.grid.rowSelected)) {
5229
- this.grid.rowSelected = function (row) {
5230
- return _this.selectedKeys.indexOf(_this.getItemKey(row)) >= 0;
5231
- };
5329
+ this.grid.rowSelected = function (row) { return _this.rowSelectionState.has(_this.getItemKey(row)); };
5232
5330
  }
5233
5331
  if (!isPresent(this.grid.cellSelected)) {
5234
5332
  this.grid.cellSelected = function (row, column, colIndex) {
5235
5333
  var contender = _this.getSelectionItem(row, column, colIndex);
5236
5334
  return {
5237
- selected: _this.selectedKeys.some(function (item) { return item.columnKey === contender.columnKey && item.itemKey === contender.itemKey; }),
5335
+ selected: _this.cellSelectionState.has(contender.itemKey, contender.columnKey),
5238
5336
  item: contender
5239
5337
  };
5240
5338
  };
@@ -5253,7 +5351,8 @@ var Selection = /** @class */ (function () {
5253
5351
  * @hidden
5254
5352
  */
5255
5353
  Selection.prototype.reset = function () {
5256
- this.selectedKeys = [];
5354
+ this.rowSelectionState.clear();
5355
+ this.cellSelectionState.clear();
5257
5356
  };
5258
5357
  Selection.prototype.getItemKey = function (row) {
5259
5358
  if (this.selectionKey) {
@@ -5290,45 +5389,49 @@ var Selection = /** @class */ (function () {
5290
5389
  if (selection.selectedRows) {
5291
5390
  selection.deselectedRows.forEach(function (item) {
5292
5391
  var itemKey = _this.getItemKey(item);
5293
- var itemIndex = _this.selectedKeys.indexOf(itemKey);
5294
- if (itemIndex >= 0) {
5295
- _this.selectedKeys.splice(itemIndex, 1);
5296
- }
5392
+ _this.rowSelectionState.delete(itemKey);
5297
5393
  });
5298
- if (this.grid.selectableSettings.mode === "single" && this.selectedKeys.length > 0) {
5394
+ if (this.grid.selectableSettings.mode === "single" && this.rowSelectionState.size > 0) {
5299
5395
  this.reset();
5300
5396
  }
5301
5397
  selection.selectedRows.forEach(function (item) {
5302
5398
  var itemKey = _this.getItemKey(item);
5303
- if (_this.selectedKeys.indexOf(itemKey) < 0) {
5304
- _this.selectedKeys.push(itemKey);
5305
- }
5399
+ _this.rowSelectionState.add(itemKey);
5306
5400
  });
5307
5401
  }
5308
5402
  else {
5309
- selection.deselectedCells.forEach(function (item) {
5310
- var itemIndex = _this.getCellSelectionItemIndex(item);
5311
- if (itemIndex >= 0) {
5312
- _this.selectedKeys.splice(itemIndex, 1);
5313
- }
5403
+ selection.deselectedCells.forEach(function (_a) {
5404
+ var itemKey = _a.itemKey, columnKey = _a.columnKey;
5405
+ _this.cellSelectionState.delete(itemKey, columnKey);
5314
5406
  });
5315
- if (this.grid.selectableSettings.mode === "single" && this.selectedKeys.length > 0) {
5407
+ if (this.grid.selectableSettings.mode === "single" && this.cellSelectionState.size > 0) {
5316
5408
  this.reset();
5317
5409
  }
5318
- selection.selectedCells.forEach(function (item) {
5319
- var itemIndex = _this.getCellSelectionItemIndex(item);
5320
- if (itemIndex < 0) {
5321
- _this.selectedKeys.push(item);
5322
- }
5410
+ selection.selectedCells.forEach(function (_a) {
5411
+ var itemKey = _a.itemKey, columnKey = _a.columnKey;
5412
+ _this.cellSelectionState.add(itemKey, columnKey);
5323
5413
  });
5324
5414
  }
5325
5415
  this.cd.markForCheck();
5326
- this.selectedKeysChange.emit(this.selectedKeys);
5416
+ this.notifyChange();
5327
5417
  };
5328
- Selection.prototype.getCellSelectionItemIndex = function (item) {
5329
- return this.selectedKeys.findIndex(function (selectedItem) {
5330
- return selectedItem.itemKey === item.itemKey && selectedItem.columnKey === item.columnKey;
5331
- });
5418
+ Selection.prototype.notifyChange = function () {
5419
+ this.lastSelectionState = this.stateToArray();
5420
+ this.selectedKeysChange.emit(this.lastSelectionState);
5421
+ };
5422
+ Selection.prototype.setState = function (selectedKeys) {
5423
+ this.reset();
5424
+ if (this.isCellSelectionMode) {
5425
+ this.cellSelectionState = new PairSet(selectedKeys, 'itemKey', 'columnKey');
5426
+ }
5427
+ else {
5428
+ this.rowSelectionState = new Set(selectedKeys);
5429
+ }
5430
+ };
5431
+ Selection.prototype.stateToArray = function () {
5432
+ return this.isCellSelectionMode ?
5433
+ this.cellSelectionState.toArray('itemKey', 'columnKey') :
5434
+ Array.from(this.rowSelectionState);
5332
5435
  };
5333
5436
  __decorate([
5334
5437
  Input(),
@@ -10741,9 +10844,12 @@ var ExpandDetailsDirective = /** @class */ (function () {
10741
10844
  this.expandedDetailKeys = [];
10742
10845
  /**
10743
10846
  * Specifies if the items should be initially expanded.
10847
+ * When set to `true` items added to the `expandedDetailKeys` collection will be collapsed, and items that are not present in it will be expanded.
10848
+ *
10744
10849
  * @default false
10745
10850
  */
10746
10851
  this.initiallyExpanded = false;
10852
+ this.expandedState = new Set();
10747
10853
  this.subscriptions = new Subscription();
10748
10854
  this.grid.isDetailExpanded = this.isExpanded.bind(this);
10749
10855
  this.subscriptions.add(merge(this.grid.detailExpand.pipe(map(function (e) { return (__assign({ expand: true }, e)); })), this.grid.detailCollapse.pipe(map(function (e) { return (__assign({ expand: false }, e)); }))).subscribe(this.toggleState.bind(this)));
@@ -10781,6 +10887,12 @@ var ExpandDetailsDirective = /** @class */ (function () {
10781
10887
  enumerable: true,
10782
10888
  configurable: true
10783
10889
  });
10890
+ ExpandDetailsDirective.prototype.ngOnChanges = function (changes) {
10891
+ // skip reinitialization if the user data is the same as the last state change
10892
+ if (isPresent(changes.expandedDetailKeys) && this.lastExpandedState !== this.expandedDetailKeys) {
10893
+ this.expandedState = new Set(this.expandedDetailKeys);
10894
+ }
10895
+ };
10784
10896
  ExpandDetailsDirective.prototype.ngOnDestroy = function () {
10785
10897
  this.subscriptions.unsubscribe();
10786
10898
  };
@@ -10796,18 +10908,23 @@ var ExpandDetailsDirective = /** @class */ (function () {
10796
10908
  */
10797
10909
  ExpandDetailsDirective.prototype.isExpanded = function (args) {
10798
10910
  var key = this.keyGetter(args.dataItem);
10799
- return this.expandedDetailKeys.indexOf(key) > -1 ? !this.initiallyExpanded : this.initiallyExpanded;
10911
+ var hasKey = this.expandedState.has(key);
10912
+ // when [initiallyExpanded]="true" a present key means the corresponding detail row is collapsed
10913
+ return this.initiallyExpanded ? !hasKey : hasKey;
10800
10914
  };
10801
10915
  ExpandDetailsDirective.prototype.toggleState = function (args) {
10802
10916
  var key = this.keyGetter(args.dataItem);
10803
10917
  if (Boolean(this.initiallyExpanded) !== args.expand) {
10804
- this.expandedDetailKeys.push(key);
10918
+ this.expandedState.add(key);
10805
10919
  }
10806
10920
  else {
10807
- var index = this.expandedDetailKeys.indexOf(key);
10808
- this.expandedDetailKeys.splice(index, 1);
10921
+ this.expandedState.delete(key);
10809
10922
  }
10810
- this.expandedDetailKeysChange.emit(this.expandedDetailKeys);
10923
+ this.notifyChange();
10924
+ };
10925
+ ExpandDetailsDirective.prototype.notifyChange = function () {
10926
+ this.lastExpandedState = Array.from(this.expandedState);
10927
+ this.expandedDetailKeysChange.emit(this.lastExpandedState);
10811
10928
  };
10812
10929
  __decorate([
10813
10930
  Output(),
@@ -11,7 +11,7 @@ exports.packageMetadata = {
11
11
  name: '@progress/kendo-angular-grid',
12
12
  productName: 'Kendo UI for Angular',
13
13
  productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
14
- publishDate: 1641921939,
14
+ publishDate: 1642155100,
15
15
  version: '',
16
16
  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'
17
17
  };
@@ -27,9 +27,12 @@ var ExpandDetailsDirective = /** @class */ (function () {
27
27
  this.expandedDetailKeys = [];
28
28
  /**
29
29
  * Specifies if the items should be initially expanded.
30
+ * When set to `true` items added to the `expandedDetailKeys` collection will be collapsed, and items that are not present in it will be expanded.
31
+ *
30
32
  * @default false
31
33
  */
32
34
  this.initiallyExpanded = false;
35
+ this.expandedState = new Set();
33
36
  this.subscriptions = new rxjs_1.Subscription();
34
37
  this.grid.isDetailExpanded = this.isExpanded.bind(this);
35
38
  this.subscriptions.add(rxjs_1.merge(this.grid.detailExpand.pipe(operators_1.map(function (e) { return (tslib_1.__assign({ expand: true }, e)); })), this.grid.detailCollapse.pipe(operators_1.map(function (e) { return (tslib_1.__assign({ expand: false }, e)); }))).subscribe(this.toggleState.bind(this)));
@@ -67,6 +70,12 @@ var ExpandDetailsDirective = /** @class */ (function () {
67
70
  enumerable: true,
68
71
  configurable: true
69
72
  });
73
+ ExpandDetailsDirective.prototype.ngOnChanges = function (changes) {
74
+ // skip reinitialization if the user data is the same as the last state change
75
+ if (utils_1.isPresent(changes.expandedDetailKeys) && this.lastExpandedState !== this.expandedDetailKeys) {
76
+ this.expandedState = new Set(this.expandedDetailKeys);
77
+ }
78
+ };
70
79
  ExpandDetailsDirective.prototype.ngOnDestroy = function () {
71
80
  this.subscriptions.unsubscribe();
72
81
  };
@@ -82,18 +91,23 @@ var ExpandDetailsDirective = /** @class */ (function () {
82
91
  */
83
92
  ExpandDetailsDirective.prototype.isExpanded = function (args) {
84
93
  var key = this.keyGetter(args.dataItem);
85
- return this.expandedDetailKeys.indexOf(key) > -1 ? !this.initiallyExpanded : this.initiallyExpanded;
94
+ var hasKey = this.expandedState.has(key);
95
+ // when [initiallyExpanded]="true" a present key means the corresponding detail row is collapsed
96
+ return this.initiallyExpanded ? !hasKey : hasKey;
86
97
  };
87
98
  ExpandDetailsDirective.prototype.toggleState = function (args) {
88
99
  var key = this.keyGetter(args.dataItem);
89
100
  if (Boolean(this.initiallyExpanded) !== args.expand) {
90
- this.expandedDetailKeys.push(key);
101
+ this.expandedState.add(key);
91
102
  }
92
103
  else {
93
- var index = this.expandedDetailKeys.indexOf(key);
94
- this.expandedDetailKeys.splice(index, 1);
104
+ this.expandedState.delete(key);
95
105
  }
96
- this.expandedDetailKeysChange.emit(this.expandedDetailKeys);
106
+ this.notifyChange();
107
+ };
108
+ ExpandDetailsDirective.prototype.notifyChange = function () {
109
+ this.lastExpandedState = Array.from(this.expandedState);
110
+ this.expandedDetailKeysChange.emit(this.lastExpandedState);
97
111
  };
98
112
  tslib_1.__decorate([
99
113
  core_1.Output(),