@progress/kendo-angular-dropdowns 7.1.0 → 7.2.0-dev.202209121509

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.
@@ -29,7 +29,7 @@ const packageMetadata = {
29
29
  name: '@progress/kendo-angular-dropdowns',
30
30
  productName: 'Kendo UI for Angular',
31
31
  productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
32
- publishDate: 1662551028,
32
+ publishDate: 1662995282,
33
33
  version: '',
34
34
  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'
35
35
  };
@@ -354,6 +354,10 @@ const getFillModeClass = (component, fillMode) => {
354
354
  };
355
355
  return FILLMODE_CLASSES[fillMode];
356
356
  };
357
+ /**
358
+ * @hidden
359
+ */
360
+ const filterAndMap = (arr, predicate, mapper) => arr.reduce((acc, curr) => predicate(curr) ? [...acc, mapper(curr)] : acc, []);
357
361
 
358
362
  /**
359
363
  * @hidden
@@ -870,123 +874,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
870
874
  }]
871
875
  }], ctorParameters: function () { return [{ type: i0.TemplateRef }]; } });
872
876
 
873
- /**
874
- * @hidden
875
- */
876
- class SelectionService {
877
- constructor() {
878
- this.onSelect = new EventEmitter();
879
- this.onChange = new EventEmitter();
880
- this.onFocus = new EventEmitter();
881
- this.total = 0;
882
- this.selectedIndices = [];
883
- }
884
- getTotal() {
885
- return this.total;
886
- }
887
- isSelected(index) {
888
- return isPresent(this.selectedIndices.find(current => current === index));
889
- }
890
- isFocused(index) {
891
- return index === this.focused;
892
- }
893
- focus(index) {
894
- if (this.isFocused(index)) {
895
- return;
896
- }
897
- this.focused = index;
898
- this.onFocus.emit(index);
899
- }
900
- select(index) {
901
- if (this.isSelected(index)) {
902
- return;
903
- }
904
- this.selectedIndices = [index];
905
- this.focused = index;
906
- this.onSelect.emit({
907
- indices: [index],
908
- newSelection: isPresent(index)
909
- });
910
- }
911
- add(index) {
912
- if (this.isSelected(index)) {
913
- return;
914
- }
915
- this.selectedIndices.push(index);
916
- this.focused = index;
917
- this.onChange.emit({
918
- added: index,
919
- indices: this.selectedIndices.slice()
920
- });
921
- }
922
- unselect(index) {
923
- if (!this.isSelected(index)) {
924
- return;
925
- }
926
- const position = this.selectedIndices.indexOf(index);
927
- this.selectedIndices.splice(position, 1);
928
- this.focused = index;
929
- this.onChange.emit({
930
- indices: this.selectedIndices.slice(),
931
- removed: index
932
- });
933
- }
934
- change(index) {
935
- const newSelection = isPresent(index) && !this.isSelected(index);
936
- this.selectedIndices = [index];
937
- this.focused = index;
938
- this.onChange.emit({
939
- indices: [index],
940
- newSelection: newSelection
941
- });
942
- }
943
- resetSelection(index) {
944
- this.selectedIndices = index instanceof Array ? index : [index];
945
- this.focused = this.selectedIndices[this.selectedIndices.length - 1];
946
- }
947
- get selected() {
948
- return this.selectedIndices.slice();
949
- }
950
- get focused() {
951
- return this.focusedIndex;
952
- }
953
- set focused(index) {
954
- if (this.focusedIndex !== index) {
955
- this.focusedIndex = index;
956
- this.onFocus.emit(index);
957
- }
958
- }
959
- }
960
- SelectionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SelectionService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
961
- SelectionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SelectionService });
962
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SelectionService, decorators: [{
963
- type: Injectable
964
- }] });
965
-
966
- /**
967
- * @hidden
968
- */
969
- var NavigationAction;
970
- (function (NavigationAction) {
971
- // eslint-disable-next-line id-denylist
972
- NavigationAction[NavigationAction["Undefined"] = 0] = "Undefined";
973
- NavigationAction[NavigationAction["Open"] = 1] = "Open";
974
- NavigationAction[NavigationAction["Close"] = 2] = "Close";
975
- NavigationAction[NavigationAction["Enter"] = 3] = "Enter";
976
- NavigationAction[NavigationAction["Tab"] = 4] = "Tab";
977
- NavigationAction[NavigationAction["Esc"] = 5] = "Esc";
978
- NavigationAction[NavigationAction["Delete"] = 6] = "Delete";
979
- NavigationAction[NavigationAction["Backspace"] = 7] = "Backspace";
980
- NavigationAction[NavigationAction["Home"] = 8] = "Home";
981
- NavigationAction[NavigationAction["End"] = 9] = "End";
982
- NavigationAction[NavigationAction["Up"] = 10] = "Up";
983
- NavigationAction[NavigationAction["Down"] = 11] = "Down";
984
- NavigationAction[NavigationAction["Left"] = 12] = "Left";
985
- NavigationAction[NavigationAction["Right"] = 13] = "Right";
986
- NavigationAction[NavigationAction["PageDown"] = 14] = "PageDown";
987
- NavigationAction[NavigationAction["PageUp"] = 15] = "PageUp";
988
- })(NavigationAction || (NavigationAction = {}));
989
-
990
877
  /**
991
878
  * @hidden
992
879
  */
@@ -1160,6 +1047,16 @@ class DataService {
1160
1047
  }
1161
1048
  return this._flatData.find((item) => item.header && item.index === index);
1162
1049
  }
1050
+ /**
1051
+ * @hidden
1052
+ * Used to get all group items indices.
1053
+ */
1054
+ groupItemsIndices() {
1055
+ if (this.isGrouped) {
1056
+ return filterAndMap(this.data, item => item.header, mappedItem => mappedItem.index);
1057
+ }
1058
+ return [];
1059
+ }
1163
1060
  /**
1164
1061
  * @hidden
1165
1062
  * Used to get the field by which the data is grouped.
@@ -1255,6 +1152,190 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
1255
1152
  type: Injectable
1256
1153
  }], ctorParameters: function () { return [{ type: DataService }]; } });
1257
1154
 
1155
+ /**
1156
+ * @hidden
1157
+ */
1158
+ class SelectionService {
1159
+ constructor(disabledItemsService) {
1160
+ this.disabledItemsService = disabledItemsService;
1161
+ this.onSelect = new EventEmitter();
1162
+ this.onChange = new EventEmitter();
1163
+ this.onFocus = new EventEmitter();
1164
+ this.total = 0;
1165
+ this.selectedIndices = [];
1166
+ this.indicesToBeRemoved = [];
1167
+ this.indicesToBeAdded = [];
1168
+ }
1169
+ getTotal() {
1170
+ return this.total;
1171
+ }
1172
+ isSelected(index) {
1173
+ return isPresent(this.selectedIndices.find(current => current === index));
1174
+ }
1175
+ isFocused(index) {
1176
+ return index === this.focused;
1177
+ }
1178
+ focus(index) {
1179
+ if (this.isFocused(index)) {
1180
+ return;
1181
+ }
1182
+ this.focused = index;
1183
+ this.onFocus.emit(index);
1184
+ }
1185
+ select(index) {
1186
+ if (this.isSelected(index)) {
1187
+ return;
1188
+ }
1189
+ this.selectedIndices = [index];
1190
+ this.focused = index;
1191
+ this.onSelect.emit({
1192
+ indices: [index],
1193
+ newSelection: isPresent(index)
1194
+ });
1195
+ }
1196
+ add(index, preventClosingPopup) {
1197
+ if (this.isSelected(index)) {
1198
+ return;
1199
+ }
1200
+ this.selectedIndices.push(index);
1201
+ this.focused = index;
1202
+ this.onChange.emit({
1203
+ added: index,
1204
+ indices: this.selectedIndices.slice(),
1205
+ preventClosingPopup: preventClosingPopup
1206
+ });
1207
+ }
1208
+ emitMultipleAddedRemoved() {
1209
+ this.onChange.emit({
1210
+ added: this.indicesToBeAdded,
1211
+ removed: this.indicesToBeRemoved,
1212
+ indices: this.selectedIndices.slice(),
1213
+ preventClosingPopup: true,
1214
+ isMultipleSelection: true
1215
+ });
1216
+ this.indicesToBeAdded = [];
1217
+ this.indicesToBeRemoved = [];
1218
+ }
1219
+ addMultiple(indices) {
1220
+ this.indicesToBeAdded = indices.slice();
1221
+ this.selectedIndices.push(...indices);
1222
+ }
1223
+ deselect(index, preventClosingPopup) {
1224
+ if (!this.isSelected(index)) {
1225
+ return;
1226
+ }
1227
+ const position = this.selectedIndices.indexOf(index);
1228
+ this.selectedIndices.splice(position, 1);
1229
+ this.focused = index;
1230
+ if (this.selected.length === 0) {
1231
+ this.lastClickedIndex = null;
1232
+ }
1233
+ this.onChange.emit({
1234
+ indices: this.selectedIndices.slice(),
1235
+ removed: index,
1236
+ preventClosingPopup: preventClosingPopup
1237
+ });
1238
+ }
1239
+ unselectMultiple(indices) {
1240
+ indices.forEach((index) => {
1241
+ const position = this.selectedIndices.indexOf(index);
1242
+ this.selectedIndices.splice(position, 1);
1243
+ });
1244
+ this.indicesToBeRemoved = indices.slice();
1245
+ }
1246
+ change(index) {
1247
+ const newSelection = isPresent(index) && !this.isSelected(index);
1248
+ this.selectedIndices = [index];
1249
+ this.focused = index;
1250
+ this.onChange.emit({
1251
+ indices: [index],
1252
+ newSelection: newSelection
1253
+ });
1254
+ }
1255
+ resetSelection(index) {
1256
+ this.selectedIndices = index instanceof Array ? index : [index];
1257
+ this.focused = this.selectedIndices[this.selectedIndices.length - 1];
1258
+ }
1259
+ get selected() {
1260
+ return this.selectedIndices.slice();
1261
+ }
1262
+ get focused() {
1263
+ return this.focusedIndex;
1264
+ }
1265
+ set focused(index) {
1266
+ if (this.focusedIndex !== index) {
1267
+ this.focusedIndex = index;
1268
+ this.onFocus.emit(index);
1269
+ }
1270
+ }
1271
+ selectFromTo(from, to) {
1272
+ let addedIndices = [];
1273
+ for (let i = from; i <= to; i++) {
1274
+ if (!this.isSelected(i) && !this.disabledItemsService.isIndexDisabled(i)) {
1275
+ addedIndices.push(i);
1276
+ }
1277
+ }
1278
+ this.addMultiple(addedIndices);
1279
+ }
1280
+ unselectFromTo(from, to) {
1281
+ let indicesToBeUnselected = [];
1282
+ for (let i = from; i >= to; i--) {
1283
+ if (this.isSelected(i) && !this.disabledItemsService.isIndexDisabled(i)) {
1284
+ indicesToBeUnselected.push(i);
1285
+ }
1286
+ }
1287
+ this.unselectMultiple(indicesToBeUnselected);
1288
+ }
1289
+ unselectNotNeededIndices(startOfSelection, endOfSelection, totalItems) {
1290
+ let indicesToBeUnselected = [];
1291
+ for (let i = 0; i < startOfSelection; i++) {
1292
+ if (this.isSelected(i)) {
1293
+ indicesToBeUnselected.push(i);
1294
+ }
1295
+ }
1296
+ for (let i = endOfSelection + 1; i < totalItems; i++) {
1297
+ if (this.isSelected(i)) {
1298
+ indicesToBeUnselected.push(i);
1299
+ }
1300
+ }
1301
+ this.unselectMultiple(indicesToBeUnselected);
1302
+ }
1303
+ }
1304
+ SelectionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SelectionService, deps: [{ token: DisabledItemsService }], target: i0.ɵɵFactoryTarget.Injectable });
1305
+ SelectionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SelectionService });
1306
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SelectionService, decorators: [{
1307
+ type: Injectable
1308
+ }], ctorParameters: function () { return [{ type: DisabledItemsService }]; } });
1309
+
1310
+ /**
1311
+ * @hidden
1312
+ */
1313
+ var NavigationAction;
1314
+ (function (NavigationAction) {
1315
+ // eslint-disable-next-line id-denylist
1316
+ NavigationAction[NavigationAction["Undefined"] = 0] = "Undefined";
1317
+ NavigationAction[NavigationAction["Open"] = 1] = "Open";
1318
+ NavigationAction[NavigationAction["Close"] = 2] = "Close";
1319
+ NavigationAction[NavigationAction["Enter"] = 3] = "Enter";
1320
+ NavigationAction[NavigationAction["Tab"] = 4] = "Tab";
1321
+ NavigationAction[NavigationAction["Esc"] = 5] = "Esc";
1322
+ NavigationAction[NavigationAction["Delete"] = 6] = "Delete";
1323
+ NavigationAction[NavigationAction["Backspace"] = 7] = "Backspace";
1324
+ NavigationAction[NavigationAction["Home"] = 8] = "Home";
1325
+ NavigationAction[NavigationAction["End"] = 9] = "End";
1326
+ NavigationAction[NavigationAction["Up"] = 10] = "Up";
1327
+ NavigationAction[NavigationAction["Down"] = 11] = "Down";
1328
+ NavigationAction[NavigationAction["Left"] = 12] = "Left";
1329
+ NavigationAction[NavigationAction["Right"] = 13] = "Right";
1330
+ NavigationAction[NavigationAction["PageDown"] = 14] = "PageDown";
1331
+ NavigationAction[NavigationAction["PageUp"] = 15] = "PageUp";
1332
+ NavigationAction[NavigationAction["SelectPrevious"] = 16] = "SelectPrevious";
1333
+ NavigationAction[NavigationAction["SelectNext"] = 17] = "SelectNext";
1334
+ NavigationAction[NavigationAction["SelectAll"] = 18] = "SelectAll";
1335
+ NavigationAction[NavigationAction["SelectAllToBeginning"] = 19] = "SelectAllToBeginning";
1336
+ NavigationAction[NavigationAction["SelectAllToEnd"] = 20] = "SelectAllToEnd";
1337
+ })(NavigationAction || (NavigationAction = {}));
1338
+
1258
1339
  const MIN_INDEX = 0;
1259
1340
  /**
1260
1341
  * @hidden
@@ -1290,10 +1371,17 @@ class NavigationService {
1290
1371
  this.end = new EventEmitter();
1291
1372
  this.pagedown = new EventEmitter();
1292
1373
  this.pageup = new EventEmitter();
1374
+ this.selectnext = new EventEmitter();
1375
+ this.selectprevious = new EventEmitter();
1376
+ this.selectall = new EventEmitter();
1377
+ this.selectalltobeginning = new EventEmitter();
1378
+ this.selectalltoend = new EventEmitter();
1293
1379
  }
1294
1380
  process(args) {
1295
1381
  const keyCode = args.originalEvent.keyCode;
1296
1382
  const altKey = args.originalEvent.altKey;
1383
+ const shiftKey = args.originalEvent.shiftKey;
1384
+ const ctrlKey = args.originalEvent.ctrlKey;
1297
1385
  let index;
1298
1386
  let action = NavigationAction.Undefined;
1299
1387
  if (altKey && keyCode === Keys.ArrowDown) {
@@ -1302,6 +1390,21 @@ class NavigationService {
1302
1390
  else if (altKey && keyCode === Keys.ArrowUp) {
1303
1391
  action = NavigationAction.Close;
1304
1392
  }
1393
+ else if (shiftKey && keyCode === Keys.ArrowUp) {
1394
+ action = NavigationAction.SelectPrevious;
1395
+ }
1396
+ else if (shiftKey && keyCode === Keys.ArrowDown) {
1397
+ action = NavigationAction.SelectNext;
1398
+ }
1399
+ else if (ctrlKey && keyCode === Keys.KeyA) {
1400
+ action = NavigationAction.SelectAll;
1401
+ }
1402
+ else if (ctrlKey && shiftKey && keyCode === Keys.Home) {
1403
+ action = NavigationAction.SelectAllToBeginning;
1404
+ }
1405
+ else if (ctrlKey && shiftKey && keyCode === Keys.End) {
1406
+ action = NavigationAction.SelectAllToEnd;
1407
+ }
1305
1408
  else if (keyCode === Keys.Enter) {
1306
1409
  action = NavigationAction.Enter;
1307
1410
  }
@@ -1562,12 +1665,13 @@ class SelectableDirective {
1562
1665
  }
1563
1666
  onClick(event) {
1564
1667
  event.stopPropagation();
1668
+ this.selectionService.lastClickedIndex = this.index;
1565
1669
  if (this.checkboxes.enabled && !this.checkboxes.checkOnClick) {
1566
1670
  return;
1567
1671
  }
1568
1672
  if (this.multipleSelection) {
1569
1673
  if (this.selectionService.isSelected(this.index)) {
1570
- this.selectionService.unselect(this.index);
1674
+ this.selectionService.deselect(this.index);
1571
1675
  }
1572
1676
  else {
1573
1677
  this.selectionService.add(this.index);
@@ -1737,7 +1841,7 @@ class ListComponent {
1737
1841
  this.selectionService.add(index);
1738
1842
  }
1739
1843
  if (!isChecked && this.selectionService.isSelected(index)) {
1740
- this.selectionService.unselect(index);
1844
+ this.selectionService.deselect(index);
1741
1845
  }
1742
1846
  }
1743
1847
  prepareClasses() {
@@ -7852,6 +7956,16 @@ class MultiSelectComponent {
7852
7956
  get isLoading() {
7853
7957
  return this.loading;
7854
7958
  }
7959
+ /**
7960
+ * @hidden
7961
+ */
7962
+ handleKeyboardEvent(event) {
7963
+ if (event.ctrlKey && event.keyCode === Keys.KeyA) {
7964
+ event.preventDefault();
7965
+ event.stopImmediatePropagation();
7966
+ this.handleSelectAll();
7967
+ }
7968
+ }
7855
7969
  /**
7856
7970
  * @hidden
7857
7971
  */
@@ -7943,23 +8057,45 @@ class MultiSelectComponent {
7943
8057
  * @hidden
7944
8058
  */
7945
8059
  change(event) {
7946
- const isCustomItem = (isPresent(event.added) || isPresent(event.removed)) && (event.added === -1 || event.removed === -1);
7947
- if (isCustomItem) {
7948
- this.addCustomValue(this.text);
7949
- return; // The change is emited asynchronosly.
7950
- }
7951
- // Existing items.
7952
- if (isPresent(event.added)) {
7953
- const dataItem = this.dataService.itemAt(event.added);
7954
- const newItem = (this.valuePrimitive && isPresent(dataItem) && isPresent(dataItem[this.valueField])) ? dataItem[this.valueField] : dataItem;
7955
- this.value = [...this.value, newItem];
7956
- }
7957
- if (isPresent(event.removed)) {
7958
- const dataItem = this.dataService.itemAt(event.removed);
7959
- const filter = (item) => getter(item, this.valueField) !== getter(dataItem, this.valueField);
7960
- this.value = this.value.filter(filter);
7961
- this.selectionService.focused = event.removed;
7962
- this.cdr.detectChanges();
8060
+ if (event.isMultipleSelection) {
8061
+ // Existing items.
8062
+ if (isPresent(event.added) && event.added.length > 0) {
8063
+ event.added.forEach((itemIndex) => {
8064
+ const dataItem = this.dataService.itemAt(itemIndex);
8065
+ const newItem = (this.valuePrimitive && isPresent(dataItem) && isPresent(dataItem[this.valueField])) ? dataItem[this.valueField] : dataItem;
8066
+ if (newItem) {
8067
+ this.value = [...this.value, newItem];
8068
+ }
8069
+ });
8070
+ }
8071
+ if (isPresent(event.removed) && event.removed.length > 0) {
8072
+ event.removed.forEach((itemIndex) => {
8073
+ const dataItem = this.dataService.itemAt(itemIndex);
8074
+ const filter = (item) => getter(item, this.valueField) !== getter(dataItem, this.valueField);
8075
+ this.value = this.value.filter(filter);
8076
+ });
8077
+ this.cdr.detectChanges();
8078
+ }
8079
+ }
8080
+ else {
8081
+ const isCustomItem = (isPresent(event.added) || isPresent(event.removed)) && (event.added === -1 || event.removed === -1);
8082
+ if (isCustomItem) {
8083
+ this.addCustomValue(this.text);
8084
+ return; // The change is emited asynchronosly.
8085
+ }
8086
+ // Existing items.
8087
+ if (isPresent(event.added)) {
8088
+ const dataItem = this.dataService.itemAt(event.added);
8089
+ const newItem = (this.valuePrimitive && isPresent(dataItem) && isPresent(dataItem[this.valueField])) ? dataItem[this.valueField] : dataItem;
8090
+ this.value = [...this.value, newItem];
8091
+ }
8092
+ if (isPresent(event.removed)) {
8093
+ const dataItem = this.dataService.itemAt(event.removed);
8094
+ const filter = (item) => getter(item, this.valueField) !== getter(dataItem, this.valueField);
8095
+ this.value = this.value.filter(filter);
8096
+ this.selectionService.focused = event.removed;
8097
+ this.cdr.detectChanges();
8098
+ }
7963
8099
  }
7964
8100
  this.emitValueChange();
7965
8101
  }
@@ -8092,10 +8228,11 @@ class MultiSelectComponent {
8092
8228
  * @hidden
8093
8229
  */
8094
8230
  clearAll(event) {
8095
- event.stopImmediatePropagation();
8096
- event.preventDefault();
8231
+ event === null || event === void 0 ? void 0 : event.stopImmediatePropagation();
8232
+ event === null || event === void 0 ? void 0 : event.preventDefault();
8097
8233
  this.focus();
8098
8234
  this.clearFilter();
8235
+ this.selectionService.lastClickedIndex = null;
8099
8236
  const selected = this.selectionService.selected;
8100
8237
  this.value = this.value.filter((_item, index) => this.disabledItemsService.isIndexDisabled(selected[index]));
8101
8238
  this.emitValueChange();
@@ -8244,7 +8381,11 @@ class MultiSelectComponent {
8244
8381
  this.navigationService.delete.pipe(filter(isTagFocused)).subscribe(this.handleDelete.bind(this)),
8245
8382
  this.navigationService.left.subscribe(this.direction === 'rtl' ? this.handleRightKey.bind(this) : this.handleLeftKey.bind(this)),
8246
8383
  this.navigationService.right.subscribe(this.direction === 'rtl' ? this.handleLeftKey.bind(this) : this.handleRightKey.bind(this)),
8247
- this.navigationService.down.subscribe((event) => this.handleDownKey(event.index))
8384
+ this.navigationService.down.subscribe((event) => this.handleDownKey(event.index)),
8385
+ this.navigationService.selectprevious.pipe(filter(isOpen)).subscribe((event) => this.handleSelectUpDown(event)),
8386
+ this.navigationService.selectnext.pipe(filter(isOpen)).subscribe((event) => this.handleSelectUpDown(event)),
8387
+ this.navigationService.selectalltobeginning.pipe(filter(isOpen)).subscribe(() => this.handleSelectAllToBeginning()),
8388
+ this.navigationService.selectalltoend.pipe(filter(isOpen)).subscribe(() => this.handleSelectAllToEnd())
8248
8389
  ].forEach(s => this.observableSubscriptions.add(s));
8249
8390
  }
8250
8391
  subscribeTouchEvents() {
@@ -8303,7 +8444,7 @@ class MultiSelectComponent {
8303
8444
  return;
8304
8445
  }
8305
8446
  if (isNumber(index)) {
8306
- this.selectionService.unselect(index);
8447
+ this.selectionService.deselect(index);
8307
8448
  this.selectionService.focused = index;
8308
8449
  this.togglePopup(false);
8309
8450
  }
@@ -8368,7 +8509,7 @@ class MultiSelectComponent {
8368
8509
  }
8369
8510
  else {
8370
8511
  if (!customItem && this.selectionService.isSelected(itemIndex)) {
8371
- this.selectionService.unselect(itemIndex);
8512
+ this.selectionService.deselect(itemIndex);
8372
8513
  this.selectionService.focused = itemIndex;
8373
8514
  }
8374
8515
  else {
@@ -8390,7 +8531,7 @@ class MultiSelectComponent {
8390
8531
  }
8391
8532
  handleItemChange(event) {
8392
8533
  this.change(event);
8393
- if (this.autoClose) {
8534
+ if (this.autoClose && !event.preventClosingPopup) {
8394
8535
  this.togglePopup(false);
8395
8536
  }
8396
8537
  if (this.autoClose || !this.filterable) {
@@ -8400,6 +8541,7 @@ class MultiSelectComponent {
8400
8541
  handleEnter(event) {
8401
8542
  const service = this.selectionService;
8402
8543
  const focusedIndex = this.selectionService.focused;
8544
+ this.selectionService.lastClickedIndex = focusedIndex;
8403
8545
  if (this.isOpen) {
8404
8546
  event.originalEvent.preventDefault();
8405
8547
  }
@@ -8410,7 +8552,7 @@ class MultiSelectComponent {
8410
8552
  return; // Clear filter & close are done at customValueSubscription due to race conditions.
8411
8553
  }
8412
8554
  if (service.isSelected(focusedIndex)) {
8413
- service.unselect(focusedIndex);
8555
+ service.deselect(focusedIndex);
8414
8556
  service.focused = focusedIndex;
8415
8557
  }
8416
8558
  else {
@@ -8433,6 +8575,85 @@ class MultiSelectComponent {
8433
8575
  handleHome() {
8434
8576
  this.focusedTagIndex = 0;
8435
8577
  }
8578
+ sortSelectionAscending() {
8579
+ return this.selectionService.selected.sort((a, b) => a - b);
8580
+ }
8581
+ handleSelectAll() {
8582
+ const selectedItemsCount = this.selectionService.selected.length;
8583
+ const dataItemsCount = this.dataService.data.length;
8584
+ const dataItemsWithoutHeadersCount = this.dataService.data.filter(i => !i.header).length;
8585
+ if ((!this.dataService.grouped && selectedItemsCount === dataItemsCount) ||
8586
+ (this.dataService.grouped && selectedItemsCount === dataItemsWithoutHeadersCount)) {
8587
+ this.clearAll();
8588
+ }
8589
+ else {
8590
+ this.selectionService.selectFromTo(0, dataItemsCount - 1);
8591
+ this.selectionService.emitMultipleAddedRemoved();
8592
+ }
8593
+ }
8594
+ handleSelectAllToBeginning() {
8595
+ const selectedItemsCount = this.selectionService.selected.length;
8596
+ const dataItemsCount = this.dataService.data.length;
8597
+ const focusedItem = this.selectionService.focused;
8598
+ const largestIndex = this.sortSelectionAscending()[selectedItemsCount - 1];
8599
+ if (selectedItemsCount !== dataItemsCount) {
8600
+ this.selectionService.unselectFromTo(largestIndex, focusedItem + 1);
8601
+ this.selectionService.selectFromTo(0, focusedItem);
8602
+ }
8603
+ this.nextTick(() => this.selectionService.focus(0));
8604
+ this.selectionService.emitMultipleAddedRemoved();
8605
+ }
8606
+ handleSelectAllToEnd() {
8607
+ const selectedItemsCount = this.selectionService.selected.length;
8608
+ const dataItemsCount = this.dataService.data.length;
8609
+ const focusedItem = this.selectionService.focused;
8610
+ if (selectedItemsCount !== dataItemsCount) {
8611
+ this.selectionService.unselectFromTo(focusedItem - 1, 0);
8612
+ this.selectionService.selectFromTo(focusedItem, dataItemsCount - 1);
8613
+ }
8614
+ if (this.dataService.grouped) {
8615
+ const lastItemIndex = this.dataService.groupIndices[this.dataService.groupIndices.length - 1] - 1;
8616
+ this.nextTick(() => this.selectionService.focus(lastItemIndex));
8617
+ }
8618
+ else {
8619
+ this.nextTick(() => this.selectionService.focus(dataItemsCount - 1));
8620
+ }
8621
+ this.selectionService.emitMultipleAddedRemoved();
8622
+ }
8623
+ handleSelectUpDown(event) {
8624
+ const focusedIndex = this.selectionService.focused;
8625
+ if (!isPresent(focusedIndex)) {
8626
+ return;
8627
+ }
8628
+ let indexToSelect;
8629
+ if (event.originalEvent.key === 'ArrowUp') {
8630
+ indexToSelect = focusedIndex > 0 ? focusedIndex - 1 : focusedIndex;
8631
+ }
8632
+ else {
8633
+ indexToSelect = focusedIndex < this.dataService.data.length - 1 ? focusedIndex + 1 : focusedIndex;
8634
+ }
8635
+ if (!isPresent(this.selectionService.lastClickedIndex)) {
8636
+ this.selectionService.lastClickedIndex = focusedIndex;
8637
+ }
8638
+ this.selectRangeFromTo(indexToSelect);
8639
+ }
8640
+ /**
8641
+ * Selects all items between the focused item and the last clicked item (index). Also removes all other selected items.
8642
+ */
8643
+ selectRangeFromTo(indexToSelect) {
8644
+ const lastClickedIndex = this.selectionService.lastClickedIndex;
8645
+ if (lastClickedIndex > indexToSelect) {
8646
+ this.selectionService.unselectNotNeededIndices(indexToSelect, lastClickedIndex, this.dataService.data.length);
8647
+ this.selectionService.selectFromTo(indexToSelect, this.selectionService.lastClickedIndex);
8648
+ this.selectionService.emitMultipleAddedRemoved();
8649
+ }
8650
+ else {
8651
+ this.selectionService.unselectNotNeededIndices(lastClickedIndex, indexToSelect, this.dataService.data.length);
8652
+ this.selectionService.selectFromTo(lastClickedIndex, indexToSelect);
8653
+ this.selectionService.emitMultipleAddedRemoved();
8654
+ }
8655
+ this.nextTick(() => this.selectionService.focus(indexToSelect));
8656
+ }
8436
8657
  handleUp(index) {
8437
8658
  this.selectionService.focused = index;
8438
8659
  }
@@ -8631,7 +8852,7 @@ class MultiSelectComponent {
8631
8852
  }
8632
8853
  }
8633
8854
  MultiSelectComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: MultiSelectComponent, deps: [{ token: i0.ElementRef }, { token: i1.LocalizationService }, { token: i2.PopupService }, { token: DataService }, { token: SelectionService }, { token: NavigationService }, { token: DisabledItemsService }, { token: i0.ChangeDetectorRef }, { token: i0.KeyValueDiffers }, { token: i0.Renderer2 }, { token: i0.NgZone }, { token: TOUCH_ENABLED, optional: true }], target: i0.ɵɵFactoryTarget.Component });
8634
- MultiSelectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: MultiSelectComponent, selector: "kendo-multiselect", inputs: { focusableId: "focusableId", autoClose: "autoClose", loading: "loading", data: "data", value: "value", valueField: "valueField", textField: "textField", tabindex: "tabindex", tabIndex: "tabIndex", size: "size", rounded: "rounded", fillMode: "fillMode", placeholder: "placeholder", disabled: "disabled", itemDisabled: "itemDisabled", checkboxes: "checkboxes", readonly: "readonly", filterable: "filterable", virtual: "virtual", popupSettings: "popupSettings", listHeight: "listHeight", valuePrimitive: "valuePrimitive", clearButton: "clearButton", tagMapper: "tagMapper", allowCustom: "allowCustom", valueNormalizer: "valueNormalizer" }, outputs: { filterChange: "filterChange", valueChange: "valueChange", open: "open", opened: "opened", close: "close", closed: "closed", onFocus: "focus", onBlur: "blur", removeTag: "removeTag" }, host: { listeners: { "mousedown": "hostMousedown($event)" }, properties: { "class.k-multiselect": "this.hostClasses", "class.k-input": "this.hostClasses", "attr.dir": "this.dir", "class.k-disabled": "this.disabledClass", "class.k-loading": "this.isLoading" } }, providers: [
8855
+ MultiSelectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: MultiSelectComponent, selector: "kendo-multiselect", inputs: { focusableId: "focusableId", autoClose: "autoClose", loading: "loading", data: "data", value: "value", valueField: "valueField", textField: "textField", tabindex: "tabindex", tabIndex: "tabIndex", size: "size", rounded: "rounded", fillMode: "fillMode", placeholder: "placeholder", disabled: "disabled", itemDisabled: "itemDisabled", checkboxes: "checkboxes", readonly: "readonly", filterable: "filterable", virtual: "virtual", popupSettings: "popupSettings", listHeight: "listHeight", valuePrimitive: "valuePrimitive", clearButton: "clearButton", tagMapper: "tagMapper", allowCustom: "allowCustom", valueNormalizer: "valueNormalizer" }, outputs: { filterChange: "filterChange", valueChange: "valueChange", open: "open", opened: "opened", close: "close", closed: "closed", onFocus: "focus", onBlur: "blur", removeTag: "removeTag" }, host: { listeners: { "document:keydown": "handleKeyboardEvent($event)", "mousedown": "hostMousedown($event)" }, properties: { "class.k-multiselect": "this.hostClasses", "class.k-input": "this.hostClasses", "attr.dir": "this.dir", "class.k-disabled": "this.disabledClass", "class.k-loading": "this.isLoading" } }, providers: [
8635
8856
  MULTISELECT_VALUE_ACCESSOR,
8636
8857
  DataService,
8637
8858
  SelectionService,
@@ -9070,6 +9291,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
9070
9291
  }], isLoading: [{
9071
9292
  type: HostBinding,
9072
9293
  args: ['class.k-loading']
9294
+ }], handleKeyboardEvent: [{
9295
+ type: HostListener,
9296
+ args: ['document:keydown', ['$event']]
9073
9297
  }], hostMousedown: [{
9074
9298
  type: HostListener,
9075
9299
  args: ['mousedown', ['$event']]