@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,16 @@ class KeyboardNavigationService {
|
|
|
281
273
|
const currentItem = toolsRef[this.focusedToolIndex].element;
|
|
282
274
|
this.changeTabindex(prevItem, currentItem);
|
|
283
275
|
}
|
|
284
|
-
|
|
276
|
+
onSpaceKey(event, listboxItems) {
|
|
277
|
+
event.stopImmediatePropagation();
|
|
278
|
+
event.preventDefault();
|
|
279
|
+
const previousItem = listboxItems[this.selectedListboxItemIndex]?.nativeElement;
|
|
280
|
+
const currentItem = listboxItems[this.focusedListboxItemIndex]?.nativeElement;
|
|
281
|
+
this.changeTabindex(previousItem, currentItem);
|
|
282
|
+
this.selectedListboxItemIndex = this.focusedListboxItemIndex;
|
|
283
|
+
this.onSelectionChange.emit(this.selectedListboxItemIndex);
|
|
284
|
+
}
|
|
285
|
+
onArrowUpOrDown(keyCode, ctrlOrMetaKey, event, activeToolbar, listboxItems) {
|
|
285
286
|
event.preventDefault();
|
|
286
287
|
const dir = keyCode === Keys.ArrowUp ? 'moveUp' : 'moveDown';
|
|
287
288
|
if (ctrlOrMetaKey) {
|
|
@@ -293,31 +294,35 @@ class KeyboardNavigationService {
|
|
|
293
294
|
this.onMoveSelectedItem.emit(dir);
|
|
294
295
|
return;
|
|
295
296
|
}
|
|
296
|
-
this.changeFocusedItem(dir);
|
|
297
|
+
this.changeFocusedItem(dir, listboxItems);
|
|
297
298
|
return;
|
|
298
299
|
}
|
|
299
|
-
dir === 'moveUp' ? this.onArrowUp() : this.onArrowDown();
|
|
300
|
+
dir === 'moveUp' ? this.onArrowUp(listboxItems) : this.onArrowDown(listboxItems);
|
|
300
301
|
this.onSelectionChange.emit(this.selectedListboxItemIndex);
|
|
301
302
|
this.focusedListboxItemIndex = this.selectedListboxItemIndex;
|
|
302
303
|
}
|
|
303
|
-
onArrowLeftOrRight(keyCode, parentListbox, childListbox, event) {
|
|
304
|
+
onArrowLeftOrRight(keyCode, parentListbox, childListbox, event, listboxItems) {
|
|
304
305
|
event.preventDefault();
|
|
305
306
|
if (event.shiftKey) {
|
|
306
307
|
this.transferAllItems(keyCode, childListbox, parentListbox);
|
|
307
308
|
return;
|
|
308
309
|
}
|
|
309
310
|
if (this.selectedListboxItemIndex >= 0) {
|
|
310
|
-
this.transferItem(keyCode, childListbox, parentListbox);
|
|
311
|
+
this.transferItem(keyCode, childListbox, parentListbox, listboxItems);
|
|
311
312
|
}
|
|
312
313
|
}
|
|
313
|
-
onSelectChange() {
|
|
314
|
-
|
|
314
|
+
onSelectChange(event, listboxItems) {
|
|
315
|
+
event.stopImmediatePropagation();
|
|
316
|
+
event.preventDefault();
|
|
317
|
+
const areIndexesEqual = this.selectedListboxItemIndex === this.focusedListboxItemIndex;
|
|
318
|
+
const canDeslect = (this.selectedListboxItemIndex || this.selectedListboxItemIndex === 0) && areIndexesEqual;
|
|
315
319
|
if (canDeslect) {
|
|
316
320
|
this.selectedListboxItemIndex = null;
|
|
317
321
|
}
|
|
318
322
|
else {
|
|
319
|
-
const
|
|
320
|
-
|
|
323
|
+
const previousItem = listboxItems[this.selectedListboxItemIndex]?.nativeElement;
|
|
324
|
+
const currentItem = listboxItems[this.focusedListboxItemIndex]?.nativeElement;
|
|
325
|
+
this.changeTabindex(previousItem, currentItem);
|
|
321
326
|
this.selectedListboxItemIndex = this.focusedListboxItemIndex;
|
|
322
327
|
}
|
|
323
328
|
this.onSelectionChange.emit(this.selectedListboxItemIndex);
|
|
@@ -332,48 +337,59 @@ class KeyboardNavigationService {
|
|
|
332
337
|
}
|
|
333
338
|
}
|
|
334
339
|
else {
|
|
335
|
-
tools[0]
|
|
340
|
+
tools[0]?.element.focus();
|
|
336
341
|
}
|
|
337
342
|
}
|
|
338
343
|
transferAllItems(keyCode, childListbox, parentListbox) {
|
|
339
344
|
const isArrowRight = keyCode === Keys.ArrowRight;
|
|
340
345
|
const actionToPerform = isArrowRight ? 'transferAllTo' : 'transferAllFrom';
|
|
341
346
|
this.onTransferAllEvent.emit(actionToPerform);
|
|
347
|
+
const adjustTabindex = (items) => {
|
|
348
|
+
items.forEach(item => {
|
|
349
|
+
if (item.nativeElement.getAttribute('tabindex') === '0') {
|
|
350
|
+
this.changeTabindex(item.nativeElement, null);
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
};
|
|
342
354
|
this.zone.onStable.pipe(take(1)).subscribe(() => {
|
|
343
355
|
const childListboxNav = childListbox?.keyboardNavigationService || parentListbox?.childListbox.keyboardNavigationService;
|
|
344
356
|
let currentItem;
|
|
345
357
|
if (isArrowRight) {
|
|
346
358
|
if (childListbox) {
|
|
347
|
-
const
|
|
348
|
-
|
|
359
|
+
const childListBoxItems = childListbox.listboxItems.toArray();
|
|
360
|
+
const childListboxItemsLength = childListBoxItems.length - 1;
|
|
361
|
+
currentItem = childListBoxItems[childListboxItemsLength].nativeElement;
|
|
349
362
|
childListboxNav.focusedListboxItemIndex = childListboxItemsLength;
|
|
350
363
|
childListboxNav.selectedListboxItemIndex = childListboxItemsLength;
|
|
351
364
|
this.focusedListboxItemIndex = 0;
|
|
352
365
|
this.selectedListboxItemIndex = 0;
|
|
366
|
+
adjustTabindex(childListBoxItems);
|
|
353
367
|
}
|
|
354
368
|
}
|
|
355
369
|
else {
|
|
356
370
|
if (parentListbox) {
|
|
357
371
|
const parentListboxNav = parentListbox.keyboardNavigationService;
|
|
358
|
-
const
|
|
359
|
-
|
|
372
|
+
const parentListBoxItems = parentListbox.listboxItems.toArray();
|
|
373
|
+
const parentListboxItemsLength = parentListBoxItems.length - 1;
|
|
374
|
+
currentItem = parentListBoxItems[parentListboxItemsLength].nativeElement;
|
|
360
375
|
parentListboxNav.focusedListboxItemIndex = parentListboxItemsLength;
|
|
361
376
|
parentListboxNav.selectedListboxItemIndex = parentListboxItemsLength;
|
|
362
377
|
childListboxNav.focusedListboxItemIndex = 0;
|
|
363
378
|
childListboxNav.selectedListboxItemIndex = 0;
|
|
379
|
+
adjustTabindex(parentListBoxItems);
|
|
364
380
|
}
|
|
365
381
|
}
|
|
366
382
|
this.changeTabindex(null, currentItem);
|
|
367
383
|
});
|
|
368
384
|
}
|
|
369
|
-
transferItem(keyCode, childListbox, parentListbox) {
|
|
385
|
+
transferItem(keyCode, childListbox, parentListbox, listboxItems) {
|
|
370
386
|
const isArrowRight = keyCode === Keys.ArrowRight;
|
|
371
387
|
const actionToPerform = isArrowRight ? 'transferFrom' : 'transferTo';
|
|
372
388
|
this.onShiftSelectedItem.emit(actionToPerform);
|
|
373
389
|
const adjustTabindex = (items, firstItem, currentItem) => {
|
|
374
|
-
items.
|
|
375
|
-
if (item.getAttribute('tabindex') === '0') {
|
|
376
|
-
this.changeTabindex(item, firstItem);
|
|
390
|
+
items.forEach(item => {
|
|
391
|
+
if (item.nativeElement.getAttribute('tabindex') === '0') {
|
|
392
|
+
this.changeTabindex(item.nativeElement, firstItem);
|
|
377
393
|
}
|
|
378
394
|
});
|
|
379
395
|
this.changeTabindex(null, currentItem);
|
|
@@ -381,58 +397,60 @@ class KeyboardNavigationService {
|
|
|
381
397
|
this.zone.onStable.pipe(take(1)).subscribe(() => {
|
|
382
398
|
if (isArrowRight) {
|
|
383
399
|
if (childListbox) {
|
|
400
|
+
const childListBoxItems = childListbox.listboxItems.toArray();
|
|
384
401
|
const childListboxNav = childListbox.keyboardNavigationService;
|
|
385
|
-
const childListboxItemsLength =
|
|
386
|
-
const
|
|
387
|
-
const
|
|
402
|
+
const childListboxItemsLength = childListbox.listboxItems.length - 1;
|
|
403
|
+
const parentListboxFirstItem = listboxItems[0].nativeElement;
|
|
404
|
+
const currentItem = childListBoxItems[childListboxItemsLength].nativeElement;
|
|
388
405
|
childListboxNav.focusedListboxItemIndex = childListboxItemsLength;
|
|
389
406
|
childListboxNav.selectedListboxItemIndex = childListboxItemsLength;
|
|
390
407
|
this.focusedListboxItemIndex = 0;
|
|
391
408
|
this.selectedListboxItemIndex = 0;
|
|
392
|
-
adjustTabindex(
|
|
409
|
+
adjustTabindex(childListBoxItems, parentListboxFirstItem, currentItem);
|
|
393
410
|
}
|
|
394
411
|
}
|
|
395
412
|
else {
|
|
396
413
|
if (parentListbox) {
|
|
414
|
+
const parentListBoxItems = parentListbox.listboxItems.toArray();
|
|
397
415
|
const childListboxNav = parentListbox.childListbox.keyboardNavigationService;
|
|
398
416
|
const parentListboxNav = parentListbox.keyboardNavigationService;
|
|
399
|
-
const parentListboxItemsLength =
|
|
400
|
-
const
|
|
401
|
-
const
|
|
417
|
+
const parentListboxItemsLength = parentListbox.listboxItems.length - 1;
|
|
418
|
+
const childListboxFirstItem = listboxItems[0].nativeElement;
|
|
419
|
+
const currentItem = parentListBoxItems[parentListboxItemsLength].nativeElement;
|
|
402
420
|
parentListboxNav.focusedListboxItemIndex = parentListboxItemsLength;
|
|
403
421
|
parentListboxNav.selectedListboxItemIndex = parentListboxItemsLength;
|
|
404
422
|
childListboxNav.focusedListboxItemIndex = 0;
|
|
405
423
|
childListboxNav.selectedListboxItemIndex = 0;
|
|
406
|
-
adjustTabindex(
|
|
424
|
+
adjustTabindex(parentListBoxItems, childListboxFirstItem, currentItem);
|
|
407
425
|
}
|
|
408
426
|
}
|
|
409
427
|
});
|
|
410
428
|
}
|
|
411
|
-
changeFocusedItem(dir) {
|
|
412
|
-
|
|
429
|
+
changeFocusedItem(dir, listboxItems) {
|
|
430
|
+
listboxItems[this.focusedListboxItemIndex].nativeElement.blur();
|
|
413
431
|
if (this.focusedListboxItemIndex > 0 && dir === 'moveUp') {
|
|
414
432
|
this.focusedListboxItemIndex -= 1;
|
|
415
433
|
}
|
|
416
|
-
else if (this.focusedListboxItemIndex <
|
|
434
|
+
else if (this.focusedListboxItemIndex < listboxItems.length - 1 && dir === 'moveDown') {
|
|
417
435
|
this.focusedListboxItemIndex += 1;
|
|
418
436
|
}
|
|
419
|
-
|
|
437
|
+
listboxItems[this.focusedListboxItemIndex].nativeElement.focus();
|
|
420
438
|
}
|
|
421
|
-
onArrowDown() {
|
|
422
|
-
if (this.selectedListboxItemIndex <
|
|
439
|
+
onArrowDown(listboxItems) {
|
|
440
|
+
if (this.selectedListboxItemIndex < listboxItems.length - 1) {
|
|
423
441
|
const offset = this.selectedListboxItemIndex ? this.selectedListboxItemIndex : this.focusedListboxItemIndex;
|
|
424
442
|
this.selectedListboxItemIndex = offset + 1;
|
|
425
|
-
const previousItem =
|
|
426
|
-
const currentItem =
|
|
443
|
+
const previousItem = listboxItems[this.selectedListboxItemIndex - 1]?.nativeElement;
|
|
444
|
+
const currentItem = listboxItems[this.selectedListboxItemIndex]?.nativeElement;
|
|
427
445
|
this.changeTabindex(previousItem, currentItem);
|
|
428
446
|
}
|
|
429
447
|
}
|
|
430
|
-
onArrowUp() {
|
|
448
|
+
onArrowUp(listboxItems) {
|
|
431
449
|
if (this.selectedListboxItemIndex > 0 || this.focusedListboxItemIndex > 0) {
|
|
432
450
|
const offset = this.selectedListboxItemIndex ? this.selectedListboxItemIndex : this.focusedListboxItemIndex;
|
|
433
451
|
this.selectedListboxItemIndex = offset - 1;
|
|
434
|
-
const previousItem =
|
|
435
|
-
const currentItem =
|
|
452
|
+
const previousItem = listboxItems[this.selectedListboxItemIndex + 1]?.nativeElement;
|
|
453
|
+
const currentItem = listboxItems[this.selectedListboxItemIndex]?.nativeElement;
|
|
436
454
|
this.changeTabindex(previousItem, currentItem);
|
|
437
455
|
}
|
|
438
456
|
}
|
|
@@ -650,7 +668,6 @@ class ListBoxComponent {
|
|
|
650
668
|
const toolsRef = this.tools.toArray();
|
|
651
669
|
const hostEl = this.hostElement.nativeElement;
|
|
652
670
|
const navService = this.keyboardNavigationService;
|
|
653
|
-
navService.listboxItems = Array.from(this.listboxElement.nativeElement.querySelectorAll('li.k-list-item'));
|
|
654
671
|
this.setIds();
|
|
655
672
|
this.initSubscriptions(navService, hostEl, toolsRef);
|
|
656
673
|
}
|
|
@@ -717,58 +734,41 @@ class ListBoxComponent {
|
|
|
717
734
|
}
|
|
718
735
|
return fieldAccessor(dataItem, this.textField);
|
|
719
736
|
}
|
|
720
|
-
|
|
721
|
-
* @hidden
|
|
722
|
-
*/
|
|
723
|
-
updateListboxItems() {
|
|
724
|
-
this.zone.onStable.pipe(take(1)).subscribe(() => {
|
|
725
|
-
this.keyboardNavigationService.listboxItems = Array.from(this.listboxElement.nativeElement.querySelectorAll('li.k-list-item'));
|
|
726
|
-
});
|
|
727
|
-
}
|
|
728
|
-
/**
|
|
729
|
-
* @hidden
|
|
730
|
-
*/
|
|
731
|
-
swapItems(firstItemIndex, secondItemIndex) {
|
|
732
|
-
const listboxItems = this.keyboardNavigationService.listboxItems;
|
|
733
|
-
[listboxItems[firstItemIndex], listboxItems[secondItemIndex]] = [
|
|
734
|
-
listboxItems[secondItemIndex],
|
|
735
|
-
listboxItems[firstItemIndex],
|
|
736
|
-
];
|
|
737
|
-
}
|
|
738
|
-
onClickEvent(listboxItems, prevIndex, currentIndex, dir) {
|
|
739
|
-
this.selectionChange.next(currentIndex);
|
|
737
|
+
onClickEvent(prevIndex, currentIndex) {
|
|
740
738
|
this.keyboardNavigationService.selectedListboxItemIndex = currentIndex;
|
|
741
739
|
this.keyboardNavigationService.focusedListboxItemIndex = currentIndex;
|
|
740
|
+
this.selectionChange.next(currentIndex);
|
|
742
741
|
this.zone.onStable.pipe(take(1)).subscribe(() => {
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
const
|
|
746
|
-
const currentItem = listboxItems[currentIndex];
|
|
742
|
+
const listboxItems = this.listboxItems.toArray();
|
|
743
|
+
const previousItem = prevIndex ? listboxItems[prevIndex].nativeElement : listboxItems[0].nativeElement;
|
|
744
|
+
const currentItem = listboxItems[currentIndex].nativeElement;
|
|
747
745
|
this.keyboardNavigationService.changeTabindex(previousItem, currentItem);
|
|
748
746
|
});
|
|
749
747
|
}
|
|
750
748
|
initSubscriptions(navService, hostEl, toolsRef) {
|
|
749
|
+
this.subs.add(navService.onShiftSelectedItem.subscribe((actionToPerform) => this.performAction(actionToPerform)));
|
|
750
|
+
this.subs.add(navService.onTransferAllEvent.subscribe((actionToPerform) => this.performAction(actionToPerform)));
|
|
751
|
+
this.subs.add(this.renderer.listen(this.listboxElement.nativeElement, 'focusin', (event) => this.onFocusIn(event)));
|
|
752
|
+
this.subs.add(this.selectionService.onSelect.subscribe((e) => this.onClickEvent(e.prevIndex, e.index)));
|
|
751
753
|
this.subs.add(navService.onDeleteEvent.subscribe((index) => this.onDeleteEvent(index, navService)));
|
|
752
|
-
this.subs.add(this.renderer.listen(hostEl, 'keydown', (event) => navService.onKeyDown(event, toolsRef, this.selectedTools, this.childListbox, this.parentListbox)));
|
|
753
|
-
this.subs.add(this.renderer.listen(this.listboxElement.nativeElement, 'focusin', () => navService.onFocusIn()));
|
|
754
|
-
this.subs.add(navService.onShiftSelectedItem.subscribe((actionToPerform) => this.onShiftItems(actionToPerform)));
|
|
755
|
-
this.subs.add(navService.onTransferAllEvent.subscribe((actionToPerform) => this.onShiftItems(actionToPerform)));
|
|
756
754
|
this.subs.add(navService.onMoveSelectedItem.subscribe((dir) => this.performAction(dir)));
|
|
757
|
-
this.subs.add(this.
|
|
755
|
+
this.subs.add(this.renderer.listen(hostEl, 'keydown', (event) => navService.onKeyDown(event, toolsRef, this.selectedTools, this.childListbox, this.parentListbox, this.listboxItems.toArray())));
|
|
758
756
|
this.subs.add(navService.onSelectionChange.subscribe((index) => {
|
|
759
757
|
this.selectionService.selectedIndex = index;
|
|
760
758
|
this.selectionChange.next({ index, prevIndex: null });
|
|
761
759
|
}));
|
|
762
760
|
}
|
|
763
|
-
|
|
764
|
-
this.
|
|
765
|
-
if (
|
|
766
|
-
this.
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
761
|
+
onFocusIn(event) {
|
|
762
|
+
const navService = this.keyboardNavigationService;
|
|
763
|
+
if (navService.focusedListboxItemIndex === navService.selectedListboxItemIndex) {
|
|
764
|
+
const items = this.listboxItems.toArray();
|
|
765
|
+
const index = items.findIndex(elem => elem.nativeElement === event.target);
|
|
766
|
+
this.selectionService.selectedIndex = index;
|
|
767
|
+
this.selectionChange.next({ index, prevIndex: null });
|
|
768
|
+
const previousItem = items[navService.selectedListboxItemIndex]?.nativeElement;
|
|
769
|
+
const currentItem = items[index]?.nativeElement;
|
|
770
|
+
this.renderer.setAttribute(previousItem, 'tabindex', '-1');
|
|
771
|
+
this.renderer.setAttribute(currentItem, 'tabindex', '0');
|
|
772
772
|
}
|
|
773
773
|
}
|
|
774
774
|
setIds() {
|
|
@@ -805,13 +805,13 @@ class ListBoxComponent {
|
|
|
805
805
|
onDeleteEvent(index, navService) {
|
|
806
806
|
this.selectionService.selectedIndex = index;
|
|
807
807
|
this.performAction('remove');
|
|
808
|
-
this.
|
|
809
|
-
const setIndex = index + 1 ===
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
navService.changeTabindex(null, navService.listboxItems[setIndex['tabindex']]);
|
|
808
|
+
const listboxItems = this.listboxItems.toArray();
|
|
809
|
+
const setIndex = index + 1 === listboxItems.length ?
|
|
810
|
+
{ index: index - 1, tabindex: index - 1 } : { index, tabindex: index + 1 };
|
|
811
|
+
navService.changeTabindex(null, listboxItems[setIndex['tabindex']]?.nativeElement);
|
|
813
812
|
this.selectionChange.next({ index: setIndex['index'], prevIndex: null });
|
|
814
813
|
navService.selectedListboxItemIndex = setIndex['index'];
|
|
814
|
+
navService.focusedListboxItemIndex = setIndex['index'];
|
|
815
815
|
navService.focusedListboxItem = setIndex['index'];
|
|
816
816
|
this.selectionService.selectedIndex = setIndex['index'];
|
|
817
817
|
}
|
|
@@ -838,7 +838,7 @@ ListBoxComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", versi
|
|
|
838
838
|
provide: L10N_PREFIX,
|
|
839
839
|
useValue: 'kendo.listbox'
|
|
840
840
|
},
|
|
841
|
-
], 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: `
|
|
841
|
+
], 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: `
|
|
842
842
|
<ng-container kendoListBoxLocalizedMessages
|
|
843
843
|
i18n-moveUp="kendo.listbox.moveUp|The title of the Move Up button"
|
|
844
844
|
moveUp="Move Up"
|
|
@@ -894,6 +894,7 @@ ListBoxComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", versi
|
|
|
894
894
|
[attr.aria-multiselectable]="false"
|
|
895
895
|
>
|
|
896
896
|
<li
|
|
897
|
+
#listboxItems
|
|
897
898
|
*ngFor="let item of data; let i = index"
|
|
898
899
|
kendoListBoxItemSelectable
|
|
899
900
|
class="k-list-item"
|
|
@@ -989,6 +990,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
|
|
|
989
990
|
[attr.aria-multiselectable]="false"
|
|
990
991
|
>
|
|
991
992
|
<li
|
|
993
|
+
#listboxItems
|
|
992
994
|
*ngFor="let item of data; let i = index"
|
|
993
995
|
kendoListBoxItemSelectable
|
|
994
996
|
class="k-list-item"
|
|
@@ -1028,6 +1030,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
|
|
|
1028
1030
|
}], listboxElement: [{
|
|
1029
1031
|
type: ViewChild,
|
|
1030
1032
|
args: ['listbox']
|
|
1033
|
+
}], listboxItems: [{
|
|
1034
|
+
type: ViewChildren,
|
|
1035
|
+
args: ['listboxItems']
|
|
1031
1036
|
}], toolbarElement: [{
|
|
1032
1037
|
type: ViewChild,
|
|
1033
1038
|
args: ['toolbar']
|
|
@@ -1148,9 +1153,8 @@ class DataBindingDirective {
|
|
|
1148
1153
|
return;
|
|
1149
1154
|
}
|
|
1150
1155
|
const newIndex = dir === 'up' ? index - 1 : index + 1;
|
|
1151
|
-
// ES6 Destructuring swap
|
|
1152
1156
|
[this.selectedBox.data[newIndex], this.selectedBox.data[index]] = [this.selectedBox.data[index], this.selectedBox.data[newIndex]];
|
|
1153
|
-
this.selectedBox.selectionService.select(newIndex
|
|
1157
|
+
this.selectedBox.selectionService.select(newIndex);
|
|
1154
1158
|
}
|
|
1155
1159
|
removeItem() {
|
|
1156
1160
|
const index = this.selectedBox.selectedIndex;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
3
|
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
4
|
*-------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { EventEmitter, NgZone, Renderer2 } from "@angular/core";
|
|
5
|
+
import { ElementRef, EventEmitter, NgZone, Renderer2 } from "@angular/core";
|
|
6
6
|
import { Button } from "@progress/kendo-angular-buttons";
|
|
7
7
|
import { ListBoxComponent } from "./listbox.component";
|
|
8
8
|
import { ActionName, Tool } from "./toolbar";
|
|
@@ -13,7 +13,6 @@ import * as i0 from "@angular/core";
|
|
|
13
13
|
export declare class KeyboardNavigationService {
|
|
14
14
|
private renderer;
|
|
15
15
|
private zone;
|
|
16
|
-
listboxItems: Array<HTMLElement>;
|
|
17
16
|
selectedListboxItemIndex: number;
|
|
18
17
|
focusedListboxItemIndex: number;
|
|
19
18
|
focusedToolIndex: number;
|
|
@@ -23,10 +22,10 @@ export declare class KeyboardNavigationService {
|
|
|
23
22
|
onTransferAllEvent: EventEmitter<ActionName>;
|
|
24
23
|
onShiftSelectedItem: EventEmitter<ActionName>;
|
|
25
24
|
constructor(renderer: Renderer2, zone: NgZone);
|
|
26
|
-
onKeyDown(event: any, toolsRef: Array<Button>, toolbar: Tool[], childListbox: ListBoxComponent, parentListbox: ListBoxComponent): void;
|
|
25
|
+
onKeyDown(event: any, toolsRef: Array<Button>, toolbar: Tool[], childListbox: ListBoxComponent, parentListbox: ListBoxComponent, listboxItems: Array<ElementRef>): void;
|
|
27
26
|
changeTabindex(previousItem: HTMLElement, currentItem: HTMLElement): void;
|
|
28
|
-
onFocusIn(): void;
|
|
29
27
|
private handleToolbarArrows;
|
|
28
|
+
private onSpaceKey;
|
|
30
29
|
private onArrowUpOrDown;
|
|
31
30
|
private onArrowLeftOrRight;
|
|
32
31
|
private onSelectChange;
|
package/listbox.component.d.ts
CHANGED
|
@@ -38,6 +38,10 @@ export declare class ListBoxComponent implements OnInit, AfterViewInit, OnDestro
|
|
|
38
38
|
* @hidden
|
|
39
39
|
*/
|
|
40
40
|
listboxElement: ElementRef;
|
|
41
|
+
/**
|
|
42
|
+
* @hidden
|
|
43
|
+
*/
|
|
44
|
+
listboxItems: QueryList<any>;
|
|
41
45
|
/**
|
|
42
46
|
* @hidden
|
|
43
47
|
*/
|
|
@@ -151,17 +155,9 @@ export declare class ListBoxComponent implements OnInit, AfterViewInit, OnDestro
|
|
|
151
155
|
* @hidden
|
|
152
156
|
*/
|
|
153
157
|
getText(dataItem: any): string;
|
|
154
|
-
/**
|
|
155
|
-
* @hidden
|
|
156
|
-
*/
|
|
157
|
-
updateListboxItems(): void;
|
|
158
|
-
/**
|
|
159
|
-
* @hidden
|
|
160
|
-
*/
|
|
161
|
-
swapItems(firstItemIndex: number, secondItemIndex: number): void;
|
|
162
158
|
private onClickEvent;
|
|
163
159
|
private initSubscriptions;
|
|
164
|
-
private
|
|
160
|
+
private onFocusIn;
|
|
165
161
|
private setIds;
|
|
166
162
|
private onDeleteEvent;
|
|
167
163
|
private setToolbarClass;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@progress/kendo-angular-listbox",
|
|
3
|
-
"version": "12.0.1-develop.
|
|
3
|
+
"version": "12.0.1-develop.4",
|
|
4
4
|
"description": "Kendo UI for Angular ListBox",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"author": "Progress",
|
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
"@angular/core": "13 - 16",
|
|
24
24
|
"@angular/platform-browser": "13 - 16",
|
|
25
25
|
"@progress/kendo-licensing": "^1.0.2",
|
|
26
|
-
"@progress/kendo-angular-buttons": "12.0.1-develop.
|
|
27
|
-
"@progress/kendo-angular-common": "12.0.1-develop.
|
|
28
|
-
"@progress/kendo-angular-popup": "12.0.1-develop.
|
|
26
|
+
"@progress/kendo-angular-buttons": "12.0.1-develop.4",
|
|
27
|
+
"@progress/kendo-angular-common": "12.0.1-develop.4",
|
|
28
|
+
"@progress/kendo-angular-popup": "12.0.1-develop.4",
|
|
29
29
|
"rxjs": "^6.5.3 || ^7.0.0"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"tslib": "^2.3.1",
|
|
33
|
-
"@progress/kendo-angular-schematics": "12.0.1-develop.
|
|
33
|
+
"@progress/kendo-angular-schematics": "12.0.1-develop.4",
|
|
34
34
|
"@progress/kendo-common": "^0.2.2"
|
|
35
35
|
},
|
|
36
36
|
"schematics": "./schematics/collection.json",
|
|
@@ -6,11 +6,11 @@ function default_1(options) {
|
|
|
6
6
|
// Additional dependencies to install.
|
|
7
7
|
// See https://github.com/telerik/kendo-schematics/issues/28
|
|
8
8
|
peerDependencies: {
|
|
9
|
-
'@progress/kendo-angular-buttons': '12.0.1-develop.
|
|
10
|
-
'@progress/kendo-angular-common': '12.0.1-develop.
|
|
11
|
-
'@progress/kendo-angular-l10n': '12.0.1-develop.
|
|
9
|
+
'@progress/kendo-angular-buttons': '12.0.1-develop.4',
|
|
10
|
+
'@progress/kendo-angular-common': '12.0.1-develop.4',
|
|
11
|
+
'@progress/kendo-angular-l10n': '12.0.1-develop.4',
|
|
12
12
|
// Peer of kendo-angular-buttons
|
|
13
|
-
'@progress/kendo-angular-popup': '12.0.1-develop.
|
|
13
|
+
'@progress/kendo-angular-popup': '12.0.1-develop.4'
|
|
14
14
|
} });
|
|
15
15
|
return (0, schematics_1.externalSchematic)('@progress/kendo-angular-schematics', 'ng-add', finalOptions);
|
|
16
16
|
}
|
package/selection.service.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export interface ListBoxSelectionEvent {
|
|
|
17
17
|
export declare class ListBoxSelectionService {
|
|
18
18
|
onSelect: EventEmitter<any>;
|
|
19
19
|
selectedIndex: number;
|
|
20
|
-
select(index: number
|
|
20
|
+
select(index: number): void;
|
|
21
21
|
isSelected(index: number): boolean;
|
|
22
22
|
clearSelection(): void;
|
|
23
23
|
static ɵfac: i0.ɵɵFactoryDeclaration<ListBoxSelectionService, never>;
|