@progress/kendo-angular-listbox 12.0.1-develop.3 → 12.0.1-develop.4
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/esm2020/data-binding.directive.mjs +1 -2
- package/esm2020/keyboard-navigation.service.mjs +69 -51
- package/esm2020/listbox.component.mjs +32 -45
- package/esm2020/package-metadata.mjs +2 -2
- package/esm2020/selection.service.mjs +2 -2
- package/fesm2015/progress-kendo-angular-listbox.mjs +112 -102
- package/fesm2020/progress-kendo-angular-listbox.mjs +106 -102
- package/keyboard-navigation.service.d.ts +3 -4
- package/listbox.component.d.ts +5 -9
- package/package.json +5 -5
- package/schematics/ngAdd/index.js +4 -4
- package/selection.service.d.ts +1 -1
|
@@ -24,8 +24,8 @@ const packageMetadata = {
|
|
|
24
24
|
name: '@progress/kendo-angular-listbox',
|
|
25
25
|
productName: 'Kendo UI for Angular',
|
|
26
26
|
productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
|
|
27
|
-
publishDate:
|
|
28
|
-
version: '12.0.1-develop.
|
|
27
|
+
publishDate: 1683180097,
|
|
28
|
+
version: '12.0.1-develop.4',
|
|
29
29
|
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'
|
|
30
30
|
};
|
|
31
31
|
|
|
@@ -37,8 +37,8 @@ class ListBoxSelectionService {
|
|
|
37
37
|
this.onSelect = new EventEmitter();
|
|
38
38
|
this.selectedIndex = null;
|
|
39
39
|
}
|
|
40
|
-
select(index
|
|
41
|
-
this.onSelect.next({ index: index, prevIndex: this.selectedIndex
|
|
40
|
+
select(index) {
|
|
41
|
+
this.onSelect.next({ index: index, prevIndex: this.selectedIndex });
|
|
42
42
|
this.selectedIndex = index;
|
|
43
43
|
}
|
|
44
44
|
isSelected(index) {
|
|
@@ -206,7 +206,7 @@ class KeyboardNavigationService {
|
|
|
206
206
|
this.onTransferAllEvent = new EventEmitter();
|
|
207
207
|
this.onShiftSelectedItem = new EventEmitter();
|
|
208
208
|
}
|
|
209
|
-
onKeyDown(event, toolsRef, toolbar, childListbox, parentListbox) {
|
|
209
|
+
onKeyDown(event, toolsRef, toolbar, childListbox, parentListbox, listboxItems) {
|
|
210
210
|
const target = event.target;
|
|
211
211
|
const keyCode = event.keyCode;
|
|
212
212
|
const ctrlOrMetaKey = event.ctrlKey || event.metaKey;
|
|
@@ -228,29 +228,24 @@ class KeyboardNavigationService {
|
|
|
228
228
|
this.onDeleteEvent.emit(this.selectedListboxItemIndex);
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
const isTargetListboxItem =
|
|
231
|
+
const isTargetListboxItem = listboxItems.find(elem => elem.nativeElement === target);
|
|
232
232
|
if (isTargetListboxItem) {
|
|
233
233
|
let isTransferToolVisible;
|
|
234
234
|
if (activeToolbar) {
|
|
235
235
|
isTransferToolVisible = activeToolbar.some(tool => tool.name.startsWith('transfer'));
|
|
236
236
|
}
|
|
237
237
|
if ((keyCode === Keys.ArrowRight || keyCode === Keys.ArrowLeft) && ctrlOrMetaKey && isTransferToolVisible) {
|
|
238
|
-
this.onArrowLeftOrRight(keyCode, parentListbox, childListbox, event);
|
|
238
|
+
this.onArrowLeftOrRight(keyCode, parentListbox, childListbox, event, listboxItems);
|
|
239
239
|
}
|
|
240
240
|
else if ((keyCode === Keys.ArrowUp || keyCode === Keys.ArrowDown)) {
|
|
241
|
-
this.onArrowUpOrDown(keyCode, ctrlOrMetaKey, event, activeToolbar);
|
|
241
|
+
this.onArrowUpOrDown(keyCode, ctrlOrMetaKey, event, activeToolbar, listboxItems);
|
|
242
242
|
}
|
|
243
243
|
else if ((event.metaKey && keyCode === Keys.Enter) || (event.ctrlKey && keyCode === Keys.Space)) {
|
|
244
|
-
|
|
245
|
-
event.preventDefault();
|
|
246
|
-
this.onSelectChange();
|
|
244
|
+
this.onSelectChange(event, listboxItems);
|
|
247
245
|
}
|
|
248
246
|
else if (keyCode === Keys.Space) {
|
|
249
247
|
if (this.selectedListboxItemIndex !== this.focusedListboxItemIndex) {
|
|
250
|
-
|
|
251
|
-
this.changeTabindex(items[this.selectedListboxItemIndex], items[this.focusedListboxItemIndex]);
|
|
252
|
-
this.selectedListboxItemIndex = this.focusedListboxItemIndex;
|
|
253
|
-
this.onSelectionChange.emit(this.selectedListboxItemIndex);
|
|
248
|
+
this.onSpaceKey(event, listboxItems);
|
|
254
249
|
}
|
|
255
250
|
}
|
|
256
251
|
}
|
|
@@ -266,9 +261,6 @@ class KeyboardNavigationService {
|
|
|
266
261
|
currentItem.focus();
|
|
267
262
|
}
|
|
268
263
|
}
|
|
269
|
-
onFocusIn() {
|
|
270
|
-
this.onSelectionChange.emit(this.selectedListboxItemIndex);
|
|
271
|
-
}
|
|
272
264
|
handleToolbarArrows(toolsRef, dir) {
|
|
273
265
|
const topReached = dir === 'up' && this.focusedToolIndex <= 0;
|
|
274
266
|
const bottomReached = dir === 'down' && this.focusedToolIndex >= toolsRef.length - 1;
|
|
@@ -281,7 +273,17 @@ class KeyboardNavigationService {
|
|
|
281
273
|
const currentItem = toolsRef[this.focusedToolIndex].element;
|
|
282
274
|
this.changeTabindex(prevItem, currentItem);
|
|
283
275
|
}
|
|
284
|
-
|
|
276
|
+
onSpaceKey(event, listboxItems) {
|
|
277
|
+
var _a, _b;
|
|
278
|
+
event.stopImmediatePropagation();
|
|
279
|
+
event.preventDefault();
|
|
280
|
+
const previousItem = (_a = listboxItems[this.selectedListboxItemIndex]) === null || _a === void 0 ? void 0 : _a.nativeElement;
|
|
281
|
+
const currentItem = (_b = listboxItems[this.focusedListboxItemIndex]) === null || _b === void 0 ? void 0 : _b.nativeElement;
|
|
282
|
+
this.changeTabindex(previousItem, currentItem);
|
|
283
|
+
this.selectedListboxItemIndex = this.focusedListboxItemIndex;
|
|
284
|
+
this.onSelectionChange.emit(this.selectedListboxItemIndex);
|
|
285
|
+
}
|
|
286
|
+
onArrowUpOrDown(keyCode, ctrlOrMetaKey, event, activeToolbar, listboxItems) {
|
|
285
287
|
event.preventDefault();
|
|
286
288
|
const dir = keyCode === Keys.ArrowUp ? 'moveUp' : 'moveDown';
|
|
287
289
|
if (ctrlOrMetaKey) {
|
|
@@ -293,36 +295,42 @@ class KeyboardNavigationService {
|
|
|
293
295
|
this.onMoveSelectedItem.emit(dir);
|
|
294
296
|
return;
|
|
295
297
|
}
|
|
296
|
-
this.changeFocusedItem(dir);
|
|
298
|
+
this.changeFocusedItem(dir, listboxItems);
|
|
297
299
|
return;
|
|
298
300
|
}
|
|
299
|
-
dir === 'moveUp' ? this.onArrowUp() : this.onArrowDown();
|
|
301
|
+
dir === 'moveUp' ? this.onArrowUp(listboxItems) : this.onArrowDown(listboxItems);
|
|
300
302
|
this.onSelectionChange.emit(this.selectedListboxItemIndex);
|
|
301
303
|
this.focusedListboxItemIndex = this.selectedListboxItemIndex;
|
|
302
304
|
}
|
|
303
|
-
onArrowLeftOrRight(keyCode, parentListbox, childListbox, event) {
|
|
305
|
+
onArrowLeftOrRight(keyCode, parentListbox, childListbox, event, listboxItems) {
|
|
304
306
|
event.preventDefault();
|
|
305
307
|
if (event.shiftKey) {
|
|
306
308
|
this.transferAllItems(keyCode, childListbox, parentListbox);
|
|
307
309
|
return;
|
|
308
310
|
}
|
|
309
311
|
if (this.selectedListboxItemIndex >= 0) {
|
|
310
|
-
this.transferItem(keyCode, childListbox, parentListbox);
|
|
312
|
+
this.transferItem(keyCode, childListbox, parentListbox, listboxItems);
|
|
311
313
|
}
|
|
312
314
|
}
|
|
313
|
-
onSelectChange() {
|
|
314
|
-
|
|
315
|
+
onSelectChange(event, listboxItems) {
|
|
316
|
+
var _a, _b;
|
|
317
|
+
event.stopImmediatePropagation();
|
|
318
|
+
event.preventDefault();
|
|
319
|
+
const areIndexesEqual = this.selectedListboxItemIndex === this.focusedListboxItemIndex;
|
|
320
|
+
const canDeslect = (this.selectedListboxItemIndex || this.selectedListboxItemIndex === 0) && areIndexesEqual;
|
|
315
321
|
if (canDeslect) {
|
|
316
322
|
this.selectedListboxItemIndex = null;
|
|
317
323
|
}
|
|
318
324
|
else {
|
|
319
|
-
const
|
|
320
|
-
|
|
325
|
+
const previousItem = (_a = listboxItems[this.selectedListboxItemIndex]) === null || _a === void 0 ? void 0 : _a.nativeElement;
|
|
326
|
+
const currentItem = (_b = listboxItems[this.focusedListboxItemIndex]) === null || _b === void 0 ? void 0 : _b.nativeElement;
|
|
327
|
+
this.changeTabindex(previousItem, currentItem);
|
|
321
328
|
this.selectedListboxItemIndex = this.focusedListboxItemIndex;
|
|
322
329
|
}
|
|
323
330
|
this.onSelectionChange.emit(this.selectedListboxItemIndex);
|
|
324
331
|
}
|
|
325
332
|
onF10Key(tools) {
|
|
333
|
+
var _a;
|
|
326
334
|
if (this.focusedToolIndex && this.focusedToolIndex > -1) {
|
|
327
335
|
if (this.focusedToolIndex >= tools.length) {
|
|
328
336
|
tools[tools.length - 1].element.focus();
|
|
@@ -332,48 +340,59 @@ class KeyboardNavigationService {
|
|
|
332
340
|
}
|
|
333
341
|
}
|
|
334
342
|
else {
|
|
335
|
-
tools[0].element.focus();
|
|
343
|
+
(_a = tools[0]) === null || _a === void 0 ? void 0 : _a.element.focus();
|
|
336
344
|
}
|
|
337
345
|
}
|
|
338
346
|
transferAllItems(keyCode, childListbox, parentListbox) {
|
|
339
347
|
const isArrowRight = keyCode === Keys.ArrowRight;
|
|
340
348
|
const actionToPerform = isArrowRight ? 'transferAllTo' : 'transferAllFrom';
|
|
341
349
|
this.onTransferAllEvent.emit(actionToPerform);
|
|
350
|
+
const adjustTabindex = (items) => {
|
|
351
|
+
items.forEach(item => {
|
|
352
|
+
if (item.nativeElement.getAttribute('tabindex') === '0') {
|
|
353
|
+
this.changeTabindex(item.nativeElement, null);
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
};
|
|
342
357
|
this.zone.onStable.pipe(take(1)).subscribe(() => {
|
|
343
358
|
const childListboxNav = (childListbox === null || childListbox === void 0 ? void 0 : childListbox.keyboardNavigationService) || (parentListbox === null || parentListbox === void 0 ? void 0 : parentListbox.childListbox.keyboardNavigationService);
|
|
344
359
|
let currentItem;
|
|
345
360
|
if (isArrowRight) {
|
|
346
361
|
if (childListbox) {
|
|
347
|
-
const
|
|
348
|
-
|
|
362
|
+
const childListBoxItems = childListbox.listboxItems.toArray();
|
|
363
|
+
const childListboxItemsLength = childListBoxItems.length - 1;
|
|
364
|
+
currentItem = childListBoxItems[childListboxItemsLength].nativeElement;
|
|
349
365
|
childListboxNav.focusedListboxItemIndex = childListboxItemsLength;
|
|
350
366
|
childListboxNav.selectedListboxItemIndex = childListboxItemsLength;
|
|
351
367
|
this.focusedListboxItemIndex = 0;
|
|
352
368
|
this.selectedListboxItemIndex = 0;
|
|
369
|
+
adjustTabindex(childListBoxItems);
|
|
353
370
|
}
|
|
354
371
|
}
|
|
355
372
|
else {
|
|
356
373
|
if (parentListbox) {
|
|
357
374
|
const parentListboxNav = parentListbox.keyboardNavigationService;
|
|
358
|
-
const
|
|
359
|
-
|
|
375
|
+
const parentListBoxItems = parentListbox.listboxItems.toArray();
|
|
376
|
+
const parentListboxItemsLength = parentListBoxItems.length - 1;
|
|
377
|
+
currentItem = parentListBoxItems[parentListboxItemsLength].nativeElement;
|
|
360
378
|
parentListboxNav.focusedListboxItemIndex = parentListboxItemsLength;
|
|
361
379
|
parentListboxNav.selectedListboxItemIndex = parentListboxItemsLength;
|
|
362
380
|
childListboxNav.focusedListboxItemIndex = 0;
|
|
363
381
|
childListboxNav.selectedListboxItemIndex = 0;
|
|
382
|
+
adjustTabindex(parentListBoxItems);
|
|
364
383
|
}
|
|
365
384
|
}
|
|
366
385
|
this.changeTabindex(null, currentItem);
|
|
367
386
|
});
|
|
368
387
|
}
|
|
369
|
-
transferItem(keyCode, childListbox, parentListbox) {
|
|
388
|
+
transferItem(keyCode, childListbox, parentListbox, listboxItems) {
|
|
370
389
|
const isArrowRight = keyCode === Keys.ArrowRight;
|
|
371
390
|
const actionToPerform = isArrowRight ? 'transferFrom' : 'transferTo';
|
|
372
391
|
this.onShiftSelectedItem.emit(actionToPerform);
|
|
373
392
|
const adjustTabindex = (items, firstItem, currentItem) => {
|
|
374
|
-
items.
|
|
375
|
-
if (item.getAttribute('tabindex') === '0') {
|
|
376
|
-
this.changeTabindex(item, firstItem);
|
|
393
|
+
items.forEach(item => {
|
|
394
|
+
if (item.nativeElement.getAttribute('tabindex') === '0') {
|
|
395
|
+
this.changeTabindex(item.nativeElement, firstItem);
|
|
377
396
|
}
|
|
378
397
|
});
|
|
379
398
|
this.changeTabindex(null, currentItem);
|
|
@@ -381,58 +400,62 @@ class KeyboardNavigationService {
|
|
|
381
400
|
this.zone.onStable.pipe(take(1)).subscribe(() => {
|
|
382
401
|
if (isArrowRight) {
|
|
383
402
|
if (childListbox) {
|
|
403
|
+
const childListBoxItems = childListbox.listboxItems.toArray();
|
|
384
404
|
const childListboxNav = childListbox.keyboardNavigationService;
|
|
385
|
-
const childListboxItemsLength =
|
|
386
|
-
const
|
|
387
|
-
const
|
|
405
|
+
const childListboxItemsLength = childListbox.listboxItems.length - 1;
|
|
406
|
+
const parentListboxFirstItem = listboxItems[0].nativeElement;
|
|
407
|
+
const currentItem = childListBoxItems[childListboxItemsLength].nativeElement;
|
|
388
408
|
childListboxNav.focusedListboxItemIndex = childListboxItemsLength;
|
|
389
409
|
childListboxNav.selectedListboxItemIndex = childListboxItemsLength;
|
|
390
410
|
this.focusedListboxItemIndex = 0;
|
|
391
411
|
this.selectedListboxItemIndex = 0;
|
|
392
|
-
adjustTabindex(
|
|
412
|
+
adjustTabindex(childListBoxItems, parentListboxFirstItem, currentItem);
|
|
393
413
|
}
|
|
394
414
|
}
|
|
395
415
|
else {
|
|
396
416
|
if (parentListbox) {
|
|
417
|
+
const parentListBoxItems = parentListbox.listboxItems.toArray();
|
|
397
418
|
const childListboxNav = parentListbox.childListbox.keyboardNavigationService;
|
|
398
419
|
const parentListboxNav = parentListbox.keyboardNavigationService;
|
|
399
|
-
const parentListboxItemsLength =
|
|
400
|
-
const
|
|
401
|
-
const
|
|
420
|
+
const parentListboxItemsLength = parentListbox.listboxItems.length - 1;
|
|
421
|
+
const childListboxFirstItem = listboxItems[0].nativeElement;
|
|
422
|
+
const currentItem = parentListBoxItems[parentListboxItemsLength].nativeElement;
|
|
402
423
|
parentListboxNav.focusedListboxItemIndex = parentListboxItemsLength;
|
|
403
424
|
parentListboxNav.selectedListboxItemIndex = parentListboxItemsLength;
|
|
404
425
|
childListboxNav.focusedListboxItemIndex = 0;
|
|
405
426
|
childListboxNav.selectedListboxItemIndex = 0;
|
|
406
|
-
adjustTabindex(
|
|
427
|
+
adjustTabindex(parentListBoxItems, childListboxFirstItem, currentItem);
|
|
407
428
|
}
|
|
408
429
|
}
|
|
409
430
|
});
|
|
410
431
|
}
|
|
411
|
-
changeFocusedItem(dir) {
|
|
412
|
-
|
|
432
|
+
changeFocusedItem(dir, listboxItems) {
|
|
433
|
+
listboxItems[this.focusedListboxItemIndex].nativeElement.blur();
|
|
413
434
|
if (this.focusedListboxItemIndex > 0 && dir === 'moveUp') {
|
|
414
435
|
this.focusedListboxItemIndex -= 1;
|
|
415
436
|
}
|
|
416
|
-
else if (this.focusedListboxItemIndex <
|
|
437
|
+
else if (this.focusedListboxItemIndex < listboxItems.length - 1 && dir === 'moveDown') {
|
|
417
438
|
this.focusedListboxItemIndex += 1;
|
|
418
439
|
}
|
|
419
|
-
|
|
440
|
+
listboxItems[this.focusedListboxItemIndex].nativeElement.focus();
|
|
420
441
|
}
|
|
421
|
-
onArrowDown() {
|
|
422
|
-
|
|
442
|
+
onArrowDown(listboxItems) {
|
|
443
|
+
var _a, _b;
|
|
444
|
+
if (this.selectedListboxItemIndex < listboxItems.length - 1) {
|
|
423
445
|
const offset = this.selectedListboxItemIndex ? this.selectedListboxItemIndex : this.focusedListboxItemIndex;
|
|
424
446
|
this.selectedListboxItemIndex = offset + 1;
|
|
425
|
-
const previousItem =
|
|
426
|
-
const currentItem =
|
|
447
|
+
const previousItem = (_a = listboxItems[this.selectedListboxItemIndex - 1]) === null || _a === void 0 ? void 0 : _a.nativeElement;
|
|
448
|
+
const currentItem = (_b = listboxItems[this.selectedListboxItemIndex]) === null || _b === void 0 ? void 0 : _b.nativeElement;
|
|
427
449
|
this.changeTabindex(previousItem, currentItem);
|
|
428
450
|
}
|
|
429
451
|
}
|
|
430
|
-
onArrowUp() {
|
|
452
|
+
onArrowUp(listboxItems) {
|
|
453
|
+
var _a, _b;
|
|
431
454
|
if (this.selectedListboxItemIndex > 0 || this.focusedListboxItemIndex > 0) {
|
|
432
455
|
const offset = this.selectedListboxItemIndex ? this.selectedListboxItemIndex : this.focusedListboxItemIndex;
|
|
433
456
|
this.selectedListboxItemIndex = offset - 1;
|
|
434
|
-
const previousItem =
|
|
435
|
-
const currentItem =
|
|
457
|
+
const previousItem = (_a = listboxItems[this.selectedListboxItemIndex + 1]) === null || _a === void 0 ? void 0 : _a.nativeElement;
|
|
458
|
+
const currentItem = (_b = listboxItems[this.selectedListboxItemIndex]) === null || _b === void 0 ? void 0 : _b.nativeElement;
|
|
436
459
|
this.changeTabindex(previousItem, currentItem);
|
|
437
460
|
}
|
|
438
461
|
}
|
|
@@ -650,7 +673,6 @@ class ListBoxComponent {
|
|
|
650
673
|
const toolsRef = this.tools.toArray();
|
|
651
674
|
const hostEl = this.hostElement.nativeElement;
|
|
652
675
|
const navService = this.keyboardNavigationService;
|
|
653
|
-
navService.listboxItems = Array.from(this.listboxElement.nativeElement.querySelectorAll('li.k-list-item'));
|
|
654
676
|
this.setIds();
|
|
655
677
|
this.initSubscriptions(navService, hostEl, toolsRef);
|
|
656
678
|
}
|
|
@@ -718,59 +740,42 @@ class ListBoxComponent {
|
|
|
718
740
|
}
|
|
719
741
|
return fieldAccessor(dataItem, this.textField);
|
|
720
742
|
}
|
|
721
|
-
|
|
722
|
-
* @hidden
|
|
723
|
-
*/
|
|
724
|
-
updateListboxItems() {
|
|
725
|
-
this.zone.onStable.pipe(take(1)).subscribe(() => {
|
|
726
|
-
this.keyboardNavigationService.listboxItems = Array.from(this.listboxElement.nativeElement.querySelectorAll('li.k-list-item'));
|
|
727
|
-
});
|
|
728
|
-
}
|
|
729
|
-
/**
|
|
730
|
-
* @hidden
|
|
731
|
-
*/
|
|
732
|
-
swapItems(firstItemIndex, secondItemIndex) {
|
|
733
|
-
const listboxItems = this.keyboardNavigationService.listboxItems;
|
|
734
|
-
[listboxItems[firstItemIndex], listboxItems[secondItemIndex]] = [
|
|
735
|
-
listboxItems[secondItemIndex],
|
|
736
|
-
listboxItems[firstItemIndex],
|
|
737
|
-
];
|
|
738
|
-
}
|
|
739
|
-
onClickEvent(listboxItems, prevIndex, currentIndex, dir) {
|
|
740
|
-
this.selectionChange.next(currentIndex);
|
|
743
|
+
onClickEvent(prevIndex, currentIndex) {
|
|
741
744
|
this.keyboardNavigationService.selectedListboxItemIndex = currentIndex;
|
|
742
745
|
this.keyboardNavigationService.focusedListboxItemIndex = currentIndex;
|
|
746
|
+
this.selectionChange.next(currentIndex);
|
|
743
747
|
this.zone.onStable.pipe(take(1)).subscribe(() => {
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
const
|
|
747
|
-
const currentItem = listboxItems[currentIndex];
|
|
748
|
+
const listboxItems = this.listboxItems.toArray();
|
|
749
|
+
const previousItem = prevIndex ? listboxItems[prevIndex].nativeElement : listboxItems[0].nativeElement;
|
|
750
|
+
const currentItem = listboxItems[currentIndex].nativeElement;
|
|
748
751
|
this.keyboardNavigationService.changeTabindex(previousItem, currentItem);
|
|
749
752
|
});
|
|
750
753
|
}
|
|
751
754
|
initSubscriptions(navService, hostEl, toolsRef) {
|
|
755
|
+
this.subs.add(navService.onShiftSelectedItem.subscribe((actionToPerform) => this.performAction(actionToPerform)));
|
|
756
|
+
this.subs.add(navService.onTransferAllEvent.subscribe((actionToPerform) => this.performAction(actionToPerform)));
|
|
757
|
+
this.subs.add(this.renderer.listen(this.listboxElement.nativeElement, 'focusin', (event) => this.onFocusIn(event)));
|
|
758
|
+
this.subs.add(this.selectionService.onSelect.subscribe((e) => this.onClickEvent(e.prevIndex, e.index)));
|
|
752
759
|
this.subs.add(navService.onDeleteEvent.subscribe((index) => this.onDeleteEvent(index, navService)));
|
|
753
|
-
this.subs.add(this.renderer.listen(hostEl, 'keydown', (event) => navService.onKeyDown(event, toolsRef, this.selectedTools, this.childListbox, this.parentListbox)));
|
|
754
|
-
this.subs.add(this.renderer.listen(this.listboxElement.nativeElement, 'focusin', () => navService.onFocusIn()));
|
|
755
|
-
this.subs.add(navService.onShiftSelectedItem.subscribe((actionToPerform) => this.onShiftItems(actionToPerform)));
|
|
756
|
-
this.subs.add(navService.onTransferAllEvent.subscribe((actionToPerform) => this.onShiftItems(actionToPerform)));
|
|
757
760
|
this.subs.add(navService.onMoveSelectedItem.subscribe((dir) => this.performAction(dir)));
|
|
758
|
-
this.subs.add(this.
|
|
761
|
+
this.subs.add(this.renderer.listen(hostEl, 'keydown', (event) => navService.onKeyDown(event, toolsRef, this.selectedTools, this.childListbox, this.parentListbox, this.listboxItems.toArray())));
|
|
759
762
|
this.subs.add(navService.onSelectionChange.subscribe((index) => {
|
|
760
763
|
this.selectionService.selectedIndex = index;
|
|
761
764
|
this.selectionChange.next({ index, prevIndex: null });
|
|
762
765
|
}));
|
|
763
766
|
}
|
|
764
|
-
|
|
767
|
+
onFocusIn(event) {
|
|
765
768
|
var _a, _b;
|
|
766
|
-
this.
|
|
767
|
-
if (
|
|
768
|
-
this.
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
(_b =
|
|
769
|
+
const navService = this.keyboardNavigationService;
|
|
770
|
+
if (navService.focusedListboxItemIndex === navService.selectedListboxItemIndex) {
|
|
771
|
+
const items = this.listboxItems.toArray();
|
|
772
|
+
const index = items.findIndex(elem => elem.nativeElement === event.target);
|
|
773
|
+
this.selectionService.selectedIndex = index;
|
|
774
|
+
this.selectionChange.next({ index, prevIndex: null });
|
|
775
|
+
const previousItem = (_a = items[navService.selectedListboxItemIndex]) === null || _a === void 0 ? void 0 : _a.nativeElement;
|
|
776
|
+
const currentItem = (_b = items[index]) === null || _b === void 0 ? void 0 : _b.nativeElement;
|
|
777
|
+
this.renderer.setAttribute(previousItem, 'tabindex', '-1');
|
|
778
|
+
this.renderer.setAttribute(currentItem, 'tabindex', '0');
|
|
774
779
|
}
|
|
775
780
|
}
|
|
776
781
|
setIds() {
|
|
@@ -806,15 +811,16 @@ class ListBoxComponent {
|
|
|
806
811
|
}
|
|
807
812
|
}
|
|
808
813
|
onDeleteEvent(index, navService) {
|
|
814
|
+
var _a;
|
|
809
815
|
this.selectionService.selectedIndex = index;
|
|
810
816
|
this.performAction('remove');
|
|
811
|
-
this.
|
|
812
|
-
const setIndex = index + 1 ===
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
navService.changeTabindex(null, navService.listboxItems[setIndex['tabindex']]);
|
|
817
|
+
const listboxItems = this.listboxItems.toArray();
|
|
818
|
+
const setIndex = index + 1 === listboxItems.length ?
|
|
819
|
+
{ index: index - 1, tabindex: index - 1 } : { index, tabindex: index + 1 };
|
|
820
|
+
navService.changeTabindex(null, (_a = listboxItems[setIndex['tabindex']]) === null || _a === void 0 ? void 0 : _a.nativeElement);
|
|
816
821
|
this.selectionChange.next({ index: setIndex['index'], prevIndex: null });
|
|
817
822
|
navService.selectedListboxItemIndex = setIndex['index'];
|
|
823
|
+
navService.focusedListboxItemIndex = setIndex['index'];
|
|
818
824
|
navService.focusedListboxItem = setIndex['index'];
|
|
819
825
|
this.selectionService.selectedIndex = setIndex['index'];
|
|
820
826
|
}
|
|
@@ -841,7 +847,7 @@ ListBoxComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", versi
|
|
|
841
847
|
provide: L10N_PREFIX,
|
|
842
848
|
useValue: 'kendo.listbox'
|
|
843
849
|
},
|
|
844
|
-
], queries: [{ propertyName: "itemTemplate", first: true, predicate: ItemTemplateDirective, descendants: true }], viewQueries: [{ propertyName: "listboxElement", first: true, predicate: ["listbox"], descendants: true }, { propertyName: "toolbarElement", first: true, predicate: ["toolbar"], descendants: true }, { propertyName: "tools", predicate: ["tools"], descendants: true }], ngImport: i0, template: `
|
|
850
|
+
], queries: [{ propertyName: "itemTemplate", first: true, predicate: ItemTemplateDirective, descendants: true }], viewQueries: [{ propertyName: "listboxElement", first: true, predicate: ["listbox"], descendants: true }, { propertyName: "toolbarElement", first: true, predicate: ["toolbar"], descendants: true }, { propertyName: "listboxItems", predicate: ["listboxItems"], descendants: true }, { propertyName: "tools", predicate: ["tools"], descendants: true }], ngImport: i0, template: `
|
|
845
851
|
<ng-container kendoListBoxLocalizedMessages
|
|
846
852
|
i18n-moveUp="kendo.listbox.moveUp|The title of the Move Up button"
|
|
847
853
|
moveUp="Move Up"
|
|
@@ -897,6 +903,7 @@ ListBoxComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", versi
|
|
|
897
903
|
[attr.aria-multiselectable]="false"
|
|
898
904
|
>
|
|
899
905
|
<li
|
|
906
|
+
#listboxItems
|
|
900
907
|
*ngFor="let item of data; let i = index"
|
|
901
908
|
kendoListBoxItemSelectable
|
|
902
909
|
class="k-list-item"
|
|
@@ -992,6 +999,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
|
|
|
992
999
|
[attr.aria-multiselectable]="false"
|
|
993
1000
|
>
|
|
994
1001
|
<li
|
|
1002
|
+
#listboxItems
|
|
995
1003
|
*ngFor="let item of data; let i = index"
|
|
996
1004
|
kendoListBoxItemSelectable
|
|
997
1005
|
class="k-list-item"
|
|
@@ -1031,6 +1039,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
|
|
|
1031
1039
|
}], listboxElement: [{
|
|
1032
1040
|
type: ViewChild,
|
|
1033
1041
|
args: ['listbox']
|
|
1042
|
+
}], listboxItems: [{
|
|
1043
|
+
type: ViewChildren,
|
|
1044
|
+
args: ['listboxItems']
|
|
1034
1045
|
}], toolbarElement: [{
|
|
1035
1046
|
type: ViewChild,
|
|
1036
1047
|
args: ['toolbar']
|
|
@@ -1151,9 +1162,8 @@ class DataBindingDirective {
|
|
|
1151
1162
|
return;
|
|
1152
1163
|
}
|
|
1153
1164
|
const newIndex = dir === 'up' ? index - 1 : index + 1;
|
|
1154
|
-
// ES6 Destructuring swap
|
|
1155
1165
|
[this.selectedBox.data[newIndex], this.selectedBox.data[index]] = [this.selectedBox.data[index], this.selectedBox.data[newIndex]];
|
|
1156
|
-
this.selectedBox.selectionService.select(newIndex
|
|
1166
|
+
this.selectedBox.selectionService.select(newIndex);
|
|
1157
1167
|
}
|
|
1158
1168
|
removeItem() {
|
|
1159
1169
|
const index = this.selectedBox.selectedIndex;
|