@progress/kendo-angular-listbox 21.4.1 → 22.0.0-develop.1
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/fesm2022/progress-kendo-angular-listbox.mjs +34 -34
- package/localization/messages.d.ts +1 -1
- package/package.json +9 -17
- package/schematics/ngAdd/index.js +4 -4
- package/esm2022/constants.mjs +0 -73
- package/esm2022/data-binding.directive.mjs +0 -294
- package/esm2022/directives.mjs +0 -19
- package/esm2022/index.mjs +0 -12
- package/esm2022/item-selectable.directive.mjs +0 -47
- package/esm2022/item-template.directive.mjs +0 -42
- package/esm2022/keyboard-navigation.service.mjs +0 -389
- package/esm2022/listbox.component.mjs +0 -792
- package/esm2022/listbox.module.mjs +0 -32
- package/esm2022/localization/custom-messages.component.mjs +0 -58
- package/esm2022/localization/localized-messages.directive.mjs +0 -39
- package/esm2022/localization/messages.mjs +0 -66
- package/esm2022/package-metadata.mjs +0 -16
- package/esm2022/progress-kendo-angular-listbox.mjs +0 -8
- package/esm2022/selection-mode.mjs +0 -5
- package/esm2022/selection.service.mjs +0 -166
- package/esm2022/size.mjs +0 -5
- package/esm2022/toolbar.mjs +0 -5
- package/esm2022/util.mjs +0 -38
|
@@ -1,792 +0,0 @@
|
|
|
1
|
-
/**-----------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright © 2026 Progress Software Corporation. All rights reserved.
|
|
3
|
-
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
-
*-------------------------------------------------------------------------------------------*/
|
|
5
|
-
/* eslint-disable @typescript-eslint/no-inferrable-types */
|
|
6
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
7
|
-
import { ChangeDetectorRef, Component, ContentChild, ElementRef, EventEmitter, HostBinding, Input, isDevMode, NgZone, Output, QueryList, Renderer2, ViewChild, ViewChildren } from '@angular/core';
|
|
8
|
-
import { validatePackage } from '@progress/kendo-licensing';
|
|
9
|
-
import { Subscription } from 'rxjs';
|
|
10
|
-
import { packageMetadata } from './package-metadata';
|
|
11
|
-
import { ListBoxSelectionService } from './selection.service';
|
|
12
|
-
import { ItemTemplateDirective } from './item-template.directive';
|
|
13
|
-
import { defaultItemDisabled, fieldAccessor, getTools } from './util';
|
|
14
|
-
import { allTools, DEFAULT_TOOLBAR_POSITION, sizeClassMap, actionsClasses } from './constants';
|
|
15
|
-
import { ButtonComponent } from '@progress/kendo-angular-buttons';
|
|
16
|
-
import { KeyboardNavigationService } from './keyboard-navigation.service';
|
|
17
|
-
import { take } from 'rxjs/operators';
|
|
18
|
-
import { L10N_PREFIX, LocalizationService } from '@progress/kendo-angular-l10n';
|
|
19
|
-
import { caretAltLeftIcon, caretAltRightIcon } from '@progress/kendo-svg-icons';
|
|
20
|
-
import { ItemSelectableDirective } from './item-selectable.directive';
|
|
21
|
-
import { LocalizedMessagesDirective } from './localization/localized-messages.directive';
|
|
22
|
-
import { isPresent, TemplateContextDirective } from '@progress/kendo-angular-common';
|
|
23
|
-
import * as i0 from "@angular/core";
|
|
24
|
-
import * as i1 from "./keyboard-navigation.service";
|
|
25
|
-
import * as i2 from "./selection.service";
|
|
26
|
-
import * as i3 from "@progress/kendo-angular-l10n";
|
|
27
|
-
const DEFAULT_SIZE = 'medium';
|
|
28
|
-
let idx = 0;
|
|
29
|
-
/**
|
|
30
|
-
* Represents the Kendo UI ListBox component for Angular.
|
|
31
|
-
* Provides a list of items from which you can select and transfer data between connected ListBoxes
|
|
32
|
-
* ([see overview]({% slug overview_listbox %})).
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```typescript
|
|
36
|
-
* @Component({
|
|
37
|
-
* selector: 'my-app',
|
|
38
|
-
* template: `
|
|
39
|
-
* <kendo-listbox
|
|
40
|
-
* [data]="items"
|
|
41
|
-
* textField="name"
|
|
42
|
-
* [toolbar]="true">
|
|
43
|
-
* </kendo-listbox>
|
|
44
|
-
* `
|
|
45
|
-
* })
|
|
46
|
-
* export class AppComponent {
|
|
47
|
-
* items = [
|
|
48
|
-
* { name: 'Item 1' },
|
|
49
|
-
* { name: 'Item 2' }
|
|
50
|
-
* ];
|
|
51
|
-
* }
|
|
52
|
-
* ```
|
|
53
|
-
*
|
|
54
|
-
* @remarks
|
|
55
|
-
* Supported children components are: {@link CustomMessagesComponent}.
|
|
56
|
-
*/
|
|
57
|
-
export class ListBoxComponent {
|
|
58
|
-
keyboardNavigationService;
|
|
59
|
-
selectionService;
|
|
60
|
-
hostElement;
|
|
61
|
-
renderer;
|
|
62
|
-
zone;
|
|
63
|
-
localization;
|
|
64
|
-
cdr;
|
|
65
|
-
/**
|
|
66
|
-
* @hidden
|
|
67
|
-
*/
|
|
68
|
-
listboxClassName = true;
|
|
69
|
-
/**
|
|
70
|
-
* @hidden
|
|
71
|
-
*/
|
|
72
|
-
direction;
|
|
73
|
-
/**
|
|
74
|
-
* @hidden
|
|
75
|
-
*/
|
|
76
|
-
itemTemplate;
|
|
77
|
-
/**
|
|
78
|
-
* @hidden
|
|
79
|
-
*/
|
|
80
|
-
listboxElement;
|
|
81
|
-
/**
|
|
82
|
-
* @hidden
|
|
83
|
-
*/
|
|
84
|
-
listboxItems;
|
|
85
|
-
/**
|
|
86
|
-
* @hidden
|
|
87
|
-
*/
|
|
88
|
-
toolbarElement;
|
|
89
|
-
/**
|
|
90
|
-
* @hidden
|
|
91
|
-
*/
|
|
92
|
-
tools;
|
|
93
|
-
/**
|
|
94
|
-
* Specifies the field of the data item that provides the text content of the nodes.
|
|
95
|
-
*/
|
|
96
|
-
textField;
|
|
97
|
-
/**
|
|
98
|
-
* Sets the selection mode of the ListBox.
|
|
99
|
-
*
|
|
100
|
-
* @default 'single'
|
|
101
|
-
*/
|
|
102
|
-
set selectable(mode) {
|
|
103
|
-
this._selectable = mode;
|
|
104
|
-
this.selectionService.selectionMode = mode;
|
|
105
|
-
}
|
|
106
|
-
get selectable() {
|
|
107
|
-
return this._selectable;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Specifies the data that the ListBox displays.
|
|
111
|
-
*
|
|
112
|
-
* @default []
|
|
113
|
-
*/
|
|
114
|
-
data = [];
|
|
115
|
-
/**
|
|
116
|
-
* Specifies the size of the component.
|
|
117
|
-
*
|
|
118
|
-
*/
|
|
119
|
-
set size(size) {
|
|
120
|
-
const newSize = size ? size : DEFAULT_SIZE;
|
|
121
|
-
this.renderer.removeClass(this.hostElement.nativeElement, `k-listbox-${sizeClassMap[this.size]}`);
|
|
122
|
-
this.setSizingClass(newSize);
|
|
123
|
-
this._size = size;
|
|
124
|
-
}
|
|
125
|
-
get size() {
|
|
126
|
-
return this._size;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Configures the toolbar of the ListBox.
|
|
130
|
-
* Specifies whether to display a toolbar and which tools and position to use.
|
|
131
|
-
*
|
|
132
|
-
* @default false
|
|
133
|
-
*/
|
|
134
|
-
set toolbar(config) {
|
|
135
|
-
let position = DEFAULT_TOOLBAR_POSITION;
|
|
136
|
-
if (typeof config === 'boolean') {
|
|
137
|
-
this.selectedTools = config ? allTools : [];
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
this.selectedTools = config.tools ? getTools(config.tools) : allTools;
|
|
141
|
-
if (config.position) {
|
|
142
|
-
position = config.position;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
this.setToolbarClass(position);
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Specifies the value of the `aria-label` attribute of the Listbox element.
|
|
149
|
-
*
|
|
150
|
-
* @default 'Listbox'
|
|
151
|
-
*/
|
|
152
|
-
listboxLabel = 'Listbox';
|
|
153
|
-
/**
|
|
154
|
-
* Specifies the value of the `aria-label` attribute of the Listbox toolbar element.
|
|
155
|
-
*
|
|
156
|
-
* @default 'Toolbar'
|
|
157
|
-
*/
|
|
158
|
-
listboxToolbarLabel = 'Toolbar';
|
|
159
|
-
/**
|
|
160
|
-
* Specifies a function that determines if a specific item is disabled.
|
|
161
|
-
*/
|
|
162
|
-
itemDisabled = defaultItemDisabled;
|
|
163
|
-
/**
|
|
164
|
-
* Fires when you select a different ListBox item.
|
|
165
|
-
* Also fires when you move a node, because moving changes its index.
|
|
166
|
-
*/
|
|
167
|
-
selectionChange = new EventEmitter();
|
|
168
|
-
/**
|
|
169
|
-
* Fires when you click a ListBox item.
|
|
170
|
-
*/
|
|
171
|
-
action = new EventEmitter();
|
|
172
|
-
/**
|
|
173
|
-
* @hidden
|
|
174
|
-
*/
|
|
175
|
-
getChildListbox = new EventEmitter();
|
|
176
|
-
/**
|
|
177
|
-
* @hidden
|
|
178
|
-
*/
|
|
179
|
-
get listClasses() {
|
|
180
|
-
return `k-list k-list-${sizeClassMap[this.size]}`;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* @hidden
|
|
184
|
-
*/
|
|
185
|
-
messageFor(key) {
|
|
186
|
-
return this.localization.get(key);
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* @hidden
|
|
190
|
-
*/
|
|
191
|
-
selectedTools = [];
|
|
192
|
-
/**
|
|
193
|
-
* @hidden
|
|
194
|
-
*/
|
|
195
|
-
listboxId;
|
|
196
|
-
/**
|
|
197
|
-
* @hidden
|
|
198
|
-
*/
|
|
199
|
-
toolbarId;
|
|
200
|
-
/**
|
|
201
|
-
* @hidden
|
|
202
|
-
*/
|
|
203
|
-
childListbox;
|
|
204
|
-
/**
|
|
205
|
-
* @hidden
|
|
206
|
-
*/
|
|
207
|
-
parentListbox;
|
|
208
|
-
/**
|
|
209
|
-
* @hidden
|
|
210
|
-
*/
|
|
211
|
-
caretAltLeftIcon = caretAltLeftIcon;
|
|
212
|
-
/**
|
|
213
|
-
* @hidden
|
|
214
|
-
*/
|
|
215
|
-
caretAltRightIcon = caretAltRightIcon;
|
|
216
|
-
localizationSubscription;
|
|
217
|
-
_size = DEFAULT_SIZE;
|
|
218
|
-
subs = new Subscription();
|
|
219
|
-
shouldFireFocusIn = false;
|
|
220
|
-
_selectable = 'single';
|
|
221
|
-
constructor(keyboardNavigationService, selectionService, hostElement, renderer, zone, localization, cdr) {
|
|
222
|
-
this.keyboardNavigationService = keyboardNavigationService;
|
|
223
|
-
this.selectionService = selectionService;
|
|
224
|
-
this.hostElement = hostElement;
|
|
225
|
-
this.renderer = renderer;
|
|
226
|
-
this.zone = zone;
|
|
227
|
-
this.localization = localization;
|
|
228
|
-
this.cdr = cdr;
|
|
229
|
-
validatePackage(packageMetadata);
|
|
230
|
-
this.setToolbarClass(DEFAULT_TOOLBAR_POSITION);
|
|
231
|
-
this.setSizingClass(this.size);
|
|
232
|
-
this.direction = localization.rtl ? 'rtl' : 'ltr';
|
|
233
|
-
this.selectionService.isItemDisabled = (index) => {
|
|
234
|
-
return this.itemDisabled(this.data[index]);
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
ngOnInit() {
|
|
238
|
-
// This event emitter gives us the connectedWith value from the DataBinding directive
|
|
239
|
-
this.getChildListbox.emit();
|
|
240
|
-
if (this.childListbox) {
|
|
241
|
-
// This allows us to know to which parent Listbox the child Listbox is connected to
|
|
242
|
-
this.childListbox.parentListbox = this;
|
|
243
|
-
}
|
|
244
|
-
this.localizationSubscription = this.localization.changes.subscribe(({ rtl }) => {
|
|
245
|
-
this.direction = rtl ? 'rtl' : 'ltr';
|
|
246
|
-
});
|
|
247
|
-
this.subs.add(this.localizationSubscription);
|
|
248
|
-
}
|
|
249
|
-
ngAfterViewInit() {
|
|
250
|
-
const toolsRef = this.tools.toArray();
|
|
251
|
-
const hostEl = this.hostElement.nativeElement;
|
|
252
|
-
const navService = this.keyboardNavigationService;
|
|
253
|
-
this.setIds();
|
|
254
|
-
this.initSubscriptions(navService, hostEl, toolsRef);
|
|
255
|
-
}
|
|
256
|
-
ngOnDestroy() {
|
|
257
|
-
this.subs.unsubscribe();
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* @hidden
|
|
261
|
-
*/
|
|
262
|
-
performAction(actionName) {
|
|
263
|
-
const isActionTransferFrom = actionName === 'transferFrom' || actionName === 'transferAllFrom';
|
|
264
|
-
const isListboxChild = this.parentListbox && !this.childListbox;
|
|
265
|
-
const isListboxParentAndChild = !!(this.parentListbox && this.childListbox);
|
|
266
|
-
const isListboxParent = !!(this.childListbox || (!this.childListbox && !this.parentListbox));
|
|
267
|
-
this.shouldFireFocusIn = false;
|
|
268
|
-
if (isListboxChild || (isListboxParentAndChild && isActionTransferFrom)) {
|
|
269
|
-
this.parentListbox.action.next(actionName);
|
|
270
|
-
}
|
|
271
|
-
else if (isListboxParent || (isListboxParentAndChild && !isActionTransferFrom)) {
|
|
272
|
-
this.action.next(actionName);
|
|
273
|
-
}
|
|
274
|
-
const toolsRef = this.tools.toArray() || this.parentListbox.tools.toArray();
|
|
275
|
-
const focusedToolIndex = toolsRef.findIndex(elem => elem.nativeElement === document.activeElement);
|
|
276
|
-
if ((this.selectedTools.length > 0 || this.parentListbox.selectedTools.length > 0) && focusedToolIndex > -1) {
|
|
277
|
-
const navService = this.keyboardNavigationService || this.parentListbox.keyboardNavigationService;
|
|
278
|
-
const selectedTools = this.selectedTools || this.parentListbox.selectedTools;
|
|
279
|
-
const prevTool = toolsRef[navService.focusedToolIndex]?.element;
|
|
280
|
-
navService.focusedToolIndex = selectedTools.findIndex(tool => tool.name === actionName);
|
|
281
|
-
const currentTool = toolsRef[navService.focusedToolIndex]?.element;
|
|
282
|
-
navService.changeTabindex(prevTool, currentTool);
|
|
283
|
-
}
|
|
284
|
-
this.cdr.markForCheck();
|
|
285
|
-
this.zone.runOutsideAngular(() => setTimeout(() => {
|
|
286
|
-
this.shouldFireFocusIn = true;
|
|
287
|
-
}));
|
|
288
|
-
}
|
|
289
|
-
/**
|
|
290
|
-
* Selects multiple ListBox nodes programmatically.
|
|
291
|
-
*/
|
|
292
|
-
select(indices) {
|
|
293
|
-
const validIndices = indices.filter(index => index >= 0 && index < this.data.length);
|
|
294
|
-
this.selectionService.setSelectedIndices(validIndices);
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* Selects a ListBox node programmatically.
|
|
298
|
-
*
|
|
299
|
-
* @hidden
|
|
300
|
-
*/
|
|
301
|
-
selectItem(index) {
|
|
302
|
-
if (index >= 0 && index < this.data.length) {
|
|
303
|
-
this.select([index]);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
/**
|
|
307
|
-
* Clears the ListBox selection programmatically.
|
|
308
|
-
*/
|
|
309
|
-
clearSelection() {
|
|
310
|
-
this.selectionService.clearSelection();
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* Gets the indexes of the currently selected items in the ListBox.
|
|
314
|
-
*/
|
|
315
|
-
get selectedIndices() {
|
|
316
|
-
return this.selectionService.selectedIndices;
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* @hidden
|
|
320
|
-
*/
|
|
321
|
-
get getListboxId() {
|
|
322
|
-
const id = ++idx;
|
|
323
|
-
const listboxId = `k-listbox-${id}`;
|
|
324
|
-
return listboxId;
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* @hidden
|
|
328
|
-
*/
|
|
329
|
-
getText(dataItem) {
|
|
330
|
-
if (typeof dataItem !== 'string' && !this.textField && isDevMode()) {
|
|
331
|
-
throw new Error('Missing textField input. When passing an array of objects as data, please set the textField input of the ListBox accordingly.');
|
|
332
|
-
}
|
|
333
|
-
return fieldAccessor(dataItem, this.textField);
|
|
334
|
-
}
|
|
335
|
-
/**
|
|
336
|
-
* @hidden
|
|
337
|
-
*/
|
|
338
|
-
toolIcon(icon) {
|
|
339
|
-
return this.direction === 'ltr' ?
|
|
340
|
-
icon :
|
|
341
|
-
icon === 'caret-alt-left' ?
|
|
342
|
-
'caret-alt-right' :
|
|
343
|
-
icon === 'caret-alt-right' ?
|
|
344
|
-
'caret-alt-left' :
|
|
345
|
-
icon;
|
|
346
|
-
}
|
|
347
|
-
/**
|
|
348
|
-
* @hidden
|
|
349
|
-
*/
|
|
350
|
-
toolSVGIcon(icon) {
|
|
351
|
-
return this.direction === 'ltr' ?
|
|
352
|
-
icon :
|
|
353
|
-
icon === this.caretAltLeftIcon ?
|
|
354
|
-
this.caretAltRightIcon :
|
|
355
|
-
icon === this.caretAltRightIcon ?
|
|
356
|
-
this.caretAltLeftIcon :
|
|
357
|
-
icon;
|
|
358
|
-
}
|
|
359
|
-
initSubscriptions(navService, hostEl, toolsRef) {
|
|
360
|
-
this.subs.add(navService.onShiftSelectedItem.subscribe((actionToPerform) => this.performAction(actionToPerform)));
|
|
361
|
-
this.subs.add(navService.onTransferAllEvent.subscribe((actionToPerform) => this.performAction(actionToPerform)));
|
|
362
|
-
this.subs.add(this.selectionService.onSelect.subscribe((event) => {
|
|
363
|
-
this.shouldFireFocusIn = false;
|
|
364
|
-
this.selectionChange.next(event);
|
|
365
|
-
const newFocusIndex = isPresent(this.selectionService.rangeSelectionTargetIndex)
|
|
366
|
-
? this.selectionService.rangeSelectionTargetIndex
|
|
367
|
-
: this.selectionService.lastSelectedOrUnselectedIndex;
|
|
368
|
-
if (isPresent(newFocusIndex)) {
|
|
369
|
-
const listboxItems = this.listboxItems.toArray();
|
|
370
|
-
const previousItem = listboxItems[navService.focusedListboxItemIndex]?.nativeElement;
|
|
371
|
-
const currentItem = listboxItems[newFocusIndex]?.nativeElement;
|
|
372
|
-
if (previousItem && currentItem) {
|
|
373
|
-
navService.changeTabindex(previousItem, currentItem, false);
|
|
374
|
-
navService.focusedListboxItemIndex = newFocusIndex;
|
|
375
|
-
navService.selectedListboxItemIndex = newFocusIndex;
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
this.cdr.markForCheck();
|
|
379
|
-
this.zone.runOutsideAngular(() => setTimeout(() => {
|
|
380
|
-
this.shouldFireFocusIn = true;
|
|
381
|
-
}));
|
|
382
|
-
}));
|
|
383
|
-
this.subs.add(navService.onDeleteEvent.subscribe((index) => this.onDeleteEvent(index, navService)));
|
|
384
|
-
this.subs.add(navService.onMoveSelectedItem.subscribe((dir) => this.performAction(dir)));
|
|
385
|
-
this.subs.add(navService.onSelectAll.subscribe(() => {
|
|
386
|
-
if (this.selectable === 'multiple') {
|
|
387
|
-
const previousSelection = [...this.selectionService.selectedIndices];
|
|
388
|
-
const allSelected = this.selectionService.areAllSelected(this.data.length);
|
|
389
|
-
if (allSelected) {
|
|
390
|
-
this.selectionService.clearSelection();
|
|
391
|
-
this.selectionChange.next({
|
|
392
|
-
selectedIndices: null,
|
|
393
|
-
deselectedIndices: previousSelection.length > 0 ? previousSelection : null
|
|
394
|
-
});
|
|
395
|
-
}
|
|
396
|
-
else {
|
|
397
|
-
this.selectionService.selectAll(this.data.length);
|
|
398
|
-
const selectedIndices = this.selectionService.selectedIndices.filter(i => !previousSelection.includes(i));
|
|
399
|
-
this.selectionChange.next({
|
|
400
|
-
selectedIndices: selectedIndices.length > 0 ? selectedIndices : null,
|
|
401
|
-
deselectedIndices: null
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
|
-
this.cdr.markForCheck();
|
|
405
|
-
}
|
|
406
|
-
}));
|
|
407
|
-
this.subs.add(navService.onSelectToEnd.subscribe(({ direction }) => {
|
|
408
|
-
if (this.selectable === 'multiple') {
|
|
409
|
-
this.shouldFireFocusIn = false;
|
|
410
|
-
const previousSelection = [...this.selectionService.selectedIndices];
|
|
411
|
-
const targetIndex = direction === 'home' ? 0 : this.data.length - 1;
|
|
412
|
-
this.selectionService.selectRange(targetIndex);
|
|
413
|
-
const selectedIndices = this.selectionService.selectedIndices.filter(i => !previousSelection.includes(i));
|
|
414
|
-
const deselectedIndices = previousSelection.filter(i => !this.selectionService.selectedIndices.includes(i));
|
|
415
|
-
this.selectionChange.next({
|
|
416
|
-
selectedIndices: selectedIndices.length > 0 ? selectedIndices : null,
|
|
417
|
-
deselectedIndices: deselectedIndices.length > 0 ? deselectedIndices : null
|
|
418
|
-
});
|
|
419
|
-
const listboxItems = this.listboxItems.toArray();
|
|
420
|
-
const currentItem = listboxItems[navService.focusedListboxItemIndex]?.nativeElement;
|
|
421
|
-
const targetItem = listboxItems[targetIndex]?.nativeElement;
|
|
422
|
-
navService.changeTabindex(currentItem, targetItem);
|
|
423
|
-
navService.focusedListboxItemIndex = targetIndex;
|
|
424
|
-
this.cdr.markForCheck();
|
|
425
|
-
this.zone.runOutsideAngular(() => setTimeout(() => {
|
|
426
|
-
this.shouldFireFocusIn = true;
|
|
427
|
-
}));
|
|
428
|
-
}
|
|
429
|
-
}));
|
|
430
|
-
if (this.listboxElement) {
|
|
431
|
-
this.subs.add(this.renderer.listen(this.listboxElement.nativeElement, 'focusin', (event) => this.onFocusIn(event)));
|
|
432
|
-
}
|
|
433
|
-
this.subs.add(this.renderer.listen(hostEl, 'keydown', (event) => navService.onKeyDown(event, toolsRef, this.selectedTools, this.childListbox, this.parentListbox, this.listboxItems.toArray(), this)));
|
|
434
|
-
this.subs.add(navService.onSelectionChange.subscribe((event) => {
|
|
435
|
-
const { index, ctrlKey, shiftKey } = event;
|
|
436
|
-
this.selectionService.select(index, ctrlKey, shiftKey);
|
|
437
|
-
}));
|
|
438
|
-
}
|
|
439
|
-
onFocusIn(event) {
|
|
440
|
-
const navService = this.keyboardNavigationService;
|
|
441
|
-
if (navService.focusedListboxItemIndex === navService.selectedListboxItemIndex && this.shouldFireFocusIn) {
|
|
442
|
-
const items = this.listboxItems.toArray();
|
|
443
|
-
const index = items.findIndex(elem => elem.nativeElement === event.target);
|
|
444
|
-
if (index === -1) {
|
|
445
|
-
return;
|
|
446
|
-
}
|
|
447
|
-
const previousSelection = [...this.selectionService.selectedIndices];
|
|
448
|
-
this.selectionService.addToSelectedIndices(index);
|
|
449
|
-
navService.focusedListboxItemIndex = index;
|
|
450
|
-
navService.selectedListboxItemIndex = index;
|
|
451
|
-
const deselected = previousSelection.filter(i => i !== index);
|
|
452
|
-
this.selectionChange.next({
|
|
453
|
-
selectedIndices: [index],
|
|
454
|
-
deselectedIndices: deselected.length > 0 ? deselected : null
|
|
455
|
-
});
|
|
456
|
-
const previousItem = items[navService.selectedListboxItemIndex]?.nativeElement;
|
|
457
|
-
const currentItem = items[index]?.nativeElement;
|
|
458
|
-
this.renderer.setAttribute(previousItem, 'tabindex', '-1');
|
|
459
|
-
this.renderer.setAttribute(currentItem, 'tabindex', '0');
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
setIds() {
|
|
463
|
-
if (!this.listboxElement) {
|
|
464
|
-
return;
|
|
465
|
-
}
|
|
466
|
-
const listbox = this.listboxElement.nativeElement;
|
|
467
|
-
this.listboxId = this.getListboxId;
|
|
468
|
-
this.renderer.setAttribute(listbox, 'id', this.listboxId);
|
|
469
|
-
if (this.selectedTools.length > 0 || this.parentListbox?.selectedTools.length > 0) {
|
|
470
|
-
const toolbar = this.toolbarElement?.nativeElement;
|
|
471
|
-
const parentToolbar = this.parentListbox?.toolbarElement?.nativeElement;
|
|
472
|
-
if (this.parentListbox && this.childListbox) {
|
|
473
|
-
this.zone.onStable.pipe(take(1)).subscribe(() => {
|
|
474
|
-
this.toolbarId = `${this.parentListbox.listboxId} ${this.listboxId} ${this.childListbox.listboxId}`;
|
|
475
|
-
this.renderer.setAttribute(toolbar, 'aria-controls', this.toolbarId);
|
|
476
|
-
});
|
|
477
|
-
}
|
|
478
|
-
else if (this.childListbox && !this.parentListbox) {
|
|
479
|
-
this.zone.onStable.pipe(take(1)).subscribe(() => {
|
|
480
|
-
this.toolbarId = this.toolbarId = `${this.listboxId} ${this.childListbox.listboxId}`;
|
|
481
|
-
this.renderer.setAttribute(toolbar, 'aria-controls', this.toolbarId);
|
|
482
|
-
});
|
|
483
|
-
}
|
|
484
|
-
else if (this.parentListbox && this.selectedTools.length > 0) {
|
|
485
|
-
this.toolbarId = `${this.parentListbox.listboxId} ${this.listboxId}`;
|
|
486
|
-
this.parentListbox.toolbarId = this.toolbarId = `${this.parentListbox.listboxId} ${this.listboxId}`;
|
|
487
|
-
this.renderer.setAttribute(toolbar, 'aria-controls', this.toolbarId);
|
|
488
|
-
parentToolbar && this.renderer.setAttribute(parentToolbar, 'aria-controls', this.parentListbox.toolbarId);
|
|
489
|
-
}
|
|
490
|
-
else if (!this.parentListbox && !this.childListbox) {
|
|
491
|
-
this.toolbarId = this.listboxId;
|
|
492
|
-
this.renderer.setAttribute(toolbar, 'aria-controls', this.toolbarId);
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
onDeleteEvent(index, navService) {
|
|
497
|
-
this.selectionService.addToSelectedIndices(index);
|
|
498
|
-
this.performAction('remove');
|
|
499
|
-
const listboxItems = this.listboxItems.toArray();
|
|
500
|
-
const setIndex = index + 1 === listboxItems.length ?
|
|
501
|
-
{ index: index - 1, tabindex: index - 1 } : { index, tabindex: index + 1 };
|
|
502
|
-
navService.changeTabindex(null, listboxItems[setIndex['tabindex']]?.nativeElement);
|
|
503
|
-
this.selectionChange.next({
|
|
504
|
-
selectedIndices: [setIndex['index']],
|
|
505
|
-
deselectedIndices: null
|
|
506
|
-
});
|
|
507
|
-
navService.selectedListboxItemIndex = setIndex['index'];
|
|
508
|
-
navService.focusedListboxItemIndex = setIndex['index'];
|
|
509
|
-
navService.focusedListboxItem = setIndex['index'];
|
|
510
|
-
this.selectionService.selectedIndices = [setIndex['index']];
|
|
511
|
-
}
|
|
512
|
-
setToolbarClass(pos) {
|
|
513
|
-
Object.keys(actionsClasses).forEach((className) => {
|
|
514
|
-
if (pos === className) {
|
|
515
|
-
this.renderer.addClass(this.hostElement.nativeElement, actionsClasses[className]);
|
|
516
|
-
}
|
|
517
|
-
else {
|
|
518
|
-
this.renderer.removeClass(this.hostElement.nativeElement, actionsClasses[className]);
|
|
519
|
-
}
|
|
520
|
-
});
|
|
521
|
-
}
|
|
522
|
-
setSizingClass(size) {
|
|
523
|
-
this.renderer.addClass(this.hostElement.nativeElement, `k-listbox-${sizeClassMap[size]}`);
|
|
524
|
-
}
|
|
525
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ListBoxComponent, deps: [{ token: i1.KeyboardNavigationService }, { token: i2.ListBoxSelectionService }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.NgZone }, { token: i3.LocalizationService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
526
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ListBoxComponent, isStandalone: true, selector: "kendo-listbox", inputs: { textField: "textField", selectable: "selectable", data: "data", size: "size", toolbar: "toolbar", listboxLabel: "listboxLabel", listboxToolbarLabel: "listboxToolbarLabel", itemDisabled: "itemDisabled" }, outputs: { selectionChange: "selectionChange", action: "action", getChildListbox: "getChildListbox" }, host: { properties: { "class.k-listbox": "this.listboxClassName", "attr.dir": "this.direction" } }, providers: [
|
|
527
|
-
ListBoxSelectionService,
|
|
528
|
-
KeyboardNavigationService,
|
|
529
|
-
LocalizationService,
|
|
530
|
-
{
|
|
531
|
-
provide: L10N_PREFIX,
|
|
532
|
-
useValue: 'kendo.listbox'
|
|
533
|
-
},
|
|
534
|
-
], 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: `
|
|
535
|
-
<ng-container kendoListBoxLocalizedMessages
|
|
536
|
-
i18n-moveUp="kendo.listbox.moveUp|The title of the Move Up button"
|
|
537
|
-
moveUp="Move Up"
|
|
538
|
-
|
|
539
|
-
i18n-moveDown="kendo.listbox.moveDown|The title of the Move Down button"
|
|
540
|
-
moveDown="Move Down"
|
|
541
|
-
|
|
542
|
-
i18n-transferTo="kendo.listbox.transferTo|The title of the Transfer To button"
|
|
543
|
-
transferTo="Transfer To"
|
|
544
|
-
|
|
545
|
-
i18n-transferAllTo="kendo.listbox.transferAllTo|The title of the Transfer All To button"
|
|
546
|
-
transferAllTo="Transfer All To"
|
|
547
|
-
|
|
548
|
-
i18n-transferFrom="kendo.listbox.transferFrom|The title of the Transfer From button"
|
|
549
|
-
transferFrom="Transfer From"
|
|
550
|
-
|
|
551
|
-
i18n-transferAllFrom="kendo.listbox.transferAllFrom|The title of the Transfer All From button"
|
|
552
|
-
transferAllFrom="Transfer All From"
|
|
553
|
-
|
|
554
|
-
i18n-remove="kendo.listbox.remove|The title of the Remove button"
|
|
555
|
-
remove="Remove"
|
|
556
|
-
|
|
557
|
-
i18n-noDataText="kendo.listbox.noDataText|The text displayed when there are no items"
|
|
558
|
-
noDataText="No data found."
|
|
559
|
-
>
|
|
560
|
-
</ng-container>
|
|
561
|
-
@if (selectedTools.length > 0) {
|
|
562
|
-
<div
|
|
563
|
-
#toolbar
|
|
564
|
-
class="k-listbox-actions"
|
|
565
|
-
role="toolbar"
|
|
566
|
-
[attr.aria-label]="listboxToolbarLabel"
|
|
567
|
-
>
|
|
568
|
-
@for (tool of selectedTools; track tool; let i = $index) {
|
|
569
|
-
<button
|
|
570
|
-
#tools
|
|
571
|
-
kendoButton
|
|
572
|
-
[attr.tabindex]="i === 0 ? '0' : '-1'"
|
|
573
|
-
[size]="this.size"
|
|
574
|
-
[icon]="toolIcon(tool.icon)"
|
|
575
|
-
[svgIcon]="toolSVGIcon(tool.svgIcon)"
|
|
576
|
-
[attr.title]="messageFor(tool.name)"
|
|
577
|
-
(click)="performAction(tool.name)"
|
|
578
|
-
role="button"
|
|
579
|
-
type="button"
|
|
580
|
-
></button>
|
|
581
|
-
}
|
|
582
|
-
</div>
|
|
583
|
-
}
|
|
584
|
-
<div class="k-list-scroller k-selectable">
|
|
585
|
-
<div class="{{ listClasses }}">
|
|
586
|
-
@if (data.length > 0) {
|
|
587
|
-
<div
|
|
588
|
-
class="k-list-content"
|
|
589
|
-
>
|
|
590
|
-
<ul
|
|
591
|
-
#listbox
|
|
592
|
-
class="k-list-ul"
|
|
593
|
-
role="listbox"
|
|
594
|
-
[attr.aria-label]="listboxLabel"
|
|
595
|
-
[attr.aria-multiselectable]="selectable === 'multiple'"
|
|
596
|
-
>
|
|
597
|
-
@for (item of data; track item; let i = $index) {
|
|
598
|
-
<li
|
|
599
|
-
#listboxItems
|
|
600
|
-
kendoListBoxItemSelectable
|
|
601
|
-
class="k-list-item"
|
|
602
|
-
[attr.tabindex]="i === keyboardNavigationService.focusedListboxItemIndex ? '0' : '-1'"
|
|
603
|
-
role="option"
|
|
604
|
-
[attr.aria-selected]="selectedIndices.indexOf(i) >= 0"
|
|
605
|
-
[index]="i"
|
|
606
|
-
[class.k-disabled]="itemDisabled(item)"
|
|
607
|
-
[attr.aria-disabled]="itemDisabled(item)"
|
|
608
|
-
>
|
|
609
|
-
@if (itemTemplate) {
|
|
610
|
-
<ng-template
|
|
611
|
-
[templateContext]="{
|
|
612
|
-
templateRef: itemTemplate.templateRef,
|
|
613
|
-
$implicit: item
|
|
614
|
-
}"
|
|
615
|
-
>
|
|
616
|
-
</ng-template>
|
|
617
|
-
} @else {
|
|
618
|
-
<span class="k-list-item-text">{{ getText(item) }}</span>
|
|
619
|
-
}
|
|
620
|
-
</li>
|
|
621
|
-
}
|
|
622
|
-
</ul>
|
|
623
|
-
</div>
|
|
624
|
-
}
|
|
625
|
-
@if (data.length === 0) {
|
|
626
|
-
<span
|
|
627
|
-
class="k-nodata"
|
|
628
|
-
>{{ messageFor('noDataText') }}</span>
|
|
629
|
-
}
|
|
630
|
-
</div>
|
|
631
|
-
</div>
|
|
632
|
-
`, isInline: true, dependencies: [{ kind: "directive", type: LocalizedMessagesDirective, selector: "[kendoListBoxLocalizedMessages]" }, { kind: "component", type: ButtonComponent, selector: "button[kendoButton]", inputs: ["arrowIcon", "toggleable", "togglable", "selected", "tabIndex", "imageUrl", "iconClass", "icon", "disabled", "size", "rounded", "fillMode", "themeColor", "svgIcon", "primary", "look"], outputs: ["selectedChange", "click"], exportAs: ["kendoButton"] }, { kind: "directive", type: ItemSelectableDirective, selector: "[kendoListBoxItemSelectable]", inputs: ["index"] }, { kind: "directive", type: TemplateContextDirective, selector: "[templateContext]", inputs: ["templateContext"] }] });
|
|
633
|
-
}
|
|
634
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ListBoxComponent, decorators: [{
|
|
635
|
-
type: Component,
|
|
636
|
-
args: [{
|
|
637
|
-
selector: 'kendo-listbox',
|
|
638
|
-
providers: [
|
|
639
|
-
ListBoxSelectionService,
|
|
640
|
-
KeyboardNavigationService,
|
|
641
|
-
LocalizationService,
|
|
642
|
-
{
|
|
643
|
-
provide: L10N_PREFIX,
|
|
644
|
-
useValue: 'kendo.listbox'
|
|
645
|
-
},
|
|
646
|
-
],
|
|
647
|
-
template: `
|
|
648
|
-
<ng-container kendoListBoxLocalizedMessages
|
|
649
|
-
i18n-moveUp="kendo.listbox.moveUp|The title of the Move Up button"
|
|
650
|
-
moveUp="Move Up"
|
|
651
|
-
|
|
652
|
-
i18n-moveDown="kendo.listbox.moveDown|The title of the Move Down button"
|
|
653
|
-
moveDown="Move Down"
|
|
654
|
-
|
|
655
|
-
i18n-transferTo="kendo.listbox.transferTo|The title of the Transfer To button"
|
|
656
|
-
transferTo="Transfer To"
|
|
657
|
-
|
|
658
|
-
i18n-transferAllTo="kendo.listbox.transferAllTo|The title of the Transfer All To button"
|
|
659
|
-
transferAllTo="Transfer All To"
|
|
660
|
-
|
|
661
|
-
i18n-transferFrom="kendo.listbox.transferFrom|The title of the Transfer From button"
|
|
662
|
-
transferFrom="Transfer From"
|
|
663
|
-
|
|
664
|
-
i18n-transferAllFrom="kendo.listbox.transferAllFrom|The title of the Transfer All From button"
|
|
665
|
-
transferAllFrom="Transfer All From"
|
|
666
|
-
|
|
667
|
-
i18n-remove="kendo.listbox.remove|The title of the Remove button"
|
|
668
|
-
remove="Remove"
|
|
669
|
-
|
|
670
|
-
i18n-noDataText="kendo.listbox.noDataText|The text displayed when there are no items"
|
|
671
|
-
noDataText="No data found."
|
|
672
|
-
>
|
|
673
|
-
</ng-container>
|
|
674
|
-
@if (selectedTools.length > 0) {
|
|
675
|
-
<div
|
|
676
|
-
#toolbar
|
|
677
|
-
class="k-listbox-actions"
|
|
678
|
-
role="toolbar"
|
|
679
|
-
[attr.aria-label]="listboxToolbarLabel"
|
|
680
|
-
>
|
|
681
|
-
@for (tool of selectedTools; track tool; let i = $index) {
|
|
682
|
-
<button
|
|
683
|
-
#tools
|
|
684
|
-
kendoButton
|
|
685
|
-
[attr.tabindex]="i === 0 ? '0' : '-1'"
|
|
686
|
-
[size]="this.size"
|
|
687
|
-
[icon]="toolIcon(tool.icon)"
|
|
688
|
-
[svgIcon]="toolSVGIcon(tool.svgIcon)"
|
|
689
|
-
[attr.title]="messageFor(tool.name)"
|
|
690
|
-
(click)="performAction(tool.name)"
|
|
691
|
-
role="button"
|
|
692
|
-
type="button"
|
|
693
|
-
></button>
|
|
694
|
-
}
|
|
695
|
-
</div>
|
|
696
|
-
}
|
|
697
|
-
<div class="k-list-scroller k-selectable">
|
|
698
|
-
<div class="{{ listClasses }}">
|
|
699
|
-
@if (data.length > 0) {
|
|
700
|
-
<div
|
|
701
|
-
class="k-list-content"
|
|
702
|
-
>
|
|
703
|
-
<ul
|
|
704
|
-
#listbox
|
|
705
|
-
class="k-list-ul"
|
|
706
|
-
role="listbox"
|
|
707
|
-
[attr.aria-label]="listboxLabel"
|
|
708
|
-
[attr.aria-multiselectable]="selectable === 'multiple'"
|
|
709
|
-
>
|
|
710
|
-
@for (item of data; track item; let i = $index) {
|
|
711
|
-
<li
|
|
712
|
-
#listboxItems
|
|
713
|
-
kendoListBoxItemSelectable
|
|
714
|
-
class="k-list-item"
|
|
715
|
-
[attr.tabindex]="i === keyboardNavigationService.focusedListboxItemIndex ? '0' : '-1'"
|
|
716
|
-
role="option"
|
|
717
|
-
[attr.aria-selected]="selectedIndices.indexOf(i) >= 0"
|
|
718
|
-
[index]="i"
|
|
719
|
-
[class.k-disabled]="itemDisabled(item)"
|
|
720
|
-
[attr.aria-disabled]="itemDisabled(item)"
|
|
721
|
-
>
|
|
722
|
-
@if (itemTemplate) {
|
|
723
|
-
<ng-template
|
|
724
|
-
[templateContext]="{
|
|
725
|
-
templateRef: itemTemplate.templateRef,
|
|
726
|
-
$implicit: item
|
|
727
|
-
}"
|
|
728
|
-
>
|
|
729
|
-
</ng-template>
|
|
730
|
-
} @else {
|
|
731
|
-
<span class="k-list-item-text">{{ getText(item) }}</span>
|
|
732
|
-
}
|
|
733
|
-
</li>
|
|
734
|
-
}
|
|
735
|
-
</ul>
|
|
736
|
-
</div>
|
|
737
|
-
}
|
|
738
|
-
@if (data.length === 0) {
|
|
739
|
-
<span
|
|
740
|
-
class="k-nodata"
|
|
741
|
-
>{{ messageFor('noDataText') }}</span>
|
|
742
|
-
}
|
|
743
|
-
</div>
|
|
744
|
-
</div>
|
|
745
|
-
`,
|
|
746
|
-
standalone: true,
|
|
747
|
-
imports: [LocalizedMessagesDirective, ButtonComponent, ItemSelectableDirective, TemplateContextDirective]
|
|
748
|
-
}]
|
|
749
|
-
}], ctorParameters: () => [{ type: i1.KeyboardNavigationService }, { type: i2.ListBoxSelectionService }, { type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.NgZone }, { type: i3.LocalizationService }, { type: i0.ChangeDetectorRef }], propDecorators: { listboxClassName: [{
|
|
750
|
-
type: HostBinding,
|
|
751
|
-
args: ['class.k-listbox']
|
|
752
|
-
}], direction: [{
|
|
753
|
-
type: HostBinding,
|
|
754
|
-
args: ['attr.dir']
|
|
755
|
-
}], itemTemplate: [{
|
|
756
|
-
type: ContentChild,
|
|
757
|
-
args: [ItemTemplateDirective]
|
|
758
|
-
}], listboxElement: [{
|
|
759
|
-
type: ViewChild,
|
|
760
|
-
args: ['listbox']
|
|
761
|
-
}], listboxItems: [{
|
|
762
|
-
type: ViewChildren,
|
|
763
|
-
args: ['listboxItems']
|
|
764
|
-
}], toolbarElement: [{
|
|
765
|
-
type: ViewChild,
|
|
766
|
-
args: ['toolbar']
|
|
767
|
-
}], tools: [{
|
|
768
|
-
type: ViewChildren,
|
|
769
|
-
args: ['tools']
|
|
770
|
-
}], textField: [{
|
|
771
|
-
type: Input
|
|
772
|
-
}], selectable: [{
|
|
773
|
-
type: Input
|
|
774
|
-
}], data: [{
|
|
775
|
-
type: Input
|
|
776
|
-
}], size: [{
|
|
777
|
-
type: Input
|
|
778
|
-
}], toolbar: [{
|
|
779
|
-
type: Input
|
|
780
|
-
}], listboxLabel: [{
|
|
781
|
-
type: Input
|
|
782
|
-
}], listboxToolbarLabel: [{
|
|
783
|
-
type: Input
|
|
784
|
-
}], itemDisabled: [{
|
|
785
|
-
type: Input
|
|
786
|
-
}], selectionChange: [{
|
|
787
|
-
type: Output
|
|
788
|
-
}], action: [{
|
|
789
|
-
type: Output
|
|
790
|
-
}], getChildListbox: [{
|
|
791
|
-
type: Output
|
|
792
|
-
}] } });
|